Bug 364987: creating second RSS ("News & Blogs") account fails. At this point, the effect is that it fixes bug 313525, the serverName value/object confusion, and cleans up AccountExists(). r=philringnalda, sr=neil
authorMagnus Melin <mkmelin@iki.fi>
Sun, 26 Oct 2008 18:49:45 +0200
changeset 717 4c428a4a8be6dc8d5c89bdc36582792454ffd4f7
parent 716 92a42626344006db0d51b1b8e612409767d66b2c
child 718 21179bc2541a1b70c1de5d8a0ed6fcd97c786840
push id644
push usermkmelin@iki.fi
push dateSun, 26 Oct 2008 16:50:48 +0000
treeherdercomm-central@4c428a4a8be6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilringnalda, neil
bugs364987, 313525
Bug 364987: creating second RSS ("News & Blogs") account fails. At this point, the effect is that it fixes bug 313525, the serverName value/object confusion, and cleans up AccountExists(). r=philringnalda, sr=neil
mail/extensions/newsblog/rss.rdf
mail/locales/en-US/chrome/messenger-newsblog/am-newsblog.dtd
mailnews/base/prefs/resources/content/AccountWizard.js
mailnews/base/prefs/resources/content/aw-accname.js
mailnews/base/prefs/resources/content/aw-server.js
--- a/mail/extensions/newsblog/rss.rdf
+++ b/mail/extensions/newsblog/rss.rdf
@@ -8,32 +8,32 @@
 
   <RDF:Description about="NC:ispinfo">
     <NC:providers>
       <NC:nsIMsgAccount about="newsblog">
 
         <!-- server info -->
         <NC:incomingServer>
           <NC:nsIMsgIncomingServer>
-            <NC:hostName>&rss.hostName;</NC:hostName>
+            <NC:hostName>Feeds</NC:hostName>
             <NC:type>rss</NC:type>
             <NC:biffMinutes>100</NC:biffMinutes>
             <NC:username>nobody</NC:username>
           </NC:nsIMsgIncomingServer>
         </NC:incomingServer>
 
         <!-- identity defaults -->
         <NC:identity>
           <NC:nsIMsgIdentity>
           </NC:nsIMsgIdentity>
         </NC:identity>
 
-	<NC:wizardAutoGenerateUniqueHostname>true</NC:wizardAutoGenerateUniqueHostname>
+        <NC:wizardAutoGenerateUniqueHostname>true</NC:wizardAutoGenerateUniqueHostname>
         <NC:wizardHideIncoming>true</NC:wizardHideIncoming>
-	      <NC:wizardAccountName>&rss.accountName;</NC:wizardAccountName>
+        <NC:wizardAccountName>&rss.accountName;</NC:wizardAccountName>
         <NC:wizardSkipPanels>identitypage,serverpage,loginpage</NC:wizardSkipPanels>
         <NC:wizardShortName>&rss.wizardShortName;</NC:wizardShortName>
         <NC:wizardLongName>&rss.wizardLongName;</NC:wizardLongName>
         <NC:wizardLongNameAccesskey>&rss.wizardLongName.accesskey;</NC:wizardLongNameAccesskey>
         <NC:wizardShow>true</NC:wizardShow>
         <NC:emailProviderName>RSS</NC:emailProviderName>
         <NC:showServerDetailsOnWizardSummary>false</NC:showServerDetailsOnWizardSummary> 
       </NC:nsIMsgAccount>
--- a/mail/locales/en-US/chrome/messenger-newsblog/am-newsblog.dtd
+++ b/mail/locales/en-US/chrome/messenger-newsblog/am-newsblog.dtd
@@ -13,9 +13,8 @@
 <!ENTITY manageSubscriptions.label "Manage Subscriptions…"> 
 <!ENTITY manageSubscriptions.accesskey "M">
 
 <!-- entities from defaults/isp/rss.rdf -->
 <!ENTITY rss.accountName            "News &amp; Blogs">
 <!ENTITY rss.wizardShortName        "RSS">  
 <!ENTITY rss.wizardLongName         "RSS News &amp; Blogs">
 <!ENTITY rss.wizardLongName.accesskey "R">
