Bug #366439 --> add ability to apend the default domain to the user name in ISP configuration files. initial r pass by neil, more review changes possibly coming.

git-svn-id: svn://10.0.0.236/trunk@218424 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scott%scott-macgregor.org
2007-01-16 06:12:55 +00:00
parent e7554c3b9f
commit 36c361bd03
3 changed files with 20 additions and 20 deletions

View File

@@ -854,10 +854,12 @@ function serverIsNntp(pageData) {
return false;
}
function getUsernameFromEmail(email)
function getUsernameFromEmail(aEmail, aEnsureDomain)
{
var emailData = email.split("@");
return emailData[0];
var username = aEmail.split("@")[0];
if (aEnsureDomain && gCurrentAccountData && gCurrentAccountData.domain)
username += '@' + gCurrentAccountData.domain;
return username;
}
function getCurrentUserName(pageData)
@@ -871,7 +873,7 @@ function getCurrentUserName(pageData)
}
if (userName == "") {
var email = pageData.identity.email.value;
userName = getUsernameFromEmail(email);
userName = getUsernameFromEmail(email, false);
}
return userName;
}
@@ -941,16 +943,10 @@ function FixupAccountDataForIsp(accountData)
return;
var email = accountData.identity.email;
var username;
if (email) {
username = getUsernameFromEmail(email);
}
// fix up the username
if (!accountData.incomingServer.username) {
accountData.incomingServer.username = username;
}
if (!accountData.incomingServer.username)
accountData.incomingServer.username = getUsernameFromEmail(email, accountData.incomingServerUserNameRequiresDomain);
if (!accountData.smtp.username &&
accountData.smtpRequiresUsername) {
@@ -960,7 +956,7 @@ function FixupAccountDataForIsp(accountData)
if (accountData.smtp.hostname == accountData.incomingServer.hostName)
accountData.smtp.username = accountData.incomingServer.username;
else
accountData.smtp.username = username;
accountData.smtp.username = getUsernameFromEmail(email, accountData.smtpUserNameRequiresDomain);
}
}

View File

@@ -85,12 +85,14 @@ function donePageInit() {
email += "@" + currentAccountData.domain;
}
setDivTextFromForm("identity.email", email);
var userName="";
if (pageData.login && pageData.login.username)
userName = pageData.login.username.value;
if (!userName && email)
userName = getUsernameFromEmail(email);
userName = getUsernameFromEmail(email, currentAccountData &&
currentAccountData.incomingServerUserNameRequiresDomain);
// Hide the "username" field if we don't want to show information
// on the incoming server.
setDivTextFromForm("server.username", hideIncoming ? null : userName);
@@ -99,7 +101,8 @@ function donePageInit() {
if (pageData.login && pageData.login.smtpusername)
smtpUserName = pageData.login.smtpusername.value;
if (!smtpUserName && email)
smtpUserName = getUsernameFromEmail(email);
smtpUserName = getUsernameFromEmail(email, currentAccountData &&
currentAccountData.smtpUserNameRequiresDomain);
setDivTextFromForm("smtpServer.username", smtpUserName);
if (pageData.accname && pageData.accname.prettyName) {

View File

@@ -79,12 +79,13 @@ function loginPageInit() {
// retrieve data from previously entered pages
var type = parent.getCurrentServerType(pageData);
dump("type = " + type + "\n");
protocolinfo = Components.classes["@mozilla.org/messenger/protocol/info;1?type=" + type].getService(Components.interfaces.nsIMsgProtocolInfo);
protocolinfo = Components.classes["@mozilla.org/messenger/protocol/info;1?type=" + type]
.getService(Components.interfaces.nsIMsgProtocolInfo);
if (protocolinfo.requiresUsername) {
// since we require a username, use the uid from the email address
loginNameInput.value = parent.getUsernameFromEmail(pageData.identity.email.value);
loginNameInput.value = parent.getUsernameFromEmail(pageData.identity.email.value, gCurrentAccountData &&
gCurrentAccountData.incomingServerUserNameRequiresDomain);
}
}