Land first cut at a junk mail dialog re-design. See the spec for more details:

http://www.mozilla.org/projects/thunderbird/specs/junkmail/junkmail.html


add a new default pref for forcing HTML junk mail to be displayed using sanitized HTML.
Defaults to true and is controlled via the Settings tab in the junk mail controls dialog.
This commit is contained in:
scott%scott-macgregor.org 2003-07-01 07:42:21 +00:00
Родитель cd40e875b0
Коммит 0f129d3a4a
5 изменённых файлов: 420 добавлений и 72 удалений

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

@ -0,0 +1,276 @@
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2002
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Seth Spitzer <sspitzer@netscape.com>
# Dan Mosedale <dmose@netscape.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
var gSpamSettings = {};
var gCurrentServer;
var gMessengerBundle;
// pref service is global
var gPrefService = null;
const kJunkOnLocalFolderURI = "mailbox://nobody@Local%20Folders/Junk";
function onJunkMailLoad()
{
gMessengerBundle = document.getElementById("bundle_messenger");
if (window.arguments && window.arguments[0]) {
setupForAccountFromFolder(window.arguments[0].folder ? window.arguments[0].folder.URI : null);
}
// initialize prefs
gPrefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
// initialize the sanitize junk mail html check box
document.getElementById('renderWithSafeHtml').checked = gPrefService.getBoolPref('mailnews.display.sanitizeJunkMail');
}
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, gCurrentServer.spamSettings.loggingEnabled);
// set up the UI for the server
setupForAccountFromFolder(event.target.id);
}
function setupForAccountFromFolder(aURI)
{
try {
if (!aURI)
throw "this can happen if no folder is selected in the folder pane"
var msgFolder = GetMsgFolderFromUri(aURI, false);
gCurrentServer = msgFolder.server;
if (gCurrentServer.type == "nntp")
throw "this can happen if the selected folder (or account) doesn't have junk controls (news)"
}
catch (ex) {
// get server for default account
// XXX TODO
// edge cases to worry about later:
// what if there is no default account?
// what if default account is of a type where canGetIncomingMessages == true?
// what if no accounts are of a type where canGetIncomingMessages == true?
var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"]
.getService(Components.interfaces.nsIMsgAccountManager);
var account = accountManager.defaultAccount;
gCurrentServer = account.incomingServer;
}
var obj;
var key = gCurrentServer.key;
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
var serverList = document.getElementById("server");
var menuitems = serverList.getElementsByAttribute("id", obj.server.serverURI);
serverList.selectedItem = menuitems[0];
// set up the UI for this server
// set up the level checkbox
document.getElementById("level").checked = (obj.settings.level > 0);
// set up the junk mail folder picker
document.getElementById("moveOnSpam").checked = obj.settings.moveOnSpam;
document.getElementById("moveTargetMode").selectedItem = document.getElementById("moveTargetMode" + obj.settings.moveTargetMode);
// the default account should be the current account
// unless you can't create a folder on that server
// or search on that account (for purge)
// in which case, use Local Folders
var defaultAccountURI = obj.server.canCreateFoldersOnServer && obj.server.canSearchMessages ? obj.server.serverURI : "mailbox://nobody@Local%20Folders";
// if there is a target account, use it, else use the default account
SetFolderPicker(obj.settings.actionTargetAccount ? obj.settings.actionTargetAccount : defaultAccountURI, "actionTargetAccount");
// if there is a target account, use it, else use Junk on Local Folders
if (obj.settings.actionTargetFolder)
SetFolderPicker(obj.settings.actionTargetFolder, "actionTargetFolder");
else {
// note, this folder might not exist, but better this than ""
// and, we'll create it if we try to use it.
SetFolderPicker(kJunkOnLocalFolderURI, "actionTargetFolder");
}
// set up the purge UI
document.getElementById("purge").checked = obj.settings.purge;
document.getElementById("purgeInterval").value = obj.settings.purgeInterval;
// set up the whitelist UI
document.getElementById("useWhiteList").checked = obj.settings.useWhiteList;
var abList = document.getElementById("whiteListAbURI");
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);
}
function junkLog()
{
// pass in the "real" spam settings, as it's the one with the logStream
var args = {spamSettings: gCurrentServer.spamSettings};
window.openDialog("chrome://messenger/content/junkLog.xul", "junkLog", "chrome,modal,titlebar,resizable,centerscreen", args);
}
function onAccept()
{
// store the current changes
storeSettings(gSpamSettings[gCurrentServer.key].settings, gCurrentServer.spamSettings.loggingEnabled);
for (var key in gSpamSettings) {
try {
// if they hit ok, set the "real" server's spam settings.
// this will set prefs.
gSpamSettings[key].server.spamSettings = gSpamSettings[key].settings;
}
catch (ex) {
dump("spam setting not saved: " + ex);
}
}
// now store off our non account specific settings
gPrefService.setBoolPref('mailnews.display.sanitizeJunkMail', document.getElementById('renderWithSafeHtml').checked);
return true;
}
function storeSettings(aSettings, aLoggingEnabled)
{
aSettings.level = document.getElementById("level").checked ? 100 : 0;
aSettings.moveOnSpam = document.getElementById("moveOnSpam").checked;
aSettings.moveTargetMode = document.getElementById("moveTargetMode").value;
aSettings.actionTargetAccount = document.getElementById("actionTargetAccount").getAttribute("uri");
var targetFolderURI = document.getElementById("actionTargetFolder").getAttribute("uri");
if (targetFolderURI)
aSettings.actionTargetFolder = targetFolderURI;
else {
// note, this folder might not exist, but better this than ""
// and, we'll create it if we try to use it.
aSettings.actionTargetFolder = kJunkOnLocalFolderURI;
}
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");
aSettings.loggingEnabled = aLoggingEnabled;
aSettings.manualMark = document.getElementById("manualMark").checked;
aSettings.manualMarkMode = document.getElementById("manualMarkMode").value;
}
function conditionallyEnableUI(id)
{
if (!document.getElementById("level").checked) {
document.getElementById("useWhiteList").disabled = true;
document.getElementById("whiteListAbURI").disabled = true;
document.getElementById("moveOnSpam").disabled = true;
document.getElementById("moveTargetMode").disabled = true;
document.getElementById("actionTargetAccount").disabled = true;
document.getElementById("actionTargetFolder").disabled = true;
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;
document.getElementById("moveTargetMode").disabled = !enabled;
document.getElementById("actionTargetAccount").disabled = !enabled || (choice == 1);
document.getElementById("actionTargetFolder").disabled = !enabled || (choice == 0);
var checked = document.getElementById("purge").checked;
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") {
enabled = document.getElementById("purge").checked;
document.getElementById("purgeInterval").disabled = !enabled;
}
if (!id || id == "useWhiteList") {
enabled = document.getElementById("useWhiteList").checked;
document.getElementById("whiteListAbURI").disabled = !enabled;
}
}
function doHelpButton()
{
openHelp("mail-junk-controls");
}

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

