From fd06ef06ef7b8bad1a4936cf280808a760bd949c Mon Sep 17 00:00:00 2001 From: "bugzilla%standard8.plus.com" Date: Thu, 8 May 2008 18:46:39 +0000 Subject: [PATCH] Bug 420614 Drop nsAdapterEnumerator (finish replacing subFoldersObsolete in js files) r=philor,sr=Neil --- mail/base/content/mailContextMenus.js | 17 +--- .../newsblog/content/feed-subscriptions.js | 70 +++++---------- .../base/resources/content/mailCommands.js | 17 ++-- .../resources/content/mailContextMenus.js | 18 ++-- .../resources/content/msgViewNavigation.js | 17 +--- .../search/resources/content/SearchDialog.js | 88 +++++++------------ 6 files changed, 70 insertions(+), 157 deletions(-) diff --git a/mail/base/content/mailContextMenus.js b/mail/base/content/mailContextMenus.js index c27f1a48b39..8649cca2c9a 100644 --- a/mail/base/content/mailContextMenus.js +++ b/mail/base/content/mailContextMenus.js @@ -446,32 +446,23 @@ function OpenMessageByHeader(messageHeader, openInNewWindow) function SearchForMessageIdInSubFolder(folder, messageId) { var messageHeader; - var subFolders = folder.subFoldersObsolete; + var subFolders = folder.subFolders; // search in folder if (!folder.isServer) messageHeader = CheckForMessageIdInFolder(folder, messageId); // search subfolders recursively - var done = !folder.hasSubFolders; - while (!done && !messageHeader) + while (subFolders.hasMoreElements() && !messageHeader) { // search in current folder - var currentFolder = subFolders.currentItem().QueryInterface(Components.interfaces.nsIMsgFolder); + var currentFolder = + subFolders.getNext().QueryInterface(Components.interfaces.nsIMsgFolder); messageHeader = CheckForMessageIdInFolder(currentFolder, messageId); // search in its subfolder if (!messageHeader && currentFolder.hasSubFolders) messageHeader = SearchForMessageIdInSubFolder(currentFolder, messageId); - - try - { - subFolders.next(); - } - catch(e) - { - done = true; - } } return messageHeader; diff --git a/mail/extensions/newsblog/content/feed-subscriptions.js b/mail/extensions/newsblog/content/feed-subscriptions.js index 47b67964849..7876d2a20b1 100644 --- a/mail/extensions/newsblog/content/feed-subscriptions.js +++ b/mail/extensions/newsblog/content/feed-subscriptions.js @@ -355,24 +355,13 @@ var gFeedSubscriptionsWindow = { container: true }; // if a feed has any sub folders, we should add them to the list of children - if (aFolder.hasSubFolders) + var folderEnumerator = aFolder.subFolders; + + while (folderEnumerator.hasMoreElements()) { - var folderEnumerator = aFolder.subFoldersObsolete; - var done = false; - - while (!done) - { - var folder = folderEnumerator.currentItem().QueryInterface(Components.interfaces.nsIMsgFolder); - folderObject.children.push(this.makeFolderObject(folder, aCurrentLevel + 1)); - - try { - folderEnumerator.next(); - } - catch (ex) - { - done = true; - } - } + var folder = + folderEnumerator.getNext().QueryInterface(Components.interfaces.nsIMsgFolder); + folderObject.children.push(this.makeFolderObject(folder, aCurrentLevel + 1)); } var feeds = this.getFeedsInFolder(aFolder); @@ -430,27 +419,16 @@ var gFeedSubscriptionsWindow = { var numFolders = 0; this.mFeedContainers = []; - if (this.mRSSServer.rootFolder.hasSubFolders) + var folderEnumerator = this.mRSSServer.rootFolder.subFolders; + + while (folderEnumerator.hasMoreElements()) { - var folderEnumerator = this.mRSSServer.rootFolder.subFoldersObsolete; - var done = false; - - while (!done) + var folder = folderEnumerator.getNext() + .QueryInterface(Components.interfaces.nsIMsgFolder); + if (!folder.getFlag(MSG_FOLDER_FLAG_TRASH)) { - var folder = folderEnumerator.currentItem().QueryInterface(Components.interfaces.nsIMsgFolder); - if (folder && !folder.getFlag(MSG_FOLDER_FLAG_TRASH)) - { - this.mFeedContainers.push(this.makeFolderObject(folder, 0)); - numFolders++; - } - - try { - folderEnumerator.next(); - } - catch (ex) - { - done = true; - } + this.mFeedContainers.push(this.makeFolderObject(folder, 0)); + numFolders++; } } this.mView.mRowCount = numFolders; @@ -942,21 +920,21 @@ var gFeedSubscriptionsWindow = { generateOutline: function(baseFolder, parent, indentLevel) { - var folderEnumerator = baseFolder.subFoldersObsolete; - var done = false; + var folderEnumerator = baseFolder.subFolders; // pretty printing var indentString = ""; for(i = 0; i < indentLevel; i++) indentString = indentString + " "; - while (!done) + while (folderEnumerator.hasMoreElements()) { - var folder = folderEnumerator.currentItem().QueryInterface(Components.interfaces.nsIMsgFolder); - if (folder && !folder.getFlag(MSG_FOLDER_FLAG_TRASH)) + var folder = folderEnumerator.getNext() + .QueryInterface(Components.interfaces.nsIMsgFolder); + if (!folder.getFlag(MSG_FOLDER_FLAG_TRASH)) { var outline; - if(folder.hasSubFolders) + if (folder.hasSubFolders) { // Make a mostly empty outline element outline = parent.ownerDocument.createElement("outline"); @@ -978,14 +956,6 @@ var gFeedSubscriptionsWindow = { } } } - - try { - folderEnumerator.next(); - } - catch (ex) - { - done = true; - } } }, diff --git a/mailnews/base/resources/content/mailCommands.js b/mailnews/base/resources/content/mailCommands.js index 4f19a55dbb2..a00380669f1 100644 --- a/mailnews/base/resources/content/mailCommands.js +++ b/mailnews/base/resources/content/mailCommands.js @@ -754,18 +754,13 @@ function deleteAllInFolder(commandName) .createInstance(Components.interfaces.nsISupportsArray); // Delete sub-folders. - var iter = folder.subFoldersObsolete; - while (true) { - try { - children.AppendElement(iter.currentItem()); - iter.next(); - } catch (ex) { - break; - } - } - for (var i = 0; i < children.Count(); ++i) { + var iter = folder.subFolders; + while (iter.hasMoreElements()) + children.AppendElement(iter.getNext()); + + for (var i = 0; i < children.Count(); ++i) folder.propagateDelete(children.GetElementAt(i), true, msgWindow); - } + children.Clear(); // Delete messages. diff --git a/mailnews/base/resources/content/mailContextMenus.js b/mailnews/base/resources/content/mailContextMenus.js index 6defa986c65..26bebbfe47f 100644 --- a/mailnews/base/resources/content/mailContextMenus.js +++ b/mailnews/base/resources/content/mailContextMenus.js @@ -734,32 +734,24 @@ function OpenMessageByHeader(messageHeader, openInNewWindow) function SearchForMessageIdInSubFolder(folder, messageId) { var messageHeader; - var subFolders = folder.subFoldersObsolete; + var subFolders = folder.subFolders; // search in folder if (!folder.isServer) messageHeader = CheckForMessageIdInFolder(folder, messageId); // search subfolders recursively - var done = !folder.hasSubFolders; - while (!done && !messageHeader) + while (subFolders.hasMoreElements() && !messageHeader) { // search in current folder - var currentFolder = subFolders.currentItem().QueryInterface(Components.interfaces.nsIMsgFolder); + var currentFolder = + subFolders.getNext().QueryInterface(Components.interfaces.nsIMsgFolder); + messageHeader = CheckForMessageIdInFolder(currentFolder, messageId); // search in its subfolder if (!messageHeader && currentFolder.hasSubFolders) messageHeader = SearchForMessageIdInSubFolder(currentFolder, messageId); - - try - { - subFolders.next(); - } - catch(e) - { - done = true; - } } return messageHeader; diff --git a/mailnews/base/resources/content/msgViewNavigation.js b/mailnews/base/resources/content/msgViewNavigation.js index 83ee2c107a6..be0edd23220 100644 --- a/mailnews/base/resources/content/msgViewNavigation.js +++ b/mailnews/base/resources/content/msgViewNavigation.js @@ -96,22 +96,13 @@ function compareFolderSortKey(folder1, folder2) function GetSubFoldersInFolderPaneOrder(folder) { - var subFolderEnumerator = folder.subFoldersObsolete; - var done = false; + var subFolders = folder.subFolders; var msgFolders = Array(); // get all the subfolders - while (!done) { - try { - var element = subFolderEnumerator.currentItem(); - var msgFolder = element.QueryInterface(Components.interfaces.nsIMsgFolder); - msgFolders[msgFolders.length] = msgFolder; - - subFolderEnumerator.next(); - } - catch (ex) { - done = true; - } + while (subFolders.hasMoreElements()) { + msgFolders[msgFolders.length] = + subFolders.getNext().QueryInterface(Components.interfaces.nsIMsgFolder); } // sort the subfolders diff --git a/mailnews/base/search/resources/content/SearchDialog.js b/mailnews/base/search/resources/content/SearchDialog.js index 3cbc6c93770..5c4e27cfc9c 100644 --- a/mailnews/base/search/resources/content/SearchDialog.js +++ b/mailnews/base/search/resources/content/SearchDialog.js @@ -437,31 +437,18 @@ function onSearch() } function AddSubFolders(folder) { - if (folder.hasSubFolders) + var subFolders = folder.subFolders; + while (subFolders.hasMoreElements()) { - var subFolderEnumerator = folder.subFoldersObsolete; - var done = false; - while (!done) + var nextFolder = + subFolders.getNext().QueryInterface(Components.interfaces.nsIMsgFolder); + + if (!(nextFolder.flags & MSG_FOLDER_FLAG_VIRTUAL)) { - var next = subFolderEnumerator.currentItem(); - if (next) - { - var nextFolder = next.QueryInterface(Components.interfaces.nsIMsgFolder); - if (nextFolder && ! (nextFolder.flags & MSG_FOLDER_FLAG_VIRTUAL)) - { - if (!nextFolder.noSelect) - gSearchSession.addScopeTerm(GetScopeForFolder(nextFolder), nextFolder); - AddSubFolders(nextFolder); - } - } - try - { - subFolderEnumerator.next(); - } - catch (ex) - { - done = true; - } + if (!nextFolder.noSelect) + gSearchSession.addScopeTerm(GetScopeForFolder(nextFolder), nextFolder); + + AddSubFolders(nextFolder); } } } @@ -469,42 +456,29 @@ function AddSubFolders(folder) { function AddSubFoldersToURI(folder) { var returnString = ""; - if (folder.hasSubFolders) - { - var subFolderEnumerator = folder.subFoldersObsolete; - var done = false; - while (!done) - { - var next = subFolderEnumerator.currentItem(); - if (next) - { - var nextFolder = next.QueryInterface(Components.interfaces.nsIMsgFolder); - if (nextFolder && ! (nextFolder.flags & MSG_FOLDER_FLAG_VIRTUAL)) - { - if (!nextFolder.noSelect && !nextFolder.isServer) - { - if (returnString.length > 0) - returnString += '|'; - returnString += nextFolder.URI; - } - var subFoldersString = AddSubFoldersToURI(nextFolder); - if (subFoldersString.length > 0) - { - if (returnString.length > 0) - returnString += '|'; - returnString += subFoldersString; - } - } - } - try + var subFolders = folder.subFolders; + + while (subFolders.hasMoreElements()) + { + var nextFolder = + subFolders.getNext().QueryInterface(Components.interfaces.nsIMsgFolder); + + if (!(nextFolder.flags & MSG_FOLDER_FLAG_VIRTUAL)) + { + if (!nextFolder.noSelect && !nextFolder.isServer) { - subFolderEnumerator.next(); - } - catch (ex) - { - done = true; - } + if (returnString.length > 0) + returnString += '|'; + returnString += nextFolder.URI; + } + var subFoldersString = AddSubFoldersToURI(nextFolder); + if (subFoldersString.length > 0) + { + if (returnString.length > 0) + returnString += '|'; + returnString += subFoldersString; + } } } return returnString;