diff --git a/mailnews/addrbook/resources/content/abCardOverlay.js b/mailnews/addrbook/resources/content/abCardOverlay.js index e87164f80e0..fe3d5e4267d 100644 --- a/mailnews/addrbook/resources/content/abCardOverlay.js +++ b/mailnews/addrbook/resources/content/abCardOverlay.js @@ -138,11 +138,12 @@ function OnLoadNewCard() } if ("aimScreenName" in window.arguments[0]) gEditCard.card.aimScreenName = window.arguments[0].aimScreenName; - - if ("allowRemoteContent" in window.arguments[0]) - document.getElementById('allowRemoteContent').checked = - window.arguments[0].allowRemoteContent == 'true'; + if ("allowRemoteContent" in window.arguments[0]) { + gEditCard.card.allowRemoteContent = window.arguments[0].allowRemoteContent; + window.arguments[0].allowRemoteContent = false; + } + if ("okCallback" in window.arguments[0]) gOkCallback = window.arguments[0].okCallback; @@ -305,9 +306,9 @@ function OnLoadEditCard() document.documentElement.buttons = "accept"; document.documentElement.removeAttribute("ondialogaccept"); } - - // hide remote content in HTML field for remote directories - if (directory.isRemote) + + // hide remote content in HTML field for remote directories + if (directory.isRemote) document.getElementById('allowRemoteContent').hidden = true; } } @@ -407,6 +408,8 @@ function NewCardOKButton() // the card that got created. gEditCard.card = GetDirectoryFromURI(uri).addCard(gEditCard.card); NotifySaveListeners(); + if ("arguments" in window && window.arguments[0]) + window.arguments[0].allowRemoteContent = gEditCard.card.allowRemoteContent; } } @@ -427,8 +430,8 @@ function GetCardValues(cardproperty, doc) if (popup) popup.value = cardproperty.preferMailFormat; - var allowRemoteContentEl = document.getElementById("allowRemoteContent"); - if (allowRemoteContentEl) + var allowRemoteContentEl = document.getElementById("allowRemoteContent"); + if (allowRemoteContentEl) allowRemoteContentEl.checked = cardproperty.allowRemoteContent; // get phonetic fields if exist @@ -468,8 +471,8 @@ function CheckAndSetCardValues(cardproperty, doc, check) if (popup) cardproperty.preferMailFormat = popup.value; - var allowRemoteContentEl = document.getElementById("allowRemoteContent"); - if (allowRemoteContentEl) + var allowRemoteContentEl = document.getElementById("allowRemoteContent"); + if (allowRemoteContentEl) cardproperty.allowRemoteContent = allowRemoteContentEl.checked; // set phonetic fields if exist diff --git a/mailnews/base/prefs/resources/content/pref-viewing_messages.xul b/mailnews/base/prefs/resources/content/pref-viewing_messages.xul index e4f3415033e..e3999f6165c 100644 --- a/mailnews/base/prefs/resources/content/pref-viewing_messages.xul +++ b/mailnews/base/prefs/resources/content/pref-viewing_messages.xul @@ -6,7 +6,6 @@ @@ -16,43 +15,21 @@ "mailQuotedSize", "mailCitationColor", "wrapLongLines", "displayGlyph", "reuseMessageWindow", "disableContent", - "useWhiteList", "whiteListAbURI", "markMessagesRead", "markMessagesReadAfter"]; var gMarkMessagesReadAfter; function Startup() { gMarkMessagesReadAfter = document.getElementById("markMessagesReadAfter"); enableTextbox(document.getElementById("markMessagesRead"), gMarkMessagesReadAfter, true); - enableWhiteList(document.getElementById("disableContent").checked); } function enableTextbox(checkbox, textbox, startingUp) { - textbox.disabled = isDisabled(checkbox.checked, textbox); + textbox.disabled = (!checkbox.checked || + parent.hPrefWindow.getPrefIsLocked(textbox.getAttribute("prefstring"))); if (!textbox.disabled && !startingUp) textbox.focus(); } - - function isDisabled(aChecked, aElement) { - return (!aChecked || - parent.hPrefWindow.getPrefIsLocked(aElement.getAttribute("prefstring"))); - } - - function enableCheckbox(aChecked, aCheckbox) { - var disabled = isDisabled(aChecked, aCheckbox); - aCheckbox.disabled = disabled; - return disabled; - } - - function enableWhiteList(aChecked) { - var useWhiteList = document.getElementById("useWhiteList"); - var disabled = enableCheckbox(aChecked, useWhiteList); - enableWLPopup(useWhiteList.checked && !disabled); - } - - function enableWLPopup(aChecked) { - enableCheckbox(aChecked, document.getElementById("whiteListAbURI")); - } ]]> @@ -74,34 +51,7 @@ - - - - - - - - + prefattribute="checked" pref="true" preftype="bool"/> diff --git a/mailnews/base/prefs/resources/locale/en-US/pref-viewing_messages.dtd b/mailnews/base/prefs/resources/locale/en-US/pref-viewing_messages.dtd index d5acd4a53c0..e69de29bb2d 100644 --- a/mailnews/base/prefs/resources/locale/en-US/pref-viewing_messages.dtd +++ b/mailnews/base/prefs/resources/locale/en-US/pref-viewing_messages.dtd @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mailnews/base/resources/content/mailWindowOverlay.js b/mailnews/base/resources/content/mailWindowOverlay.js index 9991074d9d4..7fecbeea141 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.js +++ b/mailnews/base/resources/content/mailWindowOverlay.js @@ -2196,9 +2196,13 @@ var gMessageNotificationBar = setRemoteContentMsg: function(aMsgHdr) { - var blockRemote = aMsgHdr && - aMsgHdr.getUint32Property("remoteContentPolicy") == kBlockRemoteContent; - this.updateMsgNotificationBar(kMsgNotificationRemoteImages, blockRemote); + // update the allow remote content for sender string + var headerParser = Components.classes["@mozilla.org/messenger/headerparser;1"] + .getService(Components.interfaces.nsIMsgHeaderParser); + var emailAddress = headerParser.extractHeaderAddressMailboxes(null, aMsgHdr.author); + document.getElementById('allowRemoteContentForAuthorDesc').value = + gMessengerBundle.getFormattedString('alwaysLoadRemoteContentForSender', [emailAddress ? emailAddress : aMsgHdr.author]); + this.updateMsgNotificationBar(kMsgNotificationRemoteImages, true); }, // aUrl is the nsIURI for the message currently loaded in the message pane @@ -2234,7 +2238,11 @@ var gMessageNotificationBar = } }; -function LoadMsgWithRemoteContent() +/** + * loadMsgWithRemoteContent + * Reload the current message, allowing remote content + */ +function loadMsgWithRemoteContent() { // we want to get the msg hdr for the currently selected message // change the "remoteContentBar" property on it @@ -2243,6 +2251,76 @@ function LoadMsgWithRemoteContent() setMsgHdrPropertyAndReload("remoteContentPolicy", kAllowRemoteContent); } +/** + * msgHdrForCurrentMessage + * Returns the msg hdr associated with the current loaded message. + */ +function msgHdrForCurrentMessage() +{ + var msgURI = GetLoadedMessage(); + return (msgURI && !(/type=application\/x-message-display/.test(msgURI))) ? messenger.msgHdrFromURI(msgURI) : null; +} + +/** + * Reloads the message after adjusting the remote content policy for the sender. + * Iterate through the local address books looking for a card with the same e-mail address as the + * sender of the current loaded message. If we find a card, update the allow remote content field. + * If we can't find a card, prompt the user with a new AB card dialog, pre-selecting the remote content field. + */ +function allowRemoteContentForSender() +{ + // get the sender of the msg hdr + var msgHdr = msgHdrForCurrentMessage(); + if (!msgHdr) + return; + + var headerParser = Components.classes["@mozilla.org/messenger/headerparser;1"] + .getService(Components.interfaces.nsIMsgHeaderParser); + var names = {}; + var addresses = {}; + var fullNames = {}; + var numAddresses; + + numAddresses = headerParser.parseHeadersWithArray(msgHdr.author, addresses, names, fullNames); + var authorEmailAddress = addresses.value[0]; + if (!authorEmailAddress) + return; + + // search through all of our local address books looking for a match. + var parentDir = RDF.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory); + var enumerator = parentDir.childNodes; + var cardForEmailAddress; + var addrbook; + while (!cardForEmailAddress && enumerator.hasMoreElements()) + { + addrbook = enumerator.getNext(); + if (addrbook instanceof Components.interfaces.nsIAbMDBDirectory) + cardForEmailAddress = addrbook.cardForEmailAddress(authorEmailAddress); + } + + var allowRemoteContent = false; + if (cardForEmailAddress) + { + // set the property for remote content + cardForEmailAddress.allowRemoteContent = true; + cardForEmailAddress.editCardToDatabase(""); + allowRemoteContent = true; + } + else + { + var args = {primaryEmail:authorEmailAddress, displayName:names.value[0], + allowRemoteContent:true}; + // create a new card and set the property + window.openDialog("chrome://messenger/content/addressbook/abNewCardDialog.xul", + "", "chrome,resizable=no,titlebar,modal,centerscreen", args); + allowRemoteContent = args.allowRemoteContent; + } + + // reload the message if we've updated the remote content policy for the sender + if (allowRemoteContent) + MsgReload(); +} + function MsgIsNotAScam() { // we want to get the msg hdr for the currently selected message @@ -2257,16 +2335,11 @@ 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(); - - if (msgURI && !(/type=application\/x-message-display/.test(msgURI))) + var msgHdr = msgHdrForCurrentMessage(); + if (msgHdr) { - var msgHdr = messenger.msgHdrFromURI(msgURI); - if (msgHdr) - { - msgHdr.setUint32Property(aProperty, aValue); - MsgReload(); - } + msgHdr.setUint32Property(aProperty, aValue); + MsgReload(); } } @@ -2275,14 +2348,8 @@ 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; + var msgHdr = msgHdrForCurrentMessage(); + return (msgHdr && msgHdr.getUint32Property(aProperty) != aValue); } function MarkCurrentMessageAsRead() @@ -2310,17 +2377,15 @@ function OnMsgLoaded(aUrl) return; // nsIMsgMailNewsUrl.folder throws an error when opening .eml files. + var folder; try { - var folder = aUrl.folder; - } catch (ex) { - return; - } + folder = aUrl.folder; + } catch (ex) {} var msgURI = GetLoadedMessage(); - if (!msgURI) - return; - var msgHdr = null; + if (!folder || !msgURI) + return; // If we are in the middle of a delete or move operation, make sure that // if the user clicks on another message then that message stays selected @@ -2328,8 +2393,7 @@ function OnMsgLoaded(aUrl) // SetNextMessageAfterDelete() when the operation completes (bug 243532). gNextMessageViewIndexAfterDelete = -2; - if (!(/type=application\/x-message-display/.test(msgURI))) - msgHdr = messenger.msgHdrFromURI(msgURI); + var msgHdr = msgHdrForCurrentMessage(); gMessageNotificationBar.setJunkMsg(msgHdr); diff --git a/mailnews/base/resources/content/mailWindowOverlay.xul b/mailnews/base/resources/content/mailWindowOverlay.xul index 4a70816f1c1..98a281c2f44 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.xul +++ b/mailnews/base/resources/content/mailWindowOverlay.xul @@ -1942,9 +1942,13 @@ - &remoteContentMessage.label; + + &remoteContentMessage.label; + -