зеркало из https://github.com/mozilla/gecko-dev.git
Bug #331159 --> Port some of Iann's changes to seamonkey's msg notification bar back to thunderbird to clean up the code a bit.
This commit is contained in:
Родитель
b4615539cb
Коммит
2b9be2da74
|
@ -62,10 +62,12 @@ const kNoRemoteContentPolicy = 0;
|
||||||
const kBlockRemoteContent = 1;
|
const kBlockRemoteContent = 1;
|
||||||
const kAllowRemoteContent = 2;
|
const kAllowRemoteContent = 2;
|
||||||
|
|
||||||
const kMsgNotificationNoStatus = 0;
|
const kIsAPhishMessage = 0;
|
||||||
const kMsgNotificationJunkBar = 1;
|
const kNotAPhishMessage = 1;
|
||||||
const kMsgNotificationRemoteImages = 2;
|
|
||||||
const kMsgNotificationPhishingBar = 3;
|
const kMsgNotificationPhishingBar = 1;
|
||||||
|
const kMsgNotificationJunkBar = 2;
|
||||||
|
const kMsgNotificationRemoteImages = 3;
|
||||||
|
|
||||||
var gMessengerBundle;
|
var gMessengerBundle;
|
||||||
var gPromptService;
|
var gPromptService;
|
||||||
|
@ -2124,59 +2126,54 @@ function HandleJunkStatusChanged(folder)
|
||||||
var loadedMessage = GetLoadedMessage();
|
var loadedMessage = GetLoadedMessage();
|
||||||
if (loadedMessage && (!(/type=application\/x-message-display/.test(loadedMessage))) && IsCurrentLoadedFolder(folder))
|
if (loadedMessage && (!(/type=application\/x-message-display/.test(loadedMessage))) && IsCurrentLoadedFolder(folder))
|
||||||
{
|
{
|
||||||
// if multiple message are selected
|
// if multiple message are selected and we change the junk status
|
||||||
// and we change the junk status
|
// we don't want to show the junk bar (since the message pane is blank)
|
||||||
// we don't want to show the junk bar
|
var msgHdr = null;
|
||||||
// (since the message pane is blank)
|
|
||||||
if (GetNumSelectedMessages() == 1)
|
if (GetNumSelectedMessages() == 1)
|
||||||
|
msgHdr = messenger.msgHdrFromURI(loadedMessage);
|
||||||
|
gMessageNotificationBar.setJunkMsg(msgHdr);
|
||||||
|
|
||||||
|
if (msgHdr)
|
||||||
{
|
{
|
||||||
var msgHdr = messenger.messageServiceFromURI(loadedMessage).messageURIToMsgHdr(loadedMessage);
|
// we may be forcing junk mail to be rendered with sanitized html. In that scenario, we want to
|
||||||
|
// reload the message if the status has just changed to not junk.
|
||||||
if (msgHdr)
|
var sanitizeJunkMail = gPrefBranch.getBoolPref("mailnews.display.sanitizeJunkMail");
|
||||||
|
if (sanitizeJunkMail) // only bother doing this if we are modifying the html for junk mail....
|
||||||
{
|
{
|
||||||
// HandleJunkStatusChanged is a folder wide event and does not necessarily mean
|
var moveJunkMail = (folder && folder.server && folder.server.spamSettings) ?
|
||||||
// that the junk status on our currently selected message has changed.
|
folder.server.spamSettings.manualMark : false;
|
||||||
// We have no way of determining if the junk status of our current message has really changed
|
|
||||||
// the only thing we can do is cheat by asking if the junkbar visibility had to change as a result of this notification
|
|
||||||
|
|
||||||
var changedJunkStatus = gMessageNotificationBar.setJunkMsg(msgHdr);
|
var junkScore = msgHdr.getStringProperty("junkscore");
|
||||||
|
var isJunk = ((junkScore != "") && (junkScore != "0"));
|
||||||
|
|
||||||
// we may be forcing junk mail to be rendered with sanitized html. In that scenario, we want to
|
// we used to only reload the message if we were toggling the message to NOT JUNK from junk
|
||||||
// reload the message if the status has just changed to not junk.
|
// but it can be useful to see the HTML in the message get converted to sanitized form when a message
|
||||||
|
// is marked as junk.
|
||||||
var sanitizeJunkMail = gPrefBranch.getBoolPref("mailnews.display.sanitizeJunkMail");
|
// Furthermore, if we are about to move the message that was just marked as junk,
|
||||||
if (changedJunkStatus && sanitizeJunkMail) // only bother doing this if we are modifying the html for junk mail....
|
// then don't bother reloading it.
|
||||||
{
|
if (!(isJunk && moveJunkMail))
|
||||||
var loadedFolder = GetLoadedMsgFolder();
|
|
||||||
var moveJunkMail = (loadedFolder && loadedFolder.server && loadedFolder.server.spamSettings) ?
|
|
||||||
loadedFolder.server.spamSettings.manualMark : false;
|
|
||||||
|
|
||||||
var junkScore = msgHdr.getStringProperty("junkscore");
|
|
||||||
var isJunk = ((junkScore != "") && (junkScore != "0"));
|
|
||||||
|
|
||||||
// we used to only reload the message if we were toggling the message to NOT JUNK from junk
|
|
||||||
// but it can be useful to see the HTML in the message get converted to sanitized form when a message
|
|
||||||
// is marked as junk.
|
|
||||||
// Furthermore, if we are about to move the message that was just marked as junk,
|
|
||||||
// then don't bother reloading it.
|
|
||||||
if (!(isJunk && moveJunkMail))
|
|
||||||
MsgReload();
|
MsgReload();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
gMessageNotificationBar.setJunkMsg(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var gMessageNotificationBar =
|
var gMessageNotificationBar =
|
||||||
{
|
{
|
||||||
|
mBarStatus: 0,
|
||||||
|
// flag bit values for mBarStatus, indexed by kMsgNotificationXXX
|
||||||
|
mBarFlagValues: [
|
||||||
|
0, // for no msgNotificationBar
|
||||||
|
1, // 1 << (kMsgNotificationPhishingBar - 1)
|
||||||
|
2, // 1 << (kMsgNotificationJunkBar - 1)
|
||||||
|
4 // 1 << (kMsgNotificationRemoteImages - 1)
|
||||||
|
],
|
||||||
|
|
||||||
mMsgNotificationBar: document.getElementById('msgNotificationBar'),
|
mMsgNotificationBar: document.getElementById('msgNotificationBar'),
|
||||||
|
|
||||||
setJunkMsg: function (aMsgHdr)
|
setJunkMsg: function(aMsgHdr)
|
||||||
{
|
{
|
||||||
var isJunk = false;
|
var isJunk = false;
|
||||||
var isCurrentlyNotJunk = this.mMsgNotificationBar.selectedIndex != kMsgNotificationJunkBar;
|
|
||||||
|
|
||||||
if (aMsgHdr)
|
if (aMsgHdr)
|
||||||
{
|
{
|
||||||
|
@ -2184,55 +2181,48 @@ var gMessageNotificationBar =
|
||||||
isJunk = ((junkScore != "") && (junkScore != "0"));
|
isJunk = ((junkScore != "") && (junkScore != "0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// phishing scams take precedence over junk
|
this.updateMsgNotificationBar(kMsgNotificationJunkBar, isJunk);
|
||||||
if (this.mMsgNotificationBar.selectedIndex != kMsgNotificationPhishingBar && isJunk)
|
|
||||||
this.updateMsgNotificationBar (kMsgNotificationJunkBar);
|
|
||||||
|
|
||||||
goUpdateCommand('button_junk');
|
goUpdateCommand('button_junk');
|
||||||
|
|
||||||
return (isJunk && isCurrentlyNotJunk) || (!isJunk && !isCurrentlyNotJunk);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setRemoteContentMsg: function (aMsgHdr)
|
setRemoteContentMsg: function(aMsgHdr)
|
||||||
{
|
{
|
||||||
// phishing and junk messages take precedence over the remote content msg...
|
var blockRemote = aMsgHdr &&
|
||||||
if (this.mMsgNotificationBar.selectedIndex == kMsgNotificationNoStatus)
|
aMsgHdr.getUint32Property("remoteContentPolicy") == kBlockRemoteContent;
|
||||||
this.updateMsgNotificationBar(aMsgHdr && aMsgHdr.getUint32Property("remoteContentPolicy") == kBlockRemoteContent ?
|
this.updateMsgNotificationBar(kMsgNotificationRemoteImages, blockRemote);
|
||||||
kMsgNotificationRemoteImages : kMsgNotificationNoStatus);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// aUrl is the nsIURI for the message currently loaded in the message pane
|
// aUrl is the nsIURI for the message currently loaded in the message pane
|
||||||
setPhishingMsg: function(aUrl)
|
setPhishingMsg: function(aUrl)
|
||||||
{
|
{
|
||||||
var msgURI = GetLoadedMessage();
|
// if we've explicitly marked this message as not being an email scam, then don't
|
||||||
if (msgURI && !(/type=application\/x-message-display/.test(msgURI)))
|
// bother checking it with the phishing detector.
|
||||||
{
|
var phishingMsg = false;
|
||||||
var msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI);
|
if (!checkMsgHdrPropertyIsNot("notAPhishMessage", kIsAPhishMessage))
|
||||||
// if we've explicitly marked this message as not being an email scam, then don't
|
phishingMsg = isMsgEmailScam(aUrl);
|
||||||
// bother checking it with the phishing detector.
|
this.updateMsgNotificationBar(kMsgNotificationPhishingBar, phishingMsg);
|
||||||
if (msgHdr && msgHdr.getUint32Property("notAPhishMessage"))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// phishing scams take precedence over junk and remote images.
|
|
||||||
if (isMsgEmailScam(aUrl))
|
|
||||||
this.updateMsgNotificationBar(kMsgNotificationPhishingBar);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
clearMsgNotifications: function()
|
clearMsgNotifications: function()
|
||||||
{
|
{
|
||||||
this.updateMsgNotificationBar(kMsgNotificationNoStatus);
|
this.mBarStatus = 0;
|
||||||
|
this.mMsgNotificationBar.selectedIndex = 0;
|
||||||
|
this.mMsgNotificationBar.collapsed = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
// private method used to set our message notification deck to the correct value...
|
// private method used to set our message notification deck to the correct value...
|
||||||
updateMsgNotificationBar: function(aIndex)
|
updateMsgNotificationBar: function(aIndex, aSet)
|
||||||
{
|
{
|
||||||
if (aIndex == kMsgNotificationNoStatus)
|
var chunk = this.mBarFlagValues[aIndex];
|
||||||
this.mMsgNotificationBar.setAttribute('collapsed', true);
|
var status = aSet ? this.mBarStatus | chunk : this.mBarStatus & ~chunk;
|
||||||
else
|
this.mBarStatus = status;
|
||||||
this.mMsgNotificationBar.removeAttribute('collapsed');
|
|
||||||
|
// the phishing message takes precedence over the junk message
|
||||||
this.mMsgNotificationBar.selectedIndex = aIndex;
|
// which takes precedence over the remote content message
|
||||||
|
this.mMsgNotificationBar.selectedIndex = this.mBarFlagValues.indexOf(status & -status);
|
||||||
|
|
||||||
|
this.mMsgNotificationBar.collapsed = !status;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2242,18 +2232,7 @@ function LoadMsgWithRemoteContent()
|
||||||
// change the "remoteContentBar" property on it
|
// change the "remoteContentBar" property on it
|
||||||
// then reload the message
|
// then reload the message
|
||||||
|
|
||||||
var msgURI = GetLoadedMessage();
|
setMsgHdrPropertyAndReload("remoteContentPolicy", kAllowRemoteContent);
|
||||||
var msgHdr = null;
|
|
||||||
|
|
||||||
if (msgURI && !(/type=application\/x-message-display/.test(msgURI)))
|
|
||||||
{
|
|
||||||
msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI);
|
|
||||||
if (msgHdr)
|
|
||||||
{
|
|
||||||
msgHdr.setUint32Property("remoteContentPolicy", kAllowRemoteContent);
|
|
||||||
MsgReload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function MsgIsNotAScam()
|
function MsgIsNotAScam()
|
||||||
|
@ -2262,20 +2241,42 @@ function MsgIsNotAScam()
|
||||||
// change the "isPhishingMsg" property on it
|
// change the "isPhishingMsg" property on it
|
||||||
// then reload the message
|
// then reload the message
|
||||||
|
|
||||||
|
setMsgHdrPropertyAndReload("notAPhishMessage", kNotAPhishMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setMsgHdrPropertyAndReload(aProperty, aValue)
|
||||||
|
{
|
||||||
|
// we want to get the msg hdr for the currently selected message
|
||||||
|
// change the appropiate property on it then reload the message
|
||||||
|
|
||||||
var msgURI = GetLoadedMessage();
|
var msgURI = GetLoadedMessage();
|
||||||
var msgHdr = null;
|
|
||||||
|
|
||||||
if (msgURI && !(/type=application\/x-message-display/.test(msgURI)))
|
if (msgURI && !(/type=application\/x-message-display/.test(msgURI)))
|
||||||
{
|
{
|
||||||
msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI);
|
var msgHdr = messenger.msgHdrFromURI(msgURI);
|
||||||
if (msgHdr)
|
if (msgHdr)
|
||||||
{
|
{
|
||||||
msgHdr.setUint32Property("notAPhishMessage", 1);
|
msgHdr.setUint32Property(aProperty, aValue);
|
||||||
MsgReload();
|
MsgReload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkMsgHdrPropertyIsNot(aProperty, aValue)
|
||||||
|
{
|
||||||
|
// we want to get the msg hdr for the currently selected message,
|
||||||
|
// get the appropiate property on it and then test against value.
|
||||||
|
|
||||||
|
var msgURI = GetLoadedMessage();
|
||||||
|
|
||||||
|
if (msgURI && !(/type=application\/x-message-display/.test(msgURI)))
|
||||||
|
{
|
||||||
|
var msgHdr = messenger.msgHdrFromURI(msgURI);
|
||||||
|
return (msgHdr && msgHdr.getUint32Property(aProperty) != aValue);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function MarkCurrentMessageAsRead()
|
function MarkCurrentMessageAsRead()
|
||||||
{
|
{
|
||||||
ClearPendingReadTimer();
|
ClearPendingReadTimer();
|
||||||
|
|
|
@ -2033,30 +2033,31 @@
|
||||||
<!-- The msgNotificationBar appears on top of the message and displays
|
<!-- The msgNotificationBar appears on top of the message and displays
|
||||||
information like: junk, contains remote images, or is a suspected phishing URL
|
information like: junk, contains remote images, or is a suspected phishing URL
|
||||||
-->
|
-->
|
||||||
<deck id="msgNotificationBar" selectedIndex="0" collapsed="true">
|
|
||||||
<hbox id="msgNotificationNoStatus"/>
|
|
||||||
|
|
||||||
<hbox id="junkBar" class="msgNotificationBar" align="center">
|
<deck id="msgNotificationBar" selectedIndex="0" collapsed="true">
|
||||||
<image id="junkBarImage"/>
|
<hbox id="msgNotificationNoStatus"/>
|
||||||
<description flex="1" class="msgNotificationBarText">&junkBarMessage.label;</description>
|
|
||||||
<spacer flex="1"/>
|
|
||||||
<button label="&junkBarButton.label;" oncommand="JunkSelectedMessages(false);"/>
|
|
||||||
</hbox>
|
|
||||||
|
|
||||||
<hbox id="remoteContentBar" class="msgNotificationBar" align="center">
|
<hbox id="phishingBar" class="msgNotificationBar" align="center">
|
||||||
<image id="remoteContentImage"/>
|
<image id="phishingBarImage"/>
|
||||||
<description flex="1" class="msgNotificationBarText">&remoteContentMessage.label;</description>
|
<description flex="1" class="msgNotificationBarText">&phishingBarMessage.label;</description>
|
||||||
<spacer flex="1"/>
|
<spacer flex="1"/>
|
||||||
<button label="&loadRemoteContentButton.label;" oncommand="LoadMsgWithRemoteContent();"/>
|
<button label="&removePhishingBarButton.label;" oncommand="MsgIsNotAScam();"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
<hbox id="phishingBar" class="msgNotificationBar" align="center">
|
<hbox id="junkBar" class="msgNotificationBar" align="center">
|
||||||
<image id="phishingBarImage"/>
|
<image id="junkBarImage"/>
|
||||||
<description flex="1" class="msgNotificationBarText">&phishingBarMessage.label;</description>
|
<description flex="1" class="msgNotificationBarText">&junkBarMessage.label;</description>
|
||||||
<spacer flex="1"/>
|
<spacer flex="1"/>
|
||||||
<button label="&removePhishingBarButton.label;" oncommand="MsgIsNotAScam();"/>
|
<button label="&junkBarButton.label;" oncommand="JunkSelectedMessages(false);"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
</deck>
|
|
||||||
|
<hbox id="remoteContentBar" class="msgNotificationBar" align="center">
|
||||||
|
<image id="remoteContentImage"/>
|
||||||
|
<description flex="1" class="msgNotificationBarText">&remoteContentMessage.label;</description>
|
||||||
|
<spacer flex="1"/>
|
||||||
|
<button label="&loadRemoteContentButton.label;" oncommand="LoadMsgWithRemoteContent();"/>
|
||||||
|
</hbox>
|
||||||
|
</deck>
|
||||||
|
|
||||||
#include ../../../toolkit/components/typeaheadfind/content/findBar.inc
|
#include ../../../toolkit/components/typeaheadfind/content/findBar.inc
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче