diff --git a/extensions/wallet/editor/WalletEditor.js b/extensions/wallet/editor/WalletEditor.js index 8b87f2f9a3e..1bfe4664fe7 100644 --- a/extensions/wallet/editor/WalletEditor.js +++ b/extensions/wallet/editor/WalletEditor.js @@ -24,6 +24,7 @@ /* universal global variables */ var walleteditor = null; // walleteditor interface +var walletservice = null; // walletservices interface var walletList = []; // input stream var bundle = null; // string bundle var JS_STRINGS_FILE = "chrome://communicator/locale/wallet/WalletEditor.properties"; @@ -49,13 +50,49 @@ function ViewSynonymsFromXul(){ /*** =================== STARTING AND STOPPING =================== ***/ +/* decrypt a value */ +function Decrypt(crypt) { + try { + return walletservice.WALLET_Decrypt(crypt); + } catch (ex) { + return bundle.GetStringFromName("EncryptionFailure"); + } +} + +/* encrypt a value */ +function Encrypt(text) { + try { + return walletservice.WALLET_Encrypt(text); + } catch (ex) { + alert(bundle.GetStringFromName("UnableToUnlockDatabase")); + return ""; + } +} + +/* see if user was able to unlock the database */ +function EncryptionTest() { + try { + walletservice.WALLET_Encrypt("dummy"); + } catch (ex) { + alert(bundle.GetStringFromName("UnableToUnlockDatabase")); + window.close(); + } +} + /* initializes the wallet editor dialog */ function Startup() { walleteditor = Components.classes["component://netscape/walleteditor/walleteditor-world"].createInstance(); walleteditor = walleteditor.QueryInterface(Components.interfaces.nsIWalletEditor); + walletservice = Components.classes['component://netscape/wallet']; + walletservice = walletservice.getService(); + walletservice = walletservice.QueryInterface(Components.interfaces.nsIWalletService); + bundle = srGetStrBundle(JS_STRINGS_FILE); /* initialize string bundle */ + + EncryptionTest(); /* abort if user failed to unlock the database */ + if (!FetchInput()) { return; /* user failed to unlock the database */ } @@ -121,7 +158,7 @@ function FetchInput() } } } - entries[j] = stringsLength; + entries[j] = stringsLength-1; j = 0; for (i=0; i