@ -42,7 +42,12 @@
<?xul-overlay href="chrome://messenger/content/msgFolderPickerOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://messenger/locale/junkMail.dtd">
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
%brandDTD;
<!ENTITY % junkMailDTD SYSTEM "chrome://messenger/locale/junkMail.dtd" >
%junkMailDTD;
]>
<dialog id="junkMail"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@ -51,9 +56,8 @@
windowtype="mailnews:junk"
title="&window.title;"
onload="onJunkMailLoad();"
buttons="accept,cancel,help"
ondialogaccept="return onAccept();"
ondialoghelp="return doHelpButton();">
buttons="accept,cancel"
ondialogaccept="return onAccept();">
<script type="application/x-javascript" src="chrome://messenger/content/junkMail.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/widgetglue.js"/>
@ -62,82 +66,79 @@
<stringbundleset id="stringbundleset">
<stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
</stringbundleset>
<hbox align="center">
<label value="&account.label;" accesskey="&account.accesskey;"/>
<menulist oncommand="onServerClick(event);" id="server">
<menupopup datasources="rdf:msgaccountmanager rdf:mailnewsfolders"
sortResource="http://home.netscape.com/NC-rdf#FolderTreeName"
sortDirection="ascending" ref="msgaccounts:/">
<template>
<rule nc:IsServer="true" nc:ServerType="nntp">
<!-- no support for news yet -->
</rule>
<rule nc:IsServer="true">
<menuitem uri="..." value="..."
class="folderMenuItem menuitem-iconic"
IsServer="rdf:http://home.netscape.com/NC-rdf#IsServer"
IsSecure="rdf:http://home.netscape.com/NC-rdf#IsSecure"
ServerType="rdf:http://home.netscape.com/NC-rdf#ServerType"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
</rule>
</template>
</menupopup>
</menulist>
<spacer flex="1"/>
<button label="&viewLog.label;" accesskey="&viewLog.accesskey;" oncommand="junkLog()"/>
</hbox>
<description width="1">&info1.label;</description>
<description width="1">&mainDescription.label;</description>
<separator class="thin"/>
<vbox id="junkMailControls">
<tabbox>
<tabs id="junkMailTabs">
<tab label="Junk Controls"/>
<tab label="Black Lists"/>
<tab label="&settingsTab.label;"/>
<tab label="&adaptiveTab.label;"/>
<tab label="&blackListsTab.label;"/>
</tabs>
<tabpanels id="junkMailTabsPanels" flex="1">
<!-- JunkMail Tab -->
<vbox index="name" flex="1">
<description width="1">&info2.label;</description>
<groupbox flex="1">
<caption class="tab-caption" label="Detection"/>
<vbox>
<checkbox id="level" oncommand="conditionallyEnableUI(null);" accesskey="&level.accesskey;" label="&level.label;"/>
<vbox align="start">
<checkbox id="useWhiteList" oncommand="conditionallyEnableUI('useWhiteList')" accesskey="&whitelist.accesskey;" label="&whitelist.label;"/>
<hbox>
<spacer width="20px"/>
<menulist id="whiteListAbURI">
<menupopup id="abPopup-menupopup" 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">
<menuitem uri="..."
label="rdf:http://home.netscape.com/NC-rdf#DirName"
value="rdf:http://home.netscape.com/NC-rdf#DirUri"/>
</rule>
</template>
</menupopup>
</menulist>
</hbox>
</vbox>
<vbox index="name" flex="1">
<description width="1">&settingsInfo.label;</description>
<hbox align="center">
<label value="&account.label;" accesskey="&account.accesskey;"/>
<menulist oncommand="onServerClick(event);" id="server">
<menupopup datasources="rdf:msgaccountmanager rdf:mailnewsfolders"
sortResource="http://home.netscape.com/NC-rdf#FolderTreeName"
sortDirection="ascending" ref="msgaccounts:/">
<template>
<rule nc:IsServer="true" nc:ServerType="nntp">
<!-- no support for news yet -->
</rule>
<rule nc:IsServer="true">
<menuitem uri="..." value="..."
class="folderMenuItem menuitem-iconic"
IsServer="rdf:http://home.netscape.com/NC-rdf#IsServer"
IsSecure="rdf:http://home.netscape.com/NC-rdf#IsSecure"
ServerType="rdf:http://home.netscape.com/NC-rdf#ServerType"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
</rule>
</template>
</menupopup>
</menulist>
</hbox>
<groupbox flex="1">
<caption class="tab-caption" label="&whiteListCaption.label;"/>
<vbox>
<vbox align="start">
<checkbox id="useWhiteList" oncommand="conditionallyEnableUI('useWhiteList')" accesskey="&whitelist.accesskey;" label="&whitelist.label;"/>
<hbox>
<spacer width="20px"/>
<menulist id="whiteListAbURI">
<menupopup id="abPopup-menupopup" 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">
<menuitem uri="..."
label="rdf:http://home.netscape.com/NC-rdf#DirName"
value="rdf:http://home.netscape.com/NC-rdf#DirUri"/>
</rule>
</template>
</menupopup>
</menulist>
</hbox>
</vbox>
</groupbox>
</vbox>
</groupbox>
<groupbox flex="1">
<caption class="tab-caption" label="Action"/>
<caption class="tab-caption" label="Action"/>
<vbox align="start">
<checkbox id="moveOnSpam" oncommand="conditionallyEnableUI('moveOnSpam')" label="&move.label;"/>
<checkbox id="moveOnSpam" oncommand="conditionallyEnableUI('moveOnSpam')" label="&move.label;"/>
<radiogroup id="moveTargetMode">
<grid class="specialFolderPickerGrid">
<columns>
@ -177,13 +178,38 @@
</radiogroup>
</hbox>
</vbox>
<vbox align="start">
<checkbox id="renderWithSafeHtml" label="&renderWithSafeHtml.label;"/>
</vbox>
</groupbox>
<!-- Real Time Black Lists Tab -->
<vbox index="blackLists" flex="1">
<groupbox>
<caption class="tab-caption" label="Logging"/>
<hbox>
<description>&loggingDescription.label;</description>
<spacer flex="1"/>
<button label="&viewLog.label;" accesskey="&viewLog.accesskey;" oncommand="junkLog()"/>
</hbox>
</groupbox>
</vbox>
<!-- Adaptive Filter Tab -->
<vbox index="adaptive" flex="1">
<description width="1">&adaptiveInfo.label;</description>
<separator class="thin"/>
<description width="1">&trainingWarning.label;</description>
<separator class="thin"/>
<hbox class="indent">
<checkbox id="level" oncommand="conditionallyEnableUI(null);" accesskey="&level.accesskey;" label="&level.label;"/>
</hbox>
</vbox>
<!-- Real Time Black Lists Tab -->
<vbox index="blackLists" flex="1">
<description width="1">This hasn't been implemented yet</description>
</vbox>
</vbox>
</tabpanels>
</tabbox>
</vbox>

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

