remove wallet previewer from appcores

This commit is contained in:
morse%netscape.com 1999-06-13 14:57:15 +00:00
parent 1fc94e63d3
commit ab2e112803
6 changed files with 666 additions and 0 deletions

View File

@ -0,0 +1,42 @@
#!gmake
# 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.
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = walletpreview
LIBRARY_NAME = walletpreview
IS_COMPONENT = 1
XPIDLSRCS = \
nsIWalletPreview.idl \
$(NULL)
CPPSRCS = \
nsWalletPreviewFactory.cpp \
nsWalletPreview.cpp \
$(NULL)
REQUIRES = walleteditor raptor xpcom
include $(topsrcdir)/config/rules.mk
install:: $(TARGETS)
$(INSTALL) $(srcdir)/xpconnect-walletpreview.html $(DIST)/bin/res/samples

View File

@ -0,0 +1,48 @@
#!gmake
#
# 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.
DEPTH=..\..\..
MODULE=walletpreview
MAKE_OBJ_TYPE=DLL
DLLNAME=$(MODULE)
DLL=.\$(OBJDIR)\$(DLLNAME).dll
XPIDLSRCS= .\nsIWalletPreview.idl \
$(NULL)
CPP_OBJS=\
.\$(OBJDIR)\nsWalletPreviewFactory.obj \
.\$(OBJDIR)\nsWalletPreview.obj \
$(NULL)
LLIBS=\
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\plc3.lib \
$(NULL)
LINCS=\
-I$(PUBLIC)\walleteditor \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\xpcom \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) $(DLL) $(DIST)\bin\components
$(MAKE_INSTALL) xpconnect-walletpreview.html $(DIST)\bin\res\samples

View File

@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
/*
A sample of XPConnect. This file contains a WalletPreview interface.
*/
#include "nsISupports.idl"
#include "domstubs.idl"
%{C++
#include "nsIDOMWindow.h"
%}
[scriptable, uuid(8F4CFE41-2152-11d3-ABAA-0080C787AD96)]
interface nsIWalletPreview : nsISupports
{
void SetValue(in string aValue, in nsIDOMWindow win);
string GetPrefillValue();
};
%{ C++
// {8F4CFE40-2152-11d3-ABAA-0080C787AD96}
#define NS_WALLETPREVIEW_CID \
{ 0x8f4cfe40, 0x2152, 0x11d3, { 0xab, 0xaa, 0x0, 0x80, 0xc7, 0x87, 0xad, 0x96 } };
extern nsresult
NS_NewWalletPreview(nsIWalletPreview** aWalletPreview);
%}

View File

@ -0,0 +1,158 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
#include "nscore.h"
#include "nsIAllocator.h"
#include "plstr.h"
#include "stdio.h"
#include "nsIWalletService.h"
#include "nsIServiceManager.h"
#include "nsIDOMWindow.h"
#include "nsCOMPtr.h"
#include "nsIWebShell.h"
#include "nsIWebShellWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIWalletPreview.h"
static NS_DEFINE_IID(kIWalletServiceIID, NS_IWALLETSERVICE_IID);
static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID);
class WalletPreviewImpl : public nsIWalletPreview
{
public:
WalletPreviewImpl();
virtual ~WalletPreviewImpl();
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIWalletPreview interface
NS_IMETHOD GetPrefillValue(char * *aValue);
NS_IMETHOD SetValue(const char *aValue, nsIDOMWindow *win);
};
////////////////////////////////////////////////////////////////////////
nsresult
NS_NewWalletPreview(nsIWalletPreview** aWalletPreview)
{
NS_PRECONDITION(aWalletPreview != nsnull, "null ptr");
if (!aWalletPreview) {
return NS_ERROR_NULL_POINTER;
}
*aWalletPreview = new WalletPreviewImpl();
if (! *aWalletPreview) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aWalletPreview);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
WalletPreviewImpl::WalletPreviewImpl()
{
NS_INIT_REFCNT();
}
WalletPreviewImpl::~WalletPreviewImpl()
{
}
NS_IMPL_ISUPPORTS(WalletPreviewImpl, nsIWalletPreview::GetIID());
NS_IMETHODIMP
WalletPreviewImpl::GetPrefillValue(char** aValue)
{
NS_PRECONDITION(aValue != nsnull, "null ptr");
if (!aValue) {
return NS_ERROR_NULL_POINTER;
}
nsIWalletService *walletservice;
nsresult res;
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
if ((NS_SUCCEEDED(res)) && (nsnull != walletservice)) {
nsAutoString walletList;
res = walletservice->WALLET_GetPrefillListForViewer(walletList);
if (NS_SUCCEEDED(res)) {
*aValue = walletList.ToNewCString();
}
}
return res;
}
static void DOMWindowToWebShellWindow(
nsIDOMWindow *DOMWindow,
nsCOMPtr<nsIWebShellWindow> *webWindow)
{
if (!DOMWindow) {
return; // with webWindow unchanged -- its constructor gives it a null ptr
}
nsCOMPtr<nsIScriptGlobalObject> globalScript(do_QueryInterface(DOMWindow));
nsCOMPtr<nsIWebShell> webshell, rootWebshell;
if (globalScript) {
globalScript->GetWebShell(getter_AddRefs(webshell));
}
if (webshell) {
webshell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebshell));
}
if (rootWebshell) {
nsCOMPtr<nsIWebShellContainer> webshellContainer;
rootWebshell->GetContainer(*getter_AddRefs(webshellContainer));
*webWindow = do_QueryInterface(webshellContainer);
}
}
NS_IMETHODIMP
WalletPreviewImpl::SetValue(const char* aValue, nsIDOMWindow* win)
{
/* close the window */
if (!win) {
return NS_ERROR_FAILURE;
}
nsIDOMWindow* top;
win->GetTop(&top);
if (!top) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(top, &parent);
if (parent) {
parent->Close();
}
NS_IF_RELEASE(win);
/* process the value */
NS_PRECONDITION(aValue != nsnull, "null ptr");
if (! aValue) {
return NS_ERROR_NULL_POINTER;
}
nsIWalletService *walletservice;
nsresult res;
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
if ((NS_SUCCEEDED(res)) && (nsnull != walletservice)) {
nsAutoString walletList = aValue;
res = walletservice->WALLET_PrefillReturn(walletList);
}
return res;
}

