diff options
-rw-r--r-- | mail/ChangeLog | 6 | ||||
-rw-r--r-- | mail/em-format-html.c | 55 |
2 files changed, 57 insertions, 4 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 8d65314210..43b9e1a620 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,11 @@ 2004-01-16 Jeffrey Stedfast <fejj@ximian.com> + * em-format-html.c (efh_format_address): Dump a struct + _camel_header_address to an html string. + (efh_format_header): Use efh_format_address() and set the + EM_FORMAT_HTML_HEADER_HTML bit on the flags so we don't re-convert + our html string into html. + * mail-vfolder.c (mail_vfolder_rename_uri): s/g_fre/g_free/ * em-utils.c (guess_account): Change 'tmp' to not be const - fixes diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 482b0191d5..edd7c25730 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -1454,6 +1454,50 @@ static char *i18n_hdrs[] = { #endif static void +efh_format_address (GString *out, struct _camel_header_address *a) +{ + guint32 flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES; + char *name, *mailto, *addr; + + while (a) { + if (a->name) + name = camel_text_to_html (a->name, flags, 0); + else + name = NULL; + + switch (a->type) { + case CAMEL_HEADER_ADDRESS_NAME: + if (name && *name) + g_string_append_printf (out, "%s <", name); + + mailto = camel_url_encode (a->v.addr, ""); + addr = camel_text_to_html (a->v.addr, flags, 0); + g_string_append_printf (out, "<a href=\"mailto:%s\">%s</a>", mailto, addr); + g_free (mailto); + g_free (addr); + + if (name && *name) + g_string_append (out, ">"); + break; + case CAMEL_HEADER_ADDRESS_GROUP: + g_string_append_printf (out, "%s: ", name); + efh_format_address (out, a->v.members); + g_string_append_printf (out, ";"); + break; + default: + g_warning ("Invalid address type"); + break; + } + + g_free (name); + + a = a->next; + if (a) + g_string_append (out, ", "); + } +} + +static void efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, const char *namein, guint32 flags, const char *charset) { CamelMimeMessage *msg = (CamelMimeMessage *) part; @@ -1475,6 +1519,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, const c if (addrspec) { struct _camel_header_address *addrs; + GString *html; if (!(txt = camel_medium_get_header (part, name))) return; @@ -1495,11 +1540,13 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, const c label = _(name); - if ((value = camel_header_address_list_format (addrs))) - txt = value; - - flags |= EM_FORMAT_HEADER_BOLD; + html = g_string_new (""); + efh_format_address (html, addrs); camel_header_address_unref (addrs); + txt = value = html->str; + g_string_free (html, FALSE); + + flags |= EM_FORMAT_HEADER_BOLD | EM_FORMAT_HTML_HEADER_HTML; } else if (!strcmp (name, "subject")) { txt = camel_mime_message_get_subject (msg); label = _("Subject"); |