Added PlugletTagInfo

Updated test.java
Fixed some build problems


git-svn-id: svn://10.0.0.236/trunk@46992 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
idk%eng.sun.com
1999-09-11 23:47:47 +00:00
parent 1335664f7f
commit 58c108ead3
14 changed files with 206 additions and 36 deletions

View File

@@ -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);
}

View File

@@ -52,5 +52,5 @@ public interface PlugletInstancePeer {
* @param height - new window height
*/
public void setWindowSize(int width, int height);
public PlugletTagInfo getTagInfo();
}

View File

@@ -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();
};

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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

View File

@@ -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();
}
}

View File

@@ -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;
/*

View File

@@ -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;

View File

@@ -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";