Bug 1364653 - Port bug 1356507 to TB [Show version and updater in the preferences update pane]. r=jorgk
authorRichard Marti <richard.marti@gmail.com>
Sun, 21 May 2017 15:20:25 +0200
changeset 21590 abc0bcd3caec68343fce1ff4fcb700edd6c72076
parent 21589 d60f75d773252e42d92b614f9dab52b8988856c2
child 21591 94eceea0e6e94cd1e40aa2f2b04a2dbfa0c759e1
push id13154
push usermozilla@jorgk.com
push dateThu, 25 May 2017 20:48:25 +0000
treeherdercomm-central@abc0bcd3caec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1364653, 1356507
Bug 1364653 - Port bug 1356507 to TB [Show version and updater in the preferences update pane]. r=jorgk
mail/base/content/aboutDialog-appUpdater.js
mail/components/preferences/advanced.js
mail/components/preferences/advanced.xul
mail/locales/en-US/chrome/messenger/aboutDialog.dtd
mail/locales/en-US/chrome/messenger/preferences/advanced.dtd
mail/themes/linux/mail/preferences/preferences.css
mail/themes/osx/mail/preferences/preferences.css
mail/themes/shared/mail/incontentprefs/aboutPreferences.css
mail/themes/windows/mail/preferences/preferences.css
--- a/mail/base/content/aboutDialog-appUpdater.js
+++ b/mail/base/content/aboutDialog-appUpdater.js
@@ -1,13 +1,14 @@
 /* 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/. */
 
-// Note: this file is included in aboutDialog.xul if MOZ_UPDATER is defined.
+// Note: this file is included in aboutDialog.xul and preferences/advanced.xul
+// if MOZ_UPDATER is defined.
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
 
 var gAppUpdater;
 
 function onUnload(aEvent) {
   if (gAppUpdater.isChecking)
@@ -159,16 +160,24 @@ appUpdater.prototype =
    */
   selectPanel: function(aChildID) {
     let panel = document.getElementById(aChildID);
 
     let button = panel.querySelector("button");
     if (button) {
       if (aChildID == "downloadAndInstall") {
         let updateVersion = gAppUpdater.update.displayVersion;
+        // Include the build ID if this is an "a#" (nightly) build
+        if (/a\d+$/.test(updateVersion)) {
+          let buildID = gAppUpdater.update.buildID;
+          let year = buildID.slice(0, 4);
+          let month = buildID.slice(4, 6);
+          let day = buildID.slice(6, 8);
+          updateVersion += ` (${year}-${month}-${day})`;
+        }
         button.label = this.bundle.formatStringFromName("update.downloadAndInstallButton.label", [updateVersion], 1);
         button.accessKey = this.bundle.GetStringFromName("update.downloadAndInstallButton.accesskey");
       }
       this.updateDeck.selectedPanel = panel;
       if (!document.commandDispatcher.focusedElement || // don't steal the focus
           document.commandDispatcher.focusedElement.localName == "button") // except from the other buttons
         button.focus();
 
--- a/mail/components/preferences/advanced.js
+++ b/mail/components/preferences/advanced.js
@@ -1,16 +1,17 @@
 /* -*- Mode: Java; tab-width: 2; 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/. */
 
 // Load DownloadUtils module for convertByteUnits
 Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/AppConstants.jsm");
 
 var gAdvancedPane = {
   mPane: null,
   mInitialized: false,
   mShellServiceWorking: false,
 
   _loadInContent: Services.prefs.getBoolPref("mail.preferences.inContent"),
 
@@ -80,16 +81,57 @@ var gAdvancedPane = {
         document.getElementById("alwaysCheckDefault").disabled = true;
         document.getElementById("alwaysCheckDefault").checked = false;
       }
       if (document.getElementById("checkDefaultButton"))
         document.getElementById("checkDefaultButton").disabled = true;
       this.mShellServiceWorking = false;
     }
 
+    let distroId = Services.prefs.getCharPref("distribution.id" , "");
+    if (distroId) {
+      let distroVersion = Services.prefs.getCharPref("distribution.version");
+
+      let distroIdField = document.getElementById("distributionId");
+      distroIdField.value = distroId + " - " + distroVersion;
+      distroIdField.style.display = "block";
+
+      let distroAbout = Services.prefs.getStringPref("distribution.about", "");
+      if (distroAbout) {
+        let distroField = document.getElementById("distribution");
+        distroField.value = distroAbout;
+        distroField.style.display = "block";
+      }
+    }
+
+    let version = AppConstants.MOZ_APP_VERSION_DISPLAY;
+
+    // Include the build ID and display warning if this is an "a#" (nightly) build
+    if (/a\d+$/.test(version)) {
+      let buildID = Services.appinfo.appBuildID;
+      let year = buildID.slice(0, 4);
+      let month = buildID.slice(4, 6);
+      let day = buildID.slice(6, 8);
+      version += ` (${year}-${month}-${day})`;
+    }
+
+    // Append "(32-bit)" or "(64-bit)" build architecture to the version number:
+    let bundle = Services.strings.createBundle("chrome://messenger/locale/messenger.properties");
+    let archResource = Services.appinfo.is64Bit
+                       ? "aboutDialog.architecture.sixtyFourBit"
+                       : "aboutDialog.architecture.thirtyTwoBit";
+    let arch = bundle.GetStringFromName(archResource);
+    version += ` (${arch})`;
+
+    document.getElementById("version").textContent = version;
+
+    if (AppConstants.MOZ_UPDATER) {
+      gAppUpdater = new appUpdater();
+    }
+
     if (this._loadInContent) {
       gSubDialog.init();
     }
 
     this.mInitialized = true;
   },
 
   tabSelectionChanged: function ()
--- a/mail/components/preferences/advanced.xul
+++ b/mail/components/preferences/advanced.xul
@@ -16,21 +16,28 @@
 #ifdef XP_MACOSX
 <!ENTITY % searchIntegrationMacDTD SYSTEM "chrome://messenger/locale/searchIntegrationMac.dtd" >
 %searchIntegrationMacDTD;
 #else
 <!ENTITY % searchIntegrationDefaultDTD SYSTEM "chrome://messenger/locale/searchIntegrationDefault.dtd" >
 %searchIntegrationDefaultDTD;
 #endif
 #endif
+#ifdef MOZ_UPDATER
+<!ENTITY % aboutDialogDTD SYSTEM "chrome://messenger/locale/aboutDialog.dtd" >
+%aboutDialogDTD;
+#endif
 ]>
 
 <overlay id="AdvancedPaneOverlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <prefpane id="paneAdvanced" onpaneload="gAdvancedPane.init();">
+#ifdef MOZ_UPDATER
+    <script type="application/javascript" src="chrome://messenger/content/aboutDialog-appUpdater.js"/>
+#endif
     <script type="application/javascript" src="chrome://messenger/content/preferences/advanced.js"/>
     <script type="application/javascript" src="chrome://communicator/content/utilityOverlay.js"/>
 
     <preferences id="advancedPreferences">
       <preference id="mail.preferences.advanced.selectedTabIndex"
                   name="mail.preferences.advanced.selectedTabIndex" type="int"/>
       <!-- General tab -->
 
@@ -344,45 +351,132 @@ type="bool"/>
                          aria-labelledby="offlineCompactFolder offlineCompactFolderMin compactFolderMB"/>
                 <label id="compactFolderMB" value="&offlineCompactFoldersMB.label;"/>
             </hbox>
           </groupbox>
         </tabpanel>
 
 #ifdef MOZ_UPDATER
         <!-- Update -->
-        <tabpanel orient="vertical" align="start">
+        <tabpanel orient="vertical">
           <groupbox id="updateApp">
-            <caption label="&updateApp.label;"/>
+            <caption label="&updateApp2.label;"/>
+            <hbox align="center">
+              <vbox>
+                <description>
+                  &updateApp.version.pre;<label id="version"/>&updateApp.version.post;
+#ifndef NIGHTLY_BUILD
+#expand           <label id="releasenotes" class="text-link" href="https://www.mozilla.org/thunderbird/__MOZ_APP_VERSION__/releasenotes/">&releaseNotes.link;</label>
+#endif
+                </description>
+                <description id="distribution" class="text-blurb" hidden="true"/>
+                <description id="distributionId" class="text-blurb" hidden="true"/>
+              </vbox>
+              <spacer flex="1"/>
+              <vbox>
+                <button id="showUpdateHistory"
+                        label="&updateHistory.label;"
+                        accesskey="&updateHistory.accesskey;"
+                        preference="app.update.disable_button.showUpdateHistory"
+                        oncommand="gAdvancedPane.showUpdates();"/>
+              </vbox>
+            </hbox>
+            <vbox id="updateBox">
+              <deck id="updateDeck" orient="vertical">
+                <hbox id="checkForUpdates" align="center">
+                  <spacer flex="1"/>
+                  <button id="checkForUpdatesButton" align="start"
+                          label="&update.checkForUpdatesButton.label;"
+                          accesskey="&update.checkForUpdatesButton.accesskey;"
+                          oncommand="gAppUpdater.checkForUpdates();"/>
+                </hbox>
+                <hbox id="downloadAndInstall" align="center">
+                  <spacer flex="1"/>
+                  <button id="downloadAndInstallButton"
+                          oncommand="gAppUpdater.startDownload();"/>
+                          <!-- label and accesskey will be filled by JS -->
+                </hbox>
+                <hbox id="apply" align="center">
+                  <spacer flex="1"/>
+                  <button id="updateButton"
+                          label="&update.updateButton.label3;"
+                          accesskey="&update.updateButton.accesskey;"
+                          oncommand="gAppUpdater.buttonRestartAfterDownload();"/>
+                </hbox>
+                <hbox id="checkingForUpdates" align="center">
+                  <image class="update-throbber"/><label>&update.checkingForUpdates;</label>
+                  <spacer flex="1"/>
+                  <button label="&update.checkForUpdatesButton.label;"
+                          accesskey="&update.checkForUpdatesButton.accesskey;"
+                          disabled="true"/>
+                </hbox>
+                <hbox id="downloading" align="center">
+                  <image class="update-throbber"/><label>&update.downloading.start;</label><label id="downloadStatus"/><label>&update.downloading.end;</label>
+                </hbox>
+                <hbox id="applying" align="center">
+                  <image class="update-throbber"/><label>&update.applying;</label>
+                </hbox>
+               <hbox id="downloadFailed" align="center">
+                  <label>&update.failed.start;</label><label id="failedLink" class="text-link">&update.failed.linkText;</label><label>&update.failed.end;</label>
+                  <spacer flex="1"/>
+                  <button label="&update.checkForUpdatesButton.label;"
+                          accesskey="&update.checkForUpdatesButton.accesskey;"
+                          oncommand="gAppUpdater.checkForUpdates();"/>
+                </hbox>
+                <hbox id="adminDisabled" align="center">
+                  <label>&update.adminDisabled;</label>
+                  <spacer flex="1"/>
+                  <button label="&update.checkForUpdatesButton.label;"
+                          accesskey="&update.checkForUpdatesButton.accesskey;"
+                          disabled="true"/>
+                </hbox>
+                <hbox id="noUpdatesFound" align="center">
+                  <label>&update.noUpdatesFound;</label>
+                  <spacer flex="1"/>
+                  <button label="&update.checkForUpdatesButton.label;"
+                          accesskey="&update.checkForUpdatesButton.accesskey;"
+                          oncommand="gAppUpdater.checkForUpdates();"/>
+                </hbox>
+                <hbox id="otherInstanceHandlingUpdates" align="center">
+                  <label>&update.otherInstanceHandlingUpdates;</label>
+                  <spacer flex="1"/>
+                  <button label="&update.checkForUpdatesButton.label;"
+                          accesskey="&update.checkForUpdatesButton.accesskey;"
+                          disabled="true"/>
+                </hbox>
+                <hbox id="manualUpdate" align="center">
+                  <label>&update.manual.start;</label><label id="manualLink" class="text-link">&update.manual.linkText;</label><label>&update.manual.end;</label>
+                  <spacer flex="1"/>
+                  <button label="&update.checkForUpdatesButton.label;"
+                          accesskey="&update.checkForUpdatesButton.accesskey;"
+                          disabled="true"/>
+                </hbox>
+                <hbox id="unsupportedSystem" align="center">
+                  <label>&update.unsupported.start;</label><label id="unsupportedLink" class="text-link">&update.unsupported.linkText;</label><label>&update.unsupported.end;</label>
+                  <spacer flex="1"/>
+                  <button label="&update.checkForUpdatesButton.label;"
+                          accesskey="&update.checkForUpdatesButton.accesskey;"
+                          disabled="true"/>
+                </hbox>
+              </deck>
+            </vbox>
+            <separator/>
             <radiogroup id="updateRadioGroup"
+                        align="start"
                         oncommand="gAdvancedPane.updateWritePrefs();">
               <radio value="auto"
                      label="&updateAuto.label;"
                      accesskey="&updateAuto.accesskey;"/>
-              <hbox>
-                <radio value="checkOnly"
-                       label="&updateCheck.label;"
-                       accesskey="&updateCheck.accesskey;"/>
-                <spacer flex="1"/>
-              </hbox>
-              <hbox>
-                <radio value="manual"
-                       label="&updateManual.label;"
-                       accesskey="&updateManual.accesskey;"/>
-                <spacer flex="1"/>
-              </hbox>
+              <radio value="checkOnly"
+                     label="&updateCheck.label;"
+                     accesskey="&updateCheck.accesskey;"/>
+              <radio value="manual"
+                     label="&updateManual.label;"
+                     accesskey="&updateManual.accesskey;"/>
             </radiogroup>
-
-            <hbox>
-              <button id="showUpdateHistory"
-                      label="&updateHistory.label;"
-                      accesskey="&updateHistory.accesskey;"
-                      preference="app.update.disable_button.showUpdateHistory"
-                      oncommand="gAdvancedPane.showUpdates();"/>
-            </hbox>
           </groupbox>
 
 #ifdef MOZ_MAINTENANCE_SERVICE
           <separator/>
           <checkbox id="useService"
                     label="&useService.label;"
                     accesskey="&useService.accesskey;"
                     preference="app.update.service.enabled"/>
--- a/mail/locales/en-US/chrome/messenger/aboutDialog.dtd
+++ b/mail/locales/en-US/chrome/messenger/aboutDialog.dtd
@@ -1,11 +1,14 @@
 <!ENTITY aboutDialog.title          "About &brandFullName;">
 
-
+<!-- LOCALIZATION NOTE (update.*):
+# These strings are also used in the update pane of preferences.
+# See about:preferences#advanced.
+-->
 <!-- LOCALIZATION NOTE (update.checkForUpdatesButton.*, update.updateButton.*):
 # Only one button is present at a time.
 # The button when displayed is located directly under the Thunderbird version in
 # the about dialog.
 -->
 <!ENTITY update.checkForUpdatesButton.label       "Check for Updates">
 <!ENTITY update.checkForUpdatesButton.accesskey   "C">
 <!ENTITY update.updateButton.label3               "Restart to update &brandShorterName;">
--- a/mail/locales/en-US/chrome/messenger/preferences/advanced.dtd
+++ b/mail/locales/en-US/chrome/messenger/preferences/advanced.dtd
@@ -47,17 +47,29 @@
 
 <!ENTITY crashReporterSection.label      "Crash Reporter">
 <!ENTITY crashReporterDesc.label         "&brandShortName; submits crash reports to help &vendorShortName; make your e-mail client more stable and secure">
 <!ENTITY enableCrashReporter.label       "Enable Crash Reporter">
 <!ENTITY enableCrashReporter.accesskey   "C">
 <!ENTITY crashReporterLearnMore.label    "Learn More">
 
 <!-- Update -->
-<!ENTITY updateApp.label                 "&brandShortName; updates:">
+<!-- LOCALIZATION NOTE (updateApp.label):
+  Strings from aboutDialog.dtd are displayed in this section of the preferences.
+  Please check for possible accesskey conflicts.
+-->
+<!ENTITY updateApp2.label                "&brandShortName; Updates">
+<!-- LOCALIZATION NOTE (updateApp.version.*): updateApp.version.pre is
+  followed by a version number, keep the trailing space or replace it with
+  a different character as needed. updateApp.version.post is displayed after
+  the version number, and is empty on purpose for English. You can use it
+  if required by your language.
+ -->
+<!ENTITY updateApp.version.pre           "Version ">
+<!ENTITY updateApp.version.post          "">
 <!ENTITY updateAuto.label                "Automatically install updates (recommended: improved security)">
 <!ENTITY updateAuto.accesskey            "A">
 <!ENTITY updateCheck.label               "Check for updates, but let me choose whether to install them">
 <!ENTITY updateCheck.accesskey           "C">
 <!ENTITY updateManual.label              "Never check for updates (not recommended: security risk)">
 <!ENTITY updateManual.accesskey          "N">
 <!ENTITY updateHistory.label             "Show Update History">
 <!ENTITY updateHistory.accesskey         "p">
--- a/mail/themes/linux/mail/preferences/preferences.css
+++ b/mail/themes/linux/mail/preferences/preferences.css
@@ -234,8 +234,21 @@ a {
 
 #provider-spacebox {
   -moz-box-flex: 1;
 }
 
 #provider-account-settings {
   -moz-box-flex: 0;
 }
+
+.update-throbber {
+  width: 16px;
+  min-height: 16px;
+  margin-inline-start: 6px;
+  list-style-image: url("chrome://global/skin/icons/loading.png");
+}
+
+@media (min-resolution: 1.1dppx) {
+  .update-throbber {
+    list-style-image: url("chrome://global/skin/icons/loading@2x.png");
+  }
+}
--- a/mail/themes/osx/mail/preferences/preferences.css
+++ b/mail/themes/osx/mail/preferences/preferences.css
@@ -257,16 +257,29 @@ a {
   width: 150px;
   overflow: hidden;
 }
 
 #upgrade {
   margin-top: 1em;
 }
 
+.update-throbber {
+  width: 16px;
+  min-height: 16px;
+  margin-inline-start: 6px;
+  list-style-image: url("chrome://global/skin/icons/loading.png");
+}
+
+@media (min-resolution: 1.1dppx) {
+  .update-throbber {
+    list-style-image: url("chrome://global/skin/icons/loading@2x.png");
+  }
+}
+
 #provider-space-visuals {
   width: 150px;
   height: 150px;
   float: right;
 }
 
 #provider-account-settings {
   text-align: right;
--- a/mail/themes/shared/mail/incontentprefs/aboutPreferences.css
+++ b/mail/themes/shared/mail/incontentprefs/aboutPreferences.css
@@ -226,16 +226,25 @@ tabs {
 .indent {
   margin-inline-start: 33px;
 }
 
 .inset {
   border-color: #424e5a;
 }
 
+.update-throbber {
+  margin-inline-start: 0;
+  margin-inline-end: 4px;
+}
+
+#releasenotes {
+  margin-inline-start: 6px !important;
+}
+
 #telemetryLearnMore,
 #crashReporterLearnMore {
   margin-inline-end: 4px !important;
 }
 
 /**
  * Font dialog menulist fixes
  */
--- a/mail/themes/windows/mail/preferences/preferences.css
+++ b/mail/themes/windows/mail/preferences/preferences.css
@@ -235,8 +235,21 @@ a {
 
 #provider-spacebox {
   -moz-box-flex: 1;
 }
 
 #provider-account-settings {
   -moz-box-flex: 0;
 }
+
+.update-throbber {
+  width: 16px;
+  min-height: 16px;
+  margin-inline-start: 6px;
+  list-style-image: url("chrome://global/skin/icons/loading.png");
+}
+
+@media (min-resolution: 1.1dppx) {
+  .update-throbber {
+    list-style-image: url("chrome://global/skin/icons/loading@2x.png");
+  }
+}