make appshell into a component

r=sspitzer
This commit is contained in:
alecf%netscape.com 2000-02-05 05:38:13 +00:00
Родитель 2ba127ca4b
Коммит 8af9ba10df
22 изменённых файлов: 521 добавлений и 1127 удалений

Просмотреть файл

@ -26,11 +26,34 @@
#define _NSFILELOCATIONS_H_ #define _NSFILELOCATIONS_H_
#include "nsFileSpec.h" #include "nsFileSpec.h"
#include "nsIFileLocator.h"
#ifdef XP_MAC #ifdef XP_MAC
#include <Types.h> #include <Types.h>
#endif #endif
class nsFileLocator : public nsIFileLocator
//=============================================================================
{
public:
nsFileLocator();
NS_DECL_ISUPPORTS
NS_IMETHOD GetFileLocation(
PRUint32 aType,
// NOTE: actually either nsSpecialFileSpec:Type, see nsFileLocations.h
// or nsSpecialSystemDirectory::SystemDirectories, see nsSpecialSystemDirectory.h
nsIFileSpec** outSpec);
NS_IMETHOD ForgetProfileDir();
protected:
virtual ~nsFileLocator();
};
// SEE ALSO: // SEE ALSO:
// mozilla/base/public/nsSpecialSystemDirectory.h // mozilla/base/public/nsSpecialSystemDirectory.h

Просмотреть файл

@ -26,6 +26,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk include $(DEPTH)/config/autoconf.mk
IS_COMPONENT=1
MODULE = raptor MODULE = raptor
LIBRARY_NAME = nsappshell LIBRARY_NAME = nsappshell
@ -36,7 +37,6 @@ CPPSRCS = \
nsXULCommand.cpp \ nsXULCommand.cpp \
nsAppShellService.cpp \ nsAppShellService.cpp \
nsWebShellWindow.cpp \ nsWebShellWindow.cpp \
nsAppShellFactory.cpp \
nsCommandLineService.cpp \ nsCommandLineService.cpp \
nsXPConnectFactory.cpp \ nsXPConnectFactory.cpp \
nsJSXPConnectFactory.cpp \ nsJSXPConnectFactory.cpp \
@ -48,6 +48,7 @@ CPPSRCS = \
nsDialogParamBlock.cpp \ nsDialogParamBlock.cpp \
nsCommonDialogs.cpp \ nsCommonDialogs.cpp \
nsAbout.cpp \ nsAbout.cpp \
nsAppShellFactory.cpp \
$(NULL) $(NULL)
EXTRA_DSO_LDOPTS = \ EXTRA_DSO_LDOPTS = \

Просмотреть файл

@ -22,7 +22,7 @@
DEPTH=..\..\.. DEPTH=..\..\..
include <$(DEPTH)/config/config.mak> include <$(DEPTH)/config/config.mak>
IS_COMPONENT=1
DEFINES=-D_IMPL_NS_APPSHELL -DWIN32_LEAN_AND_MEAN DEFINES=-D_IMPL_NS_APPSHELL -DWIN32_LEAN_AND_MEAN
MODULE=raptor MODULE=raptor

Просмотреть файл

@ -35,132 +35,86 @@
#include "nsAbout.h" #include "nsAbout.h"
#include "nsIGenericFactory.h" #include "nsIGenericFactory.h"
#include "nsIAppShellService.h"
#include "nsCommandLineService.h"
#include "nsNetSupportDialog.h"
#include "nsAppShellService.h"
#include "nsXPConnectFactory.h"
#include "nsWindowMediator.h"
#include "nsSessionHistory.h"
#include "nsCommonDialogs.h"
#include "nsDialogParamBlock.h"
#include "nsFileLocations.h"
/* extern the factory entry points for each component... */ /* extern the factory entry points for each component... */
nsresult NS_NewAppShellServiceFactory(nsIFactory** aFactory); nsresult NS_NewAppShellServiceFactory(nsIFactory** aFactory);
nsresult NS_NewXPConnectFactoryFactory(nsIFactory** aResult); nsresult NS_NewXPConnectFactoryFactory(nsIFactory** aResult);
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); NS_GENERIC_FACTORY_CONSTRUCTOR(nsCmdLineService);
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShellService);
static NS_DEFINE_CID(kProtocolHelperCID, NS_PROTOCOL_HELPER_CID); NS_GENERIC_FACTORY_CONSTRUCTOR(XPConnectFactoryImpl);
static NS_DEFINE_CID(kXPConnectFactoryCID, NS_XPCONNECTFACTORY_CID); NS_GENERIC_FACTORY_CONSTRUCTOR(nsNetSupportDialog);
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID); NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindowMediator);
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID); NS_GENERIC_FACTORY_CONSTRUCTOR(nsSessionHistory);
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); NS_GENERIC_FACTORY_CONSTRUCTOR(nsCommonDialogs);
static NS_DEFINE_CID(kSessionHistoryCID, NS_SESSIONHISTORY_CID); NS_GENERIC_FACTORY_CONSTRUCTOR(nsDialogParamBlock);
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileLocator);
static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID );
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID );
static NS_DEFINE_CID(kAboutModuleCID, NS_ABOUT_CID);
/*
* Global entry point to register all components in the registry...
*/
extern "C" NS_EXPORT nsresult
NSRegisterSelf(nsISupports* serviceMgr, const char *path)
{
nsComponentManager::RegisterComponent(kAppShellServiceCID, NULL, NULL, path, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kCmdLineServiceCID, NULL, NULL, path, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kFileLocatorCID,
NULL, NS_FILELOCATOR_PROGID, path, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kProtocolHelperCID, NULL, NULL, path, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kXPConnectFactoryCID, NULL, NULL, path, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kNetSupportDialogCID, NULL, NULL, path, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kSessionHistoryCID, "sessionhistory", NS_ISESSIONHISTORY_PROGID, path, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kWindowMediatorCID,
"window-mediator", NS_RDF_DATASOURCE_PROGID_PREFIX "window-mediator",
path, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kCommonDialogsCID, NULL, "component://netscape/appshell/commonDialogs", path, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kDialogParamBlockCID, NULL, NULL, path, PR_TRUE, PR_TRUE);
nsComponentManager::RegisterComponent(kAboutModuleCID, "about:", NS_ABOUT_MODULE_PROGID_PREFIX, path, PR_TRUE, PR_TRUE);
return NS_OK;
}
/*
* Global entry point to unregister all components in the registry...
*/
extern "C" NS_EXPORT nsresult
NSUnregisterSelf(nsISupports* serviceMgr, const char *path)
{
nsComponentManager::UnregisterComponent(kAppShellServiceCID, path);
nsComponentManager::UnregisterComponent(kCmdLineServiceCID, path);
nsComponentManager::UnregisterComponent(kFileLocatorCID, path);
nsComponentManager::UnregisterComponent(kProtocolHelperCID, path);
nsComponentManager::UnregisterComponent(kXPConnectFactoryCID, path);
nsComponentManager::UnregisterComponent(kNetSupportDialogCID, path);
nsComponentManager::UnregisterComponent(kWindowMediatorCID, path);
nsComponentManager::UnregisterComponent(kSessionHistoryCID, path);
nsComponentManager::UnregisterComponent(kCommonDialogsCID, path);
nsComponentManager::UnregisterComponent(kDialogParamBlockCID, path);
nsComponentManager::UnregisterComponent(kAboutModuleCID, path);
return NS_OK;
}
/* static nsModuleComponentInfo gAppShellModuleInfo[] =
* Global entry point to create class factories for the components
* available withing the DLL...
*/
#if defined(XP_MAC) && defined(MAC_STATIC)
extern "C" NS_APPSHELL nsresult
NSGetFactory_APPSHELL_DLL(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
#else
extern "C" NS_APPSHELL nsresult
NSGetFactory(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
#endif
{ {
nsresult rv = NS_ERROR_FACTORY_NOT_REGISTERED; { "AppShell Service",
NS_APPSHELL_SERVICE_CID,
"component://netscape/appshell/appShellService",
nsAppShellServiceConstructor,
},
{ "CommandLine Service",
NS_COMMANDLINE_SERVICE_CID,
NULL,
nsCmdLineServiceConstructor,
},
{ "XPConnect Factory?",
NS_XPCONNECTFACTORY_CID,
NULL,
XPConnectFactoryImplConstructor,
},
{ "Net Support Dialogs",
NS_NETSUPPORTDIALOG_CID,
NULL,
nsNetSupportDialogConstructor,
},
{ "Window Mediator",
NS_WINDOWMEDIATOR_CID,
NS_RDF_DATASOURCE_PROGID_PREFIX "window-mediator",
nsWindowMediatorConstructor,
},
{ "Session History",
NS_SESSIONHISTORY_CID,
NULL,
nsSessionHistoryConstructor,
},
{ "Common Dialogs",
NS_CommonDialog_CID,
"component://netscape/appshell/commonDialogs",
nsCommonDialogsConstructor,
},
{ "kDialogParamBlockCID",
NS_DialogParamBlock_CID,
NULL,
nsDialogParamBlockConstructor,
},
{ "kAboutModuleCID",
NS_ABOUT_CID,
NS_ABOUT_MODULE_PROGID_PREFIX,
nsAbout::Create,
},
{ "File Locator Service",
NS_FILELOCATOR_CID,
NS_FILELOCATOR_PROGID,
nsFileLocatorConstructor,
},
};
if (nsnull == aFactory) { NS_IMPL_NSGETMODULE("appshell", gAppShellModuleInfo)
return NS_ERROR_NULL_POINTER;
}
if (aClass.Equals(kAppShellServiceCID)) {
rv = NS_NewAppShellServiceFactory(aFactory);
}
else if (aClass.Equals(kCmdLineServiceCID)) {
rv = NS_NewCmdLineServiceFactory(aFactory);
}
else if (aClass.Equals(kFileLocatorCID)) {
rv = NS_NewFileLocatorFactory(aFactory);
}
else if (aClass.Equals(kXPConnectFactoryCID)) {
rv = NS_NewXPConnectFactoryFactory(aFactory);
}
else if ( aClass.Equals( kNetSupportDialogCID ) )
{
rv = NS_NewNetSupportDialogFactory(aFactory);
}
else if ( aClass.Equals( kWindowMediatorCID ) )
{
rv = NS_NewWindowMediatorFactory( aFactory );
}
else if ( aClass.Equals( kSessionHistoryCID ) )
{
rv = NS_NewSessionHistoryFactory( aFactory );
}
else if ( aClass.Equals( kCommonDialogsCID ) )
{
rv = NS_NewCommonDialogsFactory( aFactory );
}
else if ( aClass.Equals( kDialogParamBlockCID ) )
{
rv = NS_NewDialogParamBlockFactory( aFactory );
}
else if ( aClass.Equals(kAboutModuleCID ) )
{
nsIGenericFactory* fact;
rv = NS_NewGenericFactory(&fact, nsAbout::Create);
*aFactory = fact;
}
return rv;
}

Просмотреть файл

@ -67,6 +67,8 @@
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "jsapi.h" #include "jsapi.h"
#include "nsAppShellService.h"
/* Define Class IDs */ /* Define Class IDs */
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
@ -78,48 +80,6 @@ static NS_DEFINE_CID(kMetaCharsetCID, NS_META_CHARSET_CID);
static char *gEQActivatedNotification = "nsIEventQueueActivated"; static char *gEQActivatedNotification = "nsIEventQueueActivated";
static char *gEQDestroyedNotification = "nsIEventQueueDestroyed"; static char *gEQDestroyedNotification = "nsIEventQueueDestroyed";
class nsAppShellService : public nsIAppShellService,
public nsIObserver,
public nsSupportsWeakReference
{
public:
nsAppShellService(void);
NS_DECL_ISUPPORTS
NS_DECL_NSIAPPSHELLSERVICE
NS_DECL_NSIOBSERVER
protected:
virtual ~nsAppShellService();
void RegisterObserver(PRBool aRegister);
NS_IMETHOD JustCreateTopWindow(nsIWebShellWindow *aParent,
nsIURI *aUrl,
PRBool aShowWindow, PRBool aLoadDefaultPage,
PRUint32 aChromeMask,
nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
nsIWebShellWindow **aResult);
void InitializeComponent( const nsCID &aComponentCID );
void ShutdownComponent( const nsCID &aComponentCID );
typedef void (nsAppShellService::*EnumeratorMemberFunction)(const nsCID&);
void EnumerateComponents( void (nsAppShellService::*function)(const nsCID&) );
nsIAppShell* mAppShell;
nsISupportsArray* mWindowList;
nsICmdLineService* mCmdLineService;
nsIWindowMediator* mWindowMediator;
nsCOMPtr<nsIWebShellWindow> mHiddenWindow;
PRBool mDeleteCalled;
nsISplashScreen *mSplashScreen;
// The mShutdownTimer is set in Quit() to asynchronously call the
// ExitCallback(). This allows one last pass through any events in
// the event queue before shutting down the appshell.
nsCOMPtr<nsITimer> mShutdownTimer;
static void ExitCallback(nsITimer* aTimer, void* aClosure);
};
nsAppShellService::nsAppShellService() : mWindowMediator( NULL ) nsAppShellService::nsAppShellService() : mWindowMediator( NULL )
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
@ -848,39 +808,6 @@ nsAppShellService::UnregisterTopLevelWindow(nsIWebShellWindow* aWindow)
} }
NS_EXPORT nsresult NS_NewAppShellService(nsIAppShellService** aResult)
{
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = new nsAppShellService();
if (nsnull == *aResult) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aResult);
return NS_OK;
}
//----------------------------------------------------------------------
// Entry point to create nsAppShellService factory instances...
NS_DEF_FACTORY(AppShellService,nsAppShellService)
nsresult NS_NewAppShellServiceFactory(nsIFactory** aResult)
{
nsresult rv = NS_OK;
nsIFactory* inst = new nsAppShellServiceFactory;
if (nsnull == inst) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
else {
NS_ADDREF(inst);
}
*aResult = inst;
return rv;
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// nsIObserver interface and friends // nsIObserver interface and friends

Просмотреть файл

@ -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.1 (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.
*
* Contributor(s):
*/
#ifndef __nsAppShellService_h
#define __nsAppShellService_h
#include "nsISupports.h"
#include "nsIAppShellService.h"
#include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsIAppShell.h"
#include "nsITimer.h"
class nsAppShellService : public nsIAppShellService,
public nsIObserver,
public nsSupportsWeakReference
{
public:
nsAppShellService(void);
NS_DECL_ISUPPORTS
NS_DECL_NSIAPPSHELLSERVICE
NS_DECL_NSIOBSERVER
protected:
virtual ~nsAppShellService();
void RegisterObserver(PRBool aRegister);
NS_IMETHOD JustCreateTopWindow(nsIWebShellWindow *aParent,
nsIURI *aUrl,
PRBool aShowWindow, PRBool aLoadDefaultPage,
PRUint32 aChromeMask,
nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
nsIWebShellWindow **aResult);
void InitializeComponent( const nsCID &aComponentCID );
void ShutdownComponent( const nsCID &aComponentCID );
typedef void (nsAppShellService::*EnumeratorMemberFunction)(const nsCID&);
void EnumerateComponents( void (nsAppShellService::*function)(const nsCID&) );
nsIAppShell* mAppShell;
nsISupportsArray* mWindowList;
nsICmdLineService* mCmdLineService;
nsIWindowMediator* mWindowMediator;
nsCOMPtr<nsIWebShellWindow> mHiddenWindow;
PRBool mDeleteCalled;
nsISplashScreen *mSplashScreen;
// The mShutdownTimer is set in Quit() to asynchronously call the
// ExitCallback(). This allows one last pass through any events in
// the event queue before shutting down the appshell.
nsCOMPtr<nsITimer> mShutdownTimer;
static void ExitCallback(nsITimer* aTimer, void* aClosure);
};
#endif

Просмотреть файл

@ -22,44 +22,11 @@
#include "nsICmdLineService.h" #include "nsICmdLineService.h"
#include "nsVoidArray.h" #include "nsCommandLineService.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
#include "nsString.h" #include "nsString.h"
#include "plstr.h" #include "plstr.h"
/* Define Class IDs */
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
class nsCmdLineService : public nsICmdLineService
{
public:
nsCmdLineService(void);
NS_DECL_ISUPPORTS
NS_IMETHOD Initialize(PRInt32 aArgc, char** aArgv);
NS_IMETHOD GetCmdLineValue(const char* aArg, char **aValue);
NS_IMETHOD GetURLToLoad(char ** aResult);
NS_IMETHOD GetProgramName(char ** aResult);
NS_IMETHOD GetArgc(PRInt32 * aResult);
NS_IMETHOD GetArgv(char *** aResult);
protected:
virtual ~nsCmdLineService();
nsVoidArray mArgList; // The arguments
nsVoidArray mArgValueList; // The argument values
PRInt32 mArgCount; // This is not argc. This is # of argument pairs
// in the arglist and argvaluelist arrays. This
// normally is argc/2.
PRInt32 mArgc; // This is argc;
char ** mArgv; // This is argv;
};
nsCmdLineService::nsCmdLineService() nsCmdLineService::nsCmdLineService()
: mArgCount(0), mArgc(0), mArgv(0) : mArgCount(0), mArgc(0), mArgv(0)
{ {
@ -280,92 +247,3 @@ NS_EXPORT nsresult NS_NewCmdLineService(nsICmdLineService** aResult)
return NS_OK; return NS_OK;
} }
//----------------------------------------------------------------------
// Factory code for creating nsAppShellService's
class nsCmdLineServiceFactory : public nsIFactory
{
public:
nsCmdLineServiceFactory();
NS_DECL_ISUPPORTS
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
protected:
virtual ~nsCmdLineServiceFactory();
};
nsCmdLineServiceFactory::nsCmdLineServiceFactory()
{
NS_INIT_REFCNT();
}
nsresult
nsCmdLineServiceFactory::LockFactory(PRBool lock)
{
return NS_OK;
}
nsCmdLineServiceFactory::~nsCmdLineServiceFactory()
{
}
NS_IMPL_ISUPPORTS1(nsCmdLineServiceFactory, nsIFactory);
nsresult
nsCmdLineServiceFactory::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
nsresult rv;
nsCmdLineService* inst;
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
if (nsnull != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
goto done;
}
NS_NEWXPCOM(inst, nsCmdLineService);
if (inst == NULL) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto done;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst);
done:
return rv;
}
extern "C" NS_APPSHELL nsresult
NS_NewCmdLineServiceFactory(nsIFactory** aFactory)
{
nsresult rv = NS_OK;
nsIFactory* inst = new nsCmdLineServiceFactory();
if (nsnull == inst) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
else {
NS_ADDREF(inst);
}
*aFactory = inst;
return rv;
}

