зеркало из https://github.com/mozilla/gecko-dev.git
fix for bug #194273
move to junk folder (or delete) when the user manually marks as junk. this was one of the top usability items we found, during UE studies r/sr=bienvenu, a=sspitzer
This commit is contained in:
Родитель
84e7a3a1b4
Коммит
fdd4cc0957
|
@ -337,4 +337,10 @@ interface nsIMsgDBViewCommandUpdater : nsISupports
|
|||
|
||||
/* displayed message has changed */
|
||||
void displayMessageChanged(in nsIMsgFolder aFolder, in wstring aSubject, in string aKeywords);
|
||||
|
||||
/**
|
||||
* allows the backend to tell the front end to re-determine
|
||||
* which message we should selet after a delete or move
|
||||
*/
|
||||
void updateNextMessageAfterDelete();
|
||||
};
|
||||
|
|
|
@ -79,7 +79,16 @@ interface nsISpamSettings: nsISupports {
|
|||
|
||||
attribute boolean useWhiteList;
|
||||
attribute string whiteListAbURI;
|
||||
|
||||
|
||||
/**
|
||||
* should we do something (move or delete)
|
||||
* when the user manually marks a message as junk?
|
||||
*/
|
||||
attribute boolean manualMark;
|
||||
attribute long manualMarkMode;
|
||||
const long MANUAL_MARK_MODE_MOVE = 0;
|
||||
const long MANUAL_MARK_MODE_DELETE = 1;
|
||||
|
||||
// for logging
|
||||
attribute boolean loggingEnabled;
|
||||
attribute nsIOutputStream logStream;
|
||||
|
|
|
@ -144,6 +144,10 @@ function setupForAccountFromFolder(aURI)
|
|||
menuitems = abList.getElementsByAttribute("id", obj.settings.whiteListAbURI);
|
||||
abList.selectedItem = menuitems[0];
|
||||
|
||||
// set up the manual mark UI
|
||||
document.getElementById("manualMark").checked = obj.settings.manualMark;
|
||||
document.getElementById("manualMarkMode").selectedItem = document.getElementById("manualMarkMode" + obj.settings.manualMarkMode);
|
||||
|
||||
conditionallyEnableUI(null);
|
||||
}
|
||||
|
||||
|
@ -193,6 +197,9 @@ function storeSettings(aSettings, aLoggingEnabled)
|
|||
aSettings.useWhiteList = document.getElementById("useWhiteList").checked;
|
||||
aSettings.whiteListAbURI = document.getElementById("whiteListAbURI").selectedItem.getAttribute("id");
|
||||
aSettings.loggingEnabled = aLoggingEnabled;
|
||||
|
||||
aSettings.manualMark = document.getElementById("manualMark").checked;
|
||||
aSettings.manualMarkMode = document.getElementById("manualMarkMode").value;
|
||||
}
|
||||
|
||||
function conditionallyEnableUI(id)
|
||||
|
@ -209,13 +216,24 @@ function conditionallyEnableUI(id)
|
|||
document.getElementById("purge").disabled = true;
|
||||
document.getElementById("purgeInterval").disabled = true;
|
||||
document.getElementById("purgeLabel").disabled = true;
|
||||
|
||||
document.getElementById("manualMark").disabled = true;
|
||||
document.getElementById("manualMarkMode").disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById("useWhiteList").disabled = false;
|
||||
document.getElementById("moveOnSpam").disabled = false;
|
||||
|
||||
document.getElementById("manualMark").disabled = false;
|
||||
|
||||
var enabled;
|
||||
|
||||
if (!id || id == "manualMark") {
|
||||
enabled = document.getElementById("manualMark").checked;
|
||||
// need to enable manualMarkMode before we enable manualMarkMode0
|
||||
document.getElementById("manualMarkMode").disabled = !enabled;
|
||||
}
|
||||
|
||||
if (!id || id == "moveOnSpam") {
|
||||
enabled = document.getElementById("moveOnSpam").checked;
|
||||
var choice = document.getElementById("moveTargetMode").value;
|
||||
|
@ -228,6 +246,9 @@ function conditionallyEnableUI(id)
|
|||
document.getElementById("purge").disabled = !enabled;
|
||||
document.getElementById("purgeInterval").disabled = !enabled || !checked;
|
||||
document.getElementById("purgeLabel").disabled = !enabled;
|
||||
|
||||
if (!document.getElementById("manualMarkMode").disabled)
|
||||
document.getElementById("manualMarkMode0").disabled = !enabled;
|
||||
}
|
||||
|
||||
if (id == "purge") {
|
||||
|
|
|
@ -146,4 +146,15 @@
|
|||
</hbox>
|
||||
</vbox>
|
||||
|
||||
<vbox align="start">
|
||||
<checkbox id="manualMark" oncommand="conditionallyEnableUI('manualMark')" label="&manualMark.label;"/>
|
||||
<hbox>
|
||||
<spacer width="20px"/>
|
||||
<radiogroup id="manualMarkMode">
|
||||
<radio id="manualMarkMode0" value="0" label="&manualMarkModeMove.label;"/>
|
||||
<radio id="manualMarkMode1" value="1" label="&manualMarkModeDelete.label;"/>
|
||||
</radiogroup>
|
||||
</hbox>
|
||||
</vbox>
|
||||
|
||||
</dialog>
|
||||
|
|
|
@ -561,7 +561,7 @@ function deleteJunkInFolder()
|
|||
//
|
||||
// XXX todo
|
||||
// should we try to set next message after delete
|
||||
// to the the previous selected message, if it was not junk?
|
||||
// to the message selected before we did all this, if it was not junk?
|
||||
SetNextMessageAfterDelete();
|
||||
view.doCommand(nsMsgViewCommandType.deleteMsg);
|
||||
}
|
|
@ -179,6 +179,11 @@ nsMsgDBViewCommandUpdater.prototype =
|
|||
goUpdateCommand("button_junk");
|
||||
},
|
||||
|
||||
updateNextMessageAfterDelete : function()
|
||||
{
|
||||
SetNextMessageAfterDelete();
|
||||
},
|
||||
|
||||
QueryInterface : function(iid)
|
||||
{
|
||||
if (iid.equals(Components.interfaces.nsIMsgDBViewCommandUpdater) ||
|
||||
|
|
|
@ -85,6 +85,11 @@ nsMsgDBViewCommandUpdater.prototype =
|
|||
goUpdateCommand("button_junk");
|
||||
},
|
||||
|
||||
updateNextMessageAfterDelete : function()
|
||||
{
|
||||
SetNextMessageAfterDelete();
|
||||
},
|
||||
|
||||
QueryInterface : function(iid)
|
||||
{
|
||||
if (iid.equals(Components.interfaces.nsIMsgDBViewCommandUpdater) ||
|
||||
|
|
|
@ -15,3 +15,6 @@
|
|||
<!ENTITY purge2.label "days from this folder">
|
||||
<!ENTITY whitelist.label "Do not mark messages as junk mail if the sender is in my address book:">
|
||||
<!ENTITY whitelist.accesskey "D">
|
||||
<!ENTITY manualMark.label "When I manually mark messages as Junk:">
|
||||
<!ENTITY manualMarkModeMove.label "Move them to the "Junk" folder">
|
||||
<!ENTITY manualMarkModeDelete.label "Delete them">
|
||||
|
|
|
@ -474,6 +474,11 @@ nsMsgSearchCommandUpdater.prototype =
|
|||
{
|
||||
},
|
||||
|
||||
updateNextMessageAfterDelete : function()
|
||||
{
|
||||
SetNextMessageAfterDelete();
|
||||
},
|
||||
|
||||
QueryInterface : function(iid)
|
||||
{
|
||||
if (iid.equals(Components.interfaces.nsIMsgDBViewCommandUpdater) ||
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "nsIMsgSearchSession.h"
|
||||
#include "nsIMsgCopyService.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsISpamSettings.h"
|
||||
|
||||
static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID);
|
||||
|
||||
|
@ -1894,9 +1895,8 @@ NS_IMETHODIMP nsMsgDBView::DoCommandWithFolder(nsMsgViewCommandTypeValue command
|
|||
// any order (e.g. order of discontiguous selection), we have to
|
||||
// sort the indices in order to find out which nsMsgViewIndex will
|
||||
// be deleted first.
|
||||
if (numIndices > 1) {
|
||||
NS_QuickSort (indices, numIndices, sizeof(nsMsgViewIndex), CompareViewIndices, nsnull);
|
||||
}
|
||||
if (numIndices > 1)
|
||||
NS_QuickSort(indices, numIndices, sizeof(nsMsgViewIndex), CompareViewIndices, nsnull);
|
||||
NoteStartChange(nsMsgViewNotificationCode::none, 0, 0);
|
||||
rv = ApplyCommandToIndicesWithFolder(command, indices, numIndices, destFolder);
|
||||
NoteEndChange(nsMsgViewNotificationCode::none, 0, 0);
|
||||
|
@ -2621,9 +2621,8 @@ nsresult nsMsgDBView::SetJunkScoreByIndex(nsIJunkMailPlugin *aJunkPlugin,
|
|||
// and told us the junk status of this message.
|
||||
//
|
||||
rv = SetStringPropertyByIndex(aIndex, "junkscoreorigin", "user");
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "SetStringPropertyByIndex failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -2637,44 +2636,195 @@ NS_IMETHODIMP
|
|||
nsMsgDBView::OnMessageClassified(const char *aMsgURI,
|
||||
nsMsgJunkStatus aClassification)
|
||||
{
|
||||
// is this the last url in the batch?
|
||||
//
|
||||
if ( mLastJunkUriInBatch.Equals(aMsgURI) ) {
|
||||
// we can't just use m_folder
|
||||
// as this might be from a cross folder search
|
||||
// see bug #180477
|
||||
//
|
||||
nsCOMPtr <nsIMsgFolder> folder;
|
||||
nsresult rv = GetFolderFromMsgURI(aMsgURI, getter_AddRefs(folder));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
// we can't just use m_folder
|
||||
// as this might be from a cross folder search
|
||||
// see bug #180477
|
||||
nsCOMPtr <nsIMsgFolder> folder;
|
||||
nsresult rv = GetFolderFromMsgURI(aMsgURI, getter_AddRefs(folder));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
rv = folder->GetServer(getter_AddRefs(server));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
rv = folder->GetServer(getter_AddRefs(server));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// save off the msg hdr, if we need to
|
||||
rv = SaveJunkMsgForAction(server, aMsgURI, aClassification);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// get the filter, and QI to the interface we want
|
||||
//
|
||||
nsCOMPtr<nsIMsgFilterPlugin> filterPlugin;
|
||||
rv = server->GetSpamFilterPlugin(getter_AddRefs(filterPlugin));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIJunkMailPlugin> junkPlugin =
|
||||
do_QueryInterface(filterPlugin, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// close out existing coalesced junk batches
|
||||
//
|
||||
for ( ; mOutstandingJunkBatches > 0 ; --mOutstandingJunkBatches ) {
|
||||
|
||||
// tell the plugin that all outstanding batches from us
|
||||
// have finished.
|
||||
//
|
||||
rv = junkPlugin->EndBatch();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
// is this the last url in the batch?
|
||||
if (mLastJunkUriInBatch.Equals(aMsgURI))
|
||||
{
|
||||
// get the filter, and QI to the interface we want
|
||||
nsCOMPtr<nsIMsgFilterPlugin> filterPlugin;
|
||||
rv = server->GetSpamFilterPlugin(getter_AddRefs(filterPlugin));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIJunkMailPlugin> junkPlugin = do_QueryInterface(filterPlugin, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// close out existing coalesced junk batches
|
||||
for ( ; mOutstandingJunkBatches > 0 ; --mOutstandingJunkBatches )
|
||||
{
|
||||
// tell the plugin that all outstanding batches from us
|
||||
// have finished.
|
||||
rv = junkPlugin->EndBatch();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = PerformActionOnJunkMsgs();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgDBView::PerformActionOnJunkMsgs()
|
||||
{
|
||||
PRUint32 numIndices = mJunkKeys.GetSize();
|
||||
// nothing to do, bail out
|
||||
if (!numIndices)
|
||||
{
|
||||
mJunkTargetFolder = nsnull; // just to be safe
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsMsgViewIndex *indices = (nsMsgViewIndex *)nsMemory::Alloc(numIndices * sizeof(nsMsgViewIndex));
|
||||
if (!indices)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
for (PRUint32 i=0;i<numIndices;i++)
|
||||
indices[i] = FindKey(mJunkKeys.GetAt(i), PR_TRUE /* expand */); // what if we don't find the index?
|
||||
|
||||
// tell the FE to call SetNextMessageAfterDelete() because a delete is coming
|
||||
nsresult rv = mCommandUpdater->UpdateNextMessageAfterDelete();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (numIndices > 1)
|
||||
NS_QuickSort(indices, numIndices, sizeof(nsMsgViewIndex), CompareViewIndices, nsnull);
|
||||
NoteStartChange(nsMsgViewNotificationCode::none, 0, 0);
|
||||
if (mJunkTargetFolder)
|
||||
rv = ApplyCommandToIndicesWithFolder(nsMsgViewCommandType::moveMessages, indices, numIndices, mJunkTargetFolder);
|
||||
else
|
||||
rv = ApplyCommandToIndices(nsMsgViewCommandType::deleteMsg, indices, numIndices);
|
||||
NoteEndChange(nsMsgViewNotificationCode::none, 0, 0);
|
||||
|
||||
mJunkKeys.RemoveAll();
|
||||
mJunkTargetFolder = nsnull;
|
||||
nsMemory::Free(indices);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "move or delete failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgDBView::SaveJunkMsgForAction(nsIMsgIncomingServer *aServer, const char *aMsgURI, nsMsgJunkStatus aClassification)
|
||||
{
|
||||
// we only care when the message gets marked as junk
|
||||
if (aClassification == nsIJunkMailPlugin::GOOD)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr <nsISpamSettings> spamSettings;
|
||||
nsresult rv = aServer->GetSpamSettings(getter_AddRefs(spamSettings));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// if the spam feature is disabled, do nothing
|
||||
// the user could still manually mark spam if the feature is disabled
|
||||
// but let's not move or delete in that scenario
|
||||
PRInt32 spamLevel;
|
||||
(void)spamSettings->GetLevel(&spamLevel);
|
||||
if (!spamLevel)
|
||||
return NS_OK;
|
||||
|
||||
// if the manual mark functionality is turned off, bail out.
|
||||
PRBool manualMark;
|
||||
(void)spamSettings->GetManualMark(&manualMark);
|
||||
if (!manualMark)
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 manualMarkMode;
|
||||
(void)spamSettings->GetManualMarkMode(&manualMarkMode);
|
||||
|
||||
nsCOMPtr <nsIMsgMessageService> msgMessageService;
|
||||
rv = GetMessageServiceFromURI(aMsgURI, getter_AddRefs(msgMessageService));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr <nsIMsgDBHdr> msgHdr;
|
||||
rv = msgMessageService->MessageURIToMsgHdr(aMsgURI, getter_AddRefs(msgHdr));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr <nsIMsgFolder> srcFolder;
|
||||
rv = msgHdr->GetFolder(getter_AddRefs(srcFolder));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsMsgKey msgKey;
|
||||
rv = msgHdr->GetMessageKey(&msgKey);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// we can execute the move or delete
|
||||
PRUint32 folderFlags;
|
||||
srcFolder->GetFlags(&folderFlags);
|
||||
|
||||
NS_ASSERTION(manualMarkMode == nsISpamSettings::MANUAL_MARK_MODE_MOVE || manualMarkMode == nsISpamSettings::MANUAL_MARK_MODE_DELETE, "bad mode");
|
||||
if (manualMarkMode == nsISpamSettings::MANUAL_MARK_MODE_MOVE)
|
||||
{
|
||||
PRBool moveOnSpam;
|
||||
(void)spamSettings->GetMoveOnSpam(&moveOnSpam);
|
||||
// if move of spam not enabled, bail out
|
||||
if (!moveOnSpam)
|
||||
return NS_OK;
|
||||
|
||||
// if this is a junk folder
|
||||
// (not only "the" junk folder for this account)
|
||||
// don't do the move
|
||||
if (folderFlags & MSG_FOLDER_FLAG_JUNK)
|
||||
return NS_OK;
|
||||
|
||||
nsXPIDLCString spamFolderURI;
|
||||
rv = spamSettings->GetSpamFolderURI(getter_Copies(spamFolderURI));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
NS_ASSERTION(!spamFolderURI.IsEmpty(), "spam folder is empty, can't move");
|
||||
if (!spamFolderURI.IsEmpty())
|
||||
{
|
||||
nsCOMPtr<nsIMsgFolder> destFolder;
|
||||
rv = GetExistingFolder(spamFolderURI.get(), getter_AddRefs(destFolder));
|
||||
if (NS_SUCCEEDED(rv) && destFolder)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// double check the assumptions
|
||||
if (mJunkKeys.GetSize())
|
||||
NS_ASSERTION(mJunkTargetFolder == nsnull, "junk folder should be null, no keys yet");
|
||||
else
|
||||
{
|
||||
NS_ASSERTION(!mJunkTargetFolder, "should have a junk folder at this point");
|
||||
NS_ASSERTION(mJunkTargetFolder == destFolder, "junk folder doesn't match");
|
||||
}
|
||||
#endif
|
||||
// save off msg key and folder
|
||||
mJunkKeys.Add(msgKey);
|
||||
if (!mJunkTargetFolder)
|
||||
mJunkTargetFolder = destFolder;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // manualMarkMode == nsISpamSettings::MANUAL_MARK_MODE_DELETE)
|
||||
{
|
||||
// if this is in the trash, don't delete?
|
||||
if (folderFlags & MSG_FOLDER_FLAG_TRASH)
|
||||
return NS_OK;
|
||||
|
||||
// we can't delete, bail out
|
||||
PRBool canDelete;
|
||||
(void)srcFolder->GetCanDeleteMessages(&canDelete);
|
||||
if (!canDelete)
|
||||
return NS_OK;
|
||||
|
||||
// save off msg key
|
||||
mJunkKeys.Add(msgKey);
|
||||
NS_ASSERTION(mJunkTargetFolder == nsnull, "should be null");
|
||||
mJunkTargetFolder = nsnull; // should already be null
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// reversing threads involves reversing the threads but leaving the
|
||||
|
@ -5097,7 +5247,7 @@ nsresult nsMsgDBView::ToggleIgnored(nsMsgViewIndex * indices, PRInt32 numIndices
|
|||
else
|
||||
{
|
||||
if (numIndices > 1)
|
||||
NS_QuickSort (indices, numIndices, sizeof(nsMsgViewIndex), CompareViewIndices, nsnull);
|
||||
NS_QuickSort(indices, numIndices, sizeof(nsMsgViewIndex), CompareViewIndices, nsnull);
|
||||
for (int curIndex = numIndices - 1; curIndex >= 0; curIndex--)
|
||||
{
|
||||
// here we need to build up the unique threads, and mark them ignored.
|
||||
|
@ -5170,7 +5320,7 @@ nsresult nsMsgDBView::ToggleWatched( nsMsgViewIndex* indices, PRInt32 numIndices
|
|||
else
|
||||
{
|
||||
if (numIndices > 1)
|
||||
NS_QuickSort (indices, numIndices, sizeof(nsMsgViewIndex), CompareViewIndices, nsnull);
|
||||
NS_QuickSort(indices, numIndices, sizeof(nsMsgViewIndex), CompareViewIndices, nsnull);
|
||||
for (int curIndex = numIndices - 1; curIndex >= 0; curIndex--)
|
||||
{
|
||||
nsMsgViewIndex threadIndex;
|
||||
|
|
|
@ -365,7 +365,6 @@ protected:
|
|||
|
||||
// used to know to finish out the junk mail classification batch when the
|
||||
// last classification callback happens
|
||||
//
|
||||
nsCString mLastJunkUriInBatch;
|
||||
PRUint8 mOutstandingJunkBatches;
|
||||
|
||||
|
@ -377,6 +376,11 @@ private:
|
|||
static nsDateFormatSelector m_dateFormatThisWeek;
|
||||
static nsDateFormatSelector m_dateFormatToday;
|
||||
PRBool ServerSupportsFilterAfterTheFact();
|
||||
|
||||
nsMsgKeyArray mJunkKeys;
|
||||
nsCOMPtr <nsIMsgFolder> mJunkTargetFolder;
|
||||
nsresult PerformActionOnJunkMsgs();
|
||||
nsresult SaveJunkMsgForAction(nsIMsgIncomingServer *aServer, const char *aMsgURI, nsMsgJunkStatus aClassification);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -210,10 +210,10 @@ nsresult nsMsgPurgeService::PerformPurge()
|
|||
rv = server->GetSpamSettings(getter_AddRefs(spamSettings));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 spamLevel = 0;
|
||||
PRInt32 spamLevel;
|
||||
spamSettings->GetLevel(&spamLevel);
|
||||
PR_LOG(MsgPurgeLogModule, PR_LOG_ALWAYS, ("[%d] spamLevel=%d (if 0, don't purge)", serverIndex, spamLevel));
|
||||
if (spamLevel == 0)
|
||||
if (!spamLevel)
|
||||
continue;
|
||||
|
||||
// check if we are set up to purge for this server
|
||||
|
|
|
@ -62,6 +62,8 @@ nsSpamSettings::nsSpamSettings()
|
|||
mPurgeInterval = 14; // 14 days
|
||||
mUseWhiteList = PR_FALSE;
|
||||
mLoggingEnabled = PR_FALSE;
|
||||
mManualMark = PR_FALSE;
|
||||
mManualMarkMode = nsISpamSettings::MANUAL_MARK_MODE_MOVE;
|
||||
}
|
||||
|
||||
nsSpamSettings::~nsSpamSettings()
|
||||
|
@ -95,16 +97,31 @@ nsSpamSettings::GetMoveTargetMode(PRInt32 *aMoveTargetMode)
|
|||
|
||||
NS_IMETHODIMP nsSpamSettings::SetMoveTargetMode(PRInt32 aMoveTargetMode)
|
||||
{
|
||||
NS_ASSERTION((aMoveTargetMode == 0 || aMoveTargetMode == 1), "bad mode");
|
||||
NS_ASSERTION((aMoveTargetMode == nsISpamSettings::MOVE_TARGET_MODE_FOLDER || aMoveTargetMode == nsISpamSettings::MOVE_TARGET_MODE_ACCOUNT), "bad move target mode");
|
||||
mMoveTargetMode = aMoveTargetMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSpamSettings::GetManualMarkMode(PRInt32 *aManualMarkMode)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aManualMarkMode);
|
||||
*aManualMarkMode = mManualMarkMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSpamSettings::SetManualMarkMode(PRInt32 aManualMarkMode)
|
||||
{
|
||||
NS_ASSERTION((aManualMarkMode == nsISpamSettings::MANUAL_MARK_MODE_MOVE || aManualMarkMode == nsISpamSettings::MANUAL_MARK_MODE_DELETE), "bad manual mark mode");
|
||||
mManualMarkMode = aManualMarkMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_GETSET(nsSpamSettings, LoggingEnabled, PRBool, mLoggingEnabled);
|
||||
NS_IMPL_GETSET(nsSpamSettings, MoveOnSpam, PRBool, mMoveOnSpam);
|
||||
NS_IMPL_GETSET(nsSpamSettings, Purge, PRBool, mPurge);
|
||||
NS_IMPL_GETSET(nsSpamSettings, UseWhiteList, PRBool, mUseWhiteList);
|
||||
|
||||
NS_IMPL_GETSET(nsSpamSettings, ManualMark, PRBool, mManualMark);
|
||||
|
||||
NS_IMETHODIMP nsSpamSettings::GetWhiteListAbURI(char * *aWhiteListAbURI)
|
||||
{
|
||||
|
@ -327,11 +344,10 @@ NS_IMETHODIMP nsSpamSettings::Clone(nsISpamSettings *aSpamSettings)
|
|||
nsresult rv = aSpamSettings->GetUseWhiteList(&mUseWhiteList);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = aSpamSettings->GetMoveOnSpam(&mMoveOnSpam);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = aSpamSettings->GetPurge(&mPurge);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
(void)aSpamSettings->GetMoveOnSpam(&mMoveOnSpam);
|
||||
(void)aSpamSettings->GetManualMark(&mManualMark);
|
||||
(void)aSpamSettings->GetManualMarkMode(&mManualMarkMode);
|
||||
(void)aSpamSettings->GetPurge(&mPurge);
|
||||
|
||||
rv = aSpamSettings->GetPurgeInterval(&mPurgeInterval);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
@ -371,7 +387,7 @@ NS_IMETHODIMP nsSpamSettings::GetSpamFolderURI(char **aSpamFolderURI)
|
|||
if (mMoveTargetMode == nsISpamSettings::MOVE_TARGET_MODE_FOLDER)
|
||||
return GetActionTargetFolder(aSpamFolderURI);
|
||||
|
||||
// if the mode is MOVE_TARGET_MODE_ACCOUNT
|
||||
// if the mode is nsISpamSettings::MOVE_TARGET_MODE_ACCOUNT
|
||||
// the spam folder URI = account uri + "/Junk"
|
||||
nsXPIDLCString folderURI;
|
||||
nsresult rv = GetActionTargetAccount(getter_Copies(folderURI));
|
||||
|
|
|
@ -59,23 +59,24 @@ public:
|
|||
|
||||
private:
|
||||
nsCOMPtr <nsIMsgIncomingServer> mServer; // make a weak ref?
|
||||
nsCOMPtr <nsIOutputStream> mLogStream;
|
||||
|
||||
PRInt32 mManualMarkMode;
|
||||
PRInt32 mLevel;
|
||||
|
||||
PRBool mMoveOnSpam;
|
||||
PRInt32 mPurgeInterval;
|
||||
PRInt32 mMoveTargetMode;
|
||||
|
||||
PRBool mManualMark;
|
||||
PRBool mLoggingEnabled;
|
||||
PRBool mPurge;
|
||||
PRBool mUseWhiteList;
|
||||
PRBool mMoveOnSpam;
|
||||
|
||||
nsCString mActionTargetAccount;
|
||||
nsCString mActionTargetFolder;
|
||||
|
||||
PRBool mPurge;
|
||||
PRInt32 mPurgeInterval;
|
||||
|
||||
PRBool mUseWhiteList;
|
||||
nsCString mWhiteListAbURI;
|
||||
|
||||
PRBool mLoggingEnabled;
|
||||
nsCOMPtr <nsIOutputStream> mLogStream;
|
||||
nsCString mLogURL;
|
||||
|
||||
nsresult GetLogFileSpec(nsIFileSpec **aFileSpec);
|
||||
nsresult TruncateLog();
|
||||
};
|
||||
|
|
|
@ -1720,7 +1720,7 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow *aMsgWindow)
|
|||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
spamSettings->GetLevel(&spamLevel);
|
||||
if (spamLevel == 0)
|
||||
if (!spamLevel)
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIMsgMailSession> mailSession =
|
||||
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||
|
|
|
@ -1907,16 +1907,20 @@ nsMsgIncomingServer::SetSpamSettings(nsISpamSettings *aSpamSettings)
|
|||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRBool moveOnSpam;
|
||||
rv = mSpamSettings->GetMoveOnSpam(&moveOnSpam);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = SetBoolValue("moveOnSpam", moveOnSpam);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
(void)mSpamSettings->GetMoveOnSpam(&moveOnSpam);
|
||||
(void)SetBoolValue("moveOnSpam", moveOnSpam);
|
||||
|
||||
PRInt32 moveTargetMode;
|
||||
rv = mSpamSettings->GetMoveTargetMode(&moveTargetMode);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = SetIntValue("moveTargetMode", moveTargetMode);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
(void)mSpamSettings->GetMoveTargetMode(&moveTargetMode);
|
||||
(void)SetIntValue("moveTargetMode", moveTargetMode);
|
||||
|
||||
PRBool manualMark;
|
||||
(void)mSpamSettings->GetManualMark(&manualMark);
|
||||
(void)SetBoolValue("manualMark", manualMark);
|
||||
|
||||
PRInt32 manualMarkMode;
|
||||
(void)mSpamSettings->GetManualMarkMode(&manualMarkMode);
|
||||
(void)SetIntValue("manualMarkMode", manualMarkMode);
|
||||
|
||||
nsXPIDLCString spamActionTargetAccount;
|
||||
rv = mSpamSettings->GetActionTargetAccount(getter_Copies(spamActionTargetAccount));
|
||||
|
@ -2016,6 +2020,14 @@ nsMsgIncomingServer::GetSpamSettings(nsISpamSettings **aSpamSettings)
|
|||
rv = mSpamSettings->SetMoveTargetMode(moveTargetMode);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
PRBool manualMark;
|
||||
(void)GetBoolValue("manualMark", &manualMark);
|
||||
(void)mSpamSettings->SetManualMark(manualMark);
|
||||
|
||||
PRInt32 manualMarkMode;
|
||||
(void)GetIntValue("manualMarkMode", &manualMarkMode);
|
||||
(void)mSpamSettings->SetManualMarkMode(manualMarkMode);
|
||||
|
||||
nsXPIDLCString spamActionTargetAccount;
|
||||
rv = GetCharValue("spamActionTargetAccount", getter_Copies(spamActionTargetAccount));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
|
|
@ -7251,11 +7251,8 @@ nsImapMailFolder::OnMessageClassified(const char *aMsgURI, nsMsgJunkStatus aClas
|
|||
// or when manually classifying messages in those folders
|
||||
if (!(mFlags & MSG_FOLDER_FLAG_JUNK || mFlags & MSG_FOLDER_FLAG_TRASH))
|
||||
{
|
||||
PRBool moveOnSpam = PR_FALSE;
|
||||
|
||||
rv = spamSettings->GetMoveOnSpam(&moveOnSpam);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool moveOnSpam;
|
||||
(void)spamSettings->GetMoveOnSpam(&moveOnSpam);
|
||||
if (moveOnSpam)
|
||||
{
|
||||
rv = spamSettings->GetSpamFolderURI(getter_Copies(spamFolderURI));
|
||||
|
|
|
@ -371,6 +371,8 @@ pref("mail.server.default.whiteListAbURI","moz-abmdbdirectory://abook.mab"); //
|
|||
pref("mail.server.default.purgeSpam",false);
|
||||
pref("mail.server.default.purgeSpamInterval",14); // 14 days
|
||||
pref("mail.server.default.spamLoggingEnabled",false);
|
||||
pref("mail.server.default.manualMark",false);
|
||||
pref("mail.server.default.manualMarkMode",0); // 0 == "move to junk folder", 1 == "delete"
|
||||
|
||||
pref("mail.smtpserver.default.auth_method", 1); // auth any
|
||||
pref("mail.smtpserver.default.try_ssl", 0);
|
||||
|
|
|
@ -371,6 +371,8 @@ pref("mail.server.default.whiteListAbURI","moz-abmdbdirectory://abook.mab"); //
|
|||
pref("mail.server.default.purgeSpam",false);
|
||||
pref("mail.server.default.purgeSpamInterval",14); // 14 days
|
||||
pref("mail.server.default.spamLoggingEnabled",false);
|
||||
pref("mail.server.default.manualMark",false);
|
||||
pref("mail.server.default.manualMarkMode",0); // 0 == "move to junk folder", 1 == "delete"
|
||||
|
||||
pref("mail.smtpserver.default.auth_method", 1); // auth any
|
||||
pref("mail.smtpserver.default.try_ssl", 0);
|
||||
|
|
Загрузка…
Ссылка в новой задаче