зеркало из https://github.com/mozilla/gecko-dev.git
implement new nsIMessenger interface, and make it accessable from JavaScript
This commit is contained in:
Родитель
dba169e3d7
Коммит
180a1fb0e2
|
@ -25,10 +25,15 @@
|
|||
#include "rdf.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#include "nsMessenger.h"
|
||||
|
||||
/* Include all of the interfaces our factory can generate components for */
|
||||
#include "nsIMsgRFC822Parser.h"
|
||||
#include "nsMsgRFC822Parser.h"
|
||||
|
||||
static NS_DEFINE_CID(kCMessengerCID, NS_MESSENGER_CID);
|
||||
static NS_DEFINE_CID(kCMessengerBootstrapCID, NS_MESSENGER_CID);
|
||||
|
||||
static NS_DEFINE_CID(kCMsgRFC822ParserCID, NS_MSGRFC822PARSER_CID);
|
||||
static NS_DEFINE_CID(kCMsgFolderEventCID, NS_MSGFOLDEREVENT_CID);
|
||||
|
||||
|
@ -44,7 +49,10 @@ public:
|
|||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsMsgFactory(const nsCID &aClass, const char* aClassName, const char* aProgID);
|
||||
nsMsgFactory(const nsCID &aClass,
|
||||
const char* aClassName,
|
||||
const char* aProgID,
|
||||
nsISupports*);
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter, const nsIID &aIID, void **aResult);
|
||||
|
@ -56,22 +64,35 @@ protected:
|
|||
nsCID mClassID;
|
||||
char* mClassName;
|
||||
char* mProgID;
|
||||
nsIServiceManager* mServiceManager;
|
||||
};
|
||||
|
||||
nsMsgFactory::nsMsgFactory(const nsCID &aClass, const char* aClassName, const char* aProgID)
|
||||
: mClassID(aClass), mClassName(nsCRT::strdup(aClassName)), mProgID(nsCRT::strdup(aProgID))
|
||||
{
|
||||
nsMsgFactory::nsMsgFactory(const nsCID &aClass,
|
||||
const char* aClassName,
|
||||
const char* aProgID,
|
||||
nsISupports *serviceMgrSupports)
|
||||
: mClassID(aClass),
|
||||
mClassName(nsCRT::strdup(aClassName)),
|
||||
mProgID(nsCRT::strdup(aProgID))
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// store a copy of the
|
||||
serviceMgrSupports->QueryInterface(nsIServiceManager::IID(),
|
||||
(void **)mServiceManager);
|
||||
}
|
||||
|
||||
nsMsgFactory::~nsMsgFactory()
|
||||
{
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
|
||||
NS_IF_RELEASE(mServiceManager);
|
||||
delete[] mClassName;
|
||||
delete[] mProgID;
|
||||
}
|
||||
|
||||
nsresult nsMsgFactory::QueryInterface(const nsIID &aIID, void **aResult)
|
||||
nsresult
|
||||
nsMsgFactory::QueryInterface(const nsIID &aIID, void **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
@ -95,7 +116,10 @@ nsresult nsMsgFactory::QueryInterface(const nsIID &aIID, void **aResult)
|
|||
NS_IMPL_ADDREF(nsMsgFactory)
|
||||
NS_IMPL_RELEASE(nsMsgFactory)
|
||||
|
||||
nsresult nsMsgFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, void **aResult)
|
||||
nsresult
|
||||
nsMsgFactory::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
|
@ -119,6 +143,15 @@ nsresult nsMsgFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, vo
|
|||
NS_NOTREACHED("hello? what happens here?");
|
||||
return NS_OK;
|
||||
}
|
||||
else if (mClassID.Equals(kCMessengerBootstrapCID)) {
|
||||
res = NS_NewMessengerBootstrap((nsIAppShellService**)&inst,
|
||||
mServiceManager);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
else if (mClassID.Equals(kCMessengerCID)) {
|
||||
res = NS_NewMessenger((nsIMessenger**)&inst);
|
||||
if (NS_FAILED(res)) return res;
|
||||
}
|
||||
|
||||
// End of checking the interface ID code....
|
||||
if (inst) {
|
||||
|
@ -135,7 +168,8 @@ nsresult nsMsgFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, vo
|
|||
return res;
|
||||
}
|
||||
|
||||
nsresult nsMsgFactory::LockFactory(PRBool aLock)
|
||||
nsresult
|
||||
nsMsgFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
if (aLock) {
|
||||
PR_AtomicIncrement(&g_LockCount);
|
||||
|
@ -158,9 +192,10 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr,
|
|||
if (nsnull == aFactory)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aFactory = new nsMsgFactory(aClass, aClassName, aProgID);
|
||||
*aFactory = new nsMsgFactory(aClass, aClassName, aProgID, serviceMgr);
|
||||
if (aFactory)
|
||||
return (*aFactory)->QueryInterface(nsIFactory::IID(), (void**)aFactory);
|
||||
return (*aFactory)->QueryInterface(nsIFactory::IID(),
|
||||
(void**)aFactory);
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -181,6 +216,12 @@ NSRegisterSelf(nsISupports* serviceMgr, const char* path)
|
|||
rv = nsRepository::RegisterComponent(kCMsgFolderEventCID,
|
||||
nsnull, nsnull,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
|
||||
rv = nsRepository::RegisterComponent(kCMessengerCID,
|
||||
"Netscape Messenger",
|
||||
"component://netscape/messenger",
|
||||
path,
|
||||
PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -30,6 +30,7 @@ IDLSRCS = \
|
|||
|
||||
EXPORTS = \
|
||||
msgCore.h \
|
||||
nsIMessenger.h \
|
||||
nsMsgFolderFlags.h \
|
||||
nsMsgHeaderMasks.h \
|
||||
nsMsgMessageFlags.h \
|
||||
|
|
|
@ -26,6 +26,7 @@ IDLSRCS = \
|
|||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsIMessenger.h \
|
||||
nsIMsgRFC822Parser.h \
|
||||
msgCore.h \
|
||||
nsMsgFolderFlags.h \
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* DO NOT EDIT. THIS FILE IS GENERATED FROM nsIMessenger.idl
|
||||
*/
|
||||
|
||||
#ifndef __gen_nsIMessenger_h__
|
||||
#define __gen_nsIMessenger_h__
|
||||
|
||||
#include "nsISupports.h" /* interface nsISupports */
|
||||
#include "nsID.h" /* interface nsID */
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
#include "jsapi.h"
|
||||
#endif
|
||||
#include "nsDebug.h"
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "nsID.h"
|
||||
#include "nsIID.h"
|
||||
#include "nsError.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
|
||||
|
||||
/* starting interface nsIMessenger */
|
||||
|
||||
/* {01883380-cab9-11d2-b7f6-00805f05ffa5} */
|
||||
#define NS_IMESSENGER_IID_STR "01883380-cab9-11d2-b7f6-00805f05ffa5"
|
||||
#define NS_IMESSENGER_IID \
|
||||
{0x01883380, 0xcab9, 0x11d2, \
|
||||
{ 0xb7, 0xf6, 0x00, 0x80, 0x5f, 0x05, 0xff, 0xa5 }}
|
||||
|
||||
class nsIMessenger : public nsISupports {
|
||||
public:
|
||||
static const nsIID& IID() {
|
||||
static nsIID iid = NS_IMESSENGER_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIMessenger *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* __gen_nsIMessenger_h__ */
|
|
@ -0,0 +1,26 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[object, uuid(01883380-cab9-11d2-b7f6-00805f05ffa5)]
|
||||
interface nsIMessenger : nsISupports {
|
||||
|
||||
|
||||
};
|
||||
|
|
@ -26,6 +26,7 @@ MODULE = mailnewsbase
|
|||
LIBRARY_NAME=mailnewsbase
|
||||
|
||||
EXPORTS = \
|
||||
nsMessenger.h \
|
||||
nsMsgKeyArray.h\
|
||||
nsMsgGroupRecord.h \
|
||||
nsMsgRFC822Parser.h \
|
||||
|
@ -37,6 +38,8 @@ EXPORTS = \
|
|||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsMessenger.cpp \
|
||||
nsMessengerNameSet.cpp \
|
||||
nsMsgGroupRecord.cpp \
|
||||
nsMsgRFC822Parser.cpp \
|
||||
nsMsgFolder.cpp \
|
||||
|
|
|
@ -27,6 +27,8 @@ REQUIRES=xpcom js nspr
|
|||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= \
|
||||
nsMessenger.cpp \
|
||||
nsMessengerNameSet.cpp \
|
||||
nsMsgRFC822Parser.cpp \
|
||||
nsUInt32Array.cpp \
|
||||
nsMsgKeyArray.cpp \
|
||||
|
@ -39,6 +41,8 @@ CPPSRCS= \
|
|||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsMessenger.obj \
|
||||
.\$(OBJDIR)\nsMessengerNameSet.obj \
|
||||
.\$(OBJDIR)\nsMsgRFC822Parser.obj \
|
||||
.\$(OBJDIR)\nsUInt32Array.obj \
|
||||
.\$(OBJDIR)\nsMsgKeyArray.obj \
|
||||
|
@ -51,6 +55,7 @@ CPP_OBJS= \
|
|||
$(NULL)
|
||||
|
||||
EXPORTS= \
|
||||
nsMessenger.h \
|
||||
nsMsgRFC822Parser.h \
|
||||
nsUInt32Array.h \
|
||||
nsMsgKeyArray.h \
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsMessenger.h"
|
||||
#include "nsMessengerNameSet.h"
|
||||
#include "nsIScriptNameSetRegistry.h"
|
||||
|
||||
#include "nsDOMCID.h"
|
||||
|
||||
static NS_DEFINE_IID(kCScriptNameSetRegistryCID, NS_SCRIPT_NAMESET_REGISTRY_CID);
|
||||
|
||||
class nsMessengerBootstrap : public nsIAppShellService {
|
||||
|
||||
public:
|
||||
nsMessengerBootstrap(nsIServiceManager *serviceManager);
|
||||
virtual ~nsMessengerBootstrap();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIAppShellService
|
||||
// Initialize() is the only one we care about
|
||||
NS_IMETHOD Initialize();
|
||||
|
||||
private:
|
||||
nsIServiceManager *mServiceManager;
|
||||
|
||||
|
||||
private:
|
||||
NS_IMETHOD Run(void) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD GetNativeEvent(void *& aEvent,
|
||||
nsIWidget* aWidget,
|
||||
PRBool &aIsInWindow,
|
||||
PRBool &aIsMouseEvent)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHOD DispatchNativeEvent(void * aEvent)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD Shutdown(void)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHOD CreateTopLevelWindow(nsIWidget * aParent,
|
||||
nsIURL* aUrl,
|
||||
nsString& aControllerIID,
|
||||
nsIWidget*& aResult, nsIStreamObserver* anObserver,
|
||||
nsIXULWindowCallbacks *aCallbacks,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD CreateDialogWindow( nsIWidget * aParent,
|
||||
nsIURL* aUrl,
|
||||
nsString& aControllerIID,
|
||||
nsIWidget*& aResult,
|
||||
nsIStreamObserver* anObserver,
|
||||
nsIXULWindowCallbacks *aCallbacks,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHOD CloseTopLevelWindow(nsIWidget* aWindow)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD RegisterTopLevelWindow(nsIWidget* aWindow)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD UnregisterTopLevelWindow(nsIWidget* aWindow)
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMessengerBootstrap, nsIAppShellService::IID())
|
||||
|
||||
nsMessengerBootstrap::nsMessengerBootstrap(nsIServiceManager *serviceManager)
|
||||
: mServiceManager(serviceManager)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
if (mServiceManager) NS_ADDREF(mServiceManager);
|
||||
}
|
||||
|
||||
nsMessengerBootstrap::~nsMessengerBootstrap()
|
||||
{
|
||||
NS_IF_RELEASE(mServiceManager);
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMessengerBootstrap::Initialize()
|
||||
{
|
||||
nsIScriptNameSetRegistry *registry;
|
||||
nsresult rv =
|
||||
nsServiceManager::GetService(kCScriptNameSetRegistryCID,
|
||||
nsIScriptNameSetRegistry::IID(),
|
||||
(nsISupports **)®istry);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsMessengerNameSet* nameSet = new nsMessengerNameSet();
|
||||
rv = registry->AddExternalNameSet(nameSet);
|
||||
/* todo - when to release this service? */
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewMessengerBootstrap(nsIAppShellService **msgboot,
|
||||
nsIServiceManager *serviceManager)
|
||||
{
|
||||
if (!msgboot) return NS_ERROR_NULL_POINTER;
|
||||
if (!serviceManager) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsMessengerBootstrap *bootstrap =
|
||||
new nsMessengerBootstrap(serviceManager);
|
||||
|
||||
if (!bootstrap) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
return bootstrap->QueryInterface(nsIAppShellService::IID(),
|
||||
(void **)msgboot);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __nsMessenger_h
|
||||
#define __nsMessenger_h
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIMessenger.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIAppShellService.h"
|
||||
|
||||
#define NS_MESSENGER_CID \
|
||||
{ /* 241471d0-cdda-11d2-b7f6-00805f05ffa5 */ \
|
||||
0x241471d0, 0xcdda, 0x11d2, \
|
||||
{0xb7, 0xf6, 0x00, 0x80, 0x5f, 0x05, 0xff, 0xa5}}
|
||||
|
||||
#define NS_MESSENGERBOOTSTRAP_CID \
|
||||
{ /* 4a85a5d0-cddd-11d2-b7f6-00805f05ffa5 */ \
|
||||
0x4a85a5d0, 0xcddd, 0x11d2, \
|
||||
{0xb7, 0xf6, 0x00, 0x80, 0x5f, 0x05, 0xff, 0xa5}}
|
||||
|
||||
|
||||
NS_BEGIN_EXTERN_C
|
||||
|
||||
nsresult
|
||||
NS_NewMessenger(nsIMessenger **inst);
|
||||
|
||||
nsresult
|
||||
NS_NewMessengerBootstrap(nsIAppShellService** inst,
|
||||
nsIServiceManager* serviceManager);
|
||||
|
||||
NS_END_EXTERN_C
|
||||
|
||||
#endif
|
|
@ -0,0 +1,81 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "nsMessengerNameSet.h"
|
||||
|
||||
#include "nsIMessenger.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
#include "nsIScriptExternalNameSet.h"
|
||||
|
||||
static NS_DEFINE_IID(kIScriptExternalNameSetIID, NS_ISCRIPTEXTERNALNAMESET_IID);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
nsMessengerNameSet::nsMessengerNameSet()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsMessengerNameSet::~nsMessengerNameSet()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMessengerNameSet, nsIScriptExternalNameSet::IID());
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessengerNameSet::InitializeClasses(nsIScriptContext* aScriptContext)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
JSContext *cx = (JSContext*)aScriptContext->GetNativeContext();
|
||||
|
||||
printf("nsMessengerNameSet::InitializeClasses() Initializing base classes\n");
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
rv = nsIMessenger::InitJSClass(cx);
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessengerNameSet::AddNameSet(nsIScriptContext *aScriptContext)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsIScriptNameSpaceManager *manager;
|
||||
|
||||
printf("nsMessengerNameSet::AddNameSet() Registering Messenger in the JS namespace\n");
|
||||
rv = aScriptContext->GetNameSpaceManager(&manager);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = manager->RegisterGlobalName("Messenger",
|
||||
// put the CID here, not IID
|
||||
nsIMessenger::IID(),
|
||||
PR_TRUE);
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __nsMessengerNameSet_h
|
||||
#define __nsMessengerNameSet_h
|
||||
|
||||
#include "nsIScriptExternalNameSet.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
|
||||
class nsMessengerNameSet : public nsIScriptExternalNameSet
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
nsMessengerNameSet();
|
||||
virtual ~nsMessengerNameSet();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD InitializeClasses(nsIScriptContext *aScriptContext);
|
||||
NS_IMETHOD AddNameSet(nsIScriptContext* aScriptContext);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче