Add this files

git-svn-id: svn://10.0.0.236/trunk@46266 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
idk%eng.sun.com
1999-09-08 00:21:03 +00:00
parent f8078c4c9a
commit f363d1453d
31 changed files with 1548 additions and 196 deletions

View File

@@ -17,6 +17,7 @@
#include "Pluglet.h"
#include "nsIServiceManager.h"
#include "prenv.h"
#include "PlugletManager.h"
static NS_DEFINE_IID(kIPluginIID,NS_IPLUGIN_IID);
static NS_DEFINE_CID(kPluginCID,NS_PLUGIN_CID);
@@ -25,6 +26,11 @@ static NS_DEFINE_IID(kIJVMManagerIID,NS_IJVMMANAGER_IID);
static NS_DEFINE_CID(kJVMManagerCID,NS_JVMMANAGER_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 PLUGIN_MIME_DESCRIPTION "*:*:Pluglet Engine"
@@ -33,6 +39,9 @@ int PlugletEngine::objectCount = 0;
PlugletsDir * PlugletEngine::dir = NULL;
PRInt32 PlugletEngine::lockCount = 0;
PlugletEngine * PlugletEngine::engine = NULL;
nsIPluginManager *PlugletEngine::pluginManager = NULL;
jobject PlugletEngine::plugletManager = NULL;
NS_IMPL_ISUPPORTS(PlugletEngine,kIPluginIID);
NS_METHOD PlugletEngine::Initialize(void) {
//nb ???
@@ -90,20 +99,21 @@ PlugletEngine::PlugletEngine(nsISupports* aService) {
NS_INIT_REFCNT();
dir = new PlugletsDir();
nsresult res = NS_OK;
#if 0
nsIServiceManager *sm;
res = aService->QueryInterface(nsIServiceManager::GetIID(),(void**)&sm);
if (NS_FAILED(res)) {
jvmManager = NULL;
return;
}
res = sm->GetService(kPluginManagerCID,kIPluginManagerIID,(nsISupports**)&pluginManager);
#if 0
res = sm->GetService(kJVMManagerCID,kIJVMManagerIID,(nsISupports**)&jvmManager);
//nb
if (NS_FAILED(res)) {
jvmManager = NULL;
}
NS_RELEASE(sm);
#endif
NS_RELEASE(sm);
engine = this;
objectCount++;
}
@@ -128,8 +138,6 @@ static void StartJVM() {
vm_args.version = 0x00010001;
JNI_GetDefaultJavaVMInitArgs(&vm_args);
/* Append USER_CLASSPATH to the default system class path */
//nb todo urgent
sprintf(classpath, "%s%c%s",
vm_args.classpath, PATH_SEPARATOR, PR_GetEnv("CLASSPATH"));
printf("-- classpath %s\n",classpath);
@@ -159,8 +167,10 @@ JNIEnv * PlugletEngine::GetJNIEnv(void) {
}
jobject PlugletEngine::GetPlugletManager(void) {
//nb todo urgent
return NULL;
if (!plugletManager) {
plugletManager = PlugletManager::GetJObject(pluginManager);
}
return plugletManager;
}
PlugletEngine * PlugletEngine::GetEngine(void) {

View File

@@ -18,6 +18,7 @@
#include "nsplugin.h"
#include "jni.h"
#include "nsJVMManager.h"
#include "nsIPluginManager.h"
#include "PlugletsDir.h"
class PlugletEngine : public nsIPlugin {
@@ -46,6 +47,8 @@ class PlugletEngine : public nsIPlugin {
static PlugletsDir *dir;
static PlugletEngine * engine;
//nb static nsJVMManager * jvmManager;
static nsIPluginManager *pluginManager;
static jobject plugletManager;
};
#endif /* __PlugletEngine_h__ */

View File

@@ -15,8 +15,8 @@
*/
#ifndef __PlugletInputStream_h__
#define __PlugletInputStream_h__
#include "jni.h"
#include "nsIInputStream.h"
#include "jni.h"
class PlugletInputStream {
public:

View File

@@ -16,6 +16,7 @@
#include "PlugletInstance.h"
#include "PlugletEngine.h"
#include "PlugletStreamListener.h"
#include "PlugletInstancePeer.h"
jmethodID PlugletInstance::initializeMID = NULL;
jmethodID PlugletInstance::startMID = NULL;
@@ -38,6 +39,7 @@ PlugletInstance::PlugletInstance(jobject object) {
PlugletInstance::~PlugletInstance() {
PlugletEngine::GetJNIEnv()->DeleteGlobalRef(jthis);
NS_RELEASE(peer);
}
NS_METHOD PlugletInstance::HandleEvent(nsPluginEvent* event, PRBool* handled) {
@@ -46,9 +48,9 @@ NS_METHOD PlugletInstance::HandleEvent(nsPluginEvent* event, PRBool* handled) {
}
NS_METHOD PlugletInstance::Initialize(nsIPluginInstancePeer* _peer) {
JNIEnv *env = PlugletEngine::GetJNIEnv();
if (!printMID) {
//nb check for null after each and every JNI call
JNIEnv *env = PlugletEngine::GetJNIEnv();
jclass clazz = env->FindClass("org/mozilla/pluglet/PlugletInstance");
initializeMID = env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletInstancePeer;)V");
startMID = env->GetMethodID(clazz,"start","()V");
@@ -60,7 +62,11 @@ NS_METHOD PlugletInstance::Initialize(nsIPluginInstancePeer* _peer) {
}
peer = _peer;
peer->AddRef();
//nb call java
jobject obj = PlugletInstancePeer::GetJObject(peer);
if (!obj) {
return NS_ERROR_FAILURE;
}
env->CallVoidMethod(jthis,initializeMID,obj);
return NS_OK;
}

View File

@@ -0,0 +1,64 @@
/*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (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/MPL/
*
* 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 Initial Developer of the Original Code is Sun Microsystems,
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*/
#include "nsISupports.h"
#include "PlugletInstancePeer.h"
#include "PlugletEngine.h"
jclass PlugletInstancePeer::clazz = NULL;
jmethodID PlugletInstancePeer::initMID = NULL;
void PlugletInstancePeer::Initialize(void) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
clazz = env->FindClass("org/mozilla/pluglet/mozilla/PlugletInstancePeerImpl");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
clazz = NULL;
return;
}
clazz = (jclass) env->NewGlobalRef(clazz);
initMID = env->GetMethodID(clazz,"<init>","(J)V");
if (env->ExceptionOccurred()
|| !initMID) {
env->ExceptionDescribe();
clazz = NULL;
return;
}
}
void PlugletInstancePeer::Destroy(void) {
//nb who gonna cal it?
JNIEnv * env = PlugletEngine::GetJNIEnv();
if(clazz) {
env->DeleteGlobalRef(clazz);
}
}
jobject PlugletInstancePeer::GetJObject(const nsIPluginInstancePeer *stream) {
jobject res = NULL;
JNIEnv *env = PlugletEngine::GetJNIEnv();
if(!clazz) {
Initialize();
if (! clazz) {
return NULL;
}
}
res = env->NewObject(clazz,initMID,(jlong)stream);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
res = NULL;
}
return res;
}

View File

@@ -0,0 +1,30 @@
/*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (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/MPL/
*
* 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 Initial Developer of the Original Code is Sun Microsystems,
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*/
#ifndef __PlugletInstancePeer_h__
#define __PlugletInstancePeer_h__
#include "nsIPluginInstancePeer.h"
#include "jni.h"
class PlugletInstancePeer {
public:
static jobject GetJObject(const nsIPluginInstancePeer *instancePeer);
private:
static void Initialize(void);
static void Destroy(void);
static jclass clazz;
static jmethodID initMID;
};
#endif /* __PlugletInputStream_h__ */

View File

@@ -0,0 +1,63 @@
/*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (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/MPL/
*
* 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 Initial Developer of the Original Code is Sun Microsystems,
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*/
#include "PlugletManager.h"
#include "PlugletEngine.h"
jclass PlugletManager::clazz = NULL;
jmethodID PlugletManager::initMID = NULL;
void PlugletManager::Initialize(void) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
clazz = env->FindClass("org/mozilla/pluglet/mozilla/PlugletManagerImpl");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
clazz = NULL;
return;
}
clazz = (jclass) env->NewGlobalRef(clazz);
initMID = env->GetMethodID(clazz,"<init>","(J)V");
if (env->ExceptionOccurred()
|| !initMID) {
env->ExceptionDescribe();
clazz = NULL;
return;
}
}
void PlugletManager::Destroy(void) {
//nb who gonna cal it?
JNIEnv * env = PlugletEngine::GetJNIEnv();
if(clazz) {
env->DeleteGlobalRef(clazz);
}
}
jobject PlugletManager::GetJObject(const nsIPluginManager *stream) {
jobject res = NULL;
JNIEnv *env = PlugletEngine::GetJNIEnv();
if(!clazz) {
Initialize();
if (! clazz) {
return NULL;
}
}
res = env->NewObject(clazz,initMID,(jlong)stream);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
res = NULL;
}
return res;
}

View File

@@ -0,0 +1,30 @@
/*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (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/MPL/
*
* 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 Initial Developer of the Original Code is Sun Microsystems,
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*/
#ifndef __PlugletManager_h__
#define __PlugletManager_h__
#include "nsIPluginManager.h"
#include "jni.h"
class PlugletManager {
public:
static jobject GetJObject(const nsIPluginManager *instancePeer);
private:
static void Initialize(void);
static void Destroy(void);
static jclass clazz;
static jmethodID initMID;
};
#endif /* __PlugletManager_h__ */

View File

@@ -37,7 +37,7 @@ void PlugletStreamInfo::Initialize(void) {
}
void PlugletStreamInfo::Destroy(void) {
//nb who gonna call it
//nb who gonna call it?
JNIEnv * env = PlugletEngine::GetJNIEnv();
if (clazz) {
env->DeleteGlobalRef(clazz);

View File

@@ -1,93 +1,95 @@
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.0 (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/MPL/
#
# 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 Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
# Inc. All Rights Reserved.
# -*- 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
DEPTH= ..\..\..\
REQUIRES = java plug xpcom raptor oji
OBJS = \
.\$(OBJDIR)\Pluglet.obj \
.\$(OBJDIR)\PlugletEngine.obj \
.\$(OBJDIR)\PlugletList.obj \
.\$(OBJDIR)\PlugletLoader.obj \
.\$(OBJDIR)\PlugletsDir.obj \
.\$(OBJDIR)\PlugletInstance.obj \
.\$(OBJDIR)\PlugletStreamListener.obj \
.\$(OBJDIR)\PlugletStreamInfo.obj \
.\$(OBJDIR)\PlugletInputStream.obj
MAKE_OBJ_TYPE = DLL
#//------------------------------------------------------------------------
#//
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, 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
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
#//
#//------------------------------------------------------------------------
LLIBS=$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib $(DIST)\lib\oji.lib $(JDKHOME)\lib\jvm.lib
#//------------------------------------------------------------------------
#//
#// Include the common makefile rules
#//
#//------------------------------------------------------------------------
include <$(DEPTH)/config/rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\plugins
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.0 (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/MPL/
#
# 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 Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
# Inc. All Rights Reserved.
# -*- 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
DEPTH= ..\..\..\
REQUIRES = java plug xpcom raptor oji
OBJS = \
.\$(OBJDIR)\Pluglet.obj \
.\$(OBJDIR)\PlugletEngine.obj \
.\$(OBJDIR)\PlugletList.obj \
.\$(OBJDIR)\PlugletLoader.obj \
.\$(OBJDIR)\PlugletsDir.obj \
.\$(OBJDIR)\PlugletInstance.obj \
.\$(OBJDIR)\PlugletStreamListener.obj \
.\$(OBJDIR)\PlugletStreamInfo.obj \
.\$(OBJDIR)\PlugletInstancePeer.obj \
.\$(OBJDIR)\PlugletManager.obj \
.\$(OBJDIR)\PlugletInputStream.obj
MAKE_OBJ_TYPE = DLL
#//------------------------------------------------------------------------
#//
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, 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
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
#//
#//------------------------------------------------------------------------
LLIBS=$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib $(DIST)\lib\oji.lib $(JDKHOME)\lib\jvm.lib
#//------------------------------------------------------------------------
#//
#// Include the common makefile rules
#//
#//------------------------------------------------------------------------
include <$(DEPTH)/config/rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\plugins