Просмотреть файл

@ -0,0 +1,54 @@
/* -*- 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.1 (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.
*
* Contributor(s):
*/
#ifndef __nsCommandLineService_h
#define __nsCommandLineService_h
#include "nsISupports.h"
#include "nsVoidArray.h"
class nsCmdLineService : public nsICmdLineService
{
public:
nsCmdLineService(void);
NS_DECL_ISUPPORTS
NS_IMETHOD Initialize(PRInt32 aArgc, char** aArgv);
NS_IMETHOD GetCmdLineValue(const char* aArg, char **aValue);
NS_IMETHOD GetURLToLoad(char ** aResult);
NS_IMETHOD GetProgramName(char ** aResult);
NS_IMETHOD GetArgc(PRInt32 * aResult);
NS_IMETHOD GetArgv(char *** aResult);
protected:
virtual ~nsCmdLineService();
nsVoidArray mArgList; // The arguments
nsVoidArray mArgValueList; // The argument values
PRInt32 mArgCount; // This is not argc. This is # of argument pairs
// in the arglist and argvaluelist arrays. This
// normally is argc/2.
PRInt32 mArgc; // This is argc;
char ** mArgv; // This is argv;
};
#endif

Просмотреть файл

@ -21,27 +21,17 @@
* Pierre Phaneuf <pp@ludusdesign.com> * Pierre Phaneuf <pp@ludusdesign.com>
*/ */
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsICommonDialogs.h" #include "nsCommonDialogs.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "nsXPComFactory.h" #include "nsXPComFactory.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
static NS_DEFINE_CID( kDialogParamBlockCID, NS_DialogParamBlock_CID); static NS_DEFINE_CID( kDialogParamBlockCID, NS_DialogParamBlock_CID);
class nsCommonDialogs: public nsICommonDialogs
{
public:
nsCommonDialogs();
virtual ~nsCommonDialogs();
NS_DECL_NSICOMMONDIALOGS
NS_DECL_ISUPPORTS
private:
};
const char* kPromptURL="chrome://global/content/commonDialog.xul"; const char* kPromptURL="chrome://global/content/commonDialog.xul";
const char* kQuestionIconURL ="chrome://global/skin/question-icon.gif"; const char* kQuestionIconURL ="chrome://global/skin/question-icon.gif";
@ -473,24 +463,3 @@ NS_IMPL_ADDREF(nsCommonDialogs);
NS_IMPL_RELEASE(nsCommonDialogs); NS_IMPL_RELEASE(nsCommonDialogs);
NS_IMPL_QUERY_INTERFACE(nsCommonDialogs, NS_GET_IID(nsICommonDialogs)); NS_IMPL_QUERY_INTERFACE(nsCommonDialogs, NS_GET_IID(nsICommonDialogs));
// Entry point to create nsAppShellService factory instances...
NS_DEF_FACTORY(CommonDialogs, nsCommonDialogs)
nsresult NS_NewCommonDialogsFactory(nsIFactory** aResult)
{
nsresult rv = NS_OK;
nsIFactory* inst;
inst = new nsCommonDialogsFactory;
if (nsnull == inst)
{
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
{
NS_ADDREF(inst);
}
*aResult = inst;
return rv;
}

Просмотреть файл

Просмотреть файл

@ -1,141 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (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.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*/
#include "nsIDialogParamBlock.h"
#include "nsString.h"
#include "nsXPComFactory.h"
class nsDialogParamBlock: public nsIDialogParamBlock
{
enum {kNumInts = 8, kNumStrings =16 };
public:
nsDialogParamBlock();
virtual ~nsDialogParamBlock();
NS_DECL_NSIDIALOGPARAMBLOCK
// COM
NS_DECL_ISUPPORTS
private:
nsresult InBounds( PRInt32 inIndex, PRInt32 inMax )
{
if ( inIndex >= 0 && inIndex< inMax )
return NS_OK;
else
return NS_ERROR_ILLEGAL_VALUE;
}
PRInt32 mInt[ kNumInts ];
PRInt32 mNumStrings;
nsString* mString;
};
nsDialogParamBlock::nsDialogParamBlock(): mNumStrings( 0 ), mString(NULL )
{
NS_INIT_REFCNT();
for( PRInt32 i =0; i< kNumInts; i++ )
mInt[ i ] = 0;
}
nsDialogParamBlock::~nsDialogParamBlock()
{
delete [] mString;
}
NS_IMETHODIMP nsDialogParamBlock::SetNumberStrings( PRInt32 inNumStrings )
{
if ( mString != NULL )
{
return NS_ERROR_ALREADY_INITIALIZED;
}
mString = new nsString[ inNumStrings ];
if ( !mString )
return NS_ERROR_OUT_OF_MEMORY;
mNumStrings = inNumStrings;
return NS_OK;
}
NS_IMETHODIMP nsDialogParamBlock::GetInt(PRInt32 inIndex, PRInt32 *_retval)
{
nsresult rv = InBounds( inIndex, kNumInts );
if ( rv == NS_OK )
*_retval = mInt[ inIndex ];
return rv;
}
NS_IMETHODIMP nsDialogParamBlock::SetInt(PRInt32 inIndex, PRInt32 inInt)
{
nsresult rv = InBounds( inIndex, kNumInts );
if ( rv == NS_OK )
mInt[ inIndex ]= inInt;
return rv;
}
NS_IMETHODIMP nsDialogParamBlock::GetString(PRInt32 inIndex, PRUnichar **_retval)
{
if ( mNumStrings == 0 )
SetNumberStrings( kNumStrings );
nsresult rv = InBounds( inIndex, mNumStrings );
if ( rv == NS_OK )
*_retval = mString[ inIndex ].ToNewUnicode();
return rv;
}
NS_IMETHODIMP nsDialogParamBlock::SetString(PRInt32 inIndex, const PRUnichar *inString)
{
if ( mNumStrings == 0 )
SetNumberStrings( kNumStrings );
nsresult rv = InBounds( inIndex, mNumStrings );
if ( rv == NS_OK )
mString[ inIndex ]= inString;
return rv;
}
NS_IMPL_ADDREF(nsDialogParamBlock);
NS_IMPL_RELEASE(nsDialogParamBlock);
NS_IMPL_QUERY_INTERFACE1(nsDialogParamBlock, nsIDialogParamBlock)
// Entry point to create nsAppShellService factory instances...
NS_DEF_FACTORY(DialogParamBlock, nsDialogParamBlock)
nsresult NS_NewDialogParamBlockFactory(nsIFactory** aResult)
{
nsresult rv = NS_OK;
nsIFactory* inst;
inst = new nsDialogParamBlockFactory;
if (nsnull == inst)
{
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
{
NS_ADDREF(inst);
}
*aResult = inst;
return rv;
}

Просмотреть файл

Просмотреть файл

@ -536,28 +536,6 @@ void nsSpecialFileSpec::operator = (Type aType)
//======================================================================================== //========================================================================================
//======================================================================================== //========================================================================================
class nsFileLocator : public nsIFileLocator
//========================================================================================
{
public:
nsFileLocator();
NS_DECL_ISUPPORTS
NS_IMETHOD GetFileLocation(
PRUint32 aType,
// NOTE: actually either nsSpecialFileSpec:Type, see nsFileLocations.h
// or nsSpecialSystemDirectory::SystemDirectories, see nsSpecialSystemDirectory.h
nsIFileSpec** outSpec);
NS_IMETHOD ForgetProfileDir();
protected:
virtual ~nsFileLocator();
};
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
nsFileLocator::nsFileLocator() nsFileLocator::nsFileLocator()
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
@ -604,102 +582,3 @@ NS_IMETHODIMP nsFileLocator::ForgetProfileDir()
return NS_OK; return NS_OK;
} }
//----------------------------------------------------------------------------------------
NS_EXPORT nsresult NS_NewFileLocator(nsIFileLocator** aResult)
//----------------------------------------------------------------------------------------
{
if (nsnull == aResult)
return NS_ERROR_NULL_POINTER;
*aResult = new nsFileLocator();
if (nsnull == *aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}
//========================================================================================
class nsFileLocatorFactory : public nsIFactory
//========================================================================================
{
public:
nsFileLocatorFactory();
NS_DECL_ISUPPORTS
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
protected:
virtual ~nsFileLocatorFactory();
};
//----------------------------------------------------------------------------------------
nsFileLocatorFactory::nsFileLocatorFactory()
//----------------------------------------------------------------------------------------
{
NS_INIT_REFCNT();
}
//----------------------------------------------------------------------------------------
nsresult nsFileLocatorFactory::LockFactory(PRBool /*lock*/)
//----------------------------------------------------------------------------------------
{
return NS_OK;
}
//----------------------------------------------------------------------------------------
nsFileLocatorFactory::~nsFileLocatorFactory()
//----------------------------------------------------------------------------------------
{
}
NS_IMPL_ISUPPORTS1(nsFileLocatorFactory, nsIFactory);
//----------------------------------------------------------------------------------------
nsresult nsFileLocatorFactory::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
//----------------------------------------------------------------------------------------
{
nsresult rv;
nsFileLocator* inst;
if (!aResult)
return NS_ERROR_NULL_POINTER;
*aResult = NULL;
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
NS_NEWXPCOM(inst, nsFileLocator);
if (!inst)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst);
return rv;
}
//----------------------------------------------------------------------------------------
extern "C" NS_APPSHELL nsresult NS_NewFileLocatorFactory(nsIFactory** aFactory)
//----------------------------------------------------------------------------------------
{
nsresult rv = NS_OK;
nsIFactory* inst = new nsFileLocatorFactory();
if (!inst)
rv = NS_ERROR_OUT_OF_MEMORY;
else
NS_ADDREF(inst);
*aFactory = inst;
return rv;
}

Просмотреть файл

@ -29,12 +29,9 @@
#include "nsIWebShellWindow.h" #include "nsIWebShellWindow.h"
#include "nsICommonDialogs.h" #include "nsICommonDialogs.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsXPComFactory.h"
/* Define Class IDs */ /* Define Class IDs */
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
static NS_DEFINE_CID( kCommonDialogsCID, NS_CommonDialog_CID);
PRBool GetNSIPrompt( nsCOMPtr<nsIPrompt> & outPrompt ) PRBool GetNSIPrompt( nsCOMPtr<nsIPrompt> & outPrompt )
{ {
@ -186,29 +183,4 @@ nsresult nsNetSupportDialog::Select(const PRUnichar *inDialogTitle, const PRUnic
return rv; return rv;
} }
// COM Fluff
NS_IMPL_ISUPPORTS1( nsNetSupportDialog, nsIPrompt ); NS_IMPL_ISUPPORTS1( nsNetSupportDialog, nsIPrompt );
NS_DEF_FACTORY(NetSupportDialog, nsNetSupportDialog)
nsresult NS_NewNetSupportDialogFactory(nsIFactory** aFactory)
{
nsresult rv = NS_OK;
nsIFactory* inst = new nsNetSupportDialogFactory();
if (nsnull == inst)
{
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
{
NS_ADDREF(inst);
}
*aFactory = inst;
return rv;
}

Просмотреть файл

@ -21,7 +21,7 @@
*/ */
#include "nsISessionHistory.h" #include "nsSessionHistory.h"
#include "nsAppShellCIDs.h" #include "nsAppShellCIDs.h"
#include "nsVoidArray.h" #include "nsVoidArray.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
@ -41,8 +41,7 @@
static NS_DEFINE_CID(kWebShellCID, NS_WEB_SHELL_CID); static NS_DEFINE_CID(kWebShellCID, NS_WEB_SHELL_CID);
// Advance declarations
class nsHistoryEntry;
static nsHistoryEntry * GenerateTree(const char * aStickyURL, nsIWebShell * aStickyContainer, nsIWebShell * aContainer,nsHistoryEntry *aParent, nsISessionHistory * aSHist); static nsHistoryEntry * GenerateTree(const char * aStickyURL, nsIWebShell * aStickyContainer, nsIWebShell * aContainer,nsHistoryEntry *aParent, nsISessionHistory * aSHist);
@ -717,48 +716,6 @@ nsHistoryEntry::GetRootDoc(void) {
return top; return top;
} }
class nsSessionHistory: public nsISessionHistory
{
public:
nsSessionHistory();
//nsISupports
NS_DECL_ISUPPORTS
NS_DEFINE_STATIC_CID_ACCESSOR( NS_SESSIONHISTORY_CID )
NS_DECL_NSISESSIONHISTORY
protected:
virtual ~nsSessionHistory();
private:
PRInt32 mHistoryLength;
PRInt32 mHistoryCurrentIndex;
nsVoidArray mHistoryEntries;
/** Following member is used to identify whether we are in the
* middle of loading a history document. The mIsLoadingDoc flag is
* used to determine whether the document that is curently loaded
* in the window s'd go to the end of the historylist or to be
* handed over to the current history entry (mIndexOfHistoryInLoad)
* that is in the process of loading. The current history entry
* being loaded uses this new historyentry to decide whether the
* document is completely in par with the one in history. If not, it
* will initiate further loads. When the document currently loaded is
* completely on par with the one in history, it will clear the
* mIsLoadingDoc flag. Any new URL loaded from then on, will go to the
* end of the history list. Note: these members are static.
*/
PRBool mIsLoadingDoc;
nsHistoryEntry * mHistoryEntryInLoad;
};
MOZ_DECL_CTOR_COUNTER(nsSessionHistory); MOZ_DECL_CTOR_COUNTER(nsSessionHistory);
nsSessionHistory::nsSessionHistory() nsSessionHistory::nsSessionHistory()
@ -1367,107 +1324,3 @@ nsSessionHistory::SetHistoryObjectForIndex(PRInt32 aIndex, nsISupports* aState)
return NS_OK; return NS_OK;
} }
NS_EXPORT nsresult NS_NewSessionHistory(nsISessionHistory** aResult)
{
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = new nsSessionHistory();
if (nsnull == *aResult) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aResult);
return NS_OK;
}
//----------------------------------------------------------------------
// Factory code for creating nsSessionHistory
class nsSessionHistoryFactory : public nsIFactory
{
public:
nsSessionHistoryFactory();
NS_DECL_ISUPPORTS
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
protected:
virtual ~nsSessionHistoryFactory();
};
nsSessionHistoryFactory::nsSessionHistoryFactory()
{
NS_INIT_REFCNT();
}
nsresult
nsSessionHistoryFactory::LockFactory(PRBool aLock)
{
return NS_OK;
}
nsSessionHistoryFactory::~nsSessionHistoryFactory()
{
}
NS_IMPL_ISUPPORTS1(nsSessionHistoryFactory, nsIFactory);
nsresult
nsSessionHistoryFactory::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
nsresult rv;
nsSessionHistory* inst;
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
if (nsnull != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
goto done;
}
NS_NEWXPCOM(inst, nsSessionHistory);
if (inst == NULL) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto done;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst);
done:
return rv;
}
nsresult
NS_NewSessionHistoryFactory(nsIFactory** aFactory)
{
nsresult rv = NS_OK;
nsIFactory* inst = new nsSessionHistoryFactory();
if (nsnull == inst) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
else {
NS_ADDREF(inst);
}
*aFactory = inst;
return rv;
}

