fix bug #23317. when using the account wizard, check the

protocol info to see if username is required and how to preflight
the pretty name.  (news does it different than imap and pop.)

to help the insane clown posse, create a string bundle to be used
by the account wizard.

fix the bug that I just introduced where creating accounts
would fail at the very end, so the folder pane would fail to refresh.

r=alecf
This commit is contained in:
sspitzer%netscape.com 2000-01-07 07:49:37 +00:00
Родитель 04bcf3a234
Коммит c40113f7f6
15 изменённых файлов: 137 добавлений и 17 удалений

Просмотреть файл

@ -261,7 +261,7 @@ function createAccount(hash) {
if (!localMailServer) {
// creates a copy of the identity you pass in
am.createLocalMailAccount(identity);
am.createLocalMailAccount(identity, false);
}
return true;

Просмотреть файл

@ -19,13 +19,17 @@
*
* Contributor(s):
* Alec Flett <alecf@netscape.com>
* Seth Spitzer <sspitzer@netscape.com>
*/
var Bundle = srGetStrBundle("chrome://messenger/locale/prefs.properties");
function validate() {
var accountname = document.getElementById("server.prettyName").value;
if (!accountname || accountname =="") {
window.alert("Please enter a name for this account.");
var alertText = Bundle.GetStringFromName("enterAccountName");
window.alert(alertText);
return false;
}
return true;
@ -34,7 +38,15 @@ function validate() {
function onInit() {
var accountNameInput = document.getElementById("server.prettyName");
if (accountNameInput.value=="") {
var email = document.getElementById("identity.email").value;
accountNameInput.value = email;
var type = document.getElementById("server.type").value;
var protocolinfo = Components.classes["component://netscape/messenger/protocol/info;type=" + type].getService(Components.interfaces.nsIMsgProtocolInfo);
if (protocolinfo.preflightPrettyNameWithEmailAddress) {
var email = document.getElementById("identity.email").value;
accountNameInput.value = email;
}
else {
var hostname = document.getElementById("server.hostName").value;
accountNameInput.value = hostname;
}
}
}

Просмотреть файл

@ -28,8 +28,13 @@ Rights Reserved.
class="dialog"
align="vertical"
onload="parent.wizardPageLoaded('accname');">
<html:script src="aw-accname.js"/>
<html:script language="JavaScript" src="chrome://global/content/strres.js"/>
<html:script language="JavaScript" src="chrome://messenger/content/aw-accname.js"/>
<html:input type="hidden" name="identity.email" id="identity.email"/>
<html:input type="hidden" name="server.type" id="server.type"/>
<html:input type="hidden" name="server.hostName" id="server.hostName"/>
<box class="title" align="horizontal">
<html:div class="title">&accnameTitle.label;</html:div>
<spring flex="100%"/>

Просмотреть файл

@ -19,13 +19,18 @@
*
* Contributor(s):
* Alec Flett <alecf@netscape.com>
* Seth Spitzer <sspitzer@netscape.com>
*/
var protocolinfo = null;
var Bundle = srGetStrBundle("chrome://messenger/locale/prefs.properties");
function validate() {
var username = document.getElementById("server.username").value;
if (!username || username == "") {
window.alert("Please enter a username.\n");
if (protocolinfo.requiresUsername && (!username || username == "")) {
var alertText = Bundle.GetStringFromName("enterUserName");
window.alert(alertText);
return false;
}
@ -34,10 +39,20 @@ function validate() {
function onInit() {
var loginNameInput = document.getElementById("server.username");
var type = document.getElementById("server.type").value;
protocolinfo = Components.classes["component://netscape/messenger/protocol/info;type=" + type].getService(Components.interfaces.nsIMsgProtocolInfo);
if (loginNameInput.value == "") {
var email = document.getElementById("identity.email").value;
var emailParts = email.split("@");
loginNameInput.value = emailParts[0];
if (protocolinfo.requiresUsername) {
// since we require a username, use the uid from the email address
var email = document.getElementById("identity.email").value;
var emailParts = email.split("@");
loginNameInput.value = emailParts[0];
}
else {
// leave it blank.
}
}
}

Просмотреть файл

@ -28,8 +28,12 @@ Rights Reserved.
align="vertical"
class="dialog"
onload="parent.wizardPageLoaded('login');">
<html:script src="aw-login.js"/>
<html:script language="JavaScript" src="chrome://global/content/strres.js"/>
<html:script language="JavaScript" src="chrome://messenger/content/aw-login.js"/>
<html:input type="hidden" name="identity.email" id="identity.email"/>
<html:input type="hidden" name="server.type" id="server.type"/>
<box class="title" align="horizontal">
<html:div class="title">&loginTitle.label;</html:div>

Просмотреть файл

@ -40,3 +40,4 @@ am-advanced.dtd
am-copies.dtd
am-main.dtd
am-server-top.dtd
prefs.properties

Просмотреть файл

@ -49,6 +49,7 @@ EXPORT_RESOURCE_SAMPLES = \
am-copies.dtd \
am-main.dtd \
am-server-top.dtd \
prefs.properties \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -46,6 +46,7 @@ install::
$(MAKE_INSTALL) am-copies.dtd $(DISTBROWSER)
$(MAKE_INSTALL) am-main.dtd $(DISTBROWSER)
$(MAKE_INSTALL) am-server-top.dtd $(DISTBROWSER)
$(MAKE_INSTALL) prefs.properties $(DISTBROWSER)
clobber::
rm -f $(DIST)\bin\chrome\messenger\locale\en-US\custreceipt.dtd
@ -68,3 +69,4 @@ clobber::
rm -f $(DIST)\bin\chrome\messenger\locale\en-US\am-copies.dtd
rm -f $(DIST)\bin\chrome\messenger\locale\en-US\am-main.dtd
rm -f $(DIST)\bin\chrome\messenger\locale\en-US\am-server-top.dtd
rm -f $(DIST)\bin\chrome\messenger\locale\en-US\prefs.properties

Просмотреть файл

@ -0,0 +1,26 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Seth Spitzer <sspitzer@netscape.com>
#
#
# The following are used by the Account Wizard
#
enterAccountName=Please enter a name for this account.
enterUserName=Please enter a username.

Просмотреть файл

@ -143,6 +143,6 @@ interface nsIMsgAccountManager : nsISupports {
void NotifyServerLoaded(in nsIMsgIncomingServer server);
void NotifyServerUnloaded(in nsIMsgIncomingServer server);
void createLocalMailAccount(in nsIMsgIdentity identity);
void createLocalMailAccount(in nsIMsgIdentity identity, in boolean migrating);
};

Просмотреть файл

@ -34,5 +34,7 @@ interface nsIMsgProtocolInfo : nsISupports
{
attribute nsIFileSpec defaultLocalPath;
readonly attribute nsIIDPtr serverIID;
readonly attribute boolean requiresUsername;
readonly attribute boolean preflightPrettyNameWithEmailAddress;
};

Просмотреть файл

@ -1405,7 +1405,7 @@ nsMsgAccountManager::UpgradePrefs()
if (NS_FAILED(rv)) return rv;
// everyone gets a local mail account in 5.0
rv = CreateLocalMailAccount(identity);
rv = CreateLocalMailAccount(identity, PR_TRUE);
if (NS_FAILED(rv)) return rv;
}
else if (oldMailType == IMAP_4X_MAIL_TYPE) {
@ -1424,7 +1424,7 @@ nsMsgAccountManager::UpgradePrefs()
if (NS_FAILED(rv)) return rv;
// everyone gets a local mail account in 5.0
rv = CreateLocalMailAccount(identity);
rv = CreateLocalMailAccount(identity, PR_TRUE);
if (NS_FAILED(rv)) return rv;
}
#endif /* HAVE_MOVEMAIL */
@ -1764,7 +1764,7 @@ nsMsgAccountManager::Convert4XUri(const char *old_uri, const char *default_folde
}
NS_IMETHODIMP
nsMsgAccountManager::CreateLocalMailAccount(nsIMsgIdentity *identity)
nsMsgAccountManager::CreateLocalMailAccount(nsIMsgIdentity *identity, PRBool migrating)
{
nsresult rv;
@ -1803,8 +1803,12 @@ nsMsgAccountManager::CreateLocalMailAccount(nsIMsgIdentity *identity)
rv = CopyIdentity(identity,copied_identity);
if (NS_FAILED(rv)) return rv;
rv = SetMailCcAndFccValues(copied_identity);
if (NS_FAILED(rv)) return rv;
// only set the cc and fcc values if we were migrating.
// otherwise, we won't have them.
if (migrating) {
rv = SetMailCcAndFccValues(copied_identity);
if (NS_FAILED(rv)) return rv;
}
}
else {
char *profileName = nsnull;

Просмотреть файл

@ -2328,3 +2328,19 @@ nsImapService::GetServerIID(nsIID* *aServerIID)
*aServerIID = new nsIID(NS_GET_IID(nsIImapIncomingServer));
return NS_OK;
}
NS_IMETHODIMP
nsImapService::GetRequiresUsername(PRBool *aRequiresUsername)
{
NS_ENSURE_ARG_POINTER(aRequiresUsername);
*aRequiresUsername = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsImapService::GetPreflightPrettyNameWithEmailAddress(PRBool *aPreflightPrettyNameWithEmailAddress)
{
NS_ENSURE_ARG_POINTER(aPreflightPrettyNameWithEmailAddress);
*aPreflightPrettyNameWithEmailAddress = PR_TRUE;
return NS_OK;
}

Просмотреть файл

@ -331,3 +331,19 @@ nsPop3Service::GetServerIID(nsIID* *aServerIID)
*aServerIID = new nsIID(NS_GET_IID(nsIPop3IncomingServer));
return NS_OK;
}
NS_IMETHODIMP
nsPop3Service::GetRequiresUsername(PRBool *aRequiresUsername)
{
NS_ENSURE_ARG_POINTER(aRequiresUsername);
*aRequiresUsername = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsPop3Service::GetPreflightPrettyNameWithEmailAddress(PRBool *aPreflightPrettyNameWithEmailAddress)
{
NS_ENSURE_ARG_POINTER(aPreflightPrettyNameWithEmailAddress);
*aPreflightPrettyNameWithEmailAddress = PR_TRUE;
return NS_OK;
}

Просмотреть файл

@ -1077,3 +1077,19 @@ nsNntpService::GetServerIID(nsIID* *aServerIID)
*aServerIID = new nsIID(NS_GET_IID(nsINntpIncomingServer));
return NS_OK;
}
NS_IMETHODIMP
nsNntpService::GetRequiresUsername(PRBool *aRequiresUsername)
{
NS_ENSURE_ARG_POINTER(aRequiresUsername);
*aRequiresUsername = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsNntpService::GetPreflightPrettyNameWithEmailAddress(PRBool *aPreflightPrettyNameWithEmailAddress)
{
NS_ENSURE_ARG_POINTER(aPreflightPrettyNameWithEmailAddress);
*aPreflightPrettyNameWithEmailAddress = PR_FALSE;
return NS_OK;
}