Bug 736437 - Chat accounts without protocol plugin aren't correctly handled, r=clokep,bienvenu, a=bienvenu.
authorFlorian Quèze <florian@queze.net>
Thu, 21 Jun 2012 12:28:58 +0200
changeset 11321 fe09587e027c
parent 11320 39e98d760147
child 11322 52a6f232596f
push id609
push userflorian@queze.net
push date2012-06-28 16:17 +0000
treeherdercomm-aurora@52a6f232596f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersclokep, bienvenu, bienvenu
bugs736437
Bug 736437 - Chat accounts without protocol plugin aren't correctly handled, r=clokep,bienvenu, a=bienvenu.
chat/components/src/imAccounts.js
mail/components/im/content/am-im.js
mail/components/im/imIncomingServer.js
--- a/chat/components/src/imAccounts.js
+++ b/chat/components/src/imAccounts.js
@@ -507,17 +507,21 @@ imAccount.prototype = {
     AutoLoginCounter.finishedAutoLogin();
   },
 
   // Delete the account (from the preferences, mozStorage, and call unInit).
   remove: function() {
     let login = Cc["@mozilla.org/login-manager/loginInfo;1"]
                 .createInstance(Ci.nsILoginInfo);
     let passwordURI = "im://" + this.protocol.id;
-    login.init(passwordURI, null, passwordURI, this.normalizedName, "", "", "");
+    // The password is stored with the normalizedName. If the protocol
+    // plugin is missing, we can't access the normalizedName, but in
+    // lots of cases this.name is equivalent.
+    let name = this.prplAccount ? this.normalizedName : this.name;
+    login.init(passwordURI, null, passwordURI, name, "", "", "");
     let logins = LoginManager.findLogins({}, passwordURI, null, passwordURI);
     for each (let l in logins) {
       if (login.matches(l, true)) {
         LoginManager.removeLogin(l);
         break;
       }
     }
     if (this.prplAccount)
--- a/mail/components/im/content/am-im.js
+++ b/mail/components/im/content/am-im.js
@@ -24,19 +24,25 @@ var account = {
     let password = document.getElementById("server.password");
     let passwordBox = document.getElementById("passwordBox");
     if (this.proto.noPassword) {
       passwordBox.hidden = true;
       password.removeAttribute("wsm_persist");
     }
     else {
       passwordBox.hidden = false;
-      // Should we force layout here to ensure password.value works?
-      password.value = this.account.password;
-      password.setAttribute("wsm_persist", "true");
+      try {
+        // Should we force layout here to ensure password.value works?
+        // Will throw if we don't have a protocol plugin for the account.
+        password.value = this.account.password;
+        password.setAttribute("wsm_persist", "true");
+      } catch (e) {
+        passwordBox.hidden = true;
+        password.removeAttribute("wsm_persist");
+      }
     }
 
     document.getElementById("server.alias").value = this.account.alias;
 
     let protoId = this.proto.id;
     let canAutoJoin =
       protoId == "prpl-irc" || protoId == "prpl-jabber" || protoId == "prpl-gtalk";
     document.getElementById("optionalSeparator").hidden = !canAutoJoin;
--- a/mail/components/im/imIncomingServer.js
+++ b/mail/components/im/imIncomingServer.js
@@ -44,17 +44,20 @@ imIncomingServer.prototype = {
     this._prefBranch.deleteBranch("");
     delete this._prefBranch;
     delete this._imAccount;
   },
   // called by nsMsgAccountManager while deleting an account:
   forgetSessionPassword: function() { },
 
   // Shown in the "Remove Account" confirm prompt.
-  get prettyName() this.imAccount.protocol.name + " - " + this.imAccount.name,
+  get prettyName() {
+    let protocol = this.imAccount.protocol.name || this.imAccount.protocol.id;
+    return protocol + " - " + this.imAccount.name;
+  },
 
   //XXX Flo: I don't think these 2 names are visible in the UI:
   get constructedPrettyName() "constructedPrettyName FIXME",
   realHostName: "realHostName FIXME",
 
   port: 0,
   accountManagerChrome: "am-im.xul",
 
@@ -208,17 +211,17 @@ imIncomingServer.prototype = {
     };
   },
 
   // nsMsgDBFolder.cpp crashes in HandleAutoCompactEvent if this doesn't exist:
   msgStore: {
     supportsCompaction: false
   },
 
-  get serverURI() "im://" + this.imAccount.protocol.id + "/" + this.imAccount.normalizedName,
+  get serverURI() "im://" + this.imAccount.protocol.id + "/" + this.imAccount.name,
   _rootFolder: null,
   get rootMsgFolder() this.rootFolder,
   get rootFolder() {
     if (this._rootFolder)
       return this._rootFolder;
 
     return (this._rootFolder = {
       isServer: true,