Bug 92846 - Disable File | Subscribe menu when no subscribable account is available - Seamonkey part. r=IanN a=Ratty CLOSED TREE
authoraceman <acelists@atlas.sk>
Mon, 23 Nov 2015 22:24:29 +0100
changeset 18629 075959e1c6049a21ebeab8fbc01e757a8d6d5d32
parent 18628 f99e915e6daceac01bcf365a8b192eba558c8445
child 18630 c2b70a33a5fafe79bd786bbdefc7cbe48aa647f0
push id11408
push useracelists@atlas.sk
push dateMon, 23 Nov 2015 21:38:00 +0000
treeherdercomm-central@faf62f115efe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, Ratty
bugs92846
Bug 92846 - Disable File | Subscribe menu when no subscribable account is available - Seamonkey part. r=IanN a=Ratty CLOSED TREE
suite/mailnews/mail3PaneWindowCommands.js
suite/mailnews/mailWindowOverlay.xul
--- a/suite/mailnews/mail3PaneWindowCommands.js
+++ b/suite/mailnews/mail3PaneWindowCommands.js
@@ -150,17 +150,18 @@ var DefaultController =
       case "cmd_viewIgnoredThreads":
       case "cmd_stop":
       case "cmd_undo":
       case "cmd_redo":
 			case "cmd_expandAllThreads":
 			case "cmd_collapseAllThreads":
 			case "cmd_renameFolder":
 			case "cmd_sendUnsentMsgs":
-			case "cmd_openMessage":
+      case "cmd_subscribe":
+      case "cmd_openMessage":
       case "button_print":
 			case "cmd_print":
 			case "cmd_printpreview":
 			case "cmd_printSetup":
 			case "cmd_saveAsFile":
 			case "cmd_saveAsTemplate":
       case "cmd_properties":
 			case "cmd_viewPageSource":
@@ -410,16 +411,18 @@ var DefaultController =
         return true;
       case "cmd_undo":
       case "cmd_redo":
           return SetupUndoRedoCommand(command);
       case "cmd_renameFolder":
         return IsRenameFolderEnabled();
       case "cmd_sendUnsentMsgs":
         return IsSendUnsentMsgsEnabled(null);
+      case "cmd_subscribe":
+        return IsSubscribeEnabled();
       case "cmd_properties":
         return IsPropertiesEnabled(command);
       case "button_getNewMessages":
       case "cmd_getNewMessages":
       case "cmd_getMsgsForAuthAccounts":
         return IsGetNewMessagesEnabled();
       case "cmd_getNextNMessages":
         return IsGetNextNMessagesEnabled();
@@ -589,22 +592,25 @@ var DefaultController =
                 gDBView.doCommand(nsMsgViewCommandType.collapseAll);
 				break;
 			case "cmd_renameFolder":
 				MsgRenameFolder();
 				return;
 			case "cmd_sendUnsentMsgs":
 				MsgSendUnsentMsgs();
 				return;
-			case "cmd_openMessage":
-                MsgOpenSelectedMessages();
-				return;
-            case "cmd_printSetup":
-                PrintUtils.showPageSetup();
-                return;
+      case "cmd_subscribe":
+        MsgSubscribe();
+        return;
+      case "cmd_openMessage":
+        MsgOpenSelectedMessages();
+        return;
+      case "cmd_printSetup":
+        PrintUtils.showPageSetup();
+        return;
 			case "cmd_print":
 				PrintEnginePrint();
 				return;
 			case "cmd_printpreview":
 				PrintEnginePrintPreview();
 				return;
 			case "cmd_saveAsFile":
 				MsgSaveAsFile();
@@ -844,16 +850,39 @@ function IsSendUnsentMsgsEnabled(folderR
   if (!identity)
     identity = Components.classes["@mozilla.org/messenger/account-manager;1"]
                          .getService(Components.interfaces.nsIMsgAccountManager)
                          .defaultAccount.defaultIdentity;
 
   return msgSendLater.hasUnsentMessages(identity);
 }
 