Просмотреть файл

Просмотреть файл

@ -36,7 +36,6 @@
#include "nsIWindowMediator.h" #include "nsIWindowMediator.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsXPComFactory.h"
#include "nsIWebShellWindow.h" #include "nsIWebShellWindow.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
@ -44,11 +43,12 @@
#include "nsIDocumentViewer.h" #include "nsIDocumentViewer.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsWindowMediator.h"
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID); static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID); static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
static const char kURINC_WindowMediatorRoot[] = "NC:WindowMediatorRoot"; static const char kURINC_WindowMediatorRoot[] = "NC:WindowMediatorRoot";
@ -160,152 +160,6 @@ struct nsWindowInfo
} }
}; };
class nsWindowEnumerator;
class nsWindowMediator : public nsIWindowMediator
{
friend class nsWindowEnumerator;
public:
nsWindowMediator();
virtual ~nsWindowMediator();
nsresult Init();
NS_DECL_NSIWINDOWMEDIATOR
// COM and RDF
NS_DECL_ISUPPORTS
// RDF
// nsIRDFDataSource
NS_IMETHOD GetURI(char* *uri)
{
NS_PRECONDITION(uri != nsnull, "null ptr");
if (! uri)
return NS_ERROR_NULL_POINTER;
*uri = nsXPIDLCString::Copy("rdf:window-mediator");
if (! *uri)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHOD GetSource(nsIRDFResource* property,
nsIRDFNode* target,
PRBool tv,
nsIRDFResource** source)
{
return mInner->GetSource(property, target, tv, source);
}
NS_IMETHOD GetSources(nsIRDFResource* property,
nsIRDFNode* target,
PRBool tv,
nsISimpleEnumerator** sources)
{
return mInner->GetSources(property, target, tv, sources);
}
NS_IMETHOD GetTarget(nsIRDFResource* source,
nsIRDFResource* property,
PRBool tv,
nsIRDFNode** target)
{
return mInner->GetTarget(source, property, tv, target);
}
NS_IMETHOD GetTargets(nsIRDFResource* source,
nsIRDFResource* property,
PRBool tv,
nsISimpleEnumerator** targets)
{
return mInner->GetTargets(source, property, tv, targets);
}
NS_IMETHOD Assert(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget,
PRBool aTruthValue);
NS_IMETHOD Unassert(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget);
NS_IMETHOD Change(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aOldTarget,
nsIRDFNode* aNewTarget);
NS_IMETHOD Move(nsIRDFResource* aOldSource,
nsIRDFResource* aNewSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget);
NS_IMETHOD HasAssertion(nsIRDFResource* source,
nsIRDFResource* property,
nsIRDFNode* target,
PRBool tv,
PRBool* hasAssertion)
{
return mInner->HasAssertion(source, property, target, tv, hasAssertion);
}
NS_IMETHOD AddObserver(nsIRDFObserver* n)
{
return mInner->AddObserver(n);
}
NS_IMETHOD RemoveObserver(nsIRDFObserver* n)
{
return mInner->RemoveObserver(n);
}
NS_IMETHOD ArcLabelsIn( nsIRDFNode* node, nsISimpleEnumerator** labels)
{
return mInner->ArcLabelsIn(node, labels);
}
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source, nsISimpleEnumerator** labels)
{
return mInner->ArcLabelsOut(source, labels);
}
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor)
{
return mInner->GetAllResources(aCursor);
}
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
nsIEnumerator** commands);
NS_IMETHOD GetAllCmds(nsIRDFResource* source,
nsISimpleEnumerator** commands);
NS_IMETHOD IsCommandEnabled(nsISupportsArray* aSources,
nsIRDFResource* aCommand,
nsISupportsArray* aArguments,
PRBool* aResult);
NS_IMETHOD DoCommand(nsISupportsArray* aSources,
nsIRDFResource* aCommand,
nsISupportsArray* aArguments);
private:
// Helper functions
nsresult AddWindowToRDF( nsWindowInfo* ioWindowInfo );
PRInt32 AddEnumerator( nsWindowEnumerator* inEnumerator );
PRInt32 RemoveEnumerator( nsWindowEnumerator* inEnumerator);
PRInt32 mTimeStamp;
nsVoidArray mEnumeratorList;
nsVoidArray mWindowList;
// pseudo-constants for RDF
static nsIRDFResource* kNC_WindowMediatorRoot;
static nsIRDFResource* kNC_Name;
static nsIRDFResource* kNC_URL;
static PRInt32 gRefCnt;
static nsIRDFDataSource* mInner;
};
class nsWindowEnumerator : public nsISimpleEnumerator class nsWindowEnumerator : public nsISimpleEnumerator
@ -801,28 +655,6 @@ nsresult nsWindowMediator::AddWindowToRDF( nsWindowInfo* ioWindowInfo )
} }
//----------------------------------------------------------------------
// Entry point to create nsAppShellService factory instances...
NS_DEF_FACTORY(WindowMediator, nsWindowMediator)
nsresult NS_NewWindowMediatorFactory(nsIFactory** aResult)
{
nsresult rv = NS_OK;
nsIFactory* inst;
inst = new nsWindowMediatorFactory;
if (nsnull == inst)
{
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
{
NS_ADDREF(inst);
}
*aResult = inst;
return rv;
}
// window Enumerator // window Enumerator
nsWindowEnumerator::nsWindowEnumerator ( const PRUnichar* inTypeString, nsWindowMediator& inMediator, nsWindowEnumerator::nsWindowEnumerator ( const PRUnichar* inTypeString, nsWindowMediator& inMediator,

Просмотреть файл

@ -0,0 +1,177 @@
/* -*- 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.1 (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.
*
* Contributor(s):
*/
#ifndef __nsWindowMediator_h
#define __nsWindowMediator_h
#include "nsIWindowMediator.h"
#include "nsXPIDLString.h"
class nsWindowEnumerator;
struct nsWindowInfo;
class nsWindowMediator : public nsIWindowMediator
{
friend class nsWindowEnumerator;
public:
nsWindowMediator();
virtual ~nsWindowMediator();
nsresult Init();
NS_DECL_NSIWINDOWMEDIATOR
// COM and RDF
NS_DECL_ISUPPORTS
// RDF
// nsIRDFDataSource
NS_IMETHOD GetURI(char* *uri)
{
NS_PRECONDITION(uri != nsnull, "null ptr");
if (! uri)
return NS_ERROR_NULL_POINTER;
*uri = nsXPIDLCString::Copy("rdf:window-mediator");
if (! *uri)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHOD GetSource(nsIRDFResource* property,
nsIRDFNode* target,
PRBool tv,
nsIRDFResource** source)
{
return mInner->GetSource(property, target, tv, source);
}
NS_IMETHOD GetSources(nsIRDFResource* property,
nsIRDFNode* target,
PRBool tv,
nsISimpleEnumerator** sources)
{
return mInner->GetSources(property, target, tv, sources);
}
NS_IMETHOD GetTarget(nsIRDFResource* source,
nsIRDFResource* property,
PRBool tv,
nsIRDFNode** target)
{
return mInner->GetTarget(source, property, tv, target);
}
NS_IMETHOD GetTargets(nsIRDFResource* source,
nsIRDFResource* property,
PRBool tv,
nsISimpleEnumerator** targets)
{
return mInner->GetTargets(source, property, tv, targets);
}
NS_IMETHOD Assert(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget,
PRBool aTruthValue);
NS_IMETHOD Unassert(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget);
NS_IMETHOD Change(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aOldTarget,
nsIRDFNode* aNewTarget);
NS_IMETHOD Move(nsIRDFResource* aOldSource,
nsIRDFResource* aNewSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget);
NS_IMETHOD HasAssertion(nsIRDFResource* source,
nsIRDFResource* property,
nsIRDFNode* target,
PRBool tv,
PRBool* hasAssertion)
{
return mInner->HasAssertion(source, property, target, tv, hasAssertion);
}
NS_IMETHOD AddObserver(nsIRDFObserver* n)
{
return mInner->AddObserver(n);
}
NS_IMETHOD RemoveObserver(nsIRDFObserver* n)
{
return mInner->RemoveObserver(n);
}
NS_IMETHOD ArcLabelsIn( nsIRDFNode* node, nsISimpleEnumerator** labels)
{
return mInner->ArcLabelsIn(node, labels);
}
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source, nsISimpleEnumerator** labels)
{
return mInner->ArcLabelsOut(source, labels);
}
NS_IMETHOD GetAllResources(nsISimpleEnumerator** aCursor)
{
return mInner->GetAllResources(aCursor);
}
NS_IMETHOD GetAllCommands(nsIRDFResource* source,
nsIEnumerator** commands);
NS_IMETHOD GetAllCmds(nsIRDFResource* source,
nsISimpleEnumerator** commands);
NS_IMETHOD IsCommandEnabled(nsISupportsArray* aSources,
nsIRDFResource* aCommand,
nsISupportsArray* aArguments,
PRBool* aResult);
NS_IMETHOD DoCommand(nsISupportsArray* aSources,
nsIRDFResource* aCommand,
nsISupportsArray* aArguments);
private:
// Helper functions
nsresult AddWindowToRDF( nsWindowInfo* ioWindowInfo );
PRInt32 AddEnumerator( nsWindowEnumerator* inEnumerator );
PRInt32 RemoveEnumerator( nsWindowEnumerator* inEnumerator);
PRInt32 mTimeStamp;
nsVoidArray mEnumeratorList;
nsVoidArray mWindowList;
// pseudo-constants for RDF
static nsIRDFResource* kNC_WindowMediatorRoot;
static nsIRDFResource* kNC_Name;
static nsIRDFResource* kNC_URL;
static PRInt32 gRefCnt;
static nsIRDFDataSource* mInner;
};
#endif

Просмотреть файл

@ -20,33 +20,14 @@
* Contributor(s): * Contributor(s):
*/ */
#include "nsXPConnectFactory.h"
#include "nsRepository.h" #include "nsRepository.h"
#include "nsXPComFactory.h" #include "nsXPComFactory.h"
#include "nsIScriptObjectOwner.h" #include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "nsIDOMXPConnectFactory.h" #include "nsIDOMXPConnectFactory.h"
class XPConnectFactoryImpl : public nsIDOMXPConnectFactory,
public nsIScriptObjectOwner
{
public:
XPConnectFactoryImpl();
NS_DECL_ISUPPORTS
// nsIXPConnectFactory interface...
NS_IMETHOD CreateInstance(const nsString &progID, nsISupports**_retval);
// nsIScriptObjectOwner interface...
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
NS_IMETHOD SetScriptObject(void *aScriptObject);
protected:
virtual ~XPConnectFactoryImpl();
private:
void *mScriptObject;
};
XPConnectFactoryImpl::XPConnectFactoryImpl() XPConnectFactoryImpl::XPConnectFactoryImpl()
@ -133,24 +114,3 @@ XPConnectFactoryImpl::SetScriptObject(void *aScriptObject)
return NS_OK; return NS_OK;
} }
// -----
// Entry point to create nsXPConnectFactory factory instances...
// -----
NS_DEF_FACTORY(XPConnectFactory, XPConnectFactoryImpl)
nsresult NS_NewXPConnectFactoryFactory(nsIFactory** aResult)
{
nsresult rv = NS_OK;
nsIFactory* inst = new nsXPConnectFactoryFactory();
if (nsnull == inst) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
else {
NS_ADDREF(inst);
}
*aResult = inst;
return rv;
}

Просмотреть файл

@ -0,0 +1,50 @@
/* -*- 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.1 (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.
*
* Contributor(s):
*/
#ifndef __XPConnectFactory_h
#define __XPConnectFactory_h
#include "nsIDOMXPConnectFactory.h"
#include "nsIScriptObjectOwner.h"
class XPConnectFactoryImpl : public nsIDOMXPConnectFactory,
public nsIScriptObjectOwner
{
public:
XPConnectFactoryImpl();
NS_DECL_ISUPPORTS
// nsIXPConnectFactory interface...
NS_IMETHOD CreateInstance(const nsString &progID, nsISupports**_retval);
// nsIScriptObjectOwner interface...
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
NS_IMETHOD SetScriptObject(void *aScriptObject);
protected:
virtual ~XPConnectFactoryImpl();
private:
void *mScriptObject;
};
#endif

Просмотреть файл

@ -22,44 +22,11 @@
#include "nsICmdLineService.h" #include "nsICmdLineService.h"
#include "nsVoidArray.h" #include "nsCommandLineService.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
#include "nsString.h" #include "nsString.h"
#include "plstr.h" #include "plstr.h"
/* Define Class IDs */
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
class nsCmdLineService : public nsICmdLineService
{
public:
nsCmdLineService(void);
NS_DECL_ISUPPORTS
NS_IMETHOD Initialize(PRInt32 aArgc, char** aArgv);
NS_IMETHOD GetCmdLineValue(const char* aArg, char **aValue);
NS_IMETHOD GetURLToLoad(char ** aResult);
NS_IMETHOD GetProgramName(char ** aResult);
NS_IMETHOD GetArgc(PRInt32 * aResult);
NS_IMETHOD GetArgv(char *** aResult);
protected:
virtual ~nsCmdLineService();
nsVoidArray mArgList; // The arguments
nsVoidArray mArgValueList; // The argument values
PRInt32 mArgCount; // This is not argc. This is # of argument pairs
// in the arglist and argvaluelist arrays. This
// normally is argc/2.
PRInt32 mArgc; // This is argc;
char ** mArgv; // This is argv;
};
nsCmdLineService::nsCmdLineService() nsCmdLineService::nsCmdLineService()
: mArgCount(0), mArgc(0), mArgv(0) : mArgCount(0), mArgc(0), mArgv(0)
{ {
@ -280,92 +247,3 @@ NS_EXPORT nsresult NS_NewCmdLineService(nsICmdLineService** aResult)
return NS_OK; return NS_OK;
} }
//----------------------------------------------------------------------
// Factory code for creating nsAppShellService's
class nsCmdLineServiceFactory : public nsIFactory
{
public:
nsCmdLineServiceFactory();
NS_DECL_ISUPPORTS
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
protected:
virtual ~nsCmdLineServiceFactory();
};
nsCmdLineServiceFactory::nsCmdLineServiceFactory()
{
NS_INIT_REFCNT();
}
nsresult
nsCmdLineServiceFactory::LockFactory(PRBool lock)
{
return NS_OK;
}
nsCmdLineServiceFactory::~nsCmdLineServiceFactory()
{
}
NS_IMPL_ISUPPORTS1(nsCmdLineServiceFactory, nsIFactory);
nsresult
nsCmdLineServiceFactory::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
nsresult rv;
nsCmdLineService* inst;
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
if (nsnull != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
goto done;
}
NS_NEWXPCOM(inst, nsCmdLineService);
if (inst == NULL) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto done;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst);
done:
return rv;
}
extern "C" NS_APPSHELL nsresult
NS_NewCmdLineServiceFactory(nsIFactory** aFactory)
{
nsresult rv = NS_OK;
nsIFactory* inst = new nsCmdLineServiceFactory();
if (nsnull == inst) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
else {
NS_ADDREF(inst);
}
*aFactory = inst;
return rv;
}

Просмотреть файл

@ -0,0 +1,54 @@
/* -*- 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.1 (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.
*
* Contributor(s):
*/
#ifndef __nsCommandLineService_h
#define __nsCommandLineService_h
#include "nsISupports.h"
#include "nsVoidArray.h"
class nsCmdLineService : public nsICmdLineService
{
public:
nsCmdLineService(void);
NS_DECL_ISUPPORTS
NS_IMETHOD Initialize(PRInt32 aArgc, char** aArgv);
NS_IMETHOD GetCmdLineValue(const char* aArg, char **aValue);
NS_IMETHOD GetURLToLoad(char ** aResult);
NS_IMETHOD GetProgramName(char ** aResult);
NS_IMETHOD GetArgc(PRInt32 * aResult);
NS_IMETHOD GetArgv(char *** aResult);
protected:
virtual ~nsCmdLineService();
nsVoidArray mArgList; // The arguments
nsVoidArray mArgValueList; // The argument values
PRInt32 mArgCount; // This is not argc. This is # of argument pairs
// in the arglist and argvaluelist arrays. This
// normally is argc/2.
PRInt32 mArgc; // This is argc;
char ** mArgv; // This is argv;
};
#endif