diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-07-24 01:37:30 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-07-24 01:37:30 +0800 |
commit | c6a8e68892c642f071f3e9be7854c5bd386f8136 (patch) | |
tree | 3bfbd668bb24151dae70ed76aeaec1aff2ac069f | |
parent | baf3f78660a144ce364d8a27b5d41a7600b7ef21 (diff) | |
download | gsoc2013-evolution-c6a8e68892c642f071f3e9be7854c5bd386f8136.tar gsoc2013-evolution-c6a8e68892c642f071f3e9be7854c5bd386f8136.tar.gz gsoc2013-evolution-c6a8e68892c642f071f3e9be7854c5bd386f8136.tar.bz2 gsoc2013-evolution-c6a8e68892c642f071f3e9be7854c5bd386f8136.tar.lz gsoc2013-evolution-c6a8e68892c642f071f3e9be7854c5bd386f8136.tar.xz gsoc2013-evolution-c6a8e68892c642f071f3e9be7854c5bd386f8136.tar.zst gsoc2013-evolution-c6a8e68892c642f071f3e9be7854c5bd386f8136.zip |
Revert prior changes.
2003-07-23 Jeffrey Stedfast <fejj@ximian.com>
* mail-format.c (mail_format_data_wrapper_write_to_stream): Revert
prior changes.
svn path=/trunk/; revision=21921
-rw-r--r-- | mail/ChangeLog | 5 | ||||
-rw-r--r-- | mail/mail-format.c | 68 |
2 files changed, 52 insertions, 21 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index c571c9965a..83ecc9fa81 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,8 @@ +2003-07-23 Jeffrey Stedfast <fejj@ximian.com> + + * mail-format.c (mail_format_data_wrapper_write_to_stream): Revert + prior changes. + 2003-07-23 Dan Winship <danw@ximian.com> * folder-browser.c (message_list_drag_data_get): Fix type warnings diff --git a/mail/mail-format.c b/mail/mail-format.c index 2262a25385..1ee1223d46 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -1120,33 +1120,59 @@ ssize_t mail_format_data_wrapper_write_to_stream (CamelDataWrapper *wrapper, MailDisplay *mail_display, CamelStream *stream) { CamelStreamFilter *filtered_stream; - CamelMimeFilterCharset *filter; - CamelContentType *content_type; - GConfClient *gconf; ssize_t written; - char *charset; - - gconf = mail_config_get_gconf_client (); - - 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) - charset = g_strdup (mail_display->charset); - else if (content_type && (charset = (char *) header_content_type_param (content_type, "charset"))) - charset = g_strdup (charset); - else - charset = gconf_client_get_string (gconf, "/apps/evolution/mail/format/charset", NULL); filtered_stream = camel_stream_filter_new_with_stream (stream); - 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); + 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... */ + + /* 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); + + /* 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); + } + + 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"))) + 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); } - g_free (charset); - written = camel_data_wrapper_write_to_stream (wrapper, CAMEL_STREAM (filtered_stream)); camel_stream_flush (CAMEL_STREAM (filtered_stream)); camel_object_unref (filtered_stream); |