fix for #71243. don't hard code the default values, get them from the

default prefs.  fix by cavin@netscape.com.  sr=spitzer
This commit is contained in:
sspitzer%netscape.com 2001-03-30 05:22:22 +00:00
parent f55ec09bcb
commit 3c0cfdec3a
2 changed files with 26 additions and 3 deletions

View File

@ -102,7 +102,8 @@ nsSmtpServer::GetTrySSL(PRInt32 *trySSL)
*trySSL= 0;
getPrefString("try_ssl", pref);
rv = prefs->GetIntPref(pref, trySSL);
if (NS_FAILED(rv)) *trySSL = 1;
if (NS_FAILED(rv))
rv = getDefaultIntPref(prefs, 1, "try_ssl", trySSL);
return NS_OK;
}
@ -128,8 +129,29 @@ nsSmtpServer::GetAuthMethod(PRInt32 *authMethod)
*authMethod = 1;
getPrefString("auth_method", pref);
rv = prefs->GetIntPref(pref, authMethod);
if (NS_FAILED(rv)) *authMethod = 1;
return NS_OK;
if (NS_FAILED(rv))
rv = getDefaultIntPref(prefs, 1, "auth_method", authMethod);
return rv;
}
nsresult
nsSmtpServer::getDefaultIntPref(nsIPref *prefs,
PRInt32 defVal,
const char *prefName,
PRInt32 *val)
{
// mail.smtpserver.default.<prefName>
nsCAutoString fullPrefName;
fullPrefName = "mail.smtpserver.default.";
fullPrefName.Append(prefName);
nsresult rv = prefs->GetIntPref(fullPrefName, val);
if (NS_FAILED(rv))
{ // last resort
*val = defVal;
rv = NS_OK;
}
return rv;
}
NS_IMETHODIMP

View File

@ -42,6 +42,7 @@ private:
nsCString mKey;
nsresult getPrefString(const char *pref, nsCAutoString& result);
nsresult getDefaultIntPref(nsIPref *prefs, PRInt32 defVal, const char *prefName, PRInt32 *val);
nsCString m_password;
};