diff --git a/mailnews/compose/resources/locale/en-US/composeMsgs.properties b/mailnews/compose/resources/locale/en-US/composeMsgs.properties index 3a31e3fbb39..a3c3e8e705b 100644 --- a/mailnews/compose/resources/locale/en-US/composeMsgs.properties +++ b/mailnews/compose/resources/locale/en-US/composeMsgs.properties @@ -152,9 +152,12 @@ noIdentities=You don't have any email identities yet. Create one with the Accou ## @name NS_SMTP_PASSWORD_PROMPT_TITLE 12542=Mail Server Password Required -## @name NS_SMTP_PASSWORD_PROMPT +## @name NS_SMTP_PASSWORD_PROMPT1 12543=Enter your password for %S: +## @name NS_SMTP_PASSWORD_PROMPT2 +12570=Enter your password for %S on %S: + ## @name NS_SMTP_CONNECTING_TO_SERVER 12545=Connecting to server... diff --git a/mailnews/compose/src/nsMsgComposeStringBundle.h b/mailnews/compose/src/nsMsgComposeStringBundle.h index 85d1ef0158b..e029c4dd641 100644 --- a/mailnews/compose/src/nsMsgComposeStringBundle.h +++ b/mailnews/compose/src/nsMsgComposeStringBundle.h @@ -107,7 +107,8 @@ private: #define NS_MSG_LARGE_MESSAGE_WARNING NS_MSG_GENERATE_FAILURE(12541) #define NS_SMTP_PASSWORD_PROMPT_TITLE 12542 -#define NS_SMTP_PASSWORD_PROMPT 12543 +#define NS_SMTP_PASSWORD_PROMPT1 12543 +#define NS_SMTP_PASSWORD_PROMPT2 12570 #define NS_SMTP_CONNECTING_TO_SERVER NS_MSG_GENERATE_SUCCESS(12545) #define NS_MSG_SENDING_MESSAGE NS_MSG_GENERATE_SUCCESS(12550) diff --git a/mailnews/compose/src/nsSmtpProtocol.cpp b/mailnews/compose/src/nsSmtpProtocol.cpp index 631e682a0ab..7a95c14755b 100644 --- a/mailnews/compose/src/nsSmtpProtocol.cpp +++ b/mailnews/compose/src/nsSmtpProtocol.cpp @@ -1709,28 +1709,32 @@ nsSmtpProtocol::GetPassword(char **aPassword) rv = smtpServer->GetUsername(getter_Copies(username)); NS_ENSURE_SUCCESS(rv, rv); - nsCAutoString promptValue(username); + const PRUnichar *formatStrings[] = + { + NS_ConvertASCIItoUCS2(username).get() + }; PRBool hideHostnameForPassword = PR_FALSE; rv = prefBranch->GetBoolPref(prefName.get(), &hideHostnameForPassword); if (NS_SUCCEEDED(rv) && hideHostnameForPassword) { // for certain redirector types, we don't want to show the // hostname to the user when prompting for password + formatStrings[1] = nsnull; } else { nsXPIDLCString hostname; rv = smtpServer->GetHostname(getter_Copies(hostname)); NS_ENSURE_SUCCESS(rv, rv); - promptValue.Append("@"); - promptValue.Append(hostname); + formatStrings[1] = NS_ConvertASCIItoUCS2(hostname).get(); } - rv = PromptForPassword(smtpServer, smtpUrl, NS_ConvertASCIItoUCS2(promptValue).get(), aPassword); + rv = PromptForPassword(smtpServer, smtpUrl, formatStrings, aPassword); NS_ENSURE_SUCCESS(rv,rv); return rv; } -nsresult nsSmtpProtocol::PromptForPassword(nsISmtpServer *aSmtpServer, nsISmtpUrl *aSmtpUrl, const PRUnichar *aPromptValue, char **aPassword) +nsresult +nsSmtpProtocol::PromptForPassword(nsISmtpServer *aSmtpServer, nsISmtpUrl *aSmtpUrl, const PRUnichar **formatStrings, char **aPassword) { nsresult rv; nsCOMPtr stringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); @@ -1740,15 +1744,15 @@ nsresult nsSmtpProtocol::PromptForPassword(nsISmtpServer *aSmtpServer, nsISmtpUr rv = stringService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(composeStringBundle)); NS_ENSURE_SUCCESS(rv,rv); - const PRUnichar *formatStrings[] = - { - aPromptValue, - }; - nsXPIDLString passwordPromptString; - rv = composeStringBundle->FormatStringFromID(NS_SMTP_PASSWORD_PROMPT, - formatStrings, 1, - getter_Copies(passwordPromptString)); + if(formatStrings[1]) + rv = composeStringBundle->FormatStringFromID(NS_SMTP_PASSWORD_PROMPT2, + formatStrings, 2, + getter_Copies(passwordPromptString)); + else + rv = composeStringBundle->FormatStringFromID(NS_SMTP_PASSWORD_PROMPT1, + formatStrings, 1, + getter_Copies(passwordPromptString)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr netPrompt; @@ -1802,7 +1806,13 @@ nsSmtpProtocol::GetUsernamePassword(char **aUsername, char **aPassword) rv = smtpServer->GetHostname(getter_Copies(hostname)); NS_ENSURE_SUCCESS(rv, rv); - rv = PromptForPassword(smtpServer, smtpUrl, NS_ConvertASCIItoUCS2(hostname).get(), aPassword); + const PRUnichar *formatStrings[] = + { + NS_ConvertASCIItoUCS2(hostname).get(), + nsnull + }; + + rv = PromptForPassword(smtpServer, smtpUrl, formatStrings, aPassword); NS_ENSURE_SUCCESS(rv,rv); return rv; } diff --git a/mailnews/compose/src/nsSmtpProtocol.h b/mailnews/compose/src/nsSmtpProtocol.h index d41c225bde2..7223824f52d 100644 --- a/mailnews/compose/src/nsSmtpProtocol.h +++ b/mailnews/compose/src/nsSmtpProtocol.h @@ -248,7 +248,7 @@ private: const char * GetUserDomainName(); nsresult GetPassword(char **aPassword); nsresult GetUsernamePassword(char **aUsername, char **aPassword); - nsresult PromptForPassword(nsISmtpServer *aSmtpServer, nsISmtpUrl *aSmtpUrl, const PRUnichar *aPromptValue, char **aPassword); + nsresult PromptForPassword(nsISmtpServer *aSmtpServer, nsISmtpUrl *aSmtpUrl, const PRUnichar **formatStrings, char **aPassword); void BackupAuthFlags(); void RestoreAuthFlags();