From 377359d015516f4b350911ee7c9dd18534646aec Mon Sep 17 00:00:00 2001 From: "warren%netscape.com" Date: Wed, 17 May 2000 07:12:40 +0000 Subject: [PATCH] Bug 39416. Made ftp work with single sign-on for more than one user/host. git-svn-id: svn://10.0.0.236/trunk@70373 18797224-902f-48f8-a5cc-f745e15eee43 --- .../psm-glue/src/nsPSMUICallbacks.cpp | 3 +- .../extensions/wallet/src/nsWalletService.cpp | 12 +- mozilla/extensions/wallet/src/singsign.cpp | 227 --------------- .../mailnews/addrbook/src/nsAddbookUrl.cpp | 10 + .../mailnews/base/util/nsMsgMailNewsUrl.cpp | 10 + mozilla/mailnews/compose/src/nsSmtpUrl.cpp | 10 + mozilla/modules/libjar/nsJARURI.cpp | 14 + mozilla/netwerk/base/public/nsIURI.idl | 17 +- mozilla/netwerk/base/src/nsSimpleURI.cpp | 16 + mozilla/netwerk/base/src/nsStdURL.cpp | 42 +++ .../ftp/src/nsFtpConnectionThread.cpp | 5 +- .../protocol/http/src/nsHTTPChannel.cpp | 6 +- mozilla/netwerk/protocol/jar/src/nsJARURI.cpp | 14 + .../xpfe/appshell/src/nsWebShellWindow.cpp | 273 +----------------- 14 files changed, 147 insertions(+), 512 deletions(-) diff --git a/mozilla/extensions/psm-glue/src/nsPSMUICallbacks.cpp b/mozilla/extensions/psm-glue/src/nsPSMUICallbacks.cpp index ec211c54a7e..efebfac9fda 100644 --- a/mozilla/extensions/psm-glue/src/nsPSMUICallbacks.cpp +++ b/mozilla/extensions/psm-glue/src/nsPSMUICallbacks.cpp @@ -301,7 +301,8 @@ char * PromptUserCallback(void *arg, char *prompt, int isPasswd) if (NS_SUCCEEDED(rv)) { rv = dialog->PromptPassword(nsnull, NS_ConvertASCIItoUCS2(prompt).GetUnicode(), - NS_ConvertASCIItoUCS2(" ").GetUnicode(), PR_TRUE, &password, &value); + NS_ConvertASCIItoUCS2(" ").GetUnicode(), // hostname + PR_TRUE, &password, &value); if (NS_SUCCEEDED(rv)) { nsString a(password); diff --git a/mozilla/extensions/wallet/src/nsWalletService.cpp b/mozilla/extensions/wallet/src/nsWalletService.cpp index 5e833b7cbd2..6294d36ea77 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.cpp +++ b/mozilla/extensions/wallet/src/nsWalletService.cpp @@ -419,15 +419,15 @@ nsSingleSignOnPrompt::Confirm(const PRUnichar *dialogTitle, const PRUnichar *tex NS_IMETHODIMP nsSingleSignOnPrompt::ConfirmCheck(const PRUnichar *dialogTitle, const PRUnichar *text, - const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval) + const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval) { return mPrompt->ConfirmCheck(dialogTitle, text, checkMsg, checkValue, _retval); } NS_IMETHODIMP nsSingleSignOnPrompt::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text, - const PRUnichar *passwordRealm, const PRUnichar *defaultText, - PRUnichar **result, PRBool *_retval) + const PRUnichar *passwordRealm, const PRUnichar *defaultText, + PRUnichar **result, PRBool *_retval) { nsresult rv; nsCAutoString realm; @@ -438,8 +438,8 @@ nsSingleSignOnPrompt::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text NS_IMETHODIMP nsSingleSignOnPrompt::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text, - const PRUnichar *passwordRealm, PRBool persistPassword, - PRUnichar **user, PRUnichar **pwd, PRBool *_retval) + const PRUnichar *passwordRealm, PRBool persistPassword, + PRUnichar **user, PRUnichar **pwd, PRBool *_retval) { nsresult rv; nsCAutoString realm; @@ -451,7 +451,7 @@ nsSingleSignOnPrompt::PromptUsernameAndPassword(const PRUnichar *dialogTitle, co NS_IMETHODIMP nsSingleSignOnPrompt::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm, - PRBool persistPassword, PRUnichar **pwd, PRBool *_retval) + PRBool persistPassword, PRUnichar **pwd, PRBool *_retval) { nsresult rv; nsCAutoString realm; diff --git a/mozilla/extensions/wallet/src/singsign.cpp b/mozilla/extensions/wallet/src/singsign.cpp index 7a6cb653e93..728fcedaa48 100644 --- a/mozilla/extensions/wallet/src/singsign.cpp +++ b/mozilla/extensions/wallet/src/singsign.cpp @@ -779,29 +779,6 @@ si_GetURL(const char * passwordRealm) { return (NULL); } -#if 0 -static nsresult MangleUrl(const char *url, char **result) -{ - if (!url || !result) return NS_ERROR_FAILURE; - - nsCAutoString temp(url); - - temp.ReplaceSubstring("@","-"); - temp.ReplaceSubstring("/","-"); - temp.ReplaceSubstring(":","-"); - temp.ReplaceSubstring("#","-"); - temp.ReplaceSubstring("&","-"); - temp.ReplaceSubstring("?","-"); - temp.ReplaceSubstring(".","-"); - - *result = PL_strdup((const char *)temp); -#ifdef DEBUG_sspitzer - printf("mangling %s into %s\n", url, *result); -#endif - return NS_OK; -} -#endif - /* Remove a user node from a given URL node */ PRIVATE PRBool si_RemoveUser(const char *passwordRealm, nsAutoString userName, PRBool save) { @@ -814,47 +791,6 @@ si_RemoveUser(const char *passwordRealm, nsAutoString userName, PRBool save) { return PR_FALSE; } -#if 0 - nsresult res; - /* convert passwordRealm to a uri so we can parse out the username and hostname */ - nsXPIDLCString host; - if (strip) { - if (passwordRealm) { - nsCOMPtr uri; - nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, NS_GET_IID(nsIURL), (void **) getter_AddRefs(uri)); - res = uri->SetSpec(passwordRealm); - if (NS_FAILED(res)) return PR_FALSE; - - /* uri is of the form ://:@:/) */ - - /* get host part of the uri */ - res = uri->GetHost(getter_Copies(host)); - if (NS_FAILED(res)) { - return PR_FALSE; - } - - /* if no username given, extract it from uri -- note: prehost is : */ - if (userName.Length() == 0) { - nsXPIDLCString userName2; - res = uri->GetPreHost(getter_Copies(userName2)); - if (NS_FAILED(res)) { - return PR_FALSE; - } - if ((const char *)userName2 && (PL_strlen((const char *)userName2))) { - userName = NS_ConvertToString((const char *)userName2); - PRInt32 colon = userName.FindChar(':'); - if (colon != -1) { - userName.Truncate(colon); - } - } - } - } - } else { - res = MangleUrl(passwordRealm, getter_Copies(host)); - if (NS_FAILED(res)) return PR_FALSE; - } -#endif - si_lock_signon_list(); /* get URL corresponding to host */ @@ -2254,48 +2190,6 @@ PUBLIC PRBool SINGSIGN_StorePassword(const char *passwordRealm, const PRUnichar *user, const PRUnichar *password) { nsAutoString userName(user); -#if 0 - nsresult res; - - /* convert passwordRealm to a uri so we can parse out the username and hostname */ - nsXPIDLCString host; - if (strip) { - if (passwordRealm) { - nsCOMPtr uri; - nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, NS_GET_IID(nsIURL), (void **) getter_AddRefs(uri)); - res = uri->SetSpec(passwordRealm); - if (NS_FAILED(res)) return PR_FALSE; - - /* uri is of the form ://:@:/) */ - - /* get host part of the uri */ - res = uri->GetHost(getter_Copies(host)); - if (NS_FAILED(res)) { - return PR_FALSE; - } - - /* if no username given, extract it from uri -- note: prehost is : */ - if (userName.Length() == 0) { - nsXPIDLCString userName2; - res = uri->GetPreHost(getter_Copies(userName2)); - if (NS_FAILED(res)) { - return PR_FALSE; - } - if ((const char *)userName2 && (PL_strlen((const char *)userName2))) { - userName.AssignWithConversion(userName2); - PRInt32 colon = userName.FindChar(':'); - if (colon != -1) { - userName.Truncate(colon); - } - } - } - } - } else { - res = MangleUrl(passwordRealm, getter_Copies(host)); - if (NS_FAILED(res)) return PR_FALSE; - } -#endif - si_RememberSignonDataFromBrowser(passwordRealm, userName, nsAutoString(password)); return PR_TRUE; } @@ -2328,32 +2222,6 @@ SINGSIGN_PromptUsernameAndPassword persistPassword, user, pwd, pressedOK); } -#if 0 - /* convert to a uri so we can parse out the hostname */ - nsCOMPtr uri; - nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, NS_GET_IID(nsIURL), (void **) getter_AddRefs(uri)); - res = uri->SetSpec(passwordRealm); - if (NS_FAILED(res)) { - return res; - } - - /* uri is of the form ://:@:/) */ - - /* get host part of the uri */ - nsXPIDLCString host; - if (strip) { - res = uri->GetHost(getter_Copies(host)); - if (NS_FAILED(res)) { - return res; - } - } else { - res = MangleUrl(passwordRealm, getter_Copies(host)); - if (NS_FAILED(res)) { - return res; - } - } -#endif - /* prefill with previous username/password if any */ nsAutoString username, password; si_RestoreOldSignonDataFromBrowser(passwordRealm, PR_FALSE, username, password); @@ -2399,48 +2267,6 @@ SINGSIGN_PromptPassword return res; } -#if 0 - /* convert to a uri so we can parse out the username and hostname */ - nsCOMPtr uri; - nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, NS_GET_IID(nsIURL), (void **) getter_AddRefs(uri)); - res = uri->SetSpec(passwordRealm); - if (NS_FAILED(res)) { - return res; - } - - /* uri is of the form ://:@:/) */ - - /* get host part of the uri */ - nsXPIDLCString host; - if (strip) { - res = uri->GetHost(getter_Copies(host)); - if (NS_FAILED(res)) { - return res; - } - } else { - res = MangleUrl(passwordRealm, getter_Copies(host)); - if (NS_FAILED(res)) { - return res; - } - } - - /* extract username from uri -- note: prehost is : */ - if (strip) { - nsXPIDLCString prehostCString; - res = uri->GetPreHost(getter_Copies(prehostCString)); - if (NS_FAILED(res)) { - return res; - } - nsAutoString prehost; prehost.AssignWithConversion((const char *)prehostCString); - PRInt32 colon = prehost.FindChar(':'); - if (colon == -1) { - username = prehost; - } else { - prehost.Left(username, colon); - } - } -#endif - /* get previous password used with this username, pick first user if no username found */ si_RestoreOldSignonDataFromBrowser(passwordRealm, (username.Length() == 0), username, password); @@ -2487,30 +2313,6 @@ SINGSIGN_Prompt return res; } -#if 0 - /* convert to a uri so we can parse out the hostname */ - nsCOMPtr uri; - nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, NS_GET_IID(nsIURL), (void **) getter_AddRefs(uri)); - res = uri->SetSpec(passwordRealm); - if (NS_FAILED(res)) { - return res; - } - - /* get host part of the uri */ - nsXPIDLCString host; - if (strip) { - res = uri->GetHost(getter_Copies(host)); - if (NS_FAILED(res)) { - return res; - } - } else { - res = MangleUrl(passwordRealm, getter_Copies(host)); - if (NS_FAILED(res)) { - return res; - } - } -#endif - /* get previous data used with this hostname */ si_RestoreOldSignonDataFromBrowser(passwordRealm, PR_TRUE, emptyUsername, data); @@ -2783,35 +2585,6 @@ SINGSIGN_HaveData(const char *passwordRealm, const PRUnichar *userName, PRBool * return NS_OK; } -#if 0 - nsresult res; - NS_ASSERTION(strip == PR_FALSE, "this code needs to be finished for the strip case"); - - /* convert to a uri so we can parse out the username and hostname */ - nsCOMPtr uri; - nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, NS_GET_IID(nsIURL), (void **) getter_AddRefs(uri)); - res = uri->SetSpec(passwordRealm); - if (NS_FAILED(res)) return res; - - /* get host part of the uri */ - nsXPIDLCString host; - if (strip) { - res = uri->GetHost(getter_Copies(host)); - if (NS_FAILED(res)) { - return res; - } - } else { - res = MangleUrl(passwordRealm, getter_Copies(host)); - if (NS_FAILED(res)) return res; - } - - if (strip) { - /* convert passwordRealm to a uri so we can parse out the username and hostname */ - /* if no username given, extract it from uri -- note: prehost is : */ - return NS_ERROR_NOT_IMPLEMENTED; - } -#endif - /* get previous data used with this username, pick first user if no username found */ si_RestoreOldSignonDataFromBrowser(passwordRealm, (usernameForLookup.Length() == 0), usernameForLookup, data); diff --git a/mozilla/mailnews/addrbook/src/nsAddbookUrl.cpp b/mozilla/mailnews/addrbook/src/nsAddbookUrl.cpp index 9d066acf08e..5ea3d026f86 100644 --- a/mozilla/mailnews/addrbook/src/nsAddbookUrl.cpp +++ b/mozilla/mailnews/addrbook/src/nsAddbookUrl.cpp @@ -295,6 +295,16 @@ NS_IMETHODIMP nsAddbookUrl::GetSpec(char * *aSpec) return m_baseURL->GetSpec(aSpec); } +NS_IMETHODIMP nsAddbookUrl::GetPrePath(char * *aPrePath) +{ + return m_baseURL->GetPrePath(aPrePath); +} + +NS_IMETHODIMP nsAddbookUrl::SetPrePath(const char * aPrePath) +{ + return m_baseURL->SetPrePath(aPrePath); +} + NS_IMETHODIMP nsAddbookUrl::GetScheme(char * *aScheme) { return m_baseURL->GetScheme(aScheme); diff --git a/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp b/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp index 88110292856..2396ab480d5 100644 --- a/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp +++ b/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp @@ -321,6 +321,16 @@ NS_IMETHODIMP nsMsgMailNewsUrl::SetSpec(const char * aSpec) return m_baseURL->SetSpec(aSpec); } +NS_IMETHODIMP nsMsgMailNewsUrl::GetPrePath(char * *aPrePath) +{ + return m_baseURL->GetPrePath(aPrePath); +} + +NS_IMETHODIMP nsMsgMailNewsUrl::SetPrePath(const char * aPrePath) +{ + return m_baseURL->SetPrePath(aPrePath); +} + NS_IMETHODIMP nsMsgMailNewsUrl::GetScheme(char * *aScheme) { return m_baseURL->GetScheme(aScheme); diff --git a/mozilla/mailnews/compose/src/nsSmtpUrl.cpp b/mozilla/mailnews/compose/src/nsSmtpUrl.cpp index ec2c1569ab3..0d68989b189 100644 --- a/mozilla/mailnews/compose/src/nsSmtpUrl.cpp +++ b/mozilla/mailnews/compose/src/nsSmtpUrl.cpp @@ -298,6 +298,16 @@ NS_IMETHODIMP nsMailtoUrl::GetSpec(char * *aSpec) return m_baseURL->GetSpec(aSpec); } +NS_IMETHODIMP nsMailtoUrl::GetPrePath(char * *aPrePath) +{ + return m_baseURL->GetPrePath(aPrePath); +} + +NS_IMETHODIMP nsMailtoUrl::SetPrePath(const char * aPrePath) +{ + return m_baseURL->SetPrePath(aPrePath); +} + NS_IMETHODIMP nsMailtoUrl::GetScheme(char * *aScheme) { return m_baseURL->GetScheme(aScheme); diff --git a/mozilla/modules/libjar/nsJARURI.cpp b/mozilla/modules/libjar/nsJARURI.cpp index 98684f0d1b1..1c88a65d4de 100644 --- a/mozilla/modules/libjar/nsJARURI.cpp +++ b/mozilla/modules/libjar/nsJARURI.cpp @@ -137,6 +137,20 @@ nsJARURI::SetSpec(const char * aSpec) return rv; } +NS_IMETHODIMP +nsJARURI::GetPrePath(char* *prePath) +{ + *prePath = nsCRT::strdup("jar:"); + return *prePath ? NS_OK : NS_ERROR_OUT_OF_MEMORY; +} + +NS_IMETHODIMP +nsJARURI::SetPrePath(const char* prePath) +{ + NS_NOTREACHED("nsJARURI::SetPrePath"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsJARURI::GetScheme(char * *aScheme) { diff --git a/mozilla/netwerk/base/public/nsIURI.idl b/mozilla/netwerk/base/public/nsIURI.idl index 0123b1a1382..b06001f7985 100644 --- a/mozilla/netwerk/base/public/nsIURI.idl +++ b/mozilla/netwerk/base/public/nsIURI.idl @@ -39,9 +39,13 @@ * | | | | | * | | | | Path * | | | Port - * | | Host - * | PreHost - * Scheme + * | | Host / + * | PreHost / + * Scheme / + * \ / + * -------------------------------- + * | + * PrePath * * The subclass nsIURL provides a means to open an input or output * stream to a URI as a source/destination, as well as providing additional @@ -65,6 +69,13 @@ interface nsIURI : nsISupports */ attribute string spec; + /** + * The prePath returns the stuff before the path + * (e.g. protocol://user:password@host:port/). This is useful for + * authentication, or managing sessions. + */ + attribute string prePath; + /** * The Scheme is the protocol to which this URI refers. Setting * the scheme is a special operation that builds up an equivalent diff --git a/mozilla/netwerk/base/src/nsSimpleURI.cpp b/mozilla/netwerk/base/src/nsSimpleURI.cpp index 70e948c380a..38f668b4ec3 100644 --- a/mozilla/netwerk/base/src/nsSimpleURI.cpp +++ b/mozilla/netwerk/base/src/nsSimpleURI.cpp @@ -134,6 +134,22 @@ nsSimpleURI::SetScheme(const char* scheme) return NS_OK; } +NS_IMETHODIMP +nsSimpleURI::GetPrePath(char* *result) +{ + nsCAutoString prePath = mScheme; + prePath += ":"; + *result = prePath.ToNewCString(); + return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; +} + +NS_IMETHODIMP +nsSimpleURI::SetPrePath(const char* scheme) +{ + NS_NOTREACHED("nsSimpleURI::SetPrePath"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsSimpleURI::GetPreHost(char* *result) { diff --git a/mozilla/netwerk/base/src/nsStdURL.cpp b/mozilla/netwerk/base/src/nsStdURL.cpp index 7ef611e722b..9733e0ddd5f 100644 --- a/mozilla/netwerk/base/src/nsStdURL.cpp +++ b/mozilla/netwerk/base/src/nsStdURL.cpp @@ -458,6 +458,48 @@ nsStdURL::GetSpec(char **o_Spec) return (*o_Spec ? NS_OK : NS_ERROR_OUT_OF_MEMORY); } +nsresult +nsStdURL::GetPrePath(char **o_Spec) +{ + nsresult rv = NS_OK; + nsCAutoString finalSpec; // guaranteed to be singlebyte. + if (mScheme) + { + rv = AppendString(finalSpec,mScheme,ESCAPED,nsIIOService::url_Scheme); + finalSpec += "://"; + } + + rv = AppendPreHost(finalSpec,mUsername,mPassword,ESCAPED); + if (mUsername) + { + finalSpec += "@"; + } + + if (mHost) + { + rv = AppendString(finalSpec,mHost,HOSTESCAPED,nsIIOService::url_Host); + if (-1 != mPort) + { + char* portBuffer = PR_smprintf(":%d", mPort); + if (!portBuffer) + return NS_ERROR_OUT_OF_MEMORY; + finalSpec += portBuffer; + PR_smprintf_free(portBuffer); + portBuffer = 0; + } + } + *o_Spec = finalSpec.ToNewCString(); + + return (*o_Spec ? NS_OK : NS_ERROR_OUT_OF_MEMORY); +} + +nsresult +nsStdURL::SetPrePath(const char *i_Spec) +{ + NS_NOTREACHED("nsStdURL::SetPrePath"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_METHOD nsStdURL::Create(nsISupports *aOuter, REFNSIID aIID, diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp index 5c53f9ca995..df8e62a85d8 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -892,9 +892,12 @@ nsFtpConnectionThread::S_pass() { message.AppendWithConversion(" on "); message.AppendWithConversion(host); + nsXPIDLCString prePath; + rv = mURL->GetPrePath(getter_Copies(prePath)); + if (NS_FAILED(rv)) return rv; rv = proxyprompter->PromptPassword(title.GetUnicode(), message.GetUnicode(), - NS_ConvertASCIItoUCS2(host).GetUnicode(), + NS_ConvertASCIItoUCS2(prePath).GetUnicode(), PR_FALSE, &passwd, &retval); // we want to fail if the user canceled or didn't enter a password. diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp index cdede60157b..b47c97f3e33 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -1832,12 +1832,12 @@ nsHTTPChannel::Authenticate(const char *iChallenge, PRBool iProxyAuth) // Get url nsXPIDLCString urlCString; - mURI->GetHost(getter_Copies(urlCString)); + mURI->GetPrePath(getter_Copies(urlCString)); - nsAutoString hostname = NS_ConvertToString(urlCString); // XXX i18n + nsAutoString prePath = NS_ConvertToString(urlCString); // XXX i18n rv = mPrompter->PromptUsernameAndPassword(nsnull, message.GetUnicode(), - hostname.GetUnicode(), + prePath.GetUnicode(), PR_FALSE, &user, &passwd, diff --git a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp index 98684f0d1b1..1c88a65d4de 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp +++ b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp @@ -137,6 +137,20 @@ nsJARURI::SetSpec(const char * aSpec) return rv; } +NS_IMETHODIMP +nsJARURI::GetPrePath(char* *prePath) +{ + *prePath = nsCRT::strdup("jar:"); + return *prePath ? NS_OK : NS_ERROR_OUT_OF_MEMORY; +} + +NS_IMETHODIMP +nsJARURI::SetPrePath(const char* prePath) +{ + NS_NOTREACHED("nsJARURI::SetPrePath"); + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsJARURI::GetScheme(char * *aScheme) { diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index fa85fb5c0bd..22351ccb015 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1866,7 +1866,7 @@ nsDOMWindowPrompter::PromptUsernameAndPassword(const PRUnichar* dialogTitle, nsresult rv; nsAutoString title(dialogTitle); if (title == nsnull) - title.AssignWithConversion("Prompt"); // XXX i18n + title.AssignWithConversion("Username and Password"); // XXX i18n rv = mCommonDialogs->PromptUsernameAndPassword(mDOMWindow, title.GetUnicode(), text, user, pwd, _retval); return rv; @@ -1884,7 +1884,7 @@ nsDOMWindowPrompter::PromptPassword(const PRUnichar* dialogTitle, nsresult rv; nsAutoString title(dialogTitle); if (title == nsnull) - title.AssignWithConversion("Prompt"); // XXX i18n + title.AssignWithConversion("Password"); // XXX i18n rv = mCommonDialogs->PromptPassword(mDOMWindow, title.GetUnicode(), text, pwd, _retval); return rv; @@ -1982,272 +1982,3 @@ nsWebShellWindow::GetPrompter(nsIPrompt* *result) NS_ADDREF(*result); return NS_OK; } - -#if 0 -//////////////////////////////////////////////////////////////////////////////// -// nsIPrompt - -NS_IMETHODIMP nsWebShellWindow::Alert(const PRUnichar* dialogTitle, - const PRUnichar* text) -{ - nsresult rv; - nsCOMPtr domWindow; - nsIWebShell* tempWebShell; - GetWebShell(tempWebShell ); - nsCOMPtr webShell( dont_AddRef(tempWebShell) ); - if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow)))) - { - NS_ERROR("Unable to retrieve the DOM window from the new web shell."); - return rv; - } - - NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); - // todo, put that in a string bundle - nsString defaultTitle; defaultTitle.AssignWithConversion("Alert"); - if ( NS_SUCCEEDED( rv ) ) - rv = dialog->Alert( domWindow, defaultTitle.GetUnicode(),text ); - return rv; -} - -NS_IMETHODIMP nsWebShellWindow::Confirm(const PRUnichar* dialogTitle, - const PRUnichar* text, - PRBool *_retval) -{ - nsresult rv; - nsCOMPtr domWindow; - nsIWebShell* tempWebShell; - GetWebShell(tempWebShell ); - nsCOMPtr webShell( dont_AddRef(tempWebShell) ); - if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow)))) - { - NS_ERROR("Unable to retrieve the DOM window from the new web shell."); - return rv; - } - - nsString defaultTitle; defaultTitle.AssignWithConversion("Confirm"); - NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); - if ( NS_SUCCEEDED( rv ) ) - rv = dialog->Confirm( domWindow, defaultTitle.GetUnicode(), text, _retval ); - return rv; -} - -NS_IMETHODIMP nsWebShellWindow::ConfirmCheck(const PRUnichar* dialogTitle, - const PRUnichar* text, - const PRUnichar* checkMsg, - PRBool *checkValue, - PRBool *_retval) -{ - nsresult rv; - nsCOMPtr domWindow; - nsIWebShell* tempWebShell; - GetWebShell(tempWebShell ); - nsCOMPtr webShell( dont_AddRef(tempWebShell) ); - if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow)))) - { - NS_ERROR("Unable to retrieve the DOM window from the new web shell."); - return rv; - } - - // todo, put that in a string bundle - nsString defaultTitle; defaultTitle.AssignWithConversion("Confirm"); - NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); - if ( NS_SUCCEEDED( rv ) ) - rv =dialog->ConfirmCheck( domWindow,defaultTitle.GetUnicode(), text, checkMsg, checkValue, _retval ); - return rv; -} - -NS_IMETHODIMP nsWebShellWindow::UniversalDialog - (const PRUnichar *inTitleMessage, - const PRUnichar *inDialogTitle, /* e.g., alert, confirm, prompt, prompt password */ - const PRUnichar *inMsg, /* main message for dialog */ - const PRUnichar *inCheckboxMsg, /* message for checkbox */ - const PRUnichar *inButton0Text, /* text for first button */ - const PRUnichar *inButton1Text, /* text for second button */ - const PRUnichar *inButton2Text, /* text for third button */ - const PRUnichar *inButton3Text, /* text for fourth button */ - const PRUnichar *inEditfield1Msg, /*message for first edit field */ - const PRUnichar *inEditfield2Msg, /* message for second edit field */ - PRUnichar **inoutEditfield1Value, /* initial and final value for first edit field */ - PRUnichar **inoutEditfield2Value, /* initial and final value for second edit field */ - const PRUnichar *inIConURL, /* url of icon to be displayed in dialog */ - /* examples are - "chrome://global/skin/question-icon.gif" for question mark, - "chrome://global/skin/alert-icon.gif" for exclamation mark - */ - PRBool *inoutCheckboxState, /* initial and final state of check box */ - PRInt32 inNumberButtons, /* total number of buttons (0 to 4) */ - PRInt32 inNumberEditfields, /* total number of edit fields (0 to 2) */ - PRInt32 inEditField1Password, /* is first edit field a password field */ - PRInt32 *outButtonPressed) /* number of button that was pressed (0 to 3) */ -{ - nsresult rv; - nsCOMPtr domWindow; - nsIWebShell* tempWebShell; - GetWebShell(tempWebShell ); - nsCOMPtr webShell( dont_AddRef(tempWebShell) ); - if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow)))) - { - NS_ERROR("Unable to retrieve the DOM window from the new web shell."); - return rv; - } - - NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); - if ( NS_SUCCEEDED( rv ) ) - rv = dialog->UniversalDialog( - domWindow, inTitleMessage, inDialogTitle, inMsg, inCheckboxMsg, - inButton0Text, inButton1Text, inButton2Text, inButton3Text, - inEditfield1Msg, inEditfield2Msg, inoutEditfield1Value, - inoutEditfield2Value, inIConURL, inoutCheckboxState, inNumberButtons, - inNumberEditfields, inEditField1Password, outButtonPressed); - return rv; -} - - - -NS_IMETHODIMP nsWebShellWindow::Prompt(const PRUnichar* dialogTitle, - const PRUnichar* text, - const PRUnichar* passwordRealm, - const PRUnichar* defaultText, - PRUnichar* *result, - PRBool *_retval) -{ - nsresult rv; - nsCOMPtr domWindow; - nsIWebShell* tempWebShell; - GetWebShell(tempWebShell ); - nsCOMPtr webShell( dont_AddRef(tempWebShell) ); - if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow)))) - { - NS_ERROR("Unable to retrieve the DOM window from the new web shell."); - return rv; - } - // todo, put that in a string bundle - nsString defaultTitle; defaultTitle.AssignWithConversion("Prompt"); - - NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); - if ( NS_SUCCEEDED( rv ) ) - rv = dialog->Prompt( domWindow, defaultTitle.GetUnicode(), text, defaultText, result, _retval ); - return rv; -} - -NS_IMETHODIMP nsWebShellWindow::PromptUsernameAndPassword(const PRUnichar* dialogTitle, - const PRUnichar* text, - const PRUnichar* passwordRealm, - PRBool persistPassword, - PRUnichar* *user, - PRUnichar* *pwd, - PRBool *_retval) -{ - nsresult rv; - nsCOMPtr domWindow; - nsIWebShell* tempWebShell; - GetWebShell(tempWebShell ); - nsCOMPtr webShell( dont_AddRef(tempWebShell) ); - if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow)))) - { - NS_ERROR("Unable to retrieve the DOM window from the new web shell."); - return rv; - } - -// todo, put that in a string bundle -nsString defaultTitle; defaultTitle.AssignWithConversion("Prompt Username and Password"); - - NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); - if ( NS_SUCCEEDED( rv ) ) - rv = dialog->PromptUsernameAndPassword( domWindow, defaultTitle.GetUnicode(), text, user, pwd, _retval ); - return rv; -} - -NS_IMETHODIMP nsWebShellWindow::PromptPassword(const PRUnichar* dialogTitle, - const PRUnichar* text, - const PRUnichar* passwordRealm, - PRBool persistPassword, - PRUnichar* *pwd, - PRBool *_retval) -{ - nsresult rv; - nsCOMPtr domWindow; - nsIWebShell* tempWebShell; - GetWebShell(tempWebShell ); - nsCOMPtr webShell( dont_AddRef(tempWebShell) ); - if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow)))) - { - NS_ERROR("Unable to retrieve the DOM window from the new web shell."); - return rv; - } - - NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); - if ( NS_SUCCEEDED( rv ) ) - rv = dialog->PromptPassword( domWindow, dialogTitle, text, pwd, _retval ); - return rv; -} - -NS_IMETHODIMP nsWebShellWindow::Select( const PRUnichar *inDialogTitle, const PRUnichar* inMsg, PRUint32 inCount, const PRUnichar **inList, PRInt32 *outSelection, PRBool *_retval) -{ - nsresult rv; - nsCOMPtr domWindow; - nsIWebShell* tempWebShell; - GetWebShell(tempWebShell ); - nsCOMPtr webShell( dont_AddRef(tempWebShell) ); - if (NS_FAILED(rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow)))) - { - NS_ERROR("Unable to retrieve the DOM window from the new web shell."); - return rv; - } - - NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); - if ( NS_SUCCEEDED( rv ) ) - rv = dialog->Select(domWindow, inDialogTitle, inMsg, inCount,inList, outSelection, _retval); - return rv; -} - -NS_IMETHODIMP nsWebShellWindow::Alert(const char *key, const PRUnichar *title, const PRUnichar *text) -{ - return Alert( text ); -} - - -NS_IMETHODIMP nsWebShellWindow::Confirm(const char *key, const PRUnichar *title, const PRUnichar *text, PRBool *_retval) -{ - return Confirm( text, _retval ); -} - -NS_IMETHODIMP nsWebShellWindow::PromptUsernameAndPassword(const char *key, const PRUnichar *title, const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, PRBool *_retval) -{ - nsresult res; - NS_WITH_SERVICE(nsIWalletService, wallet, kWalletServiceCID, &res); - if (NS_FAILED(res)) { - return PromptUsernameAndPassword(text, user, pwd, _retval); - } - nsCOMPtr prompter = this; - return wallet->PromptUsernameAndPassword(text, user, pwd, key, prompter, PR_TRUE, _retval); -} - - -NS_IMETHODIMP nsWebShellWindow::PromptPassword(const char *key, const PRUnichar *title, const PRUnichar *text, PRUnichar **pwd, PRBool *_retval) -{ - nsresult res; - NS_WITH_SERVICE(nsIWalletService, wallet, kWalletServiceCID, &res); - if (NS_FAILED(res)) { - return PromptPassword(text, title, pwd, _retval); - } - nsCOMPtr prompter = this; - return wallet->PromptPassword(text, pwd, key, prompter, PR_TRUE, _retval); -} - -NS_IMETHODIMP nsWebShellWindow::Prompt(const char *key, const PRUnichar *title, const PRUnichar *text, PRUnichar **value, PRBool *_retval) -{ - nsresult res; - NS_WITH_SERVICE(nsIWalletService, wallet, kWalletServiceCID, &res); - if (NS_FAILED(res)) { - return Prompt(text, title, value, _retval); - } - nsCOMPtr prompter = this; - return wallet->Prompt(text, nsnull, value, key, prompter, _retval); -} - -#endif - - - -