mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 13:21:28 +00:00
Bug 39416. Made ftp work with single sign-on for more than one user/host.
This commit is contained in:
parent
9b98320e40
commit
5f6b57ef08
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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<nsIURL> 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 <scheme>://<username>:<password>@<host>:<portnumber>/<pathname>) */
|
||||
|
||||
/* 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 <username>:<password> */
|
||||
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<nsIURL> 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 <scheme>://<username>:<password>@<host>:<portnumber>/<pathname>) */
|
||||
|
||||
/* 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 <username>:<password> */
|
||||
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<nsIURL> 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 <scheme>://<username>:<password>@<host>:<portnumber>/<pathname>) */
|
||||
|
||||
/* 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<nsIURL> 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 <scheme>://<username>:<password>@<host>:<portnumber>/<pathname>) */
|
||||
|
||||
/* 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 <username>:<password> */
|
||||
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<nsIURL> 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<nsIURL> 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 <username>:<password> */
|
||||
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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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<nsIDOMWindow> domWindow;
|
||||
nsIWebShell* tempWebShell;
|
||||
GetWebShell(tempWebShell );
|
||||
nsCOMPtr<nsIWebShell> 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<nsIDOMWindow> domWindow;
|
||||
nsIWebShell* tempWebShell;
|
||||
GetWebShell(tempWebShell );
|
||||
nsCOMPtr<nsIWebShell> 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<nsIDOMWindow> domWindow;
|
||||
nsIWebShell* tempWebShell;
|
||||
GetWebShell(tempWebShell );
|
||||
nsCOMPtr<nsIWebShell> 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<nsIDOMWindow> domWindow;
|
||||
nsIWebShell* tempWebShell;
|
||||
GetWebShell(tempWebShell );
|
||||
nsCOMPtr<nsIWebShell> 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<nsIDOMWindow> domWindow;
|
||||
nsIWebShell* tempWebShell;
|
||||
GetWebShell(tempWebShell );
|
||||
nsCOMPtr<nsIWebShell> 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<nsIDOMWindow> domWindow;
|
||||
nsIWebShell* tempWebShell;
|
||||
GetWebShell(tempWebShell );
|
||||
nsCOMPtr<nsIWebShell> 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<nsIDOMWindow> domWindow;
|
||||
nsIWebShell* tempWebShell;
|
||||
GetWebShell(tempWebShell );
|
||||
nsCOMPtr<nsIWebShell> 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<nsIDOMWindow> domWindow;
|
||||
nsIWebShell* tempWebShell;
|
||||
GetWebShell(tempWebShell );
|
||||
nsCOMPtr<nsIWebShell> 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<nsIPrompt> 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<nsIPrompt> 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<nsIPrompt> prompter = this;
|
||||
return wallet->Prompt(text, nsnull, value, key, prompter, _retval);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user