View File

@ -0,0 +1,206 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
/*
A sample of XPConnect. This file contains the XPCOM factory the
creates for WalletPreviewImpl objects.
*/
#include "nsCOMPtr.h"
#include "nscore.h"
#include "nsIWalletPreview.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsXPComFactory.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_CID(kWalletPreviewCID, NS_WALLETPREVIEW_CID);
class WalletPreviewFactoryImpl : public nsIFactory
{
public:
WalletPreviewFactoryImpl(const nsCID &aClass, const char* className, const char* progID);
// nsISupports methods
NS_DECL_ISUPPORTS
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
protected:
virtual ~WalletPreviewFactoryImpl();
protected:
nsCID mClassID;
const char* mClassName;
const char* mProgID;
};
////////////////////////////////////////////////////////////////////////
WalletPreviewFactoryImpl::WalletPreviewFactoryImpl(const nsCID &aClass,
const char* className,
const char* progID)
: mClassID(aClass), mClassName(className), mProgID(progID)
{
NS_INIT_REFCNT();
}
WalletPreviewFactoryImpl::~WalletPreviewFactoryImpl()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP
WalletPreviewFactoryImpl::QueryInterface(const nsIID &aIID, void **aResult)
{
if (! aResult)
return NS_ERROR_NULL_POINTER;
// Always NULL result, in case of failure
*aResult = nsnull;
if (aIID.Equals(kISupportsIID)) {
*aResult = NS_STATIC_CAST(nsISupports*, this);
AddRef();
return NS_OK;
} else if (aIID.Equals(kIFactoryIID)) {
*aResult = NS_STATIC_CAST(nsIFactory*, this);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(WalletPreviewFactoryImpl);
NS_IMPL_RELEASE(WalletPreviewFactoryImpl);
NS_IMETHODIMP
WalletPreviewFactoryImpl::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
if (! aResult)
return NS_ERROR_NULL_POINTER;
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
*aResult = nsnull;
nsresult rv;
nsISupports *inst = nsnull;
if (mClassID.Equals(kWalletPreviewCID)) {
if (NS_FAILED(rv = NS_NewWalletPreview((nsIWalletPreview**) &inst)))
return rv;
}
else {
return NS_ERROR_NO_INTERFACE;
}
if (! inst)
return NS_ERROR_OUT_OF_MEMORY;
if (NS_FAILED(rv = inst->QueryInterface(aIID, aResult))) {
// We didn't get the right interface.
NS_ERROR("didn't support the interface you wanted");
}
NS_IF_RELEASE(inst);
return rv;
}
nsresult WalletPreviewFactoryImpl::LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// return the proper factory to the caller
extern "C" PR_IMPLEMENT(nsresult)
NSGetFactory(nsISupports* aServMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (! aFactory)
return NS_ERROR_NULL_POINTER;
WalletPreviewFactoryImpl* factory = new WalletPreviewFactoryImpl(aClass, aClassName, aProgID);
if (factory == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(factory);
*aFactory = factory;
return NS_OK;
}
extern "C" PR_IMPLEMENT(nsresult)
NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = compMgr->RegisterComponent(kWalletPreviewCID,
"WalletPreview World Component",
"component://netscape/walletpreview/walletpreview-world",
aPath, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
extern "C" PR_IMPLEMENT(nsresult)
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = compMgr->UnregisterComponent(kWalletPreviewCID, aPath);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}

View File

@ -0,0 +1,167 @@
<HTML>
<HEAD>
<TITLE>Pre-Filling</TITLE>
<SCRIPT>
/* for xpconnect */
var walletpreview =
Components.classes
["component://netscape/walletpreview/walletpreview-world"].createInstance();
walletpreview = walletpreview.QueryInterface(Components.interfaces.nsIWalletPreview);
function DoGetPrefillList()
{
return walletpreview.GetPrefillValue();
}
function DoSave(value)
{
walletpreview.SetValue(value, window);
}
/* end of xpconnect stuff */
index_frame = 0;
title_frame = 1;
list_frame = 2;
button_frame = 3;
var prefillList = [];
function loadFillins(){
top.frames[title_frame].document.open();
top.frames[title_frame].document.write
("&nbsp;Following items can be pre-filled for you.");
top.frames[title_frame].document.close();
top.frames[list_frame].document.open();
top.frames[list_frame].document.write(
"<FORM name=fSelectFillin>" +
"<BR>" +
"<TABLE BORDER=0>" +
"<TR>" +
"<TD>" +
"<BR>"
)
var count;
for (i=1; i<prefillList.length-2; i+=3) {
if(prefillList[i] != 0) {
count = prefillList[i];
top.frames[list_frame].document.write(
"<TR>" +
"<TD>" + prefillList[i+1] + ": </TD>" +
"<TD>" +
"<SELECT>"
)
count--;
}
top.frames[list_frame].document.write(
"<OPTION VALUE=\""+prefillList[i+1]+"\">" +
prefillList[i+2] +
"</OPTION>"
)
if(count == 0) {
top.frames[list_frame].document.write(
"<OPTION VALUE=\""+prefillList[i+1]+"\"></OPTION>" +
"</SELECT><BR>" +
"</TD>" +
"</TR>"
)
}
}
top.frames[list_frame].document.write(
"</TD>" +
"</TR>" +
"</TABLE>" +
"</FORM>"
);
top.frames[list_frame].document.close();
};
function loadButtons(){
top.frames[button_frame].document.open();
top.frames[button_frame].document.write(
"<FORM name=buttons>" +
"<BR>" +
"<INPUT type=CHECKBOX name=skip> Bypass this screen when prefilling this form in the future" +
"<BR>" +
"<BR>" +
"<DIV align=center>" +
"<INPUT type=BUTTON value=OK width=80 onclick=parent.Save()>" +
" &nbsp;&nbsp;" +
"<INPUT type=BUTTON value=Cancel width=80 onclick=parent.Cancel()>" +
"</DIV>" +
"<INPUT TYPE=HIDDEN NAME=fillins VALUE=\" \" SIZE=-1>" +
"<INPUT TYPE=HIDDEN NAME=list VALUE=\" \" SIZE=-1>" +
"<INPUT TYPE=HIDDEN NAME=url VALUE=\" \" SIZE=-1>" +
"</FORM>"
);
top.frames[button_frame].document.close();
}
function loadFrames(){
list = DoGetPrefillList();
BREAK = list[0];
prefillList = list.split(BREAK);
loadFillins();
loadButtons();
}
function Save(){
selname = top.frames[list_frame].document.fSelectFillin;
var list = top.frames[button_frame].document.buttons.list;
var url = top.frames[button_frame].document.buttons.url;
var skip = top.frames[button_frame].document.buttons.skip;
list.value = prefillList[prefillList.length-2];
url.value = "prefillList[prefillList.length-1]";
var fillins = top.frames[button_frame].document.buttons.fillins;
fillins.value = "";
for (i=0; i<selname.length; i++) {
fillins.value = fillins.value +
selname.elements[i].options[selname.elements[i].selectedIndex].value + "#*%&" +
selname.elements[i].options[selname.elements[i].selectedIndex].text + "#*%&";
}
var result = "|list|"+list.value+"|fillins|"+fillins.value;
result += "|url|"+url.value+"|skip|"+skip.checked+"|";
DoSave(result);
}
function Cancel(){
var result = "|list||fillins||url||skip|"+skip.checked+"|";
DoSave(result);
}
</SCRIPT>
</HEAD>
<FRAMESET ROWS = 25,25,*,75
BORDER=0
FRAMESPACING=0
onLoad=loadFrames()>
<FRAME SRC=about:blank
NAME=index_frame
SCROLLING=NO
MARGINWIDTH=1
MARGINHEIGHT=1
NORESIZE>
<FRAME SRC=about:blank
NAME=title_frame
SCROLLING=NO
MARGINWIDTH=1
MARGINHEIGHT=1
NORESIZE>
<FRAME SRC=about:blank
NAME=list_frame
SCROLLING=AUTO
MARGINWIDTH=0
MARGINHEIGHT=0
NORESIZE>
<FRAME SRC=about:blank
NAME=button_frame
SCROLLING=NO
MARGINWIDTH=1
MARGINHEIGHT=1
NORESIZE>
</FRAMESET>
<NOFRAMES>
<BODY> <BR> </BODY>
</NOFRAMES>
</HTML>