Fix unit test bustage from bug 467965 - revert return of values in SetUsername and SetHostname to what they were previously
authorMark Banner <bugzilla@standard8.plus.com>
Fri, 05 Dec 2008 10:21:29 +0000
changeset 1336 89b309ce721c9a8a1308b87227e5d798899a6a23
parent 1335 1e7d1a981aa20f2e28f1d314b280577a38634ac0
child 1337 11ccc3c7f17704f38f1da800ed19a4fc64c7530e
push id1047
push userbugzilla@standard8.plus.com
push dateFri, 05 Dec 2008 10:21:49 +0000
treeherdercomm-central@89b309ce721c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs467965
Fix unit test bustage from bug 467965 - revert return of values in SetUsername and SetHostname to what they were previously
mailnews/compose/src/nsSmtpServer.cpp
--- a/mailnews/compose/src/nsSmtpServer.cpp
+++ b/mailnews/compose/src/nsSmtpServer.cpp
@@ -126,20 +126,23 @@ nsSmtpServer::GetHostname(nsACString &aH
     aHostname = result;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSmtpServer::SetHostname(const nsACString &aHostname)
 {
-  if (aHostname.IsEmpty())
-    return mPrefBranch->ClearUserPref("hostname");
+  if (!aHostname.IsEmpty())
+    return mPrefBranch->SetCharPref("hostname", PromiseFlatCString(aHostname).get());
 
-  return mPrefBranch->SetCharPref("hostname", PromiseFlatCString(aHostname).get());
+  // If the pref value is already empty, ClearUserPref will return
+  // NS_ERROR_UNEXPECTED, so don't check the rv here.
+  mPrefBranch->ClearUserPref("hostname");
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSmtpServer::GetDescription(nsACString &aDescription)
 {
     nsCString temp;
     mPrefBranch->GetCharPref("description", getter_Copies(temp));
     aDescription.Assign(temp);
@@ -308,20 +311,23 @@ nsSmtpServer::GetUsername(nsACString &aU
   else
     aUsername = result;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSmtpServer::SetUsername(const nsACString &aUsername)
 {
-  if (aUsername.IsEmpty())
-    return mPrefBranch->ClearUserPref("username");
+  if (!aUsername.IsEmpty())
+    return mPrefBranch->SetCharPref("username", PromiseFlatCString(aUsername).get());
 
-  return mPrefBranch->SetCharPref("username", PromiseFlatCString(aUsername).get());
+  // If the pref value is already empty, ClearUserPref will return
+  // NS_ERROR_UNEXPECTED, so don't check the rv here.
+  mPrefBranch->ClearUserPref("username");
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSmtpServer::GetPassword(nsACString& aPassword)
 {
     if (m_password.IsEmpty() && !m_logonFailed)
     {
       // try to avoid prompting the user for another password. If the user has set