Bug 288212 cleanup nsAutoConfig::getEmailAddr and nsReadConfig::readConfigFile

r=alecf sr=alecf a=shaver
This commit is contained in:
timeless%mozdev.org 2005-06-01 16:25:13 +00:00
Родитель bbfe7d34e5
Коммит b72b3aa3c5
2 изменённых файлов: 12 добавлений и 14 удалений

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

@ -536,30 +536,28 @@ nsresult nsAutoConfig::getEmailAddr(nsACString & emailAddr)
rv = mPrefBranch->GetCharPref("mail.accountmanager.defaultaccount",
getter_Copies(prefValue));
// Checking prefValue and its length. Since by default the preference
// is set to nothing
PRUint32 len;
if (NS_SUCCEEDED(rv) && (len = strlen(prefValue)) > 0) {
emailAddr = NS_LITERAL_CSTRING("mail.account.") +
nsDependentCString(prefValue, len) + NS_LITERAL_CSTRING(".identities");
if (NS_SUCCEEDED(rv) && !prefValue.IsEmpty()) {
emailAddr = NS_LITERAL_CSTRING("mail.account.") +
prefValue + NS_LITERAL_CSTRING(".identities");
rv = mPrefBranch->GetCharPref(PromiseFlatCString(emailAddr).get(),
getter_Copies(prefValue));
if (NS_FAILED(rv) || (len = strlen(prefValue)) == 0)
if (NS_FAILED(rv) || prefValue.IsEmpty())
return PromptForEMailAddress(emailAddr);
emailAddr = NS_LITERAL_CSTRING("mail.identity.") +
nsDependentCString(prefValue, len) + NS_LITERAL_CSTRING(".useremail");
emailAddr = NS_LITERAL_CSTRING("mail.identity.") +
prefValue + NS_LITERAL_CSTRING(".useremail");
rv = mPrefBranch->GetCharPref(PromiseFlatCString(emailAddr).get(),
getter_Copies(prefValue));
if (NS_FAILED(rv) || (len = strlen(prefValue)) == 0)
if (NS_FAILED(rv) || prefValue.IsEmpty())
return PromptForEMailAddress(emailAddr);
emailAddr = nsDependentCString(prefValue, len);
emailAddr = prefValue;
}
else {
// look for 4.x pref in case we just migrated.
rv = mPrefBranch->GetCharPref("mail.identity.useremail",
getter_Copies(prefValue));
if (NS_SUCCEEDED(rv) && !prefValue.IsEmpty())
emailAddr = prefValue;
emailAddr = prefValue;
else if (NS_FAILED(PromptForEMailAddress(emailAddr)) && (!mCurrProfile.IsEmpty()))
emailAddr = mCurrProfile;
}

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

@ -246,8 +246,8 @@ nsresult nsReadConfig::readConfigFile()
nsXPIDLCString urlName;
rv = prefBranch->GetCharPref("autoadmin.global_config_url",
getter_Copies(urlName));
if (NS_SUCCEEDED(rv) && *urlName != '\0' ) {
if (NS_SUCCEEDED(rv) && !urlName.IsEmpty()) {
// Instantiating nsAutoConfig object if the pref is present
mAutoConfig = do_CreateInstance(NS_AUTOCONFIG_CONTRACTID, &rv);
if (NS_FAILED(rv))