Final part of bug 820377 Deal with removing of EnumerateForwards/Backwards from nsISupportsArray - Replace allServers use of nsISupportsArray with nsIArray and do some extra nsISupportsArray cleanup. pending-r=mconley,sr=Neil
authorMark Banner <bugzilla@standard8.plus.com>
Thu, 13 Dec 2012 09:45:16 +0000
changeset 14524 03b3bfba6c88d05c9f0ad22da50adfefd50afbba
parent 14523 2a6deae6e55d0483f5cc67d261ec1b208c15ebb6
child 14525 bef92f7373a52ce7be710af60fc2abd2f98276b0
push id845
push userbugzilla@standard8.plus.com
push dateTue, 19 Feb 2013 18:11:16 +0000
treeherdercomm-beta@ecc3ce2d7daa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs820377
Final part of bug 820377 Deal with removing of EnumerateForwards/Backwards from nsISupportsArray - Replace allServers use of nsISupportsArray with nsIArray and do some extra nsISupportsArray cleanup. pending-r=mconley,sr=Neil
mail/base/content/mail3PaneWindowCommands.js
mail/base/content/mailContextMenus.js
mail/base/content/mailWindowOverlay.js
mail/base/content/msgMail3PaneWindow.js
mail/test/mozmill/account/test-account-actions.js
mail/test/mozmill/account/test-account-settings-infrastructure.js
mailnews/base/content/folderWidgets.xml
mailnews/base/content/virtualFolderListDialog.js
mailnews/base/public/nsIMsgAccountManager.idl
mailnews/base/src/newMailNotificationService.js
mailnews/base/src/nsMsgAccount.cpp
mailnews/base/src/nsMsgAccountManager.cpp
mailnews/base/src/nsMsgAccountManagerDS.cpp
mailnews/base/src/nsMsgAccountManagerDS.h
mailnews/base/src/nsMsgFolderDataSource.cpp
mailnews/base/src/nsMsgOfflineManager.cpp
mailnews/base/src/nsMsgPurgeService.cpp
mailnews/base/util/nsMsgDBFolder.cpp
mailnews/base/util/nsMsgIncomingServer.cpp
mailnews/compose/src/nsSmtpServer.cpp
mailnews/db/gloda/modules/index_msg.js
mailnews/extensions/newsblog/content/utils.js
mailnews/imap/src/nsImapOfflineSync.cpp
mailnews/imap/src/nsImapOfflineSync.h
mailnews/imap/src/nsImapUndoTxn.cpp
mailnews/import/eudora/src/nsEudoraFilters.cpp
mailnews/mapi/mapihook/src/msgMapiHook.cpp
mailnews/news/src/nsNewsDownloader.cpp
mailnews/news/src/nsNewsDownloader.h
mailnews/news/src/nsNntpService.cpp
mailnews/news/src/nsNntpService.h
suite/mailnews/mail3PaneWindowCommands.js
suite/mailnews/mailContextMenus.js
suite/mailnews/mailTasksOverlay.js
suite/mailnews/search/FilterListDialog.js
--- a/mail/base/content/mail3PaneWindowCommands.js
+++ b/mail/base/content/mail3PaneWindowCommands.js
@@ -1176,19 +1176,19 @@ function CanRenameDeleteJunkMail(aFolder
   if (!aFolderUri)
     return false;
 
   // Go through junk mail settings for all servers and see if the folder is set/used by anyone.
   try
   {
     var allServers = accountManager.allServers;
 
-    for (var i=0;i<allServers.Count();i++)
+    for (var i = 0; i < allServers.length; i++)
     {
-      var currentServer = allServers.GetElementAt(i).QueryInterface(Components.interfaces.nsIMsgIncomingServer);
+      var currentServer = allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
       var settings = currentServer.spamSettings;
       // If junk mail control or move junk mail to folder option is disabled then
       // allow the folder to be removed/renamed since the folder is not used in this case.
       if (!settings.level || !settings.moveOnSpam)
         continue;
       if (settings.spamFolderURI == aFolderUri)
         return false;
     }
--- a/mail/base/content/mailContextMenus.js
+++ b/mail/base/content/mailContextMenus.js
@@ -147,22 +147,22 @@ function OpenMessageForMessageId(message
   if (!messageHeader)
   {
     var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"]
                                    .getService(Components.interfaces.nsIMsgAccountManager);
     var allServers = accountManager.allServers;
 
     messageHeader = SearchForMessageIdInSubFolder(startServer.rootFolder, messageId);
 
-    for (var i = 0; i < allServers.Count() && !messageHeader; i++)
+    for (var i = 0; i < allServers.length && !messageHeader; i++)
     {
-      var currentServer = allServers.GetElementAt(i);
-      if ((currentServer instanceof Components.interfaces.nsIMsgIncomingServer) &&
-          startServer != currentServer && currentServer.canSearchMessages &&
-          !currentServer.isDeferredTo)
+      var currentServer =
+        allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
+      if (currentServer && startServer != currentServer &&
+	  currentServer.canSearchMessages && !currentServer.isDeferredTo)
       {
         messageHeader = SearchForMessageIdInSubFolder(currentServer.rootFolder, messageId);
       }
     }
   }
   window.setCursor("auto");
 
   // if message id was found open corresponding message
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -1383,19 +1383,19 @@ function MsgGetMessagesForAllServers(def
   {
     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 pop3Server;
-    for (var i = 0; i < allServers.Count(); ++i)
+    for (var i = 0; i < allServers.length; ++i)
     {
-      var currentServer = allServers.QueryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
+      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)
       {
         if (defaultServer && defaultServer.equals(currentServer) &&
             !defaultServer.isDeferredTo &&
             defaultServer.rootFolder == defaultServer.rootMsgFolder)
         {
@@ -2469,19 +2469,18 @@ 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);
+  for (let i = 0; i < allServers.length; ++i) {
+    let server = allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
     if (server.type == "none")
       continue;
     return true;
   }
   return false;
 }
 
 function IsGetNextNMessagesEnabled()
@@ -2695,19 +2694,19 @@ function GetMessagesForAllAuthenticatedA
     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 pop3Server;
 
-    for (var i = 0; i < allServers.Count(); ++i)
+    for (var i = 0; i < allServers.length; ++i)
     {
-      var currentServer = allServers.GetElementAt(i).QueryInterface(Components.interfaces.nsIMsgIncomingServer);
+      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)
       {
         if (currentServer.type == "pop3")
         {
           CoalesceGetMsgsForPop3ServersByDestFolder(currentServer,
             pop3DownloadServersArray, localFoldersToDownloadTo);
--- a/mail/base/content/msgMail3PaneWindow.js
+++ b/mail/base/content/msgMail3PaneWindow.js
@@ -1220,19 +1220,19 @@ function MigrateJunkMailSettings()
 function MigrateFolderViews()
 {
   var folderViewsVersion = gPrefBranch.getIntPref("mail.folder.views.version");
   if (!folderViewsVersion)
   {
      var servers = accountManager.allServers;
      var server;
      var inbox;
-     for (var index = 0; index < servers.Count(); index++)
+     for (var index = 0; index < servers.length; index++)
      {
-       server = servers.QueryElementAt(index, Components.interfaces.nsIMsgIncomingServer);
+       server = servers.queryElementAt(index, Components.interfaces.nsIMsgIncomingServer);
        if (server)
        {
          inbox = GetInboxFolder(server);
          if (inbox)
            inbox.setFlag(Components.interfaces.nsMsgFolderFlags.Favorite);
        }
      }
     gPrefBranch.setIntPref("mail.folder.views.version", 1);
--- a/mail/test/mozmill/account/test-account-actions.js
+++ b/mail/test/mozmill/account/test-account-actions.js
@@ -11,17 +11,17 @@ const MODULE_REQUIRES = ["folder-display
 let imapAccount, nntpAccount, originalAccountCount;
 
 function setupModule(module) {
   collector.getModule("window-helpers").installInto(module);
   collector.getModule("folder-display-helpers").installInto(module);
   collector.getModule("account-manager-helpers").installInto(module);
 
   // There may be pre-existing accounts from other tests.
-  originalAccountCount = MailServices.accounts.allServers.Count();
+  originalAccountCount = MailServices.accounts.allServers.length;
   // There already should be a Local Folders account created.
   // It is needed for this test.
   assert_true(MailServices.accounts.localFoldersServer);
 
   // Create an IMAP server
   let imapServer = MailServices.accounts
     .createIncomingServer("nobody", "example.com", "imap")
     .QueryInterface(Components.interfaces.nsIImapIncomingServer);
@@ -40,25 +40,25 @@ function setupModule(module) {
 
   identity = MailServices.accounts.createIdentity();
   identity.email = "tinderbox2@example.com";
 
   nntpAccount = MailServices.accounts.createAccount();
   nntpAccount.incomingServer = nntpServer;
   nntpAccount.addIdentity(identity);
   // Now there should be 2 more accounts.
-  assert_equals(MailServices.accounts.allServers.Count(), originalAccountCount + 2);
+  assert_equals(MailServices.accounts.allServers.length, originalAccountCount + 2);
 }
 
 function teardownModule(module) {
   // Remove our test accounts to leave the profile clean.
   MailServices.accounts.removeAccount(nntpAccount);
   MailServices.accounts.removeAccount(imapAccount);
   // There should be only the original accounts left.
-  assert_equals(MailServices.accounts.allServers.Count(), originalAccountCount);
+  assert_equals(MailServices.accounts.allServers.length, originalAccountCount);
 }
 
 /**
  * Check that the account actions for the account are enabled or disabled appropriately.
  *
  * @param amc          the account options controller
  * @param aAccountKey  the key of the account to select
  * @param aIsSetAsDefaultEnabled  true if the menuitem should be enabled, false otherwise
--- a/mail/test/mozmill/account/test-account-settings-infrastructure.js
+++ b/mail/test/mozmill/account/test-account-settings-infrastructure.js
@@ -22,39 +22,39 @@ Components.utils.import("resource://mozm
 let gPopAccount, gOriginalAccountCount;
 
 function setupModule(module) {
   collector.getModule("window-helpers").installInto(module);
   collector.getModule("folder-display-helpers").installInto(module);
   collector.getModule("account-manager-helpers").installInto(module);
 
   // There may be pre-existing accounts from other tests.
-  gOriginalAccountCount = MailServices.accounts.allServers.Count();
+  gOriginalAccountCount = MailServices.accounts.allServers.length;
 
   // Create a POP server
   let popServer = MailServices.accounts
     .createIncomingServer("nobody", "example.com", "pop3")
     .QueryInterface(Components.interfaces.nsIPop3IncomingServer);
 
   let identity = MailServices.accounts.createIdentity();
   identity.email = "tinderbox@example.com";
 
   gPopAccount = MailServices.accounts.createAccount();
   gPopAccount.incomingServer = popServer;
   gPopAccount.addIdentity(identity);
 
   // Now there should be one more account.
-  assert_equals(MailServices.accounts.allServers.Count(), gOriginalAccountCount + 1);
+  assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount + 1);
 }
 
 function teardownModule(module) {
   // Remove our test account to leave the profile clean.
   MailServices.accounts.removeAccount(gPopAccount);
   // There should be only the original accounts left.
-  assert_equals(MailServices.accounts.allServers.Count(), gOriginalAccountCount);
+  assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount);
 }
 
 /**
  * Bug 525024.
  * Check that the options in the server pane are properly preserved across
  * pane switches.
  */
 function test_account_dot_IDs() {
--- a/mailnews/base/content/folderWidgets.xml
+++ b/mailnews/base/content/folderWidgets.xml
@@ -536,19 +536,19 @@
               oldestTime = recentFolders[recentFolders.length-1].getStringProperty("MRMTime");
             }
             recentFolders.push(aFolder);
           }
 
           // Start iterating at the top of the hierarchy, that is, with the root
           // folders for each incoming server.
           let servers = this.MailServices.accounts.allServers;
-          let count = servers.Count();
+          let count = servers.length;
           for (var i = 0; i < count; i++) {
-            var incomingServer = servers.QueryElementAt(i, Ci.nsIMsgIncomingServer);
+            var incomingServer = servers.queryElementAt(i, Ci.nsIMsgIncomingServer);
             addIfRecent(incomingServer.rootFolder);
             checkSubFolders(incomingServer.rootFolder);
           }
 
           function sorter(a, b) {
              return a.getStringProperty("MRMTime") < b.getStringProperty("MRMTime");
           }
           recentFolders.sort(sorter);
--- a/mailnews/base/content/virtualFolderListDialog.js
+++ b/mailnews/base/content/virtualFolderListDialog.js
@@ -60,20 +60,22 @@ function processSearchSettingForFolder(a
 }
 
 // warning: this routine also clears out the search property list from all of the msg folders
 function generateFoldersToSearchList()
 {
   var uriSearchString = "";
 
   var allServers = MailServices.accounts.allServers;
-  var numServers = allServers.Count();
+  var numServers = allServers.length;
   for (var index = 0; index < numServers; index++)
   {
-    var rootFolder  = allServers.GetElementAt(index).QueryInterface(Components.interfaces.nsIMsgIncomingServer).rootFolder;
+    var rootFolder =
+      allServers.queryElementAt(index,
+                                Components.interfaces.nsIMsgIncomingServer).rootFolder;
     if (rootFolder)
     {
       uriSearchString = processSearchSettingForFolder(rootFolder, uriSearchString);
       var allFolders = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
       rootFolder.ListDescendents(allFolders);
       var numFolders = allFolders.Count();
       for (var folderIndex = 0; folderIndex < numFolders; folderIndex++)
         uriSearchString = processSearchSettingForFolder(allFolders.GetElementAt(folderIndex).QueryInterface(Components.interfaces.nsIMsgFolder), uriSearchString);
@@ -83,20 +85,22 @@ function generateFoldersToSearchList()
   return uriSearchString;
 }
 
 function resetFolderToSearchAttribute()
 {
   // iterates over all accounts and all folders, clearing out the inVFEditScope property in case
   // we set it.
   var allServers = MailServices.accounts.allServers;
-  var numServers = allServers.Count();
+  var numServers = allServers.length;
   for (var index = 0; index < numServers; index++)
   {
-    var rootFolder  = allServers.GetElementAt(index).QueryInterface(Components.interfaces.nsIMsgIncomingServer).rootFolder;
+    var rootFolder =
+      allServers.queryElementAt(index,
+                                Components.interfaces.nsIMsgIncomingServer).rootFolder;
     if (rootFolder)
     {
       var allFolders = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
       rootFolder.ListDescendents(allFolders);
       var numFolders = allFolders.Count();
       for (var folderIndex = 0; folderIndex < numFolders; folderIndex++)
         allFolders.GetElementAt(folderIndex).QueryInterface(Components.interfaces.nsIMsgFolder).setInVFEditSearchScope(false, false);
     }
--- a/mailnews/base/public/nsIMsgAccountManager.idl
+++ b/mailnews/base/public/nsIMsgAccountManager.idl
@@ -5,21 +5,20 @@
 
 #include "nsISupports.idl"
 #include "nsIMsgAccount.idl"
 #include "nsIMsgIdentity.idl"
 #include "nsIMsgIncomingServer.idl"
 #include "nsIIncomingServerListener.idl"
 #include "nsIMsgFolder.idl"
 
-interface nsISupportsArray;
 interface nsIMsgFolderCache;
 interface nsIFolderListener;
 
-[scriptable, uuid(0eb25b3d-56bf-4d87-9b1d-c4a8466391f3)]
+[scriptable, uuid(d5ab0eea-49c5-42f2-b2e6-8ad306606d8b)]
 interface nsIMsgAccountManager : nsISupports {
 
   nsIMsgAccount createAccount();
   /*
    * Return the account with the provided key, or null if none found.
    */
   nsIMsgAccount getAccount(in ACString key);
     
@@ -81,17 +80,17 @@ interface nsIMsgAccountManager : nsISupp
   /* list of all identities in all accounts
    * array of nsIMsgIdentity
    */
   readonly attribute nsIArray allIdentities;
 
   /* list of all servers in all accounts, except for hidden and IM servers
    * array of nsIMsgIncomingServer
    */
-  readonly attribute nsISupportsArray allServers;
+  readonly attribute nsIArray allServers;
 
   /* summary of summary files folder cache */
   readonly attribute nsIMsgFolderCache folderCache;
 
   /* are we shutting down */
   readonly attribute boolean shutdownInProgress;
 
   /**
--- a/mailnews/base/src/newMailNotificationService.js
+++ b/mailnews/base/src/newMailNotificationService.js
@@ -103,18 +103,18 @@ NewMailNotificationService.prototype = {
     } catch (error) {
       this._log.error("NMNS_Observe failed: " + error);
     }
   },
 
   _initUnreadCount: function NMNS_initUnreadCount() {
     let total = 0;
     let allServers = MailServices.accounts.allServers;
-    for (let i = 0; i < allServers.Count(); i++) {
-      let currentServer = allServers.QueryElementAt(i, Ci.nsIMsgIncomingServer);
+    for (let i = 0; i < allServers.length; i++) {
+      let currentServer = allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
       this._log.debug("NMNS_initUnread: server " + currentServer.prettyName + " type " + currentServer.type);
       // Don't bother counting RSS or NNTP servers
       let type = currentServer.type;
       if (type == "rss" || type == "nntp")
         continue;
 
       let rootFolder = currentServer.rootFolder;
       if (rootFolder) {
--- a/mailnews/base/src/nsMsgAccount.cpp
+++ b/mailnews/base/src/nsMsgAccount.cpp
@@ -169,17 +169,16 @@ nsMsgAccount::SetIncomingServer(nsIMsgIn
         continue;
       mailSession->OnItemAdded(rootFolder, msgFolder);
       notifier->NotifyFolderAdded(msgFolder);
     }
   }
   return NS_OK;
 }
 
-/* nsISupportsArray GetIdentities (); */
 NS_IMETHODIMP
 nsMsgAccount::GetIdentities(nsIArray **_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
   NS_ENSURE_TRUE(m_identities, NS_ERROR_FAILURE);
 
   NS_IF_ADDREF(*_retval = m_identities);
   return NS_OK;
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -1176,37 +1176,34 @@ hashGetNonHiddenServersToArray(nsCString
   if (hidden)
     return PL_DHASH_NEXT;
 
   nsCString type;
   NS_ENSURE_SUCCESS(aServer->GetType(type), PL_DHASH_NEXT);
 
   if (!type.EqualsLiteral("im"))
   {
-    nsISupportsArray *array = (nsISupportsArray*) aClosure;
-    nsCOMPtr<nsISupports> serverSupports = do_QueryInterface(aServer);
-    array->AppendElement(aServer);
+    nsIMutableArray *array = static_cast<nsIMutableArray*>(aClosure);
+    array->AppendElement(aServer, false);
   }
   return PL_DHASH_NEXT;
 }
 
-/* nsISupportsArray GetAllServers (); */
 NS_IMETHODIMP
-nsMsgAccountManager::GetAllServers(nsISupportsArray **_retval)
+nsMsgAccountManager::GetAllServers(nsIArray **_retval)
 {
   nsresult rv = LoadAccounts();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsISupportsArray> servers;
-  rv = NS_NewISupportsArray(getter_AddRefs(servers));
+  nsCOMPtr<nsIMutableArray> servers(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   m_incomingServers.Enumerate(hashGetNonHiddenServersToArray,
-                              (void *)(nsISupportsArray*)servers);
-  servers.swap(*_retval);
+                              (void *)servers);
+  servers.forget(_retval);
   return rv;
 }
 
 nsresult
 nsMsgAccountManager::LoadAccounts()
 {
   nsresult rv;
 
@@ -3296,21 +3293,24 @@ nsresult nsMsgAccountManager::RemoveVFLi
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgAccountManager::GetAllFolders(nsIArray **aAllFolders)
 {
   NS_ENSURE_ARG_POINTER(aAllFolders);
-  nsCOMPtr<nsISupportsArray> servers;
+  nsCOMPtr<nsIArray> servers;
   nsresult rv = GetAllServers(getter_AddRefs(servers));
   NS_ENSURE_SUCCESS(rv, rv);
+
   uint32_t numServers = 0;
-  servers->Count(&numServers);
+  rv = servers->GetLength(&numServers);
+  NS_ENSURE_SUCCESS(rv, rv);
+
   nsCOMPtr<nsISupportsArray> allDescendents;
   rv = NS_NewISupportsArray(getter_AddRefs(allDescendents));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIMutableArray> folderArray(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t i;
--- a/mailnews/base/src/nsMsgAccountManagerDS.cpp
+++ b/mailnews/base/src/nsMsgAccountManagerDS.cpp
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * RDF datasource for the account manager
  */
 
@@ -20,16 +20,17 @@
 #include "nsICategoryManager.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsArrayEnumerator.h"
 #include "nsMsgUtils.h"
 #include "mozilla/Services.h"
+#include "nsArrayUtils.h"
 
 // turn this on to see useful output
 #undef DEBUG_amds
 
 #define NC_RDF_PAGETITLE_PREFIX               NC_NAMESPACE_URI "PageTitle"
 #define NC_RDF_PAGETITLE_MAIN                 NC_RDF_PAGETITLE_PREFIX "Main"
 #define NC_RDF_PAGETITLE_SERVER               NC_RDF_PAGETITLE_PREFIX "Server"
 #define NC_RDF_PAGETITLE_COPIES               NC_RDF_PAGETITLE_PREFIX "Copies"
@@ -38,26 +39,16 @@
 #define NC_RDF_PAGETITLE_ADDRESSING           NC_RDF_PAGETITLE_PREFIX "Addressing"
 #define NC_RDF_PAGETITLE_SMTP                 NC_RDF_PAGETITLE_PREFIX "SMTP"
 #define NC_RDF_PAGETITLE_JUNK                 NC_RDF_PAGETITLE_PREFIX "Junk"
 #define NC_RDF_PAGETAG NC_NAMESPACE_URI "PageTag"
 
 
 #define NC_RDF_ACCOUNTROOT "msgaccounts:/"
 
-typedef struct _serverCreationParams {
-  nsCOMArray<nsIRDFResource> *serverArray;
-  nsIRDFService *rdfService;
-} serverCreationParams;
-
-typedef struct {
-  nsCString serverKey;
-  bool found;
-} findServerByKeyEntry;
-
 // the root resource (msgaccounts:/)
 nsIRDFResource* nsMsgAccountManagerDataSource::kNC_AccountRoot=nullptr;
 
 // attributes of accounts
 nsIRDFResource* nsMsgAccountManagerDataSource::kNC_Name=nullptr;
 nsIRDFResource* nsMsgAccountManagerDataSource::kNC_FolderTreeName=nullptr;
 nsIRDFResource* nsMsgAccountManagerDataSource::kNC_FolderTreeSimpleName=nullptr;
 nsIRDFResource* nsMsgAccountManagerDataSource::kNC_NameSort=nullptr;
@@ -565,23 +556,41 @@ nsMsgAccountManagerDataSource::createRoo
                                                    nsCOMArray<nsIRDFResource> *aNodeArray)
 {
   nsresult rv = NS_OK;
   if (isContainment(property)) {
 
     nsCOMPtr<nsIMsgAccountManager> am = do_QueryReferent(mAccountManager);
     if (!am) return NS_ERROR_FAILURE;
 
-    nsCOMPtr<nsISupportsArray> servers;
+    nsCOMPtr<nsIArray> servers;
     rv = am->GetAllServers(getter_AddRefs(servers));
-    if (NS_FAILED(rv)) return rv;
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    uint32_t length;
+    rv = servers->GetLength(&length);
+    NS_ENSURE_SUCCESS(rv, rv);
 
-    // fill up the nodes array with the RDF Resources for the servers
-    serverCreationParams params = { aNodeArray, getRDFService() };
-    servers->EnumerateForwards(createServerResources, (void*)&params);
+    for (uint32_t i = 0; i < length; ++i)
+    {
+      nsCOMPtr<nsIMsgIncomingServer> server(do_QueryElementAt(servers, i, &rv));
+      if (NS_FAILED(rv))
+        continue;
+
+      nsCOMPtr<nsIMsgFolder> serverFolder;
+      rv = server->GetRootFolder(getter_AddRefs(serverFolder));
+      if (NS_FAILED(rv))
+        continue;
+
+      // add the resource to the array
+      nsCOMPtr<nsIRDFResource> serverResource = do_QueryInterface(serverFolder);
+      if (serverResource)
+        (void) aNodeArray->AppendObject(serverResource);
+    }
+
 #ifdef DEBUG_amds
     uint32_t nodecount;
     aNodeArray->GetLength(&nodecount);
     printf("GetTargets(): added %d servers on %s\n", nodecount,
            (const char*)property_arc);
 #endif
     // For the "settings" arc, we also want to add SMTP setting.
     if (property == kNC_Settings) {
@@ -746,44 +755,16 @@ nsMsgAccountManagerDataSource::serverHas
   rv = identities->GetLength(&count);
   if (NS_FAILED(rv)) return NS_OK;
 
   if (count >0)
     *aResult = true;
   return NS_OK;
 }
 
-// enumeration function to convert each server (element)
-// to an nsIRDFResource and append it to the array (in data)
-// always return true to try on every element instead of aborting early
-bool
-nsMsgAccountManagerDataSource::createServerResources(nsISupports *element,
-                                                     void *data)
-{
-  nsresult rv;
-  // get parameters out of the data argument
-  serverCreationParams *params = (serverCreationParams*)data;
-  nsCOMArray<nsIRDFResource> *servers = params->serverArray;
-  nsCOMPtr<nsIRDFService> rdf = params->rdfService;
-
-  // the server itself is in the element argument
-  nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(element, &rv);
-  if (NS_FAILED(rv)) return true;
-
-  nsCOMPtr <nsIMsgFolder> serverFolder;
-  rv = server->GetRootFolder(getter_AddRefs(serverFolder));
-  if(NS_FAILED(rv)) return true;
-
-  // add the resource to the array
-  nsCOMPtr<nsIRDFResource> serverResource = do_QueryInterface(serverFolder);
-  if(serverResource)
-    (void) servers->AppendObject(serverResource);
-  return true;
-}
-
 nsresult
 nsMsgAccountManagerDataSource::getAccountArcs(nsIMutableArray **aResult)
 {
   nsresult rv;
   if (!mAccountArcsOut) {
     mAccountArcsOut = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -1019,45 +1000,54 @@ nsMsgAccountManagerDataSource::canGetInc
 }
 
 nsresult
 nsMsgAccountManagerDataSource::HasAssertionAccountRoot(nsIRDFResource *aProperty,
                                                        nsIRDFNode *aTarget,
                                                        bool aTruthValue,
                                                        bool *_retval)
 {
-
-  nsresult rv;
-
   // set up default
   *_retval = false;
 
   // for child and settings arcs, just make sure it's a valid server:
   if (isContainment(aProperty)) {
 
     nsCOMPtr<nsIMsgIncomingServer> server;
-    rv = getServerForFolderNode(aTarget, getter_AddRefs(server));
+    nsresult rv = getServerForFolderNode(aTarget, getter_AddRefs(server));
     if (NS_FAILED(rv) || !server) return rv;
 
     nsCString serverKey;
     server->GetKey(serverKey);
 
     nsCOMPtr<nsIMsgAccountManager> am = do_QueryReferent(mAccountManager, &rv);
     if (NS_FAILED(rv)) return rv;
 
-    nsCOMPtr<nsISupportsArray> serverArray;
+    nsCOMPtr<nsIArray> serverArray;
     rv = am->GetAllServers(getter_AddRefs(serverArray));
-    if (NS_FAILED(rv)) return rv;
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    uint32_t length;
+    rv = serverArray->GetLength(&length);
+    NS_ENSURE_SUCCESS(rv, rv);
 
-    findServerByKeyEntry entry;
-    entry.serverKey = serverKey;
-    entry.found = false;
+    for (uint32_t i = 0; i < length; ++i)
+    {
+      nsCOMPtr<nsIMsgIncomingServer> server(do_QueryElementAt(serverArray, i, &rv));
+      if (NS_FAILED(rv))
+        continue;
 
-    serverArray->EnumerateForwards(findServerByKey, &entry);
-    (*_retval) = entry.found;
+      nsCString key;
+      server->GetKey(key);
+      if (key.Equals(serverKey))
+      {
+        *_retval = true;
+        break;
+      }
+    }
   }
 
   return NS_OK;
 }
 
 bool
 nsMsgAccountManagerDataSource::isContainment(nsIRDFResource *aProperty)
 {
@@ -1080,37 +1070,16 @@ nsMsgAccountManagerDataSource::getServer
     bool isServer;
     rv = folder->GetIsServer(&isServer);
     if (NS_SUCCEEDED(rv) && isServer) 
       return folder->GetServer(aResult);
   }
   return NS_ERROR_FAILURE;
 }
 
-bool
-nsMsgAccountManagerDataSource::findServerByKey(nsISupports *aElement,
-                                               void *aData)
-{
-  nsresult rv;
-  findServerByKeyEntry *entry = (findServerByKeyEntry*)aData;
-
-  nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(aElement, &rv);
-  if (NS_FAILED(rv)) return true;
-
-  nsCString key;
-  server->GetKey(key);
-  if (key.Equals(entry->serverKey))
-  {
-    entry->found = true;
-    return false;        // stop when found
-  }
-
-  return true;
-}
-
 nsresult
 nsMsgAccountManagerDataSource::getStringBundle()
 {
   if (mStringBundle) return NS_OK;
 
   nsCOMPtr<nsIStringBundleService> strBundleService =
     mozilla::services::GetStringBundleService();
   NS_ENSURE_TRUE(strBundleService, NS_ERROR_UNEXPECTED);
--- a/mailnews/base/src/nsMsgAccountManagerDS.h
+++ b/mailnews/base/src/nsMsgAccountManagerDS.h
@@ -125,23 +125,16 @@ protected:
   static nsIAtom* kDefaultServerAtom;
 
   static nsrefcnt gAccountManagerResourceRefCnt;
 
   static nsresult getAccountArcs(nsIMutableArray **aResult);
   static nsresult getAccountRootArcs(nsIMutableArray **aResult);
   
 private:
-  // enumeration function to convert each server (element)
-  // to an nsIRDFResource and append it to the array (in data)
-  static bool createServerResources(nsISupports *element, void *data);
-
-  // search for an account by key
-  static bool findServerByKey(nsISupports *aElement, void *aData);
-
   nsresult serverHasIdentities(nsIMsgIncomingServer *aServer, bool *aResult);
   nsresult getStringBundle();
 
   static nsCOMPtr<nsIMutableArray> mAccountArcsOut;
   static nsCOMPtr<nsIMutableArray> mAccountRootArcsOut;
   nsWeakPtr mAccountManager;
   nsCOMPtr<nsIStringBundle> mStringBundle;
 };
--- a/mailnews/base/src/nsMsgFolderDataSource.cpp
+++ b/mailnews/base/src/nsMsgFolderDataSource.cpp
@@ -2165,23 +2165,26 @@ void nsMsgFlatFolderDataSource::EnsureFo
     m_builtFolders = true; // in case something goes wrong
 
     // need an enumerator that gives all folders with unread
     nsresult rv;
     nsCOMPtr <nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
     if (NS_FAILED(rv))
       return;
 
-    nsCOMPtr<nsISupportsArray> allServers;
+    nsCOMPtr<nsIArray> allServers;
     rv = accountManager->GetAllServers(getter_AddRefs(allServers));
+    if (NS_FAILED(rv))
+      return;
+
     nsCOMPtr <nsISupportsArray> allFolders = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
     if (NS_SUCCEEDED(rv) && allServers)
     {
       uint32_t count = 0;
-      allServers->Count(&count);
+      allServers->GetLength(&count);
       uint32_t i;
       for (i = 0; i < count; i++)
       {
         nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(allServers, i);
         if (server)
         {
           nsCOMPtr <nsIMsgFolder> rootFolder;
           server->GetRootFolder(getter_AddRefs(rootFolder));
@@ -2364,23 +2367,26 @@ void nsMsgRecentFoldersDataSource::Ensur
   {
     m_builtFolders = true;
 
     nsresult rv;
     nsCOMPtr <nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
     if (NS_FAILED(rv))
       return;
 
-    nsCOMPtr<nsISupportsArray> allServers;
+    nsCOMPtr<nsIArray> allServers;
     rv = accountManager->GetAllServers(getter_AddRefs(allServers));
+    if (NS_FAILED(rv))
+      return;
+
     nsCOMPtr <nsISupportsArray> allFolders = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
     if (NS_SUCCEEDED(rv) && allServers)
     {
       uint32_t count = 0;
-      allServers->Count(&count);
+      allServers->GetLength(&count);
       uint32_t i;
       for (i = 0; i < count; i++)
       {
         nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(allServers, i);
         if (server)
         {
           nsCOMPtr <nsIMsgFolder> rootFolder;
           server->GetRootFolder(getter_AddRefs(rootFolder));
--- a/mailnews/base/src/nsMsgOfflineManager.cpp
+++ b/mailnews/base/src/nsMsgOfflineManager.cpp
@@ -5,17 +5,16 @@
 
 /*
  * The offline manager service - manages going online and offline, and synchronization
  */
 #include "msgCore.h"
 #include "netCore.h"
 #include "nsMsgOfflineManager.h"
 #include "nsIServiceManager.h"
-#include "nsISupportsArray.h"
 #include "nsMsgBaseCID.h"
 #include "nsIImapService.h"
 #include "nsMsgImapCID.h"
 #include "nsIMsgSendLater.h"
 #include "nsIMsgAccountManager.h"
 #include "nsMsgCompCID.h"
 #include "nsIIOService.h"
 #include "nsNetCID.h"
--- a/mailnews/base/src/nsMsgPurgeService.cpp
+++ b/mailnews/base/src/nsMsgPurgeService.cpp
@@ -21,16 +21,17 @@
 #include "nsIMsgFilterPlugin.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "prlog.h"
 #include "nsMsgFolderFlags.h"
 #include <stdlib.h>
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
+#include "nsArrayUtils.h"
 
 static PRLogModuleInfo *MsgPurgeLogModule = nullptr;
 
 NS_IMPL_ISUPPORTS2(nsMsgPurgeService, nsIMsgPurgeService, nsIMsgSearchNotify)
 
 void OnPurgeTimer(nsITimer *timer, void *aPurgeService)
 {
   nsMsgPurgeService *purgeService = (nsMsgPurgeService*)aPurgeService;
@@ -132,22 +133,22 @@ nsresult nsMsgPurgeService::PerformPurge
   PR_LOG(MsgPurgeLogModule, PR_LOG_ALWAYS, ("performing purge"));
 
   nsresult rv;
 
   nsCOMPtr <nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
   bool keepApplyingRetentionSettings = true;
 
-  nsCOMPtr<nsISupportsArray> allServers;
+  nsCOMPtr<nsIArray> allServers;
   rv = accountManager->GetAllServers(getter_AddRefs(allServers));
   if (NS_SUCCEEDED(rv) && allServers)
   {
     uint32_t numServers;
-    rv = allServers->Count(&numServers);
+    rv = allServers->GetLength(&numServers);
     PR_LOG(MsgPurgeLogModule, PR_LOG_ALWAYS, ("%d servers", numServers));
     nsCOMPtr<nsIMsgFolder> folderToPurge;
     PRIntervalTime startTime = PR_IntervalNow();
     int32_t purgeIntervalToUse;
     PRTime oldestPurgeTime = 0; // we're going to pick the least-recently purged folder
 
     // apply retention settings to folders that haven't had retention settings
     // applied in mMinDelayBetweenPurges minutes (default 8 hours)
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -1817,34 +1817,34 @@ private:
 };
 
 nsresult nsMsgDBFolder::HandleAutoCompactEvent(nsIMsgWindow *aWindow)
 {
   nsresult rv;
   nsCOMPtr<nsIMsgAccountManager> accountMgr = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
   if (NS_SUCCEEDED(rv))
   {
-    nsCOMPtr<nsISupportsArray> allServers;
+    nsCOMPtr<nsIArray> allServers;
     rv = accountMgr->GetAllServers(getter_AddRefs(allServers));
     NS_ENSURE_SUCCESS(rv, rv);
     uint32_t numServers = 0, serverIndex = 0;
-    rv = allServers->Count(&numServers);
+    rv = allServers->GetLength(&numServers);
     int32_t offlineSupportLevel;
     if (numServers > 0)
     {
       nsCOMPtr<nsIMutableArray> folderArray = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
       nsCOMPtr<nsIMutableArray> offlineFolderArray = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
       int32_t totalExpungedBytes = 0;
       int32_t offlineExpungedBytes = 0;
       int32_t localExpungedBytes = 0;
       do
       {
-        nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(allServers, serverIndex);
+        nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(allServers, serverIndex, &rv);
         NS_ENSURE_SUCCESS(rv, rv);
         nsCOMPtr<nsIMsgPluggableStore> msgStore;
         rv = server->GetMsgStore(getter_AddRefs(msgStore));
         NS_ENSURE_SUCCESS(rv, rv);
         if (!msgStore)
           continue;
         bool supportsCompaction;
         msgStore->GetSupportsCompaction(&supportsCompaction);
@@ -2072,22 +2072,22 @@ nsMsgDBFolder::MatchOrChangeFilterDestin
     rv = newFolder->GetURI(newUri);
     NS_ENSURE_SUCCESS(rv,rv);
   }
 
   nsCOMPtr<nsIMsgFilterList> filterList;
   nsCOMPtr<nsIMsgAccountManager> accountMgr = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsISupportsArray> allServers;
+  nsCOMPtr<nsIArray> allServers;
   rv = accountMgr->GetAllServers(getter_AddRefs(allServers));
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t numServers;
-  rv = allServers->Count(&numServers);
+  rv = allServers->GetLength(&numServers);
   for (uint32_t serverIndex = 0; serverIndex < numServers; serverIndex++)
   {
     nsCOMPtr <nsIMsgIncomingServer> server = do_QueryElementAt(allServers, serverIndex);
     if (server)
     {
       bool canHaveFilters;
       rv = server->GetCanHaveFilters(&canHaveFilters);
       if (NS_SUCCEEDED(rv) && canHaveFilters)
--- a/mailnews/base/util/nsMsgIncomingServer.cpp
+++ b/mailnews/base/util/nsMsgIncomingServer.cpp
@@ -42,16 +42,18 @@
 #include "nsIMsgMdnGenerator.h"
 #include "nsMsgFolderFlags.h"
 #include "nsMsgUtils.h"
 #include "nsMsgMessageFlags.h"
 #include "nsIMsgSearchTerm.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "mozilla/Services.h"
 #include "nsIMsgFilter.h"
+#include "nsIArray.h"
+#include "nsArrayUtils.h"
 
 #define PORT_NOT_SET -1
 
 nsMsgIncomingServer::nsMsgIncomingServer():
     m_rootFolder(0),
     m_numMsgsDownloaded(0),
     m_biffState(nsIMsgFolder::nsMsgBiffState_Unknown),
     m_serverBusy(false),
@@ -2129,24 +2131,24 @@ nsresult nsMsgIncomingServer::GetDeferre
   nsCOMPtr<nsISupportsArray> servers;
   rv = NS_NewISupportsArray(getter_AddRefs(servers));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr <nsIMsgAccount> thisAccount;
   accountManager->FindAccountForServer(destServer, getter_AddRefs(thisAccount));
   if (thisAccount)
   {
-    nsCOMPtr <nsISupportsArray> allServers;
+    nsCOMPtr<nsIArray> allServers;
     nsCString accountKey;
     thisAccount->GetKey(accountKey);
     accountManager->GetAllServers(getter_AddRefs(allServers));
     if (allServers)
     {
       uint32_t serverCount;
-      allServers->Count(&serverCount);
+      allServers->GetLength(&serverCount);
       for (uint32_t i = 0; i < serverCount; i++)
       {
         nsCOMPtr <nsIMsgIncomingServer> server (do_QueryElementAt(allServers, i));
         if (server)
         {
           nsCString deferredToAccount;
           server->GetCharValue("deferred_to_account", deferredToAccount);
           if (deferredToAccount.Equals(accountKey))
@@ -2165,24 +2167,24 @@ NS_IMETHODIMP nsMsgIncomingServer::GetIs
   nsCOMPtr<nsIMsgAccountManager> accountManager
     = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID);
   if (accountManager)
   {
     nsCOMPtr <nsIMsgAccount> thisAccount;
     accountManager->FindAccountForServer(this, getter_AddRefs(thisAccount));
     if (thisAccount)
     {
-      nsCOMPtr <nsISupportsArray> allServers;
+      nsCOMPtr<nsIArray> allServers;
       nsCString accountKey;
       thisAccount->GetKey(accountKey);
       accountManager->GetAllServers(getter_AddRefs(allServers));
       if (allServers)
       {
         uint32_t serverCount;
-        allServers->Count(&serverCount);
+        allServers->GetLength(&serverCount);
         for (uint32_t i = 0; i < serverCount; i++)
         {
           nsCOMPtr <nsIMsgIncomingServer> server (do_QueryElementAt(allServers, i));
           if (server)
           {
             nsCString deferredToAccount;
             server->GetCharValue("deferred_to_account", deferredToAccount);
             if (deferredToAccount.Equals(accountKey))
--- a/mailnews/compose/src/nsSmtpServer.cpp
+++ b/mailnews/compose/src/nsSmtpServer.cpp
@@ -10,16 +10,18 @@
 #include "nsIAuthPrompt.h"
 #include "nsMsgUtils.h"
 #include "nsIMsgAccountManager.h"
 #include "nsMsgBaseCID.h"
 #include "nsISmtpService.h"
 #include "nsMsgCompCID.h"
 #include "nsILoginInfo.h"
 #include "nsILoginManager.h"
+#include "nsIArray.h"
+#include "nsArrayUtils.h"
 
 NS_IMPL_ADDREF(nsSmtpServer)
 NS_IMPL_RELEASE(nsSmtpServer)
 NS_INTERFACE_MAP_BEGIN(nsSmtpServer)
     NS_INTERFACE_MAP_ENTRY(nsISmtpServer)
     NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
     NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISmtpServer)
 NS_INTERFACE_MAP_END
@@ -298,22 +300,22 @@ nsSmtpServer::GetPassword(nsACString& aP
             if (useMatchingHostNameServer)
               // pass in empty type and port=0, to match imap and pop3.
               accountManager->FindRealServer(userName, hostName, EmptyCString(), 0, getter_AddRefs(incomingServerToUse));
             int32_t dotPos = -1;
             if (!incomingServerToUse && useMatchingDomainServer
               && (dotPos = hostName.FindChar('.')) != kNotFound)
             {
               hostName.Cut(0, dotPos);
-              nsCOMPtr<nsISupportsArray> allServers;
+              nsCOMPtr<nsIArray> allServers;
               accountManager->GetAllServers(getter_AddRefs(allServers));
               if (allServers)
               {
                 uint32_t count = 0;
-                allServers->Count(&count);
+                allServers->GetLength(&count);
                 uint32_t i;
                 for (i = 0; i < count; i++)
                 {
                   nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(allServers, i);
                   if (server)
                   {
                     nsCString serverUserName;
                     nsCString serverHostName;
--- a/mailnews/db/gloda/modules/index_msg.js
+++ b/mailnews/db/gloda/modules/index_msg.js
@@ -999,18 +999,18 @@ var GlodaMsgIndexer = {
       // Walk the folders and make sure all the folders we would want to index
       //  are mapped.  Build up a list of GlodaFolders as we go, so that we can
       //  sort them by their indexing priority.
       let foldersToProcess = aJob.foldersToProcess = [];
 
       let accountManager = Cc["@mozilla.org/messenger/account-manager;1"].
                            getService(Ci.nsIMsgAccountManager);
       let servers = accountManager.allServers;
-      for (let i = 0; i < servers.Count(); i++) {
-        let server = servers.QueryElementAt(i, Ci.nsIMsgIncomingServer);
+      for (let i = 0; i < servers.length; i++) {
+        let server = servers.queryElementAt(i, Ci.nsIMsgIncomingServer);
         let rootFolder = server.rootFolder;
 
         let allFolders = Cc["@mozilla.org/supports-array;1"].
           createInstance(Ci.nsISupportsArray);
         rootFolder.ListDescendents(allFolders);
         let numFolders = allFolders.Count();
         for (let folderIndex = 0; folderIndex < numFolders; folderIndex++) {
           let folder = allFolders.GetElementAt(folderIndex).QueryInterface(
--- a/mailnews/extensions/newsblog/content/utils.js
+++ b/mailnews/extensions/newsblog/content/utils.js
@@ -89,19 +89,19 @@ var FeedUtils = {
 /**
  * Get all rss account servers rootFolders.
  * 
  * @return array of nsIMsgIncomingServer (empty array if none).
  */
   getAllRssServerRootFolders: function() {
     let rssRootFolders = [];
     let allServers = MailServices.accounts.allServers;
-    for (let i = 0; i < allServers.Count(); i++)
+    for (let i = 0; i < allServers.length; i++)
     {
-      let server = allServers.QueryElementAt(i, Ci.nsIMsgIncomingServer);
+      let server = allServers.queryElementAt(i, Ci.nsIMsgIncomingServer);
       if (server && server.type == "rss")
         rssRootFolders.push(server.rootFolder);
     }
 
     // By default, Tb sorts by hostname, ie Feeds, Feeds-1, and not by alpha
     // prettyName.  Do the same as a stock install to match folderpane order.
     rssRootFolders.sort(function(a, b) { return a.hostname > b.hostname });
 
--- a/mailnews/imap/src/nsImapOfflineSync.cpp
+++ b/mailnews/imap/src/nsImapOfflineSync.cpp
@@ -19,16 +19,17 @@
 #include "nsDirectoryServiceDefs.h"
 #include "nsISeekableStream.h"
 #include "nsIMsgCopyService.h"
 #include "nsImapProtocol.h"
 #include "nsMsgUtils.h"
 #include "nsIMutableArray.h"
 #include "nsIAutoSyncManager.h"
 #include "nsAlgorithm.h"
+#include "nsArrayUtils.h"
 
 static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
 
 NS_IMPL_ISUPPORTS3(nsImapOfflineSync, nsIUrlListener, nsIMsgCopyServiceListener, nsIDBChangeListener)
 
 nsImapOfflineSync::nsImapOfflineSync(nsIMsgWindow *window, nsIUrlListener *listener, nsIMsgFolder *singleFolderOnly, bool isPseudoOffline)
 {
   m_singleFolderToUpdate = singleFolderOnly;
@@ -131,28 +132,36 @@ nsresult nsImapOfflineSync::AdvanceToNex
     nsCOMPtr<nsIMsgAccountManager> accountManager = 
              do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
     NS_ASSERTION(accountManager && NS_SUCCEEDED(rv), "couldn't get account mgr");
     if (!accountManager || NS_FAILED(rv)) return rv;
 
     rv = accountManager->GetAllServers(getter_AddRefs(m_allServers));
     NS_ENSURE_SUCCESS(rv, rv);
   }
-  uint32_t serverIndex = (m_currentServer) ? m_allServers->IndexOf(m_currentServer) + 1 : 0;
+  uint32_t serverIndex = 0;
+  if (m_currentServer)
+  {
+    rv = m_allServers->IndexOf(0, m_currentServer, &serverIndex);
+    if (NS_FAILED(rv))
+      serverIndex = -1;
+
+    // Move to the next server
+    ++serverIndex;
+  }
   m_currentServer = nullptr;
   uint32_t numServers; 
-  m_allServers->Count(&numServers);
+  m_allServers->GetLength(&numServers);
   nsCOMPtr <nsIMsgFolder> rootFolder;
 
   while (serverIndex < numServers)
   {
-    nsCOMPtr <nsISupports> serverSupports = getter_AddRefs(m_allServers->ElementAt(serverIndex));
+    nsCOMPtr<nsIMsgIncomingServer> server(do_QueryElementAt(m_allServers, serverIndex));
     serverIndex++;
 
-    nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(serverSupports);
     nsCOMPtr <nsINntpIncomingServer> newsServer = do_QueryInterface(server);
     if (newsServer) // news servers aren't involved in offline imap
       continue;
     if (server)
     {
       m_currentServer = server;
       server->GetRootFolder(getter_AddRefs(rootFolder));
       if (rootFolder)
@@ -1086,18 +1095,18 @@ nsresult nsImapOfflineDownloader::Proces
   if (!m_mailboxupdatesStarted)
   {
     m_mailboxupdatesStarted = true;
     // Update the INBOX first so the updates on the remaining
     // folders pickup the results of any filter moves.
     nsCOMPtr<nsIMsgAccountManager> accountManager = 
              do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
     if (NS_FAILED(rv)) return rv;
-    nsCOMPtr<nsISupportsArray> servers;
-  
+
+    nsCOMPtr<nsIArray> servers;  
     rv = accountManager->GetAllServers(getter_AddRefs(servers));
     if (NS_FAILED(rv)) return rv;
   }
   if (!m_mailboxupdatesFinished)
   {
     AdvanceToNextServer();
     if (m_currentServer)
     {
--- a/mailnews/imap/src/nsImapOfflineSync.h
+++ b/mailnews/imap/src/nsImapOfflineSync.h
@@ -56,17 +56,17 @@ protected:
   void      ProcessCopyOperation(nsIMsgOfflineImapOperation *currentOp);
   void      ProcessEmptyTrash();
   void      ProcessAppendMsgOperation(nsIMsgOfflineImapOperation *currentOp,
                                       nsOfflineImapOperationType opType);
 
   nsCOMPtr <nsIMsgFolder> m_currentFolder;
   nsCOMPtr <nsIMsgFolder> m_singleFolderToUpdate;
   nsCOMPtr <nsIMsgWindow> m_window;
-  nsCOMPtr <nsISupportsArray> m_allServers;
+  nsCOMPtr <nsIArray> m_allServers;
   nsCOMPtr <nsISupportsArray> m_allFolders;
   nsCOMPtr <nsIMsgIncomingServer> m_currentServer;
   nsCOMPtr <nsIEnumerator> m_serverEnumerator;
   nsCOMPtr <nsIFile> m_curTempFile;
   
   nsTArray<nsMsgKey> m_CurrentKeys;
   nsCOMArray<nsIMsgOfflineImapOperation> m_currentOpsToClear;
   uint32_t      m_KeyIndex;
--- a/mailnews/imap/src/nsImapUndoTxn.cpp
+++ b/mailnews/imap/src/nsImapUndoTxn.cpp
@@ -8,17 +8,16 @@
 #include "nsIMsgHdr.h"
 #include "nsImapUndoTxn.h"
 #include "nsIIMAPHostSessionList.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsImapMailFolder.h"
 #include "nsIDBFolderInfo.h"
 #include "nsIMsgDatabase.h"
 #include "nsMsgUtils.h"
-#include "nsISupportsArray.h"
 #include "nsThreadUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 
 nsImapMoveCopyMsgTxn::nsImapMoveCopyMsgTxn() :
     m_idsAreUids(false), m_isMove(false), m_srcIsPop3(false)
 {
 }
--- a/mailnews/import/eudora/src/nsEudoraFilters.cpp
+++ b/mailnews/import/eudora/src/nsEudoraFilters.cpp
@@ -19,17 +19,18 @@
 #include "nsIMsgFilterList.h"
 #include "nsIMsgSearchTerm.h"
 #include "nsIMsgAccountManager.h"
 #include "nsIStringBundle.h"
 #include "mozilla/Services.h"
 #include "nsIMsgfilter.h"
 #include "nsEudoraFilters.h"
 #include "nsEudoraStringBundle.h"
-
+#include "nsIArray.h"
+#include "nsArrayUtils.h"
 #include "nsNetUtil.h"
 #include "nsILineInputStream.h"
 #include "EudoraDebugLog.h"
 
 #if defined(XP_WIN) || defined(XP_OS2)
 #include "nsEudoraWin32.h"
 #endif
 #ifdef XP_MACOSX
@@ -395,22 +396,22 @@ nsresult nsEudoraFilters::LoadServers()
 
   if (!m_pFilterArray)
     rv = NS_NewISupportsArray(getter_AddRefs(m_pFilterArray));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIMsgAccountManager> accountMgr = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsISupportsArray> allServers;
+  nsCOMPtr<nsIArray> allServers;
   rv = accountMgr->GetAllServers(getter_AddRefs(allServers));
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t numServers;
-  rv = allServers->Count(&numServers);
+  rv = allServers->GetLength(&numServers);
   NS_ENSURE_SUCCESS(rv, rv);
   for (uint32_t serverIndex = 0; serverIndex < numServers; serverIndex++)
   {
     nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(allServers, serverIndex, &rv);
     if (server && NS_SUCCEEDED(rv))
     {
       bool canHaveFilters;
       rv = server->GetCanHaveFilters(&canHaveFilters);
--- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp
@@ -41,17 +41,18 @@
 #include "msgMapi.h"
 #include "msgMapiHook.h"
 #include "msgMapiSupport.h"
 #include "msgMapiMain.h"
 #include "nsThreadUtils.h"
 #include "nsMsgUtils.h"
 #include "nsNetUtil.h"
 #include "mozilla/Services.h"
-
+#include "nsIArray.h"
+#include "nsArrayUtils.h"
 #include "nsEmbedCID.h"
 
 extern PRLogModuleInfo *MAPI;
 
 class nsMAPISendListener : public nsIMsgSendListener
 {
 public:
 
--- a/mailnews/news/src/nsNewsDownloader.cpp
+++ b/mailnews/news/src/nsNewsDownloader.cpp
@@ -20,16 +20,18 @@
 #include "nsIRequestObserver.h"
 #include "nsIMsgMailSession.h"
 #include "nsMsgMessageFlags.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMsgUtils.h"
 #include "mozilla/Services.h"
+#include "nsIArray.h"
+#include "nsArrayUtils.h"
 
 // This file contains the news article download state machine.
 
 // if pIds is not null, download the articles whose id's are passed in. Otherwise,
 // which articles to download is determined by nsNewsDownloader object,
 // or subclasses thereof. News can download marked objects, for example.
 nsresult nsNewsDownloader::DownloadArticles(nsIMsgWindow *window, nsIMsgFolder *folder, nsTArray<nsMsgKey> *pIds)
 {
@@ -393,20 +395,28 @@ nsresult nsMsgDownloadAllNewsgroups::Adv
     nsCOMPtr<nsIMsgAccountManager> accountManager =
              do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
     NS_ASSERTION(accountManager && NS_SUCCEEDED(rv), "couldn't get account mgr");
     if (!accountManager || NS_FAILED(rv)) return rv;
 
     rv = accountManager->GetAllServers(getter_AddRefs(m_allServers));
     NS_ENSURE_SUCCESS(rv, rv);
   }
-  uint32_t serverIndex = (m_currentServer) ? m_allServers->IndexOf(m_currentServer) + 1 : 0;
+  uint32_t serverIndex = 0;
+  if (m_currentServer)
+  {
+    rv = m_allServers->IndexOf(0, m_currentServer, &serverIndex);
+    if (NS_FAILED(rv))
+      serverIndex = -1;
+
+    ++serverIndex;
+  }
   m_currentServer = nullptr;
   uint32_t numServers;
-  m_allServers->Count(&numServers);
+  m_allServers->GetLength(&numServers);
   nsCOMPtr <nsIMsgFolder> rootFolder;
 
   while (serverIndex < numServers)
   {
     nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(m_allServers, serverIndex);
     serverIndex++;
 
     nsCOMPtr <nsINntpIncomingServer> newsServer = do_QueryInterface(server);
--- a/mailnews/news/src/nsNewsDownloader.h
+++ b/mailnews/news/src/nsNewsDownloader.h
@@ -108,17 +108,17 @@ protected:
   nsresult AdvanceToNextServer(bool *done);
   nsresult AdvanceToNextGroup(bool *done);
   nsresult DownloadMsgsForCurrentGroup();
 
   DownloadMatchingNewsArticlesToNewsDB *m_downloaderForGroup;
 
   nsCOMPtr <nsIMsgFolder> m_currentFolder;
   nsCOMPtr <nsIMsgWindow> m_window;
-  nsCOMPtr <nsISupportsArray> m_allServers;
+  nsCOMPtr <nsIArray> m_allServers;
   nsCOMPtr <nsISupportsArray> m_allFolders;
   nsCOMPtr <nsIMsgIncomingServer> m_currentServer;
   nsCOMPtr <nsIEnumerator> m_serverEnumerator;
   nsCOMPtr <nsIUrlListener> m_listener;
 
   bool m_downloadedHdrsForCurGroup;
 };
 
--- a/mailnews/news/src/nsNntpService.cpp
+++ b/mailnews/news/src/nsNntpService.cpp
@@ -44,16 +44,17 @@
 #include "nsICacheEntryDescriptor.h"
 #include "nsMsgUtils.h"
 #include "nsNetUtil.h"
 #include "nsIWindowWatcher.h"
 #include "nsICommandLine.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsIMsgMailSession.h"
 #include "nsISupportsPrimitives.h"
+#include "nsArrayUtils.h"
 
 #undef GetPort  // XXX Windows!
 #undef SetPort  // XXX Windows!
 
 #define PREF_MAIL_ROOT_NNTP   "mail.root.nntp"        // old - for backward compatibility only
 #define PREF_MAIL_ROOT_NNTP_REL   "mail.root.nntp-rel"
 
 nsNntpService::nsNntpService()
@@ -621,76 +622,56 @@ nsNntpService::CopyMessages(uint32_t aNu
                             bool moveMessage,
                             nsIUrlListener * aUrlListener,
                             nsIMsgWindow *aMsgWindow,
                             nsIURI **aURL)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-struct findNewsServerEntry {
-  const char *newsgroup;
-  nsINntpIncomingServer *server;
-};
-
-
-bool
-nsNntpService::findNewsServerWithGroup(nsISupports *aElement, void *data)
-{
-  nsresult rv;
-
-  nsCOMPtr<nsINntpIncomingServer> newsserver = do_QueryInterface(aElement, &rv);
-  if (NS_FAILED(rv) || ! newsserver) return true;
-
-  findNewsServerEntry *entry = (findNewsServerEntry*) data;
-
-  bool containsGroup = false;
-  NS_ASSERTION(MsgIsUTF8(nsDependentCString(entry->newsgroup)),
-               "newsgroup is not in UTF-8");
-  rv = newsserver->ContainsNewsgroup(nsDependentCString(entry->newsgroup),
-                                     &containsGroup);
-  if (NS_FAILED(rv)) return true;
-
-  if (containsGroup)
-  {
-    entry->server = newsserver;
-    return false;            // stop on first find
-  }
-  else
-  {
-    return true;
-  }
-}
-
 nsresult
 nsNntpService::FindServerWithNewsgroup(nsCString &host, nsCString &groupName)
 {
   nsresult rv;
 
   nsCOMPtr <nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
-  nsCOMPtr<nsISupportsArray> servers;
 
+  nsCOMPtr<nsIArray> servers;
   rv = accountManager->GetAllServers(getter_AddRefs(servers));
   NS_ENSURE_SUCCESS(rv,rv);
 
-  findNewsServerEntry serverInfo;
-  serverInfo.server = nullptr;
-  serverInfo.newsgroup = groupName.get();
+  NS_ASSERTION(MsgIsUTF8(groupName),
+               "newsgroup is not in UTF-8");
 
   // XXX TODO
   // this only looks at the list of subscribed newsgroups.
   // fix to use the hostinfo.dat information
-  servers->EnumerateForwards(findNewsServerWithGroup, (void *)&serverInfo);
-  if (serverInfo.server)
+
+  uint32_t length;
+  rv = servers->GetLength(&length);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  for (uint32_t i = 0; i < length; ++i)
   {
-    nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(serverInfo.server);
-    rv = server->GetHostName(host);
+    nsCOMPtr<nsINntpIncomingServer> newsserver(do_QueryElementAt(servers, i, &rv));
+    if (NS_FAILED(rv))
+      continue;
+
+    bool containsGroup = false;
+    rv = newsserver->ContainsNewsgroup(groupName,
+                                       &containsGroup);
+    if (containsGroup)
+    {
+      nsCOMPtr<nsIMsgIncomingServer> server(do_QueryInterface(newsserver, &rv));
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      return server->GetHostName(host);
+    }
   }
-
   return rv;
 }
 
 nsresult nsNntpService::FindHostFromGroup(nsCString &host, nsCString &groupName)
 {
   nsresult rv = NS_OK;
   // host always comes in as ""
   NS_ASSERTION(host.IsEmpty(), "host is not empty");
@@ -1008,17 +989,17 @@ nsNntpService::GetServerForUri(nsIURI *a
   // find the incoming server, it if exists.
   // migrate if necessary, before searching for it.
   // if it doesn't exist, create it.
   nsCOMPtr<nsIMsgIncomingServer> server;
 
   // Grab all servers for if this is a no-authority URL. This also loads
   // accounts if they haven't been loaded, i.e., we're running this straight
   // from the command line
-  nsCOMPtr <nsISupportsArray> servers;
+  nsCOMPtr <nsIArray> servers;
   rv = accountManager->GetAllServers(getter_AddRefs(servers));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(aUri, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mailUrl->GetServer(getter_AddRefs(server));
   NS_ENSURE_SUCCESS(rv, rv);
--- a/mailnews/news/src/nsNntpService.h
+++ b/mailnews/news/src/nsNntpService.h
@@ -60,17 +60,16 @@ protected:
   // a convience routine used to put together news urls
   nsresult ConstructNntpUrl(const char * urlString, nsIUrlListener *aUrlListener,  nsIMsgWindow * aMsgWindow, const char *originalMessageUri, int32_t action, nsIURI ** aUrl);
   nsresult CreateNewsAccount(const char *aHostname, bool aIsSecure, int32_t aPort, nsIMsgIncomingServer **aServer);
   nsresult GetServerForUri(nsIURI *aUri, nsINntpIncomingServer **aProtocol);
   // a convience routine to run news urls
   nsresult RunNewsUrl (nsIURI * aUrl, nsIMsgWindow *aMsgWindow, nsISupports * aConsumer);
   // a convience routine to go from folder uri to msg folder
   nsresult GetFolderFromUri(const char *uri, nsIMsgFolder **folder);
-  static bool findNewsServerWithGroup(nsISupports *aElement, void *data);
   nsresult DecomposeNewsMessageURI(const char * aMessageURI, nsIMsgFolder ** aFolder, nsMsgKey *aMsgKey);
 
   bool              mPrintingOperation; // Flag for printing operations
   bool        mOpenAttachmentOperation; // Flag for opening attachments
 
   nsCOMPtr<nsICacheSession> mCacheSession; // the cache session used by news
 };
 
--- a/suite/mailnews/mail3PaneWindowCommands.js
+++ b/suite/mailnews/mail3PaneWindowCommands.js
@@ -1087,19 +1087,20 @@ function CanRenameDeleteJunkMail(aFolder
   if (!aFolderUri)
     return false;
 
   // Go through junk mail settings for all servers and see if the folder is set/used by anyone.
   try
   {
     var allServers = accountManager.allServers;
 
-    for (var i=0;i<allServers.Count();i++)
+    for (var i = 0; i < allServers.length; i++)
     {
-      var currentServer = allServers.GetElementAt(i).QueryInterface(Components.interfaces.nsIMsgIncomingServer);
+      var currentServer =
+        allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
       var settings = currentServer.spamSettings;
       // If junk mail control or move junk mail to folder option is disabled then
       // allow the folder to be removed/renamed since the folder is not used in this case.
       if (!settings.level || !settings.moveOnSpam)
         continue;
       if (settings.spamFolderURI == aFolderUri)
         return false;
     }
--- a/suite/mailnews/mailContextMenus.js
+++ b/suite/mailnews/mailContextMenus.js
@@ -524,22 +524,22 @@ function OpenMessageForMessageId(message
   if (!messageHeader)
   {
     var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"]
                                    .getService(Components.interfaces.nsIMsgAccountManager);
     var allServers = accountManager.allServers;
 
     messageHeader = SearchForMessageIdInSubFolder(startServer.rootFolder, messageId);
 
-    for (var i = 0; i < allServers.Count() && !messageHeader; i++)
+    for (var i = 0; i < allServers.length && !messageHeader; i++)
     {
-      var currentServer = allServers.GetElementAt(i);
-      if ((currentServer instanceof Components.interfaces.nsIMsgIncomingServer) &&
-          startServer != currentServer && currentServer.canSearchMessages &&
-          !currentServer.isDeferredTo)
+      var currentServer =
+        allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
+      if (currentServer && startServer != currentServer &&
+          currentServer.canSearchMessages && !currentServer.isDeferredTo)
       {
         messageHeader = SearchForMessageIdInSubFolder(currentServer.rootFolder, messageId);
       }
     }
   }
   window.setCursor("auto");
 
   // if message id was found open corresponding message
--- a/suite/mailnews/mailTasksOverlay.js
+++ b/suite/mailnews/mailTasksOverlay.js
@@ -64,20 +64,20 @@ function MailTasksGetMessagesForAllServe
     var allServers = Components.classes["@mozilla.org/messenger/account-manager;1"]
                                .getService(Components.interfaces.nsIMsgAccountManager)
                                .allServers;
     // array of ISupportsArrays 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.Count(); ++i)
+    for (let i = 0; i < allServers.length; ++i)
     {
-      let currentServer = allServers.GetElementAt(i);
-      if (currentServer instanceof Components.interfaces.nsIMsgIncomingServer)
+      let currentServer = allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
+      if (currentServer)
       {
         let protocolinfo = Components.classes["@mozilla.org/messenger/protocol/info;1?type=" + currentServer.type]
                                      .getService(Components.interfaces.nsIMsgProtocolInfo);
         if (aBiff)
         {
           if (protocolinfo.canLoginAtStartUp && currentServer.loginAtStartUp)
           {
             if (aDefaultServer &&
--- a/suite/mailnews/search/FilterListDialog.js
+++ b/suite/mailnews/search/FilterListDialog.js
@@ -577,22 +577,22 @@ function getServerThatCanHaveFilters()
     if (defaultIncomingServer.canHaveFilters) {
         firstItem = defaultIncomingServer.serverURI;
     }
     // if it cannot, check all accounts to find a server
     // that can have filters
     else
     {
         var allServers = accountManager.allServers;
-        var numServers = allServers.Count();
+        var numServers = allServers.length;
         var index = 0;
         for (index = 0; index < numServers; index++)
         {
-            var currentServer
-            = allServers.GetElementAt(index).QueryInterface(Components.interfaces.nsIMsgIncomingServer);
+            var currentServer =
+              allServers.queryElementAt(index, Components.interfaces.nsIMsgIncomingServer);
 
             if (currentServer.canHaveFilters)
             {
                 firstItem = currentServer.serverURI;
                 break;
             }
         }
     }