[Pkg-mozext-commits] [gcontactsync] 35/88: Issue #19 - Duplicate master password prompt in 0.4.0rc1. Also cleaned up first login code, moved the version update to Sync.begin after the auth check.

David Prévot taffit at moszumanska.debian.org
Thu Sep 18 20:52:27 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository gcontactsync.

commit 93f75986a83effbdcb92755df47ea68e363b9f86
Author: Josh Geenen <joshgeenen at gmail.com>
Date:   Sun Jan 26 14:45:45 2014 -0600

    Issue #19 - Duplicate master password prompt in 0.4.0rc1.  Also cleaned up first login code, moved the version update to Sync.begin after the auth check.
---
 src/content/MessengerOverlay.js | 14 ++++++++++++--
 src/content/Overlay.js          | 24 ++++--------------------
 src/content/Sync.js             |  3 ++-
 3 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/src/content/MessengerOverlay.js b/src/content/MessengerOverlay.js
index 86f4fb3..ec4b344 100644
--- a/src/content/MessengerOverlay.js
+++ b/src/content/MessengerOverlay.js
@@ -91,10 +91,15 @@ com.gContactSync.MessengerOverlay = {
 
     com.gContactSync.Preferences.setSyncPref("synchronizing", false);
 
+    // If this is the first time gContactSync is running (or the user never setup an account)
+    // run the setup wizard.
     // If moving from 0.3.x or <0.4.0b1 then update the chat names and incorrect types
     // Otherwise if coming from pre-0.4.0rc1 update the incorrect types
     // The upgrade will take place during the next sync
-    if (((lastVersionMajor === 0) && (lastVersionMinor < 4) && (lastVersionMajor > 0)) ||
+    var runSetupWizard = false;
+    if ((lastVersionMajor === 0) && (lastVersionMinor === 0) && (lastVersionRelease === 0)) {
+      runSetupWizard = true;
+    } else if (((lastVersionMajor === 0) && (lastVersionMinor < 4) && (lastVersionMajor > 0)) ||
         ((lastVersionMajor === 0) && (lastVersionMinor === 4) && (lastVersionRelease === 0) && (lastVersionSuffix.length > 0) && (lastVersionSuffix.charAt(0) === "a"))) {
       com.gContactSync.Preferences.setSyncPref("v04UpgradeNeeded", true);
     } else if ((lastVersionMajor === 0) && (lastVersionMinor === 4) && (lastVersionRelease === 0) && (lastVersionSuffix.length > 0) && ((lastVersionSuffix.charAt(0) === "a") || (lastVersionSuffix.charAt(0) === "b"))) {
@@ -107,7 +112,12 @@ com.gContactSync.MessengerOverlay = {
       } catch (e) {}
     }
     // Check for an auth token and either schedule a sync if at least one exists or show the new account wizard otherwise.
-    com.gContactSync.Overlay.checkAuthentication();
+    if (runSetupWizard) {
+      com.gContactSync.Overlay.setStatusBarText(com.gContactSync.StringBundle.getStr("notAuth"));
+      com.gContactSync.Overlay.openAccountWizard(true);
+    } else {
+      com.gContactSync.Sync.schedule(com.gContactSync.Preferences.mSyncPrefs.initialDelayMinutes.value * 60000);
+    }
   },
   /**
    * Calls the original SetBusyCursor() function from mailCore.js wrapped in a
diff --git a/src/content/Overlay.js b/src/content/Overlay.js
index 04a7b87..91a54ca 100644
--- a/src/content/Overlay.js
+++ b/src/content/Overlay.js
@@ -57,7 +57,6 @@ com.gContactSync.Overlay = {
   mLastVersionMinor:   0,
   mLastVersionRelease: 0,
   mLastVersionSuffix:  "",
-  mAccountWizard:      false,
   /**
    * Called when the overlay is loaded and initializes everything and begins
    * the authentication check and sync or login prompt.
@@ -113,36 +112,21 @@ com.gContactSync.Overlay = {
     this.setStatusBarText(text + " " + hours + ":" + minutes + ":" + seconds);
   },
   /**
-   * Checks to see whether or not there is an authentication token in the login
-   * manager.  If so, it begins a sync.  If not, it shows the new account wizard.
-   */
-  checkAuthentication: function Overlay_checkAuthentication() {
-    if (com.gContactSync.gdata.isAuthValid()) {
-      this.updateVersion();  // Make sure the version has been updated
-      if (this.mAccountWizard) {
-        com.gContactSync.Sync.begin(true, null);
-      } else {
-        com.gContactSync.Sync.schedule(com.gContactSync.Preferences.mSyncPrefs.initialDelayMinutes.value * 60000);
-      }
-    } else {
-      this.setStatusBarText(com.gContactSync.StringBundle.getStr("notAuth"));
-      this.openAccountWizard(true);
-    }
-  },
-  /**
    * Prompts the user to enter his or her Google username and password and then
    * gets an authentication token to store and use.
+   * @param aSyncOnUnload {bool} If true will perform a sync when the wizard is closed.
    */
   openAccountWizard: function Overlay_openAccountWizard(aSyncOnUnload) {
     var wizard = window.open("chrome://gcontactsync/content/AccountSetupWizard.xul",
                              "SetupWindow",
                              "chrome,resizable=yes,scrollbars=no,status=no");
-    this.mAccountWizard = true;
     if (aSyncOnUnload === true) {
       // when the setup window loads, set its onunload property to begin a sync
       wizard.onload = function onloadListener() {
         wizard.onunload = function onunloadListener() {
-          com.gContactSync.Overlay.checkAuthentication();
+          if (com.gContactSync.gdata.isAuthValid()) {
+            com.gContactSync.Sync.begin(true, null);
+          }
         };
       };
     }
diff --git a/src/content/Sync.js b/src/content/Sync.js
index a745376..969f09b 100644
--- a/src/content/Sync.js
+++ b/src/content/Sync.js
@@ -109,7 +109,7 @@ com.gContactSync.Sync = {
     if (!com.gContactSync.gdata.isAuthValid()) {
       com.gContactSync.alert(com.gContactSync.StringBundle.getStr("pleaseAuth"));
       return;
-   }
+    }
     // quit if still syncing.
     if (com.gContactSync.Preferences.mSyncPrefs.synchronizing.value) {
       return;
@@ -142,6 +142,7 @@ com.gContactSync.Sync = {
       com.gContactSync.version04Upgrade();
     }
 
+    com.gContactSync.Overlay.updateVersion();
     com.gContactSync.Sync.syncNextUser();
   },
   /**

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/gcontactsync.git



More information about the Pkg-mozext-commits mailing list