зеркало из https://github.com/mozilla/pjs.git
more spam work.
This commit is contained in:
Родитель
8f6d1289a8
Коммит
86e1e22a7a
|
@ -1,67 +1,110 @@
|
||||||
var gSpamSettings;
|
var gSpamSettings = {};
|
||||||
varg gServer;
|
var gCurrentServer;
|
||||||
|
var gMessengerBundle = document.getElementById("bundle_messenger");
|
||||||
|
|
||||||
function onJunkMailLoad()
|
function onJunkMailLoad()
|
||||||
{
|
{
|
||||||
if (window.arguments && window.arguments[0])
|
if (window.arguments && window.arguments[0]) {
|
||||||
setupForAccountFromFolder(window.arguments[0].folder);
|
// XXX todo, what if no folder?
|
||||||
|
setupForAccountFromFolder(window.arguments[0].folder.URI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onServerClick()
|
function onServerClick(event)
|
||||||
{
|
{
|
||||||
|
if (gCurrentServer.serverURI == event.target.id)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// before we set the UI for the new server,
|
||||||
|
// save off the old one
|
||||||
|
storeSettings(gSpamSettings[gCurrentServer.key].settings);
|
||||||
|
|
||||||
|
// set up the UI for the server
|
||||||
|
setupForAccountFromFolder(event.target.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupForAccountFromFolder(folder)
|
function setupForAccountFromFolder(aURI)
|
||||||
{
|
{
|
||||||
// make sure we do the right thing for the stand alone msg window
|
// XXX todo
|
||||||
|
// XXX make sure we do the right thing for the stand alone msg window
|
||||||
|
// XXX if no folders are selected or if a folder that doesn't get mail (news, local?) is selected
|
||||||
try {
|
try {
|
||||||
var msgFolder = GetMsgFolderFromUri(folder.URI, false);
|
var msgFolder = GetMsgFolderFromUri(aURI, false);
|
||||||
gServer = msgFolder.server;
|
gCurrentServer = msgFolder.server;
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
// get server for default account
|
// get server for default account
|
||||||
var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"]
|
var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"]
|
||||||
.getService(Components.interfaces.nsIMsgAccountManager);
|
.getService(Components.interfaces.nsIMsgAccountManager);
|
||||||
var account = accountManager.defaultAccount;
|
var account = accountManager.defaultAccount;
|
||||||
gServer = account.incomingServer;
|
gCurrentServer = account.incomingServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get and clone spam settings for this server
|
var obj;
|
||||||
// we clone because if the users cancels we are going to throw away the changes
|
var key = gCurrentServer.key;
|
||||||
gSpamSettings = Components.classes["@mozilla.org/messenger/spamsettings;1"].createInstance(Components.interfaces.nsISpamSettings);
|
|
||||||
gSpamSettings.clone(gServer.spamSettings);
|
if (key in gSpamSettings) {
|
||||||
|
obj = gSpamSettings[key];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// get and clone spam settings for this server
|
||||||
|
// we clone because if the users cancels we are going to throw away the changes
|
||||||
|
var settings = Components.classes["@mozilla.org/messenger/spamsettings;1"].createInstance(Components.interfaces.nsISpamSettings);
|
||||||
|
settings.clone(gCurrentServer.spamSettings);
|
||||||
|
obj = {server: gCurrentServer, settings: settings};
|
||||||
|
gSpamSettings[key] = obj;
|
||||||
|
}
|
||||||
|
|
||||||
// select server in the menulist
|
// select server in the menulist
|
||||||
var serverList = document.getElementById("server");
|
var serverList = document.getElementById("server");
|
||||||
var menuitems = serverList.getElementsByAttribute("id", server.serverURI);
|
var menuitems = serverList.getElementsByAttribute("id", obj.server.serverURI);
|
||||||
serverList.selectedItem = menuitems[0];
|
serverList.selectedItem = menuitems[0];
|
||||||
|
|
||||||
// set up the UI for this server
|
// set up the UI for this server
|
||||||
document.getElementById("level").value = gSpamSettings.level;
|
document.getElementById("level").selectedItem = document.getElementById("level" + obj.settings.level);
|
||||||
|
|
||||||
document.getElementById("moveOnSpam").checked = gSpamSettings.moveOnSpam;
|
document.getElementById("moveOnSpam").checked = obj.settings.moveOnSpam;
|
||||||
// todo, use attribute string actionTargetFolder;
|
if (obj.settings.actionTargetFolder)
|
||||||
|
SetFolderPicker(obj.settings.actionTargetFolder, "actionTargetFolder");
|
||||||
|
|
||||||
document.getElementById("purge").checked = gSpamSettings.purge;
|
document.getElementById("purge").checked = obj.settings.purge;
|
||||||
document.getElementById("purgeInterval").value = gSpamSettings.purgeInterval;
|
document.getElementById("purgeInterval").value = obj.settings.purgeInterval;
|
||||||
|
|
||||||
document.getElementById("useWhiteList").checked = gSpamSettings.useWhiteList;
|
document.getElementById("useWhiteList").checked = obj.settings.useWhiteList;
|
||||||
var abList = document.getElementById("whiteListAbURI");
|
var abList = document.getElementById("whiteListAbURI");
|
||||||
menuitems = abList.getElementsByAttribute("id", gSpamSettings.whiteListAbURI);
|
menuitems = abList.getElementsByAttribute("id", obj.settings.whiteListAbURI);
|
||||||
abList.selectedItem = menuitems[0];
|
abList.selectedItem = menuitems[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function junkLog()
|
function junkLog()
|
||||||
{
|
{
|
||||||
// pass in the "real" spam settings, as it's the one with the logStream
|
// pass in the "real" spam settings, as it's the one with the logStream
|
||||||
var args = {spamSettings: gServer.spamSettings};
|
var args = {spamSettings: gCurrentServer.spamSettings};
|
||||||
window.openDialog("chrome://messenger/content/junkLog.xul", "junkLog", "chrome,modal,titlebar,resizable,centerscreen", args);
|
window.openDialog("chrome://messenger/content/junkLog.xul", "junkLog", "chrome,modal,titlebar,resizable,centerscreen", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAccept()
|
function onAccept()
|
||||||
{
|
{
|
||||||
// if they hit ok, set the "real" server's spam settings. this will set prefs.
|
for (var key in gSpamSettings) {
|
||||||
gServer.spamSettings = gSpamSettings;
|
// if they hit ok, set the "real" server's spam settings.
|
||||||
|
// this will set prefs.
|
||||||
|
gSpamSettings[key].server.spamSettings = gSpamSettings[key].settings;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function storeSettings(aSettings)
|
||||||
|
{
|
||||||
|
aSettings.level = document.getElementById("level").selectedItem.getAttribute("value");
|
||||||
|
|
||||||
|
aSettings.moveOnSpam = document.getElementById("moveOnSpam").checked;
|
||||||
|
aSettings.actionTargetFolder = document.getElementById("actionTargetFolder").getAttribute("uri");
|
||||||
|
|
||||||
|
aSettings.purge = document.getElementById("purge").checked;
|
||||||
|
aSettings.purgeInterval = document.getElementById("purgeInterval").value;
|
||||||
|
|
||||||
|
aSettings.useWhiteList = document.getElementById("useWhiteList").checked;
|
||||||
|
aSettings.whiteListAbURI = document.getElementById("whiteListAbURI").selectedItem.getAttribute("id");
|
||||||
}
|
}
|
||||||
|
|
||||||
function doHelpButton()
|
function doHelpButton()
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
ondialoghelp="return doHelpButton();"
|
ondialoghelp="return doHelpButton();"
|
||||||
persist="screenX screenY width height">
|
persist="screenX screenY width height">
|
||||||
|
|
||||||
|
<stringbundleset id="stringbundleset">
|
||||||
|
<stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
|
||||||
|
</stringbundleset>
|
||||||
|
|
||||||
<script type="application/x-javascript" src="chrome://messenger/content/junkMail.js"/>
|
<script type="application/x-javascript" src="chrome://messenger/content/junkMail.js"/>
|
||||||
<script type="application/x-javascript" src="chrome://messenger/content/widgetglue.js"/>
|
<script type="application/x-javascript" src="chrome://messenger/content/widgetglue.js"/>
|
||||||
|
|
||||||
|
@ -56,30 +60,30 @@
|
||||||
<radiogroup flex="1" id="level" orient="horizontal">
|
<radiogroup flex="1" id="level" orient="horizontal">
|
||||||
<!-- using 0 - 100, in case we ever do a slider or add more levels.
|
<!-- using 0 - 100, in case we ever do a slider or add more levels.
|
||||||
this way, the exist pref value will migrate nice. -->
|
this way, the exist pref value will migrate nice. -->
|
||||||
<radio flex="1" id="off" value="0" accesskey="&off.accesskey;" label="&off.label;"/>
|
<radio flex="1" id="level0" value="0" accesskey="&off.accesskey;" label="&off.label;"/>
|
||||||
<radio flex="1" id="lowest" value="20" accesskey="&lowest.accesskey;" label="&lowest.label;"/>
|
<radio flex="1" id="level20" value="20" accesskey="&lowest.accesskey;" label="&lowest.label;"/>
|
||||||
<radio flex="1" id="low" value="40" accesskey="&low.accesskey;" label="&low.label;"/>
|
<radio flex="1" id="level40" value="40" accesskey="&low.accesskey;" label="&low.label;"/>
|
||||||
<radio flex="1" id="medium" value="60" accesskey="&medium.accesskey;" label="&medium.label;"/>
|
<radio flex="1" id="level60" value="60" accesskey="&medium.accesskey;" label="&medium.label;"/>
|
||||||
<radio flex="1" id="high" value="80" accesskey="&high.accesskey;" label="&high.label;"/>
|
<radio flex="1" id="level80" value="80" accesskey="&high.accesskey;" label="&high.label;"/>
|
||||||
<radio flex="1" id="highest" value="100" accesskey="&highest.accesskey;" label="&highest.label;"/>
|
<radio flex="1" id="level100" value="100" accesskey="&highest.accesskey;" label="&highest.label;"/>
|
||||||
</radiogroup>
|
</radiogroup>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
<separator/>
|
<separator/>
|
||||||
|
|
||||||
<hbox align="center">
|
<hbox align="center">
|
||||||
<checkbox id="move" accesskey="&move.accesskey;" label="&move.label;"/>
|
<checkbox id="moveOnSpam" accesskey="&move.accesskey;" label="&move.label;"/>
|
||||||
<menulist id="actionTargetFolder"/>
|
<menulist id="actionTargetFolder"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
<hbox autostretch="never" align="center">
|
<hbox autostretch="never" align="center">
|
||||||
<checkbox id="purge" accesskey="&purge1.accesskey;" label="&purge1.label;"/>
|
<checkbox id="purge" accesskey="&purge1.accesskey;" label="&purge1.label;"/>
|
||||||
<textbox id="purgeInterval" />
|
<textbox size="3" id="purgeInterval" />
|
||||||
<label value="&purge2.label;"/>
|
<label value="&purge2.label;"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
<hbox align="center">
|
<hbox align="center">
|
||||||
<checkbox id="whiteList" accesskey="&whitelist.accesskey;" label="&whitelist.label;"/>
|
<checkbox id="useWhiteList" accesskey="&whitelist.accesskey;" label="&whitelist.label;"/>
|
||||||
<menulist id="whiteListAbURI">
|
<menulist id="whiteListAbURI">
|
||||||
<menupopup id="abPopup-menupopup" ref="moz-abdirectory://"
|
<menupopup id="abPopup-menupopup" ref="moz-abdirectory://"
|
||||||
datasources="rdf:addressdirectory">
|
datasources="rdf:addressdirectory">
|
||||||
|
|
Загрузка…
Ссылка в новой задаче