Follow up to bug 542998 (Need option to disable Archiving completely) - address review comments. r=Standard8
authorJim Porter <squibblyflabbetydoo@gmail.com>
Mon, 14 Mar 2011 10:30:19 +0000
changeset 7344 5294592f5499efbff63609a6b5b37dba05be229d
parent 7343 826f11122f66dff4ff2eb36aefcb35a87b876626
child 7345 6fbe19ade0d5fc5e7af5c521fe948378d0426b66
push idunknown
push userunknown
push dateunknown
reviewersStandard8
bugs542998
Follow up to bug 542998 (Need option to disable Archiving completely) - address review comments. r=Standard8
mail/base/content/folderDisplay.js
mail/base/content/mail3PaneWindowCommands.js
mail/base/content/mailWindowOverlay.js
mail/base/content/messageWindow.js
mail/base/content/nsContextMenu.js
mail/base/content/selectionsummaries.js
mailnews/base/src/nsMsgAccountManager.cpp
--- a/mail/base/content/folderDisplay.js
+++ b/mail/base/content/folderDisplay.js
@@ -2021,16 +2021,33 @@ FolderDisplayWidget.prototype = {
     if (!this.view.dbView)
       return null;
 
     let messageArray = this.view.dbView.getURIsForSelection({});
     return messageArray.length ? messageArray : null;
   },
 
   /**
+   * @return true if all the selected messages can be archived, false otherwise.
+   */
+  get canArchiveSelectedMessages() {
+    if (!this.view.dbView)
+      return false;
+
+    if (this.selectedCount == 0)
+      return false;
+    if (!this.displayedFolder || this.displayedFolder.isSpecialFolder(
+          Components.interfaces.nsMsgFolderFlags.Archive, true))
+      return false;
+    return this.selectedMessages.every(function(msg) {
+        return getIdentityForHeader(msg).archiveEnabled;
+      });
+  },
+
+  /**
    * @return true if all the selected messages can be deleted from their
    * folders, false otherwise.
    */
   get canDeleteSelectedMessages() {
     if (!this.view.dbView)
       return false;
 
     let selectedMessages = this.selectedMessages;
--- a/mail/base/content/mail3PaneWindowCommands.js
+++ b/mail/base/content/mail3PaneWindowCommands.js
@@ -373,17 +373,17 @@ var DefaultController =
       case "cmd_viewAllHeader":
       case "cmd_viewNormalHeader":
         return true;
       case "cmd_markAsFlagged":
       case "button_file":
       case "cmd_file":
       case "cmd_archive":
       case "button_archive":
-        return CanArchiveMsg();
+        return gFolderDisplay.canArchiveSelectedMessages;
       case "cmd_markAsJunk":
       case "cmd_markAsNotJunk":
         return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.junk);
       case "cmd_recalculateJunkScore":
         // We're going to take a conservative position here, because we really
         // don't want people running junk controls on folders that are not
         // enabled for junk. The junk type picks up possible dummy message headers,
         // while the runJunkControls will prevent running on XF virtual folders.
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -1524,35 +1524,16 @@ BatchMessageMover.prototype = {
       !iid.equals(Components.interfaces.nsIMsgCopyServiceListener) &&
       !iid.equals(Components.interfaces.nsISupports))
       throw Components.results.NS_ERROR_NO_INTERFACE;
     return this;
   }
 }
 
 /**
- * Checks if the selected messages can be archived. This depends on what folder
- * they're in and whether archiving is enabled for that identity.
- *
- * @return true if all selected messages can be archived, false otherwise
- */
-function CanArchiveMsg()
-{
-  if (gFolderDisplay.selectedCount == 0)
-    return false;
-  if (!gFolderDisplay.displayedFolder ||
-      gFolderDisplay.displayedFolder.isSpecialFolder(
-        Components.interfaces.nsMsgFolderFlags.Archive, true))
-    return false;
-  return gFolderDisplay.selectedMessages.every(function(msg) {
-      return getIdentityForHeader(msg).archiveEnabled;
-    });
-}
-
-/**
  * Archives the selected messages
  *
  * @param event the event that caused us to call this function
  */
 function MsgArchiveSelectedMessages(event)
 {
   let batchMover = new BatchMessageMover();
   batchMover.archiveMessages(gFolderDisplay.selectedMessages);
--- a/mail/base/content/messageWindow.js
+++ b/mail/base/content/messageWindow.js
@@ -822,17 +822,17 @@ var MessageWindowController =
       case "cmd_markAsJunk":
       case "cmd_markAsNotJunk":
         return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.junk);
       case "cmd_recalculateJunkScore":
         return gFolderDisplay.selectedMessage &&
                gFolderDisplay.getCommandStatus(nsMsgViewCommandType.runJunkControls);
       case "cmd_archive":
       case "button_archive":
