bug 44146, parent window for modal dialogs, r=dveditz

This commit is contained in:
morse%netscape.com 2000-07-19 21:10:03 +00:00
Родитель cc2b1c2b5d
Коммит 4cb24c2203
8 изменённых файлов: 52 добавлений и 12 удалений

Просмотреть файл

@ -57,6 +57,7 @@ interface nsIWalletService : nsISupports {
[noscript]void WALLET_PrefillReturn(in nsAutoString results);
void WALLET_FetchFromNetCenter();
boolean WALLET_ExpirePassword();
void WALLET_InitReencryptCallback(in nsIDOMWindow win);
void SI_RemoveUser(in string key, in wstring userName);
void SI_StorePassword(in string key, in wstring userName, in wstring pwd);

Просмотреть файл

@ -113,6 +113,12 @@ NS_IMETHODIMP nsWalletlibService::WALLET_ExpirePassword(PRBool* status){
return NS_OK;
}
NS_IMETHODIMP nsWalletlibService::WALLET_InitReencryptCallback(nsIDOMWindow* window){
/* register callback to be used when encryption pref changes */
::WLLT_InitReencryptCallback(window);
return NS_OK;
}
NS_IMETHODIMP nsWalletlibService::SI_RemoveUser(const char *key, const PRUnichar *userName) {
::SINGSIGN_RemoveUser(key, userName);
return NS_OK;
@ -191,8 +197,6 @@ void nsWalletlibService::Init()
nsServiceManager::ReleaseService(kDocLoaderServiceCID, docLoaderService );
}
/* register callback to be used when encryption pref changes */
::WLLT_InitReencryptCallback();
}
NS_IMETHODIMP

Просмотреть файл

@ -146,6 +146,15 @@ SI_RegisterCallback(const char* domain, PrefChangedFunc callback, void* instance
}
}
PUBLIC void
SI_UnregisterCallback(const char* domain, PrefChangedFunc callback, void* instance_data) {
nsresult ret;
nsCOMPtr<nsIPref> pPrefService = do_GetService(kPrefServiceCID, &ret);
if (!NS_FAILED(ret)) {
ret = pPrefService->UnregisterCallback(domain, callback, instance_data);
}
}
PUBLIC void
SI_SetBoolPref(const char * prefname, PRBool prefvalue) {
nsresult ret;

Просмотреть файл

@ -87,6 +87,9 @@ SINGSIGN_HaveData(nsIPrompt* dialog, const char* passwordRealm, const PRUnichar
extern void
SI_RegisterCallback(const char* domain, PrefChangedFunc callback, void* instance_data);
extern void
SI_UnregisterCallback(const char* domain, PrefChangedFunc callback, void* instance_data);
extern PRBool
SI_GetBoolPref(const char * prefname, PRBool defaultvalue);

Просмотреть файл

@ -2888,7 +2888,7 @@ WLLT_DeleteAll() {
}
MODULE_PRIVATE int PR_CALLBACK
wallet_ReencryptAll(const char * newpref, void * data) {
wallet_ReencryptAll(const char * newpref, void* window) {
PRUnichar * message;
/* prevent reentry for the case that the user doesn't supply correct master password */
@ -2897,6 +2897,9 @@ wallet_ReencryptAll(const char * newpref, void * data) {
return 0; /* this is PREF_NOERROR but we no longer include prefapi.h */
}
level ++;
PRInt32 count = LIST_COUNT(wallet_SchemaToValue_list);
PRInt32 i = 0;
nsAutoString value;
/* logout first so there is no conversion unless user knows the master password */
if (!changingPassword) {
@ -2904,13 +2907,14 @@ if (!changingPassword) {
if (NS_SUCCEEDED(rv)) {
rv = gSecretDecoderRing->Logout();
}
if (NS_FAILED(rv)) {
goto fail;
}
wallet_Initialize(PR_FALSE);
}
wallet_MapElement * ptr;
nsAutoString value;
PRInt32 count = LIST_COUNT(wallet_SchemaToValue_list);
gEncryptionFailure = PR_FALSE;
for (PRInt32 i=0; i<count && !gEncryptionFailure; i++) {
for (i=0; i<count && !gEncryptionFailure; i++) {
ptr = NS_STATIC_CAST(wallet_MapElement*, wallet_SchemaToValue_list->ElementAt(i));
if (!ptr->item2.IsEmpty()) {
if (NS_FAILED(Wallet_Decrypt(ptr->item2, value))) {
@ -2952,7 +2956,7 @@ if (!changingPassword) {
SI_SetBoolPref(pref_Crypto, SI_GetBoolPref(pref_Crypto, PR_TRUE));
// message = Wallet_Localize("Converted");
//????? Wallet_Alert(message);
// Wallet_Alert(message, (nsIDOMWindow *)window);
// Recycle(message);
level--;
return 0; /* this is PREF_NOERROR but we no longer include prefapi.h */
@ -2962,15 +2966,22 @@ fail:
/* alert the user to the failure */
message = Wallet_Localize("NotConverted");
//????? Wallet_Alert(message);
Wallet_Alert(message, (nsIDOMWindow *)window);
Recycle(message);
level--;
return 1;
}
PUBLIC void
WLLT_InitReencryptCallback() {
SI_RegisterCallback(pref_Crypto, wallet_ReencryptAll, NULL);
WLLT_InitReencryptCallback(nsIDOMWindow* window) {
static PRBool registered = PR_FALSE;
static nsIDOMWindow* lastWindow;
if (registered) {
SI_UnregisterCallback(pref_Crypto, wallet_ReencryptAll, lastWindow);
}
SI_RegisterCallback(pref_Crypto, wallet_ReencryptAll, window);
lastWindow = window;
registered = PR_TRUE;
}
/*

Просмотреть файл

@ -84,7 +84,7 @@ extern void
WLLT_ExpirePassword(PRBool* status);
extern void
WLLT_InitReencryptCallback();
WLLT_InitReencryptCallback(nsIDOMWindow* window);
extern nsresult
Wallet_Encrypt(const nsString& text, nsString& crypt);

Просмотреть файл

@ -298,6 +298,10 @@ function WalletAction( action )
}
if (action == "encrypt" || action == "obscure") {
wallet = Components.classes['component://netscape/wallet/wallet-service'];
wallet = wallet.getService();
wallet = wallet.QueryInterface(Components.interfaces.nsIWalletService);
wallet.WALLET_InitReencryptCallback(window._content);
if (action == "encrypt") {
this.pref.SetBoolPref("wallet.crypto", true);
} else if (action == "obscure") {

Просмотреть файл

@ -60,6 +60,14 @@
wallet.WALLET_ChangePassword();
}
function initReencryptCallback()
{
wallet = Components.classes['component://netscape/wallet/wallet-service'];
wallet = wallet.getService();
wallet = wallet.QueryInterface(Components.interfaces.nsIWalletService);
wallet.WALLET_InitReencryptCallback(window);
}
]]>
</script>
@ -100,7 +108,7 @@
<html flex="1">&encryptDescription.label;</html>
<checkbox id="encryptEnabled" value="&encryptEnabled.label;" accesskey="&encryptEnabled.accesskey;"
pref="true" preftype="bool" prefstring="wallet.crypto"
prefattribute="checked"/>
prefattribute="checked" oncommand="initReencryptCallback();"/>
</titledbox>