Bug 636839 - Port |Bug 526445 - Rearrange Sync prefs panel|. r=IanN ui-r=Neil
authorJens Hatlak <jh@junetz.de>
Tue, 01 Mar 2011 19:29:49 +0100
changeset 7235 2387bfa5924087660791aaec63534bf1a9dd0a62
parent 7234 e066581ac82de89f84851ec9732bcddda2ccf10f
child 7236 d815044142c8bf75cb4c961619054bb7f76336c2
push idunknown
push userunknown
push dateunknown
reviewersIanN, Neil
bugs636839, 526445
Bug 636839 - Port |Bug 526445 - Rearrange Sync prefs panel|. r=IanN ui-r=Neil
suite/common/pref/pref-sync.js
suite/common/pref/pref-sync.xul
suite/locales/en-US/chrome/common/pref/pref-sync.dtd
suite/locales/en-US/chrome/common/pref/prefutilities.properties
suite/themes/classic/communicator/prefpanels.css
suite/themes/modern/communicator/prefpanels.css
--- a/suite/common/pref/pref-sync.js
+++ b/suite/common/pref/pref-sync.js
@@ -37,111 +37,80 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 Components.utils.import("resource://services-sync/service.js");
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 const PAGE_NO_ACCOUNT = 0;
 const PAGE_HAS_ACCOUNT = 1;
