no bug id

converted pluglet runner to XPCOM module
(see bug 15217)
(not a part of regular build)


git-svn-id: svn://10.0.0.236/trunk@53648 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
idk%eng.sun.com
1999-11-16 10:44:25 +00:00
parent 4bd89164cd
commit 56c7b4556f
6 changed files with 92 additions and 315 deletions

View File

@@ -29,18 +29,12 @@ How To Build:
* Follow the directions in ..\README
* if you do not have working OJI set OJI_DISABLED to 1
* if you do not have working OJI set OJI_DISABLE to 1
(You can do it in your command prompt, or you can set it in
mozilla/java/plugins/src).
* type "nmake /f makefile.win"
* apply the patch to mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp
by executing : patch nsPluginHostImpl.cpp < nsPluginHostImpl.patch
and execute "nmake /f makefile.win" inside mozilla/modules/plugin/nglsrc
directory
How to Run:
* Add following directories to to your path:

View File

@@ -1,4 +1,4 @@
/*
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* The contents of this file are subject to the Mozilla 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
@@ -23,31 +23,55 @@
#include "nsIServiceManager.h"
#include "prenv.h"
#include "PlugletManager.h"
#include "ProxyJNI.h"
#include "nsIGenericFactory.h"
#include "nsIModule.h"
static NS_DEFINE_IID(kIPluginIID,NS_IPLUGIN_IID);
static NS_DEFINE_CID(kPluginCID,NS_PLUGIN_CID);
static NS_DEFINE_IID(kIServiceManagerIID, NS_ISERVICEMANAGER_IID);
static NS_DEFINE_IID(kIJVMManagerIID,NS_IJVMMANAGER_IID);
#ifndef OJI_DISABLE
#include "ProxyJNI.h"
static NS_DEFINE_CID(kJVMManagerCID,NS_JVMMANAGER_CID);
PlugletSecurityContext *PlugletEngine::securityContext = NULL;
nsJVMManager * PlugletEngine::jvmManager = NULL;
#endif /* OJI_DISABLE */
static NS_DEFINE_CID(kIPluginIID,NS_IPLUGIN_IID);
static NS_DEFINE_CID(kPluginCID,NS_PLUGIN_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
static NS_DEFINE_CID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
#define PLUGLETENGINE_PROGID \
"component://netscape/blackwood/pluglet-engine"
#define PLUGLETENGINE_CID \
{ /* C1E694F3-9BE1-11d3-837C-0004AC56C49E */ \
0xc1e694f3, 0x9be1, 0x11d3, { 0x83, 0x7c, 0x0, 0x4, 0xac, 0x56, 0xc4, 0x9e } \
}
NS_GENERIC_FACTORY_CONSTRUCTOR(PlugletEngine)
static nsModuleComponentInfo components[] =
{
{
"Pluglet Engine",
PLUGLETENGINE_CID,
PLUGLETENGINE_PROGID,
PlugletEngineConstructor
}
};
NS_IMPL_NSGETMODULE("PlugletEngineModule",components);
#define PLUGIN_MIME_DESCRIPTION "*:*:Pluglet Engine"
nsJVMManager * PlugletEngine::jvmManager = NULL;
int PlugletEngine::objectCount = 0;
PlugletsDir * PlugletEngine::dir = NULL;
PRInt32 PlugletEngine::lockCount = 0;
PlugletEngine * PlugletEngine::engine = NULL;
nsIPluginManager *PlugletEngine::pluginManager = NULL;
nsCOMPtr<nsIPluginManager> PlugletEngine::pluginManager;
jobject PlugletEngine::plugletManager = NULL;
PlugletSecurityContext *PlugletEngine::securityContext = NULL;
#define PLUGIN_MIME_DESCRIPTION "*:*:Pluglet Engine"
NS_IMPL_ISUPPORTS(PlugletEngine,kIPluginIID);
NS_METHOD PlugletEngine::Initialize(void) {
@@ -117,27 +141,9 @@ char *ToString(jobject obj,JNIEnv *env) {
return res;
}
PlugletEngine::PlugletEngine(nsISupports* aService) {
PlugletEngine::PlugletEngine() {
NS_INIT_REFCNT();
dir = new PlugletsDir();
nsresult res = NS_OK;
nsIServiceManager *sm;
res = aService->QueryInterface(nsIServiceManager::GetIID(),(void**)&sm);
if (NS_FAILED(res)) {
return;
}
res = sm->GetService(kPluginManagerCID,kIPluginManagerIID,(nsISupports**)&pluginManager);
if (NS_FAILED(res)) {
return;
}
#ifndef OJI_DISABLED
res = sm->GetService(kJVMManagerCID,kIJVMManagerIID,(nsISupports**)&jvmManager);
if (NS_FAILED(res)) {
jvmManager = NULL;
}
#endif
NS_RELEASE(sm);
engine = this;
objectCount++;
}
@@ -152,13 +158,13 @@ PlugletEngine::~PlugletEngine(void) {
#ifdef XP_PC
#define PATH_SEPARATOR ';'
#else
#else /* XP_PC */
#define PATH_SEPARATOR ':'
#endif
#endif /* XP_PC */
JavaVM *jvm = NULL;
JavaVM *PlugletEngine::jvm = NULL;
static void StartJVM() {
void PlugletEngine::StartJVM(void) {
JNIEnv *env = NULL;
jint res;
JDK1_1InitArgs vm_args;
@@ -176,35 +182,49 @@ static void StartJVM() {
printf("--JNI_CreateJavaVM failed \n");
}
}
#endif // OJI_DISABLE
#endif /* OJI_DISABLE */
JNIEnv * PlugletEngine::GetJNIEnv(void) {
JNIEnv * res;
#ifndef OJI_DISABLE
nsresult result;
if (!jvmManager) {
NS_WITH_SERVICE(nsIJVMManager, _jvmManager, kJVMManagerCID, &result);
if (NS_SUCCEEDED(result)) {
jvmManager = (nsJVMManager*)((nsIJVMManager*)_jvmManager);
}
}
if (!jvmManager) {
//nb it is bad :(
return NULL;
}
jvmManager->CreateProxyJNI(NULL,&res);
if (!securityContext) {
securityContext = new PlugletSecurityContext();
}
::SetSecurityContext(res,securityContext);
//nb error handling
#else
SetSecurityContext(res,securityContext);
#else /* OJI_DISABLE */
if (!jvm) {
printf(":) starting jvm\n");
StartJVM();
}
jvm->AttachCurrentThread(&res,NULL);
#endif //OJI_DISABLED
#endif /* OJI_DISABLED */
return res;
}
jobject PlugletEngine::GetPlugletManager(void) {
if (!pluginManager) {
nsresult res;
NS_WITH_SERVICE(nsIPluginManager,_pluginManager,kPluginManagerCID,&res);
if (NS_SUCCEEDED(res)) {
pluginManager = _pluginManager;
}
}
if (!pluginManager) {
return NULL;
}
if (!plugletManager) {
plugletManager = PlugletManager::GetJObject(pluginManager);
plugletManager = PlugletManager::GetJObject(pluginManager.get());
}
return plugletManager;
}
@@ -224,80 +244,4 @@ PRBool PlugletEngine::IsUnloadable(void) {
return (lockCount == 0
&& objectCount == 0);
}
// ******************************************
extern "C" NS_EXPORT nsresult
NSGetFactory(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (aClass.Equals(kPluginCID)) {
if (PlugletEngine::GetEngine()) {
*aFactory = PlugletEngine::GetEngine();
return NS_OK;
}
PlugletEngine * engine = new PlugletEngine(serviceMgr);
if (!engine)
return NS_ERROR_OUT_OF_MEMORY;
engine->AddRef();
*aFactory = engine;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
extern "C" NS_EXPORT PRBool
NSCanUnload(nsISupports* serviceMgr)
{
return (PlugletEngine::IsUnloadable());
}
extern "C" char*
NP_GetMIMEDescription(void)
{
return PLUGIN_MIME_DESCRIPTION;
}

View File

@@ -1,28 +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) 1998 Netscape Communications Corporation. All
; Rights Reserved.
;
; Contributor(s):
LIBRARY nppluglet
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
NSGetFactory @1

View File

@@ -22,10 +22,14 @@
#define __PlugletEngine_h__
#include "nsplugin.h"
#include "jni.h"
#include "nsJVMManager.h"
#include "nsIPluginManager.h"
#include "PlugletsDir.h"
#include "nsComPtr.h"
#ifndef OJI_DISABLED
#include "nsJVMManager.h"
#include "PlugletSecurityContext.h"
#endif /* OJI_DISABLE */
class PlugletEngine : public nsIPlugin {
public:
@@ -39,7 +43,7 @@ class PlugletEngine : public nsIPlugin {
NS_IMETHOD GetMIMEDescription(const char* *result);
NS_IMETHOD GetValue(nsPluginVariable variable, void *value);
NS_DECL_ISUPPORTS
PlugletEngine(nsISupports* aService);
PlugletEngine();
virtual ~PlugletEngine(void);
static JNIEnv * GetJNIEnv(void);
static jobject GetPlugletManager(void);
@@ -52,12 +56,20 @@ class PlugletEngine : public nsIPlugin {
static PRInt32 lockCount;
static PlugletsDir *dir;
static PlugletEngine * engine;
static nsJVMManager * jvmManager;
static nsIPluginManager *pluginManager;
static nsCOMPtr<nsIPluginManager> pluginManager;
static jobject plugletManager;
static PlugletSecurityContext * securityContext;
#ifndef OJI_DISABLE
static nsJVMManager * jvmManager;
static PlugletSecurityContext *securityContext;
#else /* OJI_DISABLE */
static JavaVM *jvm;
static void StartJVM(void);
#endif /* OJI_DISABLE */
};
#endif /* __PlugletEngine_h__ */

View File

@@ -1,125 +0,0 @@
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif\r\n"
"#include ""res\\CharFlipper.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\0"
END
#endif // APSTUDIO_INVOKED
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "PlugletEngine\0"
VALUE "FileExtents", "*\0"
VALUE "FileOpenName", "Pluglet file (*.*)\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "PlugletEngine\0"
VALUE "LegalCopyright", "Copyright © 1999\0"
VALUE "MIMEType", "*\0"
VALUE "OriginalFilename", "nppluglet.dll\0"
VALUE "ProductName", "Pluglet Engine\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#endif // !_MAC
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -17,38 +17,26 @@
# Rights Reserved.
#
# Contributor(s):
# -*- 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) 1999 Netscape Communications Corporation. All Rights
# Reserved.
IGNORE_MANIFEST=1
#//------------------------------------------------------------------------
#//
#// Makefile to build
#//
#//------------------------------------------------------------------------
MODULE = nppluglet
LIBRARY_NAME = nppluglet
MAKE_OBJ_TYPE = DLL
DLLNAME = pluglet
DLL=.\$(OBJDIR)\$(DLLNAME).dll
MODULE = pluglet
COMPONENT = 1
DEPTH= ..\..\..\
REQUIRES = java plug xpcom raptor
REQUIRES = \
!ifndef OJI_DISABLE
oji \
!endif
java plug xpcom raptor
OBJS = \
.\$(OBJDIR)\Pluglet.obj \
@@ -76,14 +64,6 @@ MAKE_OBJ_TYPE = DLL
#// (these must be defined before the common makefiles are included)
#//
#//------------------------------------------------------------------------
DLLNAME=nppluglet
PDBFILE=nppluglet.pdb
MAPFILE=nppluglet.map
DEFFILE=PlugletEngine.def
RESFILE=PlugletEngine.res
DLL = .\$(OBJDIR)\$(DLLNAME).dll
#//------------------------------------------------------------------------
#//
#// Define any local options for the make tools
@@ -110,7 +90,7 @@ LCFLAGS=$(LCFLAGS) -DOJI_DISABLE
include <$(DEPTH)/config/rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\plugins
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components