Back out part of bug 418490 due to causing regressions in reply button, and empty junk/trash folders (bug 462121).
authorMark Banner <bugzilla@standard8.plus.com>
Wed, 29 Oct 2008 11:10:11 +0000
changeset 761 a0c1355972f5a9b2ed34f65cb9b8bb2bdcad16f8
parent 760 043bc1d53edbfa2c216a8f763f13510521223cdd
child 762 2086f5b7fb2a1adaf7cc0c159c74d6307dee908d
push idunknown
push userunknown
push dateunknown
bugs418490, 462121
Back out part of bug 418490 due to causing regressions in reply button, and empty junk/trash folders (bug 462121).
mail/base/content/mailCommands.js
--- a/mail/base/content/mailCommands.js
+++ b/mail/base/content/mailCommands.js
@@ -31,18 +31,16 @@
 # use your version of this file under the terms of the MPL, indicate your
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
-Components.utils.import("resource://gre/modules/iteratorUtils.jsm");
-
 var gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
                       .getService(Components.interfaces.nsIPromptService);
 
 function GetNewMessages(selectedFolders, server)
 {
   if (!selectedFolders.length)
     return;
 
@@ -57,30 +55,32 @@ function GetNewMessages(selectedFolders,
   }
   server.getNewMessages(msgFolder, msgWindow, null);
 }
 
 function getBestIdentity(identities, optionalHint)
 {
   var identity = null;
 
+  var identitiesCount = identities.Count();
+
   try
   {
     // if we have more than one identity and a hint to help us pick one
     if (identitiesCount > 1 && optionalHint) {
       // normalize case on the optional hint to improve our chances of finding a match
       optionalHint = optionalHint.toLowerCase();
 
       var id;
       // iterate over all of the identities
       var tempID;
 
-      const nsIMsgIdentity = Components.interfaces.nsIMsgIdentity;
       var lengthOfLongestMatchingEmail = 0;
-      for each (var tempID in fixIterator(identities, nsIMsgIdentity)) {
+      for (id = 0; id < identitiesCount; ++id) {
+        tempID = identities.GetElementAt(id).QueryInterface(Components.interfaces.nsIMsgIdentity);
         if (optionalHint.indexOf(tempID.email.toLowerCase()) >= 0) {
           // Be careful, the user can have several adresses with the same
           // postfix e.g. aaa.bbb@ccc.ddd and bbb@ccc.ddd. Make sure we get the
           // longest match.
           if (tempID.email.length > lengthOfLongestMatchingEmail) {
             identity = tempID;
             lengthOfLongestMatchingEmail = tempID.email.length;
           }
@@ -91,17 +91,18 @@ function getBestIdentity(identities, opt
       // was to a mailing list. In this scenario, we won't have a match based on email address.
       // Before we just give up, try and search for just a shared domain between the hint and
       // the email addresses for our identities. Hey, it is better than nothing and in the case
       // of multiple matches here, we'll end up picking the first one anyway which is what we would have done
       // if we didn't do this second search. This helps the case for corporate users where mailing lists will have the same domain
       // as one of your multiple identities.
 
       if (!identity) {
-        for each (var tempID in fixIterator(identities, nsIMsgIdentity)) {
+        for (id = 0; id < identitiesCount; ++id) {
+          tempID = identities.GetElementAt(id).QueryInterface(Components.interfaces.nsIMsgIdentity);
           // extract out the partial domain
           var start = tempID.email.lastIndexOf("@"); // be sure to include the @ sign in our search to reduce the risk of false positives
           if (optionalHint.search(tempID.email.slice(start).toLowerCase()) >= 0) {
             identity = tempID;
             break;
           }
         }
       }
@@ -492,14 +493,16 @@ function deleteAllInFolder(commandName)
   var iter = folder.subFolders;
   while (iter.hasMoreElements())
     folder.propagateDelete(iter.getNext(), true, msgWindow);
 
   var children = Components.classes["@mozilla.org/array;1"]
                   .createInstance(Components.interfaces.nsIMutableArray);
   
   // Delete messages.
-  var messages = [m for each (m in fixIterator(folder.getMessages(msgWindow)))];
-  var children = toXPCOMArray(messages, Components.interfaces.nsISupportsArray);
+  iter = folder.getMessages(msgWindow);
+  while (iter.hasMoreElements()) {
+    children.appendElement(iter.getNext(), false);
+  }
   folder.deleteMessages(children, msgWindow, true, false, null, false); 
   children.clear();                                       
 }