Add implemenataion of PlugletInputStream and PlugletStreamInfo

git-svn-id: svn://10.0.0.236/trunk@45633 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
idk%eng.sun.com
1999-09-02 03:36:53 +00:00
parent 068888ad32
commit fae3440cff
15 changed files with 918 additions and 166 deletions

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 "PlugletInputStream.h"
#include "PlugletEngine.h"
jclass PlugletInputStream::clazz = NULL;
jmethodID PlugletInputStream::initMID = NULL;
void PlugletInputStream::Initialize(void) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
clazz = env->FindClass("org/mozilla/pluglet/mozilla/PlugletInputStream");
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 PlugletInputStream::Destroy(void) {
//nb who gonna cal it?
JNIEnv * env = PlugletEngine::GetJNIEnv();
if(clazz) {
env->DeleteGlobalRef(clazz);
}
}
jobject PlugletInputStream::GetJObject(const nsIInputStream *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 __PlugletInputStream_h__
#define __PlugletInputStream_h__
#include "jni.h"
#include "nsIInputStream.h"
class PlugletInputStream {
public:
static jobject GetJObject(const nsIInputStream *stream);
private:
static void Initialize(void);
static void Destroy(void);
static jclass clazz;
static jmethodID initMID;
};
#endif /* __PlugletInputStream_h__ */

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 "PlugletStreamInfo.h"
#include "PlugletEngine.h"
jclass PlugletStreamInfo::clazz = NULL;
jmethodID PlugletStreamInfo::initMID = NULL;
void PlugletStreamInfo::Initialize(void) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
clazz = env->FindClass("org/mozilla/pluglet/mozilla/PlugletStreamInfoImpl");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
clazz = NULL;
return;
}
clazz = (jclass) env->NewGlobalRef(clazz);
initMID = env->GetMethodID(clazz,"<init>","(J)V");
if (!initMID) {
env->ExceptionDescribe();
clazz = NULL;
return;
}
}
void PlugletStreamInfo::Destroy(void) {
//nb who gonna call it
JNIEnv * env = PlugletEngine::GetJNIEnv();
if (clazz) {
env->DeleteGlobalRef(clazz);
}
}
jobject PlugletStreamInfo::GetJObject(const nsIPluginStreamInfo *streamInfo) {
jobject res = NULL;
JNIEnv *env = PlugletEngine::GetJNIEnv();
if(!clazz) {
Initialize();
if (! clazz) {
return NULL;
}
}
res = env->NewObject(clazz,initMID,*(jlong*)(void*)&streamInfo);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
res = NULL;
}
return res;
}

View File

@@ -0,0 +1,31 @@
/*
* 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 __PlugletStreamInfo_h__
#define __PlugletStreamInfo_h__
#include "nsIPluginStreamInfo.h"
#include "jni.h"
class PlugletStreamInfo {
public:
static jobject GetJObject(const nsIPluginStreamInfo *streamInfo);
private:
static void Initialize(void);
static void Destroy(void);
static jclass clazz;
static jmethodID initMID;
};
#endif /* __PlugletStreamInfo_h__ */

View File

@@ -15,8 +15,8 @@
*/
#include "PlugletStreamListener.h"
#include "PlugletEngine.h"
#include "PlugletStreamInfo.h"
#include "PlugletInputStream.h"
jmethodID PlugletStreamListener::onStartBindingMID = NULL;
jmethodID PlugletStreamListener::onDataAvailableMID = NULL;
@@ -48,32 +48,53 @@ PlugletStreamListener::~PlugletStreamListener(void) {
NS_METHOD PlugletStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
//nb env->CallVoidMethod(jthis,onStartBindingMID,NewPluginStreamInfo(Plugin::env,pluginInfo));
env->CallVoidMethod(jthis,onStartBindingMID,PlugletStreamInfo::GetJObject(pluginInfo));
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_METHOD PlugletStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
//nb env->CallVoidMethod(jthis,onDataAvailableMID,NewPluginStreamInfo(Plugin::env,pluginInfo),
// NewInputStream(Plugin::env,input),(jint)length);
env->CallVoidMethod(jthis,onDataAvailableMID,PlugletStreamInfo::GetJObject(pluginInfo),
PlugletInputStream::GetJObject(input),(jint)length);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_METHOD PlugletStreamListener::OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
//nb Plugin::env->CallVoidMethod(jthis,onFileAvailableMID,NewPluginStreamInfo(Plugin::env,pluginInfo),
// Plugin::env->NewStringUTF(fileName));
env->CallVoidMethod(jthis,onFileAvailableMID,PlugletStreamInfo::GetJObject(pluginInfo),
env->NewStringUTF(fileName));
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_METHOD PlugletStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
//nb env->CallVoidMethod(jthis,onStopBindingMID,NewPluginStreamInfo(Plugin::env,pluginInfo),status);
env->CallVoidMethod(jthis,onStopBindingMID,PlugletStreamInfo::GetJObject(pluginInfo),status);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_METHOD PlugletStreamListener::GetStreamType(nsPluginStreamType *result) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
*result = (nsPluginStreamType)env->CallIntMethod(jthis,getStreamTypeMID);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
return NS_OK;
}

View File

@@ -1,91 +1,93 @@
#
# 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
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)\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