From beddf1b292e1454f41197663d8917db2c5bd7c8d Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Tue, 2 Feb 1999 18:37:20 +0000 Subject: [PATCH] Initial checkin git-svn-id: svn://10.0.0.236/trunk@19353 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/silentdl/tests/Example.html | 40 +- mozilla/silentdl/tests/SDLEdit.html | 238 ------- mozilla/xpfe/AppCores/MANIFEST | 10 + mozilla/xpfe/AppCores/Makefile.in | 33 + mozilla/xpfe/AppCores/idl/AppCores.idl | 13 + mozilla/xpfe/AppCores/idl/BaseAppCore.idl | 14 + mozilla/xpfe/AppCores/idl/BrowserAppCore.idl | 19 + mozilla/xpfe/AppCores/idl/MailCore.idl | 14 + mozilla/xpfe/AppCores/idl/Toolbar.idl | 13 + mozilla/xpfe/AppCores/makefile.win | 95 +++ mozilla/xpfe/AppCores/nsAppCores.cpp | 146 +++++ mozilla/xpfe/AppCores/nsAppCores.h | 64 ++ mozilla/xpfe/AppCores/nsAppCoresCIDs.h | 52 ++ mozilla/xpfe/AppCores/nsAppCoresManager.cpp | 338 ++++++++++ mozilla/xpfe/AppCores/nsAppCoresManager.h | 71 +++ .../AppCores/nsAppCoresManagerFactory.cpp | 129 ++++ .../xpfe/AppCores/nsAppCoresManagerFactory.h | 47 ++ mozilla/xpfe/AppCores/nsAppCoresNameSet.cpp | 108 ++++ mozilla/xpfe/AppCores/nsAppCoresNameSet.h | 41 ++ mozilla/xpfe/AppCores/nsBaseAppCore.cpp | 180 ++++++ mozilla/xpfe/AppCores/nsBaseAppCore.h | 63 ++ mozilla/xpfe/AppCores/nsBrowserAppCore.cpp | 202 ++++++ mozilla/xpfe/AppCores/nsBrowserAppCore.h | 74 +++ .../xpfe/AppCores/nsBrowserAppCoreFactory.cpp | 131 ++++ .../xpfe/AppCores/nsBrowserAppCoreFactory.h | 49 ++ mozilla/xpfe/AppCores/nsIDOMAppCores.h | 70 +++ mozilla/xpfe/AppCores/nsIDOMBaseAppCore.h | 57 ++ mozilla/xpfe/AppCores/nsIDOMBrowserAppCore.h | 79 +++ mozilla/xpfe/AppCores/nsIDOMMailCore.h | 63 ++ mozilla/xpfe/AppCores/nsIDOMToolbarCore.h | 59 ++ mozilla/xpfe/AppCores/nsJSAppCores.cpp | 463 ++++++++++++++ mozilla/xpfe/AppCores/nsJSBaseAppCore.cpp | 364 +++++++++++ mozilla/xpfe/AppCores/nsJSBrowserAppCore.cpp | 581 ++++++++++++++++++ mozilla/xpfe/AppCores/nsJSMailCore.cpp | 439 +++++++++++++ mozilla/xpfe/AppCores/nsJSToolbarCore.cpp | 396 ++++++++++++ mozilla/xpfe/AppCores/nsMailCore.cpp | 179 ++++++ mozilla/xpfe/AppCores/nsMailCore.h | 66 ++ mozilla/xpfe/AppCores/nsMailCoreFactory.cpp | 131 ++++ mozilla/xpfe/AppCores/nsMailCoreFactory.h | 49 ++ mozilla/xpfe/AppCores/nsToolbarCore.cpp | 173 ++++++ mozilla/xpfe/AppCores/nsToolbarCore.h | 65 ++ .../xpfe/AppCores/nsToolbarCoreFactory.cpp | 131 ++++ mozilla/xpfe/AppCores/nsToolbarCoreFactory.h | 47 ++ 43 files changed, 5329 insertions(+), 267 deletions(-) delete mode 100644 mozilla/silentdl/tests/SDLEdit.html create mode 100644 mozilla/xpfe/AppCores/MANIFEST create mode 100644 mozilla/xpfe/AppCores/Makefile.in create mode 100644 mozilla/xpfe/AppCores/idl/AppCores.idl create mode 100644 mozilla/xpfe/AppCores/idl/BaseAppCore.idl create mode 100644 mozilla/xpfe/AppCores/idl/BrowserAppCore.idl create mode 100644 mozilla/xpfe/AppCores/idl/MailCore.idl create mode 100644 mozilla/xpfe/AppCores/idl/Toolbar.idl create mode 100644 mozilla/xpfe/AppCores/makefile.win create mode 100644 mozilla/xpfe/AppCores/nsAppCores.cpp create mode 100644 mozilla/xpfe/AppCores/nsAppCores.h create mode 100644 mozilla/xpfe/AppCores/nsAppCoresCIDs.h create mode 100644 mozilla/xpfe/AppCores/nsAppCoresManager.cpp create mode 100644 mozilla/xpfe/AppCores/nsAppCoresManager.h create mode 100644 mozilla/xpfe/AppCores/nsAppCoresManagerFactory.cpp create mode 100644 mozilla/xpfe/AppCores/nsAppCoresManagerFactory.h create mode 100644 mozilla/xpfe/AppCores/nsAppCoresNameSet.cpp create mode 100644 mozilla/xpfe/AppCores/nsAppCoresNameSet.h create mode 100644 mozilla/xpfe/AppCores/nsBaseAppCore.cpp create mode 100644 mozilla/xpfe/AppCores/nsBaseAppCore.h create mode 100644 mozilla/xpfe/AppCores/nsBrowserAppCore.cpp create mode 100644 mozilla/xpfe/AppCores/nsBrowserAppCore.h create mode 100644 mozilla/xpfe/AppCores/nsBrowserAppCoreFactory.cpp create mode 100644 mozilla/xpfe/AppCores/nsBrowserAppCoreFactory.h create mode 100644 mozilla/xpfe/AppCores/nsIDOMAppCores.h create mode 100644 mozilla/xpfe/AppCores/nsIDOMBaseAppCore.h create mode 100644 mozilla/xpfe/AppCores/nsIDOMBrowserAppCore.h create mode 100644 mozilla/xpfe/AppCores/nsIDOMMailCore.h create mode 100644 mozilla/xpfe/AppCores/nsIDOMToolbarCore.h create mode 100644 mozilla/xpfe/AppCores/nsJSAppCores.cpp create mode 100644 mozilla/xpfe/AppCores/nsJSBaseAppCore.cpp create mode 100644 mozilla/xpfe/AppCores/nsJSBrowserAppCore.cpp create mode 100644 mozilla/xpfe/AppCores/nsJSMailCore.cpp create mode 100644 mozilla/xpfe/AppCores/nsJSToolbarCore.cpp create mode 100644 mozilla/xpfe/AppCores/nsMailCore.cpp create mode 100644 mozilla/xpfe/AppCores/nsMailCore.h create mode 100644 mozilla/xpfe/AppCores/nsMailCoreFactory.cpp create mode 100644 mozilla/xpfe/AppCores/nsMailCoreFactory.h create mode 100644 mozilla/xpfe/AppCores/nsToolbarCore.cpp create mode 100644 mozilla/xpfe/AppCores/nsToolbarCore.h create mode 100644 mozilla/xpfe/AppCores/nsToolbarCoreFactory.cpp create mode 100644 mozilla/xpfe/AppCores/nsToolbarCoreFactory.h diff --git a/mozilla/silentdl/tests/Example.html b/mozilla/silentdl/tests/Example.html index 510a841d80f..609df8bad4c 100644 --- a/mozilla/silentdl/tests/Example.html +++ b/mozilla/silentdl/tests/Example.html @@ -1,43 +1,25 @@ - SilentDownload Test Page + AppProcesses Test Page diff --git a/mozilla/silentdl/tests/SDLEdit.html b/mozilla/silentdl/tests/SDLEdit.html deleted file mode 100644 index a42edbdea5c..00000000000 --- a/mozilla/silentdl/tests/SDLEdit.html +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - - - -
-

- -
- - - - - - - - - - - - - - - -
ID:
URL:
Script:
- - -
- - - - - - - - - - - - - - - - - - - - - -
State:
Next Byte:
Out File:
Error Message:
- -
- -

- - - - -
-
- - - - -
-
- - -
- - -

