rest of the fix for #20401. make my fix work for all server types, not just

nntp.  r=mscott
This commit is contained in:
sspitzer%netscape.com 2000-09-06 07:17:46 +00:00
parent c396c43cf1
commit 2d856f10d6
3 changed files with 41 additions and 18 deletions

View File

@ -488,6 +488,25 @@ function setDefaultCopiesAndFoldersPrefs(identity, server)
}
function AccountExists(userName,hostName,serverType)
{
dump("AccountExists("+userName+","+hostName+","+serverType+")\n");
var accountExists = false;
var accountManager = Components.classes["component://netscape/messenger/account-manager"].getService(Components.interfaces.nsIMsgAccountManager);
try {
var server = accountManager.FindServer(userName,hostName,serverType);
if (server) {
dump("account exists\n");
accountExists = true;
}
}
catch (ex) {
dump("AccountExists() failed: "+ex+"\n");
accountExists = false;
}
return accountExists;
}
function checkForInvalidAccounts()
{
am = Components.classes["component://netscape/messenger/account-manager"].getService(Components.interfaces.nsIMsgAccountManager);

View File

@ -34,6 +34,15 @@ function validate() {
return false;
}
var pageData = parent.GetPageData();
var serverType = parent.getCurrentServerType(pageData);
var hostName = parent.getCurrentHostname(pageData);
if (parent.AccountExists(username,hostName,serverType)) {
var alertText = Bundle.GetStringFromName("accountExists");
window.alert(alertText);
return false;
}
return true;
}

View File

@ -35,27 +35,22 @@ function validate() {
return false;
}
dump("check if this account exists\n");
/* 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 pageData = parent.GetPageData();
var hostName = servername.value;
var serverType = parent.getCurrentServerType(pageData);
var userName = parent.getCurrentUserName(pageData);
var protocolinfo = Components.classes["component://netscape/messenger/protocol/info;type=" + serverType].getService(Components.interfaces.nsIMsgProtocolInfo);
if (!protocolinfo.requiresUsername) {
var userName = parent.getCurrentUserName(pageData);
var hostName = servername.value;
var accountExists = false;
var accountManager = Components.classes["component://netscape/messenger/account-manager"].getService(Components.interfaces.nsIMsgAccountManager);
try {
var server = accountManager.FindServer(userName,hostName,serverType);
if (server) {
accountExists = true;
}
}
catch (ex) {
accountExists = false;
}
if (accountExists) {
var alertText = Bundle.GetStringFromName("accountExists");
window.alert(alertText);
return false;
if (parent.AccountExists(userName,hostName,serverType)) {
var alertText = Bundle.GetStringFromName("accountExists");
window.alert(alertText);
return false;
}
}
return true;