-<!ENTITY rss.hostName               "News &amp; Blogs">
--- a/mailnews/base/prefs/resources/content/AccountWizard.js
+++ b/mailnews/base/prefs/resources/content/AccountWizard.js
@@ -731,27 +731,20 @@ function setDefaultCopiesAndFoldersPrefs
     accountData.identity.DraftFolder ? 1 : gDefaultSpecialFolderPickerMode);
   identity.tmplFolderPickerMode = (accountData.identity &&
     accountData.identity.StationeryFolder ? 1 : gDefaultSpecialFolderPickerMode);
 }
 
 function AccountExists(userName,hostName,serverType)
 {
   var accountExists = false;
-  var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
-  try {
-        var server = accountManager.findRealServer(userName,hostName,serverType,0);
-        if (server) {
-                accountExists = true;
-        }
-  }
-  catch (ex) {
-        accountExists = false;
-  }
-  return accountExists;
+  var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"]
+                                 .getService(Components.interfaces.nsIMsgAccountManager);
+
+  return accountManager.findRealServer(userName, hostName, serverType, 0);
 }
 
 function getFirstInvalidAccount()
 {
     var am = Components.classes["@mozilla.org/messenger/account-manager;1"]
                        .getService(Components.interfaces.nsIMsgAccountManager);
 
     var invalidAccounts = getInvalidAccounts(am.accounts);
--- a/mailnews/base/prefs/resources/content/aw-accname.js
+++ b/mailnews/base/prefs/resources/content/aw-accname.js
@@ -59,21 +59,20 @@ function acctNamePageUnload() {
   // multiple RSS accounts.  Note, they can all have the same pretty name.
   if (gCurrentAccountData && 
       gCurrentAccountData.wizardAutoGenerateUniqueHostname) 
   {
     var serverType = parent.getCurrentServerType(pageData);
     var userName = parent.getCurrentUserName(pageData);
     var hostName = parent.getCurrentHostname(pageData);
     var hostNamePref = hostName;
-    var i = 1;
+    var i = 2;
     while (parent.AccountExists(userName, hostName, serverType)) 
     {
-      // if "News & Blogs" exists, try
-      // "News & Blogs-1", then "News & Blogs-2", etc.
+      // If "Feeds" exists, try "Feeds-2", then "Feeds-3", etc.
       hostName = hostNamePref + "-" + i;
       i++;
     }
     setPageData(pageData, "server", "hostname", hostName);
   }
 
   var accountname = document.getElementById("prettyName").value;
   setPageData(pageData, "accname", "prettyName", accountname);
@@ -85,17 +84,17 @@ function acctNamePageUnload() {
 function acctNamePageInit()
 {
     gPrefsBundle = document.getElementById("bundle_prefs");
     var accountNameInput = document.getElementById("prettyName");
     if (accountNameInput.value=="") {
         var pageData = parent.GetPageData();
         var type = parent.getCurrentServerType(pageData);
         var accountName;
-        
+
         if (gCurrentAccountData && gCurrentAccountData.wizardAccountName)
             accountName = gCurrentAccountData.wizardAccountName;
         else if (type == "nntp") 
             accountName = pageData.newsserver.hostname.value;
         else
             accountName = pageData.identity.email.value;
         accountNameInput.value = accountName;
     }
--- a/mailnews/base/prefs/resources/content/aw-server.js
+++ b/mailnews/base/prefs/resources/content/aw-server.js
@@ -57,25 +57,25 @@ function serverPageValidate()
 {
   /* if this is for a server that doesn't require a username, 
    * check if the account exists. 
    * for other types, we check after the user provides the username (see aw-login.js)
    */
   var canAdvance = true;
 
   if (gOnMailServersPage) {
-    var incomingServerName = document.getElementById("incomingServer");
-    var smtpserver = document.getElementById("smtphostname");
-    if ((!gHideIncoming && hostnameIsIllegal(incomingServerName.value)) ||
-        hostnameIsIllegal(smtpserver.value))
+    var incomingServerName = document.getElementById("incomingServer").value;
+    var smtpserver = document.getElementById("smtphostname").value;
+    if ((!gHideIncoming && hostnameIsIllegal(incomingServerName)) ||
+        hostnameIsIllegal(smtpserver))
       canAdvance = false;
   }
   if (gOnNewsServerPage) {
-    var newsServerName = document.getElementById("newsServer");
-    if (hostnameIsIllegal(newsServerName.value))
+    var newsServerName = document.getElementById("newsServer").value;
+    if (hostnameIsIllegal(newsServerName))
       canAdvance = false;
   }
   if (canAdvance && gProtocolInfo && !gProtocolInfo.requiresUsername) {
     var pageData = parent.GetPageData();
     var serverType = parent.getCurrentServerType(pageData);
     var hostName;
     if (gOnMailServersPage)
       hostName = incomingServerName;