Bug 625085 mailWindowOverlay.js: fixup LoadMsgWithRemoteContent() and allowRemoteContentForSender() r=Mnyromyr sr=Neil
authorPhilip Chee <philip.chee@gmail.com>
Fri, 14 Jan 2011 18:20:25 +0800
changeset 6953 d3f37c90dfd951513edd121b451e10ddd27c890e
parent 6952 757586198da27c77ad38a006e2e51e2a477bb646
child 6954 21421642db18e4c316eb9276e4a0e8f40190e75e
push idunknown
push userunknown
push dateunknown
reviewersMnyromyr, Neil
bugs625085
Bug 625085 mailWindowOverlay.js: fixup LoadMsgWithRemoteContent() and allowRemoteContentForSender() r=Mnyromyr sr=Neil
suite/mailnews/mailWindowOverlay.js
--- a/suite/mailnews/mailWindowOverlay.js
+++ b/suite/mailnews/mailWindowOverlay.js
@@ -2719,16 +2719,17 @@ var gMessageNotificationBar =
  */
 function LoadMsgWithRemoteContent()
 {
   // we want to get the msg hdr for the currently selected message
   // change the "remoteContentBar" property on it
   // then reload the message
 
   setMsgHdrPropertyAndReload("remoteContentPolicy", kAllowRemoteContent);
+  window.content.focus();
 }
 
 /**
  *  msgHdrForCurrentMessage
  *   Returns the msg hdr associated with the current loaded message.
  */
 function msgHdrForCurrentMessage()
 {
@@ -2760,24 +2761,29 @@ function allowRemoteContentForSender()
   var authorEmailAddress = addresses.value[0];
   if (!authorEmailAddress)
     return;
 
   // search through all of our local address books looking for a match.
   var enumerator = Components.classes["@mozilla.org/abmanager;1"]
                              .getService(Components.interfaces.nsIAbManager)
                              .directories;
-  var cardForEmailAddress;
-  var addrbook;
+  var cardForEmailAddress = null;
+  var addrbook = null;
   while (!cardForEmailAddress && enumerator.hasMoreElements())
   {
     addrbook = enumerator.getNext()
                          .QueryInterface(Components.interfaces.nsIAbDirectory);
-    try {
-      cardForEmailAddress = addrbook.cardForEmailAddress(authorEmailAddress);
+    // Try/catch because cardForEmailAddress will throw if not implemented.
+    try
+    {
+      // If it's a read-only book, don't find a card as we won't be able
+      // to modify the card.
+      if (!addrbook.readOnly)
+        cardForEmailAddress = addrbook.cardForEmailAddress(authorEmailAddress);
     } catch (e) {}
   }
 
   var allowRemoteContent = false;
   if (cardForEmailAddress)
   {
     // set the property for remote content
     cardForEmailAddress.setProperty("AllowRemoteContent", true);