-        return CanArchiveMsg();
+        return gFolderDisplay.canArchiveSelectedMessages;
       case "cmd_reply":
       case "button_reply":
       case "cmd_replyall":
       case "button_replyall":
         return gFolderDisplay.selectedMessage && IsReplyEnabled();
       case "cmd_replylist":
       case "button_replylist":
         return gFolderDisplay.selectedMessage && IsReplyListEnabled();
--- a/mail/base/content/nsContextMenu.js
+++ b/mail/base/content/nsContextMenu.js
@@ -274,17 +274,17 @@ nsContextMenu.prototype = {
                   this.numSelectedMessages > 1 && this.inThreadPane &&
                   !this.hideMailItems);
 
     this.setSingleSelection("mailContext-copyMessageUrl", this.isNewsgroup);
 
     let msgModifyItems = this.numSelectedMessages > 0 && !this.hideMailItems &&
       !this.onPlayableMedia &&
       !(this.numSelectedMessages == 1 && gMessageDisplay.isDummy);
-    let canArchive = CanArchiveMsg();
+    let canArchive = gFolderDisplay.canArchiveSelectedMessages;
 
     this.showItem("mailContext-archive", canMove && msgModifyItems &&
                                          canArchive);
 
     // Set up the move menu. We can't move from newsgroups.
     this.showItem("mailContext-moveMenu",
                   msgModifyItems && !this.isNewsgroup);
 
--- a/mail/base/content/selectionsummaries.js
+++ b/mail/base/content/selectionsummaries.js
@@ -259,17 +259,17 @@ MultiMessageSummary.prototype = {
     let messagesTitle =
       PluralForm.get(numThreads, gSelectionSummaryStrings["NConversations"])
                 .replace("#1", numThreads);
 
     heading.textContent = messagesTitle;
 
     // enable/disable the archive button as appropriate
     let archiveBtn = htmlpane.contentDocument.getElementById('archive');
-    archiveBtn.collapsed = !CanArchiveMsg();
+    archiveBtn.collapsed = !gFolderDisplay.canArchiveSelectedMessages;
 
     // clear the messages list
     let messagesElt = htmlpane.contentDocument.getElementById('messagelist');
     while (messagesElt.firstChild)
       messagesElt.removeChild(messagesElt.firstChild);
 
     const MAX_MESSAGES = 100;
     const SNIPPET_LENGTH = 300;
@@ -553,17 +553,17 @@ ThreadSummary.prototype = {
        + " "
        + PluralForm.get(numMessages, gSelectionSummaryStrings["Nmessages"]).replace('#1', numMessages);
     let heading = htmlpane.contentDocument.getElementById('heading');
     heading.setAttribute("class", "heading");
     heading.textContent = subject;
 
     // enable/disable the archive button as appropriate
     let archiveBtn = htmlpane.contentDocument.getElementById('archive');
-    archiveBtn.collapsed = !CanArchiveMsg();
+    archiveBtn.collapsed = !gFolderDisplay.canArchiveSelectedMessages;
 
     let messagesElt = htmlpane.contentDocument.getElementById('messagelist');
     while (messagesElt.firstChild)
       messagesElt.removeChild(messagesElt.firstChild);
 
     let headerParser = Components.classes["@mozilla.org/messenger/headerparser;1"]
                                     .getService(Components.interfaces.nsIMsgHeaderParser);
     let count = 0;
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -1535,20 +1535,17 @@ nsMsgAccountManager::SetSpecialFolders()
           rv = folder->GetParent(getter_AddRefs(parent));
           if (NS_SUCCEEDED(rv) && parent)
           {
             PRBool archiveEnabled;
             thisIdentity->GetArchiveEnabled(&archiveEnabled);
             if (archiveEnabled)
               rv = folder->SetFlag(nsMsgFolderFlags::Archive);
             else
-            {
-              printf("Clearing archive flag\n");
               rv = folder->ClearFlag(nsMsgFolderFlags::Archive);
-            }
           }
         }
       }
       thisIdentity->GetStationeryFolder(folderUri);
       if (!folderUri.IsEmpty() && NS_SUCCEEDED(rdf->GetResource(folderUri, getter_AddRefs(res))))
       {
         folder = do_QueryInterface(res, &rv);
         if (folder && NS_SUCCEEDED(rv))