зеркало из https://github.com/mozilla/pjs.git
Changed to set mailCharacterSet in nsIMsgWindow so that the value can be used for a checkmark in charset menu, bug 28869, r=mscott.
This commit is contained in:
Родитель
581c22e1c0
Коммит
3728460a01
|
@ -68,6 +68,7 @@
|
|||
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIMsgWindow.h"
|
||||
|
||||
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
@ -535,6 +536,39 @@ nsMimeNewURI(nsIURI** aInstancePtrResult, const char *aSpec, nsIURI *aBase)
|
|||
return pService->NewURI(aSpec, aBase, aInstancePtrResult);
|
||||
}
|
||||
|
||||
extern "C" nsresult
|
||||
SetMailCharacterSetToMsgWindow(MimeObject *obj, const PRUnichar *aCharacterSet)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (obj && obj->options)
|
||||
{
|
||||
mime_stream_data *msd = (mime_stream_data *) (obj->options->stream_closure);
|
||||
if (msd)
|
||||
{
|
||||
nsIChannel *channel = msd->channel;
|
||||
if (channel)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetURI(getter_AddRefs(uri));
|
||||
if (uri)
|
||||
{
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(uri));
|
||||
if (msgurl)
|
||||
{
|
||||
nsCOMPtr<nsIMsgWindow> msgWindow;
|
||||
msgurl->GetMsgWindow(getter_AddRefs(msgWindow));
|
||||
if (msgWindow)
|
||||
rv = msgWindow->SetMailCharacterSet(aCharacterSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static char *
|
||||
mime_reformat_date(const char *date, void *stream_closure)
|
||||
{
|
||||
|
|
|
@ -162,6 +162,8 @@ extern "C" char *MimeGetStringByID(PRInt32 stringID);
|
|||
// Utility to create a nsIURI object...
|
||||
extern "C" nsresult nsMimeNewURI(nsIURI** aInstancePtrResult, const char *aSpec, nsIURI *aBase);
|
||||
|
||||
extern "C" nsresult SetMailCharacterSetToMsgWindow(MimeObject *obj, const PRUnichar *aCharacterSet);
|
||||
|
||||
extern "C" nsresult GetMailNewsFont(MimeObject *obj, PRBool styleFixed, char *fontName, PRUint32 nameBuffSize, PRInt32 *fontPixelSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "nsMsgMessageFlags.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsString.h"
|
||||
#include "mimetext.h"
|
||||
|
||||
#define MIME_SUPERCLASS mimeContainerClass
|
||||
MimeDefClass(MimeMessage, MimeMessageClass, mimeMessageClass,
|
||||
|
@ -429,6 +430,31 @@ HG09091
|
|||
return status;
|
||||
}
|
||||
|
||||
// Get a charset to be used for the conversion.
|
||||
const char *input_charset = NULL;
|
||||
MimeInlineText *text = (MimeInlineText *) body;
|
||||
|
||||
if (obj->options->override_charset && (*obj->options->override_charset))
|
||||
input_charset = obj->options->override_charset;
|
||||
else if ( (text) && (text->charset) && (*(text->charset)) )
|
||||
input_charset = text->charset;
|
||||
else
|
||||
{
|
||||
if (obj->options->default_charset)
|
||||
input_charset = obj->options->default_charset;
|
||||
else
|
||||
input_charset = text->defaultCharset;
|
||||
}
|
||||
|
||||
// Store the charset used for the conversion, so we can put a menu check mark.
|
||||
if (input_charset)
|
||||
{
|
||||
if (!nsCRT::strcasecmp(input_charset, "us-ascii"))
|
||||
SetMailCharacterSetToMsgWindow(obj, NS_LITERAL_STRING("ISO-8859-1"));
|
||||
else
|
||||
SetMailCharacterSetToMsgWindow(obj, NS_ConvertASCIItoUCS2(input_charset));
|
||||
}
|
||||
|
||||
/* Now that we've added this new object to our list of children,
|
||||
start its parser going. */
|
||||
status = body->clazz->parse_begin(body);
|
||||
|
|
|
@ -223,6 +223,12 @@ MimeMultipart_parse_line (char *line, PRInt32 length, MimeObject *obj)
|
|||
if (cset)
|
||||
{
|
||||
mimeEmitterUpdateCharacterSet(obj->options, cset);
|
||||
|
||||
// Also set this charset to msgWindow
|
||||
if (!nsCRT::strcasecmp(cset, "us-ascii"))
|
||||
SetMailCharacterSetToMsgWindow(obj, NS_LITERAL_STRING("ISO-8859-1"));
|
||||
else
|
||||
SetMailCharacterSetToMsgWindow(obj, NS_ConvertASCIItoUCS2(cset));
|
||||
}
|
||||
|
||||
PR_FREEIF(ct);
|
||||
|
|
Загрузка…
Ссылка в новой задаче