зеркало из https://github.com/mozilla/gecko-dev.git
Added default charset to nsIMsgCompFields, removed nsMsgI18NGetDefaultMailCharset, bug 110127, r=ducarroz, sr=bienvenu.
This commit is contained in:
Родитель
16a527d0a8
Коммит
89c29421d0
|
@ -417,29 +417,6 @@ char * nsMsgI18NEncodeMimePartIIStr(const char *header, const char *charset, PRB
|
|||
return NS_SUCCEEDED(res) ? encodedString : nsnull;
|
||||
}
|
||||
|
||||
// Get a default mail character set.
|
||||
char * nsMsgI18NGetDefaultMailCharset()
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
char * retVal = nsnull;
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &res));
|
||||
if (nsnull != prefs && NS_SUCCEEDED(res))
|
||||
{
|
||||
nsXPIDLString prefValue;
|
||||
res = prefs->GetLocalizedUnicharPref("mailnews.send_default_charset", getter_Copies(prefValue));
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
//TODO: map to mail charset (e.g. Shift_JIS -> ISO-2022-JP) bug#3941.
|
||||
retVal = ToNewUTF8String(prefValue);
|
||||
}
|
||||
else
|
||||
retVal = nsCRT::strdup("ISO-8859-1");
|
||||
}
|
||||
|
||||
return (nsnull != retVal) ? retVal : nsCRT::strdup("ISO-8859-1");
|
||||
}
|
||||
|
||||
// Return True if a charset is stateful (e.g. JIS).
|
||||
PRBool nsMsgI18Nstateful_charset(const char *charset)
|
||||
{
|
||||
|
|
|
@ -114,13 +114,6 @@ NS_MSG_BASE const char *msgCompHeaderInternalCharset(void);
|
|||
*/
|
||||
NS_MSG_BASE const char * nsMsgI18NFileSystemCharset(void);
|
||||
|
||||
/**
|
||||
* Return mail/news default send charset.
|
||||
*
|
||||
* @return Mail/news default charset for mail send.
|
||||
*/
|
||||
NS_MSG_BASE char * nsMsgI18NGetDefaultMailCharset(void);
|
||||
|
||||
/**
|
||||
* Convert from unicode to target charset.
|
||||
*
|
||||
|
|
|
@ -72,6 +72,7 @@ interface nsIMsgCompFields : nsISupports {
|
|||
attribute string priority;
|
||||
attribute string messageId;
|
||||
attribute string characterSet;
|
||||
readonly attribute string defaultCharacterSet;
|
||||
|
||||
attribute wstring templateName;
|
||||
attribute string draftId;
|
||||
|
|
|
@ -1404,8 +1404,7 @@ function SetDocumentCharacterSet(aCharset)
|
|||
|
||||
function UpdateMailEditCharset()
|
||||
{
|
||||
var send_default_charset = sPrefs.getComplexValue("mailnews.send_default_charset",
|
||||
Components.interfaces.nsIPrefLocalizedString).data;
|
||||
var send_default_charset = gMsgCompose.compFields.defaultCharacterSet;
|
||||
// dump("send_default_charset is " + send_default_charset + "\n");
|
||||
|
||||
var compFieldsCharset = gMsgCompose.compFields.characterSet;
|
||||
|
@ -1450,8 +1449,7 @@ function GetCharsetUIString()
|
|||
{
|
||||
var charset = gMsgCompose.compFields.characterSet;
|
||||
if (gSendDefaultCharset == null) {
|
||||
gSendDefaultCharset = sPrefs.getComplexValue("mailnews.send_default_charset",
|
||||
Components.interfaces.nsIPrefLocalizedString).data;
|
||||
gSendDefaultCharset = gMsgCompose.compFields.defaultCharacterSet;
|
||||
}
|
||||
|
||||
charset = charset.toUpperCase();
|
||||
|
|
|
@ -75,16 +75,17 @@ nsMsgCompFields::nsMsgCompFields()
|
|||
{
|
||||
prefs->GetBoolPref("mail.request.return_receipt_on", &m_returnReceipt);
|
||||
prefs->GetIntPref("mail.request.return_receipt", &m_receiptType);
|
||||
// Get the default charset from pref, use this as a mail charset.
|
||||
nsXPIDLString charset;
|
||||
prefs->GetLocalizedUnicharPref("mailnews.send_default_charset", getter_Copies(charset));
|
||||
if (charset.IsEmpty())
|
||||
m_DefaultCharacterSet.Assign("ISO-8859-1");
|
||||
else
|
||||
m_DefaultCharacterSet.AssignWithConversion(charset);
|
||||
SetCharacterSet(m_DefaultCharacterSet.get());
|
||||
}
|
||||
m_internalCharSet.Assign(msgCompHeaderInternalCharset());
|
||||
|
||||
// Get the default charset from pref, use this as a mail charset.
|
||||
char * default_mail_charset = nsMsgI18NGetDefaultMailCharset();
|
||||
if (default_mail_charset)
|
||||
{
|
||||
SetCharacterSet(default_mail_charset);
|
||||
PR_Free(default_mail_charset);
|
||||
}
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -777,3 +778,10 @@ NS_IMETHODIMP nsMsgCompFields::SetSecurityInfo(nsISupports * aSecurityInfo)
|
|||
mSecureCompFields = aSecurityInfo;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
inline nsresult nsMsgCompFields::GetDefaultCharacterSet(char * *aDefaultCharacterSet)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDefaultCharacterSet);
|
||||
*aDefaultCharacterSet = nsCRT::strdup(m_DefaultCharacterSet.get());
|
||||
return *aDefaultCharacterSet ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@ protected:
|
|||
PRBool m_returnReceipt;
|
||||
PRInt32 m_receiptType; /* 0:None 1:DSN 2:MDN 3:BOTH */
|
||||
nsCString m_internalCharSet;
|
||||
nsCString m_DefaultCharacterSet;
|
||||
|
||||
nsCOMPtr<nsISupports> mSecureCompFields;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче