Bug 855631 Fix Get New Messages for All Accounts (regression from bug 831993) r=mkmelin
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Thu, 04 Apr 2013 21:38:55 +0100
changeset 12258 f3890baa96844d9c93204a079d4a7849d71510e9
parent 12257 54463e2e941d92803a1ecec60bd2ce32b35a0d2b
child 12259 3e75505e71662108c0436077e9f912e0c60455b4
push id9073
push userneil@parkwaycc.co.uk
push dateThu, 04 Apr 2013 20:39:13 +0000
treeherdercomm-central@f3890baa9684 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs855631, 831993
Bug 855631 Fix Get New Messages for All Accounts (regression from bug 831993) r=mkmelin
mail/base/content/mailWindowOverlay.js
suite/mailnews/mailTasksOverlay.js
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -1380,21 +1380,20 @@ function MsgGetMessage()
 }
 
 function MsgGetMessagesForAllServers(defaultServer)
 {
   // now log into any server
   try
   {
     var allServers = accountManager.allServers;
-    // Array of isupportsarrays of servers for a particular folder.
-    var pop3DownloadServersArray = new Array();
-    // Parallel isupports array of folders to download to...
-    var localFoldersToDownloadTo = Components.classes["@mozilla.org/supports-array;1"]
-                                             .createInstance(Components.interfaces.nsISupportsArray);
+    // Array of arrays of servers for a particular folder.
+    var pop3DownloadServersArray = [];
+    // Parallel array of folders to download to...
+    var localFoldersToDownloadTo = [];
     var pop3Server;
     for (var i = 0; i < allServers.length; ++i)
     {
       var currentServer = allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
       var protocolinfo = Components.classes["@mozilla.org/messenger/protocol/info;1?type=" + currentServer.type]
                                    .getService(Components.interfaces.nsIMsgProtocolInfo);
       if (protocolinfo.canLoginAtStartUp && currentServer.loginAtStartUp)
       {
@@ -1416,18 +1415,21 @@ function MsgGetMessagesForAllServers(def
           currentServer.performBiff(msgWindow);
         }
       }
     }
     for (var i = 0; i < pop3DownloadServersArray.length; ++i)
     {
       // Any ol' pop3Server will do - the serversArray specifies which servers
       // to download from.
-      pop3Server.downloadMailFromServers(pop3DownloadServersArray[i], msgWindow,
-                                         localFoldersToDownloadTo.GetElementAt(i), null);
+      pop3Server.downloadMailFromServers(pop3DownloadServersArray[i],
+                                         pop3DownloadServersArray[i].length,
+                                         msgWindow,
+                                         localFoldersToDownloadTo[i],
+                                         null);
     }
   }
   catch(ex)
   {
     dump(ex + "\n");
   }
 }
 
