182982 - Mailnews utility library needs to use nsIPrefBranch, nsIPrefService, et alia
r=timeless/nhotta sr=bienvenu
This commit is contained in:
Родитель
78416637f9
Коммит
fa74673f01
|
@ -40,7 +40,8 @@
|
|||
#include "nsReadableUtils.h"
|
||||
#include "nsMsgDBFolder.h"
|
||||
#include "nsMsgFolderFlags.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsIMsgFolderCache.h"
|
||||
#include "nsIMsgFolderCacheElement.h"
|
||||
|
@ -71,7 +72,6 @@
|
|||
#define oneHour 3600000000
|
||||
#include "nsMsgUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
static PRTime gtimeOfLastPurgeCheck; //variable to know when to check for purge_threshhold
|
||||
|
||||
|
||||
|
@ -1507,10 +1507,10 @@ nsMsgDBFolder::GetPromptPurgeThreshold(PRBool *aPrompt)
|
|||
{
|
||||
NS_ENSURE_ARG(aPrompt);
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> prefService = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && prefService)
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && prefBranch)
|
||||
{
|
||||
rv = prefService->GetBoolPref(PREF_MAIL_PROMPT_PURGE_THRESHOLD, aPrompt);
|
||||
rv = prefBranch->GetBoolPref(PREF_MAIL_PROMPT_PURGE_THRESHOLD, aPrompt);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
*aPrompt = PR_FALSE;
|
||||
|
@ -1525,10 +1525,10 @@ nsMsgDBFolder::GetPurgeThreshold(PRInt32 *aThreshold)
|
|||
{
|
||||
NS_ENSURE_ARG(aThreshold);
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> prefService = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && prefService)
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && prefBranch)
|
||||
{
|
||||
rv = prefService->GetIntPref(PREF_MAIL_PURGE_THRESHOLD, aThreshold);
|
||||
rv = prefBranch->GetIntPref(PREF_MAIL_PURGE_THRESHOLD, aThreshold);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
*aThreshold = 0;
|
||||
|
|
|
@ -61,7 +61,8 @@
|
|||
#include "nsMsgUtils.h" // for NS_MsgHashIfNecessary()
|
||||
#include "nsMsgI18N.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsRDFCID.h"
|
||||
|
@ -2776,10 +2777,10 @@ nsMsgFolder::GetWarnFilterChanged(PRBool *aVal)
|
|||
{
|
||||
NS_ENSURE_ARG(aVal);
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> prefService = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && prefService)
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && prefBranch)
|
||||
{
|
||||
rv = prefService->GetBoolPref(PREF_MAIL_WARN_FILTER_CHANGED, aVal);
|
||||
rv = prefBranch->GetBoolPref(PREF_MAIL_WARN_FILTER_CHANGED, aVal);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
*aVal = PR_FALSE;
|
||||
|
@ -2793,9 +2794,9 @@ nsresult
|
|||
nsMsgFolder::SetWarnFilterChanged(PRBool aVal)
|
||||
{
|
||||
nsresult rv=NS_OK;
|
||||
nsCOMPtr<nsIPref> prefService = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && prefService)
|
||||
rv = prefService->SetBoolPref(PREF_MAIL_WARN_FILTER_CHANGED, aVal);
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && prefBranch)
|
||||
rv = prefBranch->SetBoolPref(PREF_MAIL_WARN_FILTER_CHANGED, aVal);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,9 @@
|
|||
#include "nsICharsetConverterManager2.h"
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIMimeConverter.h"
|
||||
#include "msgCore.h"
|
||||
#include "nsMsgI18N.h"
|
||||
|
@ -62,7 +64,6 @@
|
|||
#include "nsFileSpec.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
static NS_DEFINE_CID(kEntityConverterCID, NS_ENTITYCONVERTER_CID);
|
||||
|
||||
|
@ -638,11 +639,11 @@ nsresult nsMsgI18NSaveAsCharset(const char* contentType, const char *charset,
|
|||
if (!nsCRT::strcmp(charsetName, NS_LITERAL_STRING("ISO-2022-JP").get())) {
|
||||
static PRInt32 sSendHankakuKana = -1;
|
||||
if (sSendHankakuKana < 0) {
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &res));
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &res));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
PRBool sendHankaku;
|
||||
// Get a hidden 4.x pref with no UI, get it only once.
|
||||
if (NS_FAILED(prefs->GetBoolPref("mailnews.send_hankaku_kana", &sendHankaku)))
|
||||
if (NS_FAILED(prefBranch->GetBoolPref("mailnews.send_hankaku_kana", &sendHankaku)))
|
||||
sSendHankakuKana = 0; // no pref means need the mapping
|
||||
else
|
||||
sSendHankakuKana = sendHankaku ? 1 : 0;
|
||||
|
@ -665,13 +666,13 @@ nsresult nsMsgI18NSaveAsCharset(const char* contentType, const char *charset,
|
|||
// If the converer cannot encode to the charset,
|
||||
// then fallback to pref sepcified charsets.
|
||||
if (NS_ERROR_UENC_NOMAPPING == res && !bTEXT_HTML && fallbackCharset) {
|
||||
nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID, &res));
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &res));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsCAutoString prefString("intl.fallbackCharsetList.");
|
||||
prefString.Append(charset);
|
||||
nsXPIDLCString fallbackList;
|
||||
res = pref->GetCharPref(prefString.get(), getter_Copies(fallbackList));
|
||||
res = prefBranch->GetCharPref(prefString.get(), getter_Copies(fallbackList));
|
||||
// do the fallback only if there is a pref for the charset
|
||||
if (NS_FAILED(res) || fallbackList.IsEmpty())
|
||||
return NS_ERROR_UENC_NOMAPPING;
|
||||
|
@ -710,31 +711,32 @@ nsresult nsMsgI18NFormatNNTPXPATInNonRFC1522Format(const nsCString& aCharset,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
nsMsgI18NGetAcceptLanguage(void)
|
||||
{
|
||||
static char lang[32];
|
||||
nsresult res;
|
||||
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &res));
|
||||
if (nsnull != prefs && NS_SUCCEEDED(res))
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefBranch)
|
||||
{
|
||||
nsXPIDLString prefValue;
|
||||
nsCOMPtr<nsIPrefLocalizedString> prefString;
|
||||
|
||||
memset(lang, 0, sizeof(lang));
|
||||
res = prefs->GetLocalizedUnicharPref("intl.accept_languages", getter_Copies(prefValue));
|
||||
if (NS_SUCCEEDED(res) && prefValue)
|
||||
prefBranch->GetComplexValue("intl.accept_languages",
|
||||
NS_GET_IID(nsIPrefLocalizedString),
|
||||
getter_AddRefs(prefString));
|
||||
if (prefString)
|
||||
{
|
||||
PL_strncpy(lang, NS_ConvertUCS2toUTF8(prefValue).get(), sizeof(lang));
|
||||
lang[sizeof(lang)-1] = '\0';
|
||||
nsXPIDLString ucsval;
|
||||
prefString->ToString(getter_Copies(ucsval));
|
||||
if (!ucsval.IsEmpty())
|
||||
{
|
||||
static nsCAutoString acceptLang;
|
||||
acceptLang.Assign(NS_LossyConvertUCS2toASCII(ucsval));
|
||||
return acceptLang.get();
|
||||
}
|
||||
}
|
||||
else
|
||||
PL_strcpy(lang, "en");
|
||||
}
|
||||
else
|
||||
PL_strcpy(lang, "en");
|
||||
|
||||
return (char *)lang;
|
||||
// Default Accept-Language
|
||||
return "en";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -92,10 +92,11 @@ NS_MSG_BASE PRBool nsMsgI18Ncheck_data_in_charset_range(const char *charset,
|
|||
|
||||
/**
|
||||
* Return accept language.
|
||||
* Note, the return value is not valid after this method gets called again.
|
||||
*
|
||||
* @return Accept language.
|
||||
*/
|
||||
NS_MSG_BASE char *nsMsgI18NGetAcceptLanguage(void);
|
||||
NS_MSG_BASE const char *nsMsgI18NGetAcceptLanguage(void);
|
||||
|
||||
/**
|
||||
* Return charset name internally used in messsage compose.
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
#include "msgCore.h" // for pre-compiled headers
|
||||
#include "nsMsgIdentity.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
|
@ -54,8 +54,8 @@
|
|||
#include "nsIMsgFolder.h"
|
||||
#include "prprf.h"
|
||||
#include "nsISupportsObsolete.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsMsgIdentity,
|
||||
|
@ -65,7 +65,7 @@ nsMsgIdentity::nsMsgIdentity():
|
|||
m_signature(0),
|
||||
m_vCard(0),
|
||||
m_identityKey(0),
|
||||
m_prefs(0)
|
||||
m_prefBranch(0)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
@ -73,16 +73,16 @@ nsMsgIdentity::nsMsgIdentity():
|
|||
nsMsgIdentity::~nsMsgIdentity()
|
||||
{
|
||||
PR_FREEIF(m_identityKey);
|
||||
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID, m_prefs);
|
||||
NS_IF_RELEASE(m_prefBranch);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIdentity::getPrefService()
|
||||
{
|
||||
if (m_prefs) return NS_OK;
|
||||
return nsServiceManager::GetService(kPrefServiceCID,
|
||||
NS_GET_IID(nsIPref),
|
||||
(nsISupports**)&m_prefs);
|
||||
if (m_prefBranch)
|
||||
return NS_OK;
|
||||
|
||||
return CallGetService(NS_PREFSERVICE_CONTRACTID, &m_prefBranch);
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,7 +120,7 @@ nsMsgIdentity::getBoolPref(const char *prefname,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *fullPrefName = getPrefName(m_identityKey, prefname);
|
||||
rv = m_prefs->GetBoolPref(fullPrefName, val);
|
||||
rv = m_prefBranch->GetBoolPref(fullPrefName, val);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -137,7 +137,7 @@ nsMsgIdentity::getDefaultBoolPref(const char *prefname,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *fullPrefName = getDefaultPrefName(prefname);
|
||||
rv = m_prefs->GetBoolPref(fullPrefName, val);
|
||||
rv = m_prefBranch->GetBoolPref(fullPrefName, val);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -155,7 +155,7 @@ nsMsgIdentity::setBoolPref(const char *prefname,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *prefName = getPrefName(m_identityKey, prefname);
|
||||
rv = m_prefs->SetBoolPref(prefName, val);
|
||||
rv = m_prefBranch->SetBoolPref(prefName, val);
|
||||
PR_Free(prefName);
|
||||
return rv;
|
||||
}
|
||||
|
@ -169,12 +169,18 @@ nsMsgIdentity::getUnicharPref(const char *prefname,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *fullPrefName = getPrefName(m_identityKey, prefname);
|
||||
rv = m_prefs->CopyUnicharPref(fullPrefName, val);
|
||||
nsCOMPtr<nsISupportsString> supportsString;
|
||||
rv = m_prefBranch->GetComplexValue(fullPrefName,
|
||||
NS_GET_IID(nsISupportsString),
|
||||
getter_AddRefs(supportsString));
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
rv = getDefaultUnicharPref(prefname, val);
|
||||
|
||||
if (supportsString)
|
||||
rv = supportsString->ToString(val);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -186,7 +192,7 @@ nsMsgIdentity::getCharPref(const char *prefname,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *fullPrefName = getPrefName(m_identityKey, prefname);
|
||||
rv = m_prefs->CopyCharPref(fullPrefName, val);
|
||||
rv = m_prefBranch->GetCharPref(fullPrefName, val);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -203,14 +209,18 @@ nsMsgIdentity::getDefaultUnicharPref(const char *prefname,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *fullPrefName = getDefaultPrefName(prefname);
|
||||
rv = m_prefs->CopyUnicharPref(fullPrefName, val);
|
||||
nsCOMPtr<nsISupportsString> supportsString;
|
||||
rv = m_prefBranch->GetComplexValue(fullPrefName,
|
||||
NS_GET_IID(nsISupportsString),
|
||||
getter_AddRefs(supportsString));
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_FAILED(rv) || !supportsString) {
|
||||
*val = nsnull; // null is ok to return here
|
||||
rv = NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
return rv;
|
||||
|
||||
return supportsString->ToString(val);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -221,7 +231,7 @@ nsMsgIdentity::getDefaultCharPref(const char *prefname,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *fullPrefName = getDefaultPrefName(prefname);
|
||||
rv = m_prefs->CopyCharPref(fullPrefName, val);
|
||||
rv = m_prefBranch->GetCharPref(fullPrefName, val);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -240,10 +250,19 @@ nsMsgIdentity::setUnicharPref(const char *prefname,
|
|||
|
||||
rv = NS_OK;
|
||||
char *prefName = getPrefName(m_identityKey, prefname);
|
||||
if (val)
|
||||
rv = m_prefs->SetUnicharPref(prefName, val);
|
||||
else
|
||||
m_prefs->ClearUserPref(prefName);
|
||||
if (val) {
|
||||
nsCOMPtr<nsISupportsString> supportsString =
|
||||
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
|
||||
if (supportsString) {
|
||||
supportsString->SetData(nsDependentString(val));
|
||||
rv = m_prefBranch->SetComplexValue(prefName,
|
||||
NS_GET_IID(nsISupportsString),
|
||||
supportsString);
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_prefBranch->ClearUserPref(prefName);
|
||||
}
|
||||
PR_Free(prefName);
|
||||
return rv;
|
||||
}
|
||||
|
@ -258,9 +277,9 @@ nsMsgIdentity::setCharPref(const char *prefname,
|
|||
rv = NS_OK;
|
||||
char *prefName = getPrefName(m_identityKey, prefname);
|
||||
if (val)
|
||||
rv = m_prefs->SetCharPref(prefName, val);
|
||||
rv = m_prefBranch->SetCharPref(prefName, val);
|
||||
else
|
||||
m_prefs->ClearUserPref(prefName);
|
||||
m_prefBranch->ClearUserPref(prefName);
|
||||
PR_Free(prefName);
|
||||
return rv;
|
||||
}
|
||||
|
@ -273,7 +292,7 @@ nsMsgIdentity::getIntPref(const char *prefname,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *fullPrefName = getPrefName(m_identityKey, prefname);
|
||||
rv = m_prefs->GetIntPref(fullPrefName, val);
|
||||
rv = m_prefBranch->GetIntPref(fullPrefName, val);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -290,7 +309,7 @@ nsMsgIdentity::getDefaultIntPref(const char *prefname,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *fullPrefName = getDefaultPrefName(prefname);
|
||||
rv = m_prefs->GetIntPref(fullPrefName, val);
|
||||
rv = m_prefBranch->GetIntPref(fullPrefName, val);
|
||||
PR_Free(fullPrefName);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -309,7 +328,7 @@ nsMsgIdentity::setIntPref(const char *prefname,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *prefName = getPrefName(m_identityKey, prefname);
|
||||
rv = m_prefs->SetIntPref(prefName, val);
|
||||
rv = m_prefBranch->SetIntPref(prefName, val);
|
||||
PR_Free(prefName);
|
||||
return rv;
|
||||
}
|
||||
|
@ -376,7 +395,7 @@ nsMsgIdentity::GetSignature(nsILocalFile **sig) {
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *prefName = getPrefName(m_identityKey, "sig_file");
|
||||
rv = m_prefs->GetFileXPref(prefName, sig);
|
||||
rv = m_prefBranch->GetComplexValue(prefName, NS_GET_IID(nsILocalFile), (void **)sig);
|
||||
if (NS_FAILED(rv))
|
||||
*sig = nsnull;
|
||||
return NS_OK;
|
||||
|
@ -392,10 +411,10 @@ nsMsgIdentity::SetSignature(nsILocalFile *sig)
|
|||
rv = NS_OK;
|
||||
char *prefName = getPrefName(m_identityKey, "sig_file");
|
||||
if (sig)
|
||||
rv = m_prefs->SetFileXPref(prefName, sig);
|
||||
rv = m_prefBranch->SetComplexValue(prefName, NS_GET_IID(nsILocalFile), sig);
|
||||
/*
|
||||
else
|
||||
m_prefs->ClearFilePref(prefName);
|
||||
m_prefBranch->ClearFilePref(prefName);
|
||||
*/
|
||||
PR_Free(prefName);
|
||||
return rv;
|
||||
|
@ -407,21 +426,23 @@ NS_IMETHODIMP
|
|||
nsMsgIdentity::ClearAllValues()
|
||||
{
|
||||
nsresult rv = getPrefService();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCAutoString rootPref(NS_LITERAL_CSTRING("mail.identity."));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString rootPref("mail.identity.");
|
||||
rootPref += m_identityKey;
|
||||
|
||||
rv = m_prefs->EnumerateChildren(rootPref.get(), clearPrefEnum, (void *)m_prefs);
|
||||
PRUint32 childCount;
|
||||
char** childArray;
|
||||
rv = m_prefBranch->GetChildList(rootPref.get(), &childCount, &childArray);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
m_prefBranch->ClearUserPref(childArray[i]);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(childCount, childArray);
|
||||
|
||||
void
|
||||
nsMsgIdentity::clearPrefEnum(const char *aPref, void *aClosure)
|
||||
{
|
||||
nsIPref *prefs = (nsIPref *)aClosure;
|
||||
prefs->ClearUserPref(aPref);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -652,12 +673,10 @@ nsMsgIdentity::GetRequestReturnReceipt(PRBool *aVal)
|
|||
{
|
||||
return GetBoolAttribute("request_return_receipt_on", aVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
|
||||
rv = getPrefService();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return prefs->GetBoolPref("mail.receipt.request_return_receipt_on", aVal);
|
||||
}
|
||||
return m_prefBranch->GetBoolPref("mail.receipt.request_return_receipt_on", aVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -672,10 +691,8 @@ nsMsgIdentity::GetReceiptHeaderType(PRInt32 *aType)
|
|||
{
|
||||
return GetBoolAttribute("request_receipt_header_type", aType);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
|
||||
rv = getPrefService();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return prefs->GetBoolPref("mail.receipt.request_header_type", aType);
|
||||
}
|
||||
return m_prefBranch->GetBoolPref("mail.receipt.request_header_type", aType);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#define nsMsgIdentity_h___
|
||||
|
||||
#include "nsIMsgIdentity.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "msgCore.h"
|
||||
#include "nsISmtpServer.h"
|
||||
#include "nsWeakPtr.h"
|
||||
|
@ -58,7 +58,7 @@ private:
|
|||
nsIMsgSignature* m_signature;
|
||||
nsIMsgVCard* m_vCard;
|
||||
char *m_identityKey;
|
||||
nsIPref *m_prefs;
|
||||
nsIPrefBranch *m_prefBranch;
|
||||
nsWeakPtr m_smtpServer;
|
||||
|
||||
protected:
|
||||
|
@ -86,8 +86,6 @@ protected:
|
|||
nsresult setFolderPref(const char *pref, const char *);
|
||||
|
||||
private:
|
||||
static void clearPrefEnum(const char *aPref, void *aClosure);
|
||||
|
||||
nsresult loadSmtpServer(nsISmtpServer**);
|
||||
|
||||
};
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "nsReadableUtils.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsISupportsObsolete.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsMsgDBCID.h"
|
||||
|
@ -59,7 +60,7 @@
|
|||
#include "nsIMsgFilterService.h"
|
||||
#include "nsIMsgProtocolInfo.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
|
@ -80,7 +81,6 @@
|
|||
#include "nsMsgFolderFlags.h"
|
||||
#include "nsMsgUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
#define PORT_NOT_SET -1
|
||||
|
@ -89,7 +89,7 @@ MOZ_DECL_CTOR_COUNTER(nsMsgIncomingServer)
|
|||
|
||||
nsMsgIncomingServer::nsMsgIncomingServer():
|
||||
m_rootFolder(0),
|
||||
m_prefs(0),
|
||||
m_prefBranch(0),
|
||||
m_biffState(nsIMsgFolder::nsMsgBiffState_NoMail),
|
||||
m_serverBusy(PR_FALSE),
|
||||
m_canHaveFilters(PR_FALSE),
|
||||
|
@ -101,9 +101,7 @@ nsMsgIncomingServer::nsMsgIncomingServer():
|
|||
|
||||
nsMsgIncomingServer::~nsMsgIncomingServer()
|
||||
{
|
||||
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID,
|
||||
m_prefs,
|
||||
nsnull);
|
||||
NS_IF_RELEASE(m_prefBranch);
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,15 +119,13 @@ NS_IMPL_GETTER_STR(nsMsgIncomingServer::GetKey, m_serverKey.get())
|
|||
NS_IMETHODIMP
|
||||
nsMsgIncomingServer::SetKey(const char * serverKey)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
// in order to actually make use of the key, we need the prefs
|
||||
if (!m_prefs)
|
||||
rv = nsServiceManager::GetService(kPrefServiceCID,
|
||||
NS_GET_IID(nsIPref),
|
||||
(nsISupports**)&m_prefs);
|
||||
|
||||
m_serverKey.Assign(serverKey);
|
||||
return rv;
|
||||
|
||||
// in order to actually make use of the key, we need the prefs
|
||||
if (m_prefBranch)
|
||||
return NS_OK;
|
||||
|
||||
return CallGetService(NS_PREFSERVICE_CONTRACTID, &m_prefBranch);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -411,7 +407,7 @@ nsMsgIncomingServer::GetBoolValue(const char *prefname,
|
|||
{
|
||||
nsCAutoString fullPrefName;
|
||||
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
||||
nsresult rv = m_prefs->GetBoolPref(fullPrefName.get(), val);
|
||||
nsresult rv = m_prefBranch->GetBoolPref(fullPrefName.get(), val);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
rv = getDefaultBoolPref(prefname, val);
|
||||
|
@ -425,7 +421,7 @@ nsMsgIncomingServer::getDefaultBoolPref(const char *prefname,
|
|||
|
||||
nsCAutoString fullPrefName;
|
||||
getDefaultPrefName(prefname, fullPrefName);
|
||||
nsresult rv = m_prefs->GetBoolPref(fullPrefName.get(), val);
|
||||
nsresult rv = m_prefBranch->GetBoolPref(fullPrefName.get(), val);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
*val = PR_FALSE;
|
||||
|
@ -445,11 +441,10 @@ nsMsgIncomingServer::SetBoolValue(const char *prefname,
|
|||
PRBool defaultValue;
|
||||
rv = getDefaultBoolPref(prefname, &defaultValue);
|
||||
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
val == defaultValue)
|
||||
m_prefs->ClearUserPref(fullPrefName.get());
|
||||
if (NS_SUCCEEDED(rv) && val == defaultValue)
|
||||
m_prefBranch->ClearUserPref(fullPrefName.get());
|
||||
else
|
||||
rv = m_prefs->SetBoolPref(fullPrefName.get(), val);
|
||||
rv = m_prefBranch->SetBoolPref(fullPrefName.get(), val);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -460,7 +455,7 @@ nsMsgIncomingServer::GetIntValue(const char *prefname,
|
|||
{
|
||||
nsCAutoString fullPrefName;
|
||||
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
||||
nsresult rv = m_prefs->GetIntPref(fullPrefName.get(), val);
|
||||
nsresult rv = m_prefBranch->GetIntPref(fullPrefName.get(), val);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
rv = getDefaultIntPref(prefname, val);
|
||||
|
@ -476,11 +471,13 @@ nsMsgIncomingServer::GetFileValue(const char* prefname,
|
|||
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
||||
|
||||
nsCOMPtr<nsILocalFile> prefLocal;
|
||||
nsCOMPtr<nsIFileSpec> outSpec;
|
||||
|
||||
nsresult rv = m_prefs->GetFileXPref(fullPrefName.get(), getter_AddRefs(prefLocal));
|
||||
nsresult rv = m_prefBranch->GetComplexValue(fullPrefName.get(),
|
||||
NS_GET_IID(nsILocalFile),
|
||||
getter_AddRefs(prefLocal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIFileSpec> outSpec;
|
||||
rv = NS_NewFileSpecFromIFile(prefLocal, getter_AddRefs(outSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -499,13 +496,15 @@ nsMsgIncomingServer::SetFileValue(const char* prefname,
|
|||
|
||||
nsresult rv;
|
||||
nsFileSpec tempSpec;
|
||||
nsCOMPtr<nsILocalFile> prefLocal;
|
||||
|
||||
rv = spec->GetFileSpec(&tempSpec);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsILocalFile> prefLocal;
|
||||
rv = NS_FileSpecToIFile(&tempSpec, getter_AddRefs(prefLocal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = m_prefs->SetFileXPref(fullPrefName.get(), prefLocal);
|
||||
|
||||
rv = m_prefBranch->SetComplexValue(fullPrefName.get(), NS_GET_IID(nsIFileSpec),
|
||||
prefLocal);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -517,7 +516,7 @@ nsMsgIncomingServer::getDefaultIntPref(const char *prefname,
|
|||
|
||||
nsCAutoString fullPrefName;
|
||||
getDefaultPrefName(prefname, fullPrefName);
|
||||
nsresult rv = m_prefs->GetIntPref(fullPrefName.get(), val);
|
||||
nsresult rv = m_prefBranch->GetIntPref(fullPrefName.get(), val);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
*val = 0;
|
||||
|
@ -539,9 +538,9 @@ nsMsgIncomingServer::SetIntValue(const char *prefname,
|
|||
rv = getDefaultIntPref(prefname, &defaultVal);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && defaultVal == val)
|
||||
m_prefs->ClearUserPref(fullPrefName.get());
|
||||
m_prefBranch->ClearUserPref(fullPrefName.get());
|
||||
else
|
||||
rv = m_prefs->SetIntPref(fullPrefName.get(), val);
|
||||
rv = m_prefBranch->SetIntPref(fullPrefName.get(), val);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -552,7 +551,7 @@ nsMsgIncomingServer::GetCharValue(const char *prefname,
|
|||
{
|
||||
nsCAutoString fullPrefName;
|
||||
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
||||
nsresult rv = m_prefs->CopyCharPref(fullPrefName.get(), val);
|
||||
nsresult rv = m_prefBranch->GetCharPref(fullPrefName.get(), val);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
rv = getDefaultCharPref(prefname, val);
|
||||
|
@ -566,21 +565,27 @@ nsMsgIncomingServer::GetUnicharValue(const char *prefname,
|
|||
{
|
||||
nsCAutoString fullPrefName;
|
||||
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
||||
nsresult rv = m_prefs->CopyUnicharPref(fullPrefName.get(), val);
|
||||
nsCOMPtr<nsISupportsString> supportsString;
|
||||
nsresult rv = m_prefBranch->GetComplexValue(fullPrefName.get(),
|
||||
NS_GET_IID(nsISupportsString),
|
||||
getter_AddRefs(supportsString));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
rv = getDefaultUnicharPref(prefname, val);
|
||||
return getDefaultUnicharPref(prefname, val);
|
||||
|
||||
if (supportsString)
|
||||
rv = supportsString->ToString(val);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgIncomingServer::getDefaultCharPref(const char *prefname,
|
||||
char **val) {
|
||||
|
||||
char **val)
|
||||
{
|
||||
nsCAutoString fullPrefName;
|
||||
getDefaultPrefName(prefname, fullPrefName);
|
||||
nsresult rv = m_prefs->CopyCharPref(fullPrefName.get(), val);
|
||||
nsresult rv = m_prefBranch->GetCharPref(fullPrefName.get(), val);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
*val = nsnull; // null is ok to return here
|
||||
|
@ -595,13 +600,16 @@ nsMsgIncomingServer::getDefaultUnicharPref(const char *prefname,
|
|||
|
||||
nsCAutoString fullPrefName;
|
||||
getDefaultPrefName(prefname, fullPrefName);
|
||||
nsresult rv = m_prefs->CopyUnicharPref(fullPrefName.get(), val);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCOMPtr<nsISupportsString> supportsString;
|
||||
nsresult rv = m_prefBranch->GetComplexValue(fullPrefName.get(),
|
||||
NS_GET_IID(nsISupportsString),
|
||||
getter_AddRefs(supportsString));
|
||||
if (NS_FAILED(rv) || !supportsString) {
|
||||
*val = nsnull; // null is ok to return here
|
||||
rv = NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
return rv;
|
||||
|
||||
return supportsString->ToString(val);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -613,18 +621,17 @@ nsMsgIncomingServer::SetCharValue(const char *prefname,
|
|||
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
||||
|
||||
if (!val) {
|
||||
m_prefs->ClearUserPref(fullPrefName.get());
|
||||
m_prefBranch->ClearUserPref(fullPrefName.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
char *defaultVal=nsnull;
|
||||
rv = getDefaultCharPref(prefname, &defaultVal);
|
||||
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
PL_strcmp(defaultVal, val) == 0)
|
||||
m_prefs->ClearUserPref(fullPrefName.get());
|
||||
if (NS_SUCCEEDED(rv) && strcmp(defaultVal, val) == 0)
|
||||
m_prefBranch->ClearUserPref(fullPrefName.get());
|
||||
else
|
||||
rv = m_prefs->SetCharPref(fullPrefName.get(), val);
|
||||
rv = m_prefBranch->SetCharPref(fullPrefName.get(), val);
|
||||
|
||||
PR_FREEIF(defaultVal);
|
||||
|
||||
|
@ -640,7 +647,7 @@ nsMsgIncomingServer::SetUnicharValue(const char *prefname,
|
|||
getPrefName(m_serverKey.get(), prefname, fullPrefName);
|
||||
|
||||
if (!val) {
|
||||
m_prefs->ClearUserPref(fullPrefName.get());
|
||||
m_prefBranch->ClearUserPref(fullPrefName.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -648,9 +655,17 @@ nsMsgIncomingServer::SetUnicharValue(const char *prefname,
|
|||
rv = getDefaultUnicharPref(prefname, &defaultVal);
|
||||
if (defaultVal && NS_SUCCEEDED(rv) &&
|
||||
nsCRT::strcmp(defaultVal, val) == 0)
|
||||
m_prefs->ClearUserPref(fullPrefName.get());
|
||||
else
|
||||
rv = m_prefs->SetUnicharPref(fullPrefName.get(), val);
|
||||
m_prefBranch->ClearUserPref(fullPrefName.get());
|
||||
else {
|
||||
nsCOMPtr<nsISupportsString> supportsString =
|
||||
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
|
||||
if (supportsString) {
|
||||
supportsString->SetData(nsDependentString(val));
|
||||
rv = m_prefBranch->SetComplexValue(fullPrefName.get(),
|
||||
NS_GET_IID(nsISupportsString),
|
||||
supportsString);
|
||||
}
|
||||
}
|
||||
|
||||
PR_FREEIF(defaultVal);
|
||||
|
||||
|
@ -1012,13 +1027,21 @@ nsMsgIncomingServer::Equals(nsIMsgIncomingServer *server, PRBool *_retval)
|
|||
NS_IMETHODIMP
|
||||
nsMsgIncomingServer::ClearAllValues()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCAutoString rootPref("mail.server.");
|
||||
rootPref += m_serverKey;
|
||||
|
||||
rv = m_prefs->EnumerateChildren(rootPref.get(), clearPrefEnum, (void *)m_prefs);
|
||||
PRUint32 childCount;
|
||||
char** childArray;
|
||||
nsresult rv = m_prefBranch->GetChildList(rootPref.get(), &childCount, &childArray);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return rv;
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
m_prefBranch->ClearUserPref(childArray[i]);
|
||||
}
|
||||
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(childCount, childArray);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1058,14 +1081,6 @@ nsMsgIncomingServer::RemoveFiles()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsMsgIncomingServer::clearPrefEnum(const char *aPref, void *aClosure)
|
||||
{
|
||||
nsIPref *prefs = (nsIPref *)aClosure;
|
||||
prefs->ClearUserPref(aPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgIncomingServer::SetFilterList(nsIMsgFilterList *aFilterList)
|
||||
{
|
||||
|
@ -1290,7 +1305,7 @@ nsMsgIncomingServer::GetDoBiff(PRBool *aDoBiff)
|
|||
|
||||
nsCAutoString fullPrefName;
|
||||
getPrefName(m_serverKey.get(), BIFF_PREF_NAME, fullPrefName);
|
||||
rv = m_prefs->GetBoolPref(fullPrefName.get(), aDoBiff);
|
||||
rv = m_prefBranch->GetBoolPref(fullPrefName.get(), aDoBiff);
|
||||
if (NS_SUCCEEDED(rv)) return rv;
|
||||
|
||||
// if the pref isn't set, use the default
|
||||
|
@ -1317,7 +1332,7 @@ nsMsgIncomingServer::SetDoBiff(PRBool aDoBiff)
|
|||
nsCAutoString fullPrefName;
|
||||
getPrefName(m_serverKey.get(), BIFF_PREF_NAME, fullPrefName);
|
||||
|
||||
rv = m_prefs->SetBoolPref(fullPrefName.get(), aDoBiff);
|
||||
rv = m_prefBranch->SetBoolPref(fullPrefName.get(), aDoBiff);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1738,12 +1753,7 @@ nsMsgIncomingServer::ConfigureTemporaryReturnReceiptsFilter(nsIMsgFilterList *fi
|
|||
rv = GetIntValue("incorporate_return_receipt", &incorp);
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = prefBranch->GetIntPref("mail.incorporate.return_receipt", &incorp);
|
||||
rv = m_prefBranch->GetIntPref("mail.incorporate.return_receipt", &incorp);
|
||||
}
|
||||
|
||||
PRBool enable = (incorp == nsIMsgMdnGenerator::eIncorporateSent);
|
||||
|
@ -1930,9 +1940,10 @@ nsMsgIncomingServer::SetSpamSettings(nsISpamSettings *aSpamSettings)
|
|||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// flush these pref changes to disk
|
||||
rv = m_prefs->SavePrefFile(nsnull);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIPrefService> prefService = do_QueryInterface(m_prefBranch);
|
||||
NS_ENSURE_TRUE(prefService, NS_ERROR_FAILURE);
|
||||
|
||||
return prefService->SavePrefFile(nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#define nsMsgIncomingServer_h__
|
||||
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIMsgFilterList.h"
|
||||
#include "msgCore.h"
|
||||
#include "nsIFolder.h"
|
||||
|
@ -97,11 +97,9 @@ protected:
|
|||
nsresult getProtocolInfo(nsIMsgProtocolInfo **aResult);
|
||||
nsCOMPtr <nsIFileSpec> mFilterFile;
|
||||
nsCOMPtr <nsIMsgFilterList> mFilterList;
|
||||
// pref callback to clear the user prefs
|
||||
static void clearPrefEnum(const char *aPref, void *aClosure);
|
||||
|
||||
private:
|
||||
nsIPref *m_prefs;
|
||||
nsIPrefBranch *m_prefBranch;
|
||||
nsCString m_password;
|
||||
PRUint32 m_biffState;
|
||||
PRPackedBool m_serverBusy;
|
||||
|
|
|
@ -485,7 +485,7 @@ RRT_HEADER:
|
|||
}
|
||||
|
||||
/* for Netscape Server, Accept-Language data sent in Mail header */
|
||||
char *acceptlang = nsMsgI18NGetAcceptLanguage();
|
||||
const char *acceptlang = nsMsgI18NGetAcceptLanguage();
|
||||
if( (acceptlang != NULL) && ( *acceptlang != '\0') ){
|
||||
PUSH_STRING( "X-Accept-Language: " );
|
||||
PUSH_STRING( acceptlang );
|
||||
|
|
Загрузка…
Ссылка в новой задаче