Bug 1124105 part 3 - add user interface, r=mkmelin
authorR Kent James <rkent@caspia.com>
Thu, 19 Feb 2015 16:41:39 -0800
changeset 22395 b77afc91af46acdffe308da9659fd88fe1019c43
parent 22394 e11c5540e2336a79dc45aedab4e9889f9ac1778c
child 22396 ad83df67025a2afec65a7ed3ac825c61bde5a3e5
push id223
push usermbanner@mozilla.com
push dateMon, 11 May 2015 19:42:01 +0000
reviewersmkmelin
bugs1124105
Bug 1124105 part 3 - add user interface, r=mkmelin
mail/components/preferences/advanced.js
mail/components/preferences/advanced.xul
mail/locales/en-US/chrome/messenger/am-server-top.dtd
mail/locales/en-US/chrome/messenger/preferences/advanced.dtd
mailnews/base/prefs/content/am-server.js
mailnews/base/prefs/content/am-server.xul
mailnews/base/prefs/content/am-serverwithnoidentities.js
mailnews/base/prefs/content/am-serverwithnoidentities.xul
--- a/mail/components/preferences/advanced.js
+++ b/mail/components/preferences/advanced.js
@@ -22,16 +22,23 @@ var gAdvancedPane = {
       let preference = document.getElementById("mail.preferences.advanced.selectedTabIndex");
       if (preference.value)
         document.getElementById("advancedPrefs").selectedIndex = preference.value;
     }
 #ifdef MOZ_UPDATER
     this.updateReadPrefs();
 #endif
 
+    // Default store type initialization.
+    let storeTypeElement = document.getElementById("storeTypeMenulist");
+    // set the menuitem to match the account
+    let defaultStoreID = Services.prefs.getCharPref("mail.serverDefaultStoreContractID");
+    let targetItem = storeTypeElement.getElementsByAttribute("value", defaultStoreID);
+    storeTypeElement.selectedItem = targetItem[0];
+
 #ifdef MOZ_CRASHREPORTER
     this.initSubmitCrashes();
 #endif
     this.initTelemetry();
 
     // Search integration -- check whether we should hide or disable integration
     let hideSearchUI = false;
     let disableSearchUI = false;
@@ -121,16 +128,24 @@ var gAdvancedPane = {
       gSubDialog.open("chrome://global/content/config.xul");
     } else {
       document.documentElement.openWindow("Preferences:ConfigManager",
                                           "chrome://global/content/config.xul",
                                           "", null);
     }
   },
 
+  /**
+   * Set the default store contract ID.
+   */
+  updateDefaultStore: function(storeID)
+  {
+    Services.prefs.setCharPref("mail.serverDefaultStoreContractID", storeID);
+  },
+
   // NETWORK TAB
 
   /*
    * Preferences:
    *
    * browser.cache.disk.capacity
    * - the size of the browser cache in KB
    */
--- a/mail/components/preferences/advanced.xul
+++ b/mail/components/preferences/advanced.xul
@@ -212,16 +212,32 @@ type="int"/>
             <caption label="&configEditDesc.label;"/>
             <vbox>
               <hbox>
                 <checkbox id="enableGloda"
                           preference="mailnews.database.global.indexer.enabled"
                           label="&enableGlodaSearch.label;"
                           accesskey="&enableGlodaSearch.accesskey;"/>
               </hbox>
+              <hbox align="center">
+                <label value="&storeType.label;"
+                       accesskey="&storeType.accesskey;"
+                       control="storeTypeMenulist"/>
+                <menulist id="storeTypeMenulist"
+                          oncommand="gAdvancedPane.updateDefaultStore(this.selectedItem.value)">
+                  <menupopup id="storeTypeMenupopup">
+                    <menuitem id="mboxStore"
+                              label="&mboxStore.label;"
+                              value="@mozilla.org/msgstore/berkeleystore;1"/>
+                    <menuitem id="maildirStore"
+                              label="&maildirStore.label;"
+                              value="@mozilla.org/msgstore/maildirstore;1"/>
+                  </menupopup>
+                </menulist>
+              </hbox>
               <hbox>
                 <checkbox id="allowHWAccel"
                           label="&allowHWAccel.label;"
                           accesskey="&allowHWAccel.accesskey;"
                           preference="layers.acceleration.disabled"/>
               </hbox>
             </vbox>
             <vbox>
--- a/mail/locales/en-US/chrome/messenger/am-server-top.dtd
+++ b/mail/locales/en-US/chrome/messenger/am-server-top.dtd
@@ -79,8 +79,12 @@
 <!ENTITY localFolderPicker.label "Select Local Directory">
 <!ENTITY browseFolder.label "Browse…">
 <!ENTITY browseFolder.accesskey "B">
 <!ENTITY browseNewsrc.label "Browse…">
 <!ENTITY browseNewsrc.accesskey "e">
 
 <!ENTITY accountTitle.label "Account Settings">
 <!ENTITY accountSettingsDesc.label "The following is a special account.  There are no identities associated with it.">