@@ -2651,43 +2653,41 @@ function SendUnsentMessages()
 function CoalesceGetMsgsForPop3ServersByDestFolder(currentServer,
                                                    pop3DownloadServersArray,
                                                    localFoldersToDownloadTo)
 {
   var outNumFolders = new Object();
   const kInboxFlag = Components.interfaces.nsMsgFolderFlags.Inbox;
   var inboxFolder = currentServer.rootMsgFolder.getFolderWithFlags(kInboxFlag);
   // coalesce the servers that download into the same folder...
-  var index = localFoldersToDownloadTo.GetIndexOf(inboxFolder);
+  var index = localFoldersToDownloadTo.indexOf(inboxFolder);
   if (index == -1)
   {
     if (inboxFolder)
     {
       inboxFolder.biffState =  Components.interfaces.nsIMsgFolder.nsMsgBiffState_NoMail;
       inboxFolder.clearNewMessages();
     }
-    localFoldersToDownloadTo.AppendElement(inboxFolder);
-    index = pop3DownloadServersArray.length
-    pop3DownloadServersArray[index] = Components.classes["@mozilla.org/supports-array;1"]
-                                                .createInstance(Components.interfaces.nsISupportsArray);
+    localFoldersToDownloadTo.push(inboxFolder);
+    index = pop3DownloadServersArray.length;
+    pop3DownloadServersArray.push([]);
   }
-  pop3DownloadServersArray[index].AppendElement(currentServer);
+  pop3DownloadServersArray[index].push(currentServer);
 }
 
 function GetMessagesForAllAuthenticatedAccounts()
 {
   // now log into any server
   try
   {
     var allServers = accountManager.allServers;
     // array of isupportsarrays of servers for a particular folder
-    var pop3DownloadServersArray = new Array();
-    // parallel isupports array of folders to download to...
-    var localFoldersToDownloadTo = Components.classes["@mozilla.org/supports-array;1"]
-                                             .createInstance(Components.interfaces.nsISupportsArray);
+    var pop3DownloadServersArray = [];
+    // parallel array of folders to download to...
+    var localFoldersToDownloadTo = [];
     var pop3Server;
 
     for (var i = 0; i < allServers.length; ++i)
     {
       var currentServer = allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
       var protocolinfo = Components.classes["@mozilla.org/messenger/protocol/info;1?type=" + currentServer.type]
                                    .getService(Components.interfaces.nsIMsgProtocolInfo);
       if (protocolinfo.canGetMessages && !currentServer.passwordPromptRequired)
@@ -2701,18 +2701,21 @@ function GetMessagesForAllAuthenticatedA
         else
         // get new messages on the server for imap or rss
           GetMessagesForInboxOnServer(currentServer);
       }
     }
     for (var i = 0; i < pop3DownloadServersArray.length; ++i)
     {
       // any ol' pop3Server will do - the serversArray specifies which servers to download from
-      pop3Server.downloadMailFromServers(pop3DownloadServersArray[i], msgWindow,
-                                         localFoldersToDownloadTo.GetElementAt(i), null);
+      pop3Server.downloadMailFromServers(pop3DownloadServersArray[i],
+                                         pop3DownloadServersArray[i].length,
+                                         msgWindow,
+                                         localFoldersToDownloadTo[i],
+                                         null);
     }
   }
   catch(ex)
   {
       dump(ex + "\n");
   }
 }
 
--- a/suite/mailnews/mailTasksOverlay.js
+++ b/suite/mailnews/mailTasksOverlay.js
@@ -44,32 +44,30 @@ function CoalesceGetMsgsForPop3ServersBy
   var inbox = aCurrentServer.rootMsgFolder.getFolderWithFlags(Components.interfaces.nsMsgFolderFlags.Inbox);
   var index = aLocalFoldersToDownloadTo.indexOf(inbox);
   if (index == -1)
   {
     inbox.biffState = Components.interfaces.nsIMsgFolder.nsMsgBiffState_NoMail;
     inbox.clearNewMessages();
     aLocalFoldersToDownloadTo.push(inbox);
     index = aPOP3DownloadServersArray.length;
-    aPOP3DownloadServersArray[index] =
-      Components.classes["@mozilla.org/supports-array;1"]
-                .createInstance(Components.interfaces.nsISupportsArray);
+    aPOP3DownloadServersArray.push([]);
   }
-  aPOP3DownloadServersArray[index].AppendElement(aCurrentServer);
+  aPOP3DownloadServersArray[index].push(aCurrentServer);
 }
 
 function MailTasksGetMessagesForAllServers(aBiff, aMsgWindow, aDefaultServer)
 {
   // now log into any server
   try
   {
     var allServers = Components.classes["@mozilla.org/messenger/account-manager;1"]
                                .getService(Components.interfaces.nsIMsgAccountManager)
                                .allServers;
-    // array of ISupportsArrays of servers for a particular folder
+    // array of array of servers for a particular folder
     var pop3DownloadServersArray = [];
     // parallel array of folders to download to...
     var localFoldersToDownloadTo = [];
     var pop3Server = null;
     for (let i = 0; i < allServers.length; ++i)
     {
       let currentServer = allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
       if (currentServer)
@@ -124,16 +122,17 @@ function MailTasksGetMessagesForAllServe
 
     if (pop3Server instanceof Components.interfaces.nsIPop3IncomingServer)
     {
       for (let i = 0; i < pop3DownloadServersArray.length; ++i)
       {
         // any ol' pop3Server will do -
         // the serversArray specifies which servers to download from
         pop3Server.downloadMailFromServers(pop3DownloadServersArray[i],
+                                           pop3DownloadServersArray[i].length,
                                            aMsgWindow,
                                            localFoldersToDownloadTo[i],
                                            null);
       }
     }
   }
   catch (e)
   {