aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-10-25 07:17:54 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-10-25 07:17:54 +0000
commit749d0bd1eb364a5efc52d2f0a0b4b7731c9332ba (patch)
tree9b3c627281eba34f2e6447dfb63cd1dae90b3bd7
parentd8bb0c2d9a035c9ce315877b18a12ba5df9113b5 (diff)
match the output header for printing to the message view.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@679 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog9
-rw-r--r--ChangeLog.ja9
-rw-r--r--libsylph/Makefile.am1
-rw-r--r--libsylph/displayheader.c (renamed from src/displayheader.c)24
-rw-r--r--libsylph/displayheader.h37
-rw-r--r--libsylph/procheader.c47
-rw-r--r--libsylph/procheader.h3
-rw-r--r--libsylph/procmsg.c63
-rw-r--r--src/Makefile.am1
-rw-r--r--src/displayheader.h37
-rw-r--r--src/textview.c49
11 files changed, 169 insertions, 111 deletions
diff --git a/ChangeLog b/ChangeLog
index 10e1d8d6..b4d6c79a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-10-25
+
+ * libsylph/procmsg.c: procmsg_print_message(): match the output
+ headers to the message view.
+ * libsylph/procheader.[ch]: procheader_get_header_array_for_display():
+ added.
+ * libsylph/displayheader.[ch]: moved from src/.
+ * src/textview.c: textview_show_header(): code cleanup.
+
2005-10-24
* src/inputdialog.c: win32: make dialog in front on focus out.
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 17467bbd..758def46 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,12 @@
+2005-10-25
+
+ * libsylph/procmsg.c: procmsg_print_message(): 出力するヘッダを
+ メッセージビューに合わせた。
+ * libsylph/procheader.[ch]: procheader_get_header_array_for_display():
+ 追加。
+ * libsylph/displayheader.[ch]: src/ から移動。
+ * src/textview.c: textview_show_header(): コードの整理。
+
2005-10-24
* src/inputdialog.c: win32: focus out のときダイアログを前面にもって
diff --git a/libsylph/Makefile.am b/libsylph/Makefile.am
index f42d18a2..64c37b07 100644
--- a/libsylph/Makefile.am
+++ b/libsylph/Makefile.am
@@ -15,6 +15,7 @@ libsylph_la_SOURCES = \
base64.c base64.h \
codeconv.c codeconv.h \
customheader.c customheader.h \
+ displayheader.c displayheader.h \
filter.c filter.h \
folder.c folder.h \
html.c html.h \
diff --git a/src/displayheader.c b/libsylph/displayheader.c
index 1db374cd..edafc5a7 100644
--- a/src/displayheader.c
+++ b/libsylph/displayheader.c
@@ -1,20 +1,20 @@
/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ * LibSylph -- E-Mail client library
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
diff --git a/libsylph/displayheader.h b/libsylph/displayheader.h
new file mode 100644
index 00000000..4ca8e185
--- /dev/null
+++ b/libsylph/displayheader.h
@@ -0,0 +1,37 @@
+/*
+ * LibSylph -- E-Mail client library
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __DISPLAYHEADER_H__
+#define __DISPLAYHEADER_H__
+
+#include <glib.h>
+
+typedef struct _DisplayHeaderProp DisplayHeaderProp;
+
+struct _DisplayHeaderProp
+{
+ gchar *name;
+ gboolean hidden;
+};
+
+gchar *display_header_prop_get_str (DisplayHeaderProp *dp);
+DisplayHeaderProp *display_header_prop_read_str (gchar *buf);
+void display_header_prop_free (DisplayHeaderProp *dp);
+
+#endif /* __DISPLAYHEADER_H__ */
diff --git a/libsylph/procheader.c b/libsylph/procheader.c
index c972a83f..e175a8d6 100644
--- a/libsylph/procheader.c
+++ b/libsylph/procheader.c
@@ -32,6 +32,7 @@
#include "procheader.h"
#include "procmsg.h"
#include "codeconv.h"
+#include "displayheader.h"
#include "prefs_common.h"
#include "utils.h"
@@ -354,6 +355,52 @@ GPtrArray *procheader_get_header_array_asis(FILE *fp, const gchar *encoding)
return headers;
}
+GPtrArray *procheader_get_header_array_for_display(FILE *fp,
+ const gchar *encoding)
+{
+ GPtrArray *headers, *sorted_headers;
+ GSList *disphdr_list;
+ Header *header;
+ gint i;
+
+ g_return_val_if_fail(fp != NULL, NULL);
+
+ headers = procheader_get_header_array_asis(fp, encoding);
+
+ sorted_headers = g_ptr_array_new();
+
+ for (disphdr_list = prefs_common.disphdr_list; disphdr_list != NULL;
+ disphdr_list = disphdr_list->next) {
+ DisplayHeaderProp *dp =
+ (DisplayHeaderProp *)disphdr_list->data;
+
+ for (i = 0; i < headers->len; i++) {
+ header = g_ptr_array_index(headers, i);
+
+ if (!g_ascii_strcasecmp(header->name, dp->name)) {
+ if (dp->hidden)
+ procheader_header_free(header);
+ else
+ g_ptr_array_add(sorted_headers, header);
+
+ g_ptr_array_remove_index(headers, i);
+ i--;
+ }
+ }
+ }
+
+ if (prefs_common.show_other_header) {
+ for (i = 0; i < headers->len; i++) {
+ header = g_ptr_array_index(headers, i);
+ g_ptr_array_add(sorted_headers, header);
+ }
+ g_ptr_array_free(headers, TRUE);
+ } else
+ procheader_header_array_destroy(headers);
+
+ return sorted_headers;
+}
+
void procheader_header_list_destroy(GSList *hlist)
{
Header *header;
diff --git a/libsylph/procheader.h b/libsylph/procheader.h
index 532d21c5..d6c0a488 100644
--- a/libsylph/procheader.h
+++ b/libsylph/procheader.h
@@ -65,6 +65,9 @@ GPtrArray *procheader_get_header_array (FILE *fp,
const gchar *encoding);
GPtrArray *procheader_get_header_array_asis (FILE *fp,
const gchar *encoding);
+GPtrArray *procheader_get_header_array_for_display
+ (FILE *fp,
+ const gchar *encoding);
void procheader_header_array_destroy (GPtrArray *harray);
void procheader_header_free (Header *header);
diff --git a/libsylph/procmsg.c b/libsylph/procmsg.c
index 0dae602d..344b43f1 100644
--- a/libsylph/procmsg.c
+++ b/libsylph/procmsg.c
@@ -1153,15 +1153,17 @@ void procmsg_print_message(MsgInfo *msginfo, const gchar *cmdline)
static const gchar *def_cmd = "lpr %s";
static guint id = 0;
gchar *prtmp;
- FILE *tmpfp, *prfp;
+ FILE *msgfp, *tmpfp, *prfp;
+ GPtrArray *headers;
+ gint i;
gchar buf[1024];
gchar *p;
- g_return_if_fail(msginfo);
+ g_return_if_fail(msginfo != NULL);
if ((tmpfp = procmime_get_first_text_content
(msginfo, conv_get_locale_charset_str())) == NULL) {
- g_warning(_("Can't get text part\n"));
+ g_warning("Can't get text part\n");
return;
}
@@ -1175,23 +1177,50 @@ void procmsg_print_message(MsgInfo *msginfo, const gchar *cmdline)
return;
}
-#define OUTPUT_HEADER(s, fmt) \
- if (s) { \
- gchar *locale_str; \
- locale_str = conv_codeset_strdup \
- (s, CS_INTERNAL, conv_get_locale_charset_str()); \
- fprintf(prfp, fmt, locale_str ? locale_str : s); \
- g_free(locale_str); \
+ if ((msgfp = procmsg_open_message(msginfo)) == NULL) {
+ fclose(prfp);
+ g_free(prtmp);
+ fclose(tmpfp);
+ return;
}
- OUTPUT_HEADER(msginfo->date, "Date: %s\n");
- OUTPUT_HEADER(msginfo->from, "From: %s\n");
- OUTPUT_HEADER(msginfo->to, "To: %s\n");
- OUTPUT_HEADER(msginfo->newsgroups, "Newsgroups: %s\n");
- OUTPUT_HEADER(msginfo->subject, "Subject: %s\n");
- fputc('\n', prfp);
+ headers = procheader_get_header_array_for_display(msgfp, NULL);
+ fclose(msgfp);
+
+ for (i = 0; i < headers->len; i++) {
+ Header *hdr;
+ gchar *locale_str;
+ const gchar *body;
+
+ hdr = g_ptr_array_index(headers, i);
+
+ if (!g_ascii_strcasecmp(hdr->name, "Subject"))
+ body = msginfo->subject;
+ else if (!g_ascii_strcasecmp(hdr->name, "From"))
+ body = msginfo->from;
+ else if (!g_ascii_strcasecmp(hdr->name, "To"))
+ body = msginfo->to;
+ else if (!g_ascii_strcasecmp(hdr->name, "Cc")) {
+ unfold_line(hdr->body);
+ body = hdr->body;
+ while (g_ascii_isspace(*body))
+ body++;
+ } else {
+ body = hdr->body;
+ while (g_ascii_isspace(*body))
+ body++;
+ }
+
+ locale_str = conv_codeset_strdup
+ (body, CS_INTERNAL, conv_get_locale_charset_str());
+ fprintf(prfp, "%s: %s\n", hdr->name,
+ locale_str ? locale_str : body);
+ g_free(locale_str);
+ }
-#undef OUTPUT_HEADER
+ procheader_header_array_destroy(headers);
+
+ fputc('\n', prfp);
while (fgets(buf, sizeof(buf), tmpfp) != NULL)
fputs(buf, prfp);
diff --git a/src/Makefile.am b/src/Makefile.am
index 70445ac2..c3fafdb4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,7 +33,6 @@ sylpheed_SOURCES = \
prefs_template.c prefs_template.h \
prefs_actions.c prefs_actions.h \
account_dialog.c account_dialog.h \
- displayheader.c displayheader.h \
template.c template.h \
addressbook.c addressbook.h \
addr_compl.c addr_compl.h \
diff --git a/src/displayheader.h b/src/displayheader.h
deleted file mode 100644
index e7baa2be..00000000
--- a/src/displayheader.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __DISPLAYHEADER_H__
-#define __DISPLAYHEADER_H__
-
-#include <glib.h>
-
-typedef struct _DisplayHeaderProp DisplayHeaderProp;
-
-struct _DisplayHeaderProp
-{
- gchar *name;
- gboolean hidden;
-};
-
-gchar *display_header_prop_get_str (DisplayHeaderProp *dp);
-DisplayHeaderProp *display_header_prop_read_str (gchar *buf);
-void display_header_prop_free (DisplayHeaderProp *dp);
-
-#endif /* __DISPLAYHEADER_H__ */
diff --git a/src/textview.c b/src/textview.c
index 4463d199..3fa4557c 100644
--- a/src/textview.c
+++ b/src/textview.c
@@ -1235,58 +1235,20 @@ void textview_set_position(TextView *textview, gint pos)
static GPtrArray *textview_scan_header(TextView *textview, FILE *fp,
const gchar *encoding)
{
- gchar buf[BUFFSIZE];
- GPtrArray *headers, *sorted_headers;
- GSList *disphdr_list;
- Header *header;
- gint i;
-
g_return_val_if_fail(fp != NULL, NULL);
if (textview->show_all_headers)
return procheader_get_header_array_asis(fp, encoding);
if (!prefs_common.display_header) {
+ gchar buf[BUFFSIZE];
+
while (fgets(buf, sizeof(buf), fp) != NULL)
if (buf[0] == '\r' || buf[0] == '\n') break;
return NULL;
}
- headers = procheader_get_header_array_asis(fp, encoding);
-
- sorted_headers = g_ptr_array_new();
-
- for (disphdr_list = prefs_common.disphdr_list; disphdr_list != NULL;
- disphdr_list = disphdr_list->next) {
- DisplayHeaderProp *dp =
- (DisplayHeaderProp *)disphdr_list->data;
-
- for (i = 0; i < headers->len; i++) {
- header = g_ptr_array_index(headers, i);
-
- if (!g_ascii_strcasecmp(header->name, dp->name)) {
- if (dp->hidden)
- procheader_header_free(header);
- else
- g_ptr_array_add(sorted_headers, header);
-
- g_ptr_array_remove_index(headers, i);
- i--;
- }
- }
- }
-
- if (prefs_common.show_other_header) {
- for (i = 0; i < headers->len; i++) {
- header = g_ptr_array_index(headers, i);
- g_ptr_array_add(sorted_headers, header);
- }
- g_ptr_array_free(headers, TRUE);
- } else
- procheader_header_array_destroy(headers);
-
-
- return sorted_headers;
+ return procheader_get_header_array_for_display(fp, encoding);
}
static void textview_show_header(TextView *textview, GPtrArray *headers)
@@ -1300,12 +1262,12 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
g_return_if_fail(headers != NULL);
buffer = gtk_text_view_get_buffer(text);
+ gtk_text_buffer_get_end_iter(buffer, &iter);
for (i = 0; i < headers->len; i++) {
header = g_ptr_array_index(headers, i);
g_return_if_fail(header->name != NULL);
- gtk_text_buffer_get_end_iter(buffer, &iter);
gtk_text_buffer_insert_with_tags_by_name
(buffer, &iter, header->name, -1,
"header_title", "header", NULL);
@@ -1323,7 +1285,6 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
(!strncmp(header->name, "X-Mailer", 8) ||
!strncmp(header->name, "X-Newsreader", 12)) &&
strstr(header->body, "Sylpheed") != NULL) {
- gtk_text_buffer_get_end_iter(buffer, &iter);
gtk_text_buffer_insert_with_tags_by_name
(buffer, &iter, header->body, -1,
"header", "emphasis", NULL);
@@ -1334,7 +1295,7 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
textview_make_clickable_parts
(textview, "header", NULL, header->body);
}
- gtk_text_buffer_get_end_iter(buffer, &iter); //
+ gtk_text_buffer_get_end_iter(buffer, &iter);
gtk_text_buffer_insert_with_tags_by_name
(buffer, &iter, "\n", 1, "header", NULL);
}