diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2004-01-17 01:29:27 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2004-01-17 01:29:27 +0800 |
commit | a2381f40392da6521e96806964aa5625af71bd16 (patch) | |
tree | e64c28fdff462683d21cbfa18b8692b4d6dbf8db /mail/em-format-html.c | |
parent | 13f513ef2a1a01ceaa857419e95040b04fa05e76 (diff) | |
download | gsoc2013-evolution-a2381f40392da6521e96806964aa5625af71bd16.tar.gz gsoc2013-evolution-a2381f40392da6521e96806964aa5625af71bd16.tar.zst gsoc2013-evolution-a2381f40392da6521e96806964aa5625af71bd16.zip |
Dump a struct _camel_header_address to an html string.
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.
svn path=/trunk/; revision=24280
Diffstat (limited to 'mail/em-format-html.c')
-rw-r--r-- | mail/em-format-html.c | 55 |
1 files changed, 51 insertions, 4 deletions
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"); |