aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-part.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-07-20 08:08:50 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-07-20 08:08:50 +0800
commit25ea76f3a782b2cd0a9ed65216203b7d7472ef57 (patch)
treeb9fbdc13ea42b51c99ec31c54b883c78eaff132d /camel/camel-mime-part.c
parent0ce3b207745b7094c31a4713f8bc08cbe926b425 (diff)
downloadgsoc2013-evolution-25ea76f3a782b2cd0a9ed65216203b7d7472ef57.tar.gz
gsoc2013-evolution-25ea76f3a782b2cd0a9ed65216203b7d7472ef57.tar.zst
gsoc2013-evolution-25ea76f3a782b2cd0a9ed65216203b7d7472ef57.zip
Convert to the iconv-friendly charset names.
2001-07-19 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-filter-charset.c (camel_mime_filter_charset_new_convert): Convert to the iconv-friendly charset names. * providers/imap/camel-imap-store.c (create_folder): Fixed a compiler warning about returning without a value in a non-void function. Blah. * camel-mime-part.c (process_header): Pass the locale charset as the default_charset to header_decode_string(). * camel-folder-summary.c (camel_folder_summary_format_string): Pass the locale charset as the default_charset to header_decode_string(). (content_info_new): Same. * camel-mime-message.c (process_header): Pass the locale charset as the default_charset to header_decode_string(). * camel-mime-utils.c (append_8bit): New helper function who's purpose is similar to append_latin1() but for 8bit text that we are assuming is not latin1. (header_decode_text): Now takes a default_charset parameter and calls append_8bit when appropriate. (header_decode_string): Also takes a default_charset parameter now. (header_decode_mailbox): Pass NULL as the default_charset to header_decode_string(). svn path=/trunk/; revision=11250
Diffstat (limited to 'camel/camel-mime-part.c')
-rw-r--r--camel/camel-mime-part.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 733d08c719..a6ab3e58d5 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -40,6 +40,7 @@
#include "camel-mime-part.h"
#include "camel-mime-part-utils.h"
#include "camel-exception.h"
+#include "camel-charset-map.h"
#include "string-utils.h"
#define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/
@@ -200,6 +201,7 @@ process_header(CamelMedium *medium, const char *header_name, const char *header_
{
CamelMimePart *mime_part = CAMEL_MIME_PART (medium);
CamelHeaderType header_type;
+ const char *charset;
char *text;
/* Try to parse the header pair. If it corresponds to something */
@@ -209,30 +211,29 @@ process_header(CamelMedium *medium, const char *header_name, const char *header_
header_type = (CamelHeaderType) g_hash_table_lookup (header_name_table, header_name);
switch (header_type) {
case HEADER_DESCRIPTION: /* raw header->utf8 conversion */
- text = header_decode_string(header_value);
- g_free(mime_part->description);
- mime_part->description = g_strstrip (text);
+ g_free (mime_part->description);
+ charset = camel_charset_locale_name ();
+ mime_part->description = g_strstrip (header_decode_string (header_value, charset));
break;
case HEADER_DISPOSITION:
- set_disposition(mime_part, header_value);
+ set_disposition (mime_part, header_value);
break;
case HEADER_CONTENT_ID:
- text = header_msgid_decode(header_value);
- g_free(mime_part->content_id);
- mime_part->content_id = text;
+ g_free (mime_part->content_id);
+ mime_part->content_id = header_msgid_decode (header_value);
break;
case HEADER_ENCODING:
- text = header_token_decode(header_value);
+ text = header_token_decode (header_value);
mime_part->encoding = camel_mime_part_encoding_from_string (text);
- g_free(text);
+ g_free (text);
break;
case HEADER_CONTENT_MD5:
- g_free(mime_part->content_MD5);
- mime_part->content_MD5 = g_strdup(header_value);
+ g_free (mime_part->content_MD5);
+ mime_part->content_MD5 = g_strdup (header_value);
break;
case HEADER_CONTENT_LOCATION:
- g_free(mime_part->content_location);
- mime_part->content_location = header_location_decode(header_value);
+ g_free (mime_part->content_location);
+ mime_part->content_location = header_location_decode (header_value);
break;
case HEADER_CONTENT_TYPE:
if (mime_part->content_type)
@@ -298,7 +299,7 @@ get_headers (CamelMedium *medium)
headers = g_array_new (FALSE, FALSE, sizeof (CamelMediumHeader));
for (h = part->headers; h; h = h->next) {
header.name = h->name;
- header.value = header_decode_string (h->value);
+ header.value = header_decode_string (h->value, NULL);
g_array_append_val (headers, header);
}
@@ -604,14 +605,14 @@ write_to_stream(CamelDataWrapper *data_wrapper, CamelStream *stream)
default:
break;
}
-
- if (header_content_type_is(mp->content_type, "text", "*")) {
- charset = header_content_type_param(mp->content_type, "charset");
- if (!(charset == NULL || !strcasecmp(charset, "us-ascii") || !strcasecmp(charset, "utf-8"))) {
- charenc = (CamelMimeFilter *)camel_mime_filter_charset_new_convert("utf-8", charset);
+
+ if (header_content_type_is (mp->content_type, "text", "*")) {
+ charset = header_content_type_param (mp->content_type, "charset");
+ if (charset && !(!g_strcasecmp (charset, "us-ascii") || !g_strcasecmp (charset, "utf-8"))) {
+ charenc = (CamelMimeFilter *)camel_mime_filter_charset_new_convert ("UTF-8", charset);
}
}
-
+
if (filter || charenc) {
filter_stream = camel_stream_filter_new_with_stream(stream);