@ -19,6 +19,7 @@ messenger.jar:
*+ content/messenger/subscribe.xul (content/subscribe.xul)
*+ content/messenger/aboutDialog.xul (content/aboutDialog.xul)
*+ content/messenger/junkMail.xul (content/junkMail.xul)
*+ content/messenger/junkMail.js (content/junkMail.js)
content/messenger/about-thunderbird.png (content/about-thunderbird.png)
classic.jar:
@ -68,6 +69,7 @@ en-US.jar:
locale/en-US/messenger/h2.png (locale/h2.png)
locale/en-US/messenger/back.png (locale/back.png)
locale/en-US/messenger/aboutDialog.dtd (locale/aboutDialog.dtd)
+ locale/en-US/messenger/junkMail.dtd (locale/junkMail.dtd)
+ locale/en-US/messenger/messenger.dtd (locale/messenger.dtd)
+ locale/en-US/messenger/mailTasksOverlay.dtd (locale/mailTasksOverlay.dtd)
+ locale/en-US/messenger/msgAccountCentral.dtd (locale/msgAccountCentral.dtd)

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

@ -0,0 +1,45 @@
<!ENTITY window.title "Junk Mail Controls">
<!ENTITY mainDescription.label "&brandShortName; has several ways to detect junk mail, or unsolicited mail. These controls evaluate incoming messages and identify those that are most likely to be junk mail. A junk icon is displayed if the message is identified as junk mail.">
<!-- Tab titles -->
<!ENTITY settingsTab.label "Settings">
<!ENTITY whiteListTab.label "White Lists">
<!ENTITY adaptiveTab.label "Adaptive Filters">
<!ENTITY blackListsTab.label "Black Lists">
<!-- Settings tab -->
<!ENTITY settingsInfo.label "For each mail account, determine what &brandShortName; should do with messages identified as junk:">
<!ENTITY move.label "Move incoming messages determined to be junk mail to:">
<!ENTITY otherFolder.label "Other:">
<!ENTITY junkFolderOn.label "&quot;Junk&quot; folder on:">
<!ENTITY purge1.label "Automatically delete junk messages older than">
<!ENTITY purge1.accesskey "u">
<!ENTITY purge2.label "days from this folder">
<!ENTITY manualMark.label "When I manually mark messages as Junk:">
<!ENTITY manualMarkModeMove.label "Move them to the &quot;Junk&quot; folder">
<!ENTITY manualMarkModeDelete.label "Delete them">
<!ENTITY renderWithSafeHtml.label "When displaying HTML messages marked as junk, sanitize the HTML">
<!ENTITY account.label "Account:">
<!ENTITY account.accesskey "A">
<!ENTITY viewLog.label "Junk Mail Log">
<!ENTITY viewLog.accesskey "j">
<!ENTITY loggingDescription.label "View and configure junk mail logging.">
<!-- Adaptive Filter tab -->
<!ENTITY adaptiveInfo.label "&brandShortName; can be trained to analyze the contents of your incoming messages and identify those that are most likely to be junk. This can be an extremely effective tool for detecting junk mail.">
<!ENTITY adaptiveCaption.label "Adaptive Filters">
<!ENTITY trainingWarning.label "If enabled, you must first train &brandShortName; to identify junk mail by using the Junk toolbar button to mark messages as junk or not. You need to identify both junk and non junk messages.">
<!ENTITY level.label "Enable adaptive junk mail detection">
<!ENTITY level.accesskey "E">
<!-- White List tab -->
<!ENTITY whiteListCaption.label "White Lists">
<!ENTITY whitelist.label "Do not mark messages as junk mail if the sender is in my address book:">
<!ENTITY whitelist.accesskey "D">
<!-- Black List tab -->

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

@ -37,7 +37,6 @@
margin-left: 20px;
}
/* XXX: would be nice to find a common place for this XXX */
/* ::::captions in tabs ::::: */