- - - diff --git a/mozilla/xpfe/AppCores/MANIFEST b/mozilla/xpfe/AppCores/MANIFEST new file mode 100644 index 00000000000..11715615ce3 --- /dev/null +++ b/mozilla/xpfe/AppCores/MANIFEST @@ -0,0 +1,10 @@ +# +# This is a list of local files which get copied to the mozilla:dist:appcores directory +# + +nsIDOMAppCores.h +nsIDOMBaseAppCore.h +nsIDOMMailCore.h +nsIDOMToolbarCore.h +nsIDOMBrowserApprCore.h +nsAppCoresCIDs.h diff --git a/mozilla/xpfe/AppCores/Makefile.in b/mozilla/xpfe/AppCores/Makefile.in new file mode 100644 index 00000000000..2cc4694a6e9 --- /dev/null +++ b/mozilla/xpfe/AppCores/Makefile.in @@ -0,0 +1,33 @@ +# +# 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@ +VPATH = @srcdir@ +srcdir = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = silentdl +LIBRARY_NAME = silentdl + +EXPORTS = nsSilentDownload.h nsIDOMSilentDownloadTask.h nsIDOMSilentDownload.h + +EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) + +include $(topsrcdir)/config/rules.mk + diff --git a/mozilla/xpfe/AppCores/idl/AppCores.idl b/mozilla/xpfe/AppCores/idl/AppCores.idl new file mode 100644 index 00000000000..34f8d32196f --- /dev/null +++ b/mozilla/xpfe/AppCores/idl/AppCores.idl @@ -0,0 +1,13 @@ +interface AppCores +{ +/* IID: { 0x18c2f981, 0xb09f, 0x11d2, \ + {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}} */ + + void Startup(); + void Shutdown(); + + void Add(in BaseAppCore appcore); + void Remove(in BaseAppCore appcore); + + BaseAppCore Find(in wstring id); +}; diff --git a/mozilla/xpfe/AppCores/idl/BaseAppCore.idl b/mozilla/xpfe/AppCores/idl/BaseAppCore.idl new file mode 100644 index 00000000000..79cc02ab20a --- /dev/null +++ b/mozilla/xpfe/AppCores/idl/BaseAppCore.idl @@ -0,0 +1,14 @@ +interface BaseAppCore +{ +/* IID: { 0xbe5c13bd, 0xba9f, 0x11d2, \ + {0x96, 0xc4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56}} */ + + readonly attribute wstring id; + + void BaseAppCore(); + void Init(in wstring id); + + +}; + + diff --git a/mozilla/xpfe/AppCores/idl/BrowserAppCore.idl b/mozilla/xpfe/AppCores/idl/BrowserAppCore.idl new file mode 100644 index 00000000000..d8712407af2 --- /dev/null +++ b/mozilla/xpfe/AppCores/idl/BrowserAppCore.idl @@ -0,0 +1,19 @@ +interface BrowserAppCore : BaseAppCore +{ +/* IID: { 0xb0ffb697, 0xbab4, 0x11d2, \ + {0x96, 0xc4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56}} */ + + void BrowserAppCore(); + + void back(); + void forward(); + void loadUrl(in wstring url); + + void setToolbarWindow(in Window win); + void setContentWindow(in Window win); + + void disableCallback(in wstring script); + void enableCallback(in wstring script); + +}; + diff --git a/mozilla/xpfe/AppCores/idl/MailCore.idl b/mozilla/xpfe/AppCores/idl/MailCore.idl new file mode 100644 index 00000000000..f657ece3d4b --- /dev/null +++ b/mozilla/xpfe/AppCores/idl/MailCore.idl @@ -0,0 +1,14 @@ +interface MailCore : BaseAppCore +{ +/* IID: { 0x18c2f980, 0xb09f, 0x11d2, \ + {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}} */ + + void MailCore(); + + void SendMail(in wstring addrTo, in wstring subject, in wstring msg); + void MailCompleteCallback(in wstring script); + void SetWindow(in Window win); + +}; + + diff --git a/mozilla/xpfe/AppCores/idl/Toolbar.idl b/mozilla/xpfe/AppCores/idl/Toolbar.idl new file mode 100644 index 00000000000..aba560e4777 --- /dev/null +++ b/mozilla/xpfe/AppCores/idl/Toolbar.idl @@ -0,0 +1,13 @@ +interface ToolbarCore : BaseAppCore +{ +/* IID: { 0xbf4ae23e, 0xba9b, 0x11d2, \ + {0x96, 0xc4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56}} */ + + void ToolbarCore(); + + void SetWindow(in Window win); + void SetStatus(in wstring msg); + +}; + + diff --git a/mozilla/xpfe/AppCores/makefile.win b/mozilla/xpfe/AppCores/makefile.win new file mode 100644 index 00000000000..213d6bf8faa --- /dev/null +++ b/mozilla/xpfe/AppCores/makefile.win @@ -0,0 +1,95 @@ +#!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=..\.. +IGNORE_MANIFEST=1 + +MAKE_OBJ_TYPE = DLL +MODULE=appcores + +DLL=.\$(OBJDIR)\$(MODULE).dll + +DEFINES=-D_IMPL_NS_DOM -DWIN32_LEAN_AND_MEAN + +LCFLAGS = \ + $(LCFLAGS) \ + $(DEFINES) \ + $(NULL) + +LINCS= \ + -I$(XPDIST)\public\js \ + -I$(XPDIST)\public\netlib \ + -I$(XPDIST)\public\network \ + -I$(XPDIST)\public\dom \ + -I$(XPDIST)\public\xpcom \ + -I$(XPDIST)\public\util \ + -I$(XPDIST)\public\nspr2 \ + -I$(XPDIST)\public\pref \ + -I$(XPDIST)\public\raptor \ + $(NULL) + +LLIBS = \ + $(DIST)\lib\netlib.lib \ + $(DIST)\lib\xpcom32.lib \ + $(DIST)\lib\xppref32.lib \ + $(DIST)\lib\xplib.lib \ + $(DIST)\lib\js3250.lib \ + $(DIST)\lib\jsdombase_s.lib \ + $(DIST)\lib\raptorbase.lib \ + $(DIST)\lib\raptorgfxwin.lib \ + $(LIBNSPR) \ + $(DIST)\lib\libplc21.lib \ + $(NULL) + +OBJS = \ + .\$(OBJDIR)\nsBaseAppCore.obj \ + .\$(OBJDIR)\nsMailCore.obj \ + .\$(OBJDIR)\nsAppCoresNameSet.obj \ + .\$(OBJDIR)\nsToolbarCore.obj \ + .\$(OBJDIR)\nsBrowserAppCore.obj \ + .\$(OBJDIR)\nsMailCoreFactory.obj \ + .\$(OBJDIR)\nsToolbarCoreFactory.obj \ + .\$(OBJDIR)\nsBrowserAppCoreFactory.obj \ + .\$(OBJDIR)\nsAppCoresManager.obj \ + .\$(OBJDIR)\nsAppCoresManagerFactory.obj \ + .\$(OBJDIR)\nsJSBaseAppCore.obj \ + .\$(OBJDIR)\nsJSAppCores.obj \ + .\$(OBJDIR)\nsJSMailCore.obj \ + .\$(OBJDIR)\nsJSToolbarCore.obj \ + .\$(OBJDIR)\nsJSBrowserAppCore.obj \ + .\$(OBJDIR)\nsAppCores.obj \ + $(NULL) + + +EXPORTS= \ + nsIDOMAppCores.h \ + nsIDOMBaseAppCore.h \ + nsIDOMMailCore.h \ + nsIDOMToolbarCore.h \ + nsIDOMBrowserApprCore.h \ + nsAppCoresCIDs.h + +include <$(DEPTH)\config\rules.mak> + +install:: $(DLL) + $(MAKE_INSTALL) .\$(OBJDIR)\$(MODULE).dll $(DIST)\bin + $(MAKE_INSTALL) .\$(OBJDIR)\$(MODULE).lib $(DIST)\lib + +clobber:: + rm -f $(DIST)\lib\$(MODULE).lib + rm -f $(DIST)\bin\$(MODULE).dll diff --git a/mozilla/xpfe/AppCores/nsAppCores.cpp b/mozilla/xpfe/AppCores/nsAppCores.cpp new file mode 100644 index 00000000000..e92cd3dba6c --- /dev/null +++ b/mozilla/xpfe/AppCores/nsAppCores.cpp @@ -0,0 +1,146 @@ +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsAppCoresCIDs.h" +#include "nsAppCoresManagerFactory.h" +#include "nsMailCoreFactory.h" +#include "nsToolbarCoreFactory.h" +#include "nsBrowserAppCoreFactory.h" +#include "nsIFactory.h" +#include "nsRepository.h" + +#include "pratom.h" + +static PRInt32 gLockCnt = 0; +static PRInt32 gInstanceCnt = 0; + +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); +static NS_DEFINE_IID(kMailCoreCID, NS_MailCore_CID); +static NS_DEFINE_IID(kToolbarCoreCID, NS_TOOLBARCORE_CID); +static NS_DEFINE_IID(kBrowserAppCoreCID, NS_BROWSERAPPCORE_CID); +static NS_DEFINE_IID(kAppCoresCID, NS_AppCores_CID); + + +//////////////////////////////////////////////////////////////////////////////// +// DLL Entry Points: +//////////////////////////////////////////////////////////////////////////////// + +extern "C" NS_EXPORT PRBool +NSCanUnload(void) +{ + return PRBool (gInstanceCnt == 0 && gLockCnt == 0); +} + +extern "C" NS_EXPORT nsresult +NSRegisterSelf(const char *path) +{ + printf("*** AppCores is being registered\n"); + nsRepository::RegisterFactory(kAppCoresCID, path, PR_TRUE, PR_TRUE); + nsRepository::RegisterFactory(kMailCoreCID, path, PR_TRUE, PR_TRUE); + nsRepository::RegisterFactory(kToolbarCoreCID, path, PR_TRUE, PR_TRUE); + nsRepository::RegisterFactory(kBrowserAppCoreCID, path, PR_TRUE, PR_TRUE); + return NS_OK; +} + +extern "C" NS_EXPORT nsresult +NSUnregisterSelf(const char *path) +{ + printf("*** AppCores is being unregistered\n"); + + nsRepository::UnregisterFactory(kAppCoresCID, path); + nsRepository::UnregisterFactory(kMailCoreCID, path); + nsRepository::UnregisterFactory(kToolbarCoreCID, path); + nsRepository::UnregisterFactory(kBrowserAppCoreCID, path); + + return NS_OK; +} + + + +extern "C" NS_EXPORT nsresult +NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory) +{ + + if (aFactory == NULL) + { + return NS_ERROR_NULL_POINTER; + } + + *aFactory = NULL; + nsISupports *inst; + + + if ( aClass.Equals(kAppCoresCID) ) + { + inst = new nsAppCoresManagerFactory(); + } + else if ( aClass.Equals(kMailCoreCID) ) + { + inst = new nsMailCoreFactory(); + } + else if ( aClass.Equals(kToolbarCoreCID) ) + { + inst = new nsToolbarCoreFactory(); + } + else if ( aClass.Equals(kBrowserAppCoreCID) ) + { + inst = new nsBrowserAppCoreFactory(); + } + else + { + return NS_ERROR_ILLEGAL_VALUE; + } + + + if (inst == NULL) + { + return NS_ERROR_OUT_OF_MEMORY; + } + + + nsresult res = inst->QueryInterface(kIFactoryIID, (void**) aFactory); + + if (res != NS_OK) + { + delete inst; + } + + return res; + +} + +extern "C" void +IncInstanceCount(){ + PR_AtomicIncrement(&gInstanceCnt); +} + +extern "C" void +IncLockCount(){ + PR_AtomicIncrement(&gLockCnt); +} + +extern "C" void +DecInstanceCount(){ + PR_AtomicDecrement(&gInstanceCnt); +} + +extern "C" void +DecLockCount(){ + PR_AtomicDecrement(&gLockCnt); +} diff --git a/mozilla/xpfe/AppCores/nsAppCores.h b/mozilla/xpfe/AppCores/nsAppCores.h new file mode 100644 index 00000000000..a9ff85c65e5 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsAppCores.h @@ -0,0 +1,64 @@ +/* -*- 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. + */ +#ifndef nsAppCores_h___ +#define nsAppCores_h___ + +#include "nsISupports.h" +#include "nsIFactory.h" +#include "nscore.h" +#include "prio.h" + +//////////////////////////////////////////////////////////////////////////////// +// DLL Entry Points: +//////////////////////////////////////////////////////////////////////////////// +extern "C" NS_EXPORT nsresult +NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory); + +extern "C" NS_EXPORT PRBool +NSCanUnload(void); + +extern "C" NS_EXPORT nsresult +NSRegisterSelf(const char *path); + +extern "C" NS_EXPORT nsresult +NSUnregisterSelf(const char *path); + +extern "C" void +IncInstanceCount(); + +extern "C" void +IncLockCount(); + +extern "C" void +DecInstanceCount(); + +extern "C" void +DecLockCount(); + + + + + + + + + + + + +#endif diff --git a/mozilla/xpfe/AppCores/nsAppCoresCIDs.h b/mozilla/xpfe/AppCores/nsAppCoresCIDs.h new file mode 100644 index 00000000000..ca619c999be --- /dev/null +++ b/mozilla/xpfe/AppCores/nsAppCoresCIDs.h @@ -0,0 +1,52 @@ +#ifndef nsAppCoresCIDs_h___ +#define nsAppCoresCIDs_h___ + +#define NS_AppCores_CID \ +{ /* 18c2f982-b09f-11d2-bcde-00805f0e1353 */ \ + 0x18c2f982, 0xb09f, 0x11d2, \ + {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \ +} + +#define NS_AppCoresFactory_CID \ +{ /* 18c2f984-b09f-11d2-bcde-00805f0e1353 */ \ + 0x18c2f984, 0xb09f, 0x11d2, \ + {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \ +} + +#define NS_MailCore_CID \ +{ /* 18c2f983-b09f-11d2-bcde-00805f0e1353 */ \ + 0x18c2f983, 0xb09f, 0x11d2, \ + {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \ +} + +#define NS_MailCoreFactory_CID \ +{ /* 18c2f985-b09f-11d2-bcde-00805f0e1353 */ \ + 0x18c2f985, 0xb09f, 0x11d2, \ + {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \ +} + +#define NS_TOOLBARCORE_CID \ +{ /* BF4AE23E-BA9B-11d2-96C4-0060B0FB9956 */ \ + 0xbf4ae23e, 0xba9b, 0x11d2, \ + {0x96, 0xc4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56} \ +} + +#define NS_TOOLBARCORE_FACTORY_CID \ +{ /* BF4AE23F-BA9B-11d2-96C4-0060B0FB9956 */ \ + 00xbf4ae23f, 0xba9b, 0x11d2, \ + {0x96, 0xc4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56} \ +} + +#define NS_BROWSERAPPCORE_CID \ +{ /* BF4AE23E-BA9B-11d2-96C4-0060B0FB9956 */ \ + 0x108d75a0, 0xbab5, 0x11d2, \ + {0x96, 0xc4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56} \ +} + +#define NS_BROWSERAPPCORE_FACTORY_CID \ +{ /* BF4AE23F-BA9B-11d2-96C4-0060B0FB9956 */ \ + 0x108d759f, 0xbab5, 0x11d2, \ + {0x96, 0xc4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56} \ +} + +#endif /* nsAppCoresCIDs_h___ */ diff --git a/mozilla/xpfe/AppCores/nsAppCoresManager.cpp b/mozilla/xpfe/AppCores/nsAppCoresManager.cpp new file mode 100644 index 00000000000..12426cabe07 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsAppCoresManager.cpp @@ -0,0 +1,338 @@ + +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + + +#include "nsAppCoresCIDs.h" +#include "nsAppCores.h" +#include "nsAppCoresManager.h" +#include "nsAppCoresNameSet.h" + +#include "nscore.h" +#include "nsIFactory.h" +#include "nsISupports.h" + +#include "nsRepository.h" + +#include "nsIScriptObjectOwner.h" +#include "nsIScriptGlobalObject.h" + +#include "pratom.h" +#include "prmem.h" +#include "prio.h" +#include "mkutils.h" +#include "prefapi.h" + +#include "nsIURL.h" +#include "nsINetlibURL.h" +#include "nsINetService.h" +#include "nsIInputStream.h" +#include "nsIStreamListener.h" + +#include "nsIDOMAppCores.h" +#include "nsIDOMMailCore.h" + +/* For Javascript Namespace Access */ +#include "nsDOMCID.h" +#include "nsIServiceManager.h" +#include "nsINameSpaceManager.h" +#include "nsIScriptNameSetRegistry.h" +#include "nsIScriptNameSpaceManager.h" +#include "nsIScriptExternalNameSet.h" + +#include "nsITimer.h" +#include "nsITimerCallback.h" + +#include "nsIBrowserWindow.h" +#include "nsIWebShell.h" + +// Globals + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); + +static NS_DEFINE_IID(kIScriptNameSetRegistryIID, NS_ISCRIPTNAMESETREGISTRY_IID); +static NS_DEFINE_IID(kCScriptNameSetRegistryCID, NS_SCRIPT_NAMESET_REGISTRY_CID); +static NS_DEFINE_IID(kIScriptExternalNameSetIID, NS_ISCRIPTEXTERNALNAMESET_IID); + +static NS_DEFINE_IID(kInetServiceIID, NS_INETSERVICE_IID); +static NS_DEFINE_IID(kInetServiceCID, NS_NETSERVICE_CID); +static NS_DEFINE_IID(kInetLibURLIID, NS_INETLIBURL_IID); +static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID); + +static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID); +static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID); + +static NS_DEFINE_IID(kIMailCoreIID, NS_IDOMMAILCORE_IID); +static NS_DEFINE_IID(kIAppCoresIID, NS_IDOMAPPCORES_IID); +static NS_DEFINE_IID(kAppCoresCID, NS_AppCores_CID); +static NS_DEFINE_IID(kMailCoreCID, NS_MailCore_CID); +static NS_DEFINE_IID(kAppCoresFactoryCID, NS_AppCoresFactory_CID); +static NS_DEFINE_IID(kMailCoreFactoryCID, NS_MailCoreFactory_CID); + + +static SDL_TaskList *gTasks = nsnull; +static SDL_TaskList *gNextReadyTask = nsnull; + + +///////////////////////////////////////////////////////////////////////// +// nsAppCoresManager +///////////////////////////////////////////////////////////////////////// + +nsAppCoresManager::nsAppCoresManager() +{ + mScriptObject = nsnull; + + IncInstanceCount(); + NS_INIT_REFCNT(); +} + + +//-------------------------------------------------------- +nsAppCoresManager::~nsAppCoresManager() +{ + DecInstanceCount(); +} + + +NS_IMPL_ADDREF(nsAppCoresManager) +NS_IMPL_RELEASE(nsAppCoresManager) + + + +//-------------------------------------------------------- +NS_IMETHODIMP +nsAppCoresManager::QueryInterface(REFNSIID aIID,void** aInstancePtr) +{ + if (aInstancePtr == NULL) + { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aInstancePtr = NULL; + + + if ( aIID.Equals(kIAppCoresIID) ) + { + nsIDOMAppCores* tmp = this; + *aInstancePtr = (void*)tmp; + AddRef(); + return NS_OK; + } + else if ( aIID.Equals(kIScriptObjectOwnerIID)) + { + nsIScriptObjectOwner* tmp = this; + *aInstancePtr = (void*)tmp; + AddRef(); + return NS_OK; + } + else if ( aIID.Equals(kISupportsIID) ) + { + + nsIDOMAppCores* tmp1 = this; + nsISupports* tmp2 = tmp1; + + *aInstancePtr = (void*)tmp2; + AddRef(); + return NS_OK; + } + + return NS_NOINTERFACE; +} + + +//-------------------------------------------------------- +NS_IMETHODIMP +nsAppCoresManager::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + nsresult res = NS_OK; + + if (nsnull == mScriptObject) + { + nsIScriptGlobalObject *global = aContext->GetGlobalObject(); + + res = NS_NewScriptAppCores(aContext, (nsISupports *)(nsIDOMAppCores*)this, global, (void**)&mScriptObject); + + NS_IF_RELEASE(global); + } + + + *aScriptObject = mScriptObject; + return res; +} + +//-------------------------------------------------------- +NS_IMETHODIMP +nsAppCoresManager::SetScriptObject(void *aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + +//-------------------------------------------------------- +NS_IMETHODIMP +nsAppCoresManager::Startup() +{ + + + /***************************************/ + /* Add us to the Javascript Name Space */ + /***************************************/ + + nsIScriptNameSetRegistry *registry; + nsresult result = nsServiceManager::GetService(kCScriptNameSetRegistryCID, + kIScriptNameSetRegistryIID, + (nsISupports **)®istry); + if (NS_OK == result) + { + nsAppCoresNameSet* nameSet = new nsAppCoresNameSet(); + registry->AddExternalNameSet(nameSet); + /* FIX - do we need to release this service? When we do, it get deleted,and our name is lost. */ + } + + return result; +} + +//-------------------------------------------------------- +NS_IMETHODIMP +nsAppCoresManager::Shutdown() +{ + return NS_OK; +} + +//-------------------------------------------------------- +NS_IMETHODIMP +nsAppCoresManager::Add(nsIDOMBaseAppCore* aTask) +{ + + if (aTask == NULL) + return NS_ERROR_FAILURE; + + /* Check to see if we already have this task in our list */ + SDL_TaskList *node = gTasks; + nsString nodeIDString; + nsString addIDString; + + aTask->GetId(addIDString); + + while (node != NULL) + { + node->task->GetId(nodeIDString); + + if (nodeIDString == addIDString) + { + /*we already have this ID in our list, ignore */ + return NS_OK; + } + + node = node->next; + } + + /* add the task to our list */ + SDL_TaskList* taskNode = (SDL_TaskList*)PR_MALLOC(sizeof(SDL_TaskList)); + + aTask->AddRef(); + + taskNode->next = gTasks; + taskNode->task = aTask; + gTasks = taskNode; + + /* Lets set the next task to run to this one */ + gNextReadyTask = taskNode; + + return NS_OK; +} + +//-------------------------------------------------------- +NS_IMETHODIMP +nsAppCoresManager::Remove(nsIDOMBaseAppCore* aTask) +{ + if (aTask == NULL) + return NS_ERROR_FAILURE; + + /* Remove from our list */ + + SDL_TaskList *node = gTasks; + SDL_TaskList *lastnode = gTasks; + nsString nodeIDString; + nsString doomedIDString; + + aTask->GetId(doomedIDString); + + while (node != NULL) + { + node->task->GetId(nodeIDString); + + if (nodeIDString == doomedIDString) + { + /* we want to delete this node */ + + if (node == gTasks) + { + gTasks = node->next; + } + else + { + lastnode->next = node->next; + } + + node->task->Release(); + PR_DELETE(node); + break; + } + + lastnode = node; + node = node->next; + } + return NS_OK; +} + + + +NS_IMETHODIMP +nsAppCoresManager::Find(const nsString& aId, nsIDOMBaseAppCore** aReturn) +{ + *aReturn=nsnull; + + SDL_TaskList *node = gTasks; + nsString nodeIDString; + + while (node != NULL) + { + node->task->GetId(nodeIDString); + + if (nodeIDString == aId) + { + *aReturn = node->task; + node->task->AddRef(); + break; + } + node = node->next; + } + + return NS_OK; +} + + + + + + diff --git a/mozilla/xpfe/AppCores/nsAppCoresManager.h b/mozilla/xpfe/AppCores/nsAppCoresManager.h new file mode 100644 index 00000000000..5e01b859de7 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsAppCoresManager.h @@ -0,0 +1,71 @@ +/* -*- 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. + */ +#ifndef nsAppCoresManager_h___ +#define nsAppCoresManager_h___ + +#include "nscore.h" +#include "nsString.h" +#include "nsISupports.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMAppCores.h" +#include "prio.h" + +class nsIScriptContext; +class nsIDOMBaseAppCore; + +//////////////////////////////////////////////////////////////////////////////// +// nsAppCoresManager: +//////////////////////////////////////////////////////////////////////////////// +typedef struct _SDL_TaskList SDL_TaskList; + +typedef struct _SDL_TaskList +{ + nsIDOMBaseAppCore *task; + SDL_TaskList *next; + +} SDL_TaskList; + +class nsAppCoresManager : public nsIScriptObjectOwner, public nsIDOMAppCores +{ + public: + + nsAppCoresManager(); + ~nsAppCoresManager(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + + NS_IMETHOD Startup(); + + NS_IMETHOD Shutdown(); + + NS_IMETHOD Add(nsIDOMBaseAppCore* aAppcore); + + NS_IMETHOD Remove(nsIDOMBaseAppCore* aAppcore); + + NS_IMETHOD Find(const nsString& aId, nsIDOMBaseAppCore** aReturn); + + private: + void *mScriptObject; + + +}; + +#endif // nsAppCoresManager_h___ diff --git a/mozilla/xpfe/AppCores/nsAppCoresManagerFactory.cpp b/mozilla/xpfe/AppCores/nsAppCoresManagerFactory.cpp new file mode 100644 index 00000000000..92e19481a9d --- /dev/null +++ b/mozilla/xpfe/AppCores/nsAppCoresManagerFactory.cpp @@ -0,0 +1,129 @@ +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsAppCoresManagerFactory.h" +#include "nsAppCoresManager.h" +#include "nsAppCores.h" +#include "pratom.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); + +///////////////////////////////////////////////////////////////////////// +// nsAppCoresImplFactory +///////////////////////////////////////////////////////////////////////// + +nsAppCoresManagerFactory::nsAppCoresManagerFactory(void) +{ + mRefCnt=0; + IncInstanceCount(); +} + +nsAppCoresManagerFactory::~nsAppCoresManagerFactory(void) +{ + IncInstanceCount(); +} + + + +NS_IMETHODIMP +nsAppCoresManagerFactory::QueryInterface(REFNSIID aIID,void** aInstancePtr) +{ + if (aInstancePtr == NULL) + { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aInstancePtr = NULL; + + if ( aIID.Equals(kISupportsIID) ) + { + *aInstancePtr = (void*) this; + } + else if ( aIID.Equals(kIFactoryIID) ) + { + *aInstancePtr = (void*) this; + } + + if (aInstancePtr == NULL) + { + return NS_ERROR_NO_INTERFACE; + } + + AddRef(); + return NS_OK; +} + + + +NS_IMETHODIMP +nsAppCoresManagerFactory::AddRef(void) +{ + return ++mRefCnt; +} + + +NS_IMETHODIMP +nsAppCoresManagerFactory::Release(void) +{ + if (--mRefCnt ==0) + { + delete this; + return 0; // Don't access mRefCnt after deleting! + } + + return mRefCnt; +} + +NS_IMETHODIMP +nsAppCoresManagerFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult) +{ + if (aResult == NULL) + { + return NS_ERROR_NULL_POINTER; + } + + *aResult = NULL; + + /* do I have to use iSupports? */ + nsAppCoresManager *inst = new nsAppCoresManager(); + + if (inst == NULL) + return NS_ERROR_OUT_OF_MEMORY; + + nsresult result = inst->QueryInterface(aIID, aResult); + + if (result != NS_OK) + delete inst; + + return result; + +} + +NS_IMETHODIMP +nsAppCoresManagerFactory::LockFactory(PRBool aLock) +{ + if (aLock) + IncLockCount(); + else + DecLockCount(); + + return NS_OK; +} diff --git a/mozilla/xpfe/AppCores/nsAppCoresManagerFactory.h b/mozilla/xpfe/AppCores/nsAppCoresManagerFactory.h new file mode 100644 index 00000000000..1bb22b3a992 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsAppCoresManagerFactory.h @@ -0,0 +1,47 @@ +/* -*- 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. + */ +#ifndef nsAppCoresManagerFactory_h___ +#define nsAppCoresManagerFactory_h___ + +#include "nsIFactory.h" +#include "nsISupports.h" + +//////////////////////////////////////////////////////////////////////////////// +// nsAppCoresManagerFactory: +//////////////////////////////////////////////////////////////////////////////// + +class nsAppCoresManagerFactory : public nsIFactory +{ + public: + + nsAppCoresManagerFactory(); + ~nsAppCoresManagerFactory(); + + PRBool CanUnload(void); + + NS_DECL_ISUPPORTS + + NS_IMETHOD CreateInstance(nsISupports *aOuter, + REFNSIID aIID, + void **aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + +}; + +#endif // nsAppCoresManagerFactory_h___ \ No newline at end of file diff --git a/mozilla/xpfe/AppCores/nsAppCoresNameSet.cpp b/mozilla/xpfe/AppCores/nsAppCoresNameSet.cpp new file mode 100644 index 00000000000..e6f7a04e685 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsAppCoresNameSet.cpp @@ -0,0 +1,108 @@ + +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +//////////////////////////////////////////////////////////////////////////////// +// nsAppCoresNameSet +//////////////////////////////////////////////////////////////////////////////// +#include "nsAppCoresNameSet.h" +#include "nsIScriptContext.h" +#include "nsIScriptNameSpaceManager.h" +#include "nsIDOMAppCores.h" +#include "nsIDOMMailCore.h" +#include "nsIDOMToolbarCore.h" +#include "nsIDOMBrowserAppCore.h" +#include "nsAppCoresCIDs.h" + + +static NS_DEFINE_IID(kIScriptExternalNameSetIID, NS_ISCRIPTEXTERNALNAMESET_IID); +static NS_DEFINE_IID(kAppCoresCID, NS_AppCores_CID); +static NS_DEFINE_IID(kMailCoreCID, NS_MailCore_CID); +static NS_DEFINE_IID(kToolbarCoreCID, NS_TOOLBARCORE_CID); +static NS_DEFINE_IID(kBrowserAppCoreCID, NS_BROWSERAPPCORE_CID); + +nsAppCoresNameSet::nsAppCoresNameSet() +{ + NS_INIT_REFCNT(); +} + +nsAppCoresNameSet::~nsAppCoresNameSet() +{ +} + +NS_IMPL_ISUPPORTS(nsAppCoresNameSet, kIScriptExternalNameSetIID); + + + + +NS_IMETHODIMP +nsAppCoresNameSet::InitializeClasses(nsIScriptContext* aScriptContext) +{ + nsresult result = NS_OK; + + result = NS_InitAppCoresClass(aScriptContext, nsnull); + if (NS_OK != result) return result; + + result = NS_InitMailCoreClass(aScriptContext, nsnull); + result = NS_InitToolbarCoreClass(aScriptContext, nsnull); + result = NS_InitBrowserAppCoreClass(aScriptContext, nsnull); + + return result; +} + + + + +NS_IMETHODIMP +nsAppCoresNameSet::AddNameSet(nsIScriptContext* aScriptContext) +{ + nsresult result = NS_OK; + nsIScriptNameSpaceManager* manager; + + result = aScriptContext->GetNameSpaceManager(&manager); + if (NS_OK == result) + { + result = manager->RegisterGlobalName("MailCore", + kMailCoreCID, + PR_TRUE); + + if (NS_OK != result) return result; + + result = manager->RegisterGlobalName("ToolbarCore", + kToolbarCoreCID, + PR_TRUE); + + if (NS_OK != result) return result; + + result = manager->RegisterGlobalName("BrowserAppCore", + kBrowserAppCoreCID, + PR_TRUE); + + if (NS_OK != result) return result; + + result = manager->RegisterGlobalName("AppCoresManager", + kAppCoresCID, + PR_FALSE); + + + NS_RELEASE(manager); + } + return result; +} + diff --git a/mozilla/xpfe/AppCores/nsAppCoresNameSet.h b/mozilla/xpfe/AppCores/nsAppCoresNameSet.h new file mode 100644 index 00000000000..847d97283cb --- /dev/null +++ b/mozilla/xpfe/AppCores/nsAppCoresNameSet.h @@ -0,0 +1,41 @@ +/* -*- 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. + */ +#ifndef nsAppCoresNameSet_h___ +#define nsAppCoresNameSet_h___ + +#include "nsISupports.h" +#include "nsIScriptExternalNameSet.h" + +class nsIScriptContext; + +//////////////////////////////////////////////////////////////////////////////// +// nsAppCoresNameSet: +//////////////////////////////////////////////////////////////////////////////// + +class nsAppCoresNameSet : public nsIScriptExternalNameSet +{ + public: + nsAppCoresNameSet(); + ~nsAppCoresNameSet(); + + NS_DECL_ISUPPORTS + NS_IMETHOD InitializeClasses(nsIScriptContext* aScriptContext); + NS_IMETHOD AddNameSet(nsIScriptContext* aScriptContext); +}; + +#endif // nsAppCoresNameSet_h___ diff --git a/mozilla/xpfe/AppCores/nsBaseAppCore.cpp b/mozilla/xpfe/AppCores/nsBaseAppCore.cpp new file mode 100644 index 00000000000..43ab6be11ba --- /dev/null +++ b/mozilla/xpfe/AppCores/nsBaseAppCore.cpp @@ -0,0 +1,180 @@ + +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsBaseAppCore.h" +#include "nsIScriptContextOwner.h" +#include "nsAppCoresManager.h" +#include "nsIDOMDocument.h" +#include "nsIDOMNode.h" +#include "nsIDOMElement.h" +#include "nsIScriptContext.h" +#include "nsIDOMWindow.h" +#include "nsIDocument.h" + +// Globals +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +static NS_DEFINE_IID(kIDOMBaseAppCoreIID, nsIDOMBaseAppCore::IID()); +static NS_DEFINE_IID(kIDocumentIID, nsIDocument::IID()); + + +///////////////////////////////////////////////////////////////////////// +// nsBaseAppCore +///////////////////////////////////////////////////////////////////////// + +nsBaseAppCore::nsBaseAppCore() +{ + mScriptObject = nsnull; + IncInstanceCount(); + NS_INIT_REFCNT(); +} + +nsBaseAppCore::~nsBaseAppCore() +{ + DecInstanceCount(); +} + + +NS_IMPL_ADDREF(nsBaseAppCore) +NS_IMPL_RELEASE(nsBaseAppCore) + + +NS_IMETHODIMP +nsBaseAppCore::QueryInterface(REFNSIID aIID,void** aInstancePtr) +{ + if (aInstancePtr == NULL) { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aInstancePtr = NULL; + + if ( aIID.Equals(kIScriptObjectOwnerIID)) { + *aInstancePtr = (void*) ((nsIScriptObjectOwner*)this); + AddRef(); + return NS_OK; + } + if ( aIID.Equals(kIDOMBaseAppCoreIID)) { + *aInstancePtr = (void*) ((nsIDOMBaseAppCore*)this); + AddRef(); + return NS_OK; + } + else if ( aIID.Equals(kISupportsIID) ) { + *aInstancePtr = (void*)(nsISupports*)(nsIScriptObjectOwner*)this; + AddRef(); + return NS_OK; + } + + return NS_NOINTERFACE; +} + + +NS_IMETHODIMP +nsBaseAppCore::SetScriptObject(void *aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + + +NS_IMETHODIMP +nsBaseAppCore::Init(const nsString& aId) +{ + + mId = aId; + + return NS_OK; +} + +NS_IMETHODIMP +nsBaseAppCore::GetId(nsString& aId) +{ + aId = mId; + return NS_OK; +} + +//---------------------------------------- +nsIScriptContext * +nsBaseAppCore::GetScriptContext(nsIDOMWindow * aWin) +{ + nsIScriptContext * scriptContext = nsnull; + if (nsnull != aWin) { + nsIDOMDocument * domDoc; + aWin->GetDocument(&domDoc); + if (nsnull != domDoc) { + nsIDocument * doc; + if (NS_OK == domDoc->QueryInterface(kIDocumentIID,(void**)&doc)) { + nsIScriptContextOwner * owner = doc->GetScriptContextOwner(); + if (nsnull != owner) { + owner->GetScriptContext(&scriptContext); + NS_RELEASE(owner); + } + NS_RELEASE(doc); + } + NS_RELEASE(domDoc); + } + } + return scriptContext; +} + +//---------------------------------------- +nsCOMPtr nsBaseAppCore::FindNamedDOMNode(const nsString &aName, nsIDOMNode * aParent, PRInt32 & aCount, PRInt32 aEndCount) +{ + nsCOMPtr node; + aParent->GetFirstChild(getter_AddRefs(node)); + while (node) { + nsString name; + node->GetNodeName(name); + //printf("FindNamedDOMNode[%s] %d == %d\n", nsAutoCString(name), aCount, aEndCount); + if (name.Equals(aName)) { + aCount++; + if (aCount == aEndCount) + return node; + } + PRBool hasChildren; + node->HasChildNodes(&hasChildren); + if (hasChildren) { + nsCOMPtr found(FindNamedDOMNode(aName, node, aCount, aEndCount)); + if (found) + return found; + } + nsCOMPtr oldNode = node; + oldNode->GetNextSibling(getter_AddRefs(node)); + } + node = nsnull; + return node; + +} // nsToolbarCore::FindNamedDOMNode + +//---------------------------------------- +nsCOMPtr nsBaseAppCore::GetParentNodeFromDOMDoc(nsIDOMDocument * aDOMDoc) +{ + nsCOMPtr node; // null + + if (nsnull == aDOMDoc) { + return node; + } + + nsCOMPtr element; + aDOMDoc->GetDocumentElement(getter_AddRefs(element)); + if (element) + return nsCOMPtr(element); + return node; +} // nsToolbarCore::GetParentNodeFromDOMDoc \ No newline at end of file diff --git a/mozilla/xpfe/AppCores/nsBaseAppCore.h b/mozilla/xpfe/AppCores/nsBaseAppCore.h new file mode 100644 index 00000000000..1109e3013a3 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsBaseAppCore.h @@ -0,0 +1,63 @@ +/* -*- 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. + */ +#ifndef nsBaseAppCore_h___ +#define nsBaseAppCore_h___ + +#include "nsAppCores.h" + +//#include "nscore.h" +#include "nsString.h" +#include "nsISupports.h" +#include "nsIScriptObjectOwner.h" +#include "nsIDOMBaseAppCore.h" +#include "nsCOMPtr.h" + +class nsIDOMNode; +class nsIDOMDocument; +class nsIScriptContext; +class nsIDOMWindow; + +//////////////////////////////////////////////////////////////////////////////// +// nsBaseAppCore: +//////////////////////////////////////////////////////////////////////////////// + +class nsBaseAppCore : public nsIScriptObjectOwner, public nsIDOMBaseAppCore +{ + public: + + nsBaseAppCore(); + ~nsBaseAppCore(); + + + NS_DECL_ISUPPORTS + //NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + + NS_IMETHOD Init(const nsString& aId); + NS_IMETHOD GetId(nsString& aId); + + protected: + nsCOMPtr FindNamedDOMNode(const nsString &aName, nsIDOMNode * aParent, PRInt32 & aCount, PRInt32 aEndCount); + nsCOMPtr GetParentNodeFromDOMDoc(nsIDOMDocument * aDOMDoc); + nsIScriptContext * GetScriptContext(nsIDOMWindow * aWin); + + nsString mId; /* User ID */ + void *mScriptObject; +}; + +#endif // nsBaseAppCore_h___ \ No newline at end of file diff --git a/mozilla/xpfe/AppCores/nsBrowserAppCore.cpp b/mozilla/xpfe/AppCores/nsBrowserAppCore.cpp new file mode 100644 index 00000000000..2583ad4bd61 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsBrowserAppCore.cpp @@ -0,0 +1,202 @@ + +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsBrowserAppCore.h" +#include "nsIBrowserWindow.h" +#include "nsIWebShell.h" +#include "pratom.h" +#include "nsRepository.h" +#include "nsAppCores.h" +#include "nsAppCoresCIDs.h" +#include "nsAppCoresManager.h" + +#include "nsIScriptContext.h" +#include "nsIScriptContextOwner.h" +#include "nsIDOMDocument.h" +#include "nsIDocument.h" +#include "nsIDOMWindow.h" + + +// Globals +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIBrowserAppCoreIID, NS_IDOMBROWSERAPPCORE_IID); + +static NS_DEFINE_IID(kIDOMDocumentIID, nsIDOMDocument::IID()); +static NS_DEFINE_IID(kIDocumentIID, nsIDocument::IID()); + +static NS_DEFINE_IID(kBrowserAppCoreCID, NS_BROWSERAPPCORE_CID); + + +///////////////////////////////////////////////////////////////////////// +// nsBrowserAppCore +///////////////////////////////////////////////////////////////////////// + +nsBrowserAppCore::nsBrowserAppCore() +{ + printf("Created nsBrowserAppCore\n"); + + mScriptObject = nsnull; + mToolbarWindow = nsnull; + mToolbarScriptContext = nsnull; + mContentWindow = nsnull; + mContentScriptContext = nsnull; + + IncInstanceCount(); + NS_INIT_REFCNT(); +} + +nsBrowserAppCore::~nsBrowserAppCore() +{ + NS_IF_RELEASE(mToolbarWindow); + NS_IF_RELEASE(mToolbarScriptContext); + NS_IF_RELEASE(mContentWindow); + NS_IF_RELEASE(mContentScriptContext); + DecInstanceCount(); +} + + +NS_IMPL_ADDREF(nsBrowserAppCore) +NS_IMPL_RELEASE(nsBrowserAppCore) + + +NS_IMETHODIMP +nsBrowserAppCore::QueryInterface(REFNSIID aIID,void** aInstancePtr) +{ + if (aInstancePtr == NULL) { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aInstancePtr = NULL; + + if ( aIID.Equals(kIBrowserAppCoreIID) ) { + *aInstancePtr = (void*) ((nsIDOMBrowserAppCore*)this); + AddRef(); + return NS_OK; + } + + return nsBaseAppCore::QueryInterface(aIID, aInstancePtr); +} + + +NS_IMETHODIMP +nsBrowserAppCore::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + NS_PRECONDITION(nsnull != aScriptObject, "null arg"); + nsresult res = NS_OK; + if (nsnull == mScriptObject) + { + res = NS_NewScriptBrowserAppCore(aContext, + (nsISupports *)(nsIDOMBrowserAppCore*)this, + nsnull, + &mScriptObject); + } + + *aScriptObject = mScriptObject; + return res; +} + +NS_IMETHODIMP +nsBrowserAppCore::Init(const nsString& aId) +{ + + nsBaseAppCore::Init(aId); + + nsAppCoresManager* sdm = new nsAppCoresManager(); + sdm->Add((nsIDOMBaseAppCore *)(nsBaseAppCore *)this); + delete sdm; + + return NS_OK; +} + +NS_IMETHODIMP +nsBrowserAppCore::Back() +{ + ExecuteScript(mToolbarScriptContext, mDisableScript); + ExecuteScript(mContentScriptContext, "window.back()"); + ExecuteScript(mToolbarScriptContext, mEnableScript); + return NS_OK; +} + +NS_IMETHODIMP +nsBrowserAppCore::Forward() +{ + ExecuteScript(mToolbarScriptContext, mDisableScript); + ExecuteScript(mContentScriptContext, "window.forward()"); + ExecuteScript(mToolbarScriptContext, mEnableScript); + return NS_OK; +} + +NS_IMETHODIMP +nsBrowserAppCore::DisableCallback(const nsString& aScript) +{ + mDisableScript = aScript; + return NS_OK; +} + +NS_IMETHODIMP +nsBrowserAppCore::EnableCallback(const nsString& aScript) +{ + mEnableScript = aScript; + return NS_OK; +} + +NS_IMETHODIMP +nsBrowserAppCore::LoadUrl(const nsString& aUrl) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsBrowserAppCore::SetToolbarWindow(nsIDOMWindow* aWin) +{ + mToolbarWindow = aWin; + NS_ADDREF(aWin); + mToolbarScriptContext = GetScriptContext(aWin); + + return NS_OK; +} + +NS_IMETHODIMP +nsBrowserAppCore::SetContentWindow(nsIDOMWindow* aWin) +{ + mContentWindow = aWin; + NS_ADDREF(aWin); + mContentScriptContext = GetScriptContext(aWin); + + return NS_OK; +} + + +NS_IMETHODIMP +nsBrowserAppCore::ExecuteScript(nsIScriptContext * aContext, const nsString& aScript) +{ + if (nsnull != aContext) { + const char* url = ""; + PRBool isUndefined = PR_FALSE; + nsString rVal; + aContext->EvaluateString(aScript, url, 0, rVal, &isUndefined); + } + return NS_OK; +} + + + + diff --git a/mozilla/xpfe/AppCores/nsBrowserAppCore.h b/mozilla/xpfe/AppCores/nsBrowserAppCore.h new file mode 100644 index 00000000000..a79dc1bbd29 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsBrowserAppCore.h @@ -0,0 +1,74 @@ +/* -*- 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. + */ +#ifndef nsBrowserAppCore_h___ +#define nsBrowserAppCore_h___ + +//#include "nsAppCores.h" + +#include "nscore.h" +#include "nsString.h" +#include "nsISupports.h" + +#include "nsIDOMBrowserAppCore.h" +#include "nsBaseAppCore.h" + +class nsIBrowserWindow; +class nsIWebShell; +class nsIScriptContext; +class nsIDOMWindow; + +//////////////////////////////////////////////////////////////////////////////// +// nsBrowserAppCore: +//////////////////////////////////////////////////////////////////////////////// + +class nsBrowserAppCore : public nsBaseAppCore, + public nsIDOMBrowserAppCore +{ + public: + + nsBrowserAppCore(); + ~nsBrowserAppCore(); + + + NS_DECL_ISUPPORTS + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD Init(const nsString& aId); + NS_IMETHOD GetId(nsString& aId) { return nsBaseAppCore::GetId(aId); } + + NS_IMETHOD Back(); + NS_IMETHOD Forward(); + NS_IMETHOD LoadUrl(const nsString& aUrl); + NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin); + NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin); + NS_IMETHOD DisableCallback(const nsString& aScript); + NS_IMETHOD EnableCallback(const nsString& aScript); + + protected: + NS_IMETHOD ExecuteScript(nsIScriptContext * aContext, const nsString& aScript); + + nsString mEnableScript; + nsString mDisableScript; + + nsIScriptContext *mToolbarScriptContext; + nsIScriptContext *mContentScriptContext; + + nsIDOMWindow *mToolbarWindow; + nsIDOMWindow *mContentWindow; +}; + +#endif // nsBrowserAppCore_h___ \ No newline at end of file diff --git a/mozilla/xpfe/AppCores/nsBrowserAppCoreFactory.cpp b/mozilla/xpfe/AppCores/nsBrowserAppCoreFactory.cpp new file mode 100644 index 00000000000..6b815b80a28 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsBrowserAppCoreFactory.cpp @@ -0,0 +1,131 @@ +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsAppCores.h" +#include "nsBrowserAppCoreFactory.h" +#include "nsBrowserAppCore.h" +#include "pratom.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); + +///////////////////////////////////////////////////////////////////////// +// nsBrowserAppCoreFactory +///////////////////////////////////////////////////////////////////////// + +nsBrowserAppCoreFactory::nsBrowserAppCoreFactory(void) +{ + mRefCnt=0; + IncInstanceCount(); +} + +nsBrowserAppCoreFactory::~nsBrowserAppCoreFactory(void) +{ + DecInstanceCount(); +} + + + +NS_IMETHODIMP +nsBrowserAppCoreFactory::QueryInterface(REFNSIID aIID,void** aInstancePtr) +{ + if (aInstancePtr == NULL) + { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aInstancePtr = NULL; + + if ( aIID.Equals(kISupportsIID) ) + { + *aInstancePtr = (void*) this; + } + else if ( aIID.Equals(kIFactoryIID) ) + { + *aInstancePtr = (void*) this; + } + + if (aInstancePtr == NULL) + { + return NS_ERROR_NO_INTERFACE; + } + + AddRef(); + return NS_OK; +} + + + +NS_IMETHODIMP +nsBrowserAppCoreFactory::AddRef(void) +{ + return ++mRefCnt; +} + + +NS_IMETHODIMP +nsBrowserAppCoreFactory::Release(void) +{ + if (--mRefCnt ==0) + { + delete this; + return 0; // Don't access mRefCnt after deleting! + } + + return mRefCnt; +} + +NS_IMETHODIMP +nsBrowserAppCoreFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult) +{ + if (aResult == NULL) + { + return NS_ERROR_NULL_POINTER; + } + + *aResult = NULL; + + /* do I have to use iSupports? */ + nsBrowserAppCore *inst = new nsBrowserAppCore(); + + if (inst == NULL) + return NS_ERROR_OUT_OF_MEMORY; + + nsresult result = inst->QueryInterface(aIID, aResult); + + if (result != NS_OK) + delete inst; + + return result; + +} + +NS_IMETHODIMP +nsBrowserAppCoreFactory::LockFactory(PRBool aLock) +{ + if (aLock) + IncLockCount(); + else + DecLockCount(); + + return NS_OK; +} + + diff --git a/mozilla/xpfe/AppCores/nsBrowserAppCoreFactory.h b/mozilla/xpfe/AppCores/nsBrowserAppCoreFactory.h new file mode 100644 index 00000000000..bc8f72bf163 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsBrowserAppCoreFactory.h @@ -0,0 +1,49 @@ +/* -*- 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. + */ +#ifndef nsBrowserAppCoreFactory_h___ +#define nsBrowserAppCoreFactory_h___ + +//#include "nscore.h" +//#include "nsString.h" +#include "nsIFactory.h" +#include "nsISupports.h" + +//////////////////////////////////////////////////////////////////////////////// +// nsBrowserAppCoreFactory: +//////////////////////////////////////////////////////////////////////////////// + +class nsBrowserAppCoreFactory : public nsIFactory +{ + public: + + nsBrowserAppCoreFactory(); + ~nsBrowserAppCoreFactory(); + + PRBool CanUnload(void); + + NS_DECL_ISUPPORTS + + NS_IMETHOD CreateInstance(nsISupports *aOuter, + REFNSIID aIID, + void **aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + +}; + +#endif // nsBrowserAppCoreFactory_h___ \ No newline at end of file diff --git a/mozilla/xpfe/AppCores/nsIDOMAppCores.h b/mozilla/xpfe/AppCores/nsIDOMAppCores.h new file mode 100644 index 00000000000..a0080a2dc5f --- /dev/null +++ b/mozilla/xpfe/AppCores/nsIDOMAppCores.h @@ -0,0 +1,70 @@ +/* -*- 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 nsIDOMAppCores_h__ +#define nsIDOMAppCores_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" + +class nsIDOMBaseAppCore; + +#define NS_IDOMAPPCORES_IID \ + { 0x18c2f981, 0xb09f, 0x11d2, \ + {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}} + +class nsIDOMAppCores : public nsISupports { +public: + static const nsIID& IID() { static nsIID iid = NS_IDOMAPPCORES_IID; return iid; } + + NS_IMETHOD Startup()=0; + + NS_IMETHOD Shutdown()=0; + + NS_IMETHOD Add(nsIDOMBaseAppCore* aAppcore)=0; + + NS_IMETHOD Remove(nsIDOMBaseAppCore* aAppcore)=0; + + NS_IMETHOD Find(const nsString& aId, nsIDOMBaseAppCore** aReturn)=0; +}; + + +#define NS_DECL_IDOMAPPCORES \ + NS_IMETHOD Startup(); \ + NS_IMETHOD Shutdown(); \ + NS_IMETHOD Add(nsIDOMBaseAppCore* aAppcore); \ + NS_IMETHOD Remove(nsIDOMBaseAppCore* aAppcore); \ + NS_IMETHOD Find(const nsString& aId, nsIDOMBaseAppCore** aReturn); \ + + + +#define NS_FORWARD_IDOMAPPCORES(_to) \ + NS_IMETHOD Startup() { return _to##Startup(); } \ + NS_IMETHOD Shutdown() { return _to##Shutdown(); } \ + NS_IMETHOD Add(nsIDOMBaseAppCore* aAppcore) { return _to##Add(aAppcore); } \ + NS_IMETHOD Remove(nsIDOMBaseAppCore* aAppcore) { return _to##Remove(aAppcore); } \ + NS_IMETHOD Find(const nsString& aId, nsIDOMBaseAppCore** aReturn) { return _to##Find(aId, aReturn); } \ + + +extern nsresult NS_InitAppCoresClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptAppCores(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMAppCores_h__ diff --git a/mozilla/xpfe/AppCores/nsIDOMBaseAppCore.h b/mozilla/xpfe/AppCores/nsIDOMBaseAppCore.h new file mode 100644 index 00000000000..5fc5d2c5316 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsIDOMBaseAppCore.h @@ -0,0 +1,57 @@ +/* -*- 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 nsIDOMBaseAppCore_h__ +#define nsIDOMBaseAppCore_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" + + +#define NS_IDOMBASEAPPCORE_IID \ + { 0xbe5c13bd, 0xba9f, 0x11d2, \ + {0x96, 0xc4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56}} + +class nsIDOMBaseAppCore : public nsISupports { +public: + static const nsIID& IID() { static nsIID iid = NS_IDOMBASEAPPCORE_IID; return iid; } + + NS_IMETHOD GetId(nsString& aId)=0; + + NS_IMETHOD Init(const nsString& aId)=0; +}; + + +#define NS_DECL_IDOMBASEAPPCORE \ + NS_IMETHOD GetId(nsString& aId); \ + NS_IMETHOD Init(const nsString& aId); \ + + + +#define NS_FORWARD_IDOMBASEAPPCORE(_to) \ + NS_IMETHOD GetId(nsString& aId) { return _to##GetId(aId); } \ + NS_IMETHOD Init(const nsString& aId) { return _to##Init(aId); } \ + + +extern nsresult NS_InitBaseAppCoreClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptBaseAppCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMBaseAppCore_h__ diff --git a/mozilla/xpfe/AppCores/nsIDOMBrowserAppCore.h b/mozilla/xpfe/AppCores/nsIDOMBrowserAppCore.h new file mode 100644 index 00000000000..c5bff16589c --- /dev/null +++ b/mozilla/xpfe/AppCores/nsIDOMBrowserAppCore.h @@ -0,0 +1,79 @@ +/* -*- 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 nsIDOMBrowserAppCore_h__ +#define nsIDOMBrowserAppCore_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" +#include "nsIDOMBaseAppCore.h" + +class nsIDOMWindow; + +#define NS_IDOMBROWSERAPPCORE_IID \ + { 0xb0ffb697, 0xbab4, 0x11d2, \ + {0x96, 0xc4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56}} + +class nsIDOMBrowserAppCore : public nsIDOMBaseAppCore { +public: + static const nsIID& IID() { static nsIID iid = NS_IDOMBROWSERAPPCORE_IID; return iid; } + + NS_IMETHOD Back()=0; + + NS_IMETHOD Forward()=0; + + NS_IMETHOD LoadUrl(const nsString& aUrl)=0; + + NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin)=0; + + NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin)=0; + + NS_IMETHOD DisableCallback(const nsString& aScript)=0; + + NS_IMETHOD EnableCallback(const nsString& aScript)=0; +}; + + +#define NS_DECL_IDOMBROWSERAPPCORE \ + NS_IMETHOD Back(); \ + NS_IMETHOD Forward(); \ + NS_IMETHOD LoadUrl(const nsString& aUrl); \ + NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin); \ + NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin); \ + NS_IMETHOD DisableCallback(const nsString& aScript); \ + NS_IMETHOD EnableCallback(const nsString& aScript); \ + + + +#define NS_FORWARD_IDOMBROWSERAPPCORE(_to) \ + NS_IMETHOD Back() { return _to##Back(); } \ + NS_IMETHOD Forward() { return _to##Forward(); } \ + NS_IMETHOD LoadUrl(const nsString& aUrl) { return _to##LoadUrl(aUrl); } \ + NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin) { return _to##SetToolbarWindow(aWin); } \ + NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin) { return _to##SetContentWindow(aWin); } \ + NS_IMETHOD DisableCallback(const nsString& aScript) { return _to##DisableCallback(aScript); } \ + NS_IMETHOD EnableCallback(const nsString& aScript) { return _to##EnableCallback(aScript); } \ + + +extern nsresult NS_InitBrowserAppCoreClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptBrowserAppCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMBrowserAppCore_h__ diff --git a/mozilla/xpfe/AppCores/nsIDOMMailCore.h b/mozilla/xpfe/AppCores/nsIDOMMailCore.h new file mode 100644 index 00000000000..96bab410b3c --- /dev/null +++ b/mozilla/xpfe/AppCores/nsIDOMMailCore.h @@ -0,0 +1,63 @@ +/* -*- 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 nsIDOMMailCore_h__ +#define nsIDOMMailCore_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" +#include "nsIDOMBaseAppCore.h" + +class nsIDOMWindow; + +#define NS_IDOMMAILCORE_IID \ + { 0x18c2f980, 0xb09f, 0x11d2, \ + {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}} + +class nsIDOMMailCore : public nsIDOMBaseAppCore { +public: + static const nsIID& IID() { static nsIID iid = NS_IDOMMAILCORE_IID; return iid; } + + NS_IMETHOD SendMail(const nsString& aAddrTo, const nsString& aSubject, const nsString& aMsg)=0; + + NS_IMETHOD MailCompleteCallback(const nsString& aScript)=0; + + NS_IMETHOD SetWindow(nsIDOMWindow* aWin)=0; +}; + + +#define NS_DECL_IDOMMAILCORE \ + NS_IMETHOD SendMail(const nsString& aAddrTo, const nsString& aSubject, const nsString& aMsg); \ + NS_IMETHOD MailCompleteCallback(const nsString& aScript); \ + NS_IMETHOD SetWindow(nsIDOMWindow* aWin); \ + + + +#define NS_FORWARD_IDOMMAILCORE(_to) \ + NS_IMETHOD SendMail(const nsString& aAddrTo, const nsString& aSubject, const nsString& aMsg) { return _to##SendMail(aAddrTo, aSubject, aMsg); } \ + NS_IMETHOD MailCompleteCallback(const nsString& aScript) { return _to##MailCompleteCallback(aScript); } \ + NS_IMETHOD SetWindow(nsIDOMWindow* aWin) { return _to##SetWindow(aWin); } \ + + +extern nsresult NS_InitMailCoreClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptMailCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMMailCore_h__ diff --git a/mozilla/xpfe/AppCores/nsIDOMToolbarCore.h b/mozilla/xpfe/AppCores/nsIDOMToolbarCore.h new file mode 100644 index 00000000000..64ac2cce65b --- /dev/null +++ b/mozilla/xpfe/AppCores/nsIDOMToolbarCore.h @@ -0,0 +1,59 @@ +/* -*- 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 nsIDOMToolbarCore_h__ +#define nsIDOMToolbarCore_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" +#include "nsIDOMBaseAppCore.h" + +class nsIDOMWindow; + +#define NS_IDOMTOOLBARCORE_IID \ + { 0xbf4ae23e, 0xba9b, 0x11d2, \ + {0x96, 0xc4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56}} + +class nsIDOMToolbarCore : public nsIDOMBaseAppCore { +public: + static const nsIID& IID() { static nsIID iid = NS_IDOMTOOLBARCORE_IID; return iid; } + + NS_IMETHOD SetWindow(nsIDOMWindow* aWin)=0; + + NS_IMETHOD SetStatus(const nsString& aMsg)=0; +}; + + +#define NS_DECL_IDOMTOOLBARCORE \ + NS_IMETHOD SetWindow(nsIDOMWindow* aWin); \ + NS_IMETHOD SetStatus(const nsString& aMsg); \ + + + +#define NS_FORWARD_IDOMTOOLBARCORE(_to) \ + NS_IMETHOD SetWindow(nsIDOMWindow* aWin) { return _to##SetWindow(aWin); } \ + NS_IMETHOD SetStatus(const nsString& aMsg) { return _to##SetStatus(aMsg); } \ + + +extern nsresult NS_InitToolbarCoreClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptToolbarCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMToolbarCore_h__ diff --git a/mozilla/xpfe/AppCores/nsJSAppCores.cpp b/mozilla/xpfe/AppCores/nsJSAppCores.cpp new file mode 100644 index 00000000000..fd749f6f393 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsJSAppCores.cpp @@ -0,0 +1,463 @@ +/* -*- 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 "nsIDOMBaseAppCore.h" +#include "nsIDOMAppCores.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(kIBaseAppCoreIID, NS_IDOMBASEAPPCORE_IID); +static NS_DEFINE_IID(kIAppCoresIID, NS_IDOMAPPCORES_IID); + +NS_DEF_PTR(nsIDOMBaseAppCore); +NS_DEF_PTR(nsIDOMAppCores); + + +/***********************************************************************/ +// +// AppCores Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetAppCoresProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMAppCores *a = (nsIDOMAppCores*)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; +} + +/***********************************************************************/ +// +// AppCores Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetAppCoresProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMAppCores *a = (nsIDOMAppCores*)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; +} + + +// +// AppCores finalizer +// +PR_STATIC_CALLBACK(void) +FinalizeAppCores(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// AppCores enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumerateAppCores(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// AppCores resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolveAppCores(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +// +// Native method Startup +// +PR_STATIC_CALLBACK(JSBool) +AppCoresStartup(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMAppCores *nativeThis = (nsIDOMAppCores*)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->Startup()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function Startup requires 0 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method Shutdown +// +PR_STATIC_CALLBACK(JSBool) +AppCoresShutdown(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMAppCores *nativeThis = (nsIDOMAppCores*)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->Shutdown()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function Shutdown requires 0 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method Add +// +PR_STATIC_CALLBACK(JSBool) +AppCoresAdd(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMAppCores *nativeThis = (nsIDOMAppCores*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + nsIDOMBaseAppCorePtr 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, + kIBaseAppCoreIID, + "BaseAppCore", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->Add(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function Add requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method Remove +// +PR_STATIC_CALLBACK(JSBool) +AppCoresRemove(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMAppCores *nativeThis = (nsIDOMAppCores*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + nsIDOMBaseAppCorePtr 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, + kIBaseAppCoreIID, + "BaseAppCore", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->Remove(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function Remove requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method Find +// +PR_STATIC_CALLBACK(JSBool) +AppCoresFind(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMAppCores *nativeThis = (nsIDOMAppCores*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + nsIDOMBaseAppCore* nativeRet; + 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->Find(b0, &nativeRet)) { + return JS_FALSE; + } + + nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval); + } + else { + JS_ReportError(cx, "Function Find requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +/***********************************************************************/ +// +// class for AppCores +// +JSClass AppCoresClass = { + "AppCores", + JSCLASS_HAS_PRIVATE, + JS_PropertyStub, + JS_PropertyStub, + GetAppCoresProperty, + SetAppCoresProperty, + EnumerateAppCores, + ResolveAppCores, + JS_ConvertStub, + FinalizeAppCores +}; + + +// +// AppCores class properties +// +static JSPropertySpec AppCoresProperties[] = +{ + {0} +}; + + +// +// AppCores class methods +// +static JSFunctionSpec AppCoresMethods[] = +{ + {"Startup", AppCoresStartup, 0}, + {"Shutdown", AppCoresShutdown, 0}, + {"Add", AppCoresAdd, 1}, + {"Remove", AppCoresRemove, 1}, + {"Find", AppCoresFind, 1}, + {0} +}; + + +// +// AppCores constructor +// +PR_STATIC_CALLBACK(JSBool) +AppCores(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + return JS_FALSE; +} + + +// +// AppCores class initialization +// +nsresult NS_InitAppCoresClass(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, "AppCores", &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)) { + + proto = JS_InitClass(jscontext, // context + global, // global object + parent_proto, // parent proto + &AppCoresClass, // JSClass + AppCores, // JSNative ctor + 0, // ctor args + AppCoresProperties, // proto props + AppCoresMethods, // 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 AppCores JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptAppCores(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptAppCores"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMAppCores *aAppCores; + + 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_InitAppCoresClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIAppCoresIID, (void **)&aAppCores); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &AppCoresClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aAppCores); + } + else { + NS_RELEASE(aAppCores); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} diff --git a/mozilla/xpfe/AppCores/nsJSBaseAppCore.cpp b/mozilla/xpfe/AppCores/nsJSBaseAppCore.cpp new file mode 100644 index 00000000000..ef0e8fcca1e --- /dev/null +++ b/mozilla/xpfe/AppCores/nsJSBaseAppCore.cpp @@ -0,0 +1,364 @@ +/* -*- 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 "nsIDOMBaseAppCore.h" +#include "nsIScriptNameSpaceManager.h" +#include "nsRepository.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(kIBaseAppCoreIID, NS_IDOMBASEAPPCORE_IID); + +NS_DEF_PTR(nsIDOMBaseAppCore); + +// +// BaseAppCore property ids +// +enum BaseAppCore_slots { + BASEAPPCORE_ID = -1 +}; + +/***********************************************************************/ +// +// BaseAppCore Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetBaseAppCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMBaseAppCore *a = (nsIDOMBaseAppCore*)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 BASEAPPCORE_ID: + { + nsAutoString prop; + if (NS_OK == a->GetId(prop)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return JS_FALSE; + } + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); + } + + return PR_TRUE; +} + +/***********************************************************************/ +// +// BaseAppCore Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetBaseAppCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMBaseAppCore *a = (nsIDOMBaseAppCore*)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; +} + + +// +// BaseAppCore finalizer +// +PR_STATIC_CALLBACK(void) +FinalizeBaseAppCore(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// BaseAppCore enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumerateBaseAppCore(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// BaseAppCore resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolveBaseAppCore(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +// +// Native method Init +// +PR_STATIC_CALLBACK(JSBool) +BaseAppCoreInit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMBaseAppCore *nativeThis = (nsIDOMBaseAppCore*)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->Init(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function Init requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +/***********************************************************************/ +// +// class for BaseAppCore +// +JSClass BaseAppCoreClass = { + "BaseAppCore", + JSCLASS_HAS_PRIVATE, + JS_PropertyStub, + JS_PropertyStub, + GetBaseAppCoreProperty, + SetBaseAppCoreProperty, + EnumerateBaseAppCore, + ResolveBaseAppCore, + JS_ConvertStub, + FinalizeBaseAppCore +}; + + +// +// BaseAppCore class properties +// +static JSPropertySpec BaseAppCoreProperties[] = +{ + {"id", BASEAPPCORE_ID, JSPROP_ENUMERATE | JSPROP_READONLY}, + {0} +}; + + +// +// BaseAppCore class methods +// +static JSFunctionSpec BaseAppCoreMethods[] = +{ + {"Init", BaseAppCoreInit, 1}, + {0} +}; + + +// +// BaseAppCore constructor +// +PR_STATIC_CALLBACK(JSBool) +BaseAppCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsresult result; + nsIID classID; + nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx); + nsIScriptNameSpaceManager* manager; + nsIDOMBaseAppCore *nativeThis; + nsIScriptObjectOwner *owner = nsnull; + + static NS_DEFINE_IID(kIDOMBaseAppCoreIID, NS_IDOMBASEAPPCORE_IID); + + result = context->GetNameSpaceManager(&manager); + if (NS_OK != result) { + return JS_FALSE; + } + + result = manager->LookupName("BaseAppCore", PR_TRUE, classID); + NS_RELEASE(manager); + if (NS_OK != result) { + return JS_FALSE; + } + + result = nsRepository::CreateInstance(classID, + nsnull, + kIDOMBaseAppCoreIID, + (void **)&nativeThis); + if (NS_OK != result) { + return JS_FALSE; + } + + // XXX We should be calling Init() on the instance + + 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; +} + +// +// BaseAppCore class initialization +// +nsresult NS_InitBaseAppCoreClass(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, "BaseAppCore", &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)) { + + proto = JS_InitClass(jscontext, // context + global, // global object + parent_proto, // parent proto + &BaseAppCoreClass, // JSClass + BaseAppCore, // JSNative ctor + 0, // ctor args + BaseAppCoreProperties, // proto props + BaseAppCoreMethods, // 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 BaseAppCore JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptBaseAppCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptBaseAppCore"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMBaseAppCore *aBaseAppCore; + + 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_InitBaseAppCoreClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIBaseAppCoreIID, (void **)&aBaseAppCore); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &BaseAppCoreClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aBaseAppCore); + } + else { + NS_RELEASE(aBaseAppCore); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} diff --git a/mozilla/xpfe/AppCores/nsJSBrowserAppCore.cpp b/mozilla/xpfe/AppCores/nsJSBrowserAppCore.cpp new file mode 100644 index 00000000000..5891041a487 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsJSBrowserAppCore.cpp @@ -0,0 +1,581 @@ +/* -*- 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 "nsIDOMBrowserAppCore.h" +#include "nsIDOMWindow.h" +#include "nsIScriptNameSpaceManager.h" +#include "nsRepository.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(kIBrowserAppCoreIID, NS_IDOMBROWSERAPPCORE_IID); +static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID); + +NS_DEF_PTR(nsIDOMBrowserAppCore); +NS_DEF_PTR(nsIDOMWindow); + + +/***********************************************************************/ +// +// BrowserAppCore Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetBrowserAppCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMBrowserAppCore *a = (nsIDOMBrowserAppCore*)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; +} + +/***********************************************************************/ +// +// BrowserAppCore Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetBrowserAppCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMBrowserAppCore *a = (nsIDOMBrowserAppCore*)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; +} + + +// +// BrowserAppCore finalizer +// +PR_STATIC_CALLBACK(void) +FinalizeBrowserAppCore(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// BrowserAppCore enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumerateBrowserAppCore(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// BrowserAppCore resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolveBrowserAppCore(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +// +// Native method Back +// +PR_STATIC_CALLBACK(JSBool) +BrowserAppCoreBack(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->Back()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function back requires 0 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method Forward +// +PR_STATIC_CALLBACK(JSBool) +BrowserAppCoreForward(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->Forward()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function forward requires 0 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method LoadUrl +// +PR_STATIC_CALLBACK(JSBool) +BrowserAppCoreLoadUrl(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)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->LoadUrl(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function loadUrl requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method SetToolbarWindow +// +PR_STATIC_CALLBACK(JSBool) +BrowserAppCoreSetToolbarWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)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->SetToolbarWindow(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function setToolbarWindow requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method SetContentWindow +// +PR_STATIC_CALLBACK(JSBool) +BrowserAppCoreSetContentWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)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->SetContentWindow(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function setContentWindow requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method DisableCallback +// +PR_STATIC_CALLBACK(JSBool) +BrowserAppCoreDisableCallback(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)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->DisableCallback(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function disableCallback requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method EnableCallback +// +PR_STATIC_CALLBACK(JSBool) +BrowserAppCoreEnableCallback(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)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->EnableCallback(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function enableCallback requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +/***********************************************************************/ +// +// class for BrowserAppCore +// +JSClass BrowserAppCoreClass = { + "BrowserAppCore", + JSCLASS_HAS_PRIVATE, + JS_PropertyStub, + JS_PropertyStub, + GetBrowserAppCoreProperty, + SetBrowserAppCoreProperty, + EnumerateBrowserAppCore, + ResolveBrowserAppCore, + JS_ConvertStub, + FinalizeBrowserAppCore +}; + + +// +// BrowserAppCore class properties +// +static JSPropertySpec BrowserAppCoreProperties[] = +{ + {0} +}; + + +// +// BrowserAppCore class methods +// +static JSFunctionSpec BrowserAppCoreMethods[] = +{ + {"back", BrowserAppCoreBack, 0}, + {"forward", BrowserAppCoreForward, 0}, + {"loadUrl", BrowserAppCoreLoadUrl, 1}, + {"setToolbarWindow", BrowserAppCoreSetToolbarWindow, 1}, + {"setContentWindow", BrowserAppCoreSetContentWindow, 1}, + {"disableCallback", BrowserAppCoreDisableCallback, 1}, + {"enableCallback", BrowserAppCoreEnableCallback, 1}, + {0} +}; + + +// +// BrowserAppCore constructor +// +PR_STATIC_CALLBACK(JSBool) +BrowserAppCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsresult result; + nsIID classID; + nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx); + nsIScriptNameSpaceManager* manager; + nsIDOMBrowserAppCore *nativeThis; + nsIScriptObjectOwner *owner = nsnull; + + static NS_DEFINE_IID(kIDOMBrowserAppCoreIID, NS_IDOMBROWSERAPPCORE_IID); + + result = context->GetNameSpaceManager(&manager); + if (NS_OK != result) { + return JS_FALSE; + } + + result = manager->LookupName("BrowserAppCore", PR_TRUE, classID); + NS_RELEASE(manager); + if (NS_OK != result) { + return JS_FALSE; + } + + result = nsRepository::CreateInstance(classID, + nsnull, + kIDOMBrowserAppCoreIID, + (void **)&nativeThis); + if (NS_OK != result) { + return JS_FALSE; + } + + // XXX We should be calling Init() on the instance + + 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; +} + +// +// BrowserAppCore class initialization +// +nsresult NS_InitBrowserAppCoreClass(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, "BrowserAppCore", &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 + &BrowserAppCoreClass, // JSClass + BrowserAppCore, // JSNative ctor + 0, // ctor args + BrowserAppCoreProperties, // proto props + BrowserAppCoreMethods, // 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 BrowserAppCore JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptBrowserAppCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptBrowserAppCore"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMBrowserAppCore *aBrowserAppCore; + + 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_InitBrowserAppCoreClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIBrowserAppCoreIID, (void **)&aBrowserAppCore); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &BrowserAppCoreClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aBrowserAppCore); + } + else { + NS_RELEASE(aBrowserAppCore); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} diff --git a/mozilla/xpfe/AppCores/nsJSMailCore.cpp b/mozilla/xpfe/AppCores/nsJSMailCore.cpp new file mode 100644 index 00000000000..1e281eb850d --- /dev/null +++ b/mozilla/xpfe/AppCores/nsJSMailCore.cpp @@ -0,0 +1,439 @@ +/* -*- 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 "nsIDOMMailCore.h" +#include "nsIDOMWindow.h" +#include "nsIScriptNameSpaceManager.h" +#include "nsRepository.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(kIMailCoreIID, NS_IDOMMAILCORE_IID); +static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID); + +NS_DEF_PTR(nsIDOMMailCore); +NS_DEF_PTR(nsIDOMWindow); + + +/***********************************************************************/ +// +// MailCore Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetMailCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMMailCore *a = (nsIDOMMailCore*)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; +} + +/***********************************************************************/ +// +// MailCore Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetMailCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMMailCore *a = (nsIDOMMailCore*)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; +} + + +// +// MailCore finalizer +// +PR_STATIC_CALLBACK(void) +FinalizeMailCore(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// MailCore enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumerateMailCore(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// MailCore resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolveMailCore(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +// +// Native method SendMail +// +PR_STATIC_CALLBACK(JSBool) +MailCoreSendMail(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMMailCore *nativeThis = (nsIDOMMailCore*)JS_GetPrivate(cx, obj); + JSBool rBool = JS_FALSE; + nsAutoString b0; + nsAutoString b1; + nsAutoString b2; + + *rval = JSVAL_NULL; + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + if (argc >= 3) { + + nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); + + nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]); + + nsJSUtils::nsConvertJSValToString(b2, cx, argv[2]); + + if (NS_OK != nativeThis->SendMail(b0, b1, b2)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function SendMail requires 3 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method MailCompleteCallback +// +PR_STATIC_CALLBACK(JSBool) +MailCoreMailCompleteCallback(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMMailCore *nativeThis = (nsIDOMMailCore*)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->MailCompleteCallback(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function MailCompleteCallback requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method SetWindow +// +PR_STATIC_CALLBACK(JSBool) +MailCoreSetWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMMailCore *nativeThis = (nsIDOMMailCore*)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->SetWindow(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function SetWindow requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +/***********************************************************************/ +// +// class for MailCore +// +JSClass MailCoreClass = { + "MailCore", + JSCLASS_HAS_PRIVATE, + JS_PropertyStub, + JS_PropertyStub, + GetMailCoreProperty, + SetMailCoreProperty, + EnumerateMailCore, + ResolveMailCore, + JS_ConvertStub, + FinalizeMailCore +}; + + +// +// MailCore class properties +// +static JSPropertySpec MailCoreProperties[] = +{ + {0} +}; + + +// +// MailCore class methods +// +static JSFunctionSpec MailCoreMethods[] = +{ + {"SendMail", MailCoreSendMail, 3}, + {"MailCompleteCallback", MailCoreMailCompleteCallback, 1}, + {"SetWindow", MailCoreSetWindow, 1}, + {0} +}; + + +// +// MailCore constructor +// +PR_STATIC_CALLBACK(JSBool) +MailCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsresult result; + nsIID classID; + nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx); + nsIScriptNameSpaceManager* manager; + nsIDOMMailCore *nativeThis; + nsIScriptObjectOwner *owner = nsnull; + + static NS_DEFINE_IID(kIDOMMailCoreIID, NS_IDOMMAILCORE_IID); + + result = context->GetNameSpaceManager(&manager); + if (NS_OK != result) { + return JS_FALSE; + } + + result = manager->LookupName("MailCore", PR_TRUE, classID); + NS_RELEASE(manager); + if (NS_OK != result) { + return JS_FALSE; + } + + result = nsRepository::CreateInstance(classID, + nsnull, + kIDOMMailCoreIID, + (void **)&nativeThis); + if (NS_OK != result) { + return JS_FALSE; + } + + // XXX We should be calling Init() on the instance + + 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; +} + +// +// MailCore class initialization +// +nsresult NS_InitMailCoreClass(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, "MailCore", &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 + &MailCoreClass, // JSClass + MailCore, // JSNative ctor + 0, // ctor args + MailCoreProperties, // proto props + MailCoreMethods, // 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 MailCore JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptMailCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptMailCore"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMMailCore *aMailCore; + + 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_InitMailCoreClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIMailCoreIID, (void **)&aMailCore); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &MailCoreClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aMailCore); + } + else { + NS_RELEASE(aMailCore); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} diff --git a/mozilla/xpfe/AppCores/nsJSToolbarCore.cpp b/mozilla/xpfe/AppCores/nsJSToolbarCore.cpp new file mode 100644 index 00000000000..a74058212d3 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsJSToolbarCore.cpp @@ -0,0 +1,396 @@ +/* -*- 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 "nsIDOMToolbarCore.h" +#include "nsIDOMWindow.h" +#include "nsIScriptNameSpaceManager.h" +#include "nsRepository.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(kIToolbarCoreIID, NS_IDOMTOOLBARCORE_IID); +static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID); + +NS_DEF_PTR(nsIDOMToolbarCore); +NS_DEF_PTR(nsIDOMWindow); + + +/***********************************************************************/ +// +// ToolbarCore Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetToolbarCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMToolbarCore *a = (nsIDOMToolbarCore*)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; +} + +/***********************************************************************/ +// +// ToolbarCore Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetToolbarCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMToolbarCore *a = (nsIDOMToolbarCore*)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; +} + + +// +// ToolbarCore finalizer +// +PR_STATIC_CALLBACK(void) +FinalizeToolbarCore(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// ToolbarCore enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumerateToolbarCore(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// ToolbarCore resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolveToolbarCore(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +// +// Native method SetWindow +// +PR_STATIC_CALLBACK(JSBool) +ToolbarCoreSetWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMToolbarCore *nativeThis = (nsIDOMToolbarCore*)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->SetWindow(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function SetWindow requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +// +// Native method SetStatus +// +PR_STATIC_CALLBACK(JSBool) +ToolbarCoreSetStatus(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMToolbarCore *nativeThis = (nsIDOMToolbarCore*)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->SetStatus(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + else { + JS_ReportError(cx, "Function SetStatus requires 1 parameters"); + return JS_FALSE; + } + + return JS_TRUE; +} + + +/***********************************************************************/ +// +// class for ToolbarCore +// +JSClass ToolbarCoreClass = { + "ToolbarCore", + JSCLASS_HAS_PRIVATE, + JS_PropertyStub, + JS_PropertyStub, + GetToolbarCoreProperty, + SetToolbarCoreProperty, + EnumerateToolbarCore, + ResolveToolbarCore, + JS_ConvertStub, + FinalizeToolbarCore +}; + + +// +// ToolbarCore class properties +// +static JSPropertySpec ToolbarCoreProperties[] = +{ + {0} +}; + + +// +// ToolbarCore class methods +// +static JSFunctionSpec ToolbarCoreMethods[] = +{ + {"SetWindow", ToolbarCoreSetWindow, 1}, + {"SetStatus", ToolbarCoreSetStatus, 1}, + {0} +}; + + +// +// ToolbarCore constructor +// +PR_STATIC_CALLBACK(JSBool) +ToolbarCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsresult result; + nsIID classID; + nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx); + nsIScriptNameSpaceManager* manager; + nsIDOMToolbarCore *nativeThis; + nsIScriptObjectOwner *owner = nsnull; + + static NS_DEFINE_IID(kIDOMToolbarCoreIID, NS_IDOMTOOLBARCORE_IID); + + result = context->GetNameSpaceManager(&manager); + if (NS_OK != result) { + return JS_FALSE; + } + + result = manager->LookupName("ToolbarCore", PR_TRUE, classID); + NS_RELEASE(manager); + if (NS_OK != result) { + return JS_FALSE; + } + + result = nsRepository::CreateInstance(classID, + nsnull, + kIDOMToolbarCoreIID, + (void **)&nativeThis); + if (NS_OK != result) { + return JS_FALSE; + } + + // XXX We should be calling Init() on the instance + + 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; +} + +// +// ToolbarCore class initialization +// +nsresult NS_InitToolbarCoreClass(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, "ToolbarCore", &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 + &ToolbarCoreClass, // JSClass + ToolbarCore, // JSNative ctor + 0, // ctor args + ToolbarCoreProperties, // proto props + ToolbarCoreMethods, // 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 ToolbarCore JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptToolbarCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptToolbarCore"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMToolbarCore *aToolbarCore; + + 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_InitToolbarCoreClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIToolbarCoreIID, (void **)&aToolbarCore); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &ToolbarCoreClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aToolbarCore); + } + else { + NS_RELEASE(aToolbarCore); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} diff --git a/mozilla/xpfe/AppCores/nsMailCore.cpp b/mozilla/xpfe/AppCores/nsMailCore.cpp new file mode 100644 index 00000000000..4875ec93525 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsMailCore.cpp @@ -0,0 +1,179 @@ + +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsMailCore.h" +#include "nsIBrowserWindow.h" +#include "nsIWebShell.h" +#include "pratom.h" +#include "nsRepository.h" +#include "nsAppCores.h" +#include "nsAppCoresCIDs.h" +#include "nsAppCoresManager.h" + +#include "nsIScriptContext.h" +#include "nsIScriptContextOwner.h" +#include "nsIDOMDocument.h" +#include "nsIDocument.h" +#include "nsIDOMWindow.h" + + +// Globals +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIMailCoreIID, NS_IDOMMAILCORE_IID); + +static NS_DEFINE_IID(kIDOMDocumentIID, nsIDOMDocument::IID()); +static NS_DEFINE_IID(kIDocumentIID, nsIDocument::IID()); + +static NS_DEFINE_IID(kMailCoreCID, NS_MailCore_CID); +static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID); + + +///////////////////////////////////////////////////////////////////////// +// nsMailCore +///////////////////////////////////////////////////////////////////////// + +nsMailCore::nsMailCore() +{ + printf("Created nsMailCore\n"); + + mScriptObject = nsnull; + mScriptContext = nsnull; + mWindow = nsnull; + + IncInstanceCount(); + NS_INIT_REFCNT(); +} + +nsMailCore::~nsMailCore() +{ + NS_IF_RELEASE(mScriptContext); + NS_IF_RELEASE(mWindow); + DecInstanceCount(); +} + + +NS_IMPL_ADDREF(nsMailCore) +NS_IMPL_RELEASE(nsMailCore) + + +NS_IMETHODIMP +nsMailCore::QueryInterface(REFNSIID aIID,void** aInstancePtr) +{ + if (aInstancePtr == NULL) { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aInstancePtr = NULL; + + if ( aIID.Equals(kIMailCoreIID) ) { + *aInstancePtr = (void*) ((nsIDOMMailCore*)this); + AddRef(); + return NS_OK; + } + + return nsBaseAppCore::QueryInterface(aIID, aInstancePtr); +} + + +NS_IMETHODIMP +nsMailCore::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + NS_PRECONDITION(nsnull != aScriptObject, "null arg"); + nsresult res = NS_OK; + if (nsnull == mScriptObject) + { + res = NS_NewScriptMailCore(aContext, + (nsISupports *)(nsIDOMMailCore*)this, + nsnull, + &mScriptObject); + } + + *aScriptObject = mScriptObject; + return res; +} + +NS_IMETHODIMP +nsMailCore::Init(const nsString& aId) +{ + + nsBaseAppCore::Init(aId); + + nsAppCoresManager* sdm = new nsAppCoresManager(); + sdm->Add((nsIDOMBaseAppCore *)(nsBaseAppCore *)this); + delete sdm; + + return NS_OK; +} + +NS_IMETHODIMP +nsMailCore::MailCompleteCallback(const nsString& aScript) +{ + mScript = aScript; + return NS_OK; +} + +NS_IMETHODIMP +nsMailCore::SetWindow(nsIDOMWindow* aWin) +{ + mWindow = aWin; + NS_ADDREF(aWin); + return NS_OK; +} + +NS_IMETHODIMP +nsMailCore::SendMail(const nsString& aAddrTo, const nsString& aSubject, const nsString& aMsg) +{ + if (nsnull == mScriptContext) { + nsIDOMDocument * domDoc; + mWindow->GetDocument(&domDoc); + if (nsnull != domDoc) { + nsIDocument * doc; + if (NS_OK == domDoc->QueryInterface(kIDocumentIID,(void**)&doc)) { + nsIScriptContextOwner * owner = doc->GetScriptContextOwner(); + if (nsnull != owner) { + owner->GetScriptContext(&mScriptContext); + NS_RELEASE(owner); + } + NS_RELEASE(doc); + } + NS_RELEASE(domDoc); + } + } + + printf("----------------------------\n"); + printf("-- Sending Mail Message\n"); + printf("----------------------------\n"); + printf("To: %s \nSub: %s \nMsg: %s\n", aAddrTo.ToNewCString(), aSubject.ToNewCString(), aMsg.ToNewCString()); + printf("----------------------------\n"); + + if (nsnull != mScriptContext) { + const char* url = ""; + PRBool isUndefined = PR_FALSE; + nsString rVal; + mScriptContext->EvaluateString(mScript, url, 0, rVal, &isUndefined); + //printf("SendMail [%s] %d [%s]\n", mScript.ToNewCString(), isUndefined, rVal.ToNewCString()); + } + return NS_OK; +} + + + + diff --git a/mozilla/xpfe/AppCores/nsMailCore.h b/mozilla/xpfe/AppCores/nsMailCore.h new file mode 100644 index 00000000000..f4e01eecf82 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsMailCore.h @@ -0,0 +1,66 @@ +/* -*- 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. + */ +#ifndef nsMailCorePrivate_h___ +#define nsMailCorePrivate_h___ + +//#include "nsAppCores.h" + +#include "nscore.h" +#include "nsString.h" +#include "nsISupports.h" + +#include "nsIDOMMailCore.h" +#include "nsBaseAppCore.h" + +class nsIBrowserWindow; +class nsIWebShell; +class nsIScriptContext; +class nsIDOMWindow; + +//////////////////////////////////////////////////////////////////////////////// +// nsMailCore: +//////////////////////////////////////////////////////////////////////////////// + +class nsMailCore : public nsBaseAppCore, + public nsIDOMMailCore +{ + public: + + nsMailCore(); + ~nsMailCore(); + + + NS_DECL_ISUPPORTS + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD Init(const nsString& aId); + NS_IMETHOD GetId(nsString& aId) { return nsBaseAppCore::GetId(aId); } + + NS_IMETHOD MailCompleteCallback(const nsString& aScript); + NS_IMETHOD SetWindow(nsIDOMWindow* aWin); + + NS_IMETHOD SendMail(const nsString& aAddrTo, const nsString& aSubject, const nsString& aMsg); + + protected: + + nsString mScript; + + nsIScriptContext *mScriptContext; + nsIDOMWindow *mWindow; +}; + +#endif // nsMailCore_h___ \ No newline at end of file diff --git a/mozilla/xpfe/AppCores/nsMailCoreFactory.cpp b/mozilla/xpfe/AppCores/nsMailCoreFactory.cpp new file mode 100644 index 00000000000..0f95032fab5 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsMailCoreFactory.cpp @@ -0,0 +1,131 @@ +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsAppCores.h" +#include "nsMailCoreFactory.h" +#include "nsMailCore.h" +#include "pratom.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); + +///////////////////////////////////////////////////////////////////////// +// nsMailCoreFactory +///////////////////////////////////////////////////////////////////////// + +nsMailCoreFactory::nsMailCoreFactory(void) +{ + mRefCnt=0; + IncInstanceCount(); +} + +nsMailCoreFactory::~nsMailCoreFactory(void) +{ + DecInstanceCount(); +} + + + +NS_IMETHODIMP +nsMailCoreFactory::QueryInterface(REFNSIID aIID,void** aInstancePtr) +{ + if (aInstancePtr == NULL) + { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aInstancePtr = NULL; + + if ( aIID.Equals(kISupportsIID) ) + { + *aInstancePtr = (void*) this; + } + else if ( aIID.Equals(kIFactoryIID) ) + { + *aInstancePtr = (void*) this; + } + + if (aInstancePtr == NULL) + { + return NS_ERROR_NO_INTERFACE; + } + + AddRef(); + return NS_OK; +} + + + +NS_IMETHODIMP +nsMailCoreFactory::AddRef(void) +{ + return ++mRefCnt; +} + + +NS_IMETHODIMP +nsMailCoreFactory::Release(void) +{ + if (--mRefCnt ==0) + { + delete this; + return 0; // Don't access mRefCnt after deleting! + } + + return mRefCnt; +} + +NS_IMETHODIMP +nsMailCoreFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult) +{ + if (aResult == NULL) + { + return NS_ERROR_NULL_POINTER; + } + + *aResult = NULL; + + /* do I have to use iSupports? */ + nsMailCore *inst = new nsMailCore(); + + if (inst == NULL) + return NS_ERROR_OUT_OF_MEMORY; + + nsresult result = inst->QueryInterface(aIID, aResult); + + if (result != NS_OK) + delete inst; + + return result; + +} + +NS_IMETHODIMP +nsMailCoreFactory::LockFactory(PRBool aLock) +{ + if (aLock) + IncLockCount(); + else + DecLockCount(); + + return NS_OK; +} + + diff --git a/mozilla/xpfe/AppCores/nsMailCoreFactory.h b/mozilla/xpfe/AppCores/nsMailCoreFactory.h new file mode 100644 index 00000000000..3d58abd7414 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsMailCoreFactory.h @@ -0,0 +1,49 @@ +/* -*- 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. + */ +#ifndef nsMailCoreFactory_h___ +#define nsMailCoreFactory_h___ + +//#include "nscore.h" +//#include "nsString.h" +#include "nsIFactory.h" +#include "nsISupports.h" + +//////////////////////////////////////////////////////////////////////////////// +// nsMailCoreFactory: +//////////////////////////////////////////////////////////////////////////////// + +class nsMailCoreFactory : public nsIFactory +{ + public: + + nsMailCoreFactory(); + ~nsMailCoreFactory(); + + PRBool CanUnload(void); + + NS_DECL_ISUPPORTS + + NS_IMETHOD CreateInstance(nsISupports *aOuter, + REFNSIID aIID, + void **aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + +}; + +#endif // nsMailCoreFactory_h___ \ No newline at end of file diff --git a/mozilla/xpfe/AppCores/nsToolbarCore.cpp b/mozilla/xpfe/AppCores/nsToolbarCore.cpp new file mode 100644 index 00000000000..97b4b293139 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsToolbarCore.cpp @@ -0,0 +1,173 @@ + +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsToolbarCore.h" +#include "nsIBrowserWindow.h" +#include "nsRepository.h" +#include "nsAppCores.h" +#include "nsAppCoresCIDs.h" +#include "nsAppCoresManager.h" + +#include "nsIScriptContext.h" +#include "nsIDOMDocument.h" +#include "nsIDocument.h" +#include "nsIDOMWindow.h" +#include "nsIDOMNode.h" +#include "nsIDOMElement.h" +#include "nsIDOMCharacterData.h" + + +// Globals +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIToolbarCoreIID, NS_IDOMTOOLBARCORE_IID); + +static NS_DEFINE_IID(kIDOMDocumentIID, nsIDOMDocument::IID()); +static NS_DEFINE_IID(kIDocumentIID, nsIDocument::IID()); +static NS_DEFINE_IID(kIDOMCharacterDataIID, nsIDOMCharacterData::IID()); + +static NS_DEFINE_IID(kToolbarCoreCID, NS_TOOLBARCORE_CID); + + +///////////////////////////////////////////////////////////////////////// +// nsToolbarCore +///////////////////////////////////////////////////////////////////////// + +nsToolbarCore::nsToolbarCore() +{ + printf("Created nsToolbarCore\n"); + + mWindow = nsnull; + mStatusText = nsnull; + + IncInstanceCount(); + NS_INIT_REFCNT(); +} + +nsToolbarCore::~nsToolbarCore() +{ + NS_IF_RELEASE(mWindow); + NS_IF_RELEASE(mStatusText); + DecInstanceCount(); +} + + +NS_IMPL_ADDREF(nsToolbarCore) +NS_IMPL_RELEASE(nsToolbarCore) + + +NS_IMETHODIMP +nsToolbarCore::QueryInterface(REFNSIID aIID,void** aInstancePtr) +{ + if (aInstancePtr == NULL) { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aInstancePtr = NULL; + + if ( aIID.Equals(kIToolbarCoreIID) ) { + *aInstancePtr = (void*) ((nsIDOMToolbarCore*)this); + AddRef(); + return NS_OK; + } + + return nsBaseAppCore::QueryInterface(aIID, aInstancePtr); +} + + +NS_IMETHODIMP +nsToolbarCore::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + NS_PRECONDITION(nsnull != aScriptObject, "null arg"); + nsresult res = NS_OK; + if (nsnull == mScriptObject) + { + res = NS_NewScriptToolbarCore(aContext, + (nsISupports *)(nsIDOMToolbarCore*)this, + nsnull, + &mScriptObject); + } + + *aScriptObject = mScriptObject; + return res; +} + + + +NS_IMETHODIMP +nsToolbarCore::Init(const nsString& aId) +{ + + nsBaseAppCore::Init(aId); + + nsAppCoresManager* sdm = new nsAppCoresManager(); + sdm->Add((nsIDOMBaseAppCore *)(nsBaseAppCore *)this); + delete sdm; + + return NS_OK; +} + + + + +NS_IMETHODIMP +nsToolbarCore::SetStatus(const nsString& aMsg) +{ + if (nsnull == mStatusText) { + nsIDOMDocument * domDoc; + mWindow->GetDocument(&domDoc); + if (!domDoc) + return NS_ERROR_FAILURE; + + nsCOMPtr parent(GetParentNodeFromDOMDoc(domDoc)); + if (!parent) + return NS_ERROR_FAILURE; + + PRInt32 count = 0; + nsCOMPtr statusNode(FindNamedDOMNode(nsAutoString("#text"), parent, count, 7)); + if (!statusNode) + return NS_ERROR_FAILURE; + + nsCOMPtr charData(statusNode); + if (!charData) + return NS_ERROR_FAILURE; + + mStatusText = charData; + mStatusText->SetData(nsAutoString("Ready.....")); // <<====== EVIL HARD-CODED STRING. + NS_RELEASE(domDoc); + } + + mStatusText->SetData(aMsg); + + return NS_OK; +} + +NS_IMETHODIMP +nsToolbarCore::SetWindow(nsIDOMWindow* aWin) +{ + mWindow = aWin; + NS_ADDREF(aWin); + return NS_OK; +} + + + + + diff --git a/mozilla/xpfe/AppCores/nsToolbarCore.h b/mozilla/xpfe/AppCores/nsToolbarCore.h new file mode 100644 index 00000000000..c83e0cf6d5a --- /dev/null +++ b/mozilla/xpfe/AppCores/nsToolbarCore.h @@ -0,0 +1,65 @@ +/* -*- 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. + */ +#ifndef nsToolbarCorePrivate_h___ +#define nsToolbarCorePrivate_h___ + +//#include "nsAppCores.h" + +#include "nscore.h" +#include "nsString.h" +#include "nsISupports.h" +#include "nsIScriptObjectOwner.h" + +#include "nsIDOMToolbarCore.h" +#include "nsBaseAppCore.h" + +class nsIBrowserWindow; +class nsIWebShell; +class nsIScriptContext; +class nsIDOMWindow; +class nsIDOMDocument; +class nsIDOMCharacterData; + +//////////////////////////////////////////////////////////////////////////////// +// nsToolbarCore: +//////////////////////////////////////////////////////////////////////////////// + +class nsToolbarCore : public nsBaseAppCore, + public nsIDOMToolbarCore +{ + public: + + nsToolbarCore(); + ~nsToolbarCore(); + + + NS_DECL_ISUPPORTS + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD Init(const nsString& aId); + NS_IMETHOD GetId(nsString& aId) { return nsBaseAppCore::GetId(aId); } + + NS_IMETHOD SetWindow(nsIDOMWindow* aWin); + NS_IMETHOD SetStatus(const nsString& aMsg); + + private: + + nsIDOMWindow *mWindow; + nsIDOMCharacterData *mStatusText; +}; + +#endif // nsToolbarCore_h___ \ No newline at end of file diff --git a/mozilla/xpfe/AppCores/nsToolbarCoreFactory.cpp b/mozilla/xpfe/AppCores/nsToolbarCoreFactory.cpp new file mode 100644 index 00000000000..0b03546d390 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsToolbarCoreFactory.cpp @@ -0,0 +1,131 @@ +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsAppCores.h" +#include "nsToolbarCoreFactory.h" +#include "nsToolbarCore.h" +#include "pratom.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); + +///////////////////////////////////////////////////////////////////////// +// nsToolbarCoreFactory +///////////////////////////////////////////////////////////////////////// + +nsToolbarCoreFactory::nsToolbarCoreFactory(void) +{ + mRefCnt=0; + IncInstanceCount(); +} + +nsToolbarCoreFactory::~nsToolbarCoreFactory(void) +{ + DecInstanceCount(); +} + + + +NS_IMETHODIMP +nsToolbarCoreFactory::QueryInterface(REFNSIID aIID,void** aInstancePtr) +{ + if (aInstancePtr == NULL) + { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aInstancePtr = NULL; + + if ( aIID.Equals(kISupportsIID) ) + { + *aInstancePtr = (void*) this; + } + else if ( aIID.Equals(kIFactoryIID) ) + { + *aInstancePtr = (void*) this; + } + + if (aInstancePtr == NULL) + { + return NS_ERROR_NO_INTERFACE; + } + + AddRef(); + return NS_OK; +} + + + +NS_IMETHODIMP +nsToolbarCoreFactory::AddRef(void) +{ + return ++mRefCnt; +} + + +NS_IMETHODIMP +nsToolbarCoreFactory::Release(void) +{ + if (--mRefCnt ==0) + { + delete this; + return 0; // Don't access mRefCnt after deleting! + } + + return mRefCnt; +} + +NS_IMETHODIMP +nsToolbarCoreFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult) +{ + if (aResult == NULL) + { + return NS_ERROR_NULL_POINTER; + } + + *aResult = NULL; + + /* do I have to use iSupports? */ + nsToolbarCore *inst = new nsToolbarCore(); + + if (inst == NULL) + return NS_ERROR_OUT_OF_MEMORY; + + nsresult result = inst->QueryInterface(aIID, aResult); + + if (result != NS_OK) + delete inst; + + return result; + +} + +NS_IMETHODIMP +nsToolbarCoreFactory::LockFactory(PRBool aLock) +{ + if (aLock) + IncLockCount(); + else + DecLockCount(); + + return NS_OK; +} + + diff --git a/mozilla/xpfe/AppCores/nsToolbarCoreFactory.h b/mozilla/xpfe/AppCores/nsToolbarCoreFactory.h new file mode 100644 index 00000000000..8c0f58a6ac0 --- /dev/null +++ b/mozilla/xpfe/AppCores/nsToolbarCoreFactory.h @@ -0,0 +1,47 @@ +/* -*- 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. + */ +#ifndef nsToolbarCoreFactory_h___ +#define nsToolbarCoreFactory_h___ + +#include "nsIFactory.h" +#include "nsISupports.h" + +//////////////////////////////////////////////////////////////////////////////// +// nsToolbarCoreFactory: +//////////////////////////////////////////////////////////////////////////////// + +class nsToolbarCoreFactory : public nsIFactory +{ + public: + + nsToolbarCoreFactory(); + ~nsToolbarCoreFactory(); + + PRBool CanUnload(void); + + NS_DECL_ISUPPORTS + + NS_IMETHOD CreateInstance(nsISupports *aOuter, + REFNSIID aIID, + void **aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + +}; + +#endif // nsToolbarCoreFactory_h___ \ No newline at end of file