The compose.dll has been merged into msgcompose.dll in order to have the auto appcore registration working.

Initial check in
This commit is contained in:
ducarroz%netscape.com 1999-03-11 01:38:11 +00:00
parent bd1bdd2750
commit f31163fd6d
4 changed files with 351 additions and 0 deletions

View File

@ -0,0 +1,159 @@
/* -*- Mode: C++; tab-width: 4; 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.
*/
#include "nsComposer.h"
#include "nsComposerNameSet.h"
#include "nsIScriptNameSetRegistry.h"
#include "nsDOMCID.h"
static NS_DEFINE_IID(kCScriptNameSetRegistryCID, NS_SCRIPT_NAMESET_REGISTRY_CID);
class nsComposerBootstrap : public nsIAppShellService {
public:
nsComposerBootstrap(nsIServiceManager *serviceManager);
virtual ~nsComposerBootstrap();
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(nsComposerBootstrap, nsIAppShellService::GetIID())
nsComposerBootstrap::nsComposerBootstrap(nsIServiceManager *serviceManager)
: mServiceManager(serviceManager)
{
NS_INIT_REFCNT();
if (mServiceManager) NS_ADDREF(mServiceManager);
}
nsComposerBootstrap::~nsComposerBootstrap()
{
NS_IF_RELEASE(mServiceManager);
}
nsresult
nsComposerBootstrap::Initialize()
{
nsresult rv;
printf("Composer has been bootstrapped!\n");
nsIScriptNameSetRegistry* registry;
rv = nsServiceManager::GetService(kCScriptNameSetRegistryCID,
nsIScriptNameSetRegistry::GetIID(),
(nsISupports**)&registry);
if (NS_FAILED(rv))
return rv;
nsComposerNameSet* nameSet = new nsComposerNameSet();
if (nameSet == nsnull)
rv = NS_ERROR_OUT_OF_MEMORY;
else
rv = registry->AddExternalNameSet(nameSet);
(void)nsServiceManager::ReleaseService(kCScriptNameSetRegistryCID,
registry);
return rv;
}
nsresult
NS_NewComposerBootstrap(nsIAppShellService **msgboot,
nsIServiceManager *serviceManager)
{
if (!msgboot) return NS_ERROR_NULL_POINTER;
if (!serviceManager) return NS_ERROR_NULL_POINTER;
nsComposerBootstrap *bootstrap =
new nsComposerBootstrap(serviceManager);
if (!bootstrap) return NS_ERROR_OUT_OF_MEMORY;
return bootstrap->QueryInterface(nsIAppShellService::GetIID(),
(void **)msgboot);
}
// nsComposer implementation
class nsComposer : public nsIComposer {
public:
NS_DECL_ISUPPORTS;
};
NS_IMPL_ISUPPORTS(nsComposer, nsIComposer::GetIID())
nsresult
NS_NewComposer(nsIComposer **msg)
{
if (!msg) return NS_ERROR_NULL_POINTER;
nsComposer *composer =
new nsComposer();
if (!composer) return NS_ERROR_OUT_OF_MEMORY;
return composer->QueryInterface(nsIComposer::GetIID(),
(void**)&msg);
}

View File

@ -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 __nsComposer_h
#define __nsComposer_h
#include "nscore.h"
#include "nsIComposer.h"
#include "nsIServiceManager.h"
#include "nsIAppShellService.h"
#define NS_COMPOSER_CID \
{ /* 82041530-D73E-11d2-82A9-00805F2A0107 */ \
0x82041530, 0xd73e, 0x11d2, \
{0x82, 0xa9, 0x0, 0x80, 0x5f, 0x2a, 0x1, 0x7}}
#define NS_COMPOSERBOOTSTRAP_CID \
{ /* 82041531-D73E-11d2-82A9-00805F2A0107 */ \
0x82041531, 0xd73e, 0x11d2, \
{0x82, 0xa9, 0x0, 0x80, 0x5f, 0x2a, 0x1, 0x7}}
NS_BEGIN_EXTERN_C
nsresult
NS_NewComposer(nsIComposer **inst);
nsresult
NS_NewComposerBootstrap(nsIAppShellService** inst,
nsIServiceManager* serviceManager);
NS_END_EXTERN_C
#endif /*__nsComposer_h*/

View File

@ -0,0 +1,100 @@
/* -*- 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 "nsComposerNameSet.h"
#include "nsIComposer.h"
#include "jsapi.h"
#include "nsIScriptContext.h"
#include "nsIScriptNameSpaceManager.h"
#include "nsIScriptExternalNameSet.h"
#include "nsComposer.h"
/* hack the AppCore stuff here */
#include "nsIDOMComposeAppCore.h"
#include "nsComposeAppCore.h"
static NS_DEFINE_IID(kIScriptExternalNameSetIID, NS_ISCRIPTEXTERNALNAMESET_IID);
nsComposerNameSet::nsComposerNameSet()
{
NS_INIT_REFCNT();
}
nsComposerNameSet::~nsComposerNameSet()
{
}
NS_IMPL_ISUPPORTS(nsComposerNameSet, nsIScriptExternalNameSet::GetIID());
NS_IMETHODIMP
nsComposerNameSet::InitializeClasses(nsIScriptContext* aScriptContext)
{
nsresult rv = NS_OK;
JSContext *cx = (JSContext*)aScriptContext->GetNativeContext();
printf("nsComposerNameSet::InitializeClasses() Initializing base classes\n");
/* initialize the AppCore */
NS_InitComposeAppCoreClass(aScriptContext, nsnull);
#ifdef XPIDL_JS_STUBS
nsIComposer::InitJSClass(cx);
#endif
return rv;
}
static NS_DEFINE_CID(kCComposerCID, NS_COMPOSER_CID);
static NS_DEFINE_CID(kCComposeAppCoreCID, NS_COMPOSEAPPCORE_CID);
NS_IMETHODIMP
nsComposerNameSet::AddNameSet(nsIScriptContext *aScriptContext)
{
nsresult rv = NS_OK;
nsIScriptNameSpaceManager *manager;
printf("nsComposerNameSet::AddNameSet() Registering Composer in the JS namespace\n");
rv = aScriptContext->GetNameSpaceManager(&manager);
if (NS_SUCCEEDED(rv))
rv = manager->RegisterGlobalName("Composer",
// put the CID here, not IID
kCComposerCID,
PR_TRUE);
/* register the appcore here too */
if (NS_SUCCEEDED(rv))
rv = manager->RegisterGlobalName("ComposeAppCore",
kCComposeAppCoreCID,
PR_TRUE);
return rv;
}

View File

@ -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 __nsComposerNameSet_h
#define __nsComposerNameSet_h
#include "nsIScriptExternalNameSet.h"
#include "nsIScriptContext.h"
class nsComposerNameSet : public nsIScriptExternalNameSet
{
public:
nsComposerNameSet();
virtual ~nsComposerNameSet();
NS_DECL_ISUPPORTS
NS_IMETHOD InitializeClasses(nsIScriptContext *aScriptContext);
NS_IMETHOD AddNameSet(nsIScriptContext* aScriptContext);
};
#endif