diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-08-12 02:07:44 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-08-12 02:07:44 +0800 |
commit | 6ccafb45ae1b0469fea2ebf5e74548f9fa0d1f33 (patch) | |
tree | dc0d9c14c93f61eee7119ce6ec466aaaa2e39a98 | |
parent | 15aaf53b7dc1a328f28d402f74186b993ac39eec (diff) | |
download | gsoc2013-evolution-6ccafb45ae1b0469fea2ebf5e74548f9fa0d1f33.tar gsoc2013-evolution-6ccafb45ae1b0469fea2ebf5e74548f9fa0d1f33.tar.gz gsoc2013-evolution-6ccafb45ae1b0469fea2ebf5e74548f9fa0d1f33.tar.bz2 gsoc2013-evolution-6ccafb45ae1b0469fea2ebf5e74548f9fa0d1f33.tar.lz gsoc2013-evolution-6ccafb45ae1b0469fea2ebf5e74548f9fa0d1f33.tar.xz gsoc2013-evolution-6ccafb45ae1b0469fea2ebf5e74548f9fa0d1f33.tar.zst gsoc2013-evolution-6ccafb45ae1b0469fea2ebf5e74548f9fa0d1f33.zip |
Updated for CamelMimePart::content_type changes.
2003-08-05 Jeffrey Stedfast <fejj@ximian.com>
* mail-format.c (handle_multipart_encrypted): Updated for
CamelMimePart::content_type changes.
* mail-ops.c (save_part_save): Use
camel_data_wrapper_decode_to_stream() here.
* mail-display.c (drag_data_get_cb): Updated for
CamelMimePart::content_type changes.
(do_attachment_header): Same.
2003-07-31 Jeffrey Stedfast <fejj@ximian.com>
* mail-format.c (mail_format_raw_message): Updated to pass FALSE
as the 'decode' param to
mail_format_data_wrapper_write_to_stream().
(mail_format_data_wrapper_write_to_stream): Now takes a boolean
arg telling whether to decode or not. Also reworked the charset
logic now that camel doesn't handle this for us any longer.
(mail_format_get_data_wrapper_text): Updated.
(handle_text_plain): Same.
(handle_text_enriched): Here too.
* mail-display.c (do_attachment_header): Call decode_to_stream
here instead of write_to_stream.
(do_external_viewer): Same.
(on_url_requested): Same. Also updated for
mail_format_data_wrapper_write_to_stream().
(try_part_urls): Call decode_to_stream.
(drag_data_get_cb): Same.
svn path=/trunk/; revision=22173
-rw-r--r-- | mail/ChangeLog | 32 | ||||
-rw-r--r-- | mail/mail-display.c | 24 | ||||
-rw-r--r-- | mail/mail-format.c | 118 | ||||
-rw-r--r-- | mail/mail-format.h | 1 | ||||
-rw-r--r-- | mail/mail-ops.c | 2 |
5 files changed, 109 insertions, 68 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 6a9eceffdd..31c70606f5 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,35 @@ +2003-08-05 Jeffrey Stedfast <fejj@ximian.com> + + * mail-format.c (handle_multipart_encrypted): Updated for + CamelMimePart::content_type changes. + + * mail-ops.c (save_part_save): Use + camel_data_wrapper_decode_to_stream() here. + + * mail-display.c (drag_data_get_cb): Updated for + CamelMimePart::content_type changes. + (do_attachment_header): Same. + +2003-07-31 Jeffrey Stedfast <fejj@ximian.com> + + * mail-format.c (mail_format_raw_message): Updated to pass FALSE + as the 'decode' param to + mail_format_data_wrapper_write_to_stream(). + (mail_format_data_wrapper_write_to_stream): Now takes a boolean + arg telling whether to decode or not. Also reworked the charset + logic now that camel doesn't handle this for us any longer. + (mail_format_get_data_wrapper_text): Updated. + (handle_text_plain): Same. + (handle_text_enriched): Here too. + + * mail-display.c (do_attachment_header): Call decode_to_stream + here instead of write_to_stream. + (do_external_viewer): Same. + (on_url_requested): Same. Also updated for + mail_format_data_wrapper_write_to_stream(). + (try_part_urls): Call decode_to_stream. + (drag_data_get_cb): Same. + 2003-08-05 Not Zed <NotZed@Ximian.com> ** See bug #47224. Hook onto clicked rather than button_pressed, diff --git a/mail/mail-display.c b/mail/mail-display.c index 9654d9b198..35ab41c273 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -1056,7 +1056,7 @@ drag_data_get_cb (GtkWidget *widget, g_object_set_data_full ((GObject *) widget, "uri-list", uri_list, g_free); break; case DND_TARGET_TYPE_PART_MIME_TYPE: - if (header_content_type_is (part->content_type, "text", "*")) { + if (header_content_type_is (((CamelDataWrapper *) part)->mime_type, "text", "*")) { GByteArray *ba; ba = mail_format_get_data_wrapper_text ((CamelDataWrapper *) part, NULL); @@ -1067,16 +1067,16 @@ drag_data_get_cb (GtkWidget *widget, } } else { CamelDataWrapper *wrapper; - CamelStreamMem *cstream; + CamelStreamMem *mem; - cstream = (CamelStreamMem *) camel_stream_mem_new (); + mem = (CamelStreamMem *) camel_stream_mem_new (); wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - camel_data_wrapper_write_to_stream (wrapper, (CamelStream *)cstream); + camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) mem); gtk_selection_data_set (selection_data, selection_data->target, 8, - cstream->buffer->data, cstream->buffer->len); + mem->buffer->data, mem->buffer->len); - camel_object_unref (cstream); + camel_object_unref (mem); } break; default: @@ -1120,7 +1120,7 @@ do_attachment_header (GtkHTML *html, GtkHTMLEmbedded *eb, content = camel_medium_get_content_object (CAMEL_MEDIUM (part)); if (!camel_data_wrapper_is_offline (content)) { pbl->mstream = camel_stream_mem_new (); - camel_data_wrapper_write_to_stream (content, pbl->mstream); + camel_data_wrapper_decode_to_stream (content, pbl->mstream); camel_stream_reset (pbl->mstream); } } @@ -1149,7 +1149,7 @@ do_attachment_header (GtkHTML *html, GtkHTMLEmbedded *eb, } /* Drag & Drop */ - drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target = header_content_type_simple (part->content_type); + drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target = header_content_type_simple (((CamelDataWrapper *) part)->mime_type); camel_strdown (drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target); gtk_drag_source_set (button, GDK_BUTTON1_MASK, @@ -1245,7 +1245,7 @@ do_external_viewer (GtkHTML *html, GtkHTMLEmbedded *eb, /* Write the data to a CamelStreamMem... */ cstream = (CamelStreamMem *) camel_stream_mem_new (); wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - camel_data_wrapper_write_to_stream (wrapper, (CamelStream *)cstream); + camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *)cstream); /* ...convert the CamelStreamMem to a BonoboStreamMem... */ bstream = bonobo_stream_mem_create (cstream->buffer->data, cstream->buffer->len, TRUE, FALSE); @@ -1390,9 +1390,9 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle, html_stream = mail_display_stream_new (html, handle); if (header_content_type_is (content_type, "text", "*")) { - mail_format_data_wrapper_write_to_stream (wrapper, md, html_stream); + mail_format_data_wrapper_write_to_stream (wrapper, TRUE, md, html_stream); } else { - camel_data_wrapper_write_to_stream (wrapper, html_stream); + camel_data_wrapper_decode_to_stream (wrapper, html_stream); } camel_object_unref (html_stream); @@ -1693,7 +1693,7 @@ try_part_urls (struct _load_content_msg *m) } html_stream = mail_display_stream_new (m->html, m->handle); - camel_data_wrapper_write_to_stream (data, html_stream); + camel_data_wrapper_decode_to_stream (data, html_stream); camel_object_unref (html_stream); gtk_html_end (m->html, m->handle, GTK_HTML_STREAM_OK); diff --git a/mail/mail-format.c b/mail/mail-format.c index 1ee1223d46..b77f9316b1 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -45,6 +45,7 @@ #include <camel/camel-multipart-signed.h> #include <camel/camel-mime-filter-enriched.h> #include <camel/camel-mime-filter-tohtml.h> +#include <camel/camel-mime-filter-windows.h> #include <e-util/e-trie.h> @@ -193,7 +194,7 @@ mail_format_raw_message (CamelMimeMessage *mime_message, MailDisplay *md, camel_stream_write_string ((CamelStream *) stream, STANDARD_ISSUE_TABLE_OPEN "<tr><td><tt>"); - mail_format_data_wrapper_write_to_stream (wrapper, md, (CamelStream *) filtered_stream); + mail_format_data_wrapper_write_to_stream (wrapper, FALSE, md, (CamelStream *) filtered_stream); camel_object_unref (filtered_stream); camel_stream_write_string ((CamelStream *) stream, "</tt></td></tr></table>"); @@ -1117,67 +1118,74 @@ mail_content_loaded (CamelDataWrapper *wrapper, MailDisplay *md, gboolean redisp ssize_t -mail_format_data_wrapper_write_to_stream (CamelDataWrapper *wrapper, MailDisplay *mail_display, CamelStream *stream) +mail_format_data_wrapper_write_to_stream (CamelDataWrapper *wrapper, gboolean decode, MailDisplay *mail_display, CamelStream *stream) { - CamelStreamFilter *filtered_stream; - ssize_t written; + CamelStreamFilter *filter_stream; + CamelMimeFilterCharset *filter; + CamelContentType *content_type; + GConfClient *gconf; + ssize_t nwritten; + char *charset; - filtered_stream = camel_stream_filter_new_with_stream (stream); + gconf = mail_config_get_gconf_client (); - if (wrapper->rawtext || (mail_display && mail_display->charset)) { - CamelMimeFilterCharset *filter; - CamelContentType *content_type; - GConfClient *gconf; - char *charset; - - gconf = mail_config_get_gconf_client (); - - content_type = camel_data_wrapper_get_mime_type_field (wrapper); - - if (!wrapper->rawtext) { - /* data wrapper had been successfully converted to UTF-8 using the mime - part's charset, but the user thinks he knows best so we'll let him - shoot himself in the foot here... */ + content_type = camel_data_wrapper_get_mime_type_field (wrapper); + + /* find out the charset the user wants to override to */ + if (mail_display && mail_display->charset) { + /* user override charset */ + charset = g_strdup (mail_display->charset); + } else if (content_type && (charset = (char *) header_content_type_param (content_type, "charset"))) { + /* try to use the charset declared in the Content-Type header */ + if (!strncasecmp (charset, "iso-8859-", 9)) { + /* Since a few Windows mailers like to claim they sent + * out iso-8859-# encoded text when they really sent + * out windows-cp125#, do some simple sanity checking + * before we move on... */ + CamelMimeFilterWindows *windows; + CamelStream *null; - /* get the original charset of the mime part */ - charset = (char *) (content_type ? header_content_type_param (content_type, "charset") : NULL); - if (!charset) - charset = gconf_client_get_string (gconf, "/apps/evolution/mail/format/charset", NULL); - else - charset = g_strdup (charset); + null = camel_stream_null_new (); + filter_stream = camel_stream_filter_new_with_stream (null); + camel_object_unref (null); - /* since the content is already in UTF-8, we need to decode into the - original charset before we can convert back to UTF-8 using the charset - the user is overriding with... */ - if ((filter = camel_mime_filter_charset_new_convert ("utf-8", charset))) { - camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (filter)); - camel_object_unref (filter); - } + windows = (CamelMimeFilterWindows *) camel_mime_filter_windows_new (charset); + camel_stream_filter_add (filter_stream, (CamelMimeFilter *) windows); - g_free (charset); - } - - /* find out the charset the user wants to override to */ - if (mail_display && mail_display->charset) - charset = g_strdup (mail_display->charset); - else if (content_type && (charset = (char *) header_content_type_param (content_type, "charset"))) + if (decode) + camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) filter_stream); + else + camel_data_wrapper_write_to_stream (wrapper, (CamelStream *) filter_stream); + camel_stream_flush ((CamelStream *) filter_stream); + camel_object_unref (filter_stream); + + charset = g_strdup (camel_mime_filter_windows_real_charset (windows)); + camel_object_unref (windows); + } else { charset = g_strdup (charset); - else - charset = gconf_client_get_string (gconf, "/apps/evolution/mail/format/charset", NULL); - - if ((filter = camel_mime_filter_charset_new_convert (charset, "utf-8"))) { - camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (filter)); - camel_object_unref (filter); } - - g_free (charset); + } else { + /* default to user's locale charset? */ + charset = gconf_client_get_string (gconf, "/apps/evolution/mail/format/charset", NULL); } - written = camel_data_wrapper_write_to_stream (wrapper, CAMEL_STREAM (filtered_stream)); - camel_stream_flush (CAMEL_STREAM (filtered_stream)); - camel_object_unref (filtered_stream); + filter_stream = camel_stream_filter_new_with_stream (stream); + + if ((filter = camel_mime_filter_charset_new_convert (charset, "UTF-8"))) { + camel_stream_filter_add (filter_stream, (CamelMimeFilter *) filter); + camel_object_unref (filter); + } + + g_free (charset); + + if (decode) + nwritten = camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) filter_stream); + else + nwritten = camel_data_wrapper_write_to_stream (wrapper, (CamelStream *) filter_stream); + camel_stream_flush ((CamelStream *) filter_stream); + camel_object_unref (filter_stream); - return written; + return nwritten; } /* Return the contents of a data wrapper, or %NULL if it contains only @@ -1194,7 +1202,7 @@ mail_format_get_data_wrapper_text (CamelDataWrapper *wrapper, MailDisplay *mail_ ba = g_byte_array_new (); camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (memstream), ba); - mail_format_data_wrapper_write_to_stream (wrapper, mail_display, memstream); + mail_format_data_wrapper_write_to_stream (wrapper, TRUE, mail_display, memstream); camel_object_unref (memstream); for (text = ba->data, end = text + ba->len; text < end; text++) { @@ -1269,7 +1277,7 @@ handle_text_plain (CamelMimePart *part, const char *mime_type, camel_stream_write_string ((CamelStream *) stream, STANDARD_ISSUE_TABLE_OPEN "<tr><td><tt>\n"); wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - mail_format_data_wrapper_write_to_stream (wrapper, md, (CamelStream *) filtered_stream); + mail_format_data_wrapper_write_to_stream (wrapper, TRUE, md, (CamelStream *) filtered_stream); camel_stream_write_string ((CamelStream *) stream, "</tt></td></tr></table>\n"); @@ -1304,7 +1312,7 @@ handle_text_enriched (CamelMimePart *part, const char *mime_type, camel_stream_write_string ((CamelStream *) stream, STANDARD_ISSUE_TABLE_OPEN "<tr><td><tt>\n"); wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - mail_format_data_wrapper_write_to_stream (wrapper, md, (CamelStream *) filtered_stream); + mail_format_data_wrapper_write_to_stream (wrapper, TRUE, md, (CamelStream *) filtered_stream); camel_stream_write_string ((CamelStream *) stream, "</tt></td></tr></table>\n"); camel_object_unref (filtered_stream); @@ -1400,7 +1408,7 @@ handle_multipart_encrypted (CamelMimePart *part, const char *mime_type, gboolean handled; /* Currently we only handle RFC2015-style PGP encryption. */ - protocol = header_content_type_param (part->content_type, "protocol"); + protocol = header_content_type_param (((CamelDataWrapper *) part)->mime_type, "protocol"); if (!protocol || strcmp (protocol, "application/pgp-encrypted") != 0) return handle_multipart_mixed (part, mime_type, md, stream); diff --git a/mail/mail-format.h b/mail/mail-format.h index 2bc9016879..e39148ca83 100644 --- a/mail/mail-format.h +++ b/mail/mail-format.h @@ -34,6 +34,7 @@ GByteArray *mail_format_get_data_wrapper_text (CamelDataWrapper *data, MailDisplay *mail_display); ssize_t mail_format_data_wrapper_write_to_stream (CamelDataWrapper *wrapper, + gboolean decode, MailDisplay *mail_display, CamelStream *stream); diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 7a40e99c83..ecd56c60ed 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -2077,7 +2077,7 @@ save_part_save (struct _mail_msg *mm) filtered_stream = stream_fs; } - if (camel_data_wrapper_write_to_stream (data, filtered_stream) == -1 + if (camel_data_wrapper_decode_to_stream (data, filtered_stream) == -1 || camel_stream_flush (filtered_stream) == -1) camel_exception_setv (&mm->ex, CAMEL_EXCEPTION_SYSTEM, _("Could not write data: %s"), |