Bug 553757 SMTP server dialog doesn't size to fit all password options r=IanN r=mconley
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Mon, 14 Jul 2014 00:45:37 +0100
changeset 16518 6af58bc18eed796171365e272e8f1f4d3f368efa
parent 16517 eb8d2c2ab8dae5f51a38fe28d812a13d72ceb766
child 16519 32b8c18a0abf09ea1ab10589d65fb953ea6ec822
push id10274
push userneil@parkwaycc.co.uk
push dateSun, 13 Jul 2014 23:45:43 +0000
treeherdercomm-central@6af58bc18eed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, mconley
bugs553757
Bug 553757 SMTP server dialog doesn't size to fit all password options r=IanN r=mconley
mailnews/base/prefs/content/smtpEditOverlay.js
mailnews/base/prefs/content/smtpEditOverlay.xul
--- a/mailnews/base/prefs/content/smtpEditOverlay.js
+++ b/mailnews/base/prefs/content/smtpEditOverlay.js
@@ -29,41 +29,46 @@ function initSmtpSettings(server) {
     gSmtpAuthMethod = document.getElementById("smtp.authMethod");
     gSmtpSocketType = document.getElementById("smtp.socketType");
     gDefaultPort = document.getElementById("smtp.defaultPort");
     gPort = document.getElementById("smtp.port");
 
     if (server) {
         gSmtpHostname.value = server.hostname;
         gSmtpDescription.value = server.description;
-        gSmtpPort.value = server.port ? server.port : "";
+        gSmtpPort.value = server.port;
         gSmtpUsername.value = server.username;
         gSmtpAuthMethod.value = server.authMethod;
         gSmtpSocketType.value = (server.socketType < 4) ? server.socketType : 1;
     } else {
-        // When does that happen? TODO Get default prefs, if realistic, otherwise remove
-        gSmtpAuthMethod.value = 3; // cleartext
-        gSmtpSocketType.value = 0;
+        // New server, load default values.
+        gSmtpAuthMethod.value = Services.prefs.getIntPref("mail.smtpserver.default.authMethod");
+        gSmtpSocketType.value = Services.prefs.getIntPref("mail.smtpserver.default.try_ssl");
     }
 
+    // Although sslChanged will set a label for cleartext password,
+    // we need to use the long label so that we can size the dialog.
+    setLabelFromStringBundle("authMethod-no", "authNo");
+    setLabelFromStringBundle("authMethod-password-encrypted",
+        "authPasswordEncrypted");
+    setLabelFromStringBundle("authMethod-password-cleartext",
+        "authPasswordCleartextInsecurely");
+    setLabelFromStringBundle("authMethod-kerberos", "authKerberos");
+    setLabelFromStringBundle("authMethod-ntlm", "authNTLM");
+    setLabelFromStringBundle("authMethod-anysecure", "authAnySecure");
+    setLabelFromStringBundle("authMethod-any", "authAny");
+
+    sizeToContent();
+
     sslChanged(false);
     authMethodChanged(false);
 
     if (MailServices.smtp.defaultServer)
       onLockPreference();
 
-    setLabelFromStringBundle("authMethod-no", "authNo");
-    setLabelFromStringBundle("authMethod-kerberos", "authKerberos");
-    setLabelFromStringBundle("authMethod-ntlm", "authNTLM");
-    setLabelFromStringBundle("authMethod-anysecure", "authAnySecure");
-    setLabelFromStringBundle("authMethod-any", "authAny");
-    setLabelFromStringBundle("authMethod-password-encrypted",
-        "authPasswordEncrypted");
-    //authMethod-password-cleartext already set in sslChanged()
-
     // Hide deprecated/hidden auth options, unless selected
     hideUnlessSelected(document.getElementById("authMethod-anysecure"));
     hideUnlessSelected(document.getElementById("authMethod-any"));
 
     // "STARTTLS, if available" is vulnerable to MITM attacks so we shouldn't
     // allow users to choose it anymore. Hide the option unless the user already
     // has it set.
     hideUnlessSelected(document.getElementById("connectionSecurityType-1"));
@@ -158,17 +163,17 @@ function sslChanged(userAction)
     gDefaultPort.value = DEFAULT_SMTP_PORT;
     otherDefaultPort = DEFAULT_SMTPS_PORT;
   }
 
   // If the port is not set,
   // or the user is causing the default port to change,
   //   and the port is set to the default for the other protocol,
   // then set the port to the default for the new protocol.
-  if ((gPort.value == "") ||
+  if ((gPort.value == 0) ||
       (userAction && (gDefaultPort.value != prevDefaultPort) &&
        (gPort.value == otherDefaultPort)))
     gPort.value = gDefaultPort.value;
 
   // switch "insecure password" label
   setLabelFromStringBundle("authMethod-password-cleartext",
       socketType == Ci.nsMsgSocketType.SSL ||
       socketType == Ci.nsMsgSocketType.alwaysSTARTTLS ?
--- a/mailnews/base/prefs/content/smtpEditOverlay.xul
+++ b/mailnews/base/prefs/content/smtpEditOverlay.xul
@@ -42,17 +42,17 @@
           </row>
           <row align="center">
             <label value="&serverPort.label;"
                    accesskey="&serverPort.accesskey;"
                    control="smtp.port"/>
             <hbox align="center">
               <textbox id="smtp.port"
                        type="number"
-                       min="1"
+                       min="0"
                        max="65535"
                        size="5"
                        preftype="int"
                        prefstring="mail.smtpserver.%serverkey%.port"/>
               <label value="&serverPortDefault.label;"/>
               <label id="smtp.defaultPort"/>
             </hbox>
           </row>