+<!ENTITY storeType.label "Message Store Type:">
+<!ENTITY storeType.accesskey "T">
+<!ENTITY mboxStore.label "One large file (mbox)">
+<!ENTITY maildirStore.label "File per message (maildir)">
--- a/mail/locales/en-US/chrome/messenger/preferences/advanced.dtd
+++ b/mail/locales/en-US/chrome/messenger/preferences/advanced.dtd
@@ -9,16 +9,20 @@
 <!ENTITY itemNetworking.label    "Network &amp; Disk Space">
 <!ENTITY itemCertificates.label  "Certificates">
 
 <!-- General Settings -->
 <!ENTITY enableGlodaSearch.label       "Enable Global Search and Indexer">
 <!ENTITY enableGlodaSearch.accesskey   "E">
 <!ENTITY allowHWAccel.label            "Use hardware acceleration when available">
 <!ENTITY allowHWAccel.accesskey        "h">
+<!ENTITY storeType.label               "Message Store Type for new accounts:">
+<!ENTITY storeType.accesskey           "T">
+<!ENTITY mboxStore.label               "One large file (mbox)">
+<!ENTITY maildirStore.label            "File per message (maildir)">
 
 <!ENTITY scrolling.label               "Scrolling">
 <!ENTITY useAutoScroll.label           "Use autoscrolling">
 <!ENTITY useAutoScroll.accesskey       "U">
 <!ENTITY useSmoothScrolling.label      "Use smooth scrolling">
 <!ENTITY useSmoothScrolling.accesskey  "m">
 
 <!ENTITY systemIntegration.label       "System Integration">
--- a/mailnews/base/prefs/content/am-server.js
+++ b/mailnews/base/prefs/content/am-server.js
@@ -4,31 +4,51 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 Components.utils.import("resource:///modules/iteratorUtils.jsm");
 Components.utils.import("resource:///modules/MailUtils.js");
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 var gServer;
 
