[Pkg-mozext-commits] [gcontactsync] 16/88: Added a new account wizard that will be displayed the first time gContactSync runs as well as when the user adds a new account

David Prévot taffit at moszumanska.debian.org
Thu Sep 18 20:52:25 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 ef600df554dff221902054439c926d804dd0b116
Author: Josh Geenen <joshgeenen at gmail.com>
Date:   Sat Dec 28 09:21:24 2013 -0600

    Added a new account wizard that will be displayed the first time gContactSync runs as well as when the user adds a new account
---
 src/chrome.manifest                     |   1 +
 src/content/AccountSetupWizard.js       | 214 ++++++++++++++++++++++++++++++++
 src/content/AccountSetupWizard.xul      | 160 ++++++++++++++++++++++++
 src/content/Accounts.js                 |  42 ++++---
 src/content/Accounts.xul                |   2 +-
 src/content/LoginManager.js             |  12 +-
 src/content/MessengerOverlay.js         |   8 +-
 src/locale/en-US/AccountSetupWizard.dtd |  15 +++
 src/locale/en-US/options.dtd            |   6 +-
 9 files changed, 429 insertions(+), 31 deletions(-)

diff --git a/src/chrome.manifest b/src/chrome.manifest
index b7b80f3..27859b3 100644
--- a/src/chrome.manifest
+++ b/src/chrome.manifest
@@ -10,6 +10,7 @@ overlay  chrome://messenger/content/addressbook/abEditCardDialog.xul  chrome://g
 overlay  chrome://messenger/content/addressbook/abNewCardDialog.xul   chrome://gcontactsync/content/CardDialogOverlay.xul
 
 style    chrome://gcontactsync/content/ABOverlay.xul                  chrome://gcontactsync/skin/overlay.css
+style    chrome://gcontactsync/content/AccountSetupWizard.xul         chrome://gcontactsync/skin/overlay.css
 style    chrome://gcontactsync/content/MessengerOverlay.xul           chrome://gcontactsync/skin/overlay.css
 style    chrome://global/content/customizeToolbar.xul                 chrome://gcontactsync/skin/overlay.css
 style    chrome://messenger/content/addressbook/addressbook.xul       chrome://gcontactsync/skin/overlay.css
