Bug 187771 junk mail controls should whitelist on multiple address books

p=me r=neil sr=mscott
This commit is contained in:
bugzilla%arlen.demon.co.uk 2007-04-30 22:56:18 +00:00
Родитель 42ff015140
Коммит 6cad686612
3 изменённых файлов: 79 добавлений и 53 удалений

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

@ -65,9 +65,17 @@ function onInit(aPageId, aServerId)
SetFolderPicker(spamActionTargetFolder, 'actionTargetFolder');
// set up the whitelist UI
document.getElementById("whiteListAbURI").value =
document.getElementById("server.whiteListAbURI").value;
var wList = document.getElementById("whiteListAbURI");
var currentArray = [];
if (document.getElementById("server.useWhiteList").checked)
currentArray = document.getElementById("server.whiteListAbURI").value.split(" ");
for (var i = 0; i < wList.getRowCount(); i++)
{
var wlNode = wList.getItemAtIndex(i);
wlNode.checked = (currentArray.indexOf(wlNode.id) > -1);
}
// set up trusted IP headers
var serverFilterList = document.getElementById("useServerFilterList");
serverFilterList.value =
@ -105,12 +113,27 @@ function onServerFilterListChange()
document.getElementById("useServerFilterList").value;
}
function onSave()
{
onSaveWhiteList();
}
// propagate changes to the whitelist menu list back to
// our hidden wsm element.
function onWhiteListAbURIChange()
function onSaveWhiteList()
{
document.getElementById('server.whiteListAbURI').value =
document.getElementById("whiteListAbURI").value;
var wList = document.getElementById("whiteListAbURI");
var wlArray = [];
for (var i = 0; i < wList.getRowCount(); i++)
{
var wlNode = wList.getItemAtIndex(i);
if (wlNode.checked)
wlArray.push(wlNode.id);
}
var wlValue = wlArray.join(" ");
document.getElementById("server.whiteListAbURI").setAttribute("value", wlValue);
document.getElementById("server.useWhiteList").checked = (wlValue != "");
}
function onActionTargetChange(aMenuList, aWSMElementId)

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

@ -84,42 +84,34 @@
accesskey="&level.accesskey;" label="&level.label;"/>
<separator class="thin"/>
<grid>
<columns>
<column flex="1"/>
<column/>
</columns>
<rows>
<row align="center">
<checkbox id="server.useWhiteList"
genericattr="true" pref="true" wsm_persist="true" preftype="bool"
prefstring="mail.server.%serverkey%.useWhiteList"
accesskey="&whitelist.accesskey;" label="&whitelist.label;"/>
<menulist id="whiteListAbURI" oncommand="onWhiteListAbURIChange();" datasources="rdf:addressdirectory"
ref="moz-abdirectory://" sortActive="true" sortDirection="ascending"
sortResource="http://home.netscape.com/NC-rdf#DirTreeNameSort">
<template>
<rule nc:IsWriteable="false"/>
<rule nc:IsMailList="false">
<menupopup>
<menuitem uri="..."
label="rdf:http://home.netscape.com/NC-rdf#DirName"
value="rdf:http://home.netscape.com/NC-rdf#DirUri"/>
</menupopup>
</rule>
</template>
</menulist>
</row>
<row align="center">
<checkbox id="server.useServerFilter" label="&ispHeaders.label;" accesskey="&ispHeaders.accesskey;"
genericattr="true" pref="true" wsm_persist="true" preftype="bool"
prefstring="mail.server.%serverkey%.useServerFilter"/>
<menulist id="useServerFilterList" oncommand="onServerFilterListChange();"/>
</row>
</rows>
</grid>
<checkbox hidden="true" id="server.useWhiteList"
genericattr="true" pref="true" wsm_persist="true" preftype="bool"
prefstring="mail.server.%serverkey%.useWhiteList"/>
<label value="&whitelist.label;" accesskey="&whitelist.accesskey;"
control="whiteListAbURI"/>
<listbox id="whiteListAbURI" rows="5"
ref="moz-abdirectory://" datasources="rdf:addressdirectory"
sortActive="true" sortDirection="ascending"
sortResource="http://home.netscape.com/NC-rdf#DirTreeNameSort">
<template>
<rule nc:IsWriteable="false"/>
<rule nc:IsMailList="false">
<listitem uri="rdf:*" type="checkbox" class="listitem-iconic"
label="rdf:http://home.netscape.com/NC-rdf#DirName"
value="rdf:http://home.netscape.com/NC-rdf#DirUri"/>
</rule>
</template>
</listbox>
<vbox>
<hbox>
<checkbox id="server.useServerFilter" label="&ispHeaders.label;"
accesskey="&ispHeaders.accesskey;"
genericattr="true" pref="true" wsm_persist="true" preftype="bool"
prefstring="mail.server.%serverkey%.useServerFilter"/>
<menulist id="useServerFilterList" oncommand="onServerFilterListChange();"/>
</hbox>
</vbox>
<checkbox id="server.moveOnSpam" label="&move.label;" oncommand="updateMoveTargetMode(this.checked);"
wsm_persist="true" pref="true" preftype="bool" genericattr="true"

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

@ -1892,7 +1892,7 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow *aMsgWindow, PRBool *aFiltersRun)
*aFiltersRun = PR_FALSE;
nsCOMPtr<nsIMsgIncomingServer> server;
nsCOMPtr<nsISpamSettings> spamSettings;
nsCOMPtr<nsIAbMDBDirectory> whiteListDirectory;
nsCOMArray<nsIAbMDBDirectory> whiteListDirArray;
nsCOMPtr<nsIMsgHeaderParser> headerParser;
PRBool useWhiteList = PR_FALSE;
PRInt32 spamLevel = 0;
@ -1985,12 +1985,18 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow *aMsgWindow, PRBool *aFiltersRun)
nsCOMPtr <nsIRDFService> rdfService = do_GetService("@mozilla.org/rdf/rdf-service;1",&rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr <nsIRDFResource> resource;
rv = rdfService->GetResource(whiteListAbURI, getter_AddRefs(resource));
NS_ENSURE_SUCCESS(rv, rv);
nsCStringArray whiteListArray;
whiteListArray.ParseString(whiteListAbURI.get(), " ");
whiteListDirectory = do_QueryInterface(resource, &rv);
NS_ENSURE_SUCCESS(rv, rv);
for (PRInt32 index = 0; index < whiteListArray.Count(); index++)
{
nsCOMPtr<nsIRDFResource> resource;
rv = rdfService->GetResource(*whiteListArray[index], getter_AddRefs(resource));
nsCOMPtr<nsIAbMDBDirectory> whiteListDirectory = do_QueryInterface(resource, &rv);
if (whiteListDirectory)
whiteListDirArray.AppendObject(whiteListDirectory);
}
}
// if we can't get the db, we probably want to continue firing spam filters.
}
@ -2000,7 +2006,7 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow *aMsgWindow, PRBool *aFiltersRun)
if (prefBranch)
prefBranch->GetCharPref("mail.trusteddomains", getter_Copies(trustedMailDomains));
if (whiteListDirectory || !trustedMailDomains.IsEmpty())
if (whiteListDirArray.Count() != 0 || !trustedMailDomains.IsEmpty())
{
headerParser = do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
@ -2022,7 +2028,7 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow *aMsgWindow, PRBool *aFiltersRun)
continue;
nsXPIDLCString author;
nsXPIDLCString authorEmailAddress;
if (whiteListDirectory || !trustedMailDomains.IsEmpty())
if (whiteListDirArray.Count() != 0 || !trustedMailDomains.IsEmpty())
{
msgHdr->GetAuthor(getter_Copies(author));
rv = headerParser->ExtractHeaderAddressMailboxes(nsnull, author.get(), getter_Copies(authorEmailAddress));
@ -2046,15 +2052,20 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgWindow *aMsgWindow, PRBool *aFiltersRun)
if (!junkScore.IsEmpty()) // ignore already scored messages.
continue;
// check whitelist first:
if (whiteListDirectory)
if (whiteListDirArray.Count() != 0)
{
if (NS_SUCCEEDED(rv))
{
PRBool cardExists = PR_FALSE;
// don't want to abort the rest of the scoring.
if (!authorEmailAddress.IsEmpty())
rv = whiteListDirectory->HasCardForEmailAddress(authorEmailAddress, &cardExists);
if (NS_SUCCEEDED(rv) && cardExists)
{
for (PRInt32 index = 0; index < whiteListDirArray.Count() && !cardExists; index++)
rv = whiteListDirArray[index]->HasCardForEmailAddress(authorEmailAddress, &cardExists);
if (NS_FAILED(rv))
cardExists = PR_FALSE;
}
if (cardExists)
{
// mark this msg as non-junk, because we whitelisted it.
mDatabase->SetStringProperty(msgKey, "junkscore", "0");