+const PAGE_NEEDS_UPDATE = 2;
 
 let gSyncPane = {
   _stringBundle: null,
 
   get page() {
     return document.getElementById("weavePrefsDeck").selectedIndex;
   },
 
   set page(val) {
     document.getElementById("weavePrefsDeck").selectedIndex = val;
   },
 
   get _usingCustomServer() {
     return Weave.Svc.Prefs.isSet("serverURL");
   },
 
-  onLoginStart: function () {
-    if (this.page == PAGE_NO_ACCOUNT)
-      return;
-
-    document.getElementById("loginFeedbackRow").hidden = true;
-    document.getElementById("connectThrobber").hidden = false;
-  },
-
-  onLoginError: function () {
-    if (this.page == PAGE_NO_ACCOUNT)
-      return;
-
-    document.getElementById("connectThrobber").hidden = true;
-    document.getElementById("loginFeedbackRow").hidden = false;
+  needsUpdate: function () {
+    this.page = PAGE_NEEDS_UPDATE;
     let label = document.getElementById("loginError");
     label.value = Weave.Utils.getErrorString(Weave.Status.login);
     label.className = "error";
   },
 
-  onLoginFinish: function () {
-    document.getElementById("connectThrobber").hidden = true;
-    this.updateWeavePrefs();
-  },
-
   init: function () {
-    let obs = [
-      ["weave:service:login:start",   "onLoginStart"],
-      ["weave:service:login:error",   "onLoginError"],
-      ["weave:service:login:finish",  "onLoginFinish"],
-      ["weave:service:start-over",    "updateWeavePrefs"],
-      ["weave:service:setup-complete","updateWeavePrefs"],
-      ["weave:service:logout:finish", "updateWeavePrefs"]];
+    let topics = [
+      "weave:service:login:error",
+      "weave:service:login:finish",
+      "weave:service:start-over",
+      "weave:service:setup-complete",
+      "weave:service:logout:finish"];
 
     // Add the observers now and remove them on unload
-    let self = this;
-    let addRem = function(add) {
-      obs.forEach(function([topic, func]) {
-        //XXXzpao This should use Services.obs.* but Weave's Obs does nice handling
-        //        of `this`. Fix in a followup. (bug 583347)
-        if (add)
-          Weave.Svc.Obs.add(topic, self[func], self);
-        else
-          Weave.Svc.Obs.remove(topic, self[func], self);
-      });
-    };
-    addRem(true);
-    window.addEventListener("unload", function() addRem(false), false);
+    //XXXzpao This should use Services.obs.* but Weave's Obs does nice handling
+    //        of `this`. Fix in a followup. (bug 583347)
+    topics.forEach(function(topic) {
+      Weave.Svc.Obs.add(topic, this.updateWeavePrefs, this);
+    }, this);
+    window.addEventListener("unload", function() {
+      topics.forEach(function (topic) {
+        Weave.Svc.Obs.remove(topic, this.updateWeavePrefs, this);
+      }, gSyncPane);
+    }, false);
 
     this._stringBundle =
       Services.strings.createBundle("chrome://communicator/locale/pref/prefutilities.properties");
     this.updateWeavePrefs();
   },
 
   updateWeavePrefs: function () {
     if (Weave.Status.service == Weave.CLIENT_NOT_CONFIGURED ||
-        Weave.Svc.Prefs.get("firstSync", "") == "notReady")
+        Weave.Svc.Prefs.get("firstSync", "") == "notReady") {
       this.page = PAGE_NO_ACCOUNT;
-    else {
+    } else if (Weave.Status.login == Weave.LOGIN_FAILED_INVALID_PASSPHRASE ||
+               Weave.Status.login == Weave.LOGIN_FAILED_LOGIN_REJECTED) {
+      this.needsUpdate();
+    } else {
       this.page = PAGE_HAS_ACCOUNT;
-      document.getElementById("currentAccount").value = Weave.Service.account;
+      document.getElementById("accountName").value = Weave.Service.account;
       document.getElementById("syncComputerName").value = Weave.Clients.localName;
-      if (Weave.Status.service == Weave.LOGIN_FAILED)
-        this.onLoginError();
-      this.updateConnectButton();
       document.getElementById("tosPP").hidden = this._usingCustomServer;
     }
   },
 
-  updateConnectButton: function () {
-    let prefix = Weave.Service.isLoggedIn ? "dis" : "";
-    let button = document.getElementById("connectButton");
-    button.label = this._stringBundle.GetStringFromName(prefix + "connect.label");
-    button.accessKey = this._stringBundle.GetStringFromName(prefix + "connect.accesskey");
-  },
-
-  handleConnectCommand: function () {
-    Weave.Service.isLoggedIn ? Weave.Service.logout() : Weave.Service.login();
-  },
-
   startOver: function (showDialog) {
     if (showDialog) {
       let flags = Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING +
                   Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL;
       let buttonChoice =
         Services.prompt.confirmEx(window,
                                   this._stringBundle.GetStringFromName("stopUsingAccount.title"),
                                   this._stringBundle.GetStringFromName("differentAccount.label"),
--- a/suite/common/pref/pref-sync.xul
+++ b/suite/common/pref/pref-sync.xul
@@ -80,129 +80,107 @@
                   accesskey="&setupButton.accesskey;"
                   oncommand="gSyncPane.openSetup();"/>
           <separator/>
           <spacer flex="3"/>
         </vbox>
         <vbox id="hasAccount">
           <groupbox>
             <caption label="&accountGroupboxCaption.label;"/>
-            <grid>
-              <rows>
-                <row align="center">
-                  <label value="&currentAccount.label;" control="currentAccount"/>
-                  <textbox id="currentAccount" readonly="true">
-                    <image/>
-                  </textbox>
-                  <hbox align="center">
-                    <button id="connectButton" oncommand="gSyncPane.handleConnectCommand();"/>
-                    <image id="connectThrobber"
-                           hidden="true"/>
-                  </hbox>
-                </row>
-                <row id="loginFeedbackRow" hidden="true">
-                  <spacer/>
-                  <vbox>
-                    <label id="loginError" value=""/>
-                    <hbox>
-                      <button label="&updatePass.label;"
-                              accesskey="&updatePass.accesskey;"
-                              oncommand="gSyncPane.updatePass(); return false;"
-                              id="updatePassButton"/>
-                      <button label="&resetPass.label;"
-                              accesskey="&resetPass.accesskey;"
-                              oncommand="gSyncPane.resetPass(); return false;"
-                              id="resetPassButton"/>
-                    </hbox>
-                  </vbox>
-                  <spacer/>
-                </row>
-                <label value="&manageAccount.label;"/>
-                <vbox class="indent">
-                  <grid flex="1">
-                    <columns>
-                      <column/>
-                      <column/>
-                      <column/>
-                    </columns>
-                    <rows>
-                      <row>
-                        <button label="&viewQuota.label;"
-                                accesskey="&viewQuota.accesskey;"
-                                oncommand="gSyncPane.openQuotaDialog(); return false;"
-                                id="viewQuotaButton"/>
-                        <button label="&changePassword.label;"
-                                accesskey="&changePassword.accesskey;"
-                                oncommand="gSyncUtils.changePassword(); return false;"
-                                id="changeSyncPasswordButton"/>
-                        <button label="&mySyncKey.label;"
-                                accesskey="&mySyncKey.accesskey;"
-                                oncommand="gSyncUtils.resetPassphrase(); return false;"
-                                id="mySyncKeyButton"/>
-                      </row>
-                      <row>
-                        <button label="&resetSync.label;"
-                                accesskey="&resetSync.accesskey;"
-                                oncommand="gSyncPane.resetSync(); return false;"
-                                id="resetSyncButton"/>
-                        <button label="&stopUsingAccount.label;"
-                                accesskey="&stopUsingAccount.accesskey;"
-                                oncommand="gSyncPane.startOver(true); return false;"
-                                id="stopUsingAccountButton"/>
-                        <spacer/>
-                      </row>
-                    </rows>
-                  </grid>
-                </vbox>
-              </rows>
-            </grid>
+            <hbox align="center">
+              <label value="&accountName.label;" control="accountName"/>
+              <textbox id="accountName" flex="1" readonly="true"/>
+              <button type="menu"
+                      label="&manageAccount.label;"
+                      accesskey="&manageAccount.accesskey;">
+                <menupopup>
+                  <menuitem label="&viewQuota.label;"
+                            accesskey="&viewQuota.accesskey;"
+                            oncommand="gSyncPane.openQuotaDialog();"/>
+                  <menuseparator/>
+                  <menuitem label="&changePassword.label;"
+                            accesskey="&changePassword.accesskey;"
+                            oncommand="gSyncUtils.changePassword();"/>
+                  <menuitem label="&mySyncKey.label;"
+                            accesskey="&mySyncKey.accesskey;"
+                            oncommand="gSyncUtils.resetPassphrase();"/>
+                  <menuseparator/>
+                  <menuitem label="&resetSync.label;"
+                            accesskey="&resetSync.accesskey;"
+                            oncommand="gSyncPane.resetSync();"/>
+                  <menuitem label="&stopUsingAccount.label;"
+                            accesskey="&stopUsingAccount.accesskey;"
+                            oncommand="gSyncPane.startOver(true);"/>
+                </menupopup>
+              </button>
+            </hbox>
+            <vbox>
+              <label value="&syncMy2.label;"/>
+              <listbox id="syncEnginesList" flex="1">
+                <listitem type="checkbox"
+                          label="&engine.bookmarks.label;"
+                          accesskey="&engine.bookmarks.accesskey;"
+                          preference="engine.bookmarks"/>
+                <listitem type="checkbox"
+                          label="&engine.history.label;"
+                          accesskey="&engine.history.accesskey;"
+                          preference="engine.history"/>
+                <listitem type="checkbox"
+                          label="&engine.passwords.label;"
+                          accesskey="&engine.passwords.accesskey;"
+                          preference="engine.passwords"/>
+                <listitem type="checkbox"
+                          label="&engine.prefs.label;"
+                          accesskey="&engine.prefs.accesskey;"
+                          preference="engine.prefs"/>
+                <listitem type="checkbox"
+                          label="&engine.tabs.label;"
+                          accesskey="&engine.tabs.accesskey;"
+                          preference="engine.tabs"/>
+              </listbox>
+            </vbox>
           </groupbox>
           <groupbox>
-            <caption label="&syncPrefsCaption.label;"/>
             <grid>
               <columns>
                 <column/>
                 <column flex="1"/>
               </columns>
               <rows>
                 <row align="center">
                   <label value="&syncComputerName.label;"
                          accesskey="&syncComputerName.accesskey;"
                          control="syncComputerName"/>
                   <textbox id="syncComputerName"
                            onchange="gSyncUtils.changeName(this);"/>
                 </row>
-                <row>
-                  <label value="&syncMy.label;"/>
-                  <vbox>
-                    <checkbox label="&engine.bookmarks.label;"
-                              accesskey="&engine.bookmarks.accesskey;"
-                              preference="engine.bookmarks"/>
-                    <checkbox label="&engine.history.label;"
-                              accesskey="&engine.history.accesskey;"
-                              preference="engine.history"/>
-                    <checkbox label="&engine.passwords.label;"
-                              accesskey="&engine.passwords.accesskey;"
-                              preference="engine.passwords"/>
-                    <checkbox label="&engine.prefs.label;"
-                              accesskey="&engine.prefs.accesskey;"
-                              preference="engine.prefs"/>
-                    <checkbox label="&engine.tabs.label;"
-                              accesskey="&engine.tabs.accesskey;"
-                              preference="engine.tabs"/>
-                  </vbox>
-                </row>
               </rows>
             </grid>
-            <separator/>
           </groupbox>
           <hbox id="tosPP" pack="center">
             <label class="text-link"
                    onclick="event.stopPropagation(); gSyncUtils.openToS();"
                    value="&prefs.tosLink.label;"/>
             <label class="text-link"
                    onclick="event.stopPropagation(); gSyncUtils.openPrivacyPolicy();"
                    value="&prefs.ppLink.label;"/>
           </hbox>
         </vbox>
+        <vbox id="needsUpdate" align="center" pack="center">
+          <hbox>
+            <label id="loginError" value=""/>
+            <button label="&updatePass.label;"
+                    accesskey="&updatePass.accesskey;"
+                    oncommand="gSyncPane.updatePass(); return false;"
+                    id="updatePassButton"/>
+            <button label="&resetPass.label;"
+                    accesskey="&resetPass.accesskey;"
+                    oncommand="gSyncPane.resetPass(); return false;"
+                    id="resetPassButton"/>
+          </hbox>
+          <button label="&stopUsingAccount.label;"
+                  accesskey="&stopUsingAccount.accesskey;"
+                  oncommand="gSyncPane.startOver(true); return false;"
+                  id="stopUsingAccountButton"/>
+        </vbox>
       </deck>
   </prefpane>
 </overlay>
--- a/suite/locales/en-US/chrome/common/pref/pref-sync.dtd
+++ b/suite/locales/en-US/chrome/common/pref/pref-sync.dtd
@@ -1,42 +1,42 @@
 <!-- The page shown when not logged in... -->
 <!ENTITY setupButton.label          "Set Up &syncBrand.fullName.label;">
 <!ENTITY setupButton.accesskey      "S">
 <!ENTITY weaveDesc.label            "&syncBrand.fullName.label; lets you access your history, bookmarks, passwords and open tabs across all your devices.">
 
 <!-- The page shown when logged in... -->
 <!ENTITY accountGroupboxCaption.label "&syncBrand.fullName.label; Account">
-<!ENTITY currentAccount.label         "Current Account:">
+<!ENTITY accountName.label            "Account Name:">
 
 <!-- Login error feedback -->
 <!ENTITY updatePass.label             "Update">
 <!ENTITY updatePass.accesskey         "U">
 <!ENTITY resetPass.label              "Reset">
-<!ENTITY resetPass.accesskey          "s">
+<!ENTITY resetPass.accesskey          "R">
 
 <!-- Manage Account -->
 <!ENTITY manageAccount.label          "Manage Account">
+<!ENTITY manageAccount.accesskey      "A">
 <!ENTITY viewQuota.label              "View Quota">
 <!ENTITY viewQuota.accesskey          "V">
 <!ENTITY changePassword.label         "Change Password">
 <!ENTITY changePassword.accesskey     "C">
 <!ENTITY mySyncKey.label              "My Sync Key">
 <!ENTITY mySyncKey.accesskey          "M">
 <!ENTITY resetSync.label              "Reset Sync">
 <!ENTITY resetSync.accesskey          "e">
 <!ENTITY stopUsingAccount.label       "Stop Using This Account">
-<!ENTITY stopUsingAccount.accesskey   "A">
+<!ENTITY stopUsingAccount.accesskey   "S">
 
 <!-- Sync Settings -->
-<!ENTITY syncPrefsCaption.label       "Browser Sync">
 <!ENTITY syncComputerName.label       "Computer Name:">
 <!ENTITY syncComputerName.accesskey   "N">
 
-<!ENTITY syncMy.label               "Sync My">
+<!ENTITY syncMy2.label              "Sync My:">
 <!ENTITY engine.bookmarks.label     "Bookmarks">
 <!ENTITY engine.bookmarks.accesskey "B">
 <!ENTITY engine.tabs.label          "Tabs">
 <!ENTITY engine.tabs.accesskey      "T">
 <!ENTITY engine.history.label       "History">
 <!ENTITY engine.history.accesskey   "r">
 <!ENTITY engine.passwords.label     "Passwords">
 <!ENTITY engine.passwords.accesskey "w">
--- a/suite/locales/en-US/chrome/common/pref/prefutilities.properties
+++ b/suite/locales/en-US/chrome/common/pref/prefutilities.properties
@@ -6,15 +6,11 @@ downloadfolder=Choose a Download Folder
 desktopFolderName=Desktop
 downloadsFolderName=Downloads
 choosesound=Choose a sound
 
 SoundFiles=Sounds
 
 labelDefaultFont=Default (%font_family%)
 
-connect.label=Connect
-connect.accesskey=o
-disconnect.label=Disconnect
-disconnect.accesskey=o
 stopUsingAccount.title=Do you want to stop using this account?
 differentAccount.label=This will reset all of your Sync account information and preferences.
 differentAccountConfirm.label=Reset All Information
--- a/suite/themes/classic/communicator/prefpanels.css
+++ b/suite/themes/classic/communicator/prefpanels.css
@@ -101,12 +101,8 @@
   list-style-image: url("chrome://communicator/skin/icons/feedIcon16.png");
 }
 
 /* ::::: Sync ::::: */
 
 #syncDesc {
   padding: 0 12em;
 }
-
-#connectThrobber {
-  list-style-image: url("chrome://global/skin/icons/loading_16.png");
-}
--- a/suite/themes/modern/communicator/prefpanels.css
+++ b/suite/themes/modern/communicator/prefpanels.css
@@ -134,12 +134,8 @@
   list-style-image: url("chrome://communicator/skin/icons/feedIcon16.png");
 }
 
 /* ::::: Sync ::::: */
 
 #syncDesc {
   padding: 0 12em;
 }
-
-#connectThrobber {
-  list-style-image: url("chrome://communicator/skin/icons/loading.gif");
-}