diff --git a/extensions/wallet/public/nsIWalletService.idl b/extensions/wallet/public/nsIWalletService.idl index 80077aa3fe9f..89ee377f884e 100644 --- a/extensions/wallet/public/nsIWalletService.idl +++ b/extensions/wallet/public/nsIWalletService.idl @@ -49,13 +49,13 @@ native nsAutoString(nsAutoString); interface nsIWalletService : nsISupports { [noscript]void WALLET_PreEdit(in nsAutoStringRef walletList); [noscript]void WALLET_PostEdit(in nsAutoString walletList); - void WALLET_ChangePassword(); + boolean WALLET_ChangePassword(); void WALLET_DeleteAll(); - void WALLET_RequestToCapture(in nsIPresShell shell); - void WALLET_Prefill(in nsIPresShell shell, in boolean quick); + PRUint32 WALLET_RequestToCapture(in nsIPresShell shell); + boolean WALLET_Prefill(in nsIPresShell shell, in boolean quick); [noscript]void WALLET_PrefillReturn(in nsAutoString results); void WALLET_FetchFromNetCenter(); - void WALLET_ExpirePassword(); + boolean WALLET_ExpirePassword(); void SI_RemoveUser(in string key, in wstring userName); void SI_StorePassword(in string key, in wstring userName, in wstring pwd); diff --git a/extensions/wallet/src/nsWalletService.cpp b/extensions/wallet/src/nsWalletService.cpp index c1218bea2e12..16c30dd795ba 100644 --- a/extensions/wallet/src/nsWalletService.cpp +++ b/extensions/wallet/src/nsWalletService.cpp @@ -79,8 +79,8 @@ NS_IMETHODIMP nsWalletlibService::WALLET_PostEdit(nsAutoString walletList) { return NS_OK; } -NS_IMETHODIMP nsWalletlibService::WALLET_ChangePassword() { - ::WLLT_ChangePassword(); +NS_IMETHODIMP nsWalletlibService::WALLET_ChangePassword(PRBool* status) { + ::WLLT_ChangePassword(status); return NS_OK; } @@ -89,13 +89,13 @@ NS_IMETHODIMP nsWalletlibService::WALLET_DeleteAll() { return NS_OK; } -NS_IMETHODIMP nsWalletlibService::WALLET_RequestToCapture(nsIPresShell* shell) { - ::WLLT_RequestToCapture(shell); +NS_IMETHODIMP nsWalletlibService::WALLET_RequestToCapture(nsIPresShell* shell, PRUint32* status) { + ::WLLT_RequestToCapture(shell, status); return NS_OK; } -NS_IMETHODIMP nsWalletlibService::WALLET_Prefill(nsIPresShell* shell, PRBool quick) { - return ::WLLT_Prefill(shell, quick); +NS_IMETHODIMP nsWalletlibService::WALLET_Prefill(nsIPresShell* shell, PRBool quick, PRBool* doPrefillMessage) { + return ::WLLT_Prefill(shell, quick, doPrefillMessage); } NS_IMETHODIMP nsWalletlibService::WALLET_PrefillReturn(nsAutoString results){ @@ -108,8 +108,8 @@ NS_IMETHODIMP nsWalletlibService::WALLET_FetchFromNetCenter(){ return NS_OK; } -NS_IMETHODIMP nsWalletlibService::WALLET_ExpirePassword(){ - ::WLLT_ExpirePassword(); +NS_IMETHODIMP nsWalletlibService::WALLET_ExpirePassword(PRBool* status){ + ::WLLT_ExpirePassword(status); return NS_OK; } diff --git a/extensions/wallet/src/wallet.cpp b/extensions/wallet/src/wallet.cpp index 9537920523a4..892fe15f57b0 100644 --- a/extensions/wallet/src/wallet.cpp +++ b/extensions/wallet/src/wallet.cpp @@ -1061,36 +1061,25 @@ PRIVATE nsresult DecryptString (const char * crypt, char *& text) { } PUBLIC void -WLLT_ExpirePassword() { +WLLT_ExpirePassword(PRBool* status) { nsresult rv = wallet_CryptSetup(); if (NS_SUCCEEDED(rv)) { rv = gSecretDecoderRing->Logout(); } - PRUnichar * message; - if (NS_FAILED(rv)) { - message = Wallet_Localize("PasswordNotExpired"); - } else { - message = Wallet_Localize("PasswordExpired"); - } - Wallet_Alert(message); - Recycle(message); + *status = NS_SUCCEEDED(rv); } PRBool changingPassword = PR_FALSE; -PUBLIC -void WLLT_ChangePassword() { +PUBLIC void +WLLT_ChangePassword(PRBool* status) { nsresult rv = wallet_CryptSetup(); if (NS_SUCCEEDED(rv)) { changingPassword = PR_TRUE; rv = gSecretDecoderRing->ChangePassword(); changingPassword = PR_FALSE; } - if (NS_FAILED(rv)) { - PRUnichar * message = Wallet_Localize("PasswordNotChanged"); - Wallet_Alert(message); - Recycle(message); - } + *status = NS_SUCCEEDED(rv); } PUBLIC nsresult @@ -2873,16 +2862,11 @@ WLLT_PreEdit(nsString& walletList) PUBLIC void WLLT_DeleteAll() { - PRUnichar * message; - message = Wallet_Localize("AllDataWillBeCleared"); - if (Wallet_Confirm(message)) { - wallet_Initialize(PR_FALSE); - wallet_Clear(&wallet_SchemaToValue_list); - wallet_WriteToFile(schemaValueFileName, wallet_SchemaToValue_list); - SI_DeleteAll(); - SI_SetBoolPref(pref_Crypto, PR_FALSE); - } - Recycle(message); + wallet_Initialize(PR_FALSE); + wallet_Clear(&wallet_SchemaToValue_list); + wallet_WriteToFile(schemaValueFileName, wallet_SchemaToValue_list); + SI_DeleteAll(); + SI_SetBoolPref(pref_Crypto, PR_FALSE); } MODULE_PRIVATE int PR_CALLBACK @@ -3102,9 +3086,10 @@ WLLT_PrefillReturn(const nsString& results) * get the form elements on the current page and prefill them if possible */ PUBLIC nsresult -WLLT_Prefill(nsIPresShell* shell, PRBool quick) +WLLT_Prefill(nsIPresShell* shell, PRBool quick, PRBool* doPrefillMessage) { nsAutoString urlName; + *doPrefillMessage = PR_FALSE; /* create list of elements that can be prefilled */ nsVoidArray *wallet_PrefillElement_list=new nsVoidArray(); @@ -3210,11 +3195,7 @@ WLLT_Prefill(nsIPresShell* shell, PRBool quick) /* return if no elements were put into the list */ if (LIST_COUNT(wallet_PrefillElement_list) == 0) { - if (!gEncryptionFailure) { - PRUnichar * message = Wallet_Localize("noPrefills"); - Wallet_Alert(message); - Recycle(message); - } + *doPrefillMessage = !gEncryptionFailure; return NS_ERROR_FAILURE; // indicates to caller not to display preview screen } @@ -3265,7 +3246,7 @@ WLLT_Prefill(nsIPresShell* shell, PRBool quick) } PUBLIC void -WLLT_RequestToCapture(nsIPresShell* shell) { +WLLT_RequestToCapture(nsIPresShell* shell, PRUint32* status) { /* starting with the present shell, get each form element and put them on a list */ nsresult result; PRInt32 captureCount = 0; @@ -3349,16 +3330,13 @@ WLLT_RequestToCapture(nsIPresShell* shell) { } } } - PRUnichar * message; if (gEncryptionFailure) { - message = Wallet_Localize("UnableToCapture"); + *status = -1; /* UnableToCapture */ } else if (captureCount) { - message = Wallet_Localize("Captured"); + *status = 0; /* Captured */ } else { - message = Wallet_Localize("NotCaptured"); + *status = +1; /* NotCaptured */ } - Wallet_Alert(message); - Recycle(message); } /* should move this to an include file */ diff --git a/extensions/wallet/src/wallet.h b/extensions/wallet/src/wallet.h index d94591830742..79360b46d677 100644 --- a/extensions/wallet/src/wallet.h +++ b/extensions/wallet/src/wallet.h @@ -45,7 +45,7 @@ XP_BEGIN_PROTOS static const char *pref_Crypto = "wallet.crypto"; extern void -WLLT_ChangePassword(); +WLLT_ChangePassword(PRBool* status); extern void WLLT_DeleteAll(); @@ -60,10 +60,10 @@ extern void WLLT_PrefillReturn(const nsString& results); extern void -WLLT_RequestToCapture(nsIPresShell* shell); +WLLT_RequestToCapture(nsIPresShell* shell, PRUint32* status); extern nsresult -WLLT_Prefill(nsIPresShell* shell, PRBool quick); +WLLT_Prefill(nsIPresShell* shell, PRBool quick, PRBool* doPrefillMessage); extern void WLLT_GetNopreviewListForViewer(nsString& aNopreviewList); @@ -81,7 +81,7 @@ extern void WLLT_FetchFromNetCenter(); extern void -WLLT_ExpirePassword(); +WLLT_ExpirePassword(PRBool* status); extern void WLLT_InitReencryptCallback(); diff --git a/webshell/tests/viewer/nsBrowserWindow.cpp b/webshell/tests/viewer/nsBrowserWindow.cpp index f14cfc3c45ff..02c49f365a43 100644 --- a/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/webshell/tests/viewer/nsBrowserWindow.cpp @@ -982,7 +982,7 @@ nsBrowserWindow::DispatchMenuItem(PRInt32 aID) (nsISupports **)&walletservice); if ((NS_OK == res) && (nsnull != walletservice)) { nsString urlString2; - res = walletservice->WALLET_Prefill(shell, (PRVCY_QPREFILL == aID)); +// res = walletservice->WALLET_Prefill(shell, (PRVCY_QPREFILL == aID)); NS_RELEASE(walletservice); } diff --git a/xpfe/browser/public/nsIBrowserInstance.idl b/xpfe/browser/public/nsIBrowserInstance.idl index 118ef2715cff..68fc2f61dbe6 100644 --- a/xpfe/browser/public/nsIBrowserInstance.idl +++ b/xpfe/browser/public/nsIBrowserInstance.idl @@ -47,11 +47,11 @@ interface nsIBrowserInstance : nsISupports { void updateGoMenu(in nsIDOMNode goMenu); // Wallet (should reside elsewhere, somehow). - void walletPreview(in nsIDOMWindow win, in nsIDOMWindow form); + boolean walletPreview(in nsIDOMWindow win, in nsIDOMWindow form); - void walletChangePassword(); - void walletQuickFillin(in nsIDOMWindow win); - void walletRequestToCapture(in nsIDOMWindow win); + boolean walletChangePassword(); + boolean walletQuickFillin(in nsIDOMWindow win); + PRUint32 walletRequestToCapture(in nsIDOMWindow win); // Infrastructure. diff --git a/xpfe/browser/src/nsBrowserInstance.cpp b/xpfe/browser/src/nsBrowserInstance.cpp index 9542c678663e..6351313aa27d 100644 --- a/xpfe/browser/src/nsBrowserInstance.cpp +++ b/xpfe/browser/src/nsBrowserInstance.cpp @@ -809,7 +809,7 @@ nsBrowserInstance::GotoHistoryIndex(PRInt32 aIndex) } NS_IMETHODIMP -nsBrowserInstance::WalletPreview(nsIDOMWindow* aWin, nsIDOMWindow* aForm) +nsBrowserInstance::WalletPreview(nsIDOMWindow* aWin, nsIDOMWindow* aForm, PRBool* doPrefillMessage) { NS_PRECONDITION(aForm != nsnull, "null ptr"); if (! aForm) @@ -828,7 +828,7 @@ nsBrowserInstance::WalletPreview(nsIDOMWindow* aWin, nsIDOMWindow* aForm) kIWalletServiceIID, (nsISupports **)&walletservice); if (NS_SUCCEEDED(res) && (nsnull != walletservice)) { - res = walletservice->WALLET_Prefill(presShell, PR_FALSE); + res = walletservice->WALLET_Prefill(presShell, PR_FALSE, doPrefillMessage); nsServiceManager::ReleaseService(kWalletServiceCID, walletservice); if (NS_FAILED(res)) { /* this just means that there was nothing to prefill */ return NS_OK; @@ -863,7 +863,7 @@ nsBrowserInstance::WalletPreview(nsIDOMWindow* aWin, nsIDOMWindow* aForm) } NS_IMETHODIMP -nsBrowserInstance::WalletChangePassword() +nsBrowserInstance::WalletChangePassword(PRBool* status) { nsIWalletService *walletservice; nsresult res; @@ -871,7 +871,7 @@ nsBrowserInstance::WalletChangePassword() kIWalletServiceIID, (nsISupports **)&walletservice); if ((NS_OK == res) && (nsnull != walletservice)) { - res = walletservice->WALLET_ChangePassword(); + res = walletservice->WALLET_ChangePassword(status); nsServiceManager::ReleaseService(kWalletServiceCID, walletservice); } return NS_OK; @@ -880,7 +880,7 @@ nsBrowserInstance::WalletChangePassword() #include "nsIDOMHTMLDocument.h" static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID); NS_IMETHODIMP -nsBrowserInstance::WalletQuickFillin(nsIDOMWindow* aWin) +nsBrowserInstance::WalletQuickFillin(nsIDOMWindow* aWin, PRBool* doPrefillMessage) { NS_PRECONDITION(aWin != nsnull, "null ptr"); if (! aWin) @@ -900,7 +900,7 @@ nsBrowserInstance::WalletQuickFillin(nsIDOMWindow* aWin) kIWalletServiceIID, (nsISupports **)&walletservice); if ((NS_OK == res) && (nsnull != walletservice)) { - res = walletservice->WALLET_Prefill(presShell, PR_TRUE); + res = walletservice->WALLET_Prefill(presShell, PR_TRUE, doPrefillMessage); nsServiceManager::ReleaseService(kWalletServiceCID, walletservice); return NS_OK; } else { @@ -909,7 +909,7 @@ nsBrowserInstance::WalletQuickFillin(nsIDOMWindow* aWin) } NS_IMETHODIMP -nsBrowserInstance::WalletRequestToCapture(nsIDOMWindow* aWin) +nsBrowserInstance::WalletRequestToCapture(nsIDOMWindow* aWin, PRUint32* status) { NS_PRECONDITION(aWin != nsnull, "null ptr"); if (! aWin) @@ -929,7 +929,7 @@ nsBrowserInstance::WalletRequestToCapture(nsIDOMWindow* aWin) kIWalletServiceIID, (nsISupports **)&walletservice); if ((NS_OK == res) && (nsnull != walletservice)) { - res = walletservice->WALLET_RequestToCapture(presShell); + res = walletservice->WALLET_RequestToCapture(presShell, status); nsServiceManager::ReleaseService(kWalletServiceCID, walletservice); return NS_OK; } else { diff --git a/xpfe/communicator/resources/content/tasksOverlay.js b/xpfe/communicator/resources/content/tasksOverlay.js index 3a3647b1c24e..371139280953 100644 --- a/xpfe/communicator/resources/content/tasksOverlay.js +++ b/xpfe/communicator/resources/content/tasksOverlay.js @@ -273,17 +273,26 @@ function CheckForWalletAndImage() // perform a wallet action function WalletAction( action ) { + var strings = document.getElementById("strings"); if (action == "password" || action == "expire" || action == "clear") { wallet = Components.classes['component://netscape/wallet/wallet-service']; wallet = wallet.getService(); wallet = wallet.QueryInterface(Components.interfaces.nsIWalletService); if (action == "password") { - wallet.WALLET_ChangePassword(); + if (!wallet.WALLET_ChangePassword()) { + window.alert(strings.getAttribute("PasswordNotChanged")); + } } else if (action == "expire") { - wallet.WALLET_ExpirePassword(); + if (wallet.WALLET_ExpirePassword()) { + window.alert(strings.getAttribute("PasswordExpired")); + } else { + window.alert(strings.getAttribute("PasswordNotExpired")); + } } else if (action == "clear") { - wallet.WALLET_DeleteAll(); + if (window.confirm(strings.getAttribute("AllDataWillBeCleared"))) { + wallet.WALLET_DeleteAll(); + } } return; } @@ -331,17 +340,28 @@ function WalletAction( action ) if( appCore ) { switch( action ) { case "safefill": - appCore.walletPreview(window, window._content); + if (appCore.walletPreview(window, window._content)) { + window.alert(strings.getAttribute("noPrefills")); + } break; // case "password": // appCore.walletChangePassword(); // break; case "quickfill": - appCore.walletQuickFillin(window._content); + if (appCore.walletQuickFillin(window._content)) { + window.alert(strings.getAttribute("noPrefills")); + } break; case "capture": default: - appCore.walletRequestToCapture(window._content); + status = appCore.walletRequestToCapture(window._content); + if (status == -1) { /* UnableToCapture */ + window.alert(strings.getAttribute("UnableToCapture")); + } else if (status == 0) { /* Captured */ + window.alert(strings.getAttribute("Captured")); + } else if (status == +1) { /* NotCaptured */ + window.alert(strings.getAttribute("NotCaptured")); + } break; } } diff --git a/xpfe/communicator/resources/content/tasksOverlay.xul b/xpfe/communicator/resources/content/tasksOverlay.xul index 7720fdb17d16..451ec5710f51 100644 --- a/xpfe/communicator/resources/content/tasksOverlay.xul +++ b/xpfe/communicator/resources/content/tasksOverlay.xul @@ -38,7 +38,16 @@ - + diff --git a/xpfe/communicator/resources/locale/en-US/tasksOverlay.dtd b/xpfe/communicator/resources/locale/en-US/tasksOverlay.dtd index 4799259f234e..2f43f9531063 100644 --- a/xpfe/communicator/resources/locale/en-US/tasksOverlay.dtd +++ b/xpfe/communicator/resources/locale/en-US/tasksOverlay.dtd @@ -52,3 +52,11 @@ + + + + + + + +