From 093b943e40688c74e711cd5dda4d65bebb269243 Mon Sep 17 00:00:00 2001 From: "nhotta%netscape.com" Date: Tue, 12 Nov 2002 19:08:23 +0000 Subject: [PATCH] Separated the menu charset code from the charset initialization function, to avoid the mail font code calling the init function and reset the menu charset, bug 150530, r=ducarroz, sr=bienvenu. --- mailnews/mime/src/mimemsg.cpp | 19 ++++++++++++------- mailnews/mime/src/mimetext.cpp | 17 +++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/mailnews/mime/src/mimemsg.cpp b/mailnews/mime/src/mimemsg.cpp index f63cf9ccd855..1537feeafdae 100644 --- a/mailnews/mime/src/mimemsg.cpp +++ b/mailnews/mime/src/mimemsg.cpp @@ -485,11 +485,18 @@ MimeMessage_close_headers (MimeObject *obj) ( obj->options->part_to_load == NULL ) ) { - char *charset = NULL; - char *lct = MimeHeaders_get (msg->hdrs, HEADER_CONTENT_TYPE, - PR_FALSE, PR_FALSE); - if (lct) - charset = MimeHeaders_get_parameter (lct, "charset", NULL, NULL); + // call SetMailCharacterSetToMsgWindow() to set a menu charset + if (mime_typep(body, (MimeObjectClass *) &mimeInlineTextClass)) + { + MimeInlineText *text = (MimeInlineText *) body; + if (text && text->charset && *text->charset) + { + if (!nsCRT::strcasecmp(text->charset, "us-ascii")) + SetMailCharacterSetToMsgWindow(body, NS_LITERAL_STRING("ISO-8859-1").get()); + else + SetMailCharacterSetToMsgWindow(body, NS_ConvertASCIItoUCS2(text->charset).get()); + } + } char *msgID = MimeHeaders_get (msg->hdrs, HEADER_MESSAGE_ID, PR_FALSE, PR_FALSE); @@ -500,8 +507,6 @@ MimeMessage_close_headers (MimeObject *obj) mimeEmitterStartBody(obj->options, (obj->options->headers == MimeHeadersNone), msgID, outCharset); PR_FREEIF(msgID); - PR_FREEIF(lct); - PR_FREEIF(charset); // setting up truncated message html fotter function char *xmoz = MimeHeaders_get(msg->hdrs, HEADER_X_MOZILLA_STATUS, PR_FALSE, diff --git a/mailnews/mime/src/mimetext.cpp b/mailnews/mime/src/mimetext.cpp index 253274222452..58c464f3781d 100644 --- a/mailnews/mime/src/mimetext.cpp +++ b/mailnews/mime/src/mimetext.cpp @@ -173,14 +173,6 @@ static int MimeInlineText_initializeCharset(MimeObject *obj) } } - //update MsgWindow charset if we are instructed to do so - if (text->needUpdateMsgWinCharset && *text->charset) { - if (!nsCRT::strcasecmp(text->charset, "us-ascii")) - SetMailCharacterSetToMsgWindow(obj, NS_LITERAL_STRING("ISO-8859-1").get()); - else - SetMailCharacterSetToMsgWindow(obj, NS_ConvertASCIItoUCS2(text->charset).get()); - } - text->initializeCharset = PR_TRUE; return 0; @@ -521,7 +513,16 @@ MimeInlineText_rotate_convert_and_parse_line(char *line, PRInt32 length, MimeInlineText *text = (MimeInlineText *) obj; if (!text->initializeCharset) + { MimeInlineText_initializeCharset(obj); + //update MsgWindow charset if we are instructed to do so + if (text->needUpdateMsgWinCharset && *text->charset) { + if (!nsCRT::strcasecmp(text->charset, "us-ascii")) + SetMailCharacterSetToMsgWindow(obj, NS_LITERAL_STRING("ISO-8859-1").get()); + else + SetMailCharacterSetToMsgWindow(obj, NS_ConvertASCIItoUCS2(text->charset).get()); + } + } //if autodetect is on, push line to dam if (text->inputAutodetect)