Bug #257990 --> mark spam as read is now a global option and not account specific.

sr=bienvenu
This commit is contained in:
scott%scott-macgregor.org 2006-05-19 22:53:27 +00:00
Родитель 2f9abe7353
Коммит 5f0af21259
4 изменённых файлов: 40 добавлений и 17 удалений

Просмотреть файл

@ -53,7 +53,7 @@ interface nsISpamSettings: nsISupports {
attribute long level;
attribute boolean moveOnSpam;
attribute boolean markAsReadOnSpam;
readonly attribute boolean markAsReadOnSpam;
/**
* Most consumers will just use spamFolderURI rather than accessing any of

Просмотреть файл

@ -698,6 +698,8 @@ function OnLoadMessenger()
InitializeDataSources();
InitPanes();
MigrateJunkMailSettings();
accountManager.setSpecialFolders();
accountManager.loadVirtualFolders();
@ -1586,3 +1588,31 @@ function GetFolderAttribute(tree, source, attribute)
return target;
}
// Some of the per account junk mail settings have been
// converted to global prefs. Let's try to migrate some
// of those settings from the default account.
function MigrateJunkMailSettings()
{
var junkMailSettingsVersion = pref.getIntPref("mail.spam.version");
if (!junkMailSettingsVersion)
{
// get the default account, check to see if we have values for our
// globally migrated prefs.
var defaultAccount = accountManager.defaultAccount;
if (defaultAccount && defaultAccount.incomingServer)
{
// we only care about
var prefix = "mail.server." + defaultAccount.incomingServer.key + ".";
if (pref.prefHasUserValue(prefix + "manualMark"))
pref.setBoolPref("mail.spam.manualMark", pref.getBoolPref(prefix + "manualMark"));
if (pref.prefHasUserValue(prefix + "manualMarkMode"))
pref.setIntPref("mail.spam.manualMarkMode", pref.getIntPref(prefix + "manualMarkMode"));
if (pref.prefHasUserValue(prefix + "spamLoggingEnabled"))
pref.setBoolPref("mail.spam.logging.enabled", pref.getBoolPref(prefix + "spamLoggingEnabled"));
if (pref.prefHasUserValue(prefix + "markAsReadOnSpam"))
pref.setBoolPref("mail.spam.markAsReadOnSpam", pref.getBoolPref(prefix + "markAsReadOnSpam"));
}
// bump the version so we don't bother doing this again.
pref.setIntPref("mail.spam.version", 1);
}
}

Просмотреть файл

@ -61,7 +61,6 @@ nsSpamSettings::nsSpamSettings()
{
mLevel = 0;
mMoveOnSpam = PR_FALSE;
mMarkAsReadOnSpam = PR_FALSE;
mMoveTargetMode = nsISpamSettings::MOVE_TARGET_MODE_ACCOUNT;
mPurge = PR_FALSE;
mPurgeInterval = 14; // 14 days
@ -69,9 +68,7 @@ nsSpamSettings::nsSpamSettings()
mServerFilterTrustFlags = 0;
mUseWhiteList = PR_FALSE;
mManualMark = PR_FALSE;
mUseServerFilter = PR_FALSE;
mManualMarkMode = nsISpamSettings::MANUAL_MARK_MODE_MOVE;
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mLogFile));
if (NS_SUCCEEDED(rv))
@ -141,8 +138,16 @@ NS_IMETHODIMP nsSpamSettings::GetLoggingEnabled(PRBool *aLoggingEnabled)
return prefBranch->GetBoolPref("mail.spam.logging.enabled", aLoggingEnabled);
}
NS_IMETHODIMP nsSpamSettings::GetMarkAsReadOnSpam(PRBool *aMarkAsReadOnSpam)
{
NS_ENSURE_ARG_POINTER(aMarkAsReadOnSpam);
nsresult rv;
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
return prefBranch->GetBoolPref("mail.spam.markAsReadOnSpam", aMarkAsReadOnSpam);
}
NS_IMPL_GETSET(nsSpamSettings, MoveOnSpam, PRBool, mMoveOnSpam)
NS_IMPL_GETSET(nsSpamSettings, MarkAsReadOnSpam, PRBool, mMarkAsReadOnSpam)
NS_IMPL_GETSET(nsSpamSettings, Purge, PRBool, mPurge)
NS_IMPL_GETSET(nsSpamSettings, UseWhiteList, PRBool, mUseWhiteList)
NS_IMPL_GETSET(nsSpamSettings, UseServerFilter, PRBool, mUseServerFilter)
@ -252,12 +257,6 @@ NS_IMETHODIMP nsSpamSettings::Initialize(nsIMsgIncomingServer *aServer)
rv = SetMoveOnSpam(moveOnSpam);
NS_ENSURE_SUCCESS(rv, rv);
PRBool markAsReadOnSpam;
rv = aServer->GetBoolValue("markAsReadOnSpam", &markAsReadOnSpam);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetMarkAsReadOnSpam(markAsReadOnSpam);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 moveTargetMode;
rv = aServer->GetIntValue("moveTargetMode", &moveTargetMode);
NS_ENSURE_SUCCESS(rv, rv);
@ -366,9 +365,6 @@ NS_IMETHODIMP nsSpamSettings::Clone(nsISpamSettings *aSpamSettings)
NS_ENSURE_SUCCESS(rv,rv);
(void)aSpamSettings->GetMoveOnSpam(&mMoveOnSpam);
(void)aSpamSettings->GetMarkAsReadOnSpam(&mMarkAsReadOnSpam);
(void)aSpamSettings->GetManualMark(&mManualMark);
(void)aSpamSettings->GetManualMarkMode(&mManualMarkMode);
(void)aSpamSettings->GetPurge(&mPurge);
(void)aSpamSettings->GetUseServerFilter(&mUseServerFilter);

Просмотреть файл

@ -62,16 +62,13 @@ private:
nsCOMPtr <nsIOutputStream> mLogStream;
nsCOMPtr<nsIFile> mLogFile;
PRInt32 mManualMarkMode;
PRInt32 mLevel;
PRInt32 mPurgeInterval;
PRInt32 mMoveTargetMode;
PRBool mManualMark;
PRBool mPurge;
PRBool mUseWhiteList;
PRBool mMoveOnSpam;
PRBool mMarkAsReadOnSpam;
PRBool mUseServerFilter;
nsCString mActionTargetAccount;