+/**
+ * Determine whether there exists any server for which to show the Subscribe dialog.
+ */
+function IsSubscribeEnabled()
+{
+  // If there are any IMAP or News servers, we can show the dialog any time and
+  // it will properly show those.
+  let servers = accountManager.allServers;
+  for (let server of fixIterator(servers,
+                                 Components.interfaces.nsIMsgIncomingServer)) {
+    if (server.type == "imap" || server.type == "nntp")
+      return true;
+  }
+
+  // RSS accounts use a separate Subscribe dialog that we can only show when
+  // such an account is selected.
+  let preselectedFolder = GetFirstSelectedMsgFolder();
+  if (preselectedFolder && preselectedFolder.server.type == "rss")
+    return true;
+
+  return false;
+}
+
 function IsRenameFolderEnabled()
 {
   let folders = GetSelectedMsgFolders();
   return folders.length == 1 && folders[0].canRename &&
          isCommandEnabled("cmd_renameFolder");
 }
 
 function IsCanSearchMessagesEnabled()
--- a/suite/mailnews/mailWindowOverlay.xul
+++ b/suite/mailnews/mailWindowOverlay.xul
@@ -100,16 +100,17 @@
     <command id="cmd_printSetup" oncommand="goDoCommand('cmd_printSetup')" disabled="true"/>
     <command id="cmd_print" oncommand="goDoCommand('cmd_print')" disabled="true"/>
     <command id="cmd_printpreview" oncommand="goDoCommand('cmd_printpreview')" disabled="true"/>
     <command id="cmd_saveAsFile" oncommand="goDoCommand('cmd_saveAsFile')" disabled="true"/>
     <command id="cmd_saveAsTemplate" oncommand="goDoCommand('cmd_saveAsTemplate')" disabled="true"/>
     <command id="cmd_getNextNMessages" oncommand="goDoCommand('cmd_getNextNMessages')" disabled="true"/>
     <command id="cmd_renameFolder" oncommand="goDoCommand('cmd_renameFolder')" />
     <command id="cmd_sendUnsentMsgs" oncommand="goDoCommand('cmd_sendUnsentMsgs')" />
+    <command id="cmd_subscribe" oncommand="goDoCommand('cmd_subscribe')" disabled="true"/>
     <command id="cmd_synchronizeOffline" oncommand="goDoCommand('cmd_synchronizeOffline');" disabled="true"/>
     <command id="cmd_settingsOffline" oncommand="goDoCommand('cmd_settingsOffline');" disabled="true"/>
 </commandset>
 
 <commandset id="mailCommands">
   <command id="cmd_newNavigator"/>
   <command id="cmd_newPrivateWindow"/>
   <command id="cmd_newEditor"/>
@@ -996,18 +997,18 @@
         </menu>
       <menuitem id="menu_getnextnmsg" label="&getNextNMsgCmd.label;"
        accesskey="&getNextNMsgCmd.accesskey;"
        command="cmd_getNextNMessages"/>
       <menuitem id="menu_sendunsentmsgs" label="&sendUnsentCmd.label;"
        accesskey="&sendUnsentCmd.accesskey;"
        command="cmd_sendUnsentMsgs"/>
       <menuitem label="&subscribeCmd.label;"
-       accesskey="&subscribeCmd.accesskey;"
-       oncommand="MsgSubscribe();"/>
+                accesskey="&subscribeCmd.accesskey;"
+                command="cmd_subscribe"/>
       <menuseparator id="fileMenuAfterSubscribeSeparator"/>
       <menuitem id="menu_renameFolder" label="&renameFolder.label;"
                 accesskey="&renameFolder.accesskey;"
                 command="cmd_renameFolder"
                 observes="mailHideMenus"/>
       <menuitem id="menu_compactFolder" label="&compactFolders.label;"
                 accesskey="&compactFolders.accesskey;"
                 command="cmd_compactFolder"