diff --git a/src/content/AccountSetupWizard.js b/src/content/AccountSetupWizard.js
new file mode 100644
index 0000000..5209e81
--- /dev/null
+++ b/src/content/AccountSetupWizard.js
@@ -0,0 +1,214 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is gContactSync.
+ *
+ * The Initial Developer of the Original Code is
+ * Josh Geenen <gcontactsync at pirules.org>.
+ * Portions created by the Initial Developer are Copyright (C) 2013
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+if (!com) {var com = {};} // A generic wrapper variable
+// A wrapper for all GCS functions and variables
+if (!com.gContactSync) {com.gContactSync = {};}
+
+window.addEventListener("load",
+  /** Initializes the AccountSetupWizard class when the window has finished loading */
+  function gCS_AccountSetupWizardLoadListener(e) {
+    com.gContactSync.AccountSetupWizard.init();
+    window.sizeToContent();
+  },
+false);
+
+/**
+ * Provides helper functions for the initial setup wizard.
+ */
+com.gContactSync.AccountSetupWizard = {
+  NEW_ACCOUNT_IDS:      ["emailLabel", "email", "passwordLabel", "password"],
+  EXISTING_ACCOUNT_IDS: ["existingAccountList"],
+  mAuthToken:           "",
+  mEmailAddress:        "",
+  mAccounts:            [],
+  /**
+   */
+  init: function AccountSetupWizard_init() {
+    this.updateAccountIDs();
+    this.addAccounts();
+  },
+  addAccounts: function AccountSetupWizard_addAccounts() {
+    com.gContactSync.LOGGER.VERBOSE_LOG("Adding accounts");
+    this.mAccounts = [];
+    var authTokens = com.gContactSync.LoginManager.getAuthTokens();
+    var accountsMenuList = document.getElementById("existingAccountList");
+    for (var username in authTokens) {
+      if (this.accountAlreadyExists(username)) {continue;}
+      com.gContactSync.LOGGER.VERBOSE_LOG(" * Adding existing auth token for " + username);
+      this.mAccounts.push({username: username, token: authTokens[username]});
+      accountsMenuList.appendItem(username);
+    }
+    var emailAccounts = com.gContactSync.LoginManager.getAllEmailAccts();
+    for (var i = 0; i < emailAccounts.length; ++i) {
+      if (this.accountAlreadyExists(emailAccounts[i].username)) {continue;}
+      com.gContactSync.LOGGER.VERBOSE_LOG(" * Adding e-mail address: " + emailAccounts[i].username);
+      this.mAccounts.push(emailAccounts[i]);
+      accountsMenuList.appendItem(emailAccounts[i].username);
+    }
+    if (accountsMenuList.itemCount === 0) {
+      document.getElementById("accountOption").selectedIndex = 1;
+      document.getElementById("existingAccount").disabled = 1;
+      accountsMenuList.appendItem(com.gContactSync.StringBundle.getStr('noAccountsFound'));
+      this.updateAccountIDs();
+    }
+    accountsMenuList.selectedIndex = 0;
+  },
+  accountAlreadyExists: function AccountSetupWizard_accountAlreadyExists(username) {
+    username = username.toLowerCase();
+    for (var i = 0; i < this.mAccounts.length; ++i) {
+      if (this.mAccounts[i].username.toLowerCase() === username) {return true;}
+    }
+    return false;
+  },
+
+  updateAccountIDs: function AccountSetupWizard_updateAccountIDs() {
+    var option = document.getElementById("accountOption");
+    var disableIDs = this.EXISTING_ACCOUNT_IDS;
+    var enableIDs  = this.NEW_ACCOUNT_IDS;
+    if (option.value === "existing") {
+      disableIDs = this.NEW_ACCOUNT_IDS;
+      enableIDs  = this.EXISTING_ACCOUNT_IDS;
+    }
+    for (var i = 0; i < disableIDs.length; ++i) {
+      document.getElementById(disableIDs[i]).disabled = true;
+    }
+    for (var j = 0; j < enableIDs.length; ++j) {
+      document.getElementById(enableIDs[j]).disabled = false;
+    }
+  },
+  advanceAccountPage: function AccountSetupWizard_advancedAccountPage() {
+
+    // Try to get a token for the account
+    // If there's already a token it was advanced by a successful authentication.
+    if (this.mAuthToken !== "") {
+      return true;
+    }
+
+    var option = document.getElementById("accountOption");
+    var password = "";
+
+    com.gContactSync.LOGGER.VERBOSE_LOG("Advancing account page using a(n) " + option.value + " account.");
+
+    if (option.value === "existing") {
+      var index = document.getElementById("existingAccountList").selectedIndex;
+      this.mEmailAddress = this.mAccounts[index].username;
+      if ("token" in this.mAccounts[index]) {
+        com.gContactSync.LOGGER.VERBOSE_LOG(" * Already have a token");
+        this.mAuthToken = this.mAccounts[index].token;
+        return true;
+      }
+      password = this.mAccounts[index].password;
+    } else {
+      var emailElem    = document.getElementById("email");
+      var passwordElem = document.getElementById("password");
+      this.mEmailAddress = emailElem.value;
+      password = passwordElem.value;
+      // This is a primitive way of validating an e-mail address, but Google takes
+      // care of the rest.  It seems to allow getting an auth token w/ only the
+      // username, but returns an error when trying to do anything w/ that token
+      // so this makes sure it is a full e-mail address.
+      if (this.mEmailAddress.indexOf("@") < 1) {
+        com.gContactSync.alertError(com.gContactSync.StringBundle.getStr("invalidEmail"));
+        return false;
+      }
+    }
+
+    com.gContactSync.LOGGER.VERBOSE_LOG(" * Requesting a token for " + this.mEmailAddress);
+
+    var body    = com.gContactSync.gdata.makeAuthBody(this.mEmailAddress, password);
+    var httpReq = new com.gContactSync.GHttpRequest("authenticate", null, null, body);
+    // Move to the next page in the wizard upon successful authentication
+    httpReq.mOnSuccess = function authSuccess(httpReq) {
+      com.gContactSync.AccountSetupWizard.mAuthToken = httpReq.responseText.split("\n")[2];
+      com.gContactSync.LoginManager.addAuthToken(aUsername, 'GoogleLogin ' + aAuthToken);
+      document.getElementById("initialSetupWizard").advance();
+    };
+    // if it fails, alert the user and prompt them to try again
+    httpReq.mOnError = function authError(httpReq) {
+      com.gContactSync.alertError(com.gContactSync.StringBundle.getStr('authErr'));
+      com.gContactSync.LOGGER.LOG_ERROR('Authentication Error - ' +
+                                        httpReq.status,
+                                        httpReq.responseText);
+    };
+    // if the user is offline, alert them and quit
+    httpReq.mOnOffline = function authOffline(httpReq) {
+      com.gContactSync.alertError(com.gContactSync.StringBundle.getStr('offlineStatusText'));
+      com.gContactSync.LOGGER.LOG_ERROR('Authentication Error (offline) - ' +
+                                        httpReq.status,
+                                        httpReq.responseText);
+    };
+    httpReq.send();
+    // Don't let the page advance until a successful response is returned.
+    return false;
+  },
+  setupAccountSettings: function AccountSetupWizard_setupAccountSettings(aSearch) {
+    var abNameElem = document.getElementById("abName");
+    abNameElem.removeAllItems();
+    var abs = com.gContactSync.GAbManager.getAllAddressBooks();
+    var selectedIndex = -1;
+    var i = 0;
+    aSearch = (aSearch || this.mEmailAddress).toLowerCase();
+    for (var uri in abs) {
+      if (abs.hasOwnProperty(uri)) {
+        abNameElem.appendItem(abs[uri].getName(), uri);
+        if (abs[uri].getName().toLowerCase() === aSearch) {
+          selectedIndex = i;
+        }
+      }
+      ++i;
+    }
+    if (selectedIndex === -1) {
+      abNameElem.insertItemAt(0, this.mEmailAddress, 0);
+      selectedIndex = 0;
+    }
+    abNameElem.selectedIndex = selectedIndex;
+    com.gContactSync.Accounts.restoreGroups();
+  },
+  /**
+   * Creates and returns a new address book after requesting a name for it.
+   * If an AB of any type already exists this function will do nothing.
+   */
+  newAddressBook: function AccountSetupWizard_newAddressBook() {
+    var name = com.gContactSync.prompt(com.gContactSync.StringBundle.getStr("newABPrompt"), null, window);
+    if (!name) {
+      return;
+    }
+    com.gContactSync.AbManager.getAbByName(name);
+    this.setupAccountSettings(name);
+  }
+};
+
diff --git a/src/content/AccountSetupWizard.xul b/src/content/AccountSetupWizard.xul
new file mode 100644
index 0000000..7ee6812
--- /dev/null
+++ b/src/content/AccountSetupWizard.xul
@@ -0,0 +1,160 @@
+<?xml version="1.0"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+   - Version: MPL 1.1/GPL 2.0/LGPL 2.1
+   -
+   - The contents of this file are subject to the Mozilla Public License Version
+   - 1.1 (the "License"); you may not use this file except in compliance with
+   - the License. You may obtain a copy of the License at
+   - http://www.mozilla.org/MPL/
+   -
+   - Software distributed under the License is distributed on an "AS IS" basis,
+   - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+   - for the specific language governing rights and limitations under the
+   - License.
+   -
+   - The Original Code is gContactSync.
+   -
+   - The Initial Developer of the Original Code is
+   - Josh Geenen <gcontactsync at pirules.org>.
+   - Portions created by the Initial Developer are Copyright (C) 2013
+   - the Initial Developer. All Rights Reserved.
+   -
+   - Contributor(s):
+   -
+   - Alternatively, the contents of this file may be used under the terms of
+   - either the GNU General Public License Version 2 or later (the "GPL"), or
+   - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+   - in which case the provisions of the GPL or the LGPL are applicable instead
+   - of those above. If you wish to allow use of your version of this file only
+   - under the terms of either the GPL or the LGPL, and not to allow others to
+   - use your version of this file under the terms of the MPL, indicate your
+   - decision by deleting the provisions above and replace them with the notice
+   - and other provisions required by the LGPL or the GPL. If you do not delete
+   - the provisions above, a recipient may use your version of this file under
+   - the terms of any one of the MPL, the GPL or the LGPL.
+   -
+   - ***** END LICENSE BLOCK ***** -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<!--<?xml-stylesheet href="chrome://gcontactsync/skin/AccountSetupWizard.css" type="text/css"?>-->
+<!DOCTYPE window [
+  <!ENTITY % initialSetupDTD SYSTEM "chrome://gcontactsync/locale/AccountSetupWizard.dtd">
+  %initialSetupDTD;
+  <!ENTITY % accountsDTD SYSTEM "chrome://gcontactsync/locale/Accounts.dtd">
+  %accountsDTD;
+]>
+
+<wizard id="initialSetupWizard" title="&title.label;"
+          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/synonyms.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/LoginManager.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/StringBundle.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/FileIO.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/Logger.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/Pref.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/Namespace.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/GElement.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/gdata.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/Preferences.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/HttpRequest.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/GHttpRequest.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/AddressBook.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/GAddressBook.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/AbManager.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/GAbManager.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/Group.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/Accounts.js"/>
+  <script type="application/x-javascript"
+          src="chrome://gcontactsync/content/AccountSetupWizard.js"/>
+  <stringbundleset id="stringbundleset">
+    <stringbundle id="gContactSyncStringBundle"
+                  src="chrome://gContactSync/locale/gcontactsync.properties"/>
+  </stringbundleset>
+  <wizardpage onpageadvanced="return com.gContactSync.AccountSetupWizard.advanceAccountPage();"
+              id="accountPage">
+    <description>
+      &account.description;
+    </description>
+
+    <radiogroup id="accountOption"
+                onselect="com.gContactSync.AccountSetupWizard.updateAccountIDs();">
+      <radio id="existingAccount"
+             label="&existingAccount.label;"
+             value="existing"
+             selected="true"/>
+      <menulist id="existingAccountList">
+        <menupopup id="existingAccountPopup"/>
+      </menulist>
+      <spacer height="5px"/>
+      <radio id="newAccount" label="&newAccount.label;" value="new"/>
+      <grid flex="1" id="newAccountGrid">
+        <columns>
+          <column/>
+          <column/>
+        </columns>
+        <rows>
+          <row align="center">
+            <label id="emailLabel" value="&email.value;" control="email"/>
+            <textbox id="email"/>
+          </row>
+          <row align="center">
+            <label id="passwordLabel" value="&password.value;" control="password"/>
+            <textbox id="password" type="password"/>
+          </row>
+        </rows>
+      </grid>
+    </radiogroup>
+  </wizardpage>
+
+  <wizardpage description="&accountSettings.description;"
+              onpagerewound="com.gContactSync.AccountSetupWizard.mAuthToken='';"
+              onpageshow="com.gContactSync.AccountSetupWizard.setupAccountSettings();">
+    <label control="abName" value="&abName.value;"/>
+    <hbox>
+      <menulist id="abName">
+        <menupopup id="abNamePopup"/>
+      </menulist>
+      <button id="newABButton"
+              label="&newABButton.label;"
+              accesskey="&newABButton.accesskey;"
+              oncommand="com.gContactSync.AccountSetupWizard.newAddressBook();"/>
+    </hbox>
+    <spacer height="5px"/>
+    <label control="Groups" value="&Groups.label;"/>
+    <hbox id="GroupsBox">
+      <menulist id="Groups">
+        <menupopup id="GroupsPopup">
+          <menuitem class="default" value="All"        label="&AllGroups.label;"/>
+          <menuitem class="default" value="false"      label="&NoGroups.label;"/>
+          <menuitem class="default" value="contacts"   label="&Contacts.label;" selected="true"/>
+          <menuitem class="default" value="coworkers"  label="&Coworkers.label;"/>
+          <menuitem class="default" value="family"     label="&Family.label;"/>
+          <menuitem class="default" value="friends"    label="&Friends.label;"/>
+        </menupopup>
+      </menulist>
+      <button id="GetGroups"
+              oncommand="com.gContactSync.Accounts.getAllGroups(com.gContactSync.AccountSetupWizard.mEmailAddress);"
+              label="&GetGroups.label;"
+              accesskey="&GetGroups.accesskey;"/>
+    </hbox>
+    <spacer flex="1"/>
+    <label align="end" value="&finish.value;"/>
+  </wizardpage>
+</wizard>
diff --git a/src/content/Accounts.js b/src/content/Accounts.js
index 0fa7309..4d0679a 100644
--- a/src/content/Accounts.js
+++ b/src/content/Accounts.js
@@ -34,9 +34,9 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
-if (!com) var com = {}; // A generic wrapper variable
+if (!com) {var com = {};} // A generic wrapper variable
 // A wrapper for all GCS functions and variables
