diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-10-25 07:17:54 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-10-25 07:17:54 +0000 |
commit | 749d0bd1eb364a5efc52d2f0a0b4b7731c9332ba (patch) | |
tree | 9b3c627281eba34f2e6447dfb63cd1dae90b3bd7 /libsylph/procmsg.c | |
parent | d8bb0c2d9a035c9ce315877b18a12ba5df9113b5 (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
Diffstat (limited to 'libsylph/procmsg.c')
-rw-r--r-- | libsylph/procmsg.c | 63 |
1 files changed, 46 insertions, 17 deletions
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); |