Bug 953730 - indicate in the account manager when the password for an account is missing. r=Morian
authorFlorian Quèze <florian@instantbird.org>
Thu, 04 Mar 2010 23:52:15 +0100
changeset 17986 02c8752883c95eb842e0e3391f28145a332aa173
parent 17985 8257aff9725f5cbea0cccde885291613638460e2
child 17987 9e44431d78f13871dbe84ad12790a4795b9a5c4a
push idunknown
push userunknown
push dateunknown
reviewersMorian
bugs953730
Bug 953730 - indicate in the account manager when the password for an account is missing. r=Morian
im/content/account.js
im/content/account.xml
im/content/accounts.js
im/locales/en-US/chrome/instantbird/accounts.properties
--- a/im/content/account.js
+++ b/im/content/account.js
@@ -318,20 +318,22 @@ var account = {
 
     if (connectionInfoHasChanged) {
       /* This is the first time we try to connect with these parameters */
       this.account.firstConnectionState = this.account.FIRST_CONNECTION_SET;
 
       if (this.account.connecting) {
         this.account.disconnect();
         this.account.connect();
+        return;
       }
       let errorReason = this.account.connectionErrorReason;
       if (this.account.disconnected &&
           errorReason != Ci.purpleIAccount.NO_ERROR &&
+          errorReason != Ci.purpleIAccount.ERROR_MISSING_PASSWORD &&
           errorReason != Ci.purpleIAccount.ERROR_CRASHED &&
           errorReason != Ci.purpleIAccount.ERROR_UNKNOWN_PRPL) {
         this.account.connect();
       }
     }
   },
 
   getProtoOptions: function account_getProtoOptions() {
--- a/im/content/account.xml
+++ b/im/content/account.xml
@@ -91,16 +91,18 @@
         var state = "Unknown";
         if (this._account.connected) {
           state = "connected";
           this.refreshConnectedLabel();
         } else if (this._account.disconnected) {
           state = "disconnected";
           if (this._account.connectionErrorReason != Ci.purpleIAccount.NO_ERROR)
             this.updateConnectionError();
+          else
+            this.removeAttribute("error");
         } else if (this._account.connecting) {
           state = "connecting";
           this.updateConnectionState();
         } else if (this._account.disconnecting) {
           state = "connected";
         }
         this.setAttribute("state", state);
         this.autoLogin = aAccount.autoLogin;
@@ -127,20 +129,23 @@
 
      <method name="updateConnectionError">
       <body>
       <![CDATA[
         var bundle = document.getElementById("accountsBundle");
         const key = "account.connection.error";
         var account = this._account;
         var text;
-        if (account.connectionErrorReason == Ci.purpleIAccount.ERROR_UNKNOWN_PRPL)
+        let errorReason = account.connectionErrorReason;
+        if (errorReason == Ci.purpleIAccount.ERROR_UNKNOWN_PRPL)
           text = bundle.getFormattedString(key + "UnknownPrpl",
                                            [account.protocol.id]);
-        else if (account.connectionErrorReason == Ci.purpleIAccount.ERROR_CRASHED)
+        else if (errorReason == Ci.purpleIAccount.ERROR_MISSING_PASSWORD)
+          text = bundle.getString(key + "MissingPassword");
+        else if (errorReason == Ci.purpleIAccount.ERROR_CRASHED)
           text = bundle.getString(key + "CrashedAccount");
         else
           text = account.connectionErrorMessage;
         text = bundle.getFormattedString(key, [text]);
 
         this.setAttribute("error", "true");
         var error = document.getAnonymousElementByAttribute(this, "anonid",
                                                             "error");
--- a/im/content/accounts.js
+++ b/im/content/accounts.js
@@ -172,18 +172,20 @@ var gAccountManager = {
       if (!count) {
         document.getElementById("accountsDesk").selectedIndex = 0;
         return;
       }
       if (selectedIndex == count)
         --selectedIndex;
       this.accountList.selectedIndex = selectedIndex;
     }
-    else if (aTopic == "account-updated")
+    else if (aTopic == "account-updated") {
       document.getElementById(aObject.id).build(aObject);
+      this.disableCommandItems();
+    }
     else if (aTopic == "account-connect-progress")
       document.getElementById(aObject.id).updateConnectionState();
     else if (aTopic == "account-connect-error")
       document.getElementById(aObject.id).updateConnectionError();
     else {
       const stateEvents = {
         "account-connected": "connected",
         "account-connecting": "connecting",
@@ -316,17 +318,18 @@ var gAccountManager = {
       return;
 
     let account = selectedItem.account;
     let activeCommandName = account.disconnected ? "connect" : "disconnect";
     let activeCommandElt = document.getElementById("cmd_" + activeCommandName);
     let isCommandDisabled =
       (this.isOffline ||
        (account.disconnected &&
-        account.connectionErrorReason == Ci.purpleIAccount.ERROR_UNKNOWN_PRPL));
+        (account.connectionErrorReason == Ci.purpleIAccount.ERROR_UNKNOWN_PRPL ||
+         account.connectionErrorReason == Ci.purpleIAccount.ERROR_MISSING_PASSWORD)));
 
     [[activeCommandElt, isCommandDisabled],
      [document.getElementById("cmd_moveup"), accountList.selectedIndex == 0],
      [document.getElementById("cmd_movedown"),
       accountList.selectedIndex == accountList.itemCount - 1]
     ].forEach(function (aEltArray) {
       let [elt, state] = aEltArray;
       if (state)
--- a/im/locales/en-US/chrome/instantbird/accounts.properties
+++ b/im/locales/en-US/chrome/instantbird/accounts.properties
@@ -2,16 +2,17 @@
 protoOptions=%S Options
 accountUsername=Username:
 accountColon=%S:
 accountUsernameInfo=Please enter the username for your %S account.
 accountUsernameInfoWithDescription=Please enter the username (%S) for your %S account.
 
 account.connection.error=Error: %S
 account.connection.errorUnknownPrpl= No '%S' protocol plugin.
+account.connection.errorMissingPassword=A password is required to connect this account.
 account.connection.errorCrashedAccount=A crash occurred while connecting this account.
 account.connection.progress=Connecting: %S…
 account.connecting=Connecting…
 account.connectedForSeconds=Connected for a few seconds.
 account.connectedForDouble=Connected for %S %S and %S %S.
 account.connectedForSingle=Connected for about %S %S.
 account.reconnectInDouble=Reconnection in %S %S and %S %S.
 account.reconnectInSingle=Reconnection in %S %S.