Moved to OJI.

Added  AWT support.
Added some classes


git-svn-id: svn://10.0.0.236/trunk@47982 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
idk%eng.sun.com
1999-09-17 18:41:34 +00:00
parent 0da3025819
commit c3a4459049
27 changed files with 819 additions and 140 deletions

View File

@@ -21,7 +21,7 @@ Requirements:
* built M8 mozilla tree for WinNT4.0
* JDK1.2 or greater
* JDK1.3
* Perl 5 perl.exe must be in your path
@@ -40,11 +40,14 @@ How To Build:
How to Run:
* Add following directories to to your path:
%MOZILLA_FIVE_HOME%, %JDKHOME%\jre\bin\classic
%MOZILLA_FIVE_HOME%
How to build and run test
* go to the test directory and type "nmake /f makefile.win"
* add context of java.zip to JRE\1.3\lib\rt.jar (this is a hack. It would be
removed soon)
* Set PLUGLET environment to the directory you have test.jar
* Run appletviewer and load page test.html from test directory and if evething is ok you will see

View File

@@ -15,7 +15,7 @@
*/
package org.mozilla.pluglet;
import org.mozilla.pluglet.mozilla.*;
import java.awt.Panel;
import java.awt.Frame;
import java.awt.print.PrinterJob;
public interface PlugletInstance {
@@ -59,7 +59,7 @@ public interface PlugletInstance {
*
* @param frame the pluglet panel
*/
void setWindow(Panel frame);
void setWindow(Frame frame);
/**
* Called to instruct the pluglet instance to print itself to a printer.
*

View File

@@ -20,15 +20,16 @@ import java.net.URL;
import java.util.jar.Manifest;
import java.util.jar.Attributes;
import java.io.InputStream;
import org.mozilla.pluglet.mozilla.*;
public class PlugletLoader {
// path to jar file. Name of main class sould to be in MANIFEST.
public static Pluglet getPluglet(String path) {
try {
org.mozilla.util.Debug.print("-- PlugletLoader.getPluglet("+path+")\n");
URL url = new URL("file://"+path);
URL url = new URL("file:/"+path);
URLClassLoader loader = URLClassLoader.newInstance(new URL[]{url});
URL manifestURL = new URL("jar:file://"+path+"!/META-INF/MANIFEST.MF");
URL manifestURL = new URL("jar:file:/"+path+"!/META-INF/MANIFEST.MF");
InputStream inputStream = manifestURL.openStream();
Manifest manifest = new Manifest(inputStream);
Attributes attr = manifest.getMainAttributes();
@@ -47,6 +48,7 @@ public class PlugletLoader {
}
} catch (Exception e) {
org.mozilla.util.Debug.print("-- PlugletLoader.getPluglet exc "+e);
e.printStackTrace();
return null;
}
}
@@ -54,7 +56,7 @@ public class PlugletLoader {
public static String getMIMEDescription(String path) {
try {
org.mozilla.util.Debug.print("-- PlugletLoader.getMIMEDescription("+path+")\n");
URL manifestURL = new URL("jar:file://"+path+"!/META-INF/MANIFEST.MF");
URL manifestURL = new URL("jar:file:/"+path+"!/META-INF/MANIFEST.MF");
InputStream inputStream = manifestURL.openStream();
Manifest manifest = new Manifest(inputStream);
Attributes attr = manifest.getMainAttributes();
@@ -63,6 +65,7 @@ public class PlugletLoader {
return mimeDescription;
} catch (Exception e) {
org.mozilla.util.Debug.print(e+"\n");
e.printStackTrace();
return null;
}
}

View File

@@ -17,11 +17,11 @@ package org.mozilla.pluglet.mozilla;
import java.io.*;
class PlugletInputStream extends InputStream {
public class PlugletInputStream extends InputStream {
private long peer;
private byte buf[] = new byte[1];
private PlugletInputStream(long peer) {
public PlugletInputStream(long peer) {
this.peer = peer;
nativeInitialize();
}

View File

@@ -17,9 +17,9 @@ package org.mozilla.pluglet.mozilla;
import java.io.OutputStream;
class PlugletInstancePeerImpl implements PlugletInstancePeer {
public class PlugletInstancePeerImpl implements PlugletInstancePeer {
private long peer = 0;
private PlugletInstancePeerImpl(long peer) {
public PlugletInstancePeerImpl(long peer) {
this.peer = peer;
nativeInitialize();
}

View File

@@ -16,9 +16,9 @@
package org.mozilla.pluglet.mozilla;
import org.mozilla.pluglet.*;
import java.net.URL;
class PlugletManagerImpl implements PlugletManager {
public class PlugletManagerImpl implements PlugletManager {
private long peer = 0;
private PlugletManagerImpl(long _peer) {
public PlugletManagerImpl(long _peer) {
peer = _peer;
nativeInitialize();
}

View File

@@ -19,7 +19,7 @@ import java.io.*;
class PlugletOutputStream extends OutputStream {
private long peer;
private byte buf[] = new byte[1];
private PlugletOutputStream(long peer) {
public PlugletOutputStream(long peer) {
this.peer = peer;
nativeInitialize();
}

View File

@@ -15,8 +15,8 @@
*/
package org.mozilla.pluglet.mozilla;
class PlugletStreamInfoImpl implements PlugletStreamInfo {
private PlugletStreamInfoImpl(long peer) {
public class PlugletStreamInfoImpl implements PlugletStreamInfo {
public PlugletStreamInfoImpl(long peer) {
this.peer = peer;
nativeInitialize();
}

View File

@@ -16,9 +16,9 @@
package org.mozilla.pluglet.mozilla;
import java.util.*;
class PlugletTagInfo2Impl implements PlugletTagInfo2 {
public class PlugletTagInfo2Impl implements PlugletTagInfo2 {
private long peer = 0;
private PlugletTagInfo2Impl(long _peer) {
public PlugletTagInfo2Impl(long _peer) {
peer = _peer;
nativeInitialize();
}

Binary file not shown.

View File

@@ -0,0 +1,73 @@
/*
* 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 "PlugletTagInfo2.h"
jclass PlugletTagInfo2::clazz = NULL;
jmethodID PlugletTagInfo2::initMID = NULL;
void PlugletTagInfo2::Initialize(JNIEnv *env) {
clazz = env->FindClass("org/mozilla/pluglet/mozilla/PlugletTagInfo2Impl");
if (!clazz) {
env->ExceptionDescribe();
return;
}
clazz = (jclass) env->NewGlobalRef(clazz);
initMID = env->GetMethodID(clazz,"<init>","(J)V");
if (!initMID) {
env->ExceptionDescribe();
clazz = NULL;
return;
}
}
void PlugletTagInfo2::Destroy(JNIEnv *env) {
//nb who gonna cal it?
if(clazz) {
env->DeleteGlobalRef(clazz);
}
}
jobject PlugletTagInfo2::GetJObject(JNIEnv *env, const nsIPluginTagInfo2 *info) {
jobject res = NULL;
if(!clazz) {
Initialize(env);
if (! clazz) {
return NULL;
}
}
res = env->NewObject(clazz,initMID,(jlong)info);
if (!res) {
env->ExceptionDescribe();
}
return res;
}

View File

@@ -13,9 +13,20 @@
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*/
#ifndef __PlugletView_h__
#define __PlugletView_h__
class PlugletView {
//nb
#ifndef __PlugletTagInfo2_h__
#define __PlugletTagInfo2_h__
#include "nsIPluginTagInfo2.h"
#include "jni.h"
class PlugletTagInfo2 {
public:
static jobject GetJObject(JNIEnv* env,const nsIPluginTagInfo2 *info);
private:
static void Initialize(JNIEnv* env);
static void Destroy(JNIEnv *env);
static jclass clazz;
static jmethodID initMID;
};
#endif /* __PlugletView_h__ */
#endif /* __PlugletTagInfo2__h__ */

View File

@@ -31,7 +31,7 @@ OBJS = \
.\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletInputStream.obj \
.\$(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_PlugletManagerImpl.obj \
.\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl.obj \
.\$(OBJDIR)\PlugletTagInfo2.obj \
.\$(OBJDIR)\PlugletOutputStream.obj \

View File

@@ -0,0 +1,250 @@
/*
* 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 "nsIPluginTagInfo2.h"
#include "org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl.h"
static jfieldID peerFID = NULL;
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getAttributes
* Signature: ()Ljava/util/Properties;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAttributes
(JNIEnv *, jobject) {
//nb Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAttributes
return NULL;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getAttribute
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAttribute
(JNIEnv *env, jobject jthis, jstring _name) {
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
const char * name = NULL;
if (!(name = env->GetStringUTFChars(_name,NULL))) {
return NULL;
}
const char * result = NULL;
if (NS_FAILED(info->GetParameter(name,&result))) {
env->ReleaseStringUTFChars(_name,name);
return NULL;
}
env->ReleaseStringUTFChars(_name,name);
return env->NewStringUTF(result);
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getTagType
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getTagType
(JNIEnv *env, jobject jthis) {
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
const char * res = "Unknown";
nsPluginTagType type;
if (NS_FAILED(info->GetTagType(&type))) {
return env->NewStringUTF(res);
}
switch (type) {
case nsPluginTagType_Embed:
res = "EMBED";
break;
case nsPluginTagType_Object:
res = "OBJECT";
break;
case nsPluginTagType_Applet:
res = "APPLET";
break;
default:
res = "UNKNOWN";
break;
}
return env->NewStringUTF(res);
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getTagText
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getTagText
(JNIEnv *env, jobject jthis) {
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
const char *text = NULL;
if(NS_FAILED(info->GetTagText(&text))) {
return NULL;
}
return env->NewStringUTF(text);
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getDocumentBase
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getDocumentBase
(JNIEnv *env, jobject jthis) {
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
const char *base = NULL;
if(NS_FAILED(info->GetDocumentBase(&base))) {
return NULL;
}
return env->NewStringUTF(base);
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getDocumentEncoding
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getDocumentEncoding
(JNIEnv *env, jobject jthis) {
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
const char *encoding = NULL;
if(NS_FAILED(info->GetDocumentEncoding(&encoding))) {
return NULL;
}
return env->NewStringUTF(encoding);
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getAlignment
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAlignment
(JNIEnv *env, jobject jthis) {
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
const char *aligment = NULL;
if(NS_FAILED(info->GetAlignment(&aligment))) {
return NULL;
}
return env->NewStringUTF(aligment);
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getWidth
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getWidth
(JNIEnv *env, jobject jthis) {
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
PRUint32 res;
if(NS_FAILED(info->GetWidth(&res))) {
return 0;
}
return res;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getHeight
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getHeight
(JNIEnv *env, jobject jthis) {
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
PRUint32 res;
if(NS_FAILED(info->GetHeight(&res))) {
return 0;
}
return res;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getBorderVertSpace
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getBorderVertSpace
(JNIEnv *env, jobject jthis) {
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
PRUint32 res;
if(NS_FAILED(info->GetBorderVertSpace(&res))) {
return 0;
}
return res;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getBorderHorizSpace
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getBorderHorizSpace
(JNIEnv *env, jobject jthis) {
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
PRUint32 res;
if(NS_FAILED(info->GetBorderHorizSpace(&res))) {
return 0;
}
return res;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getUniqueID
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getUniqueID
(JNIEnv *env, jobject jthis) {
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
PRUint32 res;
if(NS_FAILED(info->GetUniqueID(&res))) {
return 0;
}
return res;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: nativeFinalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_nativeFinalize
(JNIEnv *env, jobject jthis) {
/* nb do as in java-dom stuff */
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
if(info) {
NS_RELEASE(info);
}
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: nativeInitialize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_nativeInitialize
(JNIEnv *env, jobject jthis) {
if(!peerFID) {
peerFID = env->GetFieldID(env->GetObjectClass(jthis),"peer","J");
if (!peerFID) {
return;
}
}
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
if (info) {
info->AddRef();
}
}

View File

@@ -0,0 +1,140 @@
/*
* 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_PlugletTagInfo2Impl */
#ifndef _Included_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
#define _Included_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getAttributes
* Signature: ()Ljava/util/Properties;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAttributes
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getAttribute
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAttribute
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getTagType
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getTagType
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getTagText
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getTagText
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getDocumentBase
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getDocumentBase
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getDocumentEncoding
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getDocumentEncoding
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getAlignment
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAlignment
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getWidth
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getWidth
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getHeight
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getHeight
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getBorderVertSpace
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getBorderVertSpace
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getBorderHorizSpace
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getBorderHorizSpace
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getUniqueID
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getUniqueID
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: nativeFinalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_nativeFinalize
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: nativeInitialize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_nativeInitialize
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,9 +1,97 @@
Index: nsPluginHostImpl.cpp
===================================================================
RCS file: /cvsroot/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp,v
retrieving revision 1.73
diff -r1.73 nsPluginHostImpl.cpp
1867a1868,1870
> if (NS_FAILED(result)) {
> result = plugin->CreatePluginInstance(NULL, kIPluginInstanceIID,mimeType, (void **)&instance);
> }
retrieving revision 1.76
diff -C3 -r1.76 nsPluginHostImpl.cpp
*** nsPluginHostImpl.cpp 1999/09/16 01:15:58 1.76
--- nsPluginHostImpl.cpp 1999/09/17 03:49:37
***************
*** 1863,1868 ****
--- 1863,1872 ----
result = GetPluginFactory(mimetype, &plugin);
if(!NS_FAILED(result)){
result = plugin->CreateInstance(NULL, kIPluginInstanceIID, (void **)&instance);
+ if (NS_FAILED(result)) {
+ result = plugin->CreatePluginInstance(NULL, kIPluginInstanceIID,aMimeType, (void **)&instance);
+ }
+
NS_RELEASE(plugin);
}
}
***************
*** 1911,1917 ****
for (cnt = 0; cnt < variants; cnt++)
{
! if (0 == strcmp(plugins->mMimeTypeArray[cnt], aMimeType))
return NS_OK;
}
--- 1915,1922 ----
for (cnt = 0; cnt < variants; cnt++)
{
! if (0 == strcmp(plugins->mMimeTypeArray[cnt], aMimeType)
! || 0 == strcmp(plugins->mMimeTypeArray[cnt],"*"))
return NS_OK;
}
***************
*** 2138,2144 ****
{
nsPluginTag *plugins = nsnull;
PRInt32 variants, cnt;
!
aPlugin = nsnull;
if (PR_FALSE == mPluginsLoaded)
--- 2143,2149 ----
{
nsPluginTag *plugins = nsnull;
PRInt32 variants, cnt;
! nsPluginTag *starPlugin = nsnull;
aPlugin = nsnull;
if (PR_FALSE == mPluginsLoaded)
***************
*** 2160,2166 ****
aPlugin = plugins;
return NS_OK;
}
! }
if (cnt < variants)
break;
--- 2165,2175 ----
aPlugin = plugins;
return NS_OK;
}
! if (0 == strcmp(plugins->mMimeTypeArray[cnt],"*"))
! {
! starPlugin = plugins;
! }
! }
if (cnt < variants)
break;
***************
*** 2168,2174 ****
plugins = plugins->mNext;
}
}
!
return NS_ERROR_FAILURE;
}
--- 2177,2187 ----
plugins = plugins->mNext;
}
}
! if (starPlugin != nsnull)
! {
! aPlugin = starPlugin;
! return NS_OK;
! }
return NS_ERROR_FAILURE;
}

View File

@@ -34,7 +34,7 @@ static NS_DEFINE_CID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
#define PLUGIN_MIME_DESCRIPTION "*:*:Pluglet Engine"
//nsJVMManager * PlugletEngine::jvmManager = NULL;
nsJVMManager * PlugletEngine::jvmManager = NULL;
int PlugletEngine::objectCount = 0;
PlugletsDir * PlugletEngine::dir = NULL;
PRInt32 PlugletEngine::lockCount = 0;
@@ -95,6 +95,21 @@ NS_METHOD PlugletEngine::LockFactory(PRBool aLock) {
return NS_OK;
}
char *ToString(jobject obj,JNIEnv *env) {
static jmethodID toStringID = NULL;
if (!toStringID) {
jclass clazz = env->FindClass("java/lang/Object");
toStringID = env->GetMethodID(clazz,"toString","()Ljava/lang/String;");
}
jstring jstr = (jstring) env->CallObjectMethod(obj,toStringID);
const char * str = NULL;
str = env->GetStringUTFChars(jstr,NULL);
char * res = new char[strlen(str)];
strcpy(res,str);
env->ReleaseStringUTFChars(jstr,str);
return res;
}
PlugletEngine::PlugletEngine(nsISupports* aService) {
NS_INIT_REFCNT();
dir = new PlugletsDir();
@@ -106,13 +121,13 @@ PlugletEngine::PlugletEngine(nsISupports* aService) {
return;
}
res = sm->GetService(kPluginManagerCID,kIPluginManagerIID,(nsISupports**)&pluginManager);
#if 0
if (NS_FAILED(res)) {
return;
}
res = sm->GetService(kJVMManagerCID,kIJVMManagerIID,(nsISupports**)&jvmManager);
//nb
if (NS_FAILED(res)) {
jvmManager = NULL;
}
#endif
NS_RELEASE(sm);
engine = this;
objectCount++;
@@ -148,21 +163,21 @@ static void StartJVM() {
JNIEnv * PlugletEngine::GetJNIEnv(void) {
JNIEnv * res;
#if 0
//#if 0
if (!jvmManager) {
//nb it is bad :(
return NULL;
}
jvmManager->CreateProxyJNI(NULL,&res);
//nb error handling
#endif
//#if 0
//#endif
#if 0
if (!jvm) {
printf(":) starting jvm\n");
StartJVM();
}
jvm->AttachCurrentThread(&res,NULL);
//#endif
#endif
return res;
}

View File

@@ -46,7 +46,7 @@ class PlugletEngine : public nsIPlugin {
static PRInt32 lockCount;
static PlugletsDir *dir;
static PlugletEngine * engine;
//nb static nsJVMManager * jvmManager;
static nsJVMManager * jvmManager;
static nsIPluginManager *pluginManager;
static jobject plugletManager;
};

View File

@@ -18,6 +18,7 @@
#include "PlugletStreamListener.h"
#include "PlugletInstancePeer.h"
jmethodID PlugletInstance::initializeMID = NULL;
jmethodID PlugletInstance::startMID = NULL;
jmethodID PlugletInstance::stopMID = NULL;
@@ -35,6 +36,7 @@ PlugletInstance::PlugletInstance(jobject object) {
jthis = PlugletEngine::GetJNIEnv()->NewGlobalRef(object);
//nb check for null
peer = NULL;
view = new PlugletInstanceView();
}
PlugletInstance::~PlugletInstance() {
@@ -43,7 +45,7 @@ PlugletInstance::~PlugletInstance() {
}
NS_METHOD PlugletInstance::HandleEvent(nsPluginEvent* event, PRBool* handled) {
//nb
//nb we do not need it under win32
return NS_OK;
}
@@ -57,7 +59,7 @@ NS_METHOD PlugletInstance::Initialize(nsIPluginInstancePeer* _peer) {
stopMID = env->GetMethodID(clazz,"stop","()V");
destroyMID = env->GetMethodID(clazz,"destroy","()V");
newStreamMID = env->GetMethodID(clazz,"newStream","()Lorg/mozilla/pluglet/PlugletStreamListener;");
setWindowMID = env->GetMethodID(clazz,"setWindow","(Ljava/awt/Panel;)V");
setWindowMID = env->GetMethodID(clazz,"setWindow","(Ljava/awt/Frame;)V");
printMID = env->GetMethodID(clazz,"print","(Ljava/awt/print/PrinterJob;)V");
}
peer = _peer;
@@ -113,7 +115,10 @@ NS_METHOD PlugletInstance::GetValue(nsPluginInstanceVariable variable, void *val
}
NS_METHOD PlugletInstance::SetWindow(nsPluginWindow* window) {
//nb
JNIEnv *env = PlugletEngine::GetJNIEnv();
if (view->SetWindow(window)) {
env->CallVoidMethod(jthis,setWindowMID,view->GetJObject());
}
return NS_OK;
}
@@ -123,3 +128,11 @@ NS_METHOD PlugletInstance::Print(nsPluginPrint* platformPrint) {
}

View File

@@ -17,6 +17,7 @@
#define __PlugletInstance_h__
#include "jni.h"
#include "nsplugin.h"
#include "PlugletInstanceView.h"
class PlugletInstance : public nsIPluginInstance {
public:
@@ -45,6 +46,7 @@ class PlugletInstance : public nsIPluginInstance {
static jmethodID printMID;
static jmethodID getValueMID;
nsIPluginInstancePeer *peer;
PlugletInstanceView *view;
};
#endif /* __PlugletInstance_h__ */

View File

@@ -0,0 +1,85 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* 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 <windows.h>
#include "PlugletInstanceView.h"
#include "PlugletEngine.h"
jclass PlugletInstanceView::clazz = NULL;
jmethodID PlugletInstanceView::initMID = NULL;
PlugletInstanceView::PlugletInstanceView() {
hWND = NULL;
frame = NULL;
isCreated = FALSE;
}
void PlugletInstanceView::Initialize() {
JNIEnv *env = PlugletEngine::GetJNIEnv();
clazz = env->FindClass("sun/awt/windows/WEmbeddedFrame");
if (!clazz) {
env->ExceptionDescribe();
return;
}
initMID = env->GetMethodID(clazz, "<init>", "(I)V");
if (!initMID) {
env->ExceptionDescribe();
clazz = NULL;
return;
}
}
BOOLEAN PlugletInstanceView::SetWindow(nsPluginWindow* window) {
if (!window || !window->window) {
if (isCreated) {
isCreated = FALSE;
hWND = NULL;
frame = NULL;
return TRUE;
}
}
if (hWND == reinterpret_cast<HWND>(window->window) && isCreated) {
return FALSE;
}
DWORD dwStyle = ::GetWindowLong(reinterpret_cast<HWND>(window->window), GWL_STYLE);
SetWindowLong(reinterpret_cast<HWND>(window->window), GWL_STYLE, dwStyle | WS_CHILD
| WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
if(!clazz) {
Initialize();
if (!clazz) {
return FALSE;
}
}
JNIEnv *env = PlugletEngine::GetJNIEnv();
frame = env->NewObject(clazz,initMID,(jint)window->window);
if (!frame) {
env->ExceptionDescribe();
}
hWND = (HWND) window->window;
isCreated = TRUE;
return TRUE;
}
jobject PlugletInstanceView::GetJObject() {
return frame;
}

View File

@@ -0,0 +1,45 @@
/*
* 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 __PlugletInstanceView_h__
#define __PlugletInstanceView_h__
#include <windows.h>
#include "nsplugindefs.h"
#include "jni.h"
class PlugletInstanceView {
public:
PlugletInstanceView(void);
jobject GetJObject(void);
BOOLEAN SetWindow(nsPluginWindow* window);
private:
static void Initialize(void);
static jclass clazz;
static jmethodID initMID;
HWND hWND;
BOOL isCreated;
jobject frame;
};
#endif /* __PlugletInstanceView_h__ */

View File

@@ -13,10 +13,9 @@
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*/
#include "PlugletLoader.h"
#include "PlugletEngine.h"
#include "string.h"
#include "PlugletEngine.h"
#include "PlugletLoader.h"
jclass PlugletLoader::clazz = NULL;
jmethodID PlugletLoader::getMIMEDescriptionMID = NULL;
jmethodID PlugletLoader::getPlugletMID = NULL;
@@ -114,11 +113,3 @@ jobject PlugletLoader::GetPluglet(const char * path) {
}
return jpluglet;
}

View File

@@ -56,13 +56,14 @@ nsresult PlugletsDir::GetPluglet(const char * mimeType, Pluglet **pluglet) {
return NS_ERROR_NULL_POINTER;
}
*pluglet = NULL;
nsresult res = NS_OK;
nsresult res = NS_ERROR_FAILURE;
if(!list) {
LoadPluglets();
}
for (PlugletListIterator *iter = list->GetIterator();iter->Get();iter->Next()) {
if(iter->Get()->Compare(mimeType)) {
*pluglet = iter->Get();
res = NS_OK;
break;
}
}

View File

@@ -56,7 +56,8 @@ OBJS = \
.\$(OBJDIR)\PlugletStreamInfo.obj \
.\$(OBJDIR)\PlugletInstancePeer.obj \
.\$(OBJDIR)\PlugletManager.obj \
.\$(OBJDIR)\PlugletInputStream.obj
.\$(OBJDIR)\PlugletInputStream.obj \
.\$(OBJDIR)\PlugletInstanceView.obj
MAKE_OBJ_TYPE = DLL

View File

@@ -1,81 +0,0 @@
/*
* 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;
import org.mozilla.pluglet.mozilla.*;
import java.awt.Panel;
import java.awt.print.PrinterJob;
public interface PlugletInstance {
/**
* Initializes a newly created pluglet instance, passing to it the pluglet
* instance peer which it should use for all communication back to the browser.
*
* @param peer the corresponding pluglet instance peer
*/
void initialize(PlugletInstancePeer peer);
/**
* Called to instruct the pluglet instance to start. This will be called after
* the pluglet is first created and initialized, and may be called after the
* pluglet is stopped (via the Stop method) if the pluglet instance is returned
* to in the browser window's history.
*/
void start();
/**
* Called to instruct the pluglet instance to stop, thereby suspending its state.
* This method will be called whenever the browser window goes on to display
* another page and the page containing the pluglet goes into the window's history
* list.
*/
void stop();
/**
* Called to instruct the pluglet instance to destroy itself. This is called when
* it become no longer possible to return to the pluglet instance, either because
* the browser window's history list of pages is being trimmed, or because the
* window containing this page in the history is being closed.
*/
void destroy();
/**
* Called to tell the pluglet that the initial src/data stream is
* ready.
*
* @result PlugletStreamListener
*/
PlugletStreamListener newStream();
/**
* Called when the window containing the pluglet instance changes.
*
* @param frame the pluglet panel
*/
void setWindow(Panel frame);
/**
* Called to instruct the pluglet instance to print itself to a printer.
*
* @param print printer information.
*/
void print(PrinterJob printerJob);
}

View File

@@ -1,4 +1,4 @@
/*
/*
* 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
@@ -16,10 +16,14 @@
import org.mozilla.pluglet.*;
import org.mozilla.pluglet.mozilla.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import java.io.*;
public class test implements Pluglet {
public test() {
org.mozilla.util.Debug.print("--test.test()\n");
}
/**
* Creates a new pluglet instance, based on a MIME type. This
* allows different impelementations to be created depending on
@@ -45,7 +49,33 @@ public class test implements Pluglet {
}
}
class TestInstance implements PlugletInstance{
class TestInstance implements PlugletInstance {
Panel panel;
Button button;
List list;
public TestInstance() {
org.mozilla.util.Debug.print("--TestInstance.TestInstance() \n");
panel = new Panel();
button = new Button("Press me :)");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int t = list.getSelectedIndex();
t++;
if (t >= list.getItemCount()) {
t = 0;
}
list.select(t);
}
}
);
panel.add(button);
list = new List(4,false);
list.add("Pluglet");
list.add("not");
list.add("bad");
list.select(0);
panel.add(list);
}
/**
* Initializes a newly created pluglet instance, passing to it the pluglet
* instance peer which it should use for all communication back to the browser.
@@ -57,8 +87,9 @@ class TestInstance implements PlugletInstance{
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"));
OutputStreamWriter out = new OutputStreamWriter(peer.newStream("text/plain","_new"));
String msg = "Hello, world";
out.write(msg,0,msg.length());
out.flush();
@@ -66,6 +97,7 @@ class TestInstance implements PlugletInstance{
} catch (Exception e) {
;
}
*/
}
/**
* Called to instruct the pluglet instance to start. This will be called after
@@ -108,7 +140,11 @@ class TestInstance implements PlugletInstance{
*
* @param frame the pluglet panel
*/
public void setWindow(Panel frame) {
public void setWindow(Frame frame) {
org.mozilla.util.Debug.print("--Test...SetWindow "+frame);
frame.add(panel);
frame.pack();
frame.show();
}
/**
* Called to instruct the pluglet instance to print itself to a printer.
@@ -120,6 +156,9 @@ class TestInstance implements PlugletInstance{
}
class TestStreamListener implements PlugletStreamListener {
public TestStreamListener() {
org.mozilla.util.Debug.print("--TestStreamListener.TestStreamListener()\n");
}
/**
* Notify the observer that the URL has started to load. This method is
* called only once, at the beginning of a URL load.<BR><BR>