-if (!com.gContactSync) com.gContactSync = {};
+if (!com.gContactSync) {com.gContactSync = {};}
 
 window.addEventListener("load",
   /** Initializes the Accounts class when the window has finished loading */
@@ -73,6 +73,9 @@ com.gContactSync.Accounts = {
    * filling in the usernames, hiding the advanced settings, etc.
    */
   initDialog:  function Accounts_initDialog() {
+    // This script is also included by the account setup wizard.
+    // Only run these initialization functions on the account dialog.
+    if (document.getElementById("showAdvanced") === null) {return;}
     try {
       this.fillAbTree();
       this.fillUsernames();
@@ -81,8 +84,6 @@ com.gContactSync.Accounts = {
     }
     catch (e) {
       com.gContactSync.LOGGER.LOG_WARNING("Error in Accounts.initDialog", e);
-      // TODO remove the alert
-      com.gContactSync.alertError(e);
     }
   },
   /**
@@ -408,33 +409,38 @@ com.gContactSync.Accounts = {
    * Restores the Groups menulist to contain only the default groups.
    */
   restoreGroups: function Accounts_restoreGroups() {
-    var groupElem = document.getElementById("GroupsPopup");
-    for (var i = groupElem.childNodes.length - 1; i > -1; i--) {
-      if (groupElem.childNodes[i].getAttribute("class") !== "default")
-        groupElem.removeChild(groupElem.childNodes[i]);
+    var groupElem = document.getElementById("Groups");
+    for (var i = 0; i < groupElem.itemCount;) {
+      if (groupElem.getItemAtIndex(i).getAttribute("class") != "default") {
+        groupElem.removeItemAt(i);
+      } else {
+        ++i;
+      }
+    }
+    var groupsElem = document.getElementById("Groups");
+    if (groupsElem.selectedIndex >= groupsElem.itemCount) {
+      groupsElem.selectedIndex = 2;
     }
   },
   /**
    * Fetch all groups for the selected account and add custom groups to the
    * menulist.
    */
-  getAllGroups: function Accounts_getAllGroups() {
-    var usernameElem  = document.getElementById("Username");
+  getAllGroups: function Accounts_getAllGroups(aUsername) {
     this.restoreGroups();
-    if (usernameElem.value === "none" || !usernameElem.value)
+    if (!aUsername || aUsername === "none")
       return false;
-    var token = com.gContactSync.LoginManager.getAuthTokens()[usernameElem.value];
+    var token = com.gContactSync.LoginManager.getAuthTokens()[aUsername];
     if (!token) {
-      com.gContactSync.LOGGER.LOG_WARNING("Unable to find the token for username " + usernameElem.value);
+      com.gContactSync.LOGGER.LOG_WARNING("Unable to find the token for username " + aUsername);
       return false;
     }
-    com.gContactSync.LOGGER.VERBOSE_LOG("Fetching groups for username: " + usernameElem.value);
+    com.gContactSync.LOGGER.VERBOSE_LOG("Fetching groups for username: " + aUsername);
     var httpReq = new com.gContactSync.GHttpRequest("getGroups", token, null,
-                                   null, usernameElem.value);
+                                   null, aUsername);
     httpReq.mOnSuccess = function getAllGroupsSuccess(httpReq) {
       com.gContactSync.LOGGER.VERBOSE_LOG(com.gContactSync.serializeFromText(httpReq.responseText));
-      com.gContactSync.Accounts.addGroups(httpReq.responseXML,
-                                          usernameElem.value);
+      com.gContactSync.Accounts.addGroups(httpReq.responseXML, aUsername);
     };
     httpReq.mOnError   = function getAllGroupsError(httpReq) {
       com.gContactSync.LOGGER.LOG_ERROR(httpReq.responseText);
@@ -458,7 +464,7 @@ com.gContactSync.Accounts = {
     if (!aAtom) {
       return false;
     }
-    if (usernameElem.value === "none" || usernameElem.value !== aUsername) {
+    if (usernameElem !== null && (usernameElem.value === "none" || usernameElem.value !== aUsername)) {
       return false;
     }
     arr = aAtom.getElementsByTagNameNS(com.gContactSync.gdata.namespaces.ATOM.url, "entry");
diff --git a/src/content/Accounts.xul b/src/content/Accounts.xul
index 8edf78a..286e720 100644
--- a/src/content/Accounts.xul
+++ b/src/content/Accounts.xul
@@ -98,7 +98,7 @@
             </menupopup>
           </menulist>
           <button id="GetGroups"
-                  oncommand="com.gContactSync.Accounts.getAllGroups();"
+                  oncommand="com.gContactSync.Accounts.getAllGroups(document.getElementById('Username').value);"
                   label="&GetGroups.label;"
                   accesskey="&GetGroups.accesskey;"/>
         </hbox>
diff --git a/src/content/LoginManager.js b/src/content/LoginManager.js
index 13d5ae5..0f8a1b3 100644
--- a/src/content/LoginManager.js
+++ b/src/content/LoginManager.js
@@ -15,7 +15,7 @@
  *
  * The Initial Developer of the Original Code is
  * Josh Geenen <gcontactsync at pirules.org>.
- * Portions created by the Initial Developer are Copyright (C) 2008-2009
+ * Portions created by the Initial Developer are Copyright (C) 2008-2013
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
@@ -34,9 +34,9 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
-if (!com) var com = {}; // A generic wrapper variable
+if (!com) {var com = {};} // A generic wrapper variable
 // A wrapper for all GCS functions and variables
-if (!com.gContactSync) com.gContactSync = {};
+if (!com.gContactSync) {com.gContactSync = {};}
 
 /**
  * Stores and retrieves the authentication token from the login manager.
@@ -165,7 +165,7 @@ com.gContactSync.LoginManager = {
       aUsername = aUsername.toLowerCase();
       // Find user from returned array of nsILoginInfo objects
       for (var i = 0; i < logins.length; i++) {
-        if (logins[i].username.toLowerCase() == aUsername) {
+        if (logins[i].username.toLowerCase() === aUsername) {
           try {
             com.gContactSync.LOGGER.VERBOSE_LOG("Found the login to remove");
             loginManager.removeLogin(logins[i]);
@@ -201,7 +201,7 @@ com.gContactSync.LoginManager = {
           var pass = iter.getNext().QueryInterface(Components.interfaces.nsIPassword);
           if (pass.host.indexOf("imap://") === 0 || pass.host.indexOf("mailbox://") === 0) {
             if (!aPattern || aPattern.test(pass.user)) {
-              arr.push(pass.user);
+              arr.push({username: pass.user, hostname: pass.host, password: pass.password});
             }
           }
         } catch (e) {}
@@ -222,7 +222,7 @@ com.gContactSync.LoginManager = {
         hostname = logins[i].hostname;
         if (hostname.indexOf("imap://") === 0 || hostname.indexOf("mailbox://") === 0) {
           if (!aPattern || aPattern.test(logins[i].username)) {
-            arr.push(logins[i].username);
+            arr.push({username: logins[i].username, hostname: hostname, password: logins[i].password});
           }
         }
       }
diff --git a/src/content/MessengerOverlay.js b/src/content/MessengerOverlay.js
index 5ea3741..2ae0e39 100644
--- a/src/content/MessengerOverlay.js
+++ b/src/content/MessengerOverlay.js
@@ -92,15 +92,15 @@ com.gContactSync.MessengerOverlay = {
     com.gContactSync.Preferences.setSyncPref("synchronizing", false);
 
     // On the first run display a login prompt
-    if (!lastVersionMinor) {
+    if (lastVersionMajor === lastVersionMinor === lastVersionRelease === 0) {
       com.gContactSync.Overlay.setStatusBarText(com.gContactSync.StringBundle.getStr("notAuth"));
       com.gContactSync.MessengerOverlay.promptLogin();
     } else {
 
       // If moving from 0.3.x or <0.4.0b1 then update the chat names
       // The upgrade will take place during the next sync
-      if (((lastVersionMajor == 0) && (lastVersionMinor < 4)) ||
-          ((lastVersionRelease == 0) && (lastVersionSuffix.length > 0) && (lastVersionSuffix.charAt(0) == "a"))) {
+      if (((lastVersionMajor === 0) && (lastVersionMinor < 4)) ||
+          ((lastVersionRelease === 0) && (lastVersionSuffix.length > 0) && (lastVersionSuffix.charAt(0) === "a"))) {
         com.gContactSync.Preferences.setSyncPref("v04UpgradeNeeded", true);
       }
 
@@ -225,6 +225,7 @@ com.gContactSync.MessengerOverlay = {
    * gets an authentication token to store and use.
    */
   promptLogin: function MessengerOverlay_promptLogin() {
+    // TODO - open the initial login wizard
     var prompt   = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
                              .getService(Components.interfaces.nsIPromptService)
                              .promptUsernameAndPassword;
@@ -275,6 +276,7 @@ com.gContactSync.MessengerOverlay = {
    * @param aAuthToken {string} The authentication token to store.
    */
   login: function MessengerOverlay_login(aUsername, aAuthToken) {
+    // TODO REMOVE
     com.gContactSync.LoginManager.addAuthToken(aUsername, 'GoogleLogin ' + aAuthToken);
     com.gContactSync.Overlay.setStatusBarText(com.gContactSync.StringBundle.getStr("initialSetup"));
     var setup = window.open("chrome://gcontactsync/content/FirstLogin.xul",
diff --git a/src/locale/en-US/AccountSetupWizard.dtd b/src/locale/en-US/AccountSetupWizard.dtd
new file mode 100644
index 0000000..94de979
--- /dev/null
+++ b/src/locale/en-US/AccountSetupWizard.dtd
@@ -0,0 +1,15 @@
+<!ENTITY title.label                 "gContactSync Wizard">
+
+<!ENTITY account.description         "Select the account to sync or enter your Google Account credentials below.">
+<!ENTITY account2.description        "You may setup additional accounts later.">
+<!ENTITY existingAccount.label       "Use an existing account (must be a Google Account)">
+<!ENTITY newAccount.label            "Use a new account">
+<!ENTITY email.value                 "E-mail Address:">
+<!ENTITY password.value              "Password:">
+<!ENTITY newAccount.label            "Use a new account">
+
+<!ENTITY accountSettings.description "Account Settings">
+<!ENTITY newABButton.label           "New">
+<!ENTITY newABButton.accesskey       "N">
+<!ENTITY openAccounts.label          "Open Accounts dialog when finished">
+<!ENTITY finish.value                "Click Finish to add the account and synchronize.">
diff --git a/src/locale/en-US/options.dtd b/src/locale/en-US/options.dtd
index e991307..c2d0612 100644
--- a/src/locale/en-US/options.dtd
+++ b/src/locale/en-US/options.dtd
@@ -1,4 +1,4 @@
-<!ENTITY title.label "gContactSync Preferences">
+<!ENTITY title.label                    "gContactSync Preferences">
 
 <!ENTITY main.tab                       "Main">
 <!ENTITY help.value                     "Help">
@@ -7,7 +7,7 @@
 <!ENTITY autoSync.label                 "Synchronize contacts automatically">
 <!ENTITY refreshInterval.value          "Synchronize Interval (minutes) [Default is 120 (2 hours)]">
 <!ENTITY initialDelayMinutes.value      "Initial sync delay (minutes) [Default is 5]">
-<!ENTITY abName.value                   "Name of the Address Book to sync with (should be new)">
+<!ENTITY abName.value                   "Address Book to synchronize">
 <!ENTITY syncBehavior.label             "Sync Behavior">
 <!ENTITY syncAddresses.label            "Synchronize postal addresses">
 <!ENTITY alertSummary.label             "Display a summary after every manual sync">
@@ -21,7 +21,7 @@
 <!ENTITY interface.tab                  "Interface">
 <!ENTITY buttons.label                  "Buttons and Menus">
 <!ENTITY enableMenu.label               "Enable the gContactSync Menu">
-<!ENTITY enableMenuLinks.label          "Add some links (Wiki, FAQ, etc.) to the gContactSync Menu">
+<!ENTITY enableMenuLinks.label          "Add some links (Error Report Form, FAQ, etc.) to the gContactSync Menu">
 <!ENTITY addReset.label                 "Add Replace to and Replace from Server links to the Address Book context menu">
 <!ENTITY abResults.label                "Contacts List">
 <!ENTITY phoneColLabels.label           "Rename the phone column labels">

-- 
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