+function onSave()
+{
+  let storeContractID = document.getElementById("server.storeTypeMenulist")
+                                .selectedItem
+                                .value;
+  document.getElementById("server.storeContractID")
+          .setAttribute("value", storeContractID);
+}
+
 function onInit(aPageId, aServerId)
 {
   initServerType();
 
   onCheckItem("server.biffMinutes", ["server.doBiff"]);
   onCheckItem("nntp.maxArticles", ["nntp.notifyOn"]);
   setupMailOnServerUI();
   setupFixedUI();
   if (document.getElementById("server.type").getAttribute("value") == "imap")
     setupImapDeleteUI(aServerId);
 
   // "STARTTLS, if available" is vulnerable to MITM attacks so we shouldn't
   // allow users to choose it anymore. Hide the option unless the user already
   // has it set.
   hideUnlessSelected(document.getElementById("connectionSecurityType-1"));
+
+  // UI for account store type.
+  let storeTypeElement = document.getElementById("server.storeTypeMenulist");
+  // set the menuitem to match the account
+  let currentStoreID = document.getElementById("server.storeContractID")
+                               .getAttribute("value");
+  let targetItem = storeTypeElement.getElementsByAttribute("value", currentStoreID);
+  storeTypeElement.selectedItem = targetItem[0];
+  // disable store type change if store has already been used
+  storeTypeElement.setAttribute("disabled",
+    gServer.getBoolValue("canChangeStoreType") ? "false" : "true");
 }
 
 function onPreInit(account, accountValues)
 {
   var type = parent.getAccountValue(account, accountValues, "server", "type", null, false);
   hideShowControls(type);
 
   Services.obs.notifyObservers(null, "charsetmenu-selected", "other");
--- a/mailnews/base/prefs/content/am-server.xul
+++ b/mailnews/base/prefs/content/am-server.xul
@@ -23,16 +23,23 @@
   <vbox flex="1" style="overflow: auto;">
     <script type="application/javascript" src="chrome://messenger/content/AccountManager.js"/>
     <script type="application/javascript" src="chrome://messenger/content/am-server.js"/>
     <script type="application/javascript" src="chrome://messenger/content/am-prefs.js"/>
     <script type="application/javascript" src="chrome://messenger/content/amUtils.js"/>
     <stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
 
     <label hidden="true" wsm_persist="true" id="server.type"/>
+    <label hidden="true"
+           wsm_persist="true"
+           preftype="string"
+           prefattribute="value"
+           prefstring="mail.server.%serverkey%.storeContractID"
+           genericattr="true"
+           id="server.storeContractID"/>
 
     <dialogheader title="&serverSettings.label;"/>
 
     <grid>
       <columns>
         <column/>
         <column flex="1"/>
         <column/>
@@ -368,16 +375,31 @@
         <button label="&advancedButton.label;"
                 accesskey="&advancedButton.accesskey;"
                 oncommand="onAdvanced();"
                 wsm_persist="true"
                 id="server.popAdvancedButton"
                 prefstring="mail.server.%serverkey%.advanced.disable"
                 hidefor="imap,nntp,movemail"/>
       </hbox>
+      <hbox align="center">
+        <label value="&storeType.label;"
+               accesskey="&storeType.accesskey;"
+               control="server.storeTypeMenulist"/>
+        <menulist id="server.storeTypeMenulist">
+          <menupopup id="server.storeTypeMenupopup">
+            <menuitem id="server.mboxStore"
+                      value="@mozilla.org/msgstore/berkeleystore;1"
+                      label="&mboxStore.label;"/>
+            <menuitem id="server.maildirStore"
+                      value="@mozilla.org/msgstore/maildirstore;1"
+                      label="&maildirStore.label;"/>
+          </menupopup>
+        </menulist>
+      </hbox>
 
       <vbox hidefor="imap,pop3,movemail">
         <label value="&newsrcFilePath.label;" control="nntp.newsrcFilePath"/>
         <hbox align="center">
           <textbox readonly="true"
                    wsm_persist="true"
                    flex="1"
                    id="nntp.newsrcFilePath"
--- a/mailnews/base/prefs/content/am-serverwithnoidentities.js
+++ b/mailnews/base/prefs/content/am-serverwithnoidentities.js
@@ -1,10 +1,34 @@
 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+var gServer;
+
 function onInit(aPageId, aServerId) {
+
+  // UI for account store type
+  let storeTypeElement = document.getElementById("server.storeTypeMenulist");
+  // set the menuitem to match the account
+  let currentStoreID = document.getElementById("server.storeContractID")
+                               .getAttribute("value");
+  let targetItem = storeTypeElement.getElementsByAttribute("value", currentStoreID);
+  storeTypeElement.selectedItem = targetItem[0];
+  // disable store type change if store has already been used
+  storeTypeElement.setAttribute("disabled",
+    gServer.getBoolValue("canChangeStoreType") ? "false" : "true");
 }
 
 function onPreInit(account, accountValues) {
+  gServer = account.incomingServer;
 }
+
+function onSave()
+{
+  let storeContractID = document.getElementById("server.storeTypeMenulist")
+                                .selectedItem
+                                .value;
+  document.getElementById("server.storeContractID")
+          .setAttribute("value", storeContractID);
+}
+
--- a/mailnews/base/prefs/content/am-serverwithnoidentities.xul
+++ b/mailnews/base/prefs/content/am-serverwithnoidentities.xul
@@ -15,16 +15,24 @@
       title="&accountTitle.label;"
       onload="parent.onPanelLoaded('am-serverwithnoidentities.xul');">
 
   <script type="application/javascript" src="chrome://messenger/content/am-serverwithnoidentities.js"/>
   <script type="application/javascript" src="chrome://messenger/content/amUtils.js"/>
 
   <dialogheader title="&accountTitle.label;"/>
 
+  <label hidden="true"
+         wsm_persist="true"
+         preftype="string"
+         prefattribute="value"
+         prefstring="mail.server.%serverkey%.storeContractID"
+         genericattr="true"
+         id="server.storeContractID"/>
+
   <description class="secDesc">&accountSettingsDesc.label;</description>
   <hbox align="center">
     <label value="&accountName.label;" control="server.prettyName"
            accesskey="&accountName.accesskey;"/>
     <textbox wsm_persist="true" size="30" id="server.prettyName"
              prefstring="mail.server.%serverkey%.name"/>
   </hbox>
 
@@ -34,16 +42,31 @@
     <caption label="&messageStorage.label;"/>
 
     <vbox align="start">
       <checkbox wsm_persist="true" id="server.emptyTrashOnExit"
                 label="&emptyTrashOnExit.label;"
                 accesskey="&emptyTrashOnExit.accesskey;"
                 prefattribute="value"
                 prefstring="mail.server.%serverkey%.empty_trash_on_exit"/>
+      <hbox align="center">
+        <label value="&storeType.label;"
+               accesskey="&storeType.accesskey;"
+               control="server.storeTypeMenulist"/>
+        <menulist id="server.storeTypeMenulist">
+          <menupopup id="server.storeTypeMenupopup">
+            <menuitem id="server.mboxStore"
+                      value="@mozilla.org/msgstore/berkeleystore;1"
+                      label="&mboxStore.label;"/>
+            <menuitem id="server.maildirStore"
+                      value="@mozilla.org/msgstore/maildirstore;1"
+                      label="&maildirStore.label;"/>
+          </menupopup>
+        </menulist>
+      </hbox>
     </vbox>
 
     <separator class="thin"/>
 
     <label value="&localPath.label;" control="server.localPath"/>
     <hbox align="center">
       <textbox readonly="true" wsm_persist="true" flex="1" id="server.localPath" datatype="nsILocalFile"
                prefstring="mail.server.%serverkey%.directory" class="uri-element"/>