mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-07 13:24:12 +00:00
added wallet
This commit is contained in:
parent
72ed2fa179
commit
422823b285
@ -9,6 +9,10 @@ interface BrowserAppCore : BaseAppCore
|
||||
void forward();
|
||||
void loadUrl(in wstring url);
|
||||
|
||||
void walletEditor();
|
||||
void walletSafeFillin();
|
||||
void walletQuickFillin();
|
||||
|
||||
void setToolbarWindow(in Window win);
|
||||
void setContentWindow(in Window win);
|
||||
void setWebShellWindow(in Window win);
|
||||
|
@ -39,6 +39,12 @@ public:
|
||||
|
||||
NS_IMETHOD Forward()=0;
|
||||
|
||||
#ifdef ClientWallet
|
||||
NS_IMETHOD WalletEditor()=0;
|
||||
NS_IMETHOD WalletSafeFillin()=0;
|
||||
NS_IMETHOD WalletQuickFillin()=0;
|
||||
#endif
|
||||
|
||||
NS_IMETHOD LoadUrl(const nsString& aUrl)=0;
|
||||
|
||||
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin)=0;
|
||||
|
@ -44,6 +44,7 @@ LINCS= \
|
||||
-I$(XPDIST)\public\raptor \
|
||||
-I$(XPDIST)\public\appcores \
|
||||
-I$(XPDIST)\public\rdf \
|
||||
-I$(XPDIST)\public\walletlib \
|
||||
$(NULL)
|
||||
|
||||
LLIBS = \
|
||||
|
@ -53,6 +53,12 @@
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
|
||||
#ifdef ClientWallet
|
||||
#include "nsIWalletService.h"
|
||||
static NS_DEFINE_IID(kIWalletServiceIID, NS_IWALLETSERVICE_IID);
|
||||
static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID);
|
||||
#endif
|
||||
|
||||
|
||||
/* Define Class IDs */
|
||||
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
@ -213,6 +219,167 @@ nsBrowserAppCore::Forward()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef ClientWallet
|
||||
//#define WALLET_EDITOR_URL "resource:/res/samples/walleted.html"
|
||||
#define WALLET_EDITOR_URL "http://peoplestage/morse/wallet/walleted.html"
|
||||
|
||||
PRInt32
|
||||
newWindow(char* urlName) {
|
||||
nsresult rv;
|
||||
nsString controllerCID;
|
||||
|
||||
char * urlstr=nsnull;
|
||||
char * progname = nsnull;
|
||||
char * width=nsnull, *height=nsnull;
|
||||
char * iconic_state=nsnull;
|
||||
|
||||
nsIAppShellService* appShell = nsnull;
|
||||
urlstr = urlName;
|
||||
|
||||
/*
|
||||
* Create the Application Shell instance...
|
||||
*/
|
||||
rv = nsServiceManager::GetService(kAppShellServiceCID,
|
||||
kIAppShellServiceIID,
|
||||
(nsISupports**)&appShell);
|
||||
if (!NS_SUCCEEDED(rv)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Post an event to the shell instance to load the AppShell
|
||||
* initialization routines...
|
||||
*
|
||||
* This allows the application to enter its event loop before having to
|
||||
* deal with GUI initialization...
|
||||
*/
|
||||
///write me...
|
||||
nsIURL* url;
|
||||
nsIWidget* newWindow;
|
||||
|
||||
rv = NS_NewURL(&url, urlstr);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX: Currently, the CID for the "controller" is passed in as an argument
|
||||
* to CreateTopLevelWindow(...). Once XUL supports "controller"
|
||||
* components this will be specified in the XUL description...
|
||||
*/
|
||||
controllerCID = "43147b80-8a39-11d2-9938-0080c7cb1081";
|
||||
appShell->CreateTopLevelWindow(nsnull, url, controllerCID, newWindow,
|
||||
nsnull, nsnull, 615, 650);
|
||||
NS_RELEASE(url);
|
||||
|
||||
done:
|
||||
/* Release the shell... */
|
||||
if (nsnull != appShell) {
|
||||
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
|
||||
#include "nsIPresContext.h"
|
||||
static
|
||||
nsIPresShell*
|
||||
GetPresShellFor(nsIWebShell* aWebShell)
|
||||
{
|
||||
nsIPresShell* shell = nsnull;
|
||||
if (nsnull != aWebShell) {
|
||||
nsIContentViewer* cv = nsnull;
|
||||
aWebShell->GetContentViewer(&cv);
|
||||
if (nsnull != cv) {
|
||||
nsIDocumentViewer* docv = nsnull;
|
||||
cv->QueryInterface(kIDocumentViewerIID, (void**) &docv);
|
||||
if (nsnull != docv) {
|
||||
nsIPresContext* cx;
|
||||
docv->GetPresContext(cx);
|
||||
if (nsnull != cx) {
|
||||
cx->GetShell(&shell);
|
||||
NS_RELEASE(cx);
|
||||
}
|
||||
NS_RELEASE(docv);
|
||||
}
|
||||
NS_RELEASE(cv);
|
||||
}
|
||||
}
|
||||
return shell;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserAppCore::WalletEditor()
|
||||
{
|
||||
/* set a cookie for the wallet editor */
|
||||
nsIWalletService *walletservice;
|
||||
nsresult res;
|
||||
res = nsServiceManager::GetService(kWalletServiceCID,
|
||||
kIWalletServiceIID,
|
||||
(nsISupports **)&walletservice);
|
||||
if ((NS_OK == res) && (nsnull != walletservice)) {
|
||||
nsIURL * url;
|
||||
if (!NS_FAILED(NS_NewURL(&url, WALLET_EDITOR_URL))) {
|
||||
res = walletservice->WALLET_PreEdit(url);
|
||||
NS_RELEASE(walletservice);
|
||||
}
|
||||
}
|
||||
|
||||
/* bring up the wallet editor in a new window */
|
||||
return newWindow(WALLET_EDITOR_URL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserAppCore::WalletSafeFillin()
|
||||
{
|
||||
nsIPresShell* shell;
|
||||
shell = nsnull;
|
||||
nsCOMPtr<nsIWebShell> webcontent;
|
||||
mWebShell->FindChildWithName(nsAutoString("content"), *getter_AddRefs(webcontent));
|
||||
shell = GetPresShellFor(webcontent);
|
||||
|
||||
nsIWalletService *walletservice;
|
||||
nsresult res;
|
||||
res = nsServiceManager::GetService(kWalletServiceCID,
|
||||
kIWalletServiceIID,
|
||||
(nsISupports **)&walletservice);
|
||||
if ((NS_OK == res) && (nsnull != walletservice)) {
|
||||
res = walletservice->WALLET_Prefill(shell, PR_FALSE);
|
||||
NS_RELEASE(walletservice);
|
||||
}
|
||||
|
||||
#ifndef HTMLDialogs
|
||||
return newWindow("file:///y|/htmldlgs.htm");
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserAppCore::WalletQuickFillin()
|
||||
{
|
||||
nsIPresShell* shell;
|
||||
shell = nsnull;
|
||||
nsCOMPtr<nsIWebShell> webcontent;
|
||||
mWebShell->FindChildWithName(nsAutoString("content"), *getter_AddRefs(webcontent));
|
||||
shell = GetPresShellFor(webcontent);
|
||||
|
||||
nsIWalletService *walletservice;
|
||||
nsresult res;
|
||||
res = nsServiceManager::GetService(kWalletServiceCID,
|
||||
kIWalletServiceIID,
|
||||
(nsISupports **)&walletservice);
|
||||
if ((NS_OK == res) && (nsnull != walletservice)) {
|
||||
res = walletservice->WALLET_Prefill(shell, PR_TRUE);
|
||||
NS_RELEASE(walletservice);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserAppCore::SetDisableCallback(const nsString& aScript)
|
||||
{
|
||||
|
@ -61,6 +61,13 @@ class nsBrowserAppCore : public nsBaseAppCore,
|
||||
|
||||
NS_IMETHOD Back();
|
||||
NS_IMETHOD Forward();
|
||||
|
||||
#ifdef ClientWallet
|
||||
NS_IMETHOD WalletEditor();
|
||||
NS_IMETHOD WalletSafeFillin();
|
||||
NS_IMETHOD WalletQuickFillin();
|
||||
#endif
|
||||
|
||||
NS_IMETHOD LoadUrl(const nsString& aUrl);
|
||||
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin);
|
||||
NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin);
|
||||
|
@ -196,6 +196,107 @@ BrowserAppCoreForward(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
||||
}
|
||||
|
||||
|
||||
#ifdef ClientWallet
|
||||
//
|
||||
// Native method WalletEditor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
BrowserAppCoreWalletEditor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)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->WalletEditor()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function walletEditor requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method WalletSafeFillin
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
BrowserAppCoreWalletSafeFillin(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)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->WalletSafeFillin()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function walletSafeFillin requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method WalletQuickFillin
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
BrowserAppCoreWalletQuickFillin(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)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->WalletQuickFillin()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function walletQuickFillin requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Native method LoadUrl
|
||||
//
|
||||
@ -596,6 +697,11 @@ static JSFunctionSpec BrowserAppCoreMethods[] =
|
||||
{
|
||||
{"back", BrowserAppCoreBack, 0},
|
||||
{"forward", BrowserAppCoreForward, 0},
|
||||
#ifdef ClientWallet
|
||||
{"walletEditor", BrowserAppCoreWalletEditor, 0},
|
||||
{"walletSafeFillin", BrowserAppCoreWalletSafeFillin, 0},
|
||||
{"walletQuickFillin", BrowserAppCoreWalletQuickFillin, 0},
|
||||
#endif
|
||||
{"loadUrl", BrowserAppCoreLoadUrl, 1},
|
||||
{"setToolbarWindow", BrowserAppCoreSetToolbarWindow, 1},
|
||||
{"setContentWindow", BrowserAppCoreSetContentWindow, 1},
|
||||
|
@ -250,6 +250,40 @@
|
||||
}
|
||||
}
|
||||
|
||||
function WalletEditor()
|
||||
{
|
||||
appCore = XPAppCoresManager.Find("BrowserAppCore");
|
||||
if (appCore != null) {
|
||||
dump("Wallet Editor\n");
|
||||
appCore.walletEditor();
|
||||
} else {
|
||||
dump("BrowserAppCore has not been created!\n");
|
||||
}
|
||||
}
|
||||
|
||||
function WalletSafeFillin()
|
||||
{
|
||||
appCore = XPAppCoresManager.Find("BrowserAppCore");
|
||||
if (appCore != null) {
|
||||
dump("Wallet Safe Fillin\n");
|
||||
appCore.walletSafeFillin();
|
||||
} else {
|
||||
dump("BrowserAppCore has not been created!\n");
|
||||
}
|
||||
}
|
||||
|
||||
function WalletQuickFillin()
|
||||
{
|
||||
appCore = XPAppCoresManager.Find("BrowserAppCore");
|
||||
if (appCore != null) {
|
||||
dump("Wallet Quick Fillin\n");
|
||||
appCore.walletQuickFillin();
|
||||
} else {
|
||||
dump("BrowserAppCore has not been created!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</html:script>
|
||||
|
||||
<broadcaster id="canGoBack"/>
|
||||
@ -401,6 +435,11 @@
|
||||
<menuitem name="Window 1" onclick="BrowserReload();" key="1"/>
|
||||
<menuitem name="Window 2" onclick="BrowserReload();" />
|
||||
<menuitem name="Window 3" onclick="BrowserReload();" />
|
||||
</menu>
|
||||
<menu name="Wallet">
|
||||
<menuitem name="Wallet contents" onclick="WalletEditor();"/>
|
||||
<menuitem name="Safe fillins" onclick="WalletSafeFillin();"/>
|
||||
<menuitem name="Quick fillins" onclick="WalletQuickFillin();"/>
|
||||
</menu>
|
||||
<menu name="Help">
|
||||
<menuitem name="Help Contents" onclick="BrowserReload();"/>
|
||||
|
Loading…
Reference in New Issue
Block a user