Bug 467965 Improve some of the string interfaces on nsISmtpServer. r/sr=Neil
authorMark Banner <bugzilla@standard8.plus.com>
Fri, 05 Dec 2008 09:28:47 +0000
changeset 1335 1e7d1a981aa20f2e28f1d314b280577a38634ac0
parent 1334 ac75a8511ec8089a4e1ef7c32dd2dbc525894b3a
child 1336 89b309ce721c9a8a1308b87227e5d798899a6a23
push id1046
push userbugzilla@standard8.plus.com
push dateFri, 05 Dec 2008 09:30:36 +0000
treeherdercomm-central@1e7d1a981aa2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs467965
Bug 467965 Improve some of the string interfaces on nsISmtpServer. r/sr=Neil
mailnews/compose/public/nsISmtpServer.idl
mailnews/compose/src/nsMsgSend.cpp
mailnews/compose/src/nsSmtpProtocol.cpp
mailnews/compose/src/nsSmtpProtocol.h
mailnews/compose/src/nsSmtpServer.cpp
mailnews/compose/src/nsSmtpService.cpp
mailnews/extensions/mdn/src/nsMsgMdnGenerator.cpp
mailnews/import/eudora/src/nsEudoraMac.cpp
mailnews/import/eudora/src/nsEudoraWin32.cpp
mailnews/import/oexpress/nsOESettings.cpp
mailnews/import/outlook/src/nsOutlookSettings.cpp
--- a/mailnews/compose/public/nsISmtpServer.idl
+++ b/mailnews/compose/public/nsISmtpServer.idl
@@ -43,33 +43,33 @@ interface nsIUrlListener;
 
 /**
  * This interface represents a single SMTP Server. A SMTP server instance may be
  * created/obtained from nsIMsgAccountManager.
  *
  * Most of the attributes will set/get preferences from the main preferences
  * file.
  */
-[scriptable, uuid(71f5d415-094d-4a32-899b-2256c2de6876)]
+[scriptable, uuid(67725a6a-ddab-4fed-97f1-e58105c23c0e)]
 interface nsISmtpServer : nsISupports {
 
   /// A unique identifier for the server.
   attribute string key;
 
   /// A user supplied description for the server.
   attribute AUTF8String description;
 
   /// The server's hostname.
-  attribute string hostname;
+  attribute ACString hostname;
 
   /// The server's port.
   attribute PRInt32 port;
 
   /// The username to access the server with (if required)
-  attribute string username;
+  attribute ACString username;
 
   /**
    * The password to access the server with (if required).
    *
    * @note this is stored within the server instance but not within preferences.
    * It can be specified/saved here to avoid prompting the user constantly for
    * the sending password.
    */
@@ -106,17 +106,17 @@ interface nsISmtpServer : nsISupports {
    * server. Reflects the value of the mail.smtpserver.*.hello_argument pref.
    * This is mainly useful where ISPs don't bother providing PTR records for
    * their servers and therefore users get an error on sending. See bug 244030
    * for more discussion.
    */
   readonly attribute string helloArgument;
 
   /// Returns the URI of the server (smtp:///)
-  readonly attribute string serverURI;
+  readonly attribute ACString serverURI;
 
   /**
    * Gets a password for this server, using a UI prompt if necessary.
    *
    * @param promptString  The string to prompt the user with when asking for
    *                      the password.
    * @param promptTitle   The title of the prompt.
    * @param netPrompt     An nsIAuthPrompt instance to use for the password
@@ -137,17 +137,17 @@ interface nsISmtpServer : nsISupports {
    * @param netPrompt     An nsIAuthPrompt instance to use for the password
    *                      prompt.
    * @param userid        The username to use (may be null if no password was
    *                      obtained).
    * @param password      The password to use (may be empty if no password was
    *                      obtained).
    */  
   void getUsernamePasswordWithUI(in wstring promptString, in wstring promptTitle,
-                                 in nsIAuthPrompt netPrompt, out string userid,
+                                 in nsIAuthPrompt netPrompt, out ACString userid,
                                  out ACString password);
 
   /**
    * Calling this will *remove* the saved password for this server from the
    * password manager and from the stored value.
    */
   void forgetPassword();
 
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -3899,17 +3899,17 @@ nsMsgComposeAndSend::FormatStringWithSMT
   nsCOMPtr<nsISmtpService> smtpService(do_GetService(NS_SMTPSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv,rv);
 
   // Get the smtp hostname and format the string.
   nsCString smtpHostName;
   nsCOMPtr<nsISmtpServer> smtpServer;
   rv = smtpService->GetSmtpServerByIdentity(mUserIdentity, getter_AddRefs(smtpServer));
   if (NS_SUCCEEDED(rv))
-    smtpServer->GetHostname(getter_Copies(smtpHostName));
+    smtpServer->GetHostname(smtpHostName);
 
   nsAutoString hostStr;
   CopyASCIItoUTF16(smtpHostName, hostStr);
   const PRUnichar *params[] = { hostStr.get() };
   if (NS_SUCCEEDED(rv))
     mComposeBundle->FormatStringFromID(NS_ERROR_GET_CODE(aMsgId), params, 1, aString);
   return rv;
 }
--- a/mailnews/compose/src/nsSmtpProtocol.cpp
+++ b/mailnews/compose/src/nsSmtpProtocol.cpp
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla 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/MPL/
  *
@@ -1041,17 +1041,17 @@ PRInt32 nsSmtpProtocol::AuthLoginRespons
           // if LOGIN enabled, clear it if we failed.
           ClearFlag(SMTP_AUTH_LOGIN_ENABLED);
 
         // Only forget the password if we've no mechanism left.
         if (!TestFlag(SMTP_AUTH_ANY_ENABLED))
         {
             smtpServer->ForgetPassword();
             if (m_usernamePrompted)
-                smtpServer->SetUsername("");
+              smtpServer->SetUsername(EmptyCString());
 
             // Let's restore the original auth flags from SendEhloResponse
             // so we can try them again with new password and username
             RestoreAuthFlags();
             // except for gssapi, which doesn't care about the new password.
             ClearFlag(SMTP_AUTH_GSSAPI_ENABLED);
         }
 
@@ -1072,22 +1072,26 @@ PRInt32 nsSmtpProtocol::AuthGSSAPIFirst(
   nsCAutoString command("AUTH GSSAPI ");
   nsCAutoString resp;
   nsCAutoString service("smtp@");
   nsCString hostName;
   nsCString userName;
   nsresult rv;
   nsCOMPtr<nsISmtpServer> smtpServer;
   rv = m_runningURL->GetSmtpServer(getter_AddRefs(smtpServer));
-  if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
+  if (NS_FAILED(rv))
+    return NS_ERROR_FAILURE;
 
-  rv = smtpServer->GetUsername(getter_Copies(userName));
-  if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-  rv = smtpServer->GetHostname(getter_Copies(hostName));
-  if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
+  rv = smtpServer->GetUsername(userName);
+  if (NS_FAILED(rv))
+    return NS_ERROR_FAILURE;
+
+  rv = smtpServer->GetHostname(hostName);
+  if (NS_FAILED(rv))
+    return NS_ERROR_FAILURE;
 
  service.Append(hostName);
   rv = DoGSSAPIStep1(service.get(), userName.get(), resp);
   if (NS_FAILED(rv))
   {
     m_nextState = SMTP_AUTH_PROCESS_STATE;
     ClearFlag(SMTP_AUTH_GSSAPI_ENABLED);
     return 0;
@@ -1159,20 +1163,20 @@ PRInt32 nsSmtpProtocol::AuthLoginStep1()
   PRInt32 status = 0;
   nsCString username;
   char *base64Str = nsnull;
   nsCAutoString password;
   nsCOMPtr<nsISmtpServer> smtpServer;
   rv = m_runningURL->GetSmtpServer(getter_AddRefs(smtpServer));
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
-  rv = smtpServer->GetUsername(getter_Copies(username));
+  rv = smtpServer->GetUsername(username);
   if (username.IsEmpty())
   {
-    rv = GetUsernamePassword(getter_Copies(username), password);
+    rv = GetUsernamePassword(username, password);
     m_usernamePrompted = PR_TRUE;
     if (username.IsEmpty() || password.IsEmpty())
       return NS_ERROR_SMTP_PASSWORD_UNDEFINED;
   }
 
   GetPassword(password);
   if (password.IsEmpty())
   {
@@ -1271,17 +1275,17 @@ PRInt32 nsSmtpProtocol::AuthLoginStep2()
           encodedDigest.Append(hexVal);
         }
 
         nsCOMPtr<nsISmtpServer> smtpServer;
         rv = m_runningURL->GetSmtpServer(getter_AddRefs(smtpServer));
         if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
         nsCString userName;
-        rv = smtpServer->GetUsername(getter_Copies(userName));
+        rv = smtpServer->GetUsername(userName);
 
         PR_snprintf(buffer, sizeof(buffer), "%s %s", userName.get(), encodedDigest.get());
         char *base64Str = PL_Base64Encode(buffer, strlen(buffer), nsnull);
         PR_snprintf(buffer, sizeof(buffer), "%s" CRLF, base64Str);
         NS_Free(base64Str);
       }
       if (NS_FAILED(rv))
         PR_snprintf(buffer, sizeof(buffer), "*" CRLF);
@@ -1887,28 +1891,28 @@ nsSmtpProtocol::GetPassword(nsCString &a
     nsCOMPtr <nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv,rv);
 
     nsCOMPtr<nsIPrefBranch> prefBranch;
     rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
     NS_ENSURE_SUCCESS(rv,rv);
 
     nsCString username;
-    rv = smtpServer->GetUsername(getter_Copies(username));
+    rv = smtpServer->GetUsername(username);
     NS_ENSURE_SUCCESS(rv, rv);
 
     NS_ConvertASCIItoUTF16 usernameUTF16(username);
     const PRUnichar *formatStrings[] =
     {
       usernameUTF16.get(),
       nsnull  // this will be overwritten in some cases.
     };
 
     nsCString hostname;
-    rv = smtpServer->GetHostname(getter_Copies(hostname));
+    rv = smtpServer->GetHostname(hostname);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsAutoString hostnameUTF16;
     CopyASCIItoUTF16(hostname, hostnameUTF16);
     formatStrings[1] = hostnameUTF16.get();
 
     rv = PromptForPassword(smtpServer, smtpUrl, formatStrings, aPassword);
     NS_ENSURE_SUCCESS(rv,rv);
@@ -1947,49 +1951,44 @@ nsSmtpProtocol::PromptForPassword(nsISmt
 
   rv = aSmtpServer->GetPasswordWithUI(passwordPromptString.get(), passwordTitle.get(),
     netPrompt, aPassword);
   NS_ENSURE_SUCCESS(rv,rv);
   return rv;
 }
 
 nsresult
-nsSmtpProtocol::GetUsernamePassword(char **aUsername, nsACString &aPassword)
+nsSmtpProtocol::GetUsernamePassword(nsACString &aUsername,
+                                    nsACString &aPassword)
 {
-    NS_ENSURE_ARG_POINTER(aUsername);
-
     nsresult rv;
     nsCOMPtr<nsISmtpUrl> smtpUrl = do_QueryInterface(m_runningURL, &rv);
     NS_ENSURE_SUCCESS(rv,rv);
 
     nsCOMPtr<nsISmtpServer> smtpServer;
     rv = smtpUrl->GetSmtpServer(getter_AddRefs(smtpServer));
     NS_ENSURE_SUCCESS(rv,rv);
 
     rv = smtpServer->GetPassword(aPassword);
     NS_ENSURE_SUCCESS(rv,rv);
 
     if (!aPassword.IsEmpty())
     {
         rv = smtpServer->GetUsername(aUsername);
         NS_ENSURE_SUCCESS(rv,rv);
 
-        if (*aUsername && **aUsername)
-            return rv;
-
-        // empty username
-        NS_Free(*aUsername);
-        *aUsername = 0;
+        if (!aUsername.IsEmpty())
+          return rv;
     }
     // empty password
 
     aPassword.Truncate();
 
     nsCString hostname;
-    rv = smtpServer->GetHostname(getter_Copies(hostname));
+    rv = smtpServer->GetHostname(hostname);
     NS_ENSURE_SUCCESS(rv, rv);
 
     const PRUnichar *formatStrings[] =
     {
       NS_ConvertASCIItoUTF16(hostname).get(),
       nsnull
     };
 
--- a/mailnews/compose/src/nsSmtpProtocol.h
+++ b/mailnews/compose/src/nsSmtpProtocol.h
@@ -240,17 +240,17 @@ private:
     ////////////////////////////////////////////////////////////////////////////////////////
     // End of Protocol Methods
     ////////////////////////////////////////////////////////////////////////////////////////
 
     PRInt32 SendMessageInFile();
 
     void AppendHelloArgument(nsACString& aResult);
     nsresult GetPassword(nsCString &aPassword);
-    nsresult GetUsernamePassword(char **aUsername, nsACString &aPassword);
+    nsresult GetUsernamePassword(nsACString &aUsername, nsACString &aPassword);
     nsresult PromptForPassword(nsISmtpServer *aSmtpServer, nsISmtpUrl *aSmtpUrl, 
                                const PRUnichar **formatStrings, 
                                nsACString &aPassword);
 
     void BackupAuthFlags();
     void RestoreAuthFlags();
     PRInt32 m_origAuthFlags;
 };
--- a/mailnews/compose/src/nsSmtpServer.cpp
+++ b/mailnews/compose/src/nsSmtpServer.cpp
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla 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/MPL/
  *
@@ -111,34 +111,35 @@ nsresult nsSmtpServer::getPrefs()
         if (NS_FAILED(rv))
             return rv;
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetHostname(char * *aHostname)
+nsSmtpServer::GetHostname(nsACString &aHostname)
 {
-    nsresult rv;
-    NS_ENSURE_ARG_POINTER(aHostname);
-    rv = mPrefBranch->GetCharPref("hostname", aHostname);
-    if (NS_FAILED(rv))
-        *aHostname=nsnull;
-    return NS_OK;
+  nsCString result;
+  nsresult rv = mPrefBranch->GetCharPref("hostname", getter_Copies(result));
+  if (NS_FAILED(rv))
+    aHostname.Truncate();
+  else
+    aHostname = result;
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::SetHostname(const char * aHostname)
+nsSmtpServer::SetHostname(const nsACString &aHostname)
 {
-    if (aHostname)
-        return mPrefBranch->SetCharPref("hostname", aHostname);
-    else
-        mPrefBranch->ClearUserPref("hostname");
-    return NS_OK;
+  if (aHostname.IsEmpty())
+    return mPrefBranch->ClearUserPref("hostname");
+
+  return mPrefBranch->SetCharPref("hostname", PromiseFlatCString(aHostname).get());
 }
 
 NS_IMETHODIMP
 nsSmtpServer::GetDescription(nsACString &aDescription)
 {
     nsCString temp;
     mPrefBranch->GetCharPref("description", getter_Copies(temp));
     aDescription.Assign(temp);
@@ -293,34 +294,34 @@ nsSmtpServer::getIntPrefWithDefault(cons
 
 NS_IMETHODIMP
 nsSmtpServer::SetAuthMethod(PRInt32 authMethod)
 {
     return mPrefBranch->SetIntPref("auth_method", authMethod);
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetUsername(char * *aUsername)
+nsSmtpServer::GetUsername(nsACString &aUsername)
 {
-    nsresult rv;
-    NS_ENSURE_ARG_POINTER(aUsername);
-    rv = mPrefBranch->GetCharPref("username", aUsername);
-    if (NS_FAILED(rv))
-        *aUsername = nsnull;
-    return NS_OK;
+  nsCString result;
+  nsresult rv = mPrefBranch->GetCharPref("username", getter_Copies(result));
+  if (NS_FAILED(rv))
+    aUsername.Truncate();
+  else
+    aUsername = result;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::SetUsername(const char * aUsername)
+nsSmtpServer::SetUsername(const nsACString &aUsername)
 {
-    if (aUsername)
-        return mPrefBranch->SetCharPref("username", aUsername);
-    else
-        mPrefBranch->ClearUserPref("username");
-    return NS_OK;
+  if (aUsername.IsEmpty())
+    return mPrefBranch->ClearUserPref("username");
+
+  return mPrefBranch->SetCharPref("username", PromiseFlatCString(aUsername).get());
 }
 
 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
@@ -355,18 +356,18 @@ nsSmtpServer::GetPassword(nsACString& aP
           nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
           NS_ENSURE_SUCCESS(rv,rv);
           prefBranch->GetBoolPref("mail.smtp.useMatchingHostNameServer", &useMatchingHostNameServer);
           prefBranch->GetBoolPref("mail.smtp.useMatchingDomainServer", &useMatchingDomainServer);
           if (useMatchingHostNameServer || useMatchingDomainServer)
           {
             nsCString userName;
             nsCString hostName;
-            GetHostname(getter_Copies(hostName));
-            GetUsername(getter_Copies(userName));
+            GetHostname(hostName);
+            GetUsername(userName);
             if (useMatchingHostNameServer)
               // pass in empty type and port=0, to match imap and pop3.
               accountManager->FindRealServer(userName, hostName, EmptyCString(), 0, getter_AddRefs(incomingServerToUse));
             PRInt32 dotPos = -1;
             if (!incomingServerToUse && useMatchingDomainServer
               && (dotPos = hostName.FindChar('.')) != kNotFound)
             {
               hostName.Cut(0, dotPos);
@@ -442,17 +443,17 @@ nsSmtpServer::GetPasswordWithUI(const PR
         NS_ENSURE_ARG_POINTER(aDialog);
 
         // prompt the user for the password
         if (NS_SUCCEEDED(rv))
         {
             nsString uniPassword;
             PRBool okayValue = PR_TRUE;
             nsCString serverUri;
-            rv = GetServerURI(getter_Copies(serverUri));
+            rv = GetServerURI(serverUri);
             if (NS_FAILED(rv))
                 return rv;
             nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
             PRBool passwordProtectLocalCache = PR_FALSE;
 
             (void) prefBranch->GetBoolPref( "mail.password_protect_local_cache", &passwordProtectLocalCache);
 
             PRUint32 savePasswordType = (passwordProtectLocalCache) ? nsIAuthPrompt::SAVE_PASSWORD_FOR_SESSION : nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY;
@@ -480,52 +481,51 @@ nsSmtpServer::GetPasswordWithUI(const PR
 
     return GetPassword(aPassword);
 }
 
 NS_IMETHODIMP
 nsSmtpServer::GetUsernamePasswordWithUI(const PRUnichar * aPromptMessage, const
                                 PRUnichar *aPromptTitle,
                                 nsIAuthPrompt* aDialog,
-                                char **aUsername,
+                                nsACString &aUsername,
                                 nsACString &aPassword)
 {
     nsresult rv = NS_OK;
-    NS_ENSURE_ARG_POINTER(aUsername);
 
     if (m_password.IsEmpty()) {
         NS_ENSURE_ARG_POINTER(aDialog);
         // prompt the user for the password
         if (NS_SUCCEEDED(rv))
         {
             nsString uniUsername;
             nsString uniPassword;
             PRBool okayValue = PR_TRUE;
             nsCString serverUri;
-            rv = GetServerURI(getter_Copies(serverUri));
+            rv = GetServerURI(serverUri);
             if (NS_FAILED(rv))
                 return rv;
             rv = aDialog->PromptUsernameAndPassword(aPromptTitle, aPromptMessage,
                                          NS_ConvertASCIItoUTF16(serverUri).get(), nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
                                          getter_Copies(uniUsername), getter_Copies(uniPassword), &okayValue);
             if (NS_FAILED(rv))
                 return rv;
 
             if (!okayValue) // if the user pressed cancel, just return NULL;
             {
-                *aUsername = nsnull;
-                aPassword.Truncate();
-                return rv;
+              aUsername.Truncate();
+              aPassword.Truncate();
+              return rv;
             }
 
             // we got a userid and password back...so remember it
             nsCString aCStr;
 
             LossyCopyUTF16toASCII(uniUsername, aCStr);
-            rv = SetUsername(aCStr.get());
+            rv = SetUsername(aCStr);
             if (NS_FAILED(rv))
                 return rv;
 
             LossyCopyUTF16toASCII(uniPassword, aCStr);
             rv = SetPassword(aCStr);
             if (NS_FAILED(rv))
                 return rv;
         } // if we got a prompt dialog
@@ -540,17 +540,17 @@ nsSmtpServer::GetUsernamePasswordWithUI(
 NS_IMETHODIMP
 nsSmtpServer::ForgetPassword()
 {
     nsresult rv;
     nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
     NS_ENSURE_SUCCESS(rv,rv);
 
     nsCString serverUri;
-    rv = GetServerURI(getter_Copies(serverUri));
+    rv = GetServerURI(serverUri);
     if (NS_FAILED(rv))
         return rv;
 
     nsCOMPtr<nsIURI> uri;
     NS_NewURI(getter_AddRefs(uri), serverUri);
 
     //this is need to make sure wallet service has been created
     rv = CreateServicesForPasswordManager();
@@ -560,48 +560,47 @@ nsSmtpServer::ForgetPassword()
     NS_ENSURE_SUCCESS(rv,rv);
 
     rv = SetPassword(EmptyCString());
     m_logonFailed = PR_TRUE;
     return rv;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetServerURI(char **aResult)
+nsSmtpServer::GetServerURI(nsACString &aResult)
 {
-    NS_ENSURE_ARG_POINTER(aResult);
     nsresult rv;
     nsCAutoString uri;
 
-    uri += "smtp";
-    uri += "://";
+    uri.AssignLiteral("smtp");
+    uri.AppendLiteral("://");
 
     nsCString username;
-    rv = GetUsername(getter_Copies(username));
+    rv = GetUsername(username);
 
     if (NS_SUCCEEDED(rv) && !username.IsEmpty()) {
         nsCString escapedUsername;
         MsgEscapeString(username, nsINetUtil::ESCAPE_XALPHAS, escapedUsername);
         // not all servers have a username
         uri.Append(escapedUsername);
-        uri += '@';
+        uri.AppendLiteral("@");
     }
 
     nsCString hostname;
-    rv = GetHostname(getter_Copies(hostname));
+    rv = GetHostname(hostname);
 
     if (NS_SUCCEEDED(rv) && !hostname.IsEmpty()) {
         nsCString escapedHostname;
         *((char **)getter_Copies(escapedHostname)) =
             nsEscape(hostname.get(), url_Path);
         // not all servers have a hostname
         uri.Append(escapedHostname);
     }
 
-    *aResult = ToNewCString(uri);
+    aResult = uri;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSmtpServer::ClearAllValues()
 {
   return mPrefBranch->DeleteBranch("");
 }
--- a/mailnews/compose/src/nsSmtpService.cpp
+++ b/mailnews/compose/src/nsSmtpService.cpp
@@ -173,18 +173,18 @@ nsresult NS_MsgBuildSmtpUrl(nsIFile * aF
   // other stuff from, we need to use default values....
   // ..for testing purposes....
 
     nsCString smtpHostName;
     nsCString smtpUserName;
     PRInt32 smtpPort;
     PRInt32 trySSL;
 
-    aSmtpServer->GetHostname(getter_Copies(smtpHostName));
-    aSmtpServer->GetUsername(getter_Copies(smtpUserName));
+    aSmtpServer->GetHostname(smtpHostName);
+    aSmtpServer->GetUsername(smtpUserName);
     aSmtpServer->GetPort(&smtpPort);
     aSmtpServer->GetTrySSL(&trySSL);
 
     if (!smtpPort)
       smtpPort = (trySSL == PREF_SECURE_ALWAYS_SMTPS) ? 
         nsISmtpUrl::DEFAULT_SMTPS_PORT :  nsISmtpUrl::DEFAULT_SMTP_PORT;
 
   nsresult rv;
@@ -772,22 +772,22 @@ nsSmtpService::DeleteSmtpServer(nsISmtpS
 }
 
 PRBool
 nsSmtpService::findServerByHostname(nsISmtpServer *aServer, void *aData)
 {
   findServerByHostnameEntry *entry = (findServerByHostnameEntry*)aData;
 
   nsCString hostname;
-  nsresult rv = aServer->GetHostname(getter_Copies(hostname));
+  nsresult rv = aServer->GetHostname(hostname);
   if (NS_FAILED(rv))
     return PR_TRUE;
 
   nsCString username;
-  rv = aServer->GetUsername(getter_Copies(username));
+  rv = aServer->GetUsername(username);
   if (NS_FAILED(rv))
     return PR_TRUE;
 
   PRBool checkHostname = !entry->hostname.IsEmpty();
   PRBool checkUsername = !entry->username.IsEmpty();
     
   if ((!checkHostname ||
        (entry->hostname.Equals(hostname, nsCaseInsensitiveCStringComparator())) &&
--- a/mailnews/extensions/mdn/src/nsMsgMdnGenerator.cpp
+++ b/mailnews/extensions/mdn/src/nsMsgMdnGenerator.cpp
@@ -1104,17 +1104,17 @@ NS_IMETHODIMP nsMsgMdnGenerator::OnStopR
     nsCOMPtr<nsISmtpService> smtpService(do_GetService(NS_SMTPSERVICE_CONTRACTID, &rv));
     NS_ENSURE_SUCCESS(rv,rv);
 
     // Get the smtp hostname and format the string.
     nsCString smtpHostName;
     nsCOMPtr<nsISmtpServer> smtpServer;
     rv = smtpService->GetSmtpServerByIdentity(m_identity, getter_AddRefs(smtpServer));
     if (NS_SUCCEEDED(rv)) 
-      smtpServer->GetHostname(getter_Copies(smtpHostName));
+      smtpServer->GetHostname(smtpHostName);
      
     nsAutoString hostStr;
     CopyASCIItoUTF16(smtpHostName, hostStr);
     const PRUnichar *params[] = { hostStr.get() };
 
     nsCOMPtr<nsIStringBundle> bundle;
     nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
     NS_ENSURE_SUCCESS(rv, rv);
--- a/mailnews/import/eudora/src/nsEudoraMac.cpp
+++ b/mailnews/import/eudora/src/nsEudoraMac.cpp
@@ -919,19 +919,19 @@ void nsEudoraMac::SetSmtpServer( nsIMsgA
       IMPORT_LOG1( "SMTP server already exists: %s\n", pServer);
       return;
     }
     nsCOMPtr<nsISmtpServer>    smtpServer;
 
     rv = smtpService->CreateSmtpServer( getter_AddRefs( smtpServer));
     if (NS_SUCCEEDED( rv) && smtpServer)
     {
-      smtpServer->SetHostname( pServer);
+      smtpServer->SetHostname(nsDependentCString(pServer));
       if (pUser)
-        smtpServer->SetUsername( pUser);
+        smtpServer->SetUsername(nsDependentCString(pUser));
 
       IMPORT_LOG1( "Created new SMTP server: %s\n", pServer);
     }
   }
 }
 
 
 nsresult nsEudoraMac::GetAttachmentInfo( const char *pFileName, nsIFile *pFile, nsCString& mimeType, nsCString& aAttachment)
--- a/mailnews/import/eudora/src/nsEudoraWin32.cpp
+++ b/mailnews/import/eudora/src/nsEudoraWin32.cpp
@@ -1024,19 +1024,19 @@ void nsEudoraWin32::SetSmtpServer( nsIMs
       IMPORT_LOG1( "SMTP server already exists: %s\n", pServer);
       return;
     }
     nsCOMPtr<nsISmtpServer>    smtpServer;
 
     rv = smtpService->CreateSmtpServer( getter_AddRefs( smtpServer));
     if (NS_SUCCEEDED( rv) && smtpServer)
     {
-      smtpServer->SetHostname( pServer);
+      smtpServer->SetHostname(nsDependentCString(pServer));
       if (pUser)
-        smtpServer->SetUsername( pUser);
+        smtpServer->SetUsername(nsDependentCString(pUser));
 
       IMPORT_LOG1( "Created new SMTP server: %s\n", pServer);
     }
   }
 }
 
 nsresult nsEudoraWin32::GetAttachmentInfo( const char *pFileName, nsIFile *pFile, nsCString& mimeType, nsCString& aAttachmentName)
 {
--- a/mailnews/import/oexpress/nsOESettings.cpp
+++ b/mailnews/import/oexpress/nsOESettings.cpp
@@ -610,15 +610,15 @@ void OESettings::SetSmtpServer( nsIMsgAc
     if (NS_SUCCEEDED( rv) && foundServer) {
       IMPORT_LOG1( "SMTP server already exists: %s\n", pServer);
       return;
     }
 
     nsCOMPtr<nsISmtpServer> smtpServer;
     rv = smtpService->CreateSmtpServer( getter_AddRefs( smtpServer));
     if (NS_SUCCEEDED( rv) && smtpServer) {
-      smtpServer->SetHostname( pServer);
+      smtpServer->SetHostname(nsDependentCString(pServer));
       if (!user.IsEmpty())
-        smtpServer->SetUsername( user.get());
+        smtpServer->SetUsername(user);
       IMPORT_LOG1( "Created new SMTP server: %s\n", pServer);
     }
   }
 }
--- a/mailnews/import/outlook/src/nsOutlookSettings.cpp
+++ b/mailnews/import/outlook/src/nsOutlookSettings.cpp
@@ -534,16 +534,16 @@ void OutlookSettings::SetSmtpServer(nsIM
     rv = smtpService->FindServer( user.get(), pServer, getter_AddRefs( foundServer));
     if (NS_SUCCEEDED( rv) && foundServer) {
       IMPORT_LOG1( "SMTP server already exists: %s\n", pServer);
       return;
     }
     nsCOMPtr<nsISmtpServer> smtpServer;
     rv = smtpService->CreateSmtpServer( getter_AddRefs( smtpServer));
     if (NS_SUCCEEDED( rv) && smtpServer) {
-      smtpServer->SetHostname( pServer);
+      smtpServer->SetHostname(nsDependentCString(pServer));
       if (!user.IsEmpty())
-        smtpServer->SetUsername(user.get());
+        smtpServer->SetUsername(user);
       IMPORT_LOG1( "Ceated new SMTP server: %s\n", pServer);
     }
   }
 }