diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-10-22 10:25:36 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-10-22 10:25:36 +0800 |
commit | b1c2896995bfe7bc680a80176976dbe9defea4a6 (patch) | |
tree | 8e4150d248762d850d8302459ea80cca0915165c /mail/mail-display.c | |
parent | e55790f58b0e9c30aa9cb766b607dab634fa9cf4 (diff) | |
download | gsoc2013-evolution-b1c2896995bfe7bc680a80176976dbe9defea4a6.tar.gz gsoc2013-evolution-b1c2896995bfe7bc680a80176976dbe9defea4a6.tar.zst gsoc2013-evolution-b1c2896995bfe7bc680a80176976dbe9defea4a6.zip |
Use mail_format_get_data_wrapper_text for text parts so we get free
2001-10-21 Jeffrey Stedfast <fejj@ximian.com>
* mail-display.c (on_url_requested): Use
mail_format_get_data_wrapper_text for text parts so we get free
charset conversion.
* mail-format.c (mail_format_get_data_wrapper_text): Renamed from
get_data_wrapper_text and now returns a GByteArray.
(handle_text_plain): Updated to use the new get_data_wrapper_text.
(handle_application_pgp): Same. Wow...also fixed a mem leak and
made a bit more efficient by doing so.
(handle_text_enriched): Here too. Also use string->len instead of
strlen (string->str).
(mail_format_raw_message): Same.
svn path=/trunk/; revision=13862
Diffstat (limited to 'mail/mail-display.c')
-rw-r--r-- | mail/mail-display.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/mail/mail-display.c b/mail/mail-display.c index a78ad34af1..3dbd12523c 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -1013,37 +1013,47 @@ ebook_callback (EBook *book, const gchar *addr, ECard *card, gpointer data) static void on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle, - gpointer user_data) + gpointer user_data) { MailDisplay *md = user_data; GHashTable *urls; CamelMedium *medium; GByteArray *ba; - + urls = g_datalist_get_data (md->data, "part_urls"); g_return_if_fail (urls != NULL); - + /* See if it refers to a MIME part (cid: or http:) */ medium = g_hash_table_lookup (urls, url); if (medium) { + CamelContentType *content_type; CamelDataWrapper *data; CamelStream *stream_mem; - + g_return_if_fail (CAMEL_IS_MEDIUM (medium)); - + data = camel_medium_get_content_object (medium); if (!mail_content_loaded (data, md, FALSE, url, handle)) return; - - ba = g_byte_array_new (); - stream_mem = camel_stream_mem_new_with_byte_array (ba); - camel_data_wrapper_write_to_stream (data, stream_mem); - /* printf ("-- begin --\n"); - printf (ba->data); - printf ("-- end --\n"); */ - gtk_html_write (html, handle, ba->data, ba->len); - camel_object_unref (CAMEL_OBJECT (stream_mem)); - + + content_type = camel_data_wrapper_get_mime_type_field (data); + + if (header_content_type_is (content_type, "text", "*")) { + ba = mail_format_get_data_wrapper_text (data, md); + } else { + ba = g_byte_array_new (); + stream_mem = camel_stream_mem_new (); + camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream_mem), ba); + camel_data_wrapper_write_to_stream (data, stream_mem); + camel_object_unref (CAMEL_OBJECT (stream_mem)); + } + + if (ba) { + gtk_html_write (html, handle, ba->data, ba->len); + + g_byte_array_free (ba, TRUE); + } + gtk_html_end (html, handle, GTK_HTML_STREAM_OK); return; } |