Bug 735339 - The 'Get mail' drop down shouldn't list IM accounts, r+a=bienvenu.
authorFlorian Quèze <florian@queze.net>
Mon, 02 Apr 2012 12:38:58 +0200
changeset 11140 a32b1a8e83a1f87e8262e6883d6fabe5f05c689c
parent 11139 8ab1410329379e1c14938d2139bff20b4ede0825
child 11141 7fdb23d4f87bf60554b698842de46d95bd6bd3c6
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs735339
Bug 735339 - The 'Get mail' drop down shouldn't list IM accounts, r+a=bienvenu.
mail/base/content/mail3PaneWindowCommands.js
mail/base/content/mailWindowOverlay.js
mail/base/content/messageWindow.js
mailnews/base/content/folderWidgets.xml
--- a/mail/base/content/mail3PaneWindowCommands.js
+++ b/mail/base/content/mail3PaneWindowCommands.js
@@ -514,18 +514,17 @@ var DefaultController =
       }
       case "cmd_sendUnsentMsgs":
         return IsSendUnsentMsgsEnabled(null);
       case "cmd_properties":
         return IsPropertiesEnabled(command);
       case "button_getNewMessages":
       case "cmd_getNewMessages":
       case "cmd_getMsgsForAuthAccounts":
-        // GetMsgs should always be enabled, see bugs 89404 and 111102.
-        return true;
+        return IsGetNewMessagesEnabled();
       case "cmd_getNextNMessages":
         return IsGetNextNMessagesEnabled();
       case "cmd_emptyTrash":
       {
         let folder = GetSelectedMsgFolders()[0];
         return folder && folder.server.canEmptyTrashOnExit ?
                          IsMailFolderSelected() : false;
       }
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -2289,16 +2289,30 @@ function PrintEnginePrintPreview()
 
 function IsMailFolderSelected()
 {
   var selectedFolders = GetSelectedMsgFolders();
   var folder = selectedFolders.length ? selectedFolders[0] : null;
   return folder && folder.server.type != "nntp";
 }
 
+function IsGetNewMessagesEnabled()
+{
+  let allServers = accountManager.allServers;
+  for (let i = 0; i < allServers.Count(); ++i) {
+    let server = allServers.GetElementAt(i)
+                           .QueryInterface(Components.interfaces.nsIMsgIncomingServer);
+    let type = server.type;
+    if (type == "im" || type == "none")
+      continue;
+    return true;
+  }
+  return false;
+}
+
 function IsGetNextNMessagesEnabled()
 {
   var selectedFolders = GetSelectedMsgFolders();
   var folder = selectedFolders.length ? selectedFolders[0] : null;
 
   var menuItem = document.getElementById("menu_getnextnmsg");
   if (folder && !folder.isServer &&
       folder.server instanceof Components.interfaces.nsINntpIncomingServer) {
--- a/mail/base/content/messageWindow.js
+++ b/mail/base/content/messageWindow.js
@@ -878,18 +878,17 @@ var MessageWindowController =
       case "cmd_markAsFlagged":
       case "button_file":
         return ( gFolderDisplay.selectedMessage != null);
       case "cmd_printSetup":
         return true;
       case "cmd_getNewMessages":
       case "button_getNewMessages":
       case "cmd_getMsgsForAuthAccounts":
-        // GetMsgs should always be enabled, see bugs 89404 and 111102.
-        return true;
+        return IsGetNewMessagesEnabled();
       case "cmd_getNextNMessages":
         return IsGetNextNMessagesEnabled();
       case "cmd_downloadFlagged":
       case "cmd_downloadSelected":
       case "cmd_synchronizeOffline":
         return MailOfflineMgr.isOnline();
       case "cmd_settingsOffline":
         return IsAccountOfflineEnabled();
--- a/mailnews/base/content/folderWidgets.xml
+++ b/mailnews/base/content/folderWidgets.xml
@@ -293,17 +293,17 @@
             // Do this, we'll stick them in an array, and then sort that array.
             var accounts = new Array();
             for (var i = 0; i < count; i++) {
               var acct = acctMgr.accounts.GetElementAt(i).QueryInterface(Ci.nsIMsgAccount);
 
               // This is a HACK to work around bug 41133. If we have one of the
               // dummy "news" accounts there, that account won't have an
               // incomingServer attached to it, and everything will blow up.
-              if (acct.incomingServer)
+              if (acct.incomingServer && acct.incomingServer.type != "im")
                 accounts.push(acct);
             }
 
             /**
              * This is our actual function for sorting accounts.  Accounts go
              * in the following order: (1) default account (2) other mail
              * accounts (3) Local Folders (4) news
              */
@@ -607,18 +607,21 @@
 
           // Start iterating at the top of the hierarchy, that is, with the root
           // folders for each account.
           var acctMgr = Cc["@mozilla.org/messenger/account-manager;1"].
                         getService(Ci.nsIMsgAccountManager);
           var count = acctMgr.accounts.Count();
           for (var i = 0; i < count; i++) {
             var acct = acctMgr.accounts.GetElementAt(i).QueryInterface(Ci.nsIMsgAccount);
-            addIfRecent(acct.incomingServer.rootFolder);
-            checkSubFolders(acct.incomingServer.rootFolder);
+            var incomingServer = acct.incomingServer;
+            if (incomingServer.type == "im")
+              continue;
+            addIfRecent(incomingServer.rootFolder);
+            checkSubFolders(incomingServer.rootFolder);
           }
 
           function sorter(a, b) {
              return a.getStringProperty("MRMTime") < b.getStringProperty("MRMTime");
           }
           recentFolders.sort(sorter);
 
           // Because we're scanning across multiple accounts, we can end up with