diff --git a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/ByteRanges.java b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/ByteRanges.java index a700cb4266e..4a8930eaa6e 100644 --- a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/ByteRanges.java +++ b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/ByteRanges.java @@ -1,20 +1,20 @@ -/* - * 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. - */ -package org.mozilla.pluglet.mozilla; - -public interface ByteRanges { - public void addRange(int offset, int length); -} +/* + * 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. + */ +package org.mozilla.pluglet.mozilla; + +public interface ByteRanges { + public void addRange(int offset, int length); +} diff --git a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletInstancePeer.java b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletInstancePeer.java index 1d0839a0a08..27968d6099d 100644 --- a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletInstancePeer.java +++ b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletInstancePeer.java @@ -52,5 +52,5 @@ public interface PlugletInstancePeer { * @param height - new window height */ public void setWindowSize(int width, int height); - + public PlugletTagInfo getTagInfo(); } diff --git a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletInstancePeerImpl.java b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletInstancePeerImpl.java index 0f2c7a8f324..f1a250080c8 100644 --- a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletInstancePeerImpl.java +++ b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletInstancePeerImpl.java @@ -56,6 +56,7 @@ class PlugletInstancePeerImpl implements PlugletInstancePeer { * @param height - new window height */ public native void setWindowSize(int width, int height); + public native PlugletTagInfo getTagInfo(); private native void nativeFinalize(); private native void nativeInitialize(); }; diff --git a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletTagInfo.java b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletTagInfo.java new file mode 100644 index 00000000000..b83440c44d3 --- /dev/null +++ b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletTagInfo.java @@ -0,0 +1,22 @@ +/* + * 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. + */ +package org.mozilla.pluglet.mozilla; +import java.util.*; + +public interface PlugletTagInfo { + public Properties getAttributes(); + public String getAttribute(String name); +} diff --git a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletTagInfo2.java b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletTagInfo2.java new file mode 100644 index 00000000000..d227aba21db --- /dev/null +++ b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletTagInfo2.java @@ -0,0 +1,44 @@ +/* + * 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. + */ +package org.mozilla.pluglet.mozilla; +import java.util.*; + +public interface PlugletTagInfo2 extends PlugletTagInfo { + public Properties getAttributes(); + public String getAttribute(String name); + /* Get the type of the HTML tag that was used ot instantiate this + * pluglet. Currently supported tags are EMBED, APPLET and OBJECT. + */ + public String getTagType(); + /* Get the complete text of the HTML tag that was + * used to instantiate this pluglet + */ + public String getTagText(); + public String getDocumentBase(); + /* Return an encoding whose name is specified in: + * http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#25303 + */ + public String getDocumentEncoding(); + public String getAlignment(); + public int getWidth(); + public int getHeight(); + public int getBorderVertSpace(); + public int getBorderHorizSpace(); + /* Returns a unique id for the current document on which the + * pluglet is displayed. + */ + public int getUniqueID(); +} diff --git a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletTagInfo2Impl.java b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletTagInfo2Impl.java new file mode 100644 index 00000000000..b0bb831b763 --- /dev/null +++ b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/PlugletTagInfo2Impl.java @@ -0,0 +1,54 @@ +/* + * 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. + */ +package org.mozilla.pluglet.mozilla; +import java.util.*; + +class PlugletTagInfo2Impl implements PlugletTagInfo2 { + private long peer = 0; + private PlugletTagInfo2Impl(long _peer) { + peer = _peer; + nativeInitialize(); + } + public native Properties getAttributes(); + public native String getAttribute(String name); + /* Get the type of the HTML tag that was used ot instantiate this + * pluglet. Currently supported tags are EMBED, APPLET and OBJECT. + */ + public native String getTagType(); + /* Get the complete text of the HTML tag that was + * used to instantiate this pluglet + */ + public native String getTagText(); + public native String getDocumentBase(); + /* Return an encoding whose name is specified in: + * http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#25303 + */ + public native String getDocumentEncoding(); + public native String getAlignment(); + public native int getWidth(); + public native int getHeight(); + public native int getBorderVertSpace(); + public native int getBorderHorizSpace(); + /* Returns a unique id for the current document on which the + * pluglet is displayed. + */ + public native int getUniqueID(); + protected void finalize() { + nativeFinalize(); + } + private native void nativeFinalize(); + private native void nativeInitialize(); +} diff --git a/mozilla/java/plugins/jni/makefile.win b/mozilla/java/plugins/jni/makefile.win index f5475ec810f..2a2a0ec01d1 100644 --- a/mozilla/java/plugins/jni/makefile.win +++ b/mozilla/java/plugins/jni/makefile.win @@ -32,6 +32,8 @@ OBJS = \ .\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletOutputStream.obj \ .\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.obj \ .\$(ONJDIR)\org_mozilla_pluglet_mozilla_PlugletManagerImpl.obj \ + .\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl.obj \ + .\$(OBJDIR)\PlugletTagInfo2.obj \ .\$(OBJDIR)\PlugletOutputStream.obj \ .\$(OBJDIR)\ByteRanges.obj diff --git a/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInputStream.cpp b/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInputStream.cpp index 466cb1a7791..156ad9a923b 100644 --- a/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInputStream.cpp +++ b/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInputStream.cpp @@ -27,7 +27,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInputStream_avail nsIInputStream * input = (nsIInputStream*)env->GetLongField(jthis, peerFID);; PRUint32 res = 0; if(input) { - input->GetLength(&res); + input->Available(&res); } return (jint)res; } diff --git a/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.cpp b/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.cpp index 0b8df96276d..4f2d2b8f03a 100644 --- a/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.cpp +++ b/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.cpp @@ -15,7 +15,9 @@ */ #include "nsIPluginInstancePeer.h" +#include "nsIPluginTagInfo2.h" #include "PlugletOutputStream.h" +#include "PlugletTagInfo2.h" #include "org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.h" static jfieldID peerFID = NULL; @@ -123,6 +125,25 @@ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_ instancePeer->SetWindowSize(width,height); //nb add exception throwing } + + + +static NS_DEFINE_IID(kIPluginTagInfo2,NS_IPLUGINTAGINFO2_IID); +/* + * Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl + * Method: getTagInfo + * Signature: ()Lorg/mozilla/pluglet/mozilla/PlugletTagInfo; + */ +JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_getTagInfo + (JNIEnv *env, jobject jthis) { + nsIPluginInstancePeer * instancePeer = (nsIPluginInstancePeer*)env->GetLongField(jthis, peerFID); + nsIPluginTagInfo2 * info = NULL; + if(NS_FAILED(instancePeer->QueryInterface(kIPluginTagInfo2,(void**)&info))) { + return NULL; + } + return PlugletTagInfo2::GetJObject(env,info); +} + /* * Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl * Method: nativeFinalize diff --git a/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.h b/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.h index 9232d81e4e0..0de0d85602c 100644 --- a/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.h +++ b/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.h @@ -71,6 +71,14 @@ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_setWindowSize (JNIEnv *, jobject, jint, jint); +/* + * Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl + * Method: getTagInfo + * Signature: ()Lorg/mozilla/pluglet/mozilla/PlugletTagInfo; + */ +JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_getTagInfo + (JNIEnv *, jobject); + /* * Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl * Method: nativeFinalize diff --git a/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletManagerImpl.cpp b/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletManagerImpl.cpp index 16f901ddb03..69d837dbd4c 100644 --- a/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletManagerImpl.cpp +++ b/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletManagerImpl.cpp @@ -16,14 +16,15 @@ #include "nsIPluginManager.h" #include "org_mozilla_pluglet_mozilla_PlugletManagerImpl.h" - +static jfieldID peerFID = NULL; /* * Class: org_mozilla_pluglet_mozilla_PlugletManagerImpl * Method: getValue * Signature: (I)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_getValue - (JNIEnv *, jobject, jint) { + (JNIEnv *env, jobject jthis, jint) { + nsIPluginManager * manager = (nsIPluginManager*)env->GetLongField(jthis, peerFID); //nb return NULL; } @@ -34,7 +35,8 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_ge * Signature: (Z)V */ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_reloadPluglets - (JNIEnv *, jobject, jboolean) { + (JNIEnv *env, jobject jthis, jboolean) { + nsIPluginManager * manager = (nsIPluginManager*)env->GetLongField(jthis, peerFID); //nb } @@ -44,9 +46,9 @@ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_reloa * Signature: ()Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_userAgent - (JNIEnv *, jobject) { - //nb - return NULL; + (JNIEnv *env, jobject jthis) { + nsIPluginManager * manager = (nsIPluginManager*)env->GetLongField(jthis, peerFID); + return NULL; //nb } /* @@ -55,7 +57,8 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_us * Signature: (Lorg/mozilla/pluglet/PlugletInstance;Ljava/net/URL;Ljava/lang/String;Lorg/mozilla/pluglet/PlugletStreamListener;Ljava/lang/String;Ljava/net/URL;Z)V */ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_getURL - (JNIEnv *, jobject, jobject, jobject, jstring, jobject, jstring, jobject, jboolean) { + (JNIEnv *env, jobject jthis, jobject, jobject, jstring, jobject, jstring, jobject, jboolean) { + nsIPluginManager * manager = (nsIPluginManager*)env->GetLongField(jthis, peerFID); //nb } @@ -65,7 +68,8 @@ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_getUR * Signature: (Lorg/mozilla/pluglet/PlugletInstance;Ljava/net/URL;I[BZLjava/lang/String;Lorg/mozilla/pluglet/PlugletStreamListener;Ljava/lang/String;Ljava/net/URL;ZI[B)V */ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_postURL - (JNIEnv *, jobject, jobject, jobject, jint, jbyteArray, jboolean, jstring, jobject, jstring, jobject, jboolean, jint, jbyteArray) { + (JNIEnv *env, jobject jthis, jobject, jobject, jint, jbyteArray, jboolean, jstring, jobject, jstring, jobject, jboolean, jint, jbyteArray) { + nsIPluginManager * manager = (nsIPluginManager*)env->GetLongField(jthis, peerFID); //nb } @@ -75,8 +79,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_postU * Signature: ()V */ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_nativeFinalize - (JNIEnv *, jobject) { - //nb + (JNIEnv *env, jobject jthis) { + nsIPluginManager * manager = (nsIPluginManager*)env->GetLongField(jthis, peerFID); + if(manager) { + NS_RELEASE(manager); + } } /* @@ -85,7 +92,16 @@ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_nativ * Signature: ()V */ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_nativeInitialize - (JNIEnv *, jobject) { - //nb + (JNIEnv *env, jobject jthis) { + if(!peerFID) { + peerFID = env->GetFieldID(env->GetObjectClass(jthis),"peer","J"); + if (!peerFID) { + return; + } + } + nsIPluginManager * manager = (nsIPluginManager*)env->GetLongField(jthis, peerFID); + if (manager) { + manager->AddRef(); + } } diff --git a/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletOutputStream.cpp b/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletOutputStream.cpp index dbf8a518534..547b742c798 100644 --- a/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletOutputStream.cpp +++ b/mozilla/java/plugins/jni/org_mozilla_pluglet_mozilla_PlugletOutputStream.cpp @@ -14,7 +14,7 @@ * Inc. All Rights Reserved. */ #include "nsIOutputStream.h" -#include "org_mozilla_pluglet_mozilla_PlugletOutputstream.h" +#include "org_mozilla_pluglet_mozilla_PlugletOutputStream.h" static jfieldID peerFID = NULL; /* diff --git a/mozilla/java/plugins/src/PlugletsDir.cpp b/mozilla/java/plugins/src/PlugletsDir.cpp index 12ef791b27b..b53cd7027a0 100644 --- a/mozilla/java/plugins/src/PlugletsDir.cpp +++ b/mozilla/java/plugins/src/PlugletsDir.cpp @@ -35,7 +35,8 @@ void PlugletsDir::LoadPluglets() { char * path = PR_GetEnv("PLUGLET"); int pathLength = strlen(path); Pluglet *pluglet; - for (nsDirectoryIterator iter(nsFileSpec(path),PR_TRUE); iter.Exists(); iter++) { + nsFileSpec dir(path); + for (nsDirectoryIterator iter(dir,PR_TRUE); iter.Exists(); iter++) { const nsFileSpec& file = iter; const char* name = file.GetCString(); int length; diff --git a/mozilla/java/plugins/test/test.java b/mozilla/java/plugins/test/test.java index cc5b3116da6..3253192a41d 100644 --- a/mozilla/java/plugins/test/test.java +++ b/mozilla/java/plugins/test/test.java @@ -56,6 +56,7 @@ class TestInstance implements PlugletInstance{ public void initialize(PlugletInstancePeer peer) { org.mozilla.util.Debug.print("--TestInstance.initialize\n"); peer.showStatus("Hello world"); + org.mozilla.util.Debug.print("--TestInstance.initialize "+peer.getMIMEType()); try { OutputStreamWriter out = new OutputStreamWriter(peer.newStream("text/plain","test")); String msg = "Hello, world";