Backed out 4 changesets (bug 436089) for test failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 06 Feb 2013 09:33:31 -0500
changeset 14808 c003d9d1a5eb38029181b154402261c09ed7020a
parent 14807 529e61d1d355ad4ed6487d5243f90fadddc15729
child 14809 bca970870c77ab5decff1fcebc37e3cd85c051f7
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs436089
Backed out 4 changesets (bug 436089) for test failures.
mail/base/modules/MailUtils.js
mail/components/im/imIncomingServer.js
mail/components/search/content/searchCommon.js
mail/test/mozmill/folder-tree-modes/test-smart-folders.js
mailnews/base/content/newmailalert.js
mailnews/base/content/virtualFolderListDialog.js
mailnews/base/prefs/content/am-offline.js
mailnews/base/public/nsIMsgFolder.idl
mailnews/base/src/newMailNotificationService.js
mailnews/base/src/nsMessengerOSXIntegration.mm
mailnews/base/src/nsMessengerUnixIntegration.cpp
mailnews/base/src/nsMessengerWinIntegration.cpp
mailnews/base/src/nsMsgAccountManager.cpp
mailnews/base/src/nsMsgFolderDataSource.cpp
mailnews/base/src/nsMsgPurgeService.cpp
mailnews/base/util/nsMsgDBFolder.cpp
mailnews/db/gloda/modules/gloda.js
mailnews/db/gloda/modules/index_msg.js
mailnews/db/gloda/test/unit/base_index_messages.js
mailnews/extensions/newsblog/js/newsblog.js
mailnews/imap/src/nsAutoSyncManager.cpp
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/imap/src/nsImapOfflineSync.cpp
mailnews/imap/src/nsImapOfflineSync.h
mailnews/local/src/nsLocalMailFolder.cpp
mailnews/local/src/nsRssIncomingServer.cpp
mailnews/news/src/nsNewsDownloader.cpp
mailnews/news/src/nsNewsDownloader.h
--- a/mail/base/modules/MailUtils.js
+++ b/mail/base/modules/MailUtils.js
@@ -324,20 +324,22 @@ var MailUtils =
    *     managed to set the values on all folders, false means we encountered a
    *     problem.
    */
   setStringPropertyOnFolderAndDescendents:
       function MailUtils_setStringPropertyOnFolderAndDescendents(aPropertyName,
                                                                  aPropertyValue,
                                                                  aFolder,
                                                                  aCallback) {
-    // We need to add the base folder as it does not get added by ListDescendants.
-    let allFolders = toXPCOMArray(aFolder, Ci.nsIMutableArray);
-    // - get all the descendants
-    aFolder.ListDescendants(allFolders);
+    // - get all the descendents
+    let allFolders = Cc["@mozilla.org/supports-array;1"].
+                       createInstance(Ci.nsISupportsArray);
+    // we need to add the base folder; it does not get added by ListDescendents
+    allFolders.AppendElement(aFolder);
+    aFolder.ListDescendents(allFolders);
 
     // - worker function
     function folder_string_setter_worker() {
       for each (let folder in fixIterator(allFolders, Ci.nsIMsgFolder)) {
         // skip folders that can't hold messages, no point setting things there.
         if (!folder.canFileMessages)
           continue;
 
--- a/mail/components/im/imIncomingServer.js
+++ b/mail/components/im/imIncomingServer.js
@@ -229,23 +229,21 @@ imIncomingServer.prototype = {
       server: this,
       get prettyName() this.server.prettyName, // used in the account manager tree
       get prettiestName() this.server.prettyName + " prettiestName", // never displayed?
       get name() this.server.prettyName + " name", // never displayed?
       // used in the folder pane tree, if we don't hide the IM accounts:
       get abbreviatedName() this.server.prettyName + "abbreviatedName",
       AddFolderListener: function() {},
       RemoveFolderListener: function() {},
-      descendants: Components.classes["@mozilla.org/array;1"]
-                  .createInstance(Components.interfaces.nsIArray),
-      ListDescendants: function(descendants) {},
+      ListDescendents: function(descendents) {},
       getFolderWithFlags: function(aFlags) null,
       getFoldersWithFlags: function(aFlags)
         Components.classes["@mozilla.org/array;1"]
-                  .createInstance(Components.interfaces.nsIArray),
+                  .createInstance(Components.interfaces.nsIMutableArray),
       get subFolders() EmptyEnumerator,
       getStringProperty: function(aPropertyName) "",
       getNumUnread: function(aDeep) 0,
       Shutdown: function() {},
       QueryInterface: XPCOMUtils.generateQI([Ci.nsIMsgFolder])
     });
   },
 
--- a/mail/components/search/content/searchCommon.js
+++ b/mail/components/search/content/searchCommon.js
@@ -313,18 +313,21 @@ let SearchSupport =
     let servers = accountManager.allServers;
 
     // Stores whether we're after the last folder indexed or before that --
     // if the last folder indexed is empty, this needs to be true initially
     let afterLastFolderIndexed = (this._lastFolderIndexedUri.length == 0);
 
     for each (var server in fixIterator(servers, Ci.nsIMsgIncomingServer))
     {
-      let allFolders = server.rootFolder.descendants;
-      let numFolders = allFolders.length;
+      let rootFolder = server.rootFolder;
+      let allFolders = Cc["@mozilla.org/supports-array;1"]
+                         .createInstance(Ci.nsISupportsArray);
+      rootFolder.ListDescendents(allFolders);
+      let numFolders = allFolders.Count();
       this._log.debug("in find next folder, lastFolderIndexedUri = " +
                       this._lastFolderIndexedUri);
 
       for each (var folder in fixIterator(allFolders, Ci.nsIMsgFolder))
       {
         let searchPath = this._getSearchPathForFolder(folder);
         searchPath.leafName = searchPath.leafName + ".mozmsgs";
         // If after the last folder indexed, definitely index this
--- a/mail/test/mozmill/folder-tree-modes/test-smart-folders.js
+++ b/mail/test/mozmill/folder-tree-modes/test-smart-folders.js
@@ -179,47 +179,53 @@ function test_folder_flag_changes() {
   archiveFolder.clearFlag(nsMsgFolderFlags.Archive);
 
   // Refresh the archive scope because clearing the flag should have
   // changed it.
   archiveScope = "|" + smartArchiveFolder.msgDatabase.dBFolderInfo
                  .getCharProperty("searchFolderUri") + "|";
 
   // figure out what we expect the archiveScope to now be.
+  let allDescendents = Cc["@mozilla.org/supports-array;1"]
+                         .createInstance(Ci.nsISupportsArray);
   rootFolder = inboxFolder.server.rootFolder;
   let localArchiveFolder = rootFolder.getChildNamed("Archives");
-  let allDescendants = localArchiveFolder.descendants;
+  localArchiveFolder.ListDescendents(allDescendents);
+  let numFolders = allDescendents.Count();
   desiredScope = "|" + localArchiveFolder.URI + "|";
-  for (let folder in fixIterator(allDescendants, Ci.nsIMsgFolder)) {
-    desiredScope += folder.URI + "|";
-  }
+  for each (let f in fixIterator(allDescendents, Ci.nsIMsgFolder))
+    desiredScope += f.URI + "|";
 
   if (archiveScope != desiredScope)
     throw "archive scope wrong after removing folder";
   assert_folder_and_children_not_in_scope(archiveFolder, archiveScope);
 }
 
 function assert_folder_and_children_in_scope(folder, searchScope)
 {
   let folderURI = "|" + folder.URI + "|";
   assert_uri_found(folderURI, searchScope);
-  let allDescendants = folder.descendants;
-  for (let folder in fixIterator(allDescendants, Ci.nsIMsgFolder)) {
-    assert_uri_found(folder.URI, searchScope);
-  }
+  let allDescendents = Cc["@mozilla.org/supports-array;1"]
+                         .createInstance(Ci.nsISupportsArray);
+  folder.ListDescendents(allDescendents);
+  let numFolders = allDescendents.Count();
+  for each (let f in fixIterator(allDescendents, Ci.nsIMsgFolder))
+    assert_uri_found(f.URI, searchScope)
 }
 
 function assert_folder_and_children_not_in_scope(folder, searchScope)
 {
   let folderURI = "|" + folder.URI + "|";
   assert_uri_not_found(folderURI, searchScope);
-  let allDescendants = folder.descendants;
-  for (let folder in fixIterator(allDescendants, Ci.nsIMsgFolder)) {
-    assert_uri_not_found(folder.URI, searchScope);
-  }
+  let allDescendents = Cc["@mozilla.org/supports-array;1"]
+                     .createInstance(Ci.nsISupportsArray);
+  folder.ListDescendents(allDescendents);
+  let numFolders = allDescendents.Count();
+  for each (let f in fixIterator(allDescendents, Ci.nsIMsgFolder))
+    assert_uri_not_found(f.URI, searchScope)
 }
 
 function assert_uri_found(folderURI, scopeList)
 {
   if (scopeList.indexOf(folderURI) == -1)
     throw new Error("scope " + scopeList + "doesn't contain " + folderURI);
 }
 
--- a/mailnews/base/content/newmailalert.js
+++ b/mailnews/base/content/newmailalert.js
@@ -1,14 +1,13 @@
 /* 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/. */
 
 Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource:///modules/iteratorUtils.jsm");
 
 // Copied from nsILookAndFeel.h, see comments on eMetric_AlertNotificationOrigin
 const NS_ALERT_HORIZONTAL = 1;
 const NS_ALERT_LEFT = 2;
 const NS_ALERT_TOP = 4;
 
 var gNumNewMsgsToShowInAlert = 4; // the more messages we show in the alert, the larger it will be
 var gOpenTime = 4000; // total time the alert should stay up once we are done animating.
@@ -47,21 +46,26 @@ function prefillAlertInfo()
   var message = totalNumNewMessages == 1 ? "newMailNotification_message"
                                          : "newMailNotification_messages";
   label.value = document.getElementById('bundle_messenger')
                         .getFormattedString(message,
                                             [rootFolder.prettiestName, totalNumNewMessages]);
 
   // This is really the root folder and we have to walk through the list to
   // find the real folder that has new mail in it...:(
-  let allFolders = rootFolder.descendants;
+  var allFolders = Components.classes["@mozilla.org/supports-array;1"]
+                             .createInstance(Components.interfaces.nsISupportsArray);
+  rootFolder.ListDescendents(allFolders);
+  var numFolders = allFolders.Count();
   var folderSummaryInfoEl = document.getElementById('folderSummaryInfo');
   folderSummaryInfoEl.mMaxMsgHdrsInPopup = gNumNewMsgsToShowInAlert;
-  for (let folder in fixIterator(allFolders, Components.interfaces.nsIMsgFolder))
+  for (let folderIndex = 0; folderIndex < numFolders; folderIndex++)
   {
+    var folder = allFolders.GetElementAt(folderIndex)
+                           .QueryInterface(Components.interfaces.nsIMsgFolder);
     const nsMsgFolderFlags = Components.interfaces.nsMsgFolderFlags;
     if (folder.hasNewMessages && !(folder.flags & nsMsgFolderFlags.Virtual))
     {
       var asyncFetch = {};
       folderSummaryInfoEl.parseFolder(folder, new urlListener(folder), asyncFetch);
       if (asyncFetch.value)
         gPendingPreviewFetchRequests++;
     }
--- a/mailnews/base/content/virtualFolderListDialog.js
+++ b/mailnews/base/content/virtualFolderListDialog.js
@@ -1,15 +1,14 @@
 /* -*- Mode: Java; 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/. */
 
 Components.utils.import("resource:///modules/mailServices.js");
-Components.utils.import("resource:///modules/iteratorUtils.jsm");
 
 var gFolderPickerTree = null;
 
 function onLoad()
 {
   gFolderPickerTree = document.getElementById("folderPickerTree");
 
   if (window.arguments[0].searchFolderURIs)
@@ -58,31 +57,59 @@ function processSearchSettingForFolder(a
   
   aFolder.setInVFEditSearchScope(false, false);
   return aCurrentSearchURIString;
 }
 
 // warning: this routine also clears out the search property list from all of the msg folders
 function generateFoldersToSearchList()
 {
-  let uriSearchString = "";
-  let allFolders = MailServices.accounts.allFolders;
-  for (let folder in fixIterator(allFolders, Components.interfaces.nsIMsgFolder))
-    uriSearchString = processSearchSettingForFolder(folder, uriSearchString);
+  var uriSearchString = "";
+
+  var allServers = MailServices.accounts.allServers;
+  var numServers = allServers.length;
+  for (var index = 0; index < numServers; index++)
+  {
+    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);
+    }
+  } // for each account
 
   return uriSearchString;
 }
 
 function resetFolderToSearchAttribute()
 {
   // iterates over all accounts and all folders, clearing out the inVFEditScope property in case
   // we set it.
-  let allFolders = MailServices.accounts.allFolders;
-  for (let folder in fixIterator(allFolders, Components.interfaces.nsIMsgFolder))
-    folder.setInVFEditSearchScope(false, false);
+  var allServers = MailServices.accounts.allServers;
+  var numServers = allServers.length;
+  for (var index = 0; index < numServers; index++)
+  {
+    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);
+    }
+  } // for each account
 }
 
 function ReverseStateFromNode(row)
 {
   var folder = GetFolderResource(row).QueryInterface(Components.interfaces.nsIMsgFolder);
   var currentState = folder.inVFEditSearchScope;
 
   folder.setInVFEditSearchScope(!currentState, false);
--- a/mailnews/base/prefs/content/am-offline.js
+++ b/mailnews/base/prefs/content/am-offline.js
@@ -1,15 +1,13 @@
 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * 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/. */
 
-Components.utils.import("resource:///modules/iteratorUtils.jsm");
-
 var gIncomingServer;
 var gServerType;
 var gImapIncomingServer;
 var gPref = null;
 var gLockedPref = null;
 var gOfflineMap = null; // map of folder URLs to offline flags
 
 function onInit(aPageId, aServerId) 
@@ -297,38 +295,63 @@ function onCheckItem(changeElementId, ch
     }
     else {
         element.setAttribute("disabled", "true");
     }
 }
 
 function toggleOffline()
 {
-    let offline = document.getElementById("offline.folders").checked;
-    let allFolders = gIncomingServer.rootFolder.descendants;
-    for (let folder in fixIterator(allFolders, Components.interfaces.nsIMsgFolder)) {
+    var offline = document.getElementById("offline.folders").checked;
+    var rootFolder = gIncomingServer.rootFolder;
+    var allFolders = Components.classes["@mozilla.org/supports-array;1"]
+                               .createInstance(Components.interfaces.nsISupportsArray);
+    rootFolder.ListDescendents(allFolders);
+    var numFolders = allFolders.Count();
+    var folder;
+    for (var folderIndex = 0; folderIndex < numFolders; folderIndex++)
+    {
+      folder = allFolders.QueryElementAt(folderIndex,
+                                         Components.interfaces.nsIMsgFolder);
       if (offline)
         folder.setFlag(Components.interfaces.nsMsgFolderFlags.Offline);
       else
         folder.clearFlag(Components.interfaces.nsMsgFolderFlags.Offline);
     }
+    
 }
 
 function collectOfflineFolders()
 {
-    let offlineFolderMap = {};
-    let allFolders = gIncomingServer.rootFolder.descendants;
-    for (let folder in fixIterator(allFolders, Components.interfaces.nsIMsgFolder))
+    var offlineFolderMap = {};
+    var rootFolder = gIncomingServer.rootFolder;
+    var allFolders = Components.classes["@mozilla.org/supports-array;1"]
+                               .createInstance(Components.interfaces.nsISupportsArray);
+    rootFolder.ListDescendents(allFolders);
+    var numFolders = allFolders.Count();
+    var folder;
+    for (var folderIndex = 0; folderIndex < numFolders; folderIndex++)
+    {
+      folder = allFolders.QueryElementAt(folderIndex,
+                                         Components.interfaces.nsIMsgFolder);
       offlineFolderMap[folder.folderURL] = folder.getFlag(Components.interfaces.nsMsgFolderFlags.Offline);
-
+    }
     return offlineFolderMap;
 }
 
 function restoreOfflineFolders(offlineFolderMap)
 {
-    let allFolders = gIncomingServer.rootFolder.descendants;
-    for (let folder in fixIterator(allFolders, Components.interfaces.nsIMsgFolder)) {
+    var rootFolder = gIncomingServer.rootFolder;
+    var allFolders = Components.classes["@mozilla.org/supports-array;1"]
+                               .createInstance(Components.interfaces.nsISupportsArray);
+    rootFolder.ListDescendents(allFolders);
+    var numFolders = allFolders.Count();
+    var folder;
+    for (var folderIndex = 0; folderIndex < numFolders; folderIndex++)
+    {
+      folder = allFolders.QueryElementAt(folderIndex,
+                                         Components.interfaces.nsIMsgFolder);
       if (offlineFolderMap[folder.folderURL])
         folder.setFlag(Components.interfaces.nsMsgFolderFlags.Offline);
       else
         folder.clearFlag(Components.interfaces.nsMsgFolderFlags.Offline);
     }
 }
--- a/mailnews/base/public/nsIMsgFolder.idl
+++ b/mailnews/base/public/nsIMsgFolder.idl
@@ -28,17 +28,17 @@ interface nsIArray;
 interface nsIMutableArray;
 interface nsISupportsArray;
 interface nsIMsgPluggableStore;
 
 typedef long nsMsgBiffState;
 
 // enumerated type for determining if a message has been replied to, forwarded, etc.
 typedef long nsMsgDispositionState;
-[scriptable, uuid(bc4c8fff-0352-4e28-abda-db7f86a9e5f7)]
+[scriptable, uuid(bc4c8fff-0352-4e28-abda-db7f86a9e5f6)]
 interface nsIMsgFolder : nsISupports {
 
   const nsMsgBiffState nsMsgBiffState_NewMail = 0; // User has new mail waiting.
   const nsMsgBiffState nsMsgBiffState_NoMail =  1; // No new mail is waiting.
   const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is new mail.
 
   /// Returns an enumerator containing the messages within the current database.
   readonly attribute nsISimpleEnumerator messages;
@@ -682,25 +682,18 @@ interface nsIMsgFolder : nsISupports {
   void NotifyItemAdded(in nsISupports item);
   void NotifyItemRemoved(in nsISupports item);
 
   void NotifyFolderEvent(in nsIAtom event);
 
   //  void NotifyFolderLoaded();
   //  void NotifyDeleteOrMoveMessagesCompleted(in nsIMsgFolder folder);
 
-  // Gets all descendants, not just first level children.
-  readonly attribute nsIArray descendants;
-  /*
-   * Lists all the folders that are subfolders of the current folder,
-   * all levels of children.
-   *
-   * @param aDescendants  The array in which to append the found folder(s).
-   */
-  void ListDescendants(in nsIMutableArray aDescendants);
+  // lists all descendents, not just first level children
+  void ListDescendents(in nsISupportsArray descendents);
   void Shutdown(in boolean shutdownChildren);
 
   readonly attribute boolean inVFEditSearchScope;
   void setInVFEditSearchScope(in boolean aSearchThisFolder, in boolean aSetOnSubFolders);
   void copyDataToOutputStreamForAppend(in nsIInputStream aIStream,
                      in long aLength, in nsIOutputStream outputStream);
   void copyDataDone();
   void setJunkScoreForMessages(in nsIArray aMessages, in ACString aJunkScore);
--- a/mailnews/base/src/newMailNotificationService.js
+++ b/mailnews/base/src/newMailNotificationService.js
@@ -15,17 +15,16 @@
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource:///modules/mailServices.js");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource:///modules/gloda/log4moz.js");
-Cu.import("resource:///modules/iteratorUtils.jsm");
 
 const NMNS = Ci.mozINewMailNotificationService;
 
 const countInboxesPref = "mail.notification.count.inbox_only";
 // Old name for pref
 const countNewMessagesPref = "mail.biff.use_new_count_in_mac_dock";
 // When we go cross-platform we should migrate to
 // const countNewMessagesPref = "mail.notification.count.new";
@@ -126,31 +125,37 @@ NewMailNotificationService.prototype = {
     if (!this.countNew) {
       this._log.info("NMNS_initUnread notifying listeners: " + total + " total unread messages");
       this._notifyListeners(NMNS.count, "onCountChanged", total);
     }
   },
 
   // Count all the unread messages below the given folder
   _countUnread: function NMNS_countUnread(folder) {
+    let allFolders = Cc["@mozilla.org/supports-array;1"]
+                       .createInstance(Ci.nsISupportsArray);
+
     this._log.trace("NMNS_countUnread: parent folder " + folder.URI);
     let unreadCount = 0;
 
     if (this.confirmShouldCount(folder)) {
       let count = folder.getNumUnread(false);
       this._log.debug("NMNS_countUnread: folder " + folder.URI + ", " + count + " unread");
       if (count > 0)
         unreadCount += count;
     }
 
-    let allFolders = folder.descendants;
-    for (let folder in fixIterator(allFolders, Ci.nsIMsgFolder)) {
-      if (this.confirmShouldCount(folder)) {
-        let count = folder.getNumUnread(false);
-        this._log.debug("NMNS_countUnread: folder " + folder.URI + ", " + count + " unread");
+    folder.ListDescendents(allFolders);
+    let numFolders = allFolders.Count();
+
+    for (let i = 0; i < numFolders; i++) {
+      let fold = allFolders.QueryElementAt(i, Ci.nsIMsgFolder);
+      if (this.confirmShouldCount(fold)) {
+        let count = fold.getNumUnread(false);
+        this._log.debug("NMNS_countUnread: folder " + fold.URI + ", " + count + " unread");
         if (count > 0)
           unreadCount += count;
       }
     }
     return unreadCount;
   },
 
   // Filter out special folders and then ask for observers to see if
@@ -217,33 +222,36 @@ NewMailNotificationService.prototype = {
       if (folder.server && !folder.server.performingBiff) {
         this._log.debug("NMNS_biffStateChanged: folder " + folder.URI + " notified, but server not performing biff");
         return;
       }
 
       // Biff notifications come in for the top level of the server, we need to look for
       // the folder that actually contains the new mail
 
-      let allFolders = folder.descendants;
-      let numFolders = allFolders.length;
+      let allFolders = Cc["@mozilla.org/supports-array;1"]
+                         .createInstance(Ci.nsISupportsArray);
+      folder.ListDescendents(allFolders);
+      let numFolders = allFolders.Count();
 
       this._log.trace("NMNS_biffStateChanged: folder " + folder.URI + " New mail, " + numFolders + " subfolders");
       let newCount = 0;
 
       if (this.confirmShouldCount(folder)) {
         let folderNew = folder.getNumNewMessages(false);
         this._log.debug("NMNS_biffStateChanged: folder " + folder.URI + " new messages: " + folderNew);
         if (folderNew > 0)
           newCount += folderNew;
       }
 
-      for (let folder in fixIterator(allFolders, Ci.nsIMsgFolder)) {
-        if (this.confirmShouldCount(folder)) {
-          let folderNew = folder.getNumNewMessages(false);
-          this._log.debug("NMNS_biffStateChanged: folder " + folder.URI + " new messages: " + folderNew);
+      for (let i = 0; i < numFolders; i++) {
+        let fold = allFolders.QueryElementAt(i, Ci.nsIMsgFolder);
+        if (this.confirmShouldCount(fold)) {
+          let folderNew = fold.getNumNewMessages(false);
+          this._log.debug("NMNS_biffStateChanged: folder " + fold.URI + " new messages: " + folderNew);
           if (folderNew > 0)
             newCount += folderNew;
         }
       }
       if (newCount > 0) {
         this._mNewCount += newCount;
         this._log.debug("NMNS_biffStateChanged: " + folder.URI + " New mail count " + this._mNewCount);
         if (this.countNew)
--- a/mailnews/base/src/nsMessengerOSXIntegration.mm
+++ b/mailnews/base/src/nsMessengerOSXIntegration.mm
@@ -1,16 +1,15 @@
 /* -*- 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/. */
 
 #include "nscore.h"
 #include "nsMsgUtils.h"
-#include "nsArrayUtils.h"
 #include "nsMessengerOSXIntegration.h"
 #include "nsIMsgMailSession.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsIMsgIdentity.h"
 #include "nsIMsgAccount.h"
 #include "nsIMsgFolder.h"
 #include "nsCOMPtr.h"
 #include "nsMsgBaseCID.h"
@@ -705,39 +704,41 @@ nsMessengerOSXIntegration::GetNewMailAut
 nsresult
 nsMessengerOSXIntegration::GetFirstFolderWithNewMail(nsIMsgFolder* aFolder, nsCString& aFolderURI)
 {
   // Find the subfolder in aFolder with new mail and return the folderURI
   if (aFolder)
   {
     nsCOMPtr<nsIMsgFolder> msgFolder;
     // enumerate over the folders under this root folder till we find one with new mail....
-    nsCOMPtr<nsIArray> allFolders;
-    nsresult rv = aFolder->GetDescendants(getter_AddRefs(allFolders));
+    nsCOMPtr<nsISupportsArray> allFolders;
+    NS_NewISupportsArray(getter_AddRefs(allFolders));
+    nsresult rv = aFolder->ListDescendents(allFolders);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCOMPtr<nsISimpleEnumerator> enumerator;
-    rv = allFolders->Enumerate(getter_AddRefs(enumerator));
-    if (NS_SUCCEEDED(rv) && enumerator)
+    nsCOMPtr<nsIEnumerator> enumerator;
+    allFolders->Enumerate(getter_AddRefs(enumerator));
+    if (enumerator)
     {
       nsCOMPtr<nsISupports> supports;
       int32_t numNewMessages = 0;
-      bool hasMore = false;
-      while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore)
+      nsresult more = enumerator->First();
+      while (NS_SUCCEEDED(more))
       {
-        rv = enumerator->GetNext(getter_AddRefs(supports));
-        if (NS_SUCCEEDED(rv) && supports)
+        rv = enumerator->CurrentItem(getter_AddRefs(supports));
+        if (supports)
         {
           msgFolder = do_QueryInterface(supports, &rv);
           if (msgFolder)
           {
             numNewMessages = 0;
             msgFolder->GetNumNewMessages(false, &numNewMessages);
             if (numNewMessages)
               break; // kick out of the while loop
+            more = enumerator->Next();
           }
         } // if we have a folder
       }  // if we have more potential folders to enumerate
     }  // if enumerator
 
     if (msgFolder)
       msgFolder->GetURI(aFolderURI);
   }
--- a/mailnews/base/src/nsMessengerUnixIntegration.cpp
+++ b/mailnews/base/src/nsMessengerUnixIntegration.cpp
@@ -43,17 +43,16 @@
 #include "nsIWeakReferenceUtils.h"
 
 #include "nsNativeCharsetUtils.h"
 #include "nsToolkitCompsCID.h"
 #include "nsMsgUtils.h"
 #include "msgCore.h"
 #include "nsCOMArray.h"
 #include "nsIMutableArray.h"
-#include "nsArrayUtils.h"
 #include "nsMemory.h"
 #include "mozilla/Services.h"
 
 #define ALERT_CHROME_URL "chrome://messenger/content/newmailalert.xul"
 #define NEW_MAIL_ALERT_ICON "chrome://messenger/skin/icons/new-mail-alert.png"
 #define SHOW_ALERT_PREF "mail.biff.show_alert"
 #define SHOW_ALERT_PREVIEW_LENGTH "mail.biff.alert.preview_length"
 #define SHOW_ALERT_PREVIEW_LENGTH_DEFAULT 40
@@ -232,21 +231,21 @@ nsMessengerUnixIntegration::BuildNotific
     return false;
 
   nsCString msgURI;
   folder->GetUriForMsg(aHdr, msgURI);
 
   bool localOnly;
 
   uint32_t msgURIIndex = mFetchingURIs.IndexOf(msgURI);
-  if (msgURIIndex == mFetchingURIs.NoIndex)
+  if (msgURIIndex == -1)
   {
     localOnly = false;
     mFetchingURIs.AppendElement(msgURI);
-  }
+  } 
   else
     localOnly = true;
 
   uint32_t messageKey;
   if (NS_FAILED(aHdr->GetMessageKey(&messageKey)))
     return false;
 
   bool asyncResult = false;
@@ -256,17 +255,17 @@ nsMessengerUnixIntegration::BuildNotific
   // If we're still waiting on getting the message previews,
   // bail early.  We'll come back later when the async operation
   // finishes.
   if (NS_FAILED(rv) || asyncResult)
     return false;
 
   // If we got here, that means that we've retrieved the message preview,
   // so we can stop tracking it with our mFetchingURIs array.
-  if (msgURIIndex != mFetchingURIs.NoIndex)
+  if (msgURIIndex != -1)
     mFetchingURIs.RemoveElementAt(msgURIIndex);
 
   nsCString utf8previewString;
   if (showPreview &&
       NS_FAILED(aHdr->GetStringProperty("preview", getter_Copies(utf8previewString))))
     return false;
 
   // need listener that mailbox is remote such as IMAP
@@ -595,22 +594,23 @@ nsresult nsMessengerUnixIntegration::Get
     rv = GetMRUTimestampForFolder(folder, &lastMRUTime);
     if (NS_FAILED(rv))
       lastMRUTime = 0;
 
     if (!folder)
       continue;
     // enumerate over the folders under this root folder till we find one with new mail....
     nsCOMPtr<nsIMsgFolder> msgFolder;
-    nsCOMPtr<nsIArray> allFolders;
-    rv = folder->GetDescendants(getter_AddRefs(allFolders));
+    nsCOMPtr<nsISupportsArray> allFolders;
+    NS_NewISupportsArray(getter_AddRefs(allFolders));
+    rv = folder->ListDescendents(allFolders);
     NS_ENSURE_SUCCESS(rv, rv);
 
     uint32_t subfolderCount = 0;
-    allFolders->GetLength(&subfolderCount);
+    allFolders->Count(&subfolderCount);
     uint32_t j;
     for (j = 0; j < subfolderCount; j++)
     {
       nsCOMPtr<nsIMsgFolder> msgFolder = do_QueryElementAt(allFolders, j);
 
       if (!msgFolder)
         continue;
 
--- a/mailnews/base/src/nsMessengerWinIntegration.cpp
+++ b/mailnews/base/src/nsMessengerWinIntegration.cpp
@@ -777,38 +777,40 @@ nsresult nsMessengerWinIntegration::GetF
 
   weakReference = do_QueryElementAt(mFoldersWithNewMail, 0);
   folder = do_QueryReferent(weakReference);
 
   if (folder)
   {
     nsCOMPtr<nsIMsgFolder> msgFolder;
     // enumerate over the folders under this root folder till we find one with new mail....
-    nsCOMPtr<nsIArray> allFolders;
-    rv = folder->GetDescendants(getter_AddRefs(allFolders));
+    nsCOMPtr<nsISupportsArray> allFolders;
+    NS_NewISupportsArray(getter_AddRefs(allFolders));
+    rv = folder->ListDescendents(allFolders);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCOMPtr<nsISimpleEnumerator> enumerator;
-    rv = allFolders->Enumerate(getter_AddRefs(enumerator));
-    if (NS_SUCCEEDED(rv) && enumerator)
+    nsCOMPtr<nsIEnumerator> enumerator;
+    allFolders->Enumerate(getter_AddRefs(enumerator));
+    if (enumerator)
     {
       nsCOMPtr<nsISupports> supports;
-      bool hasMore = false;
-      while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore)
+      nsresult more = enumerator->First();
+      while (NS_SUCCEEDED(more))
       {
-        rv = enumerator->GetNext(getter_AddRefs(supports));
-        if (NS_SUCCEEDED(rv) && supports)
+        rv = enumerator->CurrentItem(getter_AddRefs(supports));
+        if (supports)
         {
           msgFolder = do_QueryInterface(supports, &rv);
           if (msgFolder)
           {
             numNewMessages = 0;
             msgFolder->GetNumNewMessages(false, &numNewMessages);
             if (numNewMessages)
               break; // kick out of the while loop
+            more = enumerator->Next();
           }
         } // if we have a folder
       }  // if we have more potential folders to enumerate
     }  // if enumerator
 
     if (msgFolder)
       msgFolder->GetURI(aFolderURI);
   }
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -526,36 +526,38 @@ nsMsgAccountManager::RemoveIncomingServe
 
   // invalidate the FindServer() cache if we are removing the cached server
   if (m_lastFindServerResult == aServer)
     SetLastServerFound(nullptr, EmptyCString(), EmptyCString(), 0, EmptyCString());
 
   m_incomingServers.Remove(serverKey);
 
   nsCOMPtr<nsIMsgFolder> rootFolder;
-  nsCOMPtr<nsIArray> allDescendants;
+  nsCOMPtr<nsISupportsArray> allDescendents;
 
   rv = aServer->GetRootFolder(getter_AddRefs(rootFolder));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = rootFolder->GetDescendants(getter_AddRefs(allDescendants));
+  rv = NS_NewISupportsArray(getter_AddRefs(allDescendents));
   NS_ENSURE_SUCCESS(rv, rv);
 
+  rootFolder->ListDescendents(allDescendents);
+
   uint32_t cnt = 0;
-  rv = allDescendants->GetLength(&cnt);
+  rv = allDescendents->Count(&cnt);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIMsgFolderNotificationService> notifier =
            do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID);
   nsCOMPtr<nsIFolderListener> mailSession =
            do_GetService(NS_MSGMAILSESSION_CONTRACTID);
 
   for (uint32_t i = 0; i < cnt; i++)
   {
-    nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(allDescendants, i);
+    nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(allDescendents, i);
     if (folder)
     {
       folder->ForceDBClosed();
       if (notifier)
         notifier->NotifyFolderDeleted(folder);
       if (mailSession)
       {
         nsCOMPtr<nsIMsgFolder> parentFolder;
@@ -3292,43 +3294,56 @@ nsresult nsMsgAccountManager::RemoveVFLi
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgAccountManager::GetAllFolders(nsIArray **aAllFolders)
 {
   NS_ENSURE_ARG_POINTER(aAllFolders);
-
   nsCOMPtr<nsIArray> servers;
   nsresult rv = GetAllServers(getter_AddRefs(servers));
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t numServers = 0;
   rv = servers->GetLength(&numServers);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIMutableArray> allFolders(do_CreateInstance(NS_ARRAY_CONTRACTID, &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;
   for (i = 0; i < numServers; i++)
   {
     nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(servers, i);
     if (server)
     {
-      nsCOMPtr<nsIMsgFolder> rootFolder;
+      nsCOMPtr <nsIMsgFolder> rootFolder;
       server->GetRootFolder(getter_AddRefs(rootFolder));
       if (rootFolder)
-        rootFolder->ListDescendants(allFolders);
+        rootFolder->ListDescendents(allDescendents);
     }
   }
-
-  allFolders.forget(aAllFolders);
-  return NS_OK;
+  uint32_t folderCount;
+  rv = allDescendents->Count(&folderCount);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  // Create an nsIMutableArray from the nsISupportsArray
+  nsCOMPtr<nsIMsgFolder> folder;
+  for (i = 0; i < folderCount; i++)
+  {
+    folder = do_QueryElementAt(allDescendents, i);
+    folderArray->AppendElement(folder, false);
+  }
+  NS_ADDREF(*aAllFolders = folderArray);
+  return rv;
 }
 
 NS_IMETHODIMP nsMsgAccountManager::OnItemAdded(nsIMsgFolder *parentItem, nsISupports *item)
 {
   nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(item);
   // just kick out with a success code if the item in question is not a folder
   if (!folder)
     return NS_OK;
@@ -3408,28 +3423,28 @@ NS_IMETHODIMP nsMsgAccountManager::OnIte
             searchURI.Cut(0, 1);
             searchURI.Append(folderURI);
             dbFolderInfo->SetCharProperty(kSearchFolderUriProp, searchURI);
             break;
           }
           // New sent or archive folder, need to add sub-folders to smart folder.
           if (vfFolderFlag & (nsMsgFolderFlags::Archive | nsMsgFolderFlags::SentMail))
           {
-            nsCOMPtr<nsIArray> allDescendants;
-            rv = folder->GetDescendants(getter_AddRefs(allDescendants));
+            nsCOMPtr<nsISupportsArray> allDescendents;
+            rv = NS_NewISupportsArray(getter_AddRefs(allDescendents));
             NS_ENSURE_SUCCESS(rv, rv);
-
+            folder->ListDescendents(allDescendents);
             uint32_t cnt = 0;
-            rv = allDescendants->GetLength(&cnt);
+            rv = allDescendents->Count(&cnt);
             NS_ENSURE_SUCCESS(rv, rv);
 
             nsCOMPtr<nsIMsgFolder> parent;
             for (uint32_t j = 0; j < cnt; j++)
             {
-              nsCOMPtr<nsIMsgFolder> subFolder = do_QueryElementAt(allDescendants, j);
+              nsCOMPtr<nsIMsgFolder> subFolder = do_QueryElementAt(allDescendents, j);
               if (subFolder)
               {
                 subFolder->GetParent(getter_AddRefs(parent));
                 OnItemAdded(parent, subFolder);
               }
             }
           }
         }
@@ -3565,28 +3580,28 @@ nsMsgAccountManager::OnItemIntPropertyCh
         nsCOMPtr<nsIMsgFolder> parent;
         aFolder->GetParent(getter_AddRefs(parent));
         return OnItemAdded(parent, aFolder);
       }
       RemoveFolderFromSmartFolder(aFolder, smartFlagsChanged);
       // sent|archive flag removed, remove sub-folders from smart folder.
       if (smartFlagsChanged & (nsMsgFolderFlags::Archive | nsMsgFolderFlags::SentMail))
       {
-        nsCOMPtr<nsIArray> allDescendants;
-        nsresult rv = aFolder->GetDescendants(getter_AddRefs(allDescendants));
+        nsCOMPtr<nsISupportsArray> allDescendents;
+        nsresult rv = NS_NewISupportsArray(getter_AddRefs(allDescendents));
         NS_ENSURE_SUCCESS(rv, rv);
-
+        aFolder->ListDescendents(allDescendents);
         uint32_t cnt = 0;
-        rv = allDescendants->GetLength(&cnt);
+        rv = allDescendents->Count(&cnt);
         NS_ENSURE_SUCCESS(rv, rv);
 
         nsCOMPtr<nsIMsgFolder> parent;
         for (uint32_t j = 0; j < cnt; j++)
         {
-          nsCOMPtr<nsIMsgFolder> subFolder = do_QueryElementAt(allDescendants, j);
+          nsCOMPtr<nsIMsgFolder> subFolder = do_QueryElementAt(allDescendents, j);
           if (subFolder)
             RemoveFolderFromSmartFolder(subFolder, smartFlagsChanged);
         }
       }
     }
   }
   return NS_OK;
 }
--- a/mailnews/base/src/nsMsgFolderDataSource.cpp
+++ b/mailnews/base/src/nsMsgFolderDataSource.cpp
@@ -2159,39 +2159,66 @@ NS_IMETHODIMP nsMsgFlatFolderDataSource:
     EnsureFolders();
     return NS_NewArrayEnumerator(targets, m_folders);
   }
   return NS_NewSingletonEnumerator(targets, property);
 }
 
 void nsMsgFlatFolderDataSource::EnsureFolders()
 {
-  if (m_builtFolders)
-    return;
+  if (!m_builtFolders)
+  {
+    m_builtFolders = true; // in case something goes wrong
 
-  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;
 
-  nsresult rv;
-  nsCOMPtr<nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS_VOID(rv);
+    nsCOMPtr<nsIArray> allServers;
+    rv = accountManager->GetAllServers(getter_AddRefs(allServers));
+    if (NS_FAILED(rv))
+      return;
 
-  nsCOMPtr<nsIArray> allFolders;
-  rv = accountManager->GetAllFolders(getter_AddRefs(allFolders));
-  if (NS_FAILED(rv) || !allFolders)
-    return;
+    nsCOMPtr <nsISupportsArray> allFolders = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
+    if (NS_SUCCEEDED(rv) && allServers)
+    {
+      uint32_t count = 0;
+      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));
+          if (rootFolder)
+          {
+            nsCOMPtr<nsISimpleEnumerator> subFolders;
+            rv = rootFolder->GetSubFolders(getter_AddRefs(subFolders));
 
-  uint32_t count;
-  rv = allFolders->GetLength(&count);
-  NS_ENSURE_SUCCESS_VOID(rv);
-
-  for (uint32_t i = 0; i < count; i++)
-  {
-    nsCOMPtr<nsIMsgFolder> curFolder = do_QueryElementAt(allFolders, i);
-    if (WantsThisFolder(curFolder))
-      m_folders.AppendObject(curFolder);
+            uint32_t lastEntry;
+            allFolders->Count(&lastEntry);
+            rv = rootFolder->ListDescendents(allFolders);
+            uint32_t newLastEntry;
+            allFolders->Count(&newLastEntry);
+            for (uint32_t newEntryIndex = lastEntry; newEntryIndex < newLastEntry; newEntryIndex++)
+            {
+              nsCOMPtr <nsIMsgFolder> curFolder = do_QueryElementAt(allFolders, newEntryIndex);
+              if (WantsThisFolder(curFolder))
+              {
+                m_folders.AppendObject(curFolder);
+              }
+            }
+          }
+        }
+      }
+    }
   }
 }
 
 
 NS_IMETHODIMP nsMsgFlatFolderDataSource::GetURI(char* *aUri)
 {
   nsAutoCString uri("rdf:");
   uri.Append(m_dsName);
@@ -2335,92 +2362,115 @@ void nsMsgRecentFoldersDataSource::Clean
 {
   m_cutOffDate = 0;
   nsMsgFlatFolderDataSource::Cleanup();
 }
 
 
 void nsMsgRecentFoldersDataSource::EnsureFolders()
 {
-  if (m_builtFolders)
-    return;
-
-  m_builtFolders = true; // in case something goes wrong
+  if (!m_builtFolders)
+  {
+    m_builtFolders = true;
 
-  nsresult rv;
-  nsCOMPtr<nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS_VOID(rv);
-
-  nsCOMPtr<nsIArray> allFolders;
-  rv = accountManager->GetAllFolders(getter_AddRefs(allFolders));
-  if (NS_FAILED(rv) || !allFolders)
-    return;
+    nsresult rv;
+    nsCOMPtr <nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+    if (NS_FAILED(rv))
+      return;
 
-  uint32_t count;
-  rv = allFolders->GetLength(&count);
-  NS_ENSURE_SUCCESS_VOID(rv);
+    nsCOMPtr<nsIArray> allServers;
+    rv = accountManager->GetAllServers(getter_AddRefs(allServers));
+    if (NS_FAILED(rv))
+      return;
 
-  for (uint32_t i = 0; i < count; i++)
-  {
-    nsCOMPtr<nsIMsgFolder> curFolder = do_QueryElementAt(allFolders, i);
-    nsCString dateStr;
-    curFolder->GetStringProperty(MRU_TIME_PROPERTY, dateStr);
-    uint32_t curFolderDate = (uint32_t) dateStr.ToInteger(&rv);
-    if (NS_FAILED(rv))
-      curFolderDate = 0;
-
-    if (curFolderDate > m_cutOffDate)
+    nsCOMPtr <nsISupportsArray> allFolders = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
+    if (NS_SUCCEEDED(rv) && allServers)
     {
-      // if m_folders is "full", replace oldest folder with this folder,
-      // and adjust m_cutOffDate so that it's the mrutime
-      // of the "new" oldest folder.
-      uint32_t curFaveFoldersCount = m_folders.Count();
-      if (curFaveFoldersCount > m_maxNumFolders)
+      uint32_t count = 0;
+      allServers->GetLength(&count);
+      uint32_t i;
+      for (i = 0; i < count; i++)
       {
-        uint32_t indexOfOldestFolder = 0;
-        uint32_t oldestFaveDate = 0;
-        uint32_t newOldestFaveDate = 0;
-        for (uint32_t index = 0; index < curFaveFoldersCount; )
+        nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(allServers, i);
+        if (server)
         {
-          nsCString curFaveFolderDateStr;
-          m_folders[index]->GetStringProperty(MRU_TIME_PROPERTY, curFaveFolderDateStr);
-          uint32_t curFaveFolderDate = (uint32_t) curFaveFolderDateStr.ToInteger(&rv);
-          if (!oldestFaveDate || curFaveFolderDate < oldestFaveDate)
+          nsCOMPtr <nsIMsgFolder> rootFolder;
+          server->GetRootFolder(getter_AddRefs(rootFolder));
+          if (rootFolder)
           {
-            indexOfOldestFolder = index;
-            newOldestFaveDate = oldestFaveDate;
-            oldestFaveDate = curFaveFolderDate;
-          }
-          if (!newOldestFaveDate || (index != indexOfOldestFolder
-              && curFaveFolderDate < newOldestFaveDate)) {
-            newOldestFaveDate = curFaveFolderDate;
+            nsCOMPtr<nsISimpleEnumerator> subFolders;
+            rv = rootFolder->GetSubFolders(getter_AddRefs(subFolders));
+
+            uint32_t lastEntry;
+            allFolders->Count(&lastEntry);
+            rv = rootFolder->ListDescendents(allFolders);
+            uint32_t newLastEntry;
+            allFolders->Count(&newLastEntry);
+            for (uint32_t newEntryIndex = lastEntry; newEntryIndex < newLastEntry; newEntryIndex++)
+            {
+              nsCOMPtr <nsIMsgFolder> curFolder = do_QueryElementAt(allFolders, newEntryIndex);
+              nsCString dateStr;
+              nsresult err;
+              curFolder->GetStringProperty(MRU_TIME_PROPERTY, dateStr);
+              uint32_t curFolderDate = (uint32_t) dateStr.ToInteger(&err);
+              if (NS_FAILED(err))
+                curFolderDate = 0;
+              if (curFolderDate > m_cutOffDate)
+              {
+                // if m_folders is "full", replace oldest folder with this folder,
+                // and adjust m_cutOffDate so that it's the mrutime
+                // of the "new" oldest folder.
+                uint32_t curFaveFoldersCount = m_folders.Count();
+                if (curFaveFoldersCount > m_maxNumFolders)
+                {
+                  uint32_t indexOfOldestFolder = 0;
+                  uint32_t oldestFaveDate = 0;
+                  uint32_t newOldestFaveDate = 0;
+                  for (uint32_t index = 0; index < curFaveFoldersCount; )
+                  {
+                    nsCString curFaveFolderDateStr;
+                    m_folders[index]->GetStringProperty(MRU_TIME_PROPERTY, curFaveFolderDateStr);
+                    uint32_t curFaveFolderDate = (uint32_t) curFaveFolderDateStr.ToInteger(&err);
+                    if (!oldestFaveDate || curFaveFolderDate < oldestFaveDate)
+                    {
+                      indexOfOldestFolder = index;
+                      newOldestFaveDate = oldestFaveDate;
+                      oldestFaveDate = curFaveFolderDate;
+                    }
+                    if (!newOldestFaveDate || (index != indexOfOldestFolder
+                                                && curFaveFolderDate < newOldestFaveDate))
+                      newOldestFaveDate = curFaveFolderDate;
+                    index++;
+                  }
+                  if (curFolderDate > oldestFaveDate && m_folders.IndexOf(curFolder) == kNotFound)
+                    m_folders.ReplaceObjectAt(curFolder, indexOfOldestFolder);
+
+                  NS_ASSERTION(newOldestFaveDate >= m_cutOffDate, "cutoff date should be getting bigger");
+                  m_cutOffDate = newOldestFaveDate;
+                }
+                else if (m_folders.IndexOf(curFolder) == kNotFound)
+                  m_folders.AppendObject(curFolder);
+              }
+#ifdef DEBUG_David_Bienvenu
+              else
+              {
+                for (uint32_t index = 0; index < m_folders.Count(); index++)
+                {
+                  nsCString curFaveFolderDateStr;
+                  m_folders[index]->GetStringProperty(MRU_TIME_PROPERTY, curFaveFolderDateStr);
+                  uint32_t curFaveFolderDate = (uint32_t) curFaveFolderDateStr.ToInteger(&err);
+                  NS_ASSERTION(curFaveFolderDate > curFolderDate, "folder newer then faves but not added");
+                }
+              }
+#endif
+            }
           }
-          index++;
         }
-        if (curFolderDate > oldestFaveDate && m_folders.IndexOf(curFolder) == kNotFound)
-          m_folders.ReplaceObjectAt(curFolder, indexOfOldestFolder);
-
-        NS_ASSERTION(newOldestFaveDate >= m_cutOffDate, "cutoff date should be getting bigger");
-        m_cutOffDate = newOldestFaveDate;
-      }
-      else if (m_folders.IndexOf(curFolder) == kNotFound)
-        m_folders.AppendObject(curFolder);
-    }
-#ifdef DEBUG_David_Bienvenu
-    else
-    {
-      for (uint32_t index = 0; index < m_folders.Count(); index++)
-      {
-        nsCString curFaveFolderDateStr;
-        m_folders[index]->GetStringProperty(MRU_TIME_PROPERTY, curFaveFolderDateStr);
-        uint32_t curFaveFolderDate = (uint32_t) curFaveFolderDateStr.ToInteger(&rv);
-        NS_ASSERTION(curFaveFolderDate > curFolderDate, "folder newer then faves but not added");
       }
     }
-#endif
   }
 }
 
 NS_IMETHODIMP nsMsgRecentFoldersDataSource::OnItemAdded(nsIMsgFolder *parentItem, nsISupports *item)
 {
   // if we've already built the recent folder array, we should add this item to the array
   // since just added items are by definition new.
   // I think this means newly discovered imap folders (ones w/o msf files) will
--- a/mailnews/base/src/nsMsgPurgeService.cpp
+++ b/mailnews/base/src/nsMsgPurgeService.cpp
@@ -163,22 +163,22 @@ nsresult nsMsgPurgeService::PerformPurge
       if (NS_SUCCEEDED(rv) && server)
       {
         if (keepApplyingRetentionSettings)
         {
           nsCOMPtr <nsIMsgFolder> rootFolder;
           rv = server->GetRootFolder(getter_AddRefs(rootFolder));
           NS_ENSURE_SUCCESS(rv, rv);
 
-          nsCOMPtr<nsIArray> childFolders;
-          rv = rootFolder->GetDescendants(getter_AddRefs(childFolders));
+          nsCOMPtr <nsISupportsArray> childFolders = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
           NS_ENSURE_SUCCESS(rv, rv);
+          rv = rootFolder->ListDescendents(childFolders);
 
           uint32_t cnt = 0;
-          childFolders->GetLength(&cnt);
+          childFolders->Count(&cnt);
 
           nsCOMPtr<nsISupports> supports;
           nsCOMPtr<nsIUrlListener> urlListener;
           nsCOMPtr<nsIMsgFolder> childFolder;
 
           for (uint32_t index = 0; index < cnt; index++)
           {
             childFolder = do_QueryElementAt(childFolders, index);
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -1852,20 +1852,21 @@ nsresult nsMsgDBFolder::HandleAutoCompac
         if (!supportsCompaction)
           continue;
         nsCOMPtr<nsIMsgFolder> rootFolder;
         rv = server->GetRootFolder(getter_AddRefs(rootFolder));
         if(NS_SUCCEEDED(rv) && rootFolder)
         {
           rv = server->GetOfflineSupportLevel(&offlineSupportLevel);
           NS_ENSURE_SUCCESS(rv, rv);
-          nsCOMPtr<nsIArray> allDescendents;
-          rootFolder->GetDescendants(getter_AddRefs(allDescendents));
+          nsCOMPtr<nsISupportsArray> allDescendents;
+          NS_NewISupportsArray(getter_AddRefs(allDescendents));
+          rootFolder->ListDescendents(allDescendents);
           uint32_t cnt = 0;
-          rv = allDescendents->GetLength(&cnt);
+          rv = allDescendents->Count(&cnt);
           NS_ENSURE_SUCCESS(rv, rv);
           uint32_t expungedBytes=0;
           if (offlineSupportLevel > 0)
           {
             uint32_t flags;
             for (uint32_t i = 0; i < cnt; i++)
             {
               nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(allDescendents, i);
@@ -5066,41 +5067,27 @@ NS_IMETHODIMP nsMsgDBFolder::GetMessageH
 {
   NS_ENSURE_ARG_POINTER(aMsgHdr);
   nsCOMPtr <nsIMsgDatabase> database;
   nsresult rv = GetMsgDatabase(getter_AddRefs(database));
   NS_ENSURE_SUCCESS(rv, rv);
   return (database) ? database->GetMsgHdrForKey(msgKey, aMsgHdr) : NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP nsMsgDBFolder::GetDescendants(nsIArray** aDescendants)
-{
-  NS_ENSURE_ARG_POINTER(aDescendants);
-
-  nsresult rv;
-  nsCOMPtr<nsIMutableArray> allFolders(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = ListDescendants(allFolders);
-  allFolders.forget(aDescendants);
-  return NS_OK;
-}
-
 // this gets the deep sub-folders too, e.g., the children of the children
-NS_IMETHODIMP nsMsgDBFolder::ListDescendants(nsIMutableArray *aDescendants)
-{
-  NS_ENSURE_ARG_POINTER(aDescendants);
-
-  GetSubFolders(nullptr); // initialize mSubFolders
-  uint32_t count = mSubFolders.Count();
-  for (uint32_t i = 0; i < count; i++)
+NS_IMETHODIMP nsMsgDBFolder::ListDescendents(nsISupportsArray *descendents)
+{
+  NS_ENSURE_ARG(descendents);
+
+  int32_t count = mSubFolders.Count();
+  for (int32_t i = 0; i < count; i++)
   {
     nsCOMPtr<nsIMsgFolder> child(mSubFolders[i]);
-    aDescendants->AppendElement(child, false);
-    child->ListDescendants(aDescendants);  // recurse
+    descendents->AppendElement(child);
+    child->ListDescendents(descendents);  // recurse
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgDBFolder::GetBaseMessageURI(nsACString& baseMessageURI)
 {
   if (mBaseMessageURI.IsEmpty())
     return NS_ERROR_FAILURE;
--- a/mailnews/db/gloda/modules/gloda.js
+++ b/mailnews/db/gloda/modules/gloda.js
@@ -1175,18 +1175,23 @@ var Gloda = {
             let rootFolder = givenMsgFolder.rootFolder;
 
             // skip processing this folder if we have already processed its
             //  root folder.
             if (rootFolder.URI in seenRootFolders)
               continue;
             seenRootFolders[rootFolder.URI] = true;
 
-            let allFolders = rootFolder.descendants;
-            for (let folder in fixIterator(allFolders, Ci.nsIMsgFolder)) {
+            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(
+                Ci.nsIMsgFolder);
               let folderFlags = folder.flags;
 
               // Ignore virtual folders, non-mail folders.
               // XXX this is derived from GlodaIndexer's shouldIndexFolder.
               //  This should probably just use centralized code or the like.
               if (!(folderFlags & Ci.nsMsgFolderFlags.Mail) ||
                   (folderFlags & Ci.nsMsgFolderFlags.Virtual))
                 continue;
--- a/mailnews/db/gloda/modules/index_msg.js
+++ b/mailnews/db/gloda/modules/index_msg.js
@@ -16,17 +16,16 @@ const EXPORTED_SYMBOLS = ['GlodaMsgIndex
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource:///modules/iteratorUtils.jsm");
-Cu.import("resource:///modules/mailServices.js");
 Cu.import("resource:///modules/MailUtils.js");
 
 Cu.import("resource:///modules/gloda/log4moz.js");
 
 Cu.import("resource:///modules/gloda/utils.js");
 Cu.import("resource:///modules/gloda/datastore.js");
 Cu.import("resource:///modules/gloda/datamodel.js");
 Cu.import("resource:///modules/gloda/gloda.js");
@@ -997,20 +996,35 @@ var GlodaMsgIndexer = {
    */
   _worker_indexingSweep: function gloda_worker_indexingSweep(aJob) {
     if (!aJob.mappedFolders) {
       // 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 allFolders = MailServices.accounts.allFolders;
-      for (let folder in fixIterator(allFolders, Ci.nsIMsgFolder)) {
-        if (this.shouldIndexFolder(folder))
+      let accountManager = Cc["@mozilla.org/messenger/account-manager;1"].
+                           getService(Ci.nsIMsgAccountManager);
+      let servers = accountManager.allServers;
+      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(
+            Ci.nsIMsgFolder);
+          if (!this.shouldIndexFolder(folder))
+            continue;
+
           foldersToProcess.push(Gloda.getFolderForFolder(folder));
+        }
       }
 
       // sort the folders by priority (descending)
       foldersToProcess.sort(function (a, b) {
         return b.indexingPriority - a.indexingPriority;
       });
 
       aJob.mappedFolders = true;
@@ -1902,19 +1916,24 @@ var GlodaMsgIndexer = {
   /**
    * Queue all of the folders belonging to an account for indexing.
    */
   indexAccount: function glodaIndexAccount(aAccount) {
     let rootFolder = aAccount.incomingServer.rootFolder;
     if (rootFolder instanceof Ci.nsIMsgFolder) {
       this._log.info("Queueing account folders for indexing: " + aAccount.key);
 
-      let allFolders = rootFolder.descendants;
+      let allFolders = Cc["@mozilla.org/supports-array;1"]
+                         .createInstance(Ci.nsISupportsArray);
+      rootFolder.ListDescendents(allFolders);
+      let numFolders = allFolders.Count();
       let folderJobs = [];
-      for (let folder in fixIterator(allFolders, Ci.nsIMsgFolder)) {
+      for (let folderIndex = 0; folderIndex < numFolders; folderIndex++) {
+        let folder = allFolders.GetElementAt(folderIndex).QueryInterface(
+                                                            Ci.nsIMsgFolder);
         if (this.shouldIndexFolder(folder))
           GlodaIndexer.indexJob(
             new IndexingJob("folder", GlodaDatastore._mapFolder(folder).id));
       }
     }
     else {
       this._log.info("Skipping Account, root folder not nsIMsgFolder");
     }
@@ -2581,17 +2600,20 @@ var GlodaMsgIndexer = {
           }
           else {
             indexer._log.info("Ignoring deletion of folder " +
                               aFolder.prettiestName +
                               " because it is unknown to gloda.");
           }
         };
 
-        let descendentFolders = aFolder.descendants;
+        let descendentFolders = Cc["@mozilla.org/supports-array;1"].
+        createInstance(Ci.nsISupportsArray);
+        aFolder.ListDescendents(descendentFolders);
+
         // (the order of operations does not matter; child, non-child, whatever.)
         // delete the parent
         delFunc(aFolder, this.indexer);
         // delete all its descendents
         for (let folder in fixIterator(descendentFolders, Ci.nsIMsgFolder)) {
           delFunc(folder, this.indexer);
         }
 
@@ -2634,29 +2656,33 @@ var GlodaMsgIndexer = {
      *  will generate only a single notification.  Our logic primarily handles
      *  this by not exploding if the original folder no longer exists.
      */
     _folderRenameHelper: function gloda_indexer_folderRenameHelper(aOrigFolder,
                                                                    aNewURI) {
       let newFolder = MailUtils.getFolderForURI(aNewURI);
       let specialFolderFlags = Ci.nsMsgFolderFlags.Trash | Ci.nsMsgFolderFlags.Junk;
       if (newFolder.isSpecialFolder(specialFolderFlags, true)) {
-        let descendentFolders = newFolder.descendants;
+        let descendentFolders = Cc["@mozilla.org/supports-array;1"].
+                                  createInstance(Ci.nsISupportsArray);
+        newFolder.ListDescendents(descendentFolders);
 
         // First thing to do: make sure we don't index the resulting folder and
         //  its descendents.
         GlodaMsgIndexer.resetFolderIndexingPriority(newFolder);
         for (let folder in fixIterator(descendentFolders, Ci.nsIMsgFolder)) {
           GlodaMsgIndexer.resetFolderIndexingPriority(folder);
         }
 
         // Remove from the index messages from the original folder
         this.folderDeleted(aOrigFolder);
       } else {
-        let descendentFolders = aOrigFolder.descendants;
+        let descendentFolders = Cc["@mozilla.org/supports-array;1"].
+                                  createInstance(Ci.nsISupportsArray);
+        aOrigFolder.ListDescendents(descendentFolders);
 
         let origURI = aOrigFolder.URI;
         // this rename is straightforward.
         GlodaDatastore.renameFolder(aOrigFolder, aNewURI);
 
         for (let folder in fixIterator(descendentFolders, Ci.nsIMsgFolder)) {
           let oldSubURI = folder.URI;
           // mangle a new URI from the old URI.  we could also try and do a
--- a/mailnews/db/gloda/test/unit/base_index_messages.js
+++ b/mailnews/db/gloda/test/unit/base_index_messages.js
@@ -1029,17 +1029,19 @@ function test_folder_deletion_nested() {
   // IMAP, the moved message header are different entities and it's not msgSet2
   // that ends up indexed, but the fresh headers
   yield move_folder(folder2, folder1);
 
   // add a trash folder, and move folder1 into it
   let trash = make_empty_folder(null, [Ci.nsMsgFolderFlags.Trash]);
   yield move_folder(folder1, trash);
 
-  let descendentFolders = get_nsIMsgFolder(trash).descendants;
+  let descendentFolders = Cc["@mozilla.org/supports-array;1"]
+                          .createInstance(Ci.nsISupportsArray);
+  get_nsIMsgFolder(trash).ListDescendents(descendentFolders);
   let folders = [folder for (folder in fixIterator(descendentFolders, Ci.nsIMsgFolder))];
   do_check_eq(folders.length, 2);
   let [newFolder1, newFolder2] = folders;
 
   let glodaFolder1 = Gloda.getFolderForFolder(newFolder1);
   let glodaFolder2 = Gloda.getFolderForFolder(newFolder2);
 
   // verify that Gloda properly marked this folder as not to be indexed anymore 
--- a/mailnews/extensions/newsblog/js/newsblog.js
+++ b/mailnews/extensions/newsblog/js/newsblog.js
@@ -20,35 +20,33 @@ var nsNewsBlogFeedDownloader =
     // new feeds.
     if (FeedUtils.progressNotifier.mSubscribeMode)
     {
       FeedUtils.log.warn("downloadFeed: Aborting RSS New Mail Check. " +
                          "Feed subscription in progress\n");
       return;
     }
 
-    let allFolders = Cc["@mozilla.org/array;1"].
-                     createInstance(Ci.nsIMutableArray);
-    if (!aFolder.isServer) {
-      // Add the base folder; it does not get returned by ListDescendants. Do not
+    let allFolders = Cc["@mozilla.org/supports-array;1"].
+                     createInstance(Ci.nsISupportsArray);
+    if (!aFolder.isServer)
+      // Add the base folder; it does not get added by ListDescendents.  Do not
       // add the account folder as it doesn't have the feedUrl property or even
       // a msgDatabase necessarily.
-      allFolders.appendElement(aFolder, false);
-    }
+      allFolders.AppendElement(aFolder);
 
-    aFolder.ListDescendants(allFolders);
-
+    aFolder.ListDescendents(allFolders);
+    let numFolders = allFolders.Count();
     let trashFolder =
         aFolder.rootFolder.getFolderWithFlags(Ci.nsMsgFolderFlags.Trash);
 
     function feeder() {
       let folder;
-      let numFolders = allFolders.length;
       for (let i = 0; i < numFolders; i++) {
-        folder = allFolders.queryElementAt(i, Ci.nsIMsgFolder);
+        folder = allFolders.GetElementAt(i).QueryInterface(Ci.nsIMsgFolder);
         FeedUtils.log.debug("downloadFeed: START x/# foldername:uri - " +
                             (i+1) + "/" + numFolders + " " +
                             folder.name + ":" + folder.URI);
 
         // Ensure msgDatabase for the folder is open for new message processing.
         let msgDb;
         try {
           msgDb = folder.msgDatabase;
--- a/mailnews/imap/src/nsAutoSyncManager.cpp
+++ b/mailnews/imap/src/nsAutoSyncManager.cpp
@@ -768,36 +768,37 @@ nsresult nsAutoSyncManager::AutoUpdateFo
 
     // if we haven't logged onto this server yet, then skip this server.
     bool passwordRequired;
     incomingServer->GetServerRequiresPasswordForBiff(&passwordRequired);
     if (passwordRequired)
       continue;
 
     nsCOMPtr<nsIMsgFolder> rootFolder;
-    nsCOMPtr<nsIArray> allDescendants;
+    nsCOMPtr<nsISupportsArray> allDescendents;
 
     rv = incomingServer->GetRootFolder(getter_AddRefs(rootFolder));
     if (rootFolder)
     {
+      allDescendents = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
       if (NS_FAILED(rv))
         continue;
 
-      rv = rootFolder->GetDescendants(getter_AddRefs(allDescendants));
-      if (!allDescendants)
+      rv = rootFolder->ListDescendents(allDescendents);
+      if (!allDescendents)
         continue;
 
       uint32_t cnt = 0;
-      rv = allDescendants->GetLength(&cnt);
+      rv = allDescendents->Count(&cnt);
       if (NS_FAILED(rv))
         continue;
 
       for (uint32_t i = 0; i < cnt; i++)
       {
-        nsCOMPtr<nsIMsgFolder> folder(do_QueryElementAt(allDescendants, i, &rv));
+        nsCOMPtr<nsIMsgFolder> folder(do_QueryElementAt(allDescendents, i, &rv));
         if (NS_FAILED(rv))
           continue;
 
         uint32_t folderFlags;
         rv = folder->GetFlags(&folderFlags);
         // Skip this folder if not offline or is a saved search or is no select.
         if (NS_FAILED(rv) || !(folderFlags & nsMsgFolderFlags::Offline) ||
             folderFlags & (nsMsgFolderFlags::Virtual |
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -1350,23 +1350,25 @@ NS_IMETHODIMP nsImapMailFolder::Expunge(
 NS_IMETHODIMP nsImapMailFolder::CompactAll(nsIUrlListener *aListener,
                                                nsIMsgWindow *aMsgWindow,
                                                bool aCompactOfflineAlso)
 {
   nsresult rv;
   nsCOMPtr<nsIMutableArray> folderArray, offlineFolderArray;
 
   nsCOMPtr<nsIMsgFolder> rootFolder;
-  nsCOMPtr<nsIArray> allDescendents;
+  nsCOMPtr<nsISupportsArray> allDescendents;
   rv = GetRootFolder(getter_AddRefs(rootFolder));
   if (NS_SUCCEEDED(rv) && rootFolder)
   {
-    rootFolder->GetDescendants(getter_AddRefs(allDescendents));
+    allDescendents = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
+    NS_ENSURE_TRUE(allDescendents, rv);
+    rootFolder->ListDescendents(allDescendents);
     uint32_t cnt = 0;
-    rv = allDescendents->GetLength(&cnt);
+    rv = allDescendents->Count(&cnt);
     NS_ENSURE_SUCCESS(rv, rv);
     folderArray = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
     NS_ENSURE_TRUE(folderArray, rv);
     if (aCompactOfflineAlso)
     {
       offlineFolderArray = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
       NS_ENSURE_TRUE(offlineFolderArray, rv);
     }
--- a/mailnews/imap/src/nsImapOfflineSync.cpp
+++ b/mailnews/imap/src/nsImapOfflineSync.cpp
@@ -103,137 +103,133 @@ nsImapOfflineSync::OnStopRunningUrl(nsIU
   {
     ClearCurrentOps();
     rv = ProcessNextOperation();
   }
   // else if it's a non-stop error, and we're doing multiple folders,
   // go to the next folder.
   else if (!m_singleFolderToUpdate)
   {
-    if (AdvanceToNextFolder())
+    rv = AdvanceToNextFolder();
+    if (NS_SUCCEEDED(rv))
       rv = ProcessNextOperation();
     else if (m_listener)
       m_listener->OnStopRunningUrl(url, rv);
   }
 
   return rv;
 }
 
-/**
- * Leaves m_currentServer at the next imap or local mail "server" that
- * might have offline events to playback. If no more servers,
- * m_currentServer will be left at nullptr and the function returns false.
- * Also, sets up m_serverEnumerator to enumerate over the server.
- */
-bool nsImapOfflineSync::AdvanceToNextServer()
+// leaves m_currentServer at the next imap or local mail "server" that
+// might have offline events to playback. If no more servers,
+// m_currentServer will be left at nullptr.
+// Also, sets up m_serverEnumerator to enumerate over the server
+nsresult nsImapOfflineSync::AdvanceToNextServer()
 {
   nsresult rv = NS_OK;
 
   if (!m_allServers)
   {
     NS_ASSERTION(!m_currentServer, "this shouldn't be set");
     m_currentServer = nullptr;
     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 false;
+    if (!accountManager || NS_FAILED(rv)) return rv;
 
     rv = accountManager->GetAllServers(getter_AddRefs(m_allServers));
-    NS_ENSURE_SUCCESS(rv, false);
+    NS_ENSURE_SUCCESS(rv, rv);
   }
   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;
+  uint32_t 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);
+    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)
       {
-        rv = rootFolder->GetDescendants(getter_AddRefs(m_allFolders));
+        m_allFolders = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
+        NS_ENSURE_TRUE(m_allFolders, rv);
+        rv = rootFolder->ListDescendents(m_allFolders);
         if (NS_SUCCEEDED(rv))
+          m_allFolders->Enumerate(getter_AddRefs(m_serverEnumerator));
+        if (NS_SUCCEEDED(rv) && m_serverEnumerator)
         {
-          rv = m_allFolders->Enumerate(getter_AddRefs(m_serverEnumerator));
-          if (NS_SUCCEEDED(rv) && m_serverEnumerator)
-          {
-            bool hasMore = false;
-            rv = m_serverEnumerator->HasMoreElements(&hasMore);
-            if (NS_SUCCEEDED(rv) && hasMore)
-              return true;
-          }
+          rv = m_serverEnumerator->First();
+          if (NS_SUCCEEDED(rv))
+            break;
         }
       }
     }
   }
-  return false;
+  return rv;
 }
 
-/**
- * Sets m_currentFolder to the next folder to process.
- *
- * @return  True if next folder to process was found, otherwise false.
- */
-bool nsImapOfflineSync::AdvanceToNextFolder()
+nsresult nsImapOfflineSync::AdvanceToNextFolder()
 {
+  nsresult rv;
   // we always start by changing flags
   mCurrentPlaybackOpType = nsIMsgOfflineImapOperation::kFlagsChanged;
 
   if (m_currentFolder)
   {
     m_currentFolder->SetMsgDatabase(nullptr);
     m_currentFolder = nullptr;
   }
 
-  bool hasMore = false;
-  if (m_currentServer)
-    m_serverEnumerator->HasMoreElements(&hasMore);
-  if (!hasMore)
-    hasMore = AdvanceToNextServer();
+  if (!m_currentServer)
+     rv = AdvanceToNextServer();
+  else
+    rv = m_serverEnumerator->Next();
+  if (NS_FAILED(rv))
+    rv = AdvanceToNextServer();
 
-  if (hasMore)
+  if (NS_SUCCEEDED(rv) && m_serverEnumerator)
   {
-    nsCOMPtr<nsISupports> supports;
-    nsresult rv = m_serverEnumerator->GetNext(getter_AddRefs(supports));
-    if (NS_SUCCEEDED(rv))
-      m_currentFolder = do_QueryInterface(supports);
+    nsCOMPtr <nsISupports> supports;
+    rv = m_serverEnumerator->CurrentItem(getter_AddRefs(supports));
+    m_currentFolder = do_QueryInterface(supports);
   }
   ClearDB();
-  return m_currentFolder;
+  return rv;
 }
 
 void nsImapOfflineSync::AdvanceToFirstIMAPFolder()
 {
+  nsresult rv;
   m_currentServer = nullptr;
-  nsCOMPtr<nsIMsgImapMailFolder> imapFolder;
-  while (!imapFolder && AdvanceToNextFolder())
+  nsCOMPtr <nsIMsgImapMailFolder> imapFolder;
+  do
   {
-    imapFolder = do_QueryInterface(m_currentFolder);
+    rv = AdvanceToNextFolder();
+    if (m_currentFolder)
+      imapFolder = do_QueryInterface(m_currentFolder);
   }
+  while (NS_SUCCEEDED(rv) && m_currentFolder && !imapFolder);
 }
 
 void nsImapOfflineSync::ProcessFlagOperation(nsIMsgOfflineImapOperation *op)
 {
   nsCOMPtr <nsIMsgOfflineImapOperation> currentOp = op;
   nsTArray<nsMsgKey> matchingFlagKeys;
   uint32_t currentKeyIndex = m_KeyIndex;
 
@@ -1107,17 +1103,18 @@ nsresult nsImapOfflineDownloader::Proces
     if (NS_FAILED(rv)) return rv;
 
     nsCOMPtr<nsIArray> servers;
     rv = accountManager->GetAllServers(getter_AddRefs(servers));
     if (NS_FAILED(rv)) return rv;
   }
   if (!m_mailboxupdatesFinished)
   {
-    if (AdvanceToNextServer())
+    AdvanceToNextServer();
+    if (m_currentServer)
     {
       nsCOMPtr <nsIMsgFolder> rootMsgFolder;
       m_currentServer->GetRootFolder(getter_AddRefs(rootMsgFolder));
       nsCOMPtr<nsIMsgFolder> inbox;
       if (rootMsgFolder)
       {
           rootMsgFolder->GetFolderWithFlags(nsMsgFolderFlags::Inbox,
                                             getter_AddRefs(inbox));
@@ -1162,18 +1159,19 @@ nsresult nsImapOfflineDownloader::Proces
       return ProcessNextOperation(); // recurse and do next server.
     }
     else
     {
       m_allServers = nullptr;
       m_mailboxupdatesFinished = true;
     }
   }
+  AdvanceToNextFolder();
 
-  while (AdvanceToNextFolder())
+  while (m_currentFolder)
   {
     uint32_t folderFlags;
 
     ClearDB();
     nsCOMPtr <nsIMsgImapMailFolder> imapFolder;
     if (m_currentFolder)
       imapFolder = do_QueryInterface(m_currentFolder);
     m_currentFolder->GetFlags(&folderFlags);
@@ -1181,16 +1179,17 @@ nsresult nsImapOfflineDownloader::Proces
     if (imapFolder && folderFlags & nsMsgFolderFlags::Offline &&
       ! (folderFlags & nsMsgFolderFlags::Virtual))
     {
       rv = m_currentFolder->DownloadAllForOffline(this, m_window);
       if (NS_SUCCEEDED(rv) || rv == NS_BINDING_ABORTED)
         return rv;
       // if this fails and the user didn't cancel/stop, fall through to code that advances to next folder
     }
+    AdvanceToNextFolder();
   }
   if (m_listener)
     m_listener->OnStopRunningUrl(nullptr, NS_OK);
   return rv;
 }
 
 
 NS_IMETHODIMP nsImapOfflineSync::OnStartCopy()
--- a/mailnews/imap/src/nsImapOfflineSync.h
+++ b/mailnews/imap/src/nsImapOfflineSync.h
@@ -38,18 +38,18 @@ public: // set to one folder to playback
   void      SetPseudoOffline(bool pseudoOffline) {m_pseudoOffline = pseudoOffline;}
   bool      ProcessingStaleFolderUpdate() { return m_singleFolderToUpdate != nullptr; }
 
   bool      CreateOfflineFolder(nsIMsgFolder *folder);
   void      SetWindow(nsIMsgWindow *window);
 protected:
   bool      CreateOfflineFolders();
   bool      DestFolderOnSameServer(nsIMsgFolder *destFolder);
-  bool      AdvanceToNextServer();
-  bool      AdvanceToNextFolder();
+  nsresult  AdvanceToNextServer();
+  nsresult  AdvanceToNextFolder();
   void      AdvanceToFirstIMAPFolder();
   void      DeleteAllOfflineOpsForCurrentDB();
   void      ClearCurrentOps();
   // Clears m_currentDB, and unregister listener.
   void      ClearDB();
   void      ProcessFlagOperation(nsIMsgOfflineImapOperation *currentOp);
   void      ProcessKeywordOperation(nsIMsgOfflineImapOperation *op);
   void      ProcessMoveOperation(nsIMsgOfflineImapOperation *currentOp);
@@ -57,21 +57,21 @@ protected:
   void      ProcessEmptyTrash();
   void      ProcessAppendMsgOperation(nsIMsgOfflineImapOperation *currentOp,
                                       nsOfflineImapOperationType opType);
 
   nsCOMPtr <nsIMsgFolder> m_currentFolder;
   nsCOMPtr <nsIMsgFolder> m_singleFolderToUpdate;
   nsCOMPtr <nsIMsgWindow> m_window;
   nsCOMPtr <nsIArray> m_allServers;
-  nsCOMPtr <nsIArray> m_allFolders;
+  nsCOMPtr <nsISupportsArray> m_allFolders;
   nsCOMPtr <nsIMsgIncomingServer> m_currentServer;
-  nsCOMPtr <nsISimpleEnumerator> m_serverEnumerator;
+  nsCOMPtr <nsIEnumerator> m_serverEnumerator;
   nsCOMPtr <nsIFile> m_curTempFile;
-
+  
   nsTArray<nsMsgKey> m_CurrentKeys;
   nsCOMArray<nsIMsgOfflineImapOperation> m_currentOpsToClear;
   uint32_t      m_KeyIndex;
   nsCOMPtr <nsIMsgDatabase> m_currentDB;
   nsCOMPtr <nsIUrlListener> m_listener;
   int32_t	mCurrentUIDValidity;
   int32_t	mCurrentPlaybackOpType;	// kFlagsChanged -> kMsgCopy -> kMsgMoved
   bool	m_mailboxupdatesStarted;
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -586,31 +586,31 @@ nsMsgLocalMailFolder::CreateSubfolderInt
 
 NS_IMETHODIMP nsMsgLocalMailFolder::CompactAll(nsIUrlListener *aListener,
                                                nsIMsgWindow *aMsgWindow,
                                                bool aCompactOfflineAlso)
 {
   nsresult rv = NS_OK;
   nsCOMPtr<nsIMutableArray> folderArray;
   nsCOMPtr<nsIMsgFolder> rootFolder;
-  nsCOMPtr<nsIArray> allDescendents;
+  nsCOMPtr<nsISupportsArray> allDescendents;
   rv = GetRootFolder(getter_AddRefs(rootFolder));
   nsCOMPtr<nsIMsgPluggableStore> msgStore;
   GetMsgStore(getter_AddRefs(msgStore));
   bool storeSupportsCompaction;
   msgStore->GetSupportsCompaction(&storeSupportsCompaction);
   if (!storeSupportsCompaction)
     return NotifyCompactCompleted();
 
   if (NS_SUCCEEDED(rv) && rootFolder)
   {
-    rv = rootFolder->GetDescendants(getter_AddRefs(allDescendents));
-    NS_ENSURE_SUCCESS(rv, rv);
-    uint32_t cnt = 0;
-    rv = allDescendents->GetLength(&cnt);
+    NS_NewISupportsArray(getter_AddRefs(allDescendents));
+    rootFolder->ListDescendents(allDescendents);
+    uint32_t cnt =0;
+    rv = allDescendents->Count(&cnt);
     NS_ENSURE_SUCCESS(rv, rv);
     folderArray = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
     uint32_t expungedBytes = 0;
     for (uint32_t i = 0; i < cnt; i++)
     {
       nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(allDescendents, i, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
 
@@ -655,16 +655,17 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Empt
   if (NS_SUCCEEDED(rv))
   {
     uint32_t flags;
     nsCString trashUri;
     trashFolder->GetURI(trashUri);
     trashFolder->GetFlags(&flags);
     int32_t totalMessages = 0;
     rv = trashFolder->GetTotalMessages(true, &totalMessages);
+
     if (totalMessages <= 0)
     {
       nsCOMPtr<nsISimpleEnumerator> enumerator;
       rv = trashFolder->GetSubFolders(getter_AddRefs(enumerator));
       NS_ENSURE_SUCCESS(rv,rv);
       // Any folders to deal with?
       bool hasMore;
       rv = enumerator->HasMoreElements(&hasMore);
--- a/mailnews/local/src/nsRssIncomingServer.cpp
+++ b/mailnews/local/src/nsRssIncomingServer.cpp
@@ -9,17 +9,16 @@
 #include "nsMsgBaseCID.h"
 #include "nsIFile.h"
 #include "nsIMsgFolderNotificationService.h"
 
 #include "nsIMsgLocalMailFolder.h"
 #include "nsIDBFolderInfo.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
-#include "nsArrayUtils.h"
 #include "nsMsgUtils.h"
 
 nsrefcnt nsRssIncomingServer::gInstanceCount    = 0;
 
 NS_IMPL_ISUPPORTS_INHERITED3(nsRssIncomingServer,
                              nsMsgIncomingServer,
                              nsIRssIncomingServer,
                              nsIMsgFolderListener,
@@ -246,29 +245,30 @@ nsresult nsRssIncomingServer::FolderChan
     NS_ENSURE_SUCCESS(rv, rv);
     rssDownloader->UpdateSubscriptionsDS(aFolder, aUnsubscribe);
 
     if (!aUnsubscribe)
     {
       // If the user was moving a set of nested folders, we only
       // get a single notification, so we need to iterate over all of the
       // descedent folders of the folder whose location has changed.
-      nsCOMPtr<nsIArray> allDescendents;
-      rv = aFolder->GetDescendants(getter_AddRefs(allDescendents));
+      nsCOMPtr<nsISupportsArray> allDescendents;
+      NS_NewISupportsArray(getter_AddRefs(allDescendents));
+      rv = aFolder->ListDescendents(allDescendents);
       NS_ENSURE_SUCCESS(rv, rv);
 
       uint32_t cnt = 0;
-      allDescendents->GetLength(&cnt);
+      allDescendents->Count(&cnt);
 
       nsCOMPtr<nsIMsgFolder> rssFolder;
 
       for (uint32_t index = 0; index < cnt; index++)
       {
         rssFolder = do_QueryElementAt(allDescendents, index, &rv);
-        if (NS_SUCCEEDED(rv) && rssFolder)
+        if (rssFolder)
           rssDownloader->UpdateSubscriptionsDS(rssFolder, aUnsubscribe);
       }
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
--- a/mailnews/news/src/nsNewsDownloader.cpp
+++ b/mailnews/news/src/nsNewsDownloader.cpp
@@ -373,37 +373,37 @@ nsMsgDownloadAllNewsgroups::OnStopRunnin
     }
   }
   else if (m_listener)  // notify main observer.
     m_listener->OnStopRunningUrl(url, exitCode);
 
   return rv;
 }
 
-/**
- * Leaves m_currentServer at the next nntp "server" that
- * might have folders to download for offline use. If no more servers,
- * m_currentServer will be left at nullptr and the function returns false.
- * Also, sets up m_serverEnumerator to enumerate over the server.
- * If no servers found, m_serverEnumerator will be left at null.
- */
-bool nsMsgDownloadAllNewsgroups::AdvanceToNextServer()
+// leaves m_currentServer at the next nntp "server" that
+// might have folders to download for offline use. If no more servers,
+// m_currentServer will be left at nullptr.
+// Also, sets up m_serverEnumerator to enumerate over the server
+// If no servers found, m_serverEnumerator will be left at null,
+nsresult nsMsgDownloadAllNewsgroups::AdvanceToNextServer(bool *done)
 {
   nsresult rv;
 
+  NS_ENSURE_ARG(done);
+
+  *done = true;
   if (!m_allServers)
   {
     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 false;
+    if (!accountManager || NS_FAILED(rv)) return rv;
 
     rv = accountManager->GetAllServers(getter_AddRefs(m_allServers));
-    NS_ENSURE_SUCCESS(rv, false);
+    NS_ENSURE_SUCCESS(rv, rv);
   }
   uint32_t serverIndex = 0;
   if (m_currentServer)
   {
     rv = m_allServers->IndexOf(0, m_currentServer, &serverIndex);
     if (NS_FAILED(rv))
       serverIndex = -1;
 
@@ -417,49 +417,46 @@ bool nsMsgDownloadAllNewsgroups::Advance
   while (serverIndex < numServers)
   {
     nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(m_allServers, serverIndex);
     serverIndex++;
 
     nsCOMPtr <nsINntpIncomingServer> newsServer = do_QueryInterface(server);
     if (!newsServer) // we're only looking for news servers
       continue;
-
     if (server)
     {
       m_currentServer = server;
       server->GetRootFolder(getter_AddRefs(rootFolder));
       if (rootFolder)
       {
-        rv = rootFolder->GetDescendants(getter_AddRefs(m_allFolders));
+        NS_NewISupportsArray(getter_AddRefs(m_allFolders));
+        rv = rootFolder->ListDescendents(m_allFolders);
         if (NS_SUCCEEDED(rv))
+          m_allFolders->Enumerate(getter_AddRefs(m_serverEnumerator));
+        if (NS_SUCCEEDED(rv) && m_serverEnumerator)
         {
-          rv = m_allFolders->Enumerate(getter_AddRefs(m_serverEnumerator));
-          if (NS_SUCCEEDED(rv) && m_serverEnumerator)
+          rv = m_serverEnumerator->First();
+          if (NS_SUCCEEDED(rv))
           {
-            bool hasMore = false;
-            rv = m_serverEnumerator->HasMoreElements(&hasMore);
-            if (NS_SUCCEEDED(rv) && hasMore)
-              return true;
+            *done = false;
+            break;
           }
         }
       }
     }
   }
-  return false;
+  return rv;
 }
 
-/**
- * Sets m_currentFolder to the next usable folder.
- *
- * @return  False if no more folders found, otherwise true.
- */
-bool nsMsgDownloadAllNewsgroups::AdvanceToNextGroup()
+nsresult nsMsgDownloadAllNewsgroups::AdvanceToNextGroup(bool *done)
 {
-  nsresult rv = NS_OK;
+  nsresult rv;
+  NS_ENSURE_ARG(done);
+  *done = true;
 
   if (m_currentFolder)
   {
     nsCOMPtr <nsIMsgNewsFolder> newsFolder = do_QueryInterface(m_currentFolder);
     if (newsFolder)
       newsFolder->SetSaveArticleOffline(false);
 
     nsCOMPtr<nsIMsgMailSession> session =
@@ -471,30 +468,33 @@ bool nsMsgDownloadAllNewsgroups::Advance
       m_currentFolder->GetFlags(&folderFlags);
       session->IsFolderOpenInWindow(m_currentFolder, &folderOpen);
       if (!folderOpen && ! (folderFlags & (nsMsgFolderFlags::Trash | nsMsgFolderFlags::Inbox)))
         m_currentFolder->SetMsgDatabase(nullptr);
     }
     m_currentFolder = nullptr;
   }
 
-  bool hasMore = false;
-  if (m_currentServer)
-    m_serverEnumerator->HasMoreElements(&hasMore);
-  if (!hasMore)
-    hasMore = AdvanceToNextServer();
+  *done = false;
+
+  if (!m_currentServer)
+     rv = AdvanceToNextServer(done);
+  else
+     rv = m_serverEnumerator->Next();
+  if (NS_FAILED(rv))
+    rv = AdvanceToNextServer(done);
 
-  if (hasMore)
+  if (NS_SUCCEEDED(rv) && !*done && m_serverEnumerator)
   {
-    nsCOMPtr<nsISupports> supports;
-    rv = m_serverEnumerator->GetNext(getter_AddRefs(supports));
-    if (NS_SUCCEEDED(rv))
-      m_currentFolder = do_QueryInterface(supports);
+    nsCOMPtr <nsISupports> supports;
+    rv = m_serverEnumerator->CurrentItem(getter_AddRefs(supports));
+    m_currentFolder = do_QueryInterface(supports);
+    *done = false;
   }
-  return m_currentFolder;
+  return rv;
 }
 
 nsresult DownloadMatchingNewsArticlesToNewsDB::RunSearch(nsIMsgFolder *folder, nsIMsgDatabase *newsDB, nsIMsgSearchSession *searchSession)
 {
   m_folder = folder;
   m_newsDB = newsDB;
   m_searchSession = searchSession;
 
@@ -508,30 +508,31 @@ nsresult DownloadMatchingNewsArticlesToN
   nsresult rv = searchSession->AddScopeTerm(nsMsgSearchScope::localNews, folder);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return searchSession->Search(m_window);
 }
 
 nsresult nsMsgDownloadAllNewsgroups::ProcessNextGroup()
 {
+  nsresult rv = NS_OK;
   bool done = false;
 
-  while (!done)
+  while (NS_SUCCEEDED(rv) && !done)
   {
-    done = !AdvanceToNextGroup();
-    if (!done && m_currentFolder)
+    rv = AdvanceToNextGroup(&done);
+    if (m_currentFolder)
     {
       uint32_t folderFlags;
       m_currentFolder->GetFlags(&folderFlags);
       if (folderFlags & nsMsgFolderFlags::Offline)
         break;
     }
   }
-  if (done)
+  if (NS_FAILED(rv) || done)
   {
     if (m_listener)
       return m_listener->OnStopRunningUrl(nullptr, NS_OK);
   }
   m_downloadedHdrsForCurGroup = true;
   return m_currentFolder ? m_currentFolder->GetNewMessages(m_window, this) : NS_ERROR_NOT_INITIALIZED;
 }
 
--- a/mailnews/news/src/nsNewsDownloader.h
+++ b/mailnews/news/src/nsNewsDownloader.h
@@ -100,26 +100,26 @@ public:
   virtual ~nsMsgDownloadAllNewsgroups();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIURLLISTENER
 
   nsresult ProcessNextGroup();
 
 protected:
-  bool     AdvanceToNextServer();
-  bool     AdvanceToNextGroup();
+  nsresult AdvanceToNextServer(bool *done);
+  nsresult AdvanceToNextGroup(bool *done);
   nsresult DownloadMsgsForCurrentGroup();
 
   DownloadMatchingNewsArticlesToNewsDB *m_downloaderForGroup;
 
   nsCOMPtr <nsIMsgFolder> m_currentFolder;
   nsCOMPtr <nsIMsgWindow> m_window;
   nsCOMPtr <nsIArray> m_allServers;
-  nsCOMPtr <nsIArray> m_allFolders;
+  nsCOMPtr <nsISupportsArray> m_allFolders;
   nsCOMPtr <nsIMsgIncomingServer> m_currentServer;
-  nsCOMPtr <nsISimpleEnumerator> m_serverEnumerator;
+  nsCOMPtr <nsIEnumerator> m_serverEnumerator;
   nsCOMPtr <nsIUrlListener> m_listener;
 
   bool m_downloadedHdrsForCurGroup;
 };
 
 #endif