Bug 436089 - Convert nsIMsgFolder::ListDescendents() from nsISupportsArray to nsIArray descendants attribute - TB JS conversions. r=mkmelin
authoraceman <acelists@atlas.sk>
Thu, 07 Feb 2013 12:38:01 -0500
changeset 14825 6b92c81ffe0403033c31b2a0c1ce1c76e0692272
parent 14824 e98ade781a3b90361c7085609deb73bb448b9442
child 14826 fa45b123a36a70427b23578d7ef0a1000ba000aa
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)
reviewersmkmelin
bugs436089
Bug 436089 - Convert nsIMsgFolder::ListDescendents() from nsISupportsArray to nsIArray descendants attribute - TB JS conversions. r=mkmelin
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
--- a/mail/base/modules/MailUtils.js
+++ b/mail/base/modules/MailUtils.js
@@ -324,22 +324,20 @@ var MailUtils =
    *     managed to set the values on all folders, false means we encountered a
    *     problem.
    */
   setStringPropertyOnFolderAndDescendents:
       function MailUtils_setStringPropertyOnFolderAndDescendents(aPropertyName,
                                                                  aPropertyValue,
                                                                  aFolder,
                                                                  aCallback) {
-    // - 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);
+    // 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);
 
     // - 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,21 +229,23 @@ 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() {},
-      ListDescendents: function(descendents) {},
+      descendants: Components.classes["@mozilla.org/array;1"]
+                  .createInstance(Components.interfaces.nsIArray),
+      ListDescendants: function(descendants) {},
       getFolderWithFlags: function(aFlags) null,
       getFoldersWithFlags: function(aFlags)
         Components.classes["@mozilla.org/array;1"]
-                  .createInstance(Components.interfaces.nsIMutableArray),
+                  .createInstance(Components.interfaces.nsIArray),
       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,21 +313,18 @@ 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 rootFolder = server.rootFolder;
-      let allFolders = Cc["@mozilla.org/supports-array;1"]
-                         .createInstance(Ci.nsISupportsArray);
-      rootFolder.ListDescendents(allFolders);
-      let numFolders = allFolders.Count();
+      let allFolders = server.rootFolder.descendants;
+      let numFolders = allFolders.length;
       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,53 +179,47 @@ 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");
-  localArchiveFolder.ListDescendents(allDescendents);
-  let numFolders = allDescendents.Count();
+  let allDescendants = localArchiveFolder.descendants;
   desiredScope = "|" + localArchiveFolder.URI + "|";
-  for each (let f in fixIterator(allDescendents, Ci.nsIMsgFolder))
-    desiredScope += f.URI + "|";
+  for (let folder in fixIterator(allDescendants, Ci.nsIMsgFolder)) {
+    desiredScope += folder.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 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)
+  let allDescendants = folder.descendants;
+  for (let folder in fixIterator(allDescendants, Ci.nsIMsgFolder)) {
+    assert_uri_found(folder.URI, searchScope);
+  }
 }
 
 function assert_folder_and_children_not_in_scope(folder, searchScope)
 {
   let folderURI = "|" + folder.URI + "|";
   assert_uri_not_found(folderURI, 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)
+  let allDescendants = folder.descendants;
+  for (let folder in fixIterator(allDescendants, Ci.nsIMsgFolder)) {
+    assert_uri_not_found(folder.URI, searchScope);
+  }
 }
 
 function assert_uri_found(folderURI, scopeList)
 {
   if (scopeList.indexOf(folderURI) == -1)
     throw new Error("scope " + scopeList + "doesn't contain " + folderURI);
 }