Bug 727851 - Use getSpecialFolderString() in folderWidgets.xml._setCssSelectors. r=bienvenu
authoraceman <acelists@atlas.sk>
Tue, 21 Feb 2012 15:33:47 +0000
changeset 10895 d182f15b6b63386ea9c5df69abd3128765768c27
parent 10894 9a19110c96ccf9990f4513be9eafcaa8af8a9877
child 10896 1882581fa8584d2a429eb26f76a542b634a71f4a
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu
bugs727851
Bug 727851 - Use getSpecialFolderString() in folderWidgets.xml._setCssSelectors. r=bienvenu
mailnews/base/content/folderWidgets.xml
mailnews/base/util/folderUtils.jsm
--- a/mailnews/base/content/folderWidgets.xml
+++ b/mailnews/base/content/folderWidgets.xml
@@ -681,43 +681,25 @@
          -
          - @param aFolder    the folder that corresponds to the menu/menuitem
          - @param aMenuNode  the actual DOM node to set attributes on
         -->
       <method name="_setCssSelectors">
         <parameter name="aFolder"/>
         <parameter name="aMenuNode"/>
         <body><![CDATA[
-          const Ci = Components.interfaces;
+          Components.utils.import("resource:///modules/folderUtils.jsm");
           // First set the SpecialFolder attribute
-          if (aFolder.flags & Ci.nsMsgFolderFlags.Inbox)
-            aMenuNode.setAttribute("SpecialFolder", "Inbox");
-          else if (aFolder.flags & Ci.nsMsgFolderFlags.Trash)
-            aMenuNode.setAttribute("SpecialFolder", "Trash");
-          else if (aFolder.flags & Ci.nsMsgFolderFlags.Queue)
-            aMenuNode.setAttribute("SpecialFolder", "Outbox");
-          else if (aFolder.flags & Ci.nsMsgFolderFlags.SentMail)
-            aMenuNode.setAttribute("SpecialFolder", "Sent");
-          else if (aFolder.flags & Ci.nsMsgFolderFlags.Drafts)
-            aMenuNode.setAttribute("SpecialFolder", "Drafts");
-          else if (aFolder.flags & Ci.nsMsgFolderFlags.Templates)
-            aMenuNode.setAttribute("SpecialFolder", "Templates");
-          else if (aFolder.flags & Ci.nsMsgFolderFlags.Junk)
-            aMenuNode.setAttribute("SpecialFolder", "Junk");
-          else if (aFolder.flags & Ci.nsMsgFolderFlags.Archive)
-            aMenuNode.setAttribute("SpecialFolder", "Archive");
-          else if (aFolder.flags & Ci.nsMsgFolderFlags.Virtual)
-            aMenuNode.setAttribute("SpecialFolder", "Virtual");
-          else
-            aMenuNode.setAttribute("SpecialFolder", "none");
+          aMenuNode.setAttribute("SpecialFolder", getSpecialFolderString(aFolder));
 
           // Now set the biffState
-          var biffStates = ["NewMail", "NoMail", "UnknownMail"];
-          for each (var state in biffStates) {
-            if (aFolder.biffState == Ci.nsIMsgFolder["nsMsgBiffState_" + state]) {
+          let biffStates = ["NewMail", "NoMail", "UnknownMail"];
+          for each (let state in biffStates) {
+            if (aFolder.biffState ==
+                Components.interfaces.nsIMsgFolder["nsMsgBiffState_" + state]) {
               aMenuNode.setAttribute("BiffState", state);
               break;
             }
           }
 
           aMenuNode.setAttribute("IsServer", aFolder.isServer);
           aMenuNode.setAttribute("IsSecure", aFolder.server.isSecure);
           aMenuNode.setAttribute("ServerType", aFolder.server.type);
--- a/mailnews/base/util/folderUtils.jsm
+++ b/mailnews/base/util/folderUtils.jsm
@@ -39,17 +39,17 @@
  */
 
 var EXPORTED_SYMBOLS = ["setPropertyAtoms", "getSpecialFolderString",
                         "getFolderFromUri"];
 
 /**
  * Returns a string representation of a folder's "special" type
  *
- * @param aFolder  the folder whose special type should be returned
+ * @param aFolder  the nsIMsgFolder whose special type should be returned
  */
 function getSpecialFolderString(aFolder) {
   const Ci = Components.interfaces;
   if (aFolder.flags & Ci.nsMsgFolderFlags.Inbox)
     return "Inbox";
   if (aFolder.flags & Ci.nsMsgFolderFlags.Trash)
     return "Trash";
   if (aFolder.flags & Ci.nsMsgFolderFlags.Queue)