diff --git a/extensions/wallet/public/nsIWalletService.h b/extensions/wallet/public/nsIWalletService.h index 5bd4cb5b6e4..1f6c5760650 100644 --- a/extensions/wallet/public/nsIWalletService.h +++ b/extensions/wallet/public/nsIWalletService.h @@ -58,6 +58,7 @@ struct nsIWalletService : public nsISupports NS_IMETHOD SI_GetRejectListForViewer(nsString& aRejectList)=0; NS_IMETHOD WALLET_GetNopreviewListForViewer(nsString& aNopreviewList)=0; NS_IMETHOD WALLET_GetNocaptureListForViewer(nsString& aNocaptureList)=0; + NS_IMETHOD WALLET_GetPrefillListForViewer(nsString& aPrefillList)=0; NS_IMETHOD SI_RememberSignonData (char* URLName, char** name_array, char** value_array, char** type_array, PRInt32 value_cnt) = 0; NS_IMETHOD SI_RestoreSignonData diff --git a/extensions/wallet/src/nsWalletService.cpp b/extensions/wallet/src/nsWalletService.cpp index b24c1529f62..c72082677f4 100644 --- a/extensions/wallet/src/nsWalletService.cpp +++ b/extensions/wallet/src/nsWalletService.cpp @@ -118,6 +118,11 @@ NS_IMETHODIMP nsWalletlibService::WALLET_GetNocaptureListForViewer(nsString& aNo return NS_OK; } +NS_IMETHODIMP nsWalletlibService::WALLET_GetPrefillListForViewer(nsString& aPrefillList){ + ::WLLT_GetPrefillListForViewer(aPrefillList); + return NS_OK; +} + NS_IMETHODIMP nsWalletlibService::SI_RememberSignonData (char* URLName, char** name_array, char** value_array, char** type_array, PRInt32 value_cnt) { ::SINGSIGN_RememberSignonData(URLName, name_array, value_array, type_array, value_cnt); diff --git a/extensions/wallet/src/nsWalletService.h b/extensions/wallet/src/nsWalletService.h index 51ae0fffe25..f5614003d34 100644 --- a/extensions/wallet/src/nsWalletService.h +++ b/extensions/wallet/src/nsWalletService.h @@ -43,6 +43,7 @@ public: NS_IMETHOD SI_GetRejectListForViewer(nsString& aRejectList); NS_IMETHOD WALLET_GetNopreviewListForViewer(nsString& aNopreviewList); NS_IMETHOD WALLET_GetNocaptureListForViewer(nsString& aNocaptureList); + NS_IMETHOD WALLET_GetPrefillListForViewer(nsString& aPrefillList); NS_IMETHOD SI_RememberSignonData (char* URLName, char** name_array, char** value_array, char** type_array, PRInt32 value_cnt); diff --git a/extensions/wallet/src/wallet.cpp b/extensions/wallet/src/wallet.cpp index 70b0dd86941..89f04109012 100644 --- a/extensions/wallet/src/wallet.cpp +++ b/extensions/wallet/src/wallet.cpp @@ -1604,6 +1604,42 @@ wallet_ReleasePrefillElementList(XP_List * wallet_PrefillElement_list) { } } +#define BUFLEN3 5000 +#define BREAK '\001' + +XP_List * wallet_list; +nsString wallet_url; + +PUBLIC void +WLLT_GetPrefillListForViewer(nsString& aPrefillList) +{ + char *buffer = (char*)XP_ALLOC(BUFLEN3); + int g = 0, prefillNum = 0; + XP_List *list_ptr = wallet_list; + wallet_PrefillElement * ptr; + buffer[0] = '\0'; + char * schema; + char * value; + + while((ptr = (wallet_PrefillElement *) XP_ListNextObject(list_ptr))!=0) { + schema = ptr->schema->ToNewCString(); + value = ptr->value->ToNewCString(); + g += PR_snprintf(buffer+g, BUFLEN3-g, + "%c%d%c%s%c%s", + BREAK, ptr->count, + BREAK, schema, + BREAK, value); + delete []schema; + delete []value; + } + char * urlCString; + urlCString = wallet_url.ToNewCString(); + g += PR_snprintf(buffer+g, BUFLEN3-g,"%c%ld%c%s", BREAK, wallet_list, BREAK, urlCString); + delete []urlCString; + aPrefillList = buffer; + PR_FREEIF(buffer); +} + #define BUFLEN 50000 extern void @@ -1631,6 +1667,7 @@ wallet_RequestToPrefill(XP_List * list, nsString url) { " title_frame = 1;\n" " list_frame = 2;\n" " button_frame = 3;\n" +" var prefillList = [];\n" "\n" ); @@ -1650,48 +1687,40 @@ wallet_RequestToPrefill(XP_List * list, nsString url) { " \"\" +\n" " \"\" +\n" " \"\" +\n" +" \"\" +\n" " \"\" +\n" -" \"\" +\n", - schema); - } - delete []schema; - delete []value; - } - - /* finish generating list of fillins */ - g += PR_snprintf(buffer+g, BUFLEN-g, +" \"\" \n" +" )\n" +" }\n" +" }\n" +" top.frames[list_frame].document.write(\n" " \"\" +\n" " \"\" +\n" " \"
\" +\n" -" \"
\" +\n", +" \"
\" \n" +" )\n", heading); PR_FREEIF(heading); /* generate the html for the list of fillins */ - wallet_PrefillElement * ptr; - XP_List * list_ptr = list; - PRUint32 count; - while((ptr = (wallet_PrefillElement *) XP_ListNextObject(list_ptr))!=0) { - char * schema; - schema = ptr->schema->ToNewCString(); - char * value; - value = ptr->value->ToNewCString(); - if (ptr->count) { - count = ptr->count; - g += PR_snprintf(buffer+g, BUFLEN-g, + g += PR_snprintf(buffer+g, BUFLEN-g, +" var count;\n" +" for (i=1; i\" +\n" -" \"
%s: \" + prefillList[i+1] + \": \" +\n" -" \"\" \n" +" )\n" +" count--;\n" +" }\n" +" top.frames[list_frame].document.write(\n" +" \"\" \n" +" )\n" +" if(count == 0) {\n" +" top.frames[list_frame].document.write(\n" +" \"\" +\n" " \"
\" +\n" " \"
\" +\n" @@ -1701,7 +1730,6 @@ wallet_RequestToPrefill(XP_List * list, nsString url) { " };\n" "\n" ); - PR_FREEIF(heading); /* generate rest of html */ char * skipMessage = Wallet_Localize("BypassThisScreen"); @@ -1722,7 +1750,7 @@ wallet_RequestToPrefill(XP_List * list, nsString url) { skipMessage); PR_FREEIF(skipMessage); - /* generate remainder of html, it will go into strings->arg[2] */ + /* generate remainder of html */ char * urlCString; urlCString = url.ToNewCString(); g += PR_snprintf(buffer+g, BUFLEN-g, @@ -1736,6 +1764,9 @@ wallet_RequestToPrefill(XP_List * list, nsString url) { "\n" " function loadFrames(){\n" " StartUp(\"Wallet\");\n" +" list = DoGetPrefillList();\n" +" BREAK = list[0];\n" +" prefillList = list.split(BREAK);\n" " loadFillins();\n" " loadButtons();\n" " }\n" @@ -1745,8 +1776,8 @@ wallet_RequestToPrefill(XP_List * list, nsString url) { " var list = top.frames[button_frame].document.buttons.list;\n" " var url = top.frames[button_frame].document.buttons.url;\n" " var skip = top.frames[button_frame].document.buttons.skip;\n" -" list.value = %ld;\n" -" url.value = \"%s\";\n" +" list.value = prefillList[prefillList.length-2];\n" +" url.value = \"prefillList[prefillList.length-1]\";\n" " var fillins = top.frames[button_frame].document.buttons.fillins;\n" " fillins.value = \"\";\n" " for (i=0; i
\n" "\n" "\n", - list, urlCString, SEPARATOR, SEPARATOR); + SEPARATOR, SEPARATOR); delete []urlCString; SI_MakeDialog(buffer); @@ -2343,6 +2374,8 @@ WLLT_Prefill(nsIPresShell* shell, nsString url, PRBool quick) { return NS_ERROR_FAILURE; // indicates to caller not to display preview screen } else { /* let user preview and verify the prefills first */ + wallet_list = wallet_PrefillElement_list; + wallet_url = url; wallet_RequestToPrefill(wallet_PrefillElement_list, url); #ifdef DEBUG wallet_DumpStopwatch(); diff --git a/extensions/wallet/src/wallet.h b/extensions/wallet/src/wallet.h index cdebb56bf4e..429cbe7d37e 100644 --- a/extensions/wallet/src/wallet.h +++ b/extensions/wallet/src/wallet.h @@ -57,6 +57,8 @@ WLLT_GetNopreviewListForViewer (nsString& aNopreviewList); extern void WLLT_GetNocaptureListForViewer (nsString& aNocaptureList); +extern void +WLLT_GetPrefillListForViewer (nsString& aPrefillList); XP_END_PROTOS diff --git a/xpfe/AppCores/idl/WalletCore.idl b/xpfe/AppCores/idl/WalletCore.idl index 5cd48f9128a..e69de29bb2d 100644 --- a/xpfe/AppCores/idl/WalletCore.idl +++ b/xpfe/AppCores/idl/WalletCore.idl @@ -1,14 +0,0 @@ -interface WalletCore : BaseAppCore -{ - void WalletCore(); - - void ShowWindow(in Window currentFrontWin, in Window form); - - void ChangePanel(in wstring url); - void PanelLoaded(in Window win); - - void SaveWallet(in wstring results); - void CancelWallet(); -}; - - diff --git a/xpfe/AppCores/public/nsIDOMWalletCore.h b/xpfe/AppCores/public/nsIDOMWalletCore.h index a0bfebaf844..e69de29bb2d 100644 --- a/xpfe/AppCores/public/nsIDOMWalletCore.h +++ b/xpfe/AppCores/public/nsIDOMWalletCore.h @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ -/* AUTO-GENERATED. DO NOT EDIT!!! */ - -#ifndef nsIDOMWalletCore_h__ -#define nsIDOMWalletCore_h__ - -#include "nsISupports.h" -#include "nsString.h" -#include "nsIScriptContext.h" -#include "nsIDOMBaseAppCore.h" - -class nsIDOMWindow; - -#define NS_IDOMWALLETCORE_IID \ - { 0x9d6e2540, 0x108b, 0x11d3,\ - { 0xab, 0xa3, 0x0, 0x80, 0xc7, 0x87, 0xad, 0x96 }}; - -class nsIDOMWalletCore : public nsIDOMBaseAppCore { -public: - static const nsIID& GetIID() { static nsIID iid = NS_IDOMWALLETCORE_IID; return iid; } - - NS_IMETHOD ShowWindow(nsIDOMWindow* aCurrentFrontWin, nsIDOMWindow* aForm)=0; - - NS_IMETHOD ChangePanel(const nsString& aUrl)=0; - - NS_IMETHOD PanelLoaded(nsIDOMWindow* aWin)=0; - - NS_IMETHOD SaveWallet(const nsString& aResults)=0; - - NS_IMETHOD CancelWallet()=0; -}; - - -#define NS_DECL_IDOMWALLETCORE \ - NS_IMETHOD ShowWindow(nsIDOMWindow* aCurrentFrontWin, nsIDOMWindow* aForm); \ - NS_IMETHOD ChangePanel(const nsString& aUrl); \ - NS_IMETHOD PanelLoaded(nsIDOMWindow* aWin); \ - NS_IMETHOD SaveWallet(const nsString& aResults); \ - NS_IMETHOD CancelWallet(); \ - - - -#define NS_FORWARD_IDOMWALLETCORE(_to) \ - NS_IMETHOD ShowWindow(nsIDOMWindow* aCurrentFrontWin, nsIDOMWindow* aForm) { return _to ShowWindow(aCurrentFrontWin, aForm); } \ - NS_IMETHOD ChangePanel(const nsString& aUrl) { return _to ChangePanel(aUrl); } \ - NS_IMETHOD PanelLoaded(nsIDOMWindow* aWin) { return _to PanelLoaded(aWin); } \ - NS_IMETHOD SaveWallet(const nsString& aResults) { return _to SaveWallet(aResults); } \ - NS_IMETHOD CancelWallet() { return _to CancelWallet(); } \ - - -extern "C" NS_DOM nsresult NS_InitWalletCoreClass(nsIScriptContext *aContext, void **aPrototype); - -extern "C" NS_DOM nsresult NS_NewScriptWalletCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); - -#endif // nsIDOMWalletCore_h__ diff --git a/xpfe/AppCores/src/nsJSWalletCore.cpp b/xpfe/AppCores/src/nsJSWalletCore.cpp index b8dcc40e6f0..e69de29bb2d 100644 --- a/xpfe/AppCores/src/nsJSWalletCore.cpp +++ b/xpfe/AppCores/src/nsJSWalletCore.cpp @@ -1,531 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. - */ -/* AUTO-GENERATED. DO NOT EDIT!!! */ - -#include "jsapi.h" -#include "nsJSUtils.h" -#include "nscore.h" -#include "nsIScriptContext.h" -#include "nsIJSScriptObject.h" -#include "nsIScriptObjectOwner.h" -#include "nsIScriptGlobalObject.h" -#include "nsIPtr.h" -#include "nsString.h" -#include "nsIDOMWalletCore.h" -#include "nsIDOMWindow.h" -#include "nsIScriptNameSpaceManager.h" -#include "nsIComponentManager.h" -#include "nsIJSNativeInitializer.h" -#include "nsDOMCID.h" - - -static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); -static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); -static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); -static NS_DEFINE_IID(kIWalletCoreIID, NS_IDOMWALLETCORE_IID); -static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID); - -NS_DEF_PTR(nsIDOMWalletCore); -NS_DEF_PTR(nsIDOMWindow); - - -/***********************************************************************/ -// -// WalletCore Properties Getter -// -PR_STATIC_CALLBACK(JSBool) -GetWalletCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) -{ - nsIDOMWalletCore *a = (nsIDOMWalletCore*)JS_GetPrivate(cx, obj); - - // If there's no private data, this must be the prototype, so ignore - if (nsnull == a) { - return JS_TRUE; - } - - if (JSVAL_IS_INT(id)) { - switch(JSVAL_TO_INT(id)) { - case 0: - default: - return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); - } - } - else { - return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); - } - - return PR_TRUE; -} - -/***********************************************************************/ -// -// WalletCore Properties Setter -// -PR_STATIC_CALLBACK(JSBool) -SetWalletCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) -{ - nsIDOMWalletCore *a = (nsIDOMWalletCore*)JS_GetPrivate(cx, obj); - - // If there's no private data, this must be the prototype, so ignore - if (nsnull == a) { - return JS_TRUE; - } - - if (JSVAL_IS_INT(id)) { - switch(JSVAL_TO_INT(id)) { - case 0: - default: - return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp); - } - } - else { - return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp); - } - - return PR_TRUE; -} - - -// -// WalletCore finalizer -// -PR_STATIC_CALLBACK(void) -FinalizeWalletCore(JSContext *cx, JSObject *obj) -{ - nsJSUtils::nsGenericFinalize(cx, obj); -} - - -// -// WalletCore enumerate -// -PR_STATIC_CALLBACK(JSBool) -EnumerateWalletCore(JSContext *cx, JSObject *obj) -{ - return nsJSUtils::nsGenericEnumerate(cx, obj); -} - - -// -// WalletCore resolve -// -PR_STATIC_CALLBACK(JSBool) -ResolveWalletCore(JSContext *cx, JSObject *obj, jsval id) -{ - return nsJSUtils::nsGenericResolve(cx, obj, id); -} - - -// -// Native method ShowWindow -// -PR_STATIC_CALLBACK(JSBool) -WalletCoreShowWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMWalletCore *nativeThis = (nsIDOMWalletCore*)JS_GetPrivate(cx, obj); - JSBool rBool = JS_FALSE; - nsIDOMWindowPtr b0; - nsIDOMWindowPtr b1; - - *rval = JSVAL_NULL; - - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - if (argc >= 2) { - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, - kIWindowIID, - "Window", - cx, - argv[0])) { - return JS_FALSE; - } - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1, - kIWindowIID, - "Window", - cx, - argv[1])) { - return JS_FALSE; - } - - if (NS_OK != nativeThis->ShowWindow(b0, b1)) { - return JS_FALSE; - } - - *rval = JSVAL_VOID; - } - else { - JS_ReportError(cx, "Function ShowWindow requires 2 parameters"); - return JS_FALSE; - } - - return JS_TRUE; -} - - -// -// Native method ChangePanel -// -PR_STATIC_CALLBACK(JSBool) -WalletCoreChangePanel(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMWalletCore *nativeThis = (nsIDOMWalletCore*)JS_GetPrivate(cx, obj); - JSBool rBool = JS_FALSE; - nsAutoString b0; - - *rval = JSVAL_NULL; - - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - if (argc >= 1) { - - nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); - - if (NS_OK != nativeThis->ChangePanel(b0)) { - return JS_FALSE; - } - - *rval = JSVAL_VOID; - } - else { - JS_ReportError(cx, "Function ChangePanel requires 1 parameters"); - return JS_FALSE; - } - - return JS_TRUE; -} - - -// -// Native method PanelLoaded -// -PR_STATIC_CALLBACK(JSBool) -WalletCorePanelLoaded(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMWalletCore *nativeThis = (nsIDOMWalletCore*)JS_GetPrivate(cx, obj); - JSBool rBool = JS_FALSE; - nsIDOMWindowPtr b0; - - *rval = JSVAL_NULL; - - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - if (argc >= 1) { - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, - kIWindowIID, - "Window", - cx, - argv[0])) { - return JS_FALSE; - } - - if (NS_OK != nativeThis->PanelLoaded(b0)) { - return JS_FALSE; - } - - *rval = JSVAL_VOID; - } - else { - JS_ReportError(cx, "Function PanelLoaded requires 1 parameters"); - return JS_FALSE; - } - - return JS_TRUE; -} - - -// -// Native method SaveWallet -// -PR_STATIC_CALLBACK(JSBool) -WalletCoreSaveWallet(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMWalletCore *nativeThis = (nsIDOMWalletCore*)JS_GetPrivate(cx, obj); - JSBool rBool = JS_FALSE; - nsAutoString b0; - - *rval = JSVAL_NULL; - - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - if (argc >= 1) { - - nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); - - if (NS_OK != nativeThis->SaveWallet(b0)) { - return JS_FALSE; - } - - *rval = JSVAL_VOID; - } - else { - JS_ReportError(cx, "Function SaveWallet requires 1 parameters"); - return JS_FALSE; - } - - return JS_TRUE; -} - - -// -// Native method CancelWallet -// -PR_STATIC_CALLBACK(JSBool) -WalletCoreCancelWallet(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMWalletCore *nativeThis = (nsIDOMWalletCore*)JS_GetPrivate(cx, obj); - JSBool rBool = JS_FALSE; - - *rval = JSVAL_NULL; - - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - if (argc >= 0) { - - if (NS_OK != nativeThis->CancelWallet()) { - return JS_FALSE; - } - - *rval = JSVAL_VOID; - } - else { - JS_ReportError(cx, "Function CancelWallet requires 0 parameters"); - return JS_FALSE; - } - - return JS_TRUE; -} - - -/***********************************************************************/ -// -// class for WalletCore -// -JSClass WalletCoreClass = { - "WalletCore", - JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS, - JS_PropertyStub, - JS_PropertyStub, - GetWalletCoreProperty, - SetWalletCoreProperty, - EnumerateWalletCore, - ResolveWalletCore, - JS_ConvertStub, - FinalizeWalletCore -}; - - -// -// WalletCore class properties -// -static JSPropertySpec WalletCoreProperties[] = -{ - {0} -}; - - -// -// WalletCore class methods -// -static JSFunctionSpec WalletCoreMethods[] = -{ - {"ShowWindow", WalletCoreShowWindow, 2}, - {"ChangePanel", WalletCoreChangePanel, 1}, - {"PanelLoaded", WalletCorePanelLoaded, 1}, - {"SaveWallet", WalletCoreSaveWallet, 1}, - {"CancelWallet", WalletCoreCancelWallet, 0}, - {0} -}; - - -// -// WalletCore constructor -// -PR_STATIC_CALLBACK(JSBool) -WalletCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsresult result; - nsIID classID; - nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx); - nsIScriptNameSpaceManager* manager; - nsIDOMWalletCore *nativeThis; - nsIScriptObjectOwner *owner = nsnull; - nsIJSNativeInitializer* initializer = nsnull; - - static NS_DEFINE_IID(kIDOMWalletCoreIID, NS_IDOMWALLETCORE_IID); - static NS_DEFINE_IID(kIJSNativeInitializerIID, NS_IJSNATIVEINITIALIZER_IID); - - result = context->GetNameSpaceManager(&manager); - if (NS_OK != result) { - return JS_FALSE; - } - - result = manager->LookupName("WalletCore", PR_TRUE, classID); - NS_RELEASE(manager); - if (NS_OK != result) { - return JS_FALSE; - } - - result = nsComponentManager::CreateInstance(classID, - nsnull, - kIDOMWalletCoreIID, - (void **)&nativeThis); - if (NS_OK != result) { - return JS_FALSE; - } - - result = nativeThis->QueryInterface(kIJSNativeInitializerIID, (void **)&initializer); - if (NS_OK == result) { - result = initializer->Initialize(cx, argc, argv); - NS_RELEASE(initializer); - - if (NS_OK != result) { - NS_RELEASE(nativeThis); - return JS_FALSE; - } - } - - result = nativeThis->QueryInterface(kIScriptObjectOwnerIID, (void **)&owner); - if (NS_OK != result) { - NS_RELEASE(nativeThis); - return JS_FALSE; - } - - owner->SetScriptObject((void *)obj); - JS_SetPrivate(cx, obj, nativeThis); - - NS_RELEASE(owner); - return JS_TRUE; -} - -// -// WalletCore class initialization -// -extern "C" NS_DOM nsresult NS_InitWalletCoreClass(nsIScriptContext *aContext, void **aPrototype) -{ - JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); - JSObject *proto = nsnull; - JSObject *constructor = nsnull; - JSObject *parent_proto = nsnull; - JSObject *global = JS_GetGlobalObject(jscontext); - jsval vp; - - if ((PR_TRUE != JS_LookupProperty(jscontext, global, "WalletCore", &vp)) || - !JSVAL_IS_OBJECT(vp) || - ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) || - (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) || - !JSVAL_IS_OBJECT(vp)) { - - if (NS_OK != NS_InitBaseAppCoreClass(aContext, (void **)&parent_proto)) { - return NS_ERROR_FAILURE; - } - proto = JS_InitClass(jscontext, // context - global, // global object - parent_proto, // parent proto - &WalletCoreClass, // JSClass - WalletCore, // JSNative ctor - 0, // ctor args - WalletCoreProperties, // proto props - WalletCoreMethods, // proto funcs - nsnull, // ctor props (static) - nsnull); // ctor funcs (static) - if (nsnull == proto) { - return NS_ERROR_FAILURE; - } - - } - else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) { - proto = JSVAL_TO_OBJECT(vp); - } - else { - return NS_ERROR_FAILURE; - } - - if (aPrototype) { - *aPrototype = proto; - } - return NS_OK; -} - - -// -// Method for creating a new WalletCore JavaScript object -// -extern "C" NS_DOM nsresult NS_NewScriptWalletCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) -{ - NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptWalletCore"); - JSObject *proto; - JSObject *parent; - nsIScriptObjectOwner *owner; - JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); - nsresult result = NS_OK; - nsIDOMWalletCore *aWalletCore; - - if (nsnull == aParent) { - parent = nsnull; - } - else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { - if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) { - NS_RELEASE(owner); - return NS_ERROR_FAILURE; - } - NS_RELEASE(owner); - } - else { - return NS_ERROR_FAILURE; - } - - if (NS_OK != NS_InitWalletCoreClass(aContext, (void **)&proto)) { - return NS_ERROR_FAILURE; - } - - result = aSupports->QueryInterface(kIWalletCoreIID, (void **)&aWalletCore); - if (NS_OK != result) { - return result; - } - - // create a js object for this class - *aReturn = JS_NewObject(jscontext, &WalletCoreClass, proto, parent); - if (nsnull != *aReturn) { - // connect the native object to the js object - JS_SetPrivate(jscontext, (JSObject *)*aReturn, aWalletCore); - } - else { - NS_RELEASE(aWalletCore); - return NS_ERROR_FAILURE; - } - - return NS_OK; -} diff --git a/xpfe/AppCores/src/nsWalletCore.cpp b/xpfe/AppCores/src/nsWalletCore.cpp index 4df102a14e0..5601da81d33 100644 --- a/xpfe/AppCores/src/nsWalletCore.cpp +++ b/xpfe/AppCores/src/nsWalletCore.cpp @@ -324,3 +324,21 @@ NS_IMETHODIMP nsWalletCore::CancelWallet() return Close(mPanelWindow); } +//---------------------------------------------------------------------------------------- +NS_IMETHODIMP nsWalletCore::GetPrefillList(nsString& aPrefillList) +//---------------------------------------------------------------------------------------- +{ + nsIWalletService *walletservice; + nsresult res; + res = nsServiceManager::GetService(kWalletServiceCID, + kIWalletServiceIID, + (nsISupports **)&walletservice); + if ((NS_OK == res) && (nsnull != walletservice)) { + res = walletservice->WALLET_GetPrefillListForViewer(aPrefillList); + nsServiceManager::ReleaseService(kWalletServiceCID, walletservice); + } + + return NS_OK; +} + + diff --git a/xpfe/AppCores/xul/WalletWindow.js b/xpfe/AppCores/xul/WalletWindow.js index f5ed98fae64..e69de29bb2d 100644 --- a/xpfe/AppCores/xul/WalletWindow.js +++ b/xpfe/AppCores/xul/WalletWindow.js @@ -1,40 +0,0 @@ -var walletCore; - -function StartUp(windowName) -{ - dump("\nDoing " + windowName + " startup...\n"); - walletCore = XPAppCoresManager.Find("WalletCore"); - dump("Looking up WalletCore...\n"); - if (walletCore == null) - { - dump("Creating WalletCore...\n"); - walletCore = new WalletCore(); - if (walletCore != null) - { - dump("WalletCore has been created.\n"); - walletCore.Init("WalletCore"); - } - else - { - dump("WalletCore was not created"); - } - } - else - { - dump("WalletCore has already been created! Hurrah!\n"); - } - if (walletCore != null && windowName != "Top" && windowName != "Bottom") - { - walletCore.PanelLoaded(window); - } -} - -function DoSave(results) -{ - walletCore.SaveWallet(results); -} - -function DoCancel() -{ - walletCore.CancelWallet(); -}