diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index ab45e8e8ae38..27b3c4d53a82 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -1045,7 +1045,7 @@ NS_IMETHODIMP nsDocShell::LoadURI(const PRUnichar* aURI) dnsMsg.AppendWithConversion(' '); dnsMsg.Append(messageStr); - prompter->Alert(dnsMsg.GetUnicode()); + prompter->Alert(nsnull, dnsMsg.GetUnicode()); } // end unknown protocol if(!uri) diff --git a/docshell/base/nsWebShell.cpp b/docshell/base/nsWebShell.cpp index 1018c1bb3fed..056dab2e8722 100644 --- a/docshell/base/nsWebShell.cpp +++ b/docshell/base/nsWebShell.cpp @@ -1046,7 +1046,7 @@ nsWebShell::OnOverLink(nsIContent* aContent, NS_IMETHODIMP nsWebShell::GetLinkState(const nsString& aLinkURI, nsLinkState& aState) { - aState = eLinkState_Unvisited; + aState = eLinkState_Unvisited; if(mGlobalHistory) { @@ -1276,7 +1276,7 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, errorMsg.AppendWithConversion(' '); errorMsg.Append(messageStr); - prompter->Alert(errorMsg.GetUnicode()); + prompter->Alert(nsnull, errorMsg.GetUnicode()); } else if(aStatus == NS_ERROR_CONNECTION_REFUSED) {// Doc failed to load because we couldn't connect to the server. @@ -1304,7 +1304,7 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, errorMsg.AppendInt(port); } errorMsg.AppendWithConversion('.'); - prompter->Alert(errorMsg.GetUnicode()); + prompter->Alert(nsnull, errorMsg.GetUnicode()); } else if(aStatus == NS_ERROR_NET_TIMEOUT) {// Doc failed to load because the socket function timed out. @@ -1326,7 +1326,7 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, errorMsg.AppendWithConversion(host); errorMsg.AppendWithConversion('.'); - prompter->Alert(errorMsg.GetUnicode()); + prompter->Alert(nsnull, errorMsg.GetUnicode()); } // end NS_ERROR_NET_TIMEOUT } // end mDocLoader == loader diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index 041790248553..09bd6ea026e2 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -1166,7 +1166,7 @@ NS_IMETHODIMP GlobalWindowImpl::Alert(JSContext* cx, jsval* argv, PRUint32 argc) nsCOMPtr prompter(do_GetInterface(mDocShell)); NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE); - return prompter->Alert(str.GetUnicode()); + return prompter->Alert(nsnull, str.GetUnicode()); } NS_IMETHODIMP GlobalWindowImpl::Confirm(JSContext* cx, jsval* argv, @@ -1185,7 +1185,7 @@ NS_IMETHODIMP GlobalWindowImpl::Confirm(JSContext* cx, jsval* argv, nsCOMPtr prompter(do_GetInterface(mDocShell)); NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE); - return prompter->Confirm(str.GetUnicode(), aReturn); + return prompter->Confirm(nsnull, str.GetUnicode(), aReturn); } NS_IMETHODIMP GlobalWindowImpl::Prompt(JSContext* cx, jsval* argv, @@ -1213,7 +1213,8 @@ NS_IMETHODIMP GlobalWindowImpl::Prompt(JSContext* cx, jsval* argv, PRBool b; PRUnichar* uniResult = nsnull; - ret = prompter->Prompt(str.GetUnicode(), initial.GetUnicode(), &uniResult, &b); + ret = prompter->Prompt(nsnull, str.GetUnicode(), nsnull, + initial.GetUnicode(), &uniResult, &b); aReturn = uniResult; if(uniResult) nsAllocator::Free(uniResult); diff --git a/embedding/browser/activex/src/control/WebBrowserContainer.cpp b/embedding/browser/activex/src/control/WebBrowserContainer.cpp index 394b9cf9d08b..962687cfd39e 100644 --- a/embedding/browser/activex/src/control/WebBrowserContainer.cpp +++ b/embedding/browser/activex/src/control/WebBrowserContainer.cpp @@ -84,48 +84,53 @@ NS_IMETHODIMP CWebBrowserContainer::GetInterface(const nsIID & uuid, void * *res // nsIPrompt /* void alert (in wstring text); */ -NS_IMETHODIMP CWebBrowserContainer::Alert(const PRUnichar *text) +NS_IMETHODIMP CWebBrowserContainer::Alert(const PRUnichar* dialogTitle, const PRUnichar *text) { USES_CONVERSION; - m_pOwner->MessageBox(W2T(text), _T("Alert"), MB_OK | MB_ICONEXCLAMATION); + m_pOwner->MessageBox(W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION); return NS_OK; } /* boolean confirm (in wstring text); */ -NS_IMETHODIMP CWebBrowserContainer::Confirm(const PRUnichar *text, PRBool *_retval) +NS_IMETHODIMP CWebBrowserContainer::Confirm(const PRUnichar* dialogTitle, const PRUnichar *text, PRBool *_retval) { USES_CONVERSION; - int nAnswer = m_pOwner->MessageBox(W2T(text), _T("Confirm"), MB_YESNO | MB_ICONQUESTION); + int nAnswer = m_pOwner->MessageBox(W2T(text), W2T(dialogTitle), MB_YESNO | MB_ICONQUESTION); *_retval = (nAnswer == IDYES) ? PR_TRUE : PR_FALSE; return NS_OK; } /* boolean confirmCheck (in wstring text, in wstring checkMsg, out boolean checkValue); */ -NS_IMETHODIMP CWebBrowserContainer::ConfirmCheck(const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval) +NS_IMETHODIMP CWebBrowserContainer::ConfirmCheck(const PRUnichar* dialogTitle, const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval) { USES_CONVERSION; // TODO show dialog with check box - int nAnswer = m_pOwner->MessageBox(W2T(text), _T("Confirm"), MB_YESNO | MB_ICONQUESTION); + int nAnswer = m_pOwner->MessageBox(W2T(text), W2T(dialogTitle), MB_YESNO | MB_ICONQUESTION); *_retval = (nAnswer == IDYES) ? PR_TRUE : PR_FALSE; return NS_OK; } /* boolean prompt (in wstring text, in wstring defaultText, out wstring result); */ -NS_IMETHODIMP CWebBrowserContainer::Prompt(const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval) +NS_IMETHODIMP CWebBrowserContainer::Prompt(const PRUnichar* dialogTitle, const PRUnichar *text, const PRUnichar* passwordRealm, + const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval) { return NS_ERROR_NOT_IMPLEMENTED; } /* boolean promptUsernameAndPassword (in wstring text, out wstring user, out wstring pwd); */ -NS_IMETHODIMP CWebBrowserContainer::PromptUsernameAndPassword(const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, PRBool *_retval) +NS_IMETHODIMP CWebBrowserContainer::PromptUsernameAndPassword(const PRUnichar* dialogTitle, const PRUnichar *text, + const PRUnichar* passwordRealm, PRBool persistPassword, + PRUnichar **user, PRUnichar **pwd, PRBool *_retval) { return NS_ERROR_NOT_IMPLEMENTED; } /* boolean promptPassword (in wstring text, in wstring title, out wstring pwd); */ -NS_IMETHODIMP CWebBrowserContainer::PromptPassword(const PRUnichar *text, const PRUnichar *title, PRUnichar **pwd, PRBool *_retval) +NS_IMETHODIMP CWebBrowserContainer::PromptPassword(const PRUnichar* dialogTitle, const PRUnichar *text, + const PRUnichar* passwordRealm, PRBool persistPassword, + PRUnichar **pwd, PRBool *_retval) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/extensions/psm-glue/src/nsPSMUICallbacks.cpp b/extensions/psm-glue/src/nsPSMUICallbacks.cpp index d1b1e9cd7892..ec211c54a7ef 100644 --- a/extensions/psm-glue/src/nsPSMUICallbacks.cpp +++ b/extensions/psm-glue/src/nsPSMUICallbacks.cpp @@ -300,7 +300,8 @@ char * PromptUserCallback(void *arg, char *prompt, int isPasswd) NS_WITH_PROXIED_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, NS_UI_THREAD_EVENTQ, &rv); if (NS_SUCCEEDED(rv)) { - rv = dialog->PromptPassword(NS_ConvertASCIItoUCS2(prompt).GetUnicode(), NS_ConvertASCIItoUCS2(" ").GetUnicode(), &password, &value); + rv = dialog->PromptPassword(nsnull, NS_ConvertASCIItoUCS2(prompt).GetUnicode(), + NS_ConvertASCIItoUCS2(" ").GetUnicode(), PR_TRUE, &password, &value); if (NS_SUCCEEDED(rv)) { nsString a(password); diff --git a/extensions/wallet/public/nsIWalletService.idl b/extensions/wallet/public/nsIWalletService.idl index 48616d327175..cada30caa226 100644 --- a/extensions/wallet/public/nsIWalletService.idl +++ b/extensions/wallet/public/nsIWalletService.idl @@ -21,7 +21,6 @@ */ #include "nsISupports.idl" -#include "nsIURL.idl" #include "nsIPrompt.idl" %{ C++ @@ -32,11 +31,12 @@ #define NS_WALLETSERVICE_CID \ { 0x738cfd52, 0xabcf, 0x11d2, { 0xab, 0x4b, 0x0, 0x80, 0xc7, 0x87, 0xad, 0x96 } } -#define NS_WALLETSERVICE_PROGID "component://netscape/wallet" +#define NS_WALLETSERVICE_PROGID "component://netscape/wallet/wallet-service" #define NS_WALLETSERVICE_CLASSNAME "Auto Form Fill and Wallet" %} interface nsIPresShell; + native nsAutoString(nsAutoString); [ref] native nsAutoStringRef(nsAutoString); @@ -57,13 +57,10 @@ interface nsIWalletService : nsISupports { void WALLET_FetchFromNetCenter(); void WALLET_ExpirePassword(); - boolean PromptUsernameAndPasswordURL(in wstring text, out wstring user, out wstring pwd, in string urlname, in boolean stripUrl, in nsIPrompt dialog); - boolean PromptPasswordURL(in wstring text, out wstring pwd, in string urlname, in boolean stripUrl, in nsIPrompt dialog); - boolean PromptURL(in wstring text, in wstring defaultText, out wstring result, in string urlname, in boolean stripUrl, in nsIPrompt dialog); - void SI_RemoveUser(in string URLName, in boolean stripUrl, in wstring userName); - void SI_StorePassword(in string URLName, in boolean stripUrl, in wstring userName, in wstring pwd); + void SI_RemoveUser(in string key, in wstring userName); + void SI_StorePassword(in string key, in wstring userName, in wstring pwd); - boolean haveData(in string url, in wstring userName, in boolean stripUrl); + boolean haveData(in string key, in wstring userName); [noscript] void WALLET_GetNopreviewListForViewer(in nsAutoStringRef aNopreviewList); [noscript] void WALLET_GetNocaptureListForViewer(in nsAutoStringRef aNocaptureList); @@ -75,3 +72,45 @@ interface nsIWalletService : nsISupports { string WALLET_Encrypt(in wstring text); wstring WALLET_Decrypt(in string crypt); }; + +[scriptable, uuid(6228d644-17fe-11d4-8cee-0060b0fc14a3)] +interface nsISingleSignOnPrompt : nsIPrompt +{ + void init(in nsIPrompt dialogs); +}; + +%{C++ + +#define NS_SINGLESIGNONPROMPT_CID \ +{ /* 64997e60-17fe-11d4-8cee-0060b0fc14a3 */ \ + 0x64997e60, \ + 0x17fe, \ + 0x11d4, \ + {0x8c, 0xee, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \ +} + +#define NS_SINGLESIGNONPROMPT_CLASSNAME "Single Sign-On Prompt" +#define NS_SINGLESIGNONPROMPT_PROGID "component://netscape/wallet/single-sign-on-prompt" + +#include "nsIComponentManager.h" +#include "nsCOMPtr.h" + +inline nsresult +NS_NewSingleSignOnPrompt(nsIPrompt* *result, nsIPrompt* dialogs) +{ + nsresult rv; + nsCOMPtr prompt; + static NS_DEFINE_CID(kSingleSignOnPromptCID, NS_SINGLESIGNONPROMPT_CID); + rv = nsComponentManager::CreateInstance(kSingleSignOnPromptCID, + nsnull, + NS_GET_IID(nsISingleSignOnPrompt), + getter_AddRefs(prompt)); + if (NS_FAILED(rv)) return rv; + rv = prompt->Init(dialogs); + if (NS_FAILED(rv)) return rv; + *result = prompt; + NS_ADDREF(*result); + return NS_OK; +} + +%} diff --git a/extensions/wallet/src/nsWalletFactory.cpp b/extensions/wallet/src/nsWalletFactory.cpp index 0a12df1a8221..56a473d1b4d7 100644 --- a/extensions/wallet/src/nsWalletFactory.cpp +++ b/extensions/wallet/src/nsWalletFactory.cpp @@ -34,6 +34,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsWalletlibService) static nsModuleComponentInfo components[] = { { NS_WALLETSERVICE_CLASSNAME, NS_WALLETSERVICE_CID, NS_WALLETSERVICE_PROGID, nsWalletlibServiceConstructor }, + { NS_SINGLESIGNONPROMPT_CLASSNAME, NS_SINGLESIGNONPROMPT_CID, + NS_SINGLESIGNONPROMPT_PROGID, nsSingleSignOnPrompt::Create } }; NS_IMPL_NSGETMODULE("nsWalletModule", components) diff --git a/extensions/wallet/src/nsWalletService.cpp b/extensions/wallet/src/nsWalletService.cpp index c3be0190513c..5e833b7cbd28 100644 --- a/extensions/wallet/src/nsWalletService.cpp +++ b/extensions/wallet/src/nsWalletService.cpp @@ -109,33 +109,13 @@ NS_IMETHODIMP nsWalletlibService::WALLET_ExpirePassword(){ return NS_OK; } -NS_IMETHODIMP nsWalletlibService::PromptUsernameAndPasswordURL - (const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, - const char *urlname, PRBool stripUrl, nsIPrompt* dialog, PRBool *returnValue) { - return ::SINGSIGN_PromptUsernameAndPassword - (text, user, pwd, urlname, dialog, returnValue, stripUrl); -} - -NS_IMETHODIMP nsWalletlibService::PromptPasswordURL - (const PRUnichar *text, PRUnichar **pwd, const char *urlname, PRBool stripUrl, - nsIPrompt* dialog, PRBool *returnValue) { - return ::SINGSIGN_PromptPassword(text, pwd, urlname, dialog, returnValue, stripUrl); -} - -NS_IMETHODIMP nsWalletlibService::PromptURL - (const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **resultText, - const char *urlname, PRBool stripUrl, nsIPrompt* dialog, PRBool *returnValue) { - return ::SINGSIGN_Prompt - (text, defaultText, resultText, urlname, dialog, returnValue, stripUrl); -} - -NS_IMETHODIMP nsWalletlibService::SI_RemoveUser(const char *URLName, PRBool stripUrl, const PRUnichar *userName) { - ::SINGSIGN_RemoveUser(URLName, userName, stripUrl); +NS_IMETHODIMP nsWalletlibService::SI_RemoveUser(const char *key, const PRUnichar *userName) { + ::SINGSIGN_RemoveUser(key, userName); return NS_OK; } -NS_IMETHODIMP nsWalletlibService::SI_StorePassword(const char *URLName, PRBool stripUrl, const PRUnichar *userName, const PRUnichar *password) { - ::SINGSIGN_StorePassword(URLName, userName, password, stripUrl); +NS_IMETHODIMP nsWalletlibService::SI_StorePassword(const char *key, const PRUnichar *userName, const PRUnichar *password) { + ::SINGSIGN_StorePassword(key, userName, password); return NS_OK; } @@ -397,9 +377,9 @@ nsWalletlibService::GetPassword(PRUnichar **password) } NS_IMETHODIMP -nsWalletlibService::HaveData(const char *url, const PRUnichar *userName, PRBool stripUrl, PRBool *_retval) +nsWalletlibService::HaveData(const char *key, const PRUnichar *userName, PRBool *_retval) { - return ::SINGSIGN_HaveData(url, userName, stripUrl, _retval); + return ::SINGSIGN_HaveData(key, userName, _retval); } NS_IMETHODIMP @@ -419,3 +399,113 @@ nsWalletlibService::WALLET_Decrypt (const char *crypt, PRUnichar **text) { *text = textAutoString.ToNewUnicode(); return rv; } + +//////////////////////////////////////////////////////////////////////////////// +// nsSingleSignOnPrompt + +NS_IMPL_THREADSAFE_ISUPPORTS2(nsSingleSignOnPrompt, nsISingleSignOnPrompt, nsIPrompt) + +NS_IMETHODIMP +nsSingleSignOnPrompt::Alert(const PRUnichar *dialogTitle, const PRUnichar *text) +{ + return mPrompt->Alert(dialogTitle, text); +} + +NS_IMETHODIMP +nsSingleSignOnPrompt::Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *_retval) +{ + return mPrompt->Confirm(dialogTitle, text, _retval); +} + +NS_IMETHODIMP +nsSingleSignOnPrompt::ConfirmCheck(const PRUnichar *dialogTitle, const PRUnichar *text, + 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) +{ + nsresult rv; + nsCAutoString realm; + realm.AssignWithConversion(passwordRealm); // XXX should be PRUnichar* + rv = SINGSIGN_Prompt(dialogTitle, text, defaultText, result, realm.GetBuffer(), mPrompt, _retval); + return rv; +} + +NS_IMETHODIMP +nsSingleSignOnPrompt::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text, + const PRUnichar *passwordRealm, PRBool persistPassword, + PRUnichar **user, PRUnichar **pwd, PRBool *_retval) +{ + nsresult rv; + nsCAutoString realm; + realm.AssignWithConversion(passwordRealm); // XXX should be PRUnichar* + rv = SINGSIGN_PromptUsernameAndPassword(dialogTitle, text, user, pwd, + realm.GetBuffer(), mPrompt, _retval, persistPassword); + return rv; +} + +NS_IMETHODIMP +nsSingleSignOnPrompt::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *passwordRealm, + PRBool persistPassword, PRUnichar **pwd, PRBool *_retval) +{ + nsresult rv; + nsCAutoString realm; + realm.AssignWithConversion(passwordRealm); // XXX should be PRUnichar* + rv = SINGSIGN_PromptPassword(dialogTitle, text, pwd, + realm.GetBuffer(), mPrompt, _retval, persistPassword); + return rv; +} + +NS_IMETHODIMP +nsSingleSignOnPrompt::Select(const PRUnichar *dialogTitle, const PRUnichar *text, PRUint32 count, + const PRUnichar **selectList, PRInt32 *outSelection, PRBool *_retval) +{ + return mPrompt->Select(dialogTitle, text, count, selectList, outSelection, _retval); +} + +NS_IMETHODIMP +nsSingleSignOnPrompt::UniversalDialog(const PRUnichar *titleMessage, const PRUnichar *dialogTitle, + const PRUnichar *text, const PRUnichar *checkboxMsg, const PRUnichar *button0Text, + const PRUnichar *button1Text, const PRUnichar *button2Text, + const PRUnichar *button3Text, const PRUnichar *editfield1Msg, + const PRUnichar *editfield2Msg, PRUnichar **editfield1Value, + PRUnichar **editfield2Value, const PRUnichar *iconURL, + PRBool *checkboxState, PRInt32 numberButtons, PRInt32 numberEditfields, + PRInt32 editField1Password, PRInt32 *buttonPressed) +{ + return mPrompt->UniversalDialog(titleMessage, dialogTitle, text, checkboxMsg, button0Text, button1Text, + button2Text, button3Text, editfield1Msg, editfield2Msg, editfield1Value, + editfield2Value, iconURL, checkboxState, numberButtons, numberEditfields, + editField1Password, buttonPressed); +} + +// nsISingleSignOnPrompt methods: + +NS_IMETHODIMP +nsSingleSignOnPrompt::Init(nsIPrompt* dialogs) +{ + mPrompt = dialogs; + return NS_OK; +} + +NS_METHOD +nsSingleSignOnPrompt::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) +{ + if (aOuter) + return NS_ERROR_NO_AGGREGATION; + + nsSingleSignOnPrompt* prompt = new nsSingleSignOnPrompt(); + if (prompt == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(prompt); + nsresult rv = prompt->QueryInterface(aIID, aResult); + NS_RELEASE(prompt); + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/extensions/wallet/src/nsWalletService.h b/extensions/wallet/src/nsWalletService.h index 9b91171035ea..654bb90b32ee 100644 --- a/extensions/wallet/src/nsWalletService.h +++ b/extensions/wallet/src/nsWalletService.h @@ -29,6 +29,7 @@ #include "nsIDocumentLoaderObserver.h" #include "nsWeakReference.h" #include "nsIPasswordSink.h" +#include "nsIPrompt.h" #include "nsIDOMWindow.h" #include "nsIURI.h" @@ -41,54 +42,17 @@ class nsWalletlibService : public nsIWalletService, public: NS_DECL_ISUPPORTS + NS_DECL_NSIWALLETSERVICE + NS_DECL_NSIOBSERVER + NS_DECL_NSIDOCUMENTLOADEROBSERVER + NS_DECL_NSIPASSWORDSINK + // NS_DECL_NSSUPPORTSWEAKREFERENCE + nsWalletlibService(); - /* Implementation of the nsIWalletService interface */ - - NS_IMETHOD WALLET_PreEdit(nsAutoString& walletList); - NS_IMETHOD WALLET_PostEdit(nsAutoString walletList); - NS_IMETHOD WALLET_ChangePassword(); - NS_IMETHOD WALLET_ReencryptAll(); - NS_IMETHOD WALLET_RequestToCapture(nsIPresShell* shell); - NS_IMETHOD WALLET_Prefill(nsIPresShell* shell, PRBool quick); - NS_IMETHOD WALLET_PrefillReturn(nsAutoString results); - NS_IMETHOD WALLET_FetchFromNetCenter(); - NS_IMETHOD WALLET_ExpirePassword(); - - NS_IMETHOD PromptUsernameAndPasswordURL - (const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, - const char *urlname, PRBool stripUrl, nsIPrompt* dialog, PRBool *_retval); - NS_IMETHOD PromptPasswordURL - (const PRUnichar *text, PRUnichar **pwd, const char *urlname, PRBool stripUrl, nsIPrompt* dialog, PRBool *_retval); - NS_IMETHOD PromptURL - (const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **result, - const char *urlname, PRBool stripUrl, nsIPrompt* dialog, PRBool *_retval); - - NS_IMETHOD SI_RemoveUser(const char *URLName, PRBool stripUrl, const PRUnichar *userName); - NS_IMETHOD SI_StorePassword(const char *URLName, PRBool stripUrl, const PRUnichar *userName, const PRUnichar *password); - - NS_IMETHOD HaveData(const char *url, const PRUnichar *userName, PRBool stripUrl, PRBool *_retval); - - NS_IMETHOD WALLET_GetNopreviewListForViewer(nsAutoString& aNopreviewList); - NS_IMETHOD WALLET_GetNocaptureListForViewer(nsAutoString& aNocaptureList); - NS_IMETHOD WALLET_GetPrefillListForViewer(nsAutoString& aPrefillList); - NS_IMETHOD SI_GetSignonListForViewer(nsAutoString& aSignonList); - NS_IMETHOD SI_GetRejectListForViewer(nsAutoString& aRejectList); - NS_IMETHOD SI_SignonViewerReturn(nsAutoString results); - - NS_IMETHOD WALLET_Encrypt (const PRUnichar *text, char **crypt); - NS_IMETHOD WALLET_Decrypt (const char *crypt, PRUnichar **text); - - // nsIObserver - NS_DECL_NSIOBSERVER + // NS_DECL_NSIFORMSUBMITOBSERVER NS_IMETHOD Notify(nsIContent* formNode, nsIDOMWindow* window, nsIURI* actionURL); - - // nsIDocumentLoaderObserver - NS_DECL_NSIDOCUMENTLOADEROBSERVER - - // nsIPasswordSink - NS_DECL_NSIPASSWORDSINK - + protected: virtual ~nsWalletlibService(); @@ -96,5 +60,25 @@ private: void Init(); }; +//////////////////////////////////////////////////////////////////////////////// + +class nsSingleSignOnPrompt : public nsISingleSignOnPrompt +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIPROMPT + NS_DECL_NSISINGLESIGNONPROMPT + + nsSingleSignOnPrompt() { NS_INIT_REFCNT(); } + virtual ~nsSingleSignOnPrompt() {} + + static NS_METHOD + Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); + +protected: + nsCOMPtr mPrompt; +}; + +//////////////////////////////////////////////////////////////////////////////// #endif /* nsWalletService_h___ */ diff --git a/extensions/wallet/src/singsign.cpp b/extensions/wallet/src/singsign.cpp index b9e361b47f54..178de784eeae 100644 --- a/extensions/wallet/src/singsign.cpp +++ b/extensions/wallet/src/singsign.cpp @@ -559,24 +559,24 @@ Local_SACopy(char **destination, const char *source) { const char* empty = "empty"; PRIVATE char* -si_StrippedURL (const char* URLName) { +si_StrippedURL (const char* passwordRealm) { char *result = 0; char *s, *t; - /* check for null URLName */ - if (URLName == NULL || PL_strlen(URLName) == 0) { + /* check for null passwordRealm */ + if (passwordRealm == NULL || PL_strlen(passwordRealm) == 0) { return NULL; } /* remove protocol */ - s = (char*) PL_strchr(URLName +1, '/'); + s = (char*) PL_strchr(passwordRealm +1, '/'); if (s && *s == '/' && *(s+1) == '/') { s += 2; } if (s) { StrAllocCopy(result, s); } else { - StrAllocCopy(result, URLName); + StrAllocCopy(result, passwordRealm); } /* remove everything after hostname */ @@ -709,8 +709,8 @@ public: class si_SignonURLStruct { public: - si_SignonURLStruct() : URLName(NULL), chosen_user(NULL), signonUser_list(NULL) {} - char * URLName; + si_SignonURLStruct() : passwordRealm(NULL), chosen_user(NULL), signonUser_list(NULL) {} + char * passwordRealm; si_SignonUserStruct* chosen_user; /* this is a state variable */ nsVoidArray * signonUser_list; }; @@ -718,8 +718,8 @@ public: class si_Reject { public: - si_Reject() : URLName(NULL) {} - char * URLName; + si_Reject() : passwordRealm(NULL) {} + char * passwordRealm; nsAutoString userName; }; @@ -734,14 +734,14 @@ public: //} si_SignonUserStruct; //typedef struct _SignonURLStruct { -// char * URLName; +// char * passwordRealm; // si_SignonUserStruct* chosen_user; /* this is a state variable */ // nsVoidArray * signonUser_list; //} si_SignonURLStruct; //typedef struct _RejectStruct { -// char * URLName; +// char * passwordRealm; // nsAutoString userName; //} si_Reject; @@ -756,29 +756,30 @@ PRIVATE PRBool si_signon_list_changed = PR_FALSE; * This routine is called only when holding the signon lock!!! */ PRIVATE si_SignonURLStruct * -si_GetURL(const char * URLName) { +si_GetURL(const char * passwordRealm) { si_SignonURLStruct * url; - char *strippedURLName = 0; - if (!URLName) { - /* no URLName specified, return first URL (returns NULL if not URLs) */ + char *strippedRealm = 0; + if (!passwordRealm) { + /* no passwordRealm specified, return first URL (returns NULL if not URLs) */ if (LIST_COUNT(si_signon_list)==0) { return NULL; } return (si_SignonURLStruct *) (si_signon_list->ElementAt(0)); } - strippedURLName = si_StrippedURL(URLName); + strippedRealm = si_StrippedURL(passwordRealm); PRInt32 urlCount = LIST_COUNT(si_signon_list); for (PRInt32 i=0; iElementAt(i)); - if(url->URLName && !PL_strcmp(strippedURLName, url->URLName)) { - PR_Free(strippedURLName); + if(url->passwordRealm && !PL_strcmp(strippedRealm, url->passwordRealm)) { + PR_Free(strippedRealm); return url; } } - PR_Free(strippedURLName); + PR_Free(strippedRealm); return (NULL); } +#if 0 static nsresult MangleUrl(const char *url, char **result) { if (!url || !result) return NS_ERROR_FAILURE; @@ -799,11 +800,11 @@ static nsresult MangleUrl(const char *url, char **result) #endif return NS_OK; } +#endif /* Remove a user node from a given URL node */ PRIVATE PRBool -si_RemoveUser(const char *URLName, nsAutoString userName, PRBool save, PRBool strip) { - nsresult res; +si_RemoveUser(const char *passwordRealm, nsAutoString userName, PRBool save) { si_SignonURLStruct * url; si_SignonUserStruct * user; si_SignonDataStruct * data; @@ -813,13 +814,15 @@ si_RemoveUser(const char *URLName, nsAutoString userName, PRBool save, PRBool st return PR_FALSE; } - /* convert URLName to a uri so we can parse out the username and hostname */ +#if 0 + nsresult res; + /* convert passwordRealm to a uri so we can parse out the username and hostname */ nsXPIDLCString host; if (strip) { - if (URLName) { + if (passwordRealm) { nsCOMPtr uri; nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, NS_GET_IID(nsIURL), (void **) getter_AddRefs(uri)); - res = uri->SetSpec(URLName); + res = uri->SetSpec(passwordRealm); if (NS_FAILED(res)) return PR_FALSE; /* uri is of the form ://:@:/) */ @@ -847,14 +850,15 @@ si_RemoveUser(const char *URLName, nsAutoString userName, PRBool save, PRBool st } } } else { - res = MangleUrl(URLName, getter_Copies(host)); + res = MangleUrl(passwordRealm, getter_Copies(host)); if (NS_FAILED(res)) return PR_FALSE; } +#endif si_lock_signon_list(); /* get URL corresponding to host */ - url = si_GetURL((const char *)host); + url = si_GetURL(passwordRealm); if (!url) { /* URL not found */ si_unlock_signon_list(); @@ -894,7 +898,7 @@ si_RemoveUser(const char *URLName, nsAutoString userName, PRBool save, PRBool st /* remove this URL if it contains no more users */ if (LIST_COUNT(url->signonUser_list) == 0) { - PR_Free(url->URLName); + PR_Free(url->passwordRealm); si_signon_list->RemoveElement(url); } @@ -909,14 +913,14 @@ si_RemoveUser(const char *URLName, nsAutoString userName, PRBool save, PRBool st } PUBLIC PRBool -SINGSIGN_RemoveUser(const char *URLName, const PRUnichar *userName, PRBool strip) { - return si_RemoveUser(URLName, nsAutoString(userName), PR_TRUE, strip); +SINGSIGN_RemoveUser(const char *passwordRealm, const PRUnichar *userName) { + return si_RemoveUser(passwordRealm, nsAutoString(userName), PR_TRUE); } /* Determine if a specified url/user exists */ PRIVATE PRBool -si_CheckForUser(char *URLName, nsAutoString userName) { +si_CheckForUser(char *passwordRealm, nsAutoString userName) { si_SignonURLStruct * url; si_SignonUserStruct * user; si_SignonDataStruct * data; @@ -928,8 +932,8 @@ si_CheckForUser(char *URLName, nsAutoString userName) { si_lock_signon_list(); - /* get URL corresponding to URLName */ - url = si_GetURL(URLName); + /* get URL corresponding to passwordRealm */ + url = si_GetURL(passwordRealm); if (!url) { /* URL not found */ si_unlock_signon_list(); @@ -961,13 +965,13 @@ si_CheckForUser(char *URLName, nsAutoString userName) { * This routine is called only if signon pref is enabled!!! */ PRIVATE si_SignonUserStruct* -si_GetUser(const char* URLName, PRBool pickFirstUser, nsAutoString userText) { +si_GetUser(const char* passwordRealm, PRBool pickFirstUser, nsAutoString userText) { si_SignonURLStruct* url; si_SignonUserStruct* user = nsnull; si_SignonDataStruct* data; /* get to node for this URL */ - url = si_GetURL(URLName); + url = si_GetURL(passwordRealm); if (url != NULL) { /* node for this URL was found */ @@ -1068,7 +1072,7 @@ si_GetUser(const char* URLName, PRBool pickFirstUser, nsAutoString userText) { */ #ifdef junk - NET_RemoveURLFromCache(NET_CreateURLStruct((char *)URLName, NET_DONT_RELOAD)); + NET_RemoveURLFromCache(NET_CreateURLStruct((char *)passwordRealm, NET_DONT_RELOAD)); #endif } @@ -1086,13 +1090,13 @@ si_GetUser(const char* URLName, PRBool pickFirstUser, nsAutoString userText) { * This routine is called only if signon pref is enabled!!! */ PRIVATE si_SignonUserStruct* -si_GetSpecificUser(const char* URLName, nsAutoString userName, nsAutoString userText) { +si_GetSpecificUser(const char* passwordRealm, nsAutoString userName, nsAutoString userText) { si_SignonURLStruct* url; si_SignonUserStruct* user; si_SignonDataStruct* data; /* get to node for this URL */ - url = si_GetURL(URLName); + url = si_GetURL(passwordRealm); if (url != NULL) { /* step through set of user nodes for this URL looking for specified username */ @@ -1118,7 +1122,7 @@ si_GetSpecificUser(const char* URLName, nsAutoString userName, nsAutoString user */ #ifdef junk - NET_RemoveURLFromCache(NET_CreateURLStruct((char *)URLName, NET_DONT_RELOAD)); + NET_RemoveURLFromCache(NET_CreateURLStruct((char *)passwordRealm, NET_DONT_RELOAD)); #endif } @@ -1186,7 +1190,7 @@ si_GetURLAndUserForChangeForm(nsAutoString password) nsAutoString userName; if (NS_SUCCEEDED(si_Decrypt (data->value, userName))) { - nsAutoString temp; temp.AssignWithConversion(url->URLName); + nsAutoString temp; temp.AssignWithConversion(url->passwordRealm); temp.AppendWithConversion(":"); temp.Append(userName); @@ -1242,7 +1246,7 @@ PUBLIC void SI_RemoveAllSignonData() { if (si_PartiallyLoaded) { /* repeatedly remove first user node of first URL node */ - while (si_RemoveUser(NULL, nsAutoString(), PR_FALSE, PR_TRUE)) { + while (si_RemoveUser(NULL, nsAutoString(), PR_FALSE)) { } } si_PartiallyLoaded = PR_FALSE; @@ -1273,12 +1277,12 @@ si_FreeReject(si_Reject * reject) { return; } si_reject_list->RemoveElement(reject); - PR_FREEIF(reject->URLName); + PR_FREEIF(reject->passwordRealm); PR_Free(reject); } PRIVATE PRBool -si_CheckForReject(char * URLName, nsAutoString userName) { +si_CheckForReject(char * passwordRealm, nsAutoString userName) { si_Reject * reject; si_lock_signon_list(); @@ -1286,9 +1290,9 @@ si_CheckForReject(char * URLName, nsAutoString userName) { PRInt32 rejectCount = LIST_COUNT(si_reject_list); for (PRInt32 i=0; iElementAt(i)); - if(!PL_strcmp(URLName, reject->URLName)) { + if(!PL_strcmp(passwordRealm, reject->passwordRealm)) { // No need for username check on a rejectlist entry. URL check is sufficient -// if(!PL_strcmp(userName, reject->userName) && !PL_strcmp(URLName, reject->URLName)) { +// if(!PL_strcmp(userName, reject->userName) && !PL_strcmp(passwordRealm, reject->passwordRealm)) { si_unlock_signon_list(); return PR_TRUE; } @@ -1299,8 +1303,8 @@ si_CheckForReject(char * URLName, nsAutoString userName) { } PRIVATE void -si_PutReject(char * URLName, nsAutoString userName, PRBool save) { - char * URLName2=NULL; +si_PutReject(char * passwordRealm, nsAutoString userName, PRBool save) { + char * passwordRealm2=NULL; nsAutoString userName2; si_Reject * reject = new si_Reject; @@ -1318,15 +1322,15 @@ si_PutReject(char * URLName, nsAutoString userName, PRBool save) { si_lock_signon_list(); } - StrAllocCopy(URLName2, URLName); + StrAllocCopy(passwordRealm2, passwordRealm); userName2 = userName; - reject->URLName = URLName2; + reject->passwordRealm = passwordRealm2; reject->userName = userName2; if(!si_reject_list) { si_reject_list = new nsVoidArray(); if(!si_reject_list) { - PR_Free(reject->URLName); + PR_Free(reject->passwordRealm); PR_Free(reject); if (save) { si_unlock_signon_list(); @@ -1342,7 +1346,7 @@ si_PutReject(char * URLName, nsAutoString userName, PRBool save) { for (PRInt32 i = 0; iElementAt(i)); if (tmp_reject) { - if (PL_strcasecmp(reject->URLName, tmp_reject->URLName)<0) { + if (PL_strcasecmp(reject->passwordRealm, tmp_reject->passwordRealm)<0) { si_reject_list->InsertElementAt(reject, i); rejectAdded = PR_TRUE; break; @@ -1375,7 +1379,7 @@ si_PutReject(char * URLName, nsAutoString userName, PRBool save) { * This routine is called only if signon pref is enabled!!! */ PRIVATE void -si_PutData(const char * URLName, nsVoidArray * signonData, PRBool save) { +si_PutData(const char * passwordRealm, nsVoidArray * signonData, PRBool save) { PRBool added_to_list = PR_FALSE; si_SignonURLStruct * url; si_SignonUserStruct * user; @@ -1417,7 +1421,7 @@ si_PutData(const char * URLName, nsVoidArray * signonData, PRBool save) { } /* find node in signon list having the same URL */ - if ((url = si_GetURL(URLName)) == NULL) { + if ((url = si_GetURL(passwordRealm)) == NULL) { /* doesn't exist so allocate new node to be put into signon list */ url = new si_SignonURLStruct; @@ -1429,8 +1433,8 @@ si_PutData(const char * URLName, nsVoidArray * signonData, PRBool save) { } /* fill in fields of new node */ - url->URLName = si_StrippedURL(URLName); - if (!url->URLName) { + url->passwordRealm = si_StrippedURL(passwordRealm); + if (!url->passwordRealm) { PR_Free(url); if (save) { si_unlock_signon_list(); @@ -1440,7 +1444,7 @@ si_PutData(const char * URLName, nsVoidArray * signonData, PRBool save) { url->signonUser_list = new nsVoidArray(); if(!url->signonUser_list) { - PR_Free(url->URLName); + PR_Free(url->passwordRealm); PR_Free(url); } @@ -1453,7 +1457,7 @@ si_PutData(const char * URLName, nsVoidArray * signonData, PRBool save) { for (PRInt32 ii = 0; iiElementAt(ii)); if (tmp_URL) { - if (PL_strcasecmp(url->URLName, tmp_URL->URLName)<0) { + if (PL_strcasecmp(url->passwordRealm, tmp_URL->passwordRealm)<0) { si_signon_list->InsertElementAt(url, ii); added_to_list = PR_TRUE; break; @@ -1666,7 +1670,7 @@ si_ReadLine */ PUBLIC int SI_LoadSignonData() { - char * URLName; + char * passwordRealm; nsAutoString buffer; PRBool badInput = PR_FALSE; @@ -1710,15 +1714,15 @@ SI_LoadSignonData() { break; /* end of reject list */ } si_StripLF(buffer); - URLName = buffer.ToNewCString(); - si_PutReject(URLName, buffer, PR_FALSE); /* middle parameter is obsolete */ - Recycle (URLName); + passwordRealm = buffer.ToNewCString(); + si_PutReject(passwordRealm, buffer, PR_FALSE); /* middle parameter is obsolete */ + Recycle (passwordRealm); } /* read the URL line */ while(!NS_FAILED(si_ReadLine(strm, buffer))) { si_StripLF(buffer); - URLName = buffer.ToNewCString(); + passwordRealm = buffer.ToNewCString(); /* prepare to read the name/value pairs */ badInput = PR_FALSE; @@ -1767,15 +1771,15 @@ SI_LoadSignonData() { } /* store the info for this URL into memory-resident data structure */ - if (!URLName || PL_strlen(URLName) == 0) { + if (!passwordRealm || PL_strlen(passwordRealm) == 0) { badInput = PR_TRUE; } if (!badInput) { - si_PutData(URLName, signonData, PR_FALSE); + si_PutData(passwordRealm, signonData, PR_FALSE); } /* free up all the allocations done for processing this URL */ - Recycle(URLName); + Recycle(passwordRealm); if (badInput) { si_unlock_signon_list(); return -1; @@ -1852,9 +1856,9 @@ si_SaveSignonDataLocked() { si_WriteLine(strm, NS_ConvertToString(HEADER_VERSION)); /* format for next part of file shall be: - * URLName -- first url/username on reject list + * passwordRealm -- first url/username on reject list * userName - * URLName -- second url/username on reject list + * passwordRealm -- second url/username on reject list * userName * ... -- etc. * . -- end of list @@ -1865,7 +1869,7 @@ si_SaveSignonDataLocked() { PRInt32 rejectCount = LIST_COUNT(si_reject_list); for (PRInt32 i=0; iElementAt(i)); - si_WriteLine(strm, NS_ConvertToString(reject->URLName)); + si_WriteLine(strm, NS_ConvertToString(reject->passwordRealm)); } } si_WriteLine(strm, NS_ConvertToString(".")); @@ -1886,7 +1890,7 @@ si_SaveSignonDataLocked() { for (PRInt32 i3=0; i3signonUser_list->ElementAt(i3)); si_WriteLine - (strm, NS_ConvertToString(url->URLName)); + (strm, NS_ConvertToString(url->passwordRealm)); /* write out each data node of the user node */ PRInt32 dataCount = LIST_COUNT(user->signonData_list); @@ -1915,11 +1919,11 @@ si_SaveSignonDataLocked() { /* Ask user if it is ok to save the signon data */ PRIVATE PRBool -si_OkToSave(char *URLName, nsAutoString userName) { - char *strippedURLName = 0; +si_OkToSave(char *passwordRealm, nsAutoString userName) { + char *strippedRealm = 0; /* if url/user already exists, then it is safe to save it again */ - if (si_CheckForUser(URLName, userName)) { + if (si_CheckForUser(passwordRealm, userName)) { return PR_TRUE; } @@ -1937,19 +1941,19 @@ si_OkToSave(char *URLName, nsAutoString userName) { } #endif - strippedURLName = si_StrippedURL(URLName); - if (si_CheckForReject(strippedURLName, userName)) { - PR_Free(strippedURLName); + strippedRealm = si_StrippedURL(passwordRealm); + if (si_CheckForReject(strippedRealm, userName)) { + PR_Free(strippedRealm); return PR_FALSE; } PRUnichar * message = Wallet_Localize("WantToSavePassword?"); PRInt32 button = si_3ButtonConfirm(message); if (button == NEVER_BUTTON) { - si_PutReject(strippedURLName, userName, PR_TRUE); + si_PutReject(strippedRealm, userName, PR_TRUE); } Recycle(message); - PR_Free(strippedURLName); + PR_Free(strippedRealm); return (button == YES_BUTTON); } @@ -1957,7 +1961,7 @@ si_OkToSave(char *URLName, nsAutoString userName) { * Check for a signon submission and remember the data if so */ PUBLIC void -SINGSIGN_RememberSignonData (char* URLName, nsVoidArray * signonData) +SINGSIGN_RememberSignonData (char* passwordRealm, nsVoidArray * signonData) { int passwordCount = 0; int pswd[3]; @@ -1998,7 +2002,7 @@ SINGSIGN_RememberSignonData (char* URLName, nsVoidArray * signonData) if (jCount()) { data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(j)); - if (si_OkToSave(URLName, data2->value)) { + if (si_OkToSave(passwordRealm, data2->value)) { for (j=0; jCount(); j++) { data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(j)); nsAutoString value = data2->value; @@ -2006,7 +2010,7 @@ SINGSIGN_RememberSignonData (char* URLName, nsVoidArray * signonData) return; } } - si_PutData(URLName, signonData, PR_TRUE); + si_PutData(passwordRealm, signonData, PR_TRUE); } } } else if (passwordCount == 2) { @@ -2068,7 +2072,7 @@ SINGSIGN_RememberSignonData (char* URLName, nsVoidArray * signonData) } PUBLIC void -SINGSIGN_RestoreSignonData (char* URLName, PRUnichar* name, PRUnichar** value, PRUint32 elementNumber) { +SINGSIGN_RestoreSignonData (char* passwordRealm, PRUnichar* name, PRUnichar** value, PRUint32 elementNumber) { si_SignonUserStruct* user; si_SignonDataStruct* data; nsAutoString correctedName; @@ -2101,7 +2105,7 @@ SINGSIGN_RestoreSignonData (char* URLName, PRUnichar* name, PRUnichar** value, P /* determine if name has been saved (avoids unlocking the database if not) */ PRBool nameFound = PR_FALSE; - user = si_GetUser(URLName, PR_FALSE, correctedName); + user = si_GetUser(passwordRealm, PR_FALSE, correctedName); if (user) { PRInt32 dataCount = LIST_COUNT(user->signonData_list); for (PRInt32 i=0; isignonData_list->ElementAt(0)); /* 1st item on form */ if(data->isPassword && correctedName.Length() && (data->name == correctedName)) { /* current item is first item on form and is a password */ - user = (URLName, MK_SIGNON_PASSWORDS_FETCH); + user = (passwordRealm, MK_SIGNON_PASSWORDS_FETCH); if (user) { /* user has confirmed it's a change-of-password form */ PRInt32 dataCount = LIST_COUNT(user->signonData_list); @@ -2152,7 +2156,7 @@ SINGSIGN_RestoreSignonData (char* URLName, PRUnichar* name, PRUnichar** value, P /* restore the data from previous time this URL was visited */ - user = si_GetUser(URLName, PR_FALSE, correctedName); + user = si_GetUser(passwordRealm, PR_FALSE, correctedName); if (user) { PRInt32 dataCount = LIST_COUNT(user->signonData_list); for (PRInt32 i=0; iAppendElement(data2); /* Save the signon data */ - si_PutData(URLName, signonData, PR_TRUE); + si_PutData(passwordRealm, signonData, PR_TRUE); /* Deallocate */ delete data1; @@ -2211,16 +2215,16 @@ si_RememberSignonDataFromBrowser(const char* URLName, nsAutoString username, nsA */ PRIVATE void si_RestoreOldSignonDataFromBrowser - (const char* URLName, PRBool pickFirstUser, nsAutoString& username, nsAutoString& password) { + (const char* passwordRealm, PRBool pickFirstUser, nsAutoString& username, nsAutoString& password) { si_SignonUserStruct* user; si_SignonDataStruct* data; /* get the data from previous time this URL was visited */ si_lock_signon_list(); if (username.Length() != 0) { - user = si_GetSpecificUser(URLName, username, NS_ConvertToString(USERNAMEFIELD)); + user = si_GetSpecificUser(passwordRealm, username, NS_ConvertToString(USERNAMEFIELD)); } else { - user = si_GetUser(URLName, pickFirstUser, NS_ConvertToString(USERNAMEFIELD)); + user = si_GetUser(passwordRealm, pickFirstUser, NS_ConvertToString(USERNAMEFIELD)); } if (!user) { /* leave original username and password from caller unchanged */ @@ -2247,18 +2251,19 @@ si_RestoreOldSignonDataFromBrowser } PUBLIC PRBool -SINGSIGN_StorePassword(const char *URLName, const PRUnichar *user, const PRUnichar *password, PRBool strip) { - nsresult res; - +SINGSIGN_StorePassword(const char *passwordRealm, const PRUnichar *user, const PRUnichar *password) { nsAutoString userName(user); - /* convert URLName to a uri so we can parse out the username and hostname */ +#if 0 + nsresult res; + + /* convert passwordRealm to a uri so we can parse out the username and hostname */ nsXPIDLCString host; if (strip) { - if (URLName) { + if (passwordRealm) { nsCOMPtr uri; nsComponentManager::CreateInstance(kStandardUrlCID, nsnull, NS_GET_IID(nsIURL), (void **) getter_AddRefs(uri)); - res = uri->SetSpec(URLName); + res = uri->SetSpec(passwordRealm); if (NS_FAILED(res)) return PR_FALSE; /* uri is of the form ://:@:/) */ @@ -2286,11 +2291,12 @@ SINGSIGN_StorePassword(const char *URLName, const PRUnichar *user, const PRUnich } } } else { - res = MangleUrl(URLName, getter_Copies(host)); + res = MangleUrl(passwordRealm, getter_Copies(host)); if (NS_FAILED(res)) return PR_FALSE; } +#endif - si_RememberSignonDataFromBrowser ((const char *)host, userName, nsAutoString(password)); + si_RememberSignonDataFromBrowser(passwordRealm, userName, nsAutoString(password)); return PR_TRUE; } @@ -2310,20 +2316,23 @@ SINGSIGN_StorePassword(const char *URLName, const PRUnichar *user, const PRUnich PUBLIC nsresult SINGSIGN_PromptUsernameAndPassword - (const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, - const char *urlname, nsIPrompt* dialog, PRBool *pressedOK, PRBool strip) { + (const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, + const char *passwordRealm, nsIPrompt* dialog, PRBool *pressedOK, PRBool persistPassword) { nsresult res; /* do only the dialog if signon preference is not enabled */ if (!si_GetSignonRememberingPref()){ - return dialog->PromptUsernameAndPassword(text, user, pwd, pressedOK); + nsString realm = NS_ConvertToString(passwordRealm); // XXX hack + return dialog->PromptUsernameAndPassword(dialogTitle, text, realm.GetUnicode(), + 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(urlname); + res = uri->SetSpec(passwordRealm); if (NS_FAILED(res)) { return res; } @@ -2338,15 +2347,16 @@ SINGSIGN_PromptUsernameAndPassword return res; } } else { - res = MangleUrl(urlname, getter_Copies(host)); + 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((const char*)host, PR_FALSE, username, password); + si_RestoreOldSignonDataFromBrowser(passwordRealm, PR_FALSE, username, password); /* get new username/password from user */ *user = username.ToNewUnicode(); @@ -2361,7 +2371,7 @@ SINGSIGN_PromptUsernameAndPassword return NS_OK; } if (checked) { - si_RememberSignonDataFromBrowser ((const char*)host, nsAutoString(*user), nsAutoString(*pwd)); + si_RememberSignonDataFromBrowser (passwordRealm, nsAutoString(*user), nsAutoString(*pwd)); } /* cleanup and return */ @@ -2371,8 +2381,8 @@ SINGSIGN_PromptUsernameAndPassword PUBLIC nsresult SINGSIGN_PromptPassword - (const PRUnichar *text, PRUnichar **pwd, const char *urlname, - nsIPrompt* dialog, PRBool *pressedOK, PRBool strip) + (const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **pwd, const char *passwordRealm, + nsIPrompt* dialog, PRBool *pressedOK, PRBool persistPassword) { nsresult res; @@ -2381,15 +2391,19 @@ SINGSIGN_PromptPassword /* do only the dialog if signon preference is not enabled */ if (!si_GetSignonRememberingPref()){ PRUnichar * prompt_string = Wallet_Localize("PromptForPassword"); - res = dialog->PromptPassword(text, prompt_string, pwd, pressedOK); + nsString realm = NS_ConvertToString(passwordRealm); // XXX hack + res = dialog->PromptPassword(prompt_string, + text, realm.GetUnicode(), persistPassword, + pwd, pressedOK); Recycle(prompt_string); 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(urlname); + res = uri->SetSpec(passwordRealm); if (NS_FAILED(res)) { return res; } @@ -2404,7 +2418,7 @@ SINGSIGN_PromptPassword return res; } } else { - res = MangleUrl(urlname, getter_Copies(host)); + res = MangleUrl(passwordRealm, getter_Copies(host)); if (NS_FAILED(res)) { return res; } @@ -2425,9 +2439,10 @@ SINGSIGN_PromptPassword prehost.Left(username, colon); } } +#endif /* get previous password used with this username, pick first user if no username found */ - si_RestoreOldSignonDataFromBrowser((const char *)host, (username.Length() == 0), username, password); + si_RestoreOldSignonDataFromBrowser(passwordRealm, (username.Length() == 0), username, password); /* return if a password was found */ if (password.Length() != 0) { @@ -2447,7 +2462,7 @@ SINGSIGN_PromptPassword return NS_OK; } if (checked) { - si_RememberSignonDataFromBrowser ((const char *)host, username, nsAutoString(*pwd)); + si_RememberSignonDataFromBrowser(passwordRealm, username, nsAutoString(*pwd)); } /* cleanup and return */ @@ -2457,8 +2472,8 @@ SINGSIGN_PromptPassword PUBLIC nsresult SINGSIGN_Prompt - (const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **resultText, - const char *urlname, nsIPrompt* dialog, PRBool *pressedOK, PRBool strip) + (const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **resultText, + const char *passwordRealm, nsIPrompt* dialog, PRBool *pressedOK) { nsresult res; nsAutoString data, emptyUsername; @@ -2466,15 +2481,17 @@ SINGSIGN_Prompt /* do only the dialog if signon preference is not enabled */ if (!si_GetSignonRememberingPref()){ PRUnichar * prompt_string = Wallet_Localize("PromptForData"); - res = dialog->Prompt(text, prompt_string, resultText, pressedOK); + nsString realm = NS_ConvertToString(passwordRealm); // XXX hack + res = dialog->Prompt(dialogTitle, text, realm.GetUnicode(), prompt_string, resultText, pressedOK); Recycle(prompt_string); 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(urlname); + res = uri->SetSpec(passwordRealm); if (NS_FAILED(res)) { return res; } @@ -2487,14 +2504,15 @@ SINGSIGN_Prompt return res; } } else { - res = MangleUrl(urlname, getter_Copies(host)); + res = MangleUrl(passwordRealm, getter_Copies(host)); if (NS_FAILED(res)) { return res; } } +#endif /* get previous data used with this hostname */ - si_RestoreOldSignonDataFromBrowser((const char *)host, PR_TRUE, emptyUsername, data); + si_RestoreOldSignonDataFromBrowser(passwordRealm, PR_TRUE, emptyUsername, data); /* return if data was found */ if (data.Length() != 0) { @@ -2514,7 +2532,7 @@ SINGSIGN_Prompt return NS_OK; } if (checked) { - si_RememberSignonDataFromBrowser ((const char *)host, emptyUsername, nsAutoString(*resultText)); + si_RememberSignonDataFromBrowser(passwordRealm, emptyUsername, nsAutoString(*resultText)); } /* cleanup and return */ @@ -2606,7 +2624,7 @@ SINGSIGN_SignonViewerReturn (nsAutoString results) { /* do the deletion */ nsAutoString userName; if (NS_SUCCEEDED(si_Decrypt(data->value, userName))) { - si_RemoveUser(url->URLName, userName, PR_TRUE, PR_TRUE); + si_RemoveUser(url->passwordRealm, userName, PR_TRUE); si_signon_list_changed = PR_TRUE; } } @@ -2669,7 +2687,7 @@ SINGSIGN_GetSignonListForViewer(nsAutoString& aSignonList) buffer.AppendWithConversion("\n"); @@ -2755,9 +2773,8 @@ SINGSIGN_GetRejectListForViewer(nsAutoString& aRejectList) } PUBLIC nsresult -SINGSIGN_HaveData(const char *url, const PRUnichar *userName, PRBool strip, PRBool *retval) +SINGSIGN_HaveData(const char *passwordRealm, const PRUnichar *userName, PRBool *retval) { - nsresult res; nsAutoString data, usernameForLookup; *retval = PR_FALSE; @@ -2766,12 +2783,14 @@ SINGSIGN_HaveData(const char *url, const PRUnichar *userName, PRBool strip, PRBo 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(url); + res = uri->SetSpec(passwordRealm); if (NS_FAILED(res)) return res; /* get host part of the uri */ @@ -2782,18 +2801,19 @@ SINGSIGN_HaveData(const char *url, const PRUnichar *userName, PRBool strip, PRBo return res; } } else { - res = MangleUrl(url, getter_Copies(host)); + res = MangleUrl(passwordRealm, getter_Copies(host)); if (NS_FAILED(res)) return res; } if (strip) { - /* convert url to a uri so we can parse out the username and hostname */ + /* 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((const char *)host, (usernameForLookup.Length() == 0), usernameForLookup, data); + si_RestoreOldSignonDataFromBrowser(passwordRealm, (usernameForLookup.Length() == 0), usernameForLookup, data); if (data.Length()) { *retval = PR_TRUE; @@ -2829,7 +2849,7 @@ si_KeychainCallback( KCEvent keychainEvent, KCCallbackInfo *info, void *userCont */ PRIVATE int si_LoadSignonDataFromKeychain() { - char * URLName; + char * passwordRealm; si_FormSubmitData submit; nsAutoString name_array[MAX_ARRAY_SIZE]; nsAutoString value_array[MAX_ARRAY_SIZE]; @@ -2903,8 +2923,8 @@ si_LoadSignonDataFromKeychain() { /* null terminate */ buffer[actualSize] = 0; - URLName = NULL; - StrAllocCopy(URLName, buffer); + passwordRealm = NULL; + StrAllocCopy(passwordRealm, buffer); if (!reject) { /* get the password data */ status = KCGetData(itemRef, BUFFER_SIZE, buffer, &actualSize); @@ -2963,19 +2983,19 @@ si_LoadSignonDataFromKeychain() { } submit.value_cnt++; /* store the info for this URL into memory-resident data structure */ - if (!URLName || PL_strlen(URLName) == 0) { + if (!passwordRealm || PL_strlen(passwordRealm) == 0) { badInput = PR_TRUE; } if (!badInput) { - si_PutData(URLName, &submit, PR_FALSE); + si_PutData(passwordRealm, &submit, PR_FALSE); } } else { /* reject */ - si_PutReject(URLName, nsAutoString(buffer), PR_FALSE); + si_PutReject(passwordRealm, nsAutoString(buffer), PR_FALSE); } reject = PR_FALSE; /* reset reject flag */ - PR_Free(URLName); + PR_Free(passwordRealm); KCReleaseItemRef( &itemRef ); status = KCFindNextItem( searchRef, &itemRef); } @@ -3032,7 +3052,7 @@ si_SaveSignonDataInKeychain() { for (PRInt32 i=0; iElementAt(i)); status = kcaddinternetpassword - (reject->URLName, nil, + (reject->passwordRealm, nil, reject->userName, kAnyPort, kNetscapeProtocolType, @@ -3101,7 +3121,7 @@ si_SaveSignonDataInKeychain() { } /* if it's already there, we just want to change the password */ status = kcfindinternetpassword - (URL->URLName, + (URL->passwordRealm, nil, account, kAnyPort, @@ -3121,7 +3141,7 @@ si_SaveSignonDataInKeychain() { } else { /* wasn't there, let's add it */ status = kcaddinternetpassword - (URL->URLName, + (URL->passwordRealm, nil, account, kAnyPort, diff --git a/extensions/wallet/src/singsign.h b/extensions/wallet/src/singsign.h index c7ed35419f9c..5c3177e70f12 100644 --- a/extensions/wallet/src/singsign.h +++ b/extensions/wallet/src/singsign.h @@ -44,33 +44,33 @@ extern void SINGSIGN_SignonViewerReturn(nsAutoString results); extern void -SINGSIGN_RestoreSignonData(char* URLName, PRUnichar* name, PRUnichar** value, PRUint32 elementNumber); +SINGSIGN_RestoreSignonData(char* passwordRealm, PRUnichar* name, PRUnichar** value, PRUint32 elementNumber); extern nsresult SINGSIGN_PromptUsernameAndPassword - (const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, - const char *urlname,nsIPrompt* dialog, PRBool *returnValue, PRBool strip); + (const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, + const char* passwordRealm, nsIPrompt* dialog, PRBool *returnValue, PRBool persistPassword = PR_TRUE); extern nsresult SINGSIGN_PromptPassword - (const PRUnichar *text, PRUnichar **pwd, const char *urlname, - nsIPrompt* dialog, PRBool *returnValue, PRBool strip); + (const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **pwd, const char* passwordRealm, + nsIPrompt* dialog, PRBool *returnValue, PRBool persistPassword = PR_TRUE); extern nsresult SINGSIGN_Prompt - (const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **resultText, - const char *urlname,nsIPrompt* dialog, PRBool *returnValue, PRBool strip); + (const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **resultText, + const char* passwordRealm, nsIPrompt* dialog, PRBool *returnValue); extern PRBool SINGSIGN_RemoveUser - (const char *URLName, const PRUnichar *userName, PRBool strip); + (const char* passwordRealm, const PRUnichar *userName); extern PRBool SINGSIGN_StorePassword - (const char *URLName, const PRUnichar *userName, const PRUnichar *password, PRBool strip); + (const char* passwordRealm, const PRUnichar *userName, const PRUnichar *password); extern nsresult -SINGSIGN_HaveData(const char *url, const PRUnichar *userName, PRBool strip, PRBool *retval); +SINGSIGN_HaveData(const char* passwordRealm, const PRUnichar *userName, PRBool *retval); XP_END_PROTOS diff --git a/extensions/wallet/src/wallet.cpp b/extensions/wallet/src/wallet.cpp index a41f15dde30d..d33296608fb0 100644 --- a/extensions/wallet/src/wallet.cpp +++ b/extensions/wallet/src/wallet.cpp @@ -755,7 +755,7 @@ Wallet_Confirm(PRUnichar * szMessage) const nsAutoString message = szMessage; retval = PR_FALSE; /* in case user exits dialog by clicking X */ - res = dialog->Confirm(message.GetUnicode(), &retval); + res = dialog->Confirm(nsnull, message.GetUnicode(), &retval); return retval; } @@ -856,7 +856,7 @@ Wallet_Alert(PRUnichar * szMessage) } const nsAutoString message = szMessage; - res = dialog->Alert(message.GetUnicode()); + res = dialog->Alert(nsnull, message.GetUnicode()); return; // XXX should return the error } diff --git a/mailnews/absync/src/nsAbSync.cpp b/mailnews/absync/src/nsAbSync.cpp index 776053a21e08..cead4ef77475 100644 --- a/mailnews/absync/src/nsAbSync.cpp +++ b/mailnews/absync/src/nsAbSync.cpp @@ -279,7 +279,7 @@ nsAbSync::DisplayErrorMessage(const PRUnichar * msg) NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv); if (NS_FAILED(rv)) return rv; - rv = dialog->Alert(msg); + rv = dialog->Alert(nsnull, msg); return NS_OK; } diff --git a/mailnews/addrbook/src/nsAddbookUrl.h b/mailnews/addrbook/src/nsAddbookUrl.h index 3209b1f63616..ffa8d7e719f7 100644 --- a/mailnews/addrbook/src/nsAddbookUrl.h +++ b/mailnews/addrbook/src/nsAddbookUrl.h @@ -28,7 +28,6 @@ #include "nsIFileSpec.h" #include "nsIMsgIdentity.h" #include "nsCOMPtr.h" -#include "nsINetPrompt.h" #include "nsISmtpServer.h" #include "nsIAddbookUrl.h" #include "nsAbCardProperty.h" diff --git a/mailnews/base/public/nsIMsgIncomingServer.idl b/mailnews/base/public/nsIMsgIncomingServer.idl index 2e4083a378e9..4016e01e53b4 100644 --- a/mailnews/base/public/nsIMsgIncomingServer.idl +++ b/mailnews/base/public/nsIMsgIncomingServer.idl @@ -103,7 +103,7 @@ interface nsIMsgIncomingServer : nsISupports { /* the RDF URI for the root mail folder */ - readonly attribute string serverURI; + readonly attribute string serverPasswordRealm; /* the root folder for this server */ attribute nsIFolder RootFolder; diff --git a/mailnews/base/src/nsMessenger.cpp b/mailnews/base/src/nsMessenger.cpp index 14e3f0d1e1cc..a3e6dceb3a59 100644 --- a/mailnews/base/src/nsMessenger.cpp +++ b/mailnews/base/src/nsMessenger.cpp @@ -989,8 +989,9 @@ nsMessenger::Alert(const char *stringName) { nsCOMPtr dialog(do_GetInterface(mDocShell)); - if (dialog) - rv = dialog->Alert(errorMessage.GetUnicode()); + if (dialog) { + rv = dialog->Alert(nsnull, errorMessage.GetUnicode()); + } } return rv; } diff --git a/mailnews/base/src/nsSubscribableServer.cpp b/mailnews/base/src/nsSubscribableServer.cpp index 64c3ba526940..c31b0d5593b0 100644 --- a/mailnews/base/src/nsSubscribableServer.cpp +++ b/mailnews/base/src/nsSubscribableServer.cpp @@ -75,7 +75,7 @@ nsSubscribableServer::SetAsSubscribedInSubscribeDS(const char *aName) nsXPIDLCString serverUri; - rv = mIncomingServer->GetServerURI(getter_Copies(serverUri)); + rv = mIncomingServer->GetServerPasswordRealm(getter_Copies(serverUri)); if (NS_FAILED(rv)) return rv; nsCAutoString uri; @@ -157,7 +157,7 @@ nsSubscribableServer::AddToSubscribeDS(const char *aName) #endif nsXPIDLCString serverUri; - rv = mIncomingServer->GetServerURI(getter_Copies(serverUri)); + rv = mIncomingServer->GetServerPasswordRealm(getter_Copies(serverUri)); if (NS_FAILED(rv)) return rv; nsCAutoString uri; diff --git a/mailnews/base/util/nsMsgIncomingServer.cpp b/mailnews/base/util/nsMsgIncomingServer.cpp index 70ae90edb910..f1196d78030d 100644 --- a/mailnews/base/util/nsMsgIncomingServer.cpp +++ b/mailnews/base/util/nsMsgIncomingServer.cpp @@ -44,7 +44,7 @@ #include "nsIDocShell.h" #include "nsIWebShell.h" #include "nsIWebShellWindow.h" -#include "nsINetPrompt.h" +#include "nsIPrompt.h" #include "nsIWalletService.h" #include "nsIRDFService.h" @@ -52,6 +52,7 @@ #include "nsAppShellCIDs.h" #include "nsIXULWindow.h" #include "nsRDFCID.h" +#include "nsIInterfaceRequestor.h" #ifdef DEBUG_sspitzer #define DEBUG_MSGINCOMING_SERVER @@ -181,7 +182,7 @@ nsMsgIncomingServer::CloseCachedConnections() // construct ://[@] dialog; + nsCOMPtr dialog; // aMsgWindow is required if we need to prompt if (aMsgWindow) { @@ -617,13 +618,10 @@ nsMsgIncomingServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const nsCOMPtr docShell; rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell)); if (NS_FAILED(rv)) return rv; + nsCOMPtr webShell(do_QueryInterface(docShell, &rv)); if (NS_FAILED(rv)) return rv; - // get top level window - nsCOMPtr topLevelWindow; - rv = webShell->GetTopLevelWindow(getter_AddRefs(topLevelWindow)); - if (NS_FAILED(rv)) return rv; - dialog = do_QueryInterface( topLevelWindow, &rv ); + dialog = do_GetInterface(webShell, &rv); } else { @@ -641,10 +639,12 @@ nsMsgIncomingServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const { nsXPIDLString uniPassword; nsXPIDLCString serverUri; - rv = GetServerURI(getter_Copies(serverUri)); + rv = GetServerPasswordRealm(getter_Copies(serverUri)); if (NS_FAILED(rv)) return rv; - rv = dialog->PromptPassword(serverUri, PR_FALSE, aPromptTitle, aPromptMessage, getter_Copies(uniPassword), okayValue); - if (NS_FAILED(rv)) return rv; + rv = dialog->PromptPassword(aPromptTitle, aPromptMessage, + NS_ConvertToString(serverUri).GetUnicode(), PR_TRUE, + getter_Copies(uniPassword), okayValue); + if (NS_FAILED(rv)) return rv; if (!*okayValue) // if the user pressed cancel, just return NULL; { @@ -677,11 +677,11 @@ nsMsgIncomingServer::StorePassword() if (NS_FAILED(rv)) return rv; nsXPIDLCString serverUri; - rv = GetServerURI(getter_Copies(serverUri)); + rv = GetServerPasswordRealm(getter_Copies(serverUri)); if (NS_FAILED(rv)) return rv; nsAutoString password; password.AssignWithConversion((const char *)pwd); - rv = walletservice->SI_StorePassword((const char *)serverUri, PR_FALSE, nsnull, password.GetUnicode()); + rv = walletservice->SI_StorePassword((const char *)serverUri, nsnull, password.GetUnicode()); return rv; } @@ -694,14 +694,14 @@ nsMsgIncomingServer::ForgetPassword() nsXPIDLCString serverUri; - rv = GetServerURI(getter_Copies(serverUri)); + rv = GetServerPasswordRealm(getter_Copies(serverUri)); if (NS_FAILED(rv)) return rv; rv = SetPassword(""); if (NS_FAILED(rv)) return rv; - rv = walletservice->SI_RemoveUser((const char *)serverUri, PR_FALSE, nsnull); + rv = walletservice->SI_RemoveUser((const char *)serverUri, nsnull); return rv; } diff --git a/mailnews/base/util/nsMsgProtocol.cpp b/mailnews/base/util/nsMsgProtocol.cpp index 2587e8a97ca2..a00d9002f99e 100644 --- a/mailnews/base/util/nsMsgProtocol.cpp +++ b/mailnews/base/util/nsMsgProtocol.cpp @@ -260,7 +260,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *c default: break; } - dialog->Alert(alertMsg.GetUnicode()); + dialog->Alert(nsnull, alertMsg.GetUnicode()); } } diff --git a/mailnews/compose/public/nsISmtpServer.idl b/mailnews/compose/public/nsISmtpServer.idl index 3682c0ea2549..64e9b0a0eb0a 100644 --- a/mailnews/compose/public/nsISmtpServer.idl +++ b/mailnews/compose/public/nsISmtpServer.idl @@ -20,7 +20,7 @@ #include "nsISupports.idl" -interface nsINetPrompt; +interface nsIPrompt; [scriptable, uuid(6a0b35ce-54e4-11d3-81df-006008948010)] interface nsISmtpServer : nsISupports { @@ -38,6 +38,6 @@ interface nsISmtpServer : nsISupports { readonly attribute string serverURI; string getPasswordWithUI(in wstring promptString, in wstring promptTitle, - in nsINetPrompt netPrompt); + in nsIPrompt netPrompt); void forgetPassword(); }; diff --git a/mailnews/compose/public/nsISmtpService.idl b/mailnews/compose/public/nsISmtpService.idl index 9d65dc7ca4e2..150254afe256 100644 --- a/mailnews/compose/public/nsISmtpService.idl +++ b/mailnews/compose/public/nsISmtpService.idl @@ -28,7 +28,7 @@ interface nsIURI; interface nsIUrlListener; interface nsISupportsArray; interface nsIMsgIdentity; -interface nsINetPrompt; +interface nsIPrompt; [scriptable, uuid(FBAF0F10-CA9B-11d2-8063-006008128C4E)] interface nsISmtpService : nsISupports { @@ -55,7 +55,7 @@ interface nsISmtpService : nsISupports { in nsIMsgIdentity aSenderIdentity, in nsIUrlListener aUrlListener, in nsISmtpServer aServer, - in nsINetPrompt aNetPrompt, + in nsIPrompt aNetPrompt, out nsIURI aURL); /** diff --git a/mailnews/compose/public/nsISmtpUrl.idl b/mailnews/compose/public/nsISmtpUrl.idl index 26a92e3bf7f6..3d958d4c21c0 100644 --- a/mailnews/compose/public/nsISmtpUrl.idl +++ b/mailnews/compose/public/nsISmtpUrl.idl @@ -29,7 +29,7 @@ %} interface nsIMsgIdentity; -interface nsINetPrompt; +interface nsIPrompt; interface nsISmtpServer; [scriptable, uuid(16ADF2F1-BBAD-11d2-804E-006008128C4E)] @@ -64,7 +64,7 @@ interface nsISmtpUrl : nsISupports { // NOTE: the SMTP username and SMTP server are in the smtp url // smtp://sspitzer@tintin/... attribute nsIMsgIdentity senderIdentity; - attribute nsINetPrompt netPrompt; + attribute nsIPrompt prompt; attribute nsISmtpServer smtpServer; }; diff --git a/mailnews/compose/src/nsMsgCopy.cpp b/mailnews/compose/src/nsMsgCopy.cpp index 6d14517b3d1a..d63b7c39eeb8 100644 --- a/mailnews/compose/src/nsMsgCopy.cpp +++ b/mailnews/compose/src/nsMsgCopy.cpp @@ -369,7 +369,7 @@ LocateMessageFolder(nsIMsgIdentity *userIdentity, // newsgroup://news.mozilla.org/netscape.test // char *serverURI = nsnull; - rv = inServer->GetServerURI(&serverURI); + rv = inServer->GetServerPasswordRealm(&serverURI); if ( NS_FAILED(rv) || (!serverURI) || !(*serverURI) ) continue; diff --git a/mailnews/compose/src/nsMsgPrompts.cpp b/mailnews/compose/src/nsMsgPrompts.cpp index 1128ba1a68ac..ddd507d9b88d 100644 --- a/mailnews/compose/src/nsMsgPrompts.cpp +++ b/mailnews/compose/src/nsMsgPrompts.cpp @@ -56,7 +56,7 @@ nsMsgDisplayMessageByString(const PRUnichar * msg) NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv); if (NS_FAILED(rv)) return rv; - rv = dialog->Alert(msg); + rv = dialog->Alert(nsnull, msg); return NS_OK; } @@ -90,7 +90,7 @@ nsMsgAskBooleanQuestionByString(const PRUnichar * msg, PRBool *answer) if (dialog) { - rv = dialog->Confirm(msg, &result); + rv = dialog->Confirm(nsnull, msg, &result); if (result == 1) *answer = PR_TRUE; else diff --git a/mailnews/compose/src/nsMsgSend.cpp b/mailnews/compose/src/nsMsgSend.cpp index 063888f65532..0a6757b41693 100644 --- a/mailnews/compose/src/nsMsgSend.cpp +++ b/mailnews/compose/src/nsMsgSend.cpp @@ -66,7 +66,7 @@ #include "nsIMsgMailSession.h" #include "nsTextFormatter.h" #include "nsIWebShell.h" -#include "nsINetPrompt.h" +#include "nsIPrompt.h" #include "nsIAppShellService.h" #include "nsMailHeaders.h" #include "nsIDocShell.h" @@ -2811,13 +2811,11 @@ nsMsgComposeAndSend::DeliverFileAsMail() NS_NewFileSpecWithSpec(*mTempFileSpec, getter_AddRefs(aFileSpec)); // rhp: we don't always have a mDocShell... - nsCOMPtr netPrompt = nsnull; + nsCOMPtr netPrompt; nsCOMPtr webShell(do_QueryInterface(mDocShell)); if (webShell) { - nsCOMPtr topLevelWindow; - rv = webShell->GetTopLevelWindow(getter_AddRefs(topLevelWindow)); - netPrompt = do_QueryInterface(topLevelWindow, &rv); + netPrompt = do_GetInterface(webShell, &rv); } else { @@ -2829,7 +2827,7 @@ nsMsgComposeAndSend::DeliverFileAsMail() appshellservice->GetHiddenWindow(getter_AddRefs(xulWindow)); if (xulWindow) { - netPrompt = do_QueryInterface(xulWindow, &rv); + netPrompt = do_GetInterface(xulWindow, &rv); } } } diff --git a/mailnews/compose/src/nsSmtpProtocol.cpp b/mailnews/compose/src/nsSmtpProtocol.cpp index 333b3fc66f8f..8b2ce9958d4b 100644 --- a/mailnews/compose/src/nsSmtpProtocol.cpp +++ b/mailnews/compose/src/nsSmtpProtocol.cpp @@ -35,7 +35,6 @@ #include "nsString.h" #include "nsTextFormatter.h" #include "nsIMsgIdentity.h" -#include "nsINetPrompt.h" #include "nsISmtpServer.h" #include "nsMsgComposeStringBundle.h" #include "prtime.h" @@ -112,7 +111,7 @@ nsresult nsExplainErrorDetails(int code, ...) } if (msg) { - rv = dialog->Alert(msg); + rv = dialog->Alert(nsnull, msg); nsTextFormatter::smprintf_free(msg); } @@ -1490,8 +1489,8 @@ nsSmtpProtocol::GetPassword(char **aPassword) nsCRT::free(*aPassword); *aPassword = 0; - nsCOMPtr netPrompt; - rv = smtpUrl->GetNetPrompt(getter_AddRefs(netPrompt)); + nsCOMPtr netPrompt; + rv = smtpUrl->GetPrompt(getter_AddRefs(netPrompt)); if (NS_FAILED(rv)) return rv; nsXPIDLCString username; @@ -1605,8 +1604,9 @@ NS_IMETHODIMP nsSmtpProtocol::OnLogonRedirectionError(const PRUnichar *pErrMsg, // step (2) alert the user about the error nsCOMPtr dialog (do_GetService(kCNetSupportDialogCID)); - if (dialog && pErrMsg && pErrMsg[0]) - dialog->Alert(pErrMsg); + if (dialog && pErrMsg && pErrMsg[0]) { + dialog->Alert(nsnull, pErrMsg); + } // step (3) if they entered a bad password, forget about it! if (aBadPassword && smtpServer) diff --git a/mailnews/compose/src/nsSmtpServer.cpp b/mailnews/compose/src/nsSmtpServer.cpp index 018f804447cd..3233e73c41f7 100644 --- a/mailnews/compose/src/nsSmtpServer.cpp +++ b/mailnews/compose/src/nsSmtpServer.cpp @@ -24,7 +24,7 @@ #include "nsIPref.h" #include "nsEscape.h" #include "nsSmtpServer.h" -#include "nsINetPrompt.h" +#include "nsIPrompt.h" #include "nsIWalletService.h" #include "nsXPIDLString.h" @@ -199,7 +199,7 @@ nsSmtpServer::SetPassword(const char * aPassword) NS_IMETHODIMP nsSmtpServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const PRUnichar *aPromptTitle, - nsINetPrompt* aDialog, + nsIPrompt* aDialog, char **aPassword) { nsresult rv = NS_OK; @@ -217,8 +217,10 @@ nsSmtpServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const nsXPIDLCString serverUri; rv = GetServerURI(getter_Copies(serverUri)); if (NS_FAILED(rv)) return rv; - rv = aDialog->PromptPassword(serverUri, PR_FALSE, aPromptTitle, aPromptMessage, getter_Copies(uniPassword), &okayValue); - if (NS_FAILED(rv)) return rv; + rv = aDialog->PromptPassword(aPromptTitle, aPromptMessage, + NS_ConvertToString(serverUri).GetUnicode(), PR_TRUE, + getter_Copies(uniPassword), &okayValue); + if (NS_FAILED(rv)) return rv; if (!okayValue) // if the user pressed cancel, just return NULL; { @@ -254,7 +256,7 @@ nsSmtpServer::ForgetPassword() if (NS_FAILED(rv)) return rv; - rv = walletservice->SI_RemoveUser((const char *)serverUri, PR_FALSE, nsnull); + rv = walletservice->SI_RemoveUser((const char *)serverUri, nsnull); return rv; } diff --git a/mailnews/compose/src/nsSmtpService.cpp b/mailnews/compose/src/nsSmtpService.cpp index 508433df30c8..582a100cc13b 100644 --- a/mailnews/compose/src/nsSmtpService.cpp +++ b/mailnews/compose/src/nsSmtpService.cpp @@ -36,7 +36,7 @@ #include "nsIFileSpec.h" #include "nsCOMPtr.h" #include "nsIMsgIdentity.h" -#include "nsINetPrompt.h" +#include "nsIPrompt.h" #include "nsMsgComposeStringBundle.h" typedef struct _findServerByKeyEntry { @@ -63,7 +63,7 @@ NS_MsgBuildSmtpUrl(nsIFileSpec * aFilePath, const char* aRecipients, nsIMsgIdentity * aSenderIdentity, nsIUrlListener * aUrlListener, - nsINetPrompt * aNetPrompt, + nsIPrompt * aNetPrompt, nsIURI ** aUrl); nsresult NS_MsgLoadSmtpUrl(nsIURI * aUrl, nsISupports * aConsumer); @@ -89,7 +89,7 @@ nsresult nsSmtpService::SendMailMessage(nsIFileSpec * aFilePath, nsIMsgIdentity * aSenderIdentity, nsIUrlListener * aUrlListener, nsISmtpServer * aServer, - nsINetPrompt * aNetPrompt, + nsIPrompt * aNetPrompt, nsIURI ** aURL) { nsIURI * urlToRun = nsnull; @@ -152,7 +152,7 @@ nsresult NS_MsgBuildSmtpUrl(nsIFileSpec * aFilePath, const char * aRecipients, nsIMsgIdentity * aSenderIdentity, nsIUrlListener * aUrlListener, - nsINetPrompt * aNetPrompt, + nsIPrompt * aNetPrompt, nsIURI ** aUrl) { // mscott: this function is a convience hack until netlib actually dispatches smtp urls. @@ -174,10 +174,10 @@ nsresult NS_MsgBuildSmtpUrl(nsIFileSpec * aFilePath, { nsCOMPtr url = do_QueryInterface(smtpUrl); url->SetSpec(urlSpec); - smtpUrl->SetRecipients(aRecipients); + smtpUrl->SetRecipients(aRecipients); smtpUrl->SetPostMessageFile(aFilePath); smtpUrl->SetSenderIdentity(aSenderIdentity); - smtpUrl->SetNetPrompt(aNetPrompt); + smtpUrl->SetPrompt(aNetPrompt); url->RegisterListener(aUrlListener); PR_Free(urlSpec); } diff --git a/mailnews/compose/src/nsSmtpUrl.cpp b/mailnews/compose/src/nsSmtpUrl.cpp index c8c86e985bfa..ec2c1569ab3f 100644 --- a/mailnews/compose/src/nsSmtpUrl.cpp +++ b/mailnews/compose/src/nsSmtpUrl.cpp @@ -511,7 +511,7 @@ nsSmtpUrl::SetSenderIdentity(nsIMsgIdentity * aSenderIdentity) } NS_IMETHODIMP -nsSmtpUrl::SetNetPrompt(nsINetPrompt *aNetPrompt) +nsSmtpUrl::SetPrompt(nsIPrompt *aNetPrompt) { NS_ENSURE_ARG_POINTER(aNetPrompt); m_netPrompt = aNetPrompt; @@ -519,7 +519,7 @@ nsSmtpUrl::SetNetPrompt(nsINetPrompt *aNetPrompt) } NS_IMETHODIMP -nsSmtpUrl::GetNetPrompt(nsINetPrompt **aNetPrompt) +nsSmtpUrl::GetPrompt(nsIPrompt **aNetPrompt) { NS_ENSURE_ARG_POINTER(aNetPrompt); if (!m_netPrompt) return NS_ERROR_NULL_POINTER; diff --git a/mailnews/compose/src/nsSmtpUrl.h b/mailnews/compose/src/nsSmtpUrl.h index f3c141c88f53..2f57d8460891 100644 --- a/mailnews/compose/src/nsSmtpUrl.h +++ b/mailnews/compose/src/nsSmtpUrl.h @@ -29,7 +29,7 @@ #include "nsIFileSpec.h" #include "nsIMsgIdentity.h" #include "nsCOMPtr.h" -#include "nsINetPrompt.h" +#include "nsIPrompt.h" #include "nsISmtpServer.h" class nsMailtoUrl : public nsIMailtoUrl, public nsIURI @@ -99,7 +99,7 @@ protected: nsCString m_userName; nsCOMPtr m_fileName; nsCOMPtr m_senderIdentity; - nsCOMPtr m_netPrompt; + nsCOMPtr m_netPrompt; nsCOMPtr m_smtpServer; // it is possible to encode the message to parse in the form of a url. diff --git a/mailnews/imap/src/nsImapIncomingServer.cpp b/mailnews/imap/src/nsImapIncomingServer.cpp index 6438a027b5a6..8ca789e40340 100644 --- a/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mailnews/imap/src/nsImapIncomingServer.cpp @@ -702,7 +702,7 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath, nsCAutoString uri; nsXPIDLCString serverUri; - GetServerURI(getter_Copies(serverUri)); + GetServerPasswordRealm(getter_Copies(serverUri)); uri.Assign(serverUri); @@ -1313,7 +1313,7 @@ nsImapIncomingServer::FEAlert(const PRUnichar* aString) nsresult rv; NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv); - rv = dialog->Alert(aString); + rv = dialog->Alert(nsnull, aString); return rv; } @@ -1340,7 +1340,7 @@ NS_IMETHODIMP nsImapIncomingServer::FEAlertFromServer(const char *aString) { nsAutoString message(serverSaidPrefix); message.AppendWithConversion(whereRealMessage ? whereRealMessage : serverSaid); - rv = dialog->Alert(message.GetUnicode()); + rv = dialog->Alert(nsnull, message.GetUnicode()); PR_Free(serverSaidPrefix); } diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index 5828078e0c10..8dbc68483480 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -1519,8 +1519,9 @@ nsImapMailFolder::DeleteSubFolders(nsISupportsArray* folders, nsIMsgWindow *msgW if (docShell) dialog = do_GetInterface(docShell); PRUnichar *moveToTrashStr = IMAPGetStringByID(IMAP_MOVE_FOLDER_TO_TRASH); - if (dialog && moveToTrashStr) - dialog->Confirm (moveToTrashStr, &moveToTrash); + if (dialog && moveToTrashStr) { + dialog->Confirm(nsnull, moveToTrashStr, &moveToTrash); + } for (i = 0; i < folderCount; i++) { diff --git a/mailnews/local/src/nsLocalMailFolder.cpp b/mailnews/local/src/nsLocalMailFolder.cpp index 8e89893bbf03..4ad2adf4f7bf 100644 --- a/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mailnews/local/src/nsLocalMailFolder.cpp @@ -1273,7 +1273,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::DeleteSubFolders( if (dialog) { PRBool okToDelete = PR_FALSE; - dialog->Confirm(alertString, &okToDelete); + dialog->Confirm(nsnull, alertString, &okToDelete); if (okToDelete) return nsMsgFolder::DeleteSubFolders(folders, msgWindow); } diff --git a/mailnews/local/src/nsMailboxUrl.cpp b/mailnews/local/src/nsMailboxUrl.cpp index 835f11d93f1f..aacfe2d439fb 100644 --- a/mailnews/local/src/nsMailboxUrl.cpp +++ b/mailnews/local/src/nsMailboxUrl.cpp @@ -99,7 +99,7 @@ static char *nsMailboxGetURI(const char *nativepath) PRInt32 len = PL_strlen(serverPath); if (PL_strncasecmp(serverPath, filePath, len) == 0) { nsXPIDLCString serverURI; - rv = server->GetServerURI(getter_Copies(serverURI)); + rv = server->GetServerPasswordRealm(getter_Copies(serverURI)); if (NS_FAILED(rv)) continue; // the relpath is just past the serverpath diff --git a/mailnews/local/src/nsPop3Protocol.cpp b/mailnews/local/src/nsPop3Protocol.cpp index fda8e288c4a1..8993a40e7aed 100644 --- a/mailnews/local/src/nsPop3Protocol.cpp +++ b/mailnews/local/src/nsPop3Protocol.cpp @@ -796,9 +796,10 @@ nsPop3Protocol::Error(PRInt32 err_code) if (NS_SUCCEEDED(rv)) { PRUnichar * alertString = nsnull; - mStringService->GetStringByID(err_code, &alertString); - if (alertString) - dialog->Alert(alertString); + mStringService->GetStringByID(err_code, &alertString); + if (alertString) { + dialog->Alert(nsnull, alertString); + } nsCRT::free(alertString); } diff --git a/mailnews/news/src/nsNNTPProtocol.cpp b/mailnews/news/src/nsNNTPProtocol.cpp index 3c683109c19d..5baef61efa18 100644 --- a/mailnews/news/src/nsNNTPProtocol.cpp +++ b/mailnews/news/src/nsNNTPProtocol.cpp @@ -84,7 +84,8 @@ #include "nsIPref.h" #include "nsIMsgWindow.h" -#include "nsINetPrompt.h" +#include "nsIWebShell.h" +#include "nsIWebShellWindow.h" #include "nntpCore.h" #undef GetPort // XXX Windows! @@ -3867,7 +3868,7 @@ PRInt32 nsNNTPProtocol::DoCancel() if (!cancelInfo.from) { GetNewsStringByName("cancelDisallowed", getter_Copies(alertText)); - rv = dialog->Alert(alertText); + rv = dialog->Alert(nsnull, alertText); // XXX: todo, check rv? status = MK_NNTP_CANCEL_DISALLOWED; @@ -3892,7 +3893,7 @@ PRInt32 nsNNTPProtocol::DoCancel() /* Last chance to cancel the cancel. */ GetNewsStringByName("cancelConfirm", getter_Copies(confirmText)); - rv = dialog->Confirm(confirmText, &confirmCancelResult); + rv = dialog->Confirm(nsnull, confirmText, &confirmCancelResult); // XXX: todo, check rv? } else { @@ -3965,7 +3966,7 @@ PRInt32 nsNNTPProtocol::DoCancel() rv = prefs->GetBoolPref(PREF_NEWS_CANCEL_ALERT_ON_SUCCESS, &showAlertAfterCancel); if (NS_FAILED(rv) || showAlertAfterCancel) { GetNewsStringByName("messageCancelled", getter_Copies(alertText)); - rv = dialog->Alert(alertText); + rv = dialog->Alert(nsnull, alertText); // XXX: todo, check rv? } diff --git a/mailnews/news/src/nsNewsFolder.cpp b/mailnews/news/src/nsNewsFolder.cpp index 6f8b55040bf3..7f15c5d95d75 100644 --- a/mailnews/news/src/nsNewsFolder.cpp +++ b/mailnews/news/src/nsNewsFolder.cpp @@ -58,7 +58,7 @@ #include "nsIMsgWindow.h" #include "nsIDocShell.h" #include "nsIWebShell.h" -#include "nsINetPrompt.h" +#include "nsIPrompt.h" #include "nsXPIDLString.h" @@ -70,6 +70,7 @@ #include "nsIAppShellService.h" #include "nsIXULWindow.h" #include "nsAppShellCIDs.h" +#include "nsIInterfaceRequestor.h" // we need this because of an egcs 1.0 (and possibly gcc) compiler bug // that doesn't allow you to call ::nsISupports::GetIID() inside of a class @@ -1373,7 +1374,7 @@ NS_IMETHODIMP nsMsgNewsFolder::ForgetGroupUsername() rv = CreateNewsgroupUsernameUrlForSignon(mURI, getter_Copies(signonURL)); if (NS_FAILED(rv)) return rv; - rv = walletservice->SI_RemoveUser((const char *)signonURL, PR_FALSE, nsnull); + rv = walletservice->SI_RemoveUser((const char *)signonURL, nsnull); return rv; } @@ -1390,7 +1391,7 @@ NS_IMETHODIMP nsMsgNewsFolder::ForgetGroupPassword() rv = CreateNewsgroupPasswordUrlForSignon(mURI, getter_Copies(signonURL)); if (NS_FAILED(rv)) return rv; - rv = walletservice->SI_RemoveUser((const char *)signonURL, PR_FALSE, nsnull); + rv = walletservice->SI_RemoveUser((const char *)signonURL, nsnull); return rv; } @@ -1400,32 +1401,28 @@ nsMsgNewsFolder::GetGroupPasswordWithUI(const PRUnichar * aPromptMessage, const nsIMsgWindow* aMsgWindow, char **aGroupPassword) { - nsresult rv = NS_OK; + nsresult rv = NS_OK; - NS_ENSURE_ARG_POINTER(aGroupPassword); + NS_ENSURE_ARG_POINTER(aGroupPassword); - if (!mGroupPassword) { - // prompt the user for the password + if (!mGroupPassword) { + // prompt the user for the password + + nsCOMPtr dialog; - nsCOMPtr dialog; - - NS_ASSERTION(aMsgWindow,"no msg window, fix this, for now, use the hidden window"); + NS_ASSERTION(aMsgWindow,"no msg window, fix this, for now, use the hidden window"); if (aMsgWindow) { - nsCOMPtr docShell; + nsCOMPtr docShell; - rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell)); - if (NS_FAILED(rv)) return rv; + rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell)); + if (NS_FAILED(rv)) return rv; - nsCOMPtr webShell(do_QueryInterface(docShell, &rv)); - if (NS_FAILED(rv)) return rv; + nsCOMPtr webShell(do_QueryInterface(docShell, &rv)); + if (NS_FAILED(rv)) return rv; - // get top level window - nsCOMPtr topLevelWindow; - rv = webShell->GetTopLevelWindow(getter_AddRefs(topLevelWindow)); - if (NS_FAILED(rv)) return rv; - dialog = do_QueryInterface(topLevelWindow, &rv); + dialog = do_GetInterface(webShell, &rv); if (NS_FAILED(rv)) return rv; - } + } else { nsCOMPtr appshellservice = do_GetService(kAppShellServiceCID, &rv); if (NS_FAILED(rv)) return rv; @@ -1436,39 +1433,41 @@ nsMsgNewsFolder::GetGroupPasswordWithUI(const PRUnichar * aPromptMessage, const if (NS_FAILED(rv)) return rv; if (!xulWindow) return NS_ERROR_FAILURE; - dialog = do_QueryInterface(xulWindow, &rv); + dialog = do_GetInterface(xulWindow, &rv); if (NS_FAILED(rv)) return rv; } NS_ASSERTION(dialog,"we didn't get a net prompt"); - if (dialog) { - nsXPIDLString uniGroupPassword; + if (dialog) { + nsXPIDLString uniGroupPassword; - PRBool okayValue = PR_TRUE; + PRBool okayValue = PR_TRUE; - nsXPIDLCString signonURL; - rv = CreateNewsgroupPasswordUrlForSignon(mURI, getter_Copies(signonURL)); - if (NS_FAILED(rv)) return rv; + nsXPIDLCString signonURL; + rv = CreateNewsgroupPasswordUrlForSignon(mURI, getter_Copies(signonURL)); + if (NS_FAILED(rv)) return rv; - rv = dialog->PromptPassword((const char *)signonURL, PR_FALSE, aPromptTitle, aPromptMessage, getter_Copies(uniGroupPassword), &okayValue); - if (NS_FAILED(rv)) return rv; + nsAutoString realm = NS_ConvertToString(signonURL); + rv = dialog->PromptPassword(aPromptTitle, aPromptMessage, realm.GetUnicode(), PR_TRUE, + getter_Copies(uniGroupPassword), &okayValue); + if (NS_FAILED(rv)) return rv; - if (!okayValue) // if the user pressed cancel, just return NULL; - { - *aGroupPassword = nsnull; - return rv; - } + if (!okayValue) // if the user pressed cancel, just return NULL; + { + *aGroupPassword = nsnull; + return rv; + } - // we got a password back...so remember it - nsCString aCStr; aCStr.AssignWithConversion(uniGroupPassword); - rv = SetGroupPassword((const char *) aCStr); - if (NS_FAILED(rv)) return rv; + // we got a password back...so remember it + nsCString aCStr; aCStr.AssignWithConversion(uniGroupPassword); + rv = SetGroupPassword((const char *) aCStr); + if (NS_FAILED(rv)) return rv; - } // if we got a prompt dialog - } // if the password is empty + } // if we got a prompt dialog + } // if the password is empty - rv = GetGroupPassword(aGroupPassword); - return rv; + rv = GetGroupPassword(aGroupPassword); + return rv; } NS_IMETHODIMP @@ -1484,23 +1483,19 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const if (!mGroupUsername) { // prompt the user for the username - nsCOMPtr dialog; + nsCOMPtr dialog; NS_ASSERTION(aMsgWindow,"no msg window, fix this, for now, use the hidden window"); if (aMsgWindow) { - // prompt the user for the password - nsCOMPtr docShell; - rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell)); - if (NS_FAILED(rv)) return rv; - nsCOMPtr webShell(do_QueryInterface(docShell, &rv)); - if (NS_FAILED(rv)) return rv; - // get top level window - nsCOMPtr topLevelWindow; - rv = webShell->GetTopLevelWindow(getter_AddRefs(topLevelWindow)); - if (NS_FAILED(rv)) return rv; - dialog = do_QueryInterface(topLevelWindow, &rv); + // prompt the user for the password + nsCOMPtr docShell; + rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell)); + if (NS_FAILED(rv)) return rv; + nsCOMPtr webShell(do_QueryInterface(docShell, &rv)); + if (NS_FAILED(rv)) return rv; + dialog = do_GetInterface(webShell, &rv); if (NS_FAILED(rv)) return rv; - } + } else { nsCOMPtr appshellservice = do_GetService(kAppShellServiceCID, &rv); if (NS_FAILED(rv)) return rv; @@ -1511,7 +1506,7 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const if (NS_FAILED(rv)) return rv; if (!xulWindow) return NS_ERROR_FAILURE; - dialog = do_QueryInterface(xulWindow, &rv); + dialog = do_GetInterface(xulWindow, &rv); if (NS_FAILED(rv)) return rv; } @@ -1525,7 +1520,9 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const rv = CreateNewsgroupUsernameUrlForSignon(mURI, getter_Copies(signonURL)); if (NS_FAILED(rv)) return rv; - rv = dialog->Prompt((const char *)signonURL, PR_FALSE, aPromptTitle, aPromptMessage, getter_Copies(uniGroupUsername), &okayValue); + nsAutoString realm = NS_ConvertToString(signonURL); + rv = dialog->Prompt(aPromptTitle, aPromptMessage, realm.GetUnicode(), nsnull, + getter_Copies(uniGroupUsername), &okayValue); if (NS_FAILED(rv)) return rv; if (!okayValue) // if the user pressed cancel, just return NULL; diff --git a/mailnews/news/src/nsNntpService.cpp b/mailnews/news/src/nsNntpService.cpp index bb22e898ef20..b9bbd49d2792 100644 --- a/mailnews/news/src/nsNntpService.cpp +++ b/mailnews/news/src/nsNntpService.cpp @@ -1052,7 +1052,7 @@ NS_IMETHODIMP nsNntpService::CancelMessages(const char *hostname, const char *ne if (!messages) { nsAutoString alertText; alertText.AssignWithConversion("No articles are selected."); if (dialog) - rv = dialog->Alert(alertText.GetUnicode()); + rv = dialog->Alert(nsnull, alertText.GetUnicode()); return NS_ERROR_NULL_POINTER; } @@ -1068,7 +1068,7 @@ NS_IMETHODIMP nsNntpService::CancelMessages(const char *hostname, const char *ne if (count != 1) { nsAutoString alertText; alertText.AssignWithConversion("You can only cancel one article at a time."); if (dialog) - rv = dialog->Alert(alertText.GetUnicode()); + rv = dialog->Alert(nsnull, alertText.GetUnicode()); return NS_ERROR_FAILURE; } @@ -1270,7 +1270,7 @@ NS_IMETHODIMP nsNntpService::Search(nsIMsgSearchSession *aSearchSession, nsIMsgW nsCOMPtr uri; nsXPIDLCString serverUri; nsXPIDLString newsgroupName; - rv = server->GetServerURI(getter_Copies(serverUri)); + rv = server->GetServerPasswordRealm(getter_Copies(serverUri)); if (NS_FAILED(rv)) return rv; aMsgFolder->GetName(getter_Copies(newsgroupName)); if (NS_FAILED(rv)) return rv; @@ -1309,7 +1309,7 @@ nsNntpService::UpdateCounts(nsINntpIncomingServer *aNntpServer, nsIMsgWindow *aM if (!server) return NS_ERROR_FAILURE; nsXPIDLCString serverUri; - rv = server->GetServerURI(getter_Copies(serverUri)); + rv = server->GetServerPasswordRealm(getter_Copies(serverUri)); if (NS_FAILED(rv)) return rv; rv = ConstructNntpUrl((const char *)serverUri, "", nsMsgKey_None, nsnull, getter_AddRefs(uri)); @@ -1337,7 +1337,7 @@ nsNntpService::BuildSubscribeDatasource(nsINntpIncomingServer *aNntpServer, nsIM if (!server) return NS_ERROR_FAILURE; nsXPIDLCString serverUri; - rv = server->GetServerURI(getter_Copies(serverUri)); + rv = server->GetServerPasswordRealm(getter_Copies(serverUri)); nsCAutoString uriStr; uriStr += (const char *)serverUri; diff --git a/netwerk/base/public/nsINetPrompt.idl b/netwerk/base/public/nsINetPrompt.idl index ce0f18a9b0c7..fbb04e0363fb 100644 --- a/netwerk/base/public/nsINetPrompt.idl +++ b/netwerk/base/public/nsINetPrompt.idl @@ -30,23 +30,21 @@ interface nsINetPrompt : nsISupports /** * Puts up an alert dialog with an OK button. */ - void alert( in string url, in boolean stripurl, in wstring title, in wstring text); + void alert(in string key, in wstring title, in wstring text); /** * Puts up a dialog with OK and Cancel buttons. * @return true for OK, false for Cancel */ - boolean confirm( in string url, in boolean stripurl, in wstring title, in wstring text); + boolean confirm(in string key, in wstring title, in wstring text); /** * Puts up a username/password dialog with OK and Cancel buttons. * @return true for OK, false for Cancel */ - boolean promptUsernameAndPassword( - in string url, - in boolean stripurl, - in wstring title, - in wstring text, + boolean promptUsernameAndPassword(in string key, + in wstring title, + in wstring text, out wstring user, out wstring pwd); @@ -54,23 +52,19 @@ interface nsINetPrompt : nsISupports * Puts up a password dialog with OK and Cancel buttons. * @return true for OK, false for Cancel */ - boolean promptPassword( - in string url, - in boolean stripurl, - in wstring title, - in wstring text, + boolean promptPassword(in string key, + in wstring title, + in wstring text, out wstring pwd); /** * Puts up a prompt dialog with OK and Cancel buttons. * @return true for OK, false for Cancel */ - boolean prompt( - in string url, - in boolean stripurl, - in wstring title, - in wstring text, - out wstring pwd); + boolean prompt(in string key, + in wstring title, + in wstring text, + out wstring pwd); }; diff --git a/netwerk/base/public/nsIPrompt.idl b/netwerk/base/public/nsIPrompt.idl index 85ad35dfef5f..fc2858dd90b5 100644 --- a/netwerk/base/public/nsIPrompt.idl +++ b/netwerk/base/public/nsIPrompt.idl @@ -28,20 +28,23 @@ interface nsIPrompt : nsISupports /** * Puts up an alert dialog with an OK button. */ - void alert(in wstring text); + void alert(in wstring dialogTitle, + in wstring text); /** * Puts up a dialog with OK and Cancel buttons. * @return true for OK, false for Cancel */ - boolean confirm(in wstring text); + boolean confirm(in wstring dialogTitle, + in wstring text); /** * Puts up a dialog with OK and Cancel buttons, and * a message with a single checkbox. * @return true for OK, false for Cancel */ - boolean confirmCheck(in wstring text, + boolean confirmCheck(in wstring dialogTitle, + in wstring text, in wstring checkMsg, out boolean checkValue); @@ -49,7 +52,9 @@ interface nsIPrompt : nsISupports * Puts up a text input dialog with OK and Cancel buttons. * @return true for OK, false for Cancel */ - boolean prompt(in wstring text, + boolean prompt(in wstring dialogTitle, + in wstring text, + in wstring passwordRealm, in wstring defaultText, out wstring result); @@ -57,7 +62,10 @@ interface nsIPrompt : nsISupports * Puts up a username/password dialog with OK and Cancel buttons. * @return true for OK, false for Cancel */ - boolean promptUsernameAndPassword(in wstring text, + boolean promptUsernameAndPassword(in wstring dialogTitle, + in wstring text, + in wstring passwordRealm, + in boolean persistPassword, out wstring user, out wstring pwd); @@ -65,38 +73,40 @@ interface nsIPrompt : nsISupports * Puts up a password dialog with OK and Cancel buttons. * @return true for OK, false for Cancel */ - boolean promptPassword(in wstring text, - in wstring title, + boolean promptPassword(in wstring dialogTitle, + in wstring text, + in wstring passwordRealm, + in boolean persistPassword, out wstring pwd); /** * Puts up a dialog box which has a list box of strings */ - boolean select(in wstring inDialogTitle, - in wstring inMsg, - in PRUint32 inCount, - [array, size_is(inCount)] in wstring inList, + boolean select(in wstring dialogTitle, + in wstring text, + in PRUint32 count, + [array, size_is(count)] in wstring selectList, out long outSelection); /** * Put up a universal dialog */ - void universalDialog(in wstring inTitleMessage, - in wstring inDialogTitle, /* e.g., alert, confirm, prompt, prompt password */ - in wstring inMsg, /* main message for dialog */ - in wstring inCheckboxMsg, /* message for checkbox */ - in wstring inButton0Text, /* text for first button */ - in wstring inButton1Text, /* text for second button */ - in wstring inButton2Text, /* text for third button */ - in wstring inButton3Text, /* text for fourth button */ - in wstring inEditfield1Msg, /*message for first edit field */ - in wstring inEditfield2Msg, /* message for second edit field */ - inout wstring inoutEditfield1Value, /* initial and final value for first edit field */ - inout wstring inoutEditfield2Value, /* initial and final value for second edit field */ - in wstring inIConURL, /* url of icon to be displayed in dialog */ - inout boolean inoutCheckboxState, /* initial and final state of checkbox */ - in PRInt32 inNumberButtons, /* total number of buttons (0 to 4) */ - in PRInt32 inNumberEditfields, /* total number of edit fields (0 to 2) */ - in PRInt32 inEditField1Password, /* ??? */ - out PRInt32 outButtonPressed); /* number of button that was pressed (0 to 3) */ + void universalDialog(in wstring titleMessage, + in wstring dialogTitle, /* e.g., alert, confirm, prompt, prompt password */ + in wstring text, /* main message for dialog */ + in wstring checkboxMsg, /* message for checkbox */ + in wstring button0Text, /* text for first button */ + in wstring button1Text, /* text for second button */ + in wstring button2Text, /* text for third button */ + in wstring button3Text, /* text for fourth button */ + in wstring editfield1Msg, /*message for first edit field */ + in wstring editfield2Msg, /* message for second edit field */ + inout wstring editfield1Value, /* initial and final value for first edit field */ + inout wstring editfield2Value, /* initial and final value for second edit field */ + in wstring iconURL, /* url of icon to be displayed in dialog */ + inout boolean checkboxState, /* initial and final state of checkbox */ + in PRInt32 numberButtons, /* total number of buttons (0 to 4) */ + in PRInt32 numberEditfields, /* total number of edit fields (0 to 2) */ + in PRInt32 editField1Password, /* ??? */ + out PRInt32 buttonPressed); /* number of button that was pressed (0 to 3) */ }; diff --git a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp index 9425e93a0b40..5c53f9ca9950 100644 --- a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -810,8 +810,11 @@ nsFtpConnectionThread::S_user() { message.AssignWithConversion("Enter username and password for "); //TODO localize it! message.AppendWithConversion(host); - rv = proxyprompter->PromptUsernameAndPassword(message.GetUnicode(), - &user, &passwd, &retval); + nsAutoString realm = NS_ConvertToString(host); // XXX i18n + rv = proxyprompter->PromptUsernameAndPassword(nsnull, + message.GetUnicode(), + realm.GetUnicode(), PR_FALSE, + &user, &passwd, &retval); // if the user canceled or didn't supply a username we want to fail if (!retval || (user && !*user) ) @@ -889,9 +892,10 @@ nsFtpConnectionThread::S_pass() { message.AppendWithConversion(" on "); message.AppendWithConversion(host); - rv = proxyprompter->PromptPassword(message.GetUnicode(), - title.GetUnicode(), - &passwd, &retval); + rv = proxyprompter->PromptPassword(title.GetUnicode(), + message.GetUnicode(), + NS_ConvertASCIItoUCS2(host).GetUnicode(), + PR_FALSE, &passwd, &retval); // we want to fail if the user canceled or didn't enter a password. if (!retval || (passwd && !*passwd) ) diff --git a/netwerk/protocol/http/src/nsHTTPChannel.cpp b/netwerk/protocol/http/src/nsHTTPChannel.cpp index c3474e515afc..a9c7524ca325 100644 --- a/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -60,7 +60,6 @@ // Once other kinds of auth are up change TODO #include "nsBasicAuth.h" static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID); -#include "nsINetPrompt.h" #include "nsProxiedService.h" static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID); @@ -1781,14 +1780,17 @@ nsHTTPChannel::Authenticate(const char *iChallenge, PRBool iProxyAuth) message.AppendWithConversion(iChallenge); // Get url - nsXPIDLCString urlCString; + nsXPIDLCString urlCString; mURI->GetHost(getter_Copies(urlCString)); - rv = mPrompter->PromptUsernameAndPassword( - message.GetUnicode(), - &user, - &passwd, - &retval); + nsAutoString hostname = NS_ConvertToString(urlCString); // XXX i18n + rv = mPrompter->PromptUsernameAndPassword(nsnull, + message.GetUnicode(), + hostname.GetUnicode(), + PR_FALSE, + &user, + &passwd, + &retval); if (NS_SUCCEEDED(rv) && (retval)) { diff --git a/webshell/src/nsWebShell.cpp b/webshell/src/nsWebShell.cpp index 1018c1bb3fed..056dab2e8722 100644 --- a/webshell/src/nsWebShell.cpp +++ b/webshell/src/nsWebShell.cpp @@ -1046,7 +1046,7 @@ nsWebShell::OnOverLink(nsIContent* aContent, NS_IMETHODIMP nsWebShell::GetLinkState(const nsString& aLinkURI, nsLinkState& aState) { - aState = eLinkState_Unvisited; + aState = eLinkState_Unvisited; if(mGlobalHistory) { @@ -1276,7 +1276,7 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, errorMsg.AppendWithConversion(' '); errorMsg.Append(messageStr); - prompter->Alert(errorMsg.GetUnicode()); + prompter->Alert(nsnull, errorMsg.GetUnicode()); } else if(aStatus == NS_ERROR_CONNECTION_REFUSED) {// Doc failed to load because we couldn't connect to the server. @@ -1304,7 +1304,7 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, errorMsg.AppendInt(port); } errorMsg.AppendWithConversion('.'); - prompter->Alert(errorMsg.GetUnicode()); + prompter->Alert(nsnull, errorMsg.GetUnicode()); } else if(aStatus == NS_ERROR_NET_TIMEOUT) {// Doc failed to load because the socket function timed out. @@ -1326,7 +1326,7 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, errorMsg.AppendWithConversion(host); errorMsg.AppendWithConversion('.'); - prompter->Alert(errorMsg.GetUnicode()); + prompter->Alert(nsnull, errorMsg.GetUnicode()); } // end NS_ERROR_NET_TIMEOUT } // end mDocLoader == loader diff --git a/webshell/tests/viewer/nsBrowserWindow.cpp b/webshell/tests/viewer/nsBrowserWindow.cpp index 1af11c889f83..28c4d6ff074d 100644 --- a/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/webshell/tests/viewer/nsBrowserWindow.cpp @@ -2186,7 +2186,7 @@ nsBrowserWindow::OnStatus(nsIChannel* channel, nsISupports *ctxt, const PRUnicha } NS_IMETHODIMP -nsBrowserWindow::Alert(const PRUnichar *text) +nsBrowserWindow::Alert(const PRUnichar *dialogTitle, const PRUnichar *text) { nsCAutoString str; str.AssignWithConversion(text); printf("%cBrowser Window Alert: %s\n", '\007', str.GetBuffer()); @@ -2195,7 +2195,8 @@ nsBrowserWindow::Alert(const PRUnichar *text) } NS_IMETHODIMP -nsBrowserWindow::Confirm(const PRUnichar *text, +nsBrowserWindow::Confirm(const PRUnichar *dialogTitle, + const PRUnichar *text, PRBool *result) { nsCAutoString str; str.AssignWithConversion(text); @@ -2220,16 +2221,19 @@ nsBrowserWindow::Confirm(const PRUnichar *text, } NS_IMETHODIMP -nsBrowserWindow::ConfirmCheck(const PRUnichar *text, +nsBrowserWindow::ConfirmCheck(const PRUnichar *dialogTitle, + const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *result) { - return Confirm(text, result); + return Confirm(dialogTitle, text, result); } NS_IMETHODIMP -nsBrowserWindow::Prompt(const PRUnichar *text, +nsBrowserWindow::Prompt(const PRUnichar *dialogTitle, + const PRUnichar *text, + const PRUnichar *passwordRealm, const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval) @@ -2253,7 +2257,10 @@ nsBrowserWindow::Prompt(const PRUnichar *text, } NS_IMETHODIMP -nsBrowserWindow::PromptUsernameAndPassword(const PRUnichar *text, +nsBrowserWindow::PromptUsernameAndPassword(const PRUnichar *dialogTitle, + const PRUnichar *text, + const PRUnichar *passwordRealm, + PRBool persistPassword, PRUnichar **user, PRUnichar **pwd, PRBool *_retval) @@ -2283,8 +2290,10 @@ nsBrowserWindow::PromptUsernameAndPassword(const PRUnichar *text, } NS_IMETHODIMP -nsBrowserWindow::PromptPassword(const PRUnichar *text, - const PRUnichar *title, +nsBrowserWindow::PromptPassword(const PRUnichar *dialogTitle, + const PRUnichar *text, + const PRUnichar *passwordRealm, + PRBool persistPassword, PRUnichar **pwd, PRBool *_retval) { diff --git a/xpfe/appshell/public/nsIWebShellWindow.h b/xpfe/appshell/public/nsIWebShellWindow.h index e6a71ff1d564..bc741a73c24f 100644 --- a/xpfe/appshell/public/nsIWebShellWindow.h +++ b/xpfe/appshell/public/nsIWebShellWindow.h @@ -25,12 +25,13 @@ #include "nsISupports.h" - /* Forward declarations.... */ class nsIWebShell; class nsIWidget; class nsString; class nsIDOMWindow; +class nsIPrompt; + // Interface ID for nsIWebShellWindow #define NS_IWEBSHELL_WINDOW_IID \ { 0x28dce479, 0xbf73, 0x11d2, { 0x96, 0xc8, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56}} @@ -61,6 +62,8 @@ public: * @return always NS_OK */ NS_IMETHOD ShouldLoadDefaultPage(PRBool *aYes) = 0; + + NS_IMETHOD GetPrompter(nsIPrompt* *result) = 0; }; diff --git a/xpfe/appshell/src/nsChromeTreeOwner.cpp b/xpfe/appshell/src/nsChromeTreeOwner.cpp index 942abef8b1d1..c711ce99a906 100644 --- a/xpfe/appshell/src/nsChromeTreeOwner.cpp +++ b/xpfe/appshell/src/nsChromeTreeOwner.cpp @@ -74,7 +74,7 @@ NS_IMETHODIMP nsChromeTreeOwner::GetInterface(const nsIID& aIID, void** aSink) NS_ENSURE_ARG_POINTER(aSink); if(aIID.Equals(NS_GET_IID(nsIPrompt))) - return mXULWindow->QueryInterface(aIID, aSink); + return mXULWindow->GetInterface(aIID, aSink); else return QueryInterface(aIID, aSink); diff --git a/xpfe/appshell/src/nsContentTreeOwner.cpp b/xpfe/appshell/src/nsContentTreeOwner.cpp index 090059c02720..3583091b5578 100644 --- a/xpfe/appshell/src/nsContentTreeOwner.cpp +++ b/xpfe/appshell/src/nsContentTreeOwner.cpp @@ -82,7 +82,7 @@ NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, void** aSink) if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome))) *aSink = NS_STATIC_CAST(nsIWebBrowserChrome*, this); else if(aIID.Equals(NS_GET_IID(nsIPrompt))) - return mXULWindow->QueryInterface(aIID, aSink); + return mXULWindow->GetInterface(aIID, aSink); else return QueryInterface(aIID, aSink); diff --git a/xpfe/appshell/src/nsNetSupportDialog.cpp b/xpfe/appshell/src/nsNetSupportDialog.cpp index 03954526cf84..a4fc77b6a50f 100644 --- a/xpfe/appshell/src/nsNetSupportDialog.cpp +++ b/xpfe/appshell/src/nsNetSupportDialog.cpp @@ -34,6 +34,7 @@ #include "nsIDOMWindow.h" #include "nsIServiceManager.h" #include "nsIXULWindow.h" +#include "nsIInterfaceRequestor.h" /* Define Class IDs */ static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); @@ -46,7 +47,7 @@ PRBool GetNSIPrompt( nsCOMPtr & outPrompt ) nsCOMPtr xulWindow; appShellService->GetHiddenWindow(getter_AddRefs(xulWindow)); - outPrompt = do_QueryInterface(xulWindow); + outPrompt = do_GetInterface(xulWindow); if(outPrompt) return PR_TRUE; return PR_FALSE; @@ -63,29 +64,30 @@ nsNetSupportDialog::~nsNetSupportDialog() -NS_IMETHODIMP nsNetSupportDialog::Alert(const PRUnichar *text) +NS_IMETHODIMP nsNetSupportDialog::Alert(const PRUnichar *dialogTitle, const PRUnichar *text) { nsresult rv = NS_ERROR_FAILURE; nsCOMPtr< nsIPrompt> dialogService; if( GetNSIPrompt( dialogService ) ) - rv = dialogService->Alert( text ); + rv = dialogService->Alert(dialogTitle, text); return rv; } -NS_IMETHODIMP nsNetSupportDialog::Confirm(const PRUnichar *text, PRBool *returnValue) +NS_IMETHODIMP nsNetSupportDialog::Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *returnValue) { nsresult rv = NS_ERROR_FAILURE; nsCOMPtr< nsIPrompt> dialogService; if( GetNSIPrompt( dialogService ) ) - rv = dialogService->Confirm( text, returnValue ); + rv = dialogService->Confirm(dialogTitle, text, returnValue); return rv; } -NS_IMETHODIMP nsNetSupportDialog::ConfirmCheck(const PRUnichar *text, +NS_IMETHODIMP nsNetSupportDialog::ConfirmCheck(const PRUnichar *dialogTitle, + const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *returnValue) @@ -94,7 +96,7 @@ NS_IMETHODIMP nsNetSupportDialog::ConfirmCheck(const PRUnichar *text, nsresult rv = NS_ERROR_FAILURE; nsCOMPtr< nsIPrompt> dialogService; if( GetNSIPrompt( dialogService ) ) - rv = dialogService->ConfirmCheck( text, checkMsg, checkValue, returnValue ); + rv = dialogService->ConfirmCheck(dialogTitle, text, checkMsg, checkValue, returnValue); return rv; } @@ -139,7 +141,9 @@ NS_IMETHODIMP nsNetSupportDialog::UniversalDialog return rv; } -NS_IMETHODIMP nsNetSupportDialog::Prompt(const PRUnichar *text, +NS_IMETHODIMP nsNetSupportDialog::Prompt(const PRUnichar *dialogTitle, + const PRUnichar *text, + const PRUnichar *passwordRealm, const PRUnichar *defaultText, PRUnichar **resultText, PRBool *returnValue) @@ -148,12 +152,15 @@ NS_IMETHODIMP nsNetSupportDialog::Prompt(const PRUnichar *text, nsresult rv = NS_ERROR_FAILURE; nsCOMPtr< nsIPrompt> dialogService; if( GetNSIPrompt( dialogService ) ) - rv = dialogService->Prompt( text, defaultText, resultText, returnValue ); + rv = dialogService->Prompt(dialogTitle, text, passwordRealm, defaultText, resultText, returnValue); return rv; } -NS_IMETHODIMP nsNetSupportDialog::PromptUsernameAndPassword(const PRUnichar *text, +NS_IMETHODIMP nsNetSupportDialog::PromptUsernameAndPassword(const PRUnichar *dialogTitle, + const PRUnichar *text, + const PRUnichar *passwordRealm, + PRBool persistPassword, PRUnichar **user, PRUnichar **pwd, PRBool *returnValue) @@ -162,22 +169,32 @@ NS_IMETHODIMP nsNetSupportDialog::PromptUsernameAndPassword(const PRUnichar *tex nsresult rv = NS_ERROR_FAILURE; nsCOMPtr< nsIPrompt> dialogService; if( GetNSIPrompt( dialogService ) ) - rv = dialogService->PromptUsernameAndPassword( text, user, pwd, returnValue ); + rv = dialogService->PromptUsernameAndPassword(dialogTitle, text, passwordRealm, persistPassword, user, pwd, returnValue); return rv; } -NS_IMETHODIMP nsNetSupportDialog::PromptPassword(const PRUnichar *text, const PRUnichar *title, PRUnichar **pwd, PRBool *_retval) +NS_IMETHODIMP nsNetSupportDialog::PromptPassword(const PRUnichar *dialogTitle, + const PRUnichar *text, + const PRUnichar *passwordRealm, + PRBool persistPassword, + PRUnichar **pwd, + PRBool *_retval) { nsresult rv = NS_ERROR_FAILURE; nsCOMPtr< nsIPrompt> dialogService; if( GetNSIPrompt( dialogService ) ) - rv = dialogService->PromptPassword( text, title, pwd, _retval ); + rv = dialogService->PromptPassword(dialogTitle, text, passwordRealm, persistPassword, pwd, _retval); return rv; } -nsresult nsNetSupportDialog::Select(const PRUnichar *inDialogTitle, const PRUnichar *inMsg, PRUint32 inCount, const PRUnichar **inList, PRInt32 *outSelection, PRBool *_retval) +nsresult nsNetSupportDialog::Select(const PRUnichar *inDialogTitle, + const PRUnichar *inMsg, + PRUint32 inCount, + const PRUnichar **inList, + PRInt32 *outSelection, + PRBool *_retval) { nsresult rv = NS_ERROR_FAILURE; nsCOMPtr< nsIPrompt> dialogService; diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index f1de34cbfa05..82465337c2c9 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -256,8 +256,6 @@ NS_INTERFACE_MAP_BEGIN(nsWebShellWindow) NS_INTERFACE_MAP_ENTRY(nsIWebShellWindow) NS_INTERFACE_MAP_ENTRY(nsIWebShellContainer) NS_INTERFACE_MAP_ENTRY(nsIDocumentLoaderObserver) - NS_INTERFACE_MAP_ENTRY(nsIPrompt) - NS_INTERFACE_MAP_ENTRY(nsINetPrompt) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_ENTRY(nsIXULWindow) NS_INTERFACE_MAP_ENTRY(nsIBaseWindow) @@ -1432,7 +1430,7 @@ void nsWebShellWindow::LoadContentAreas() { char *urlChar; nsIWebShell *contentShell; nsresult rv; - for (endPos = 0; endPos < searchSpec.Length(); ) { + for (endPos = 0; endPos < (PRInt32)searchSpec.Length(); ) { // extract contentAreaID and URL substrings begPos = endPos; eqPos = searchSpec.FindChar('=', PR_FALSE,begPos); @@ -1729,9 +1727,265 @@ NS_IMETHODIMP nsWebShellWindow::Destroy() return nsXULWindow::Destroy(); } - + +//////////////////////////////////////////////////////////////////////////////// +// XXX What a mess we have here w.r.t. our prompting interfaces. As far as I +// can tell, the situation looks something like this: +// +// - clients get the nsIPrompt from the web shell window +// - the web shell window passes control to nsCommonDialogs +// - nsCommonDialogs calls into js with the current dom window +// - the dom window gets the nsIPrompt of its tree owner +// - somewhere along the way a real dialog comes up +// +// This little transducer maps the nsIPrompt interface to the nsICommonDialogs +// interface. Ideally, nsIPrompt would be implemented by nsIDOMWindow which +// would eliminate the need for this. + +class nsDOMWindowPrompter : public nsIPrompt +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIPROMPT + + nsDOMWindowPrompter(nsIDOMWindow* window); + virtual ~nsDOMWindowPrompter() {} + + nsresult Init(); + +protected: + nsCOMPtr mDOMWindow; + nsCOMPtr mCommonDialogs; +}; + +static nsresult +NS_NewDOMWindowPrompter(nsIPrompt* *result, nsIDOMWindow* window) +{ + nsresult rv; + nsDOMWindowPrompter* prompter = new nsDOMWindowPrompter(window); + if (prompter == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(prompter); + rv = prompter->Init(); + if (NS_FAILED(rv)) { + NS_RELEASE(prompter); + return rv; + } + *result = prompter; + return NS_OK; +} + +NS_IMPL_THREADSAFE_ISUPPORTS1(nsDOMWindowPrompter, nsIPrompt) + +nsDOMWindowPrompter::nsDOMWindowPrompter(nsIDOMWindow* window) + : mDOMWindow(window) +{ + NS_INIT_REFCNT(); +} + +nsresult +nsDOMWindowPrompter::Init() +{ + nsresult rv; + mCommonDialogs = do_GetService(kCommonDialogsCID, &rv); + return rv; +} + +NS_IMETHODIMP +nsDOMWindowPrompter::Alert(const PRUnichar* dialogTitle, + const PRUnichar* text) +{ + nsresult rv; + nsAutoString title(dialogTitle); + if (title == nsnull) + title.AssignWithConversion("Alert"); // XXX i18n + rv = mCommonDialogs->Alert(mDOMWindow, title.GetUnicode(), text); + return rv; +} + +NS_IMETHODIMP +nsDOMWindowPrompter::Confirm(const PRUnichar* dialogTitle, + const PRUnichar* text, + PRBool *_retval) +{ + nsresult rv; + nsAutoString title(dialogTitle); + if (title == nsnull) + title.AssignWithConversion("Confirm"); // XXX i18n + rv = mCommonDialogs->Confirm(mDOMWindow, title.GetUnicode(), text, _retval); + return rv; +} + +NS_IMETHODIMP +nsDOMWindowPrompter::ConfirmCheck(const PRUnichar* dialogTitle, + const PRUnichar* text, + const PRUnichar* checkMsg, + PRBool *checkValue, + PRBool *_retval) +{ + nsresult rv; + nsAutoString title(dialogTitle); + if (title == nsnull) + title.AssignWithConversion("Confirm"); // XXX i18n + rv = mCommonDialogs->ConfirmCheck(mDOMWindow, title.GetUnicode(), text, + checkMsg, checkValue, _retval); + return rv; +} + +NS_IMETHODIMP +nsDOMWindowPrompter::Prompt(const PRUnichar* dialogTitle, + const PRUnichar* text, + const PRUnichar* passwordRealm, + const PRUnichar* defaultText, + PRUnichar* *result, + PRBool *_retval) +{ + // ignore passwordRealm here? + nsresult rv; + nsAutoString title(dialogTitle); + if (title == nsnull) + title.AssignWithConversion("Prompt"); // XXX i18n + rv = mCommonDialogs->Prompt(mDOMWindow, title.GetUnicode(), text, + defaultText, result, _retval); + return rv; +} + +NS_IMETHODIMP +nsDOMWindowPrompter::PromptUsernameAndPassword(const PRUnichar* dialogTitle, + const PRUnichar* text, + const PRUnichar* passwordRealm, + PRBool persistPassword, + PRUnichar* *user, + PRUnichar* *pwd, + PRBool *_retval) +{ + // ignore passwordRealm and persistPassword here? + nsresult rv; + nsAutoString title(dialogTitle); + if (title == nsnull) + title.AssignWithConversion("Prompt"); // XXX i18n + rv = mCommonDialogs->PromptUsernameAndPassword(mDOMWindow, title.GetUnicode(), text, + user, pwd, _retval); + return rv; +} + +NS_IMETHODIMP +nsDOMWindowPrompter::PromptPassword(const PRUnichar* dialogTitle, + const PRUnichar* text, + const PRUnichar* passwordRealm, + PRBool persistPassword, + PRUnichar* *pwd, + PRBool *_retval) +{ + // ignore passwordRealm and persistPassword here? + nsresult rv; + nsAutoString title(dialogTitle); + if (title == nsnull) + title.AssignWithConversion("Prompt"); // XXX i18n + rv = mCommonDialogs->PromptPassword(mDOMWindow, title.GetUnicode(), text, + pwd, _retval); + return rv; +} + +NS_IMETHODIMP +nsDOMWindowPrompter::Select(const PRUnichar *dialogTitle, + const PRUnichar* inMsg, + PRUint32 inCount, + const PRUnichar **inList, + PRInt32 *outSelection, + PRBool *_retval) +{ + nsresult rv; + nsAutoString title(dialogTitle); + if (title == nsnull) + title.AssignWithConversion("Select"); // XXX i18n + rv = mCommonDialogs->Select(mDOMWindow, title.GetUnicode(), inMsg, + inCount, inList, outSelection, _retval); + return rv; +} + +NS_IMETHODIMP +nsDOMWindowPrompter::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; + rv = mCommonDialogs->UniversalDialog(mDOMWindow, + inTitleMessage, + inDialogTitle, + inMsg, + inCheckboxMsg, + inButton0Text, + inButton1Text, + inButton2Text, + inButton3Text, + inEditfield1Msg, + inEditfield2Msg, + inoutEditfield1Value, + inoutEditfield2Value, + inIConURL, + inoutCheckboxState, + inNumberButtons, + inNumberEditfields, + inEditField1Password, + outButtonPressed); + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// + +NS_IMETHODIMP +nsWebShellWindow::GetPrompter(nsIPrompt* *result) +{ + nsresult rv; + if (mPrompter == nsnull) { + nsIWebShell* tempWebShell; + GetWebShell(tempWebShell); + nsCOMPtr webShell(dont_AddRef(tempWebShell)); + nsCOMPtr domWindow; + rv = ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow)); + if (NS_FAILED(rv)) { + NS_ERROR("Unable to retrieve the DOM window from the new web shell."); + return rv; + } + nsCOMPtr prompt; + rv = NS_NewDOMWindowPrompter(getter_AddRefs(prompt), domWindow); + if (NS_FAILED(rv)) return rv; + + // wrap the nsDOMWindowPrompter in a nsISingleSignOnPrompt: + rv = NS_NewSingleSignOnPrompt(getter_AddRefs(mPrompter), prompt); + if (NS_FAILED(rv)) return rv; + } + *result = mPrompter; + NS_ADDREF(*result); + return NS_OK; +} + +#if 0 +//////////////////////////////////////////////////////////////////////////////// // nsIPrompt -NS_IMETHODIMP nsWebShellWindow::Alert(const PRUnichar *text) + +NS_IMETHODIMP nsWebShellWindow::Alert(const PRUnichar* dialogTitle, + const PRUnichar* text) { nsresult rv; nsCOMPtr domWindow; @@ -1752,7 +2006,9 @@ NS_IMETHODIMP nsWebShellWindow::Alert(const PRUnichar *text) return rv; } -NS_IMETHODIMP nsWebShellWindow::Confirm(const PRUnichar *text, PRBool *_retval) +NS_IMETHODIMP nsWebShellWindow::Confirm(const PRUnichar* dialogTitle, + const PRUnichar* text, + PRBool *_retval) { nsresult rv; nsCOMPtr domWindow; @@ -1772,7 +2028,11 @@ NS_IMETHODIMP nsWebShellWindow::Confirm(const PRUnichar *text, PRBool *_retval) return rv; } -NS_IMETHODIMP nsWebShellWindow::ConfirmCheck(const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval) +NS_IMETHODIMP nsWebShellWindow::ConfirmCheck(const PRUnichar* dialogTitle, + const PRUnichar* text, + const PRUnichar* checkMsg, + PRBool *checkValue, + PRBool *_retval) { nsresult rv; nsCOMPtr domWindow; @@ -1841,7 +2101,12 @@ NS_IMETHODIMP nsWebShellWindow::UniversalDialog -NS_IMETHODIMP nsWebShellWindow::Prompt(const PRUnichar *text, const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval) +NS_IMETHODIMP nsWebShellWindow::Prompt(const PRUnichar* dialogTitle, + const PRUnichar* text, + const PRUnichar* passwordRealm, + const PRUnichar* defaultText, + PRUnichar* *result, + PRBool *_retval) { nsresult rv; nsCOMPtr domWindow; @@ -1862,7 +2127,13 @@ NS_IMETHODIMP nsWebShellWindow::Prompt(const PRUnichar *text, const PRUnichar *d return rv; } -NS_IMETHODIMP nsWebShellWindow::PromptUsernameAndPassword(const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, PRBool *_retval) +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; @@ -1884,7 +2155,12 @@ nsString defaultTitle; defaultTitle.AssignWithConversion("Prompt Username and Pa return rv; } -NS_IMETHODIMP nsWebShellWindow::PromptPassword(const PRUnichar *text, const PRUnichar *title, PRUnichar **pwd, PRBool *_retval) +NS_IMETHODIMP nsWebShellWindow::PromptPassword(const PRUnichar* dialogTitle, + const PRUnichar* text, + const PRUnichar* passwordRealm, + PRBool persistPassword, + PRUnichar* *pwd, + PRBool *_retval) { nsresult rv; nsCOMPtr domWindow; @@ -1899,7 +2175,7 @@ NS_IMETHODIMP nsWebShellWindow::PromptPassword(const PRUnichar *text, const PRUn NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &rv); if ( NS_SUCCEEDED( rv ) ) - rv = dialog->PromptPassword( domWindow, title, text, pwd, _retval ); + rv = dialog->PromptPassword( domWindow, dialogTitle, text, pwd, _retval ); return rv; } @@ -1922,30 +2198,30 @@ NS_IMETHODIMP nsWebShellWindow::Select( const PRUnichar *inDialogTitle, const PR return rv; } -NS_IMETHODIMP nsWebShellWindow::Alert(const char *url, PRBool stripUrl, const PRUnichar *title, const PRUnichar *text) +NS_IMETHODIMP nsWebShellWindow::Alert(const char *key, const PRUnichar *title, const PRUnichar *text) { return Alert( text ); } -NS_IMETHODIMP nsWebShellWindow::Confirm(const char *url, PRBool stripUrl, const PRUnichar *title, const PRUnichar *text, PRBool *_retval) +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 *url, PRBool stripUrl, const PRUnichar *title, const PRUnichar *text, PRUnichar **user, PRUnichar **pwd, PRBool *_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); + return PromptUsernameAndPassword(text, user, pwd, _retval); } nsCOMPtr prompter = this; - return wallet->PromptUsernameAndPasswordURL(text,user, pwd, url, stripUrl, prompter, _retval); + return wallet->PromptUsernameAndPassword(text, user, pwd, key, prompter, PR_TRUE, _retval); } -NS_IMETHODIMP nsWebShellWindow::PromptPassword(const char *url, PRBool stripUrl, const PRUnichar *title, const PRUnichar *text, PRUnichar **pwd, PRBool *_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); @@ -1953,10 +2229,10 @@ NS_IMETHODIMP nsWebShellWindow::PromptPassword(const char *url, PRBool stripUrl, return PromptPassword(text, title, pwd, _retval); } nsCOMPtr prompter = this; - return wallet->PromptPasswordURL(text, pwd, url, stripUrl, prompter, _retval); + return wallet->PromptPassword(text, pwd, key, prompter, PR_TRUE, _retval); } -NS_IMETHODIMP nsWebShellWindow::Prompt(const char *url, PRBool stripUrl, const PRUnichar *title, const PRUnichar *text, PRUnichar **value, PRBool *_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); @@ -1964,5 +2240,11 @@ NS_IMETHODIMP nsWebShellWindow::Prompt(const char *url, PRBool stripUrl, const P return Prompt(text, title, value, _retval); } nsCOMPtr prompter = this; - return wallet->PromptURL(text, nsnull, value, url, stripUrl, prompter, _retval); + return wallet->Prompt(text, nsnull, value, key, prompter, _retval); } + +#endif + + + + diff --git a/xpfe/appshell/src/nsWebShellWindow.h b/xpfe/appshell/src/nsWebShellWindow.h index 059b29ffe1a6..0bf4532ed686 100644 --- a/xpfe/appshell/src/nsWebShellWindow.h +++ b/xpfe/appshell/src/nsWebShellWindow.h @@ -34,7 +34,6 @@ #include "nsITimer.h" #include "nsIPrompt.h" -#include "nsINetPrompt.h" // can't use forward class decl's because of template bugs on Solaris #include "nsIDOMDocument.h" #include "nsIDOMNode.h" @@ -62,9 +61,7 @@ class nsWebShellWindow : public nsXULWindow, public nsIWebShellWindow, public nsIWebShellContainer, public nsIDocumentLoaderObserver, - public nsIDocumentObserver, - public nsIPrompt, - public nsINetPrompt + public nsIDocumentObserver { public: @@ -90,6 +87,7 @@ public: NS_IMETHOD GetWidget(nsIWidget *& aWidget); NS_IMETHOD GetDOMWindow(nsIDOMWindow** aDOMWindow); NS_IMETHOD ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindow** aDOMWindow); + NS_IMETHOD GetPrompter(nsIPrompt* *result); // nsWebShellWindow methods... nsresult Initialize(nsIXULWindow * aParent, nsIAppShell* aShell, nsIURI* aUrl, PRBool aCreatedVisible, PRBool aLoadDefaultPage, @@ -167,11 +165,6 @@ public: // nsIBaseWindow NS_IMETHOD Destroy(); - // nsIPrompt - NS_DECL_NSIPROMPT - - // nsINetPrompt - NS_DECL_NSINETPROMPT protected: void LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow); @@ -206,6 +199,7 @@ protected: nsCOMPtr mSPTimer; PRBool mSPTimerSize, mSPTimerPosition; PRLock * mSPTimerLock; + nsCOMPtr mPrompter; void SetPersistenceTimer(PRBool aSize, PRBool aPosition); static void FirePersistenceTimer(nsITimer *aTimer, void *aClosure); diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp index 50a8bf9633e9..fa701520d06b 100644 --- a/xpfe/appshell/src/nsXULWindow.cpp +++ b/xpfe/appshell/src/nsXULWindow.cpp @@ -101,8 +101,16 @@ NS_INTERFACE_MAP_END NS_IMETHODIMP nsXULWindow::GetInterface(const nsIID& aIID, void** aSink) { + nsresult rv; NS_ENSURE_ARG_POINTER(aSink); + if (aIID.Equals(NS_GET_IID(nsIPrompt))) { + // XXX until nsIWebShellWindow goes away: + nsCOMPtr webShellWin = + do_QueryInterface(NS_STATIC_CAST(nsIXULWindow*, this), &rv); + if (NS_FAILED(rv)) return rv; + return webShellWin->GetPrompter((nsIPrompt**)aSink); + } if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome)) && NS_SUCCEEDED(EnsureContentTreeOwner()) && NS_SUCCEEDED(mContentTreeOwner->QueryInterface(aIID, aSink))) diff --git a/xpfe/components/bookmarks/src/nsBookmarksService.cpp b/xpfe/components/bookmarks/src/nsBookmarksService.cpp index b9bbfe17b93b..98d3ce2caea5 100644 --- a/xpfe/components/bookmarks/src/nsBookmarksService.cpp +++ b/xpfe/components/bookmarks/src/nsBookmarksService.cpp @@ -2644,8 +2644,8 @@ nsBookmarksService::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsAutoString stopOption; getLocaleString("WebPageAskStopOption", stopOption); PRBool stopCheckingFlag = PR_FALSE; - rv = dialog->ConfirmCheck(promptStr.GetUnicode(), stopOption.GetUnicode(), - &stopCheckingFlag, &openURLFlag); + rv = dialog->ConfirmCheck(nsnull, promptStr.GetUnicode(), stopOption.GetUnicode(), + &stopCheckingFlag, &openURLFlag); if (NS_FAILED(rv)) { openURLFlag = PR_FALSE; diff --git a/xpinstall/src/nsInstall.cpp b/xpinstall/src/nsInstall.cpp index 09251a83e5ad..fcc5e59bb167 100644 --- a/xpinstall/src/nsInstall.cpp +++ b/xpinstall/src/nsInstall.cpp @@ -2393,7 +2393,7 @@ nsInstall::Alert(nsString& string) if (NS_FAILED(res)) return res; - return dialog->Alert(string.GetUnicode()); + return dialog->Alert(nsnull, string.GetUnicode()); } PRInt32 @@ -2406,7 +2406,7 @@ nsInstall::Confirm(nsString& string, PRBool* aReturn) if (NS_FAILED(res)) return res; - return dialog->Confirm(string.GetUnicode(), aReturn); + return dialog->Confirm(nsnull, string.GetUnicode(), aReturn); } diff --git a/xpinstall/src/nsXPInstallManager.cpp b/xpinstall/src/nsXPInstallManager.cpp index 36939478a71c..515d05b34a29 100644 --- a/xpinstall/src/nsXPInstallManager.cpp +++ b/xpinstall/src/nsXPInstallManager.cpp @@ -335,7 +335,8 @@ PRBool nsXPInstallManager::ConfirmChromeInstall() NS_WITH_SERVICE(nsIPrompt, dlgService, kNetSupportDialogCID, &rv); if (NS_SUCCEEDED(rv)) { - rv = dlgService->ConfirmCheck( confirmText, + rv = dlgService->ConfirmCheck( nsnull, + confirmText, applyNowText, &mSelectChrome, &bInstall );