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

@@ -1,60 +1,62 @@
#
# 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.
IGNORE_MANIFEST=1
#//------------------------------------------------------------------------
#//
#// Makefile to build
#//
#//------------------------------------------------------------------------
MODULE = plugletjni
LIBRARY_NAME = plugletjni
DEPTH= ..\..\..
OBJS = \
.\$(OBJDIR)\org_mozilla_util_Debug.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=plugletjni
DLL = .\$(OBJDIR)\$(DLLNAME).dll
#//------------------------------------------------------------------------
#//
#// Define any local options for the make tools
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
#//
#//------------------------------------------------------------------------
#//------------------------------------------------------------------------
#//
#// Include the common makefile rules
#//
#//------------------------------------------------------------------------
include <$(DEPTH)/config/rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\
#
# 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.
IGNORE_MANIFEST=1
#//------------------------------------------------------------------------
#//
#// Makefile to build
#//
#//------------------------------------------------------------------------
MODULE = plugletjni
LIBRARY_NAME = plugletjni
DEPTH= ..\..\..
OBJS = \
.\$(OBJDIR)\org_mozilla_util_Debug.obj \
.\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl.obj \
.\$(OBJDIR)\org_mozilla_pluglet_mozilla_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=plugletjni
DLL = .\$(OBJDIR)\$(DLLNAME).dll
#//------------------------------------------------------------------------
#//
#// Define any local options for the make tools
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
#//
#//------------------------------------------------------------------------
#//------------------------------------------------------------------------
#//
#// Include the common makefile rules
#//
#//------------------------------------------------------------------------
include <$(DEPTH)/config/rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\

View File

@@ -0,0 +1,110 @@
/*
* 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 "nsIInputStream.h"
#include "org_mozilla_pluglet_mozilla_PlugletInputStream.h"
static jfieldID peerFID = NULL;
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInputStream
* Method: available
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInputStream_available
(JNIEnv *env, jobject jthis) {
nsIInputStream * input = (nsIInputStream*)env->GetLongField(jthis, peerFID);;
PRUint32 res = 0;
if(input) {
input->GetLength(&res);
}
return (jint)res;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInputStream
* Method: close
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInputStream_close
(JNIEnv *env, jobject jthis) {
nsIInputStream * input = (nsIInputStream*)env->GetLongField(jthis, peerFID);
if (input) {
NS_RELEASE(input);
env->SetLongField(jthis, peerFID,0);
}
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInputStream
* Method: read
* Signature: ([BI)I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInputStream_read
(JNIEnv *env, jobject jthis, jbyteArray b, jint len) {
PRUint32 retval = 0;
nsIInputStream * input = (nsIInputStream*)env->GetLongField(jthis, peerFID);
if (env->ExceptionOccurred()) {
return retval;
}
jbyte * bufElems = env->GetByteArrayElements(b,NULL);
if (env->ExceptionOccurred()) {
return retval;
}
nsresult res;
res = input->Read((char*)bufElems,(PRUint32)len,&retval);
if (NS_FAILED(res)) {
return retval;
}
env->ReleaseByteArrayElements(b,bufElems,0);
return retval;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInputStream
* Method: nativeFinalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInputStream_nativeFinalize
(JNIEnv *env, jobject jthis) {
/* nb do as in java-dom stuff */
nsIInputStream * input = (nsIInputStream*)env->GetLongField(jthis, peerFID);
if(input) {
NS_RELEASE(input);
}
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInputStream
* Method: nativeInitialize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInputStream_nativeInitialize
(JNIEnv *env, jobject jthis) {
if(!peerFID) {
peerFID = env->GetFieldID(env->GetObjectClass(jthis),"peer","J");
if (!peerFID) {
return;
}
}
if (env->ExceptionOccurred()) {
return;
}
nsIInputStream * input = (nsIInputStream*)env->GetLongField(jthis, peerFID);
if (input) {
input->AddRef();
}
}

View File

@@ -0,0 +1,71 @@
/*
* 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.
*/
/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class org_mozilla_pluglet_mozilla_PlugletInputStream */
#ifndef _Included_org_mozilla_pluglet_mozilla_PlugletInputStream
#define _Included_org_mozilla_pluglet_mozilla_PlugletInputStream
#ifdef __cplusplus
extern "C" {
#endif
#undef org_mozilla_pluglet_mozilla_PlugletInputStream_SKIP_BUFFER_SIZE
#define org_mozilla_pluglet_mozilla_PlugletInputStream_SKIP_BUFFER_SIZE 2048L
/* Inaccessible static: skipBuffer */
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInputStream
* Method: available
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInputStream_available
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInputStream
* Method: close
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInputStream_close
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInputStream
* Method: read
* Signature: ([BI)I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInputStream_read
(JNIEnv *, jobject, jbyteArray, jint);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInputStream
* Method: nativeFinalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInputStream_nativeFinalize
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInputStream
* Method: nativeInitialize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInputStream_nativeInitialize
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,156 @@
/*
* 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 "nsIPluginStreamInfo.h"
#include "org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl.h"
static jfieldID peerFID = NULL;
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: getContentType
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_getContentType
(JNIEnv *env, jobject jthis) {
nsIPluginStreamInfo * streamInfo = (nsIPluginStreamInfo*)env->GetLongField(jthis, peerFID);
if (env->ExceptionOccurred()) {
return NULL;
}
nsMIMEType mimeType;
if(NS_FAILED(streamInfo->GetContentType(&mimeType)) /* nb do we need to free this memory? */
|| !mimeType) {
return NULL;
} else {
return env->NewStringUTF((char *)mimeType);
}
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: isSeekable
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_isSeekable
(JNIEnv *env, jobject jthis) {
nsIPluginStreamInfo * streamInfo = (nsIPluginStreamInfo*)env->GetLongField(jthis, peerFID);;
if (env->ExceptionOccurred()) {
return JNI_FALSE; // it does not matter
}
PRBool res;
streamInfo->IsSeekable(&res);
if (res == PR_TRUE) {
return JNI_TRUE;
} else {
return JNI_FALSE;
}
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: getLength
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_getLength
(JNIEnv *env, jobject jthis) {
nsIPluginStreamInfo * streamInfo = (nsIPluginStreamInfo*)env->GetLongField(jthis, peerFID);
if (env->ExceptionOccurred()) {
return 0; // it does not matter
}
PRUint32 length;
nsresult rv = streamInfo->GetLength(&length);
if (NS_FAILED(rv)) {
return -1;
}
return length;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: getLastModified
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_getLastModified
(JNIEnv *env, jobject jthis) {
nsIPluginStreamInfo * streamInfo = (nsIPluginStreamInfo*)env->GetLongField(jthis, peerFID);;
if (env->ExceptionOccurred()) {
return 0; // it does not matter
}
PRUint32 res = 0;
streamInfo->GetLastModified(&res);
return res;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: getURL
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_getURL
(JNIEnv *env, jobject jthis) {
nsIPluginStreamInfo * streamInfo = (nsIPluginStreamInfo*)env->GetLongField(jthis, peerFID);
if (env->ExceptionOccurred()) {
return 0; // it does not matter
}
const char *res = NULL;
streamInfo->GetURL(&res); /* do we need to free this memory */
return (res)? env->NewStringUTF(res) : NULL;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: requestRead
* Signature: (Lorg/mozilla/pluglet/mozilla/ByteRanges;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_requestRead
(JNIEnv *, jobject, jobject) {
/* nb let's do it */
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: nativeFinalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_nativeFinalize
(JNIEnv *env, jobject jthis) {
/* nb do as in java-dom stuff */
nsIPluginStreamInfo * streamInfo = (nsIPluginStreamInfo*)env->GetLongField(jthis, peerFID);
if (streamInfo) {
NS_RELEASE(streamInfo);
}
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: nativeInitialize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_nativeInitialize
(JNIEnv *env, jobject jthis) {
if(!peerFID) {
peerFID = env->GetFieldID(env->GetObjectClass(jthis),"peer","J");
if (!peerFID) {
return;
}
}
nsIPluginStreamInfo * streamInfo = (nsIPluginStreamInfo*)env->GetLongField(jthis, peerFID);;
if (streamInfo) {
streamInfo->AddRef();
}
}

View File

@@ -0,0 +1,92 @@
/*
* 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.
*/
/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl */
#ifndef _Included_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
#define _Included_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: getContentType
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_getContentType
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: isSeekable
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_isSeekable
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: getLength
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_getLength
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: getLastModified
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_getLastModified
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: getURL
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_getURL
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: requestRead
* Signature: (Lorg/mozilla/pluglet/mozilla/ByteRanges;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_requestRead
(JNIEnv *, jobject, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: nativeFinalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_nativeFinalize
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl
* Method: nativeInitialize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl_nativeInitialize
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif