From 0f2fac77957be95c6d2c00048a27a8bbad3100df Mon Sep 17 00:00:00 2001 From: "ducarroz%netscape.com" Date: Thu, 11 Mar 1999 01:38:11 +0000 Subject: [PATCH] The compose.dll has been merged into msgcompose.dll in order to have the auto appcore registration working. Initial check in git-svn-id: svn://10.0.0.236/trunk@23644 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mailnews/compose/src/nsComposer.cpp | 159 ++++++++++++++++++ mozilla/mailnews/compose/src/nsComposer.h | 50 ++++++ .../compose/src/nsComposerNameSet.cpp | 100 +++++++++++ .../mailnews/compose/src/nsComposerNameSet.h | 42 +++++ 4 files changed, 351 insertions(+) create mode 100644 mozilla/mailnews/compose/src/nsComposer.cpp create mode 100644 mozilla/mailnews/compose/src/nsComposer.h create mode 100644 mozilla/mailnews/compose/src/nsComposerNameSet.cpp create mode 100644 mozilla/mailnews/compose/src/nsComposerNameSet.h diff --git a/mozilla/mailnews/compose/src/nsComposer.cpp b/mozilla/mailnews/compose/src/nsComposer.cpp new file mode 100644 index 00000000000..bff556f238b --- /dev/null +++ b/mozilla/mailnews/compose/src/nsComposer.cpp @@ -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**)®istry); + 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); +} + diff --git a/mozilla/mailnews/compose/src/nsComposer.h b/mozilla/mailnews/compose/src/nsComposer.h new file mode 100644 index 00000000000..b0a594505d8 --- /dev/null +++ b/mozilla/mailnews/compose/src/nsComposer.h @@ -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*/ diff --git a/mozilla/mailnews/compose/src/nsComposerNameSet.cpp b/mozilla/mailnews/compose/src/nsComposerNameSet.cpp new file mode 100644 index 00000000000..803bd586029 --- /dev/null +++ b/mozilla/mailnews/compose/src/nsComposerNameSet.cpp @@ -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; + +} + + diff --git a/mozilla/mailnews/compose/src/nsComposerNameSet.h b/mozilla/mailnews/compose/src/nsComposerNameSet.h new file mode 100644 index 00000000000..f45ef1b07b3 --- /dev/null +++ b/mozilla/mailnews/compose/src/nsComposerNameSet.h @@ -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