From e2987a0982308b9114a78e1eb76bd1aab20bd052 Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Tue, 10 Aug 1999 23:08:50 +0000 Subject: [PATCH] Fix for Bug #11470 --> when prompting the user for a password (when getting new mail for pop), let's gracefully abort the operation if the user hits cancel. --- mailnews/local/src/nsPop3Protocol.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mailnews/local/src/nsPop3Protocol.cpp b/mailnews/local/src/nsPop3Protocol.cpp index 97f27b45914f..b26f8a155291 100644 --- a/mailnews/local/src/nsPop3Protocol.cpp +++ b/mailnews/local/src/nsPop3Protocol.cpp @@ -449,6 +449,8 @@ const char * nsPop3Protocol::GetPassword() msgUrl->GetHost(getter_Copies(hostName)); + // mscott - this is just a temporary hack using the raw string..this needs to be pushed into + // a string bundle!!!!! if (hostName) promptText = PR_smprintf("Enter your password for %s@%s.", (const char *) m_username, (const char *) hostName); else @@ -456,6 +458,10 @@ const char * nsPop3Protocol::GetPassword() dialog->PromptPassword(nsAutoString(promptText).GetUnicode(), &uniPassword, &okayValue); PR_FREEIF(promptText); + + if (!okayValue) // if the user pressed cancel, just return NULL; + return nsnull; + m_password = uniPassword; // this ugly cast is ok...there is a bug in the idl compiler that is preventing // the char * argument to SetPassword from being const. @@ -490,7 +496,10 @@ nsresult nsPop3Protocol::LoadUrl(nsIURI* aURL, nsISupports * /* aConsumer */) // -*-*-*- To Do: // Call SetUsername(accntName); // Call SetPassword(aPassword); - GetPassword(); + const char * password = GetPassword(); + // if we didn't get a password back, abort the entire operation! + if (!password) + return NS_ERROR_FAILURE; nsCOMPtr url = do_QueryInterface(aURL, &rv); if (NS_FAILED(rv)) return rv;