bug 18180

Names changed
Pluglet->PlugletFactory, *PlugletInstance*->*Pluglet*
This commit is contained in:
idk%eng.sun.com 1999-11-09 10:28:46 +00:00
parent 4095510e3a
commit 12b30bdf0b
33 changed files with 811 additions and 800 deletions

View File

@ -19,27 +19,66 @@
* Contributor(s):
*/
package org.mozilla.pluglet;
import org.mozilla.pluglet.mozilla.*;
import java.awt.Frame;
import java.awt.print.PrinterJob;
public interface Pluglet {
/**
* Creates a new pluglet instance, based on a MIME type. This
* allows different impelementations to be created depending on
* the specified MIME type.
* 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 peer
*/
public PlugletInstance createPlugletInstance(String mimeType);
void initialize(PlugletPeer peer);
/**
* Initializes the pluglet and will be called before any new instances are
* created.
* 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.
*/
public void initialize(PlugletManager manager);
void start();
/**
* Called when the browser is done with the pluglet factory, or when
* the pluglet is disabled by the user.
* 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.
*/
public void shutdown();
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(Frame frame);
/**
* Called to instruct the pluglet instance to print itself to a printer.
*
* @param print printer information.
*/
void print(PrinterJob printerJob);
}

View File

@ -18,34 +18,30 @@
*
* Contributor(s):
*/
#ifndef __PlugletList_h__
#define __PlugletList_h__
#include "Pluglet.h"
class PlugletListIterator;
package org.mozilla.pluglet;
import org.mozilla.pluglet.mozilla.*;
public interface PlugletFactory {
/**
* Creates a new pluglet instance, based on a MIME type. This
* allows different impelementations to be created depending on
* the specified MIME type.
*/
public Pluglet createPluglet(String mimeType);
/**
* Initializes the pluglet and will be called before any new instances are
* created.
*/
public void initialize(PlugletManager manager);
/**
* Called when the browser is done with the pluglet factory, or when
* the pluglet is disabled by the user.
*/
public void shutdown();
}
class PlugletList {
friend class PlugletListIterator;
public:
PlugletList();
~PlugletList();
void Add(Pluglet *pluglet);
PlugletListIterator * GetIterator(void);
private:
struct PlugletListNode {
PlugletListNode(Pluglet *v,PlugletListNode *n = NULL);
Pluglet * value;
PlugletListNode * next;
};
PlugletListNode * head;
PlugletListNode * tail;
};
class PlugletListIterator {
public:
PlugletListIterator(PlugletList *list);
Pluglet * Get(void);
Pluglet * Next(void);
private:
PlugletList::PlugletListNode *current;
};
#endif /* __PlugletList_h__ */

View File

@ -1,86 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (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 Original Code is mozilla.org code.
*
* 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.
*
* Contributor(s):
*/
package org.mozilla.pluglet;
import org.mozilla.pluglet.mozilla.*;
import java.awt.Frame;
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(Frame frame);
/**
* Called to instruct the pluglet instance to print itself to a printer.
*
* @param print printer information.
*/
void print(PrinterJob printerJob);
}

View File

@ -30,7 +30,7 @@ import java.security.*;
public class PlugletLoader {
// path to jar file. Name of main class sould to be in MANIFEST.
public static Pluglet getPluglet(String path) {
public static PlugletFactory getPluglet(String path) {
try {
org.mozilla.util.Debug.print("-- PlugletLoader.getPluglet("+path+")\n");
URL url = new URL("file:/"+path);
@ -41,7 +41,7 @@ public class PlugletLoader {
Attributes attr = manifest.getMainAttributes();
String plugletClassName = attr.getValue("Pluglet-Class");
org.mozilla.util.Debug.print("-- PlugletLoader.getPluglet class name "+plugletClassName+"\n");
org.mozilla.util.Debug.print("-- PL url[0] "+loader.getURLs()[0]);
org.mozilla.util.Debug.print("-- PL url[0] "+loader.getURLs()[0]+"\n");
if (plugletClassName == null) {
//nb
return null;
@ -58,9 +58,11 @@ public class PlugletLoader {
collection.add(perm);
policy.grantPermission(codesource,collection);
Object pluglet = loader.loadClass(plugletClassName).newInstance();
if (pluglet instanceof Pluglet) {
return (Pluglet) pluglet;
if (pluglet instanceof PlugletFactory) {
org.mozilla.util.Debug.print("-- ok we have a PlugletFactory"+"\n");
return (PlugletFactory) pluglet;
} else {
org.mozilla.util.Debug.print("-- oups we do not have a PlugletFactory"+"\n");
return null;
}
} catch (Exception e) {

View File

@ -47,7 +47,7 @@ public interface PlugletManager {
public String userAgent();
/**
* Fetches a URL.
* @param plugletInst the pluglet making the request.
* @param pluglet the pluglet making the request.
* If null, the URL is fetched in the background.
* @param url the URL to fetch
* @param target the target window into which to load the URL
@ -62,7 +62,7 @@ public interface PlugletManager {
* 'javascript:' URLs, even if the user currently has JavaScript
* disabled (usually specify false)
*/
public void getURL(PlugletInstance plugletInst,
public void getURL(Pluglet pluglet,
URL url, String target,
PlugletStreamListener streamListener,
String altHost, URL referrer,
@ -70,7 +70,7 @@ public interface PlugletManager {
/**
* Posts to a URL with post data and/or post headers.
*
* @param plugletInst the pluglet making the request. If null, the URL
* @param pluglet the pluglet making the request. If null, the URL
* is fetched in the background.
* @param url the URL to fetch
* @param target the target window into which to load the URL
@ -93,7 +93,7 @@ public interface PlugletManager {
* are no post headers
*/
public void postURL(PlugletInstance plugletInst,
public void postURL(Pluglet pluglet,
URL url,
int postDataLen,
byte[] postData,

View File

@ -50,7 +50,7 @@ public class PlugletManagerImpl implements PlugletManager {
public native String userAgent();
/**
* Fetches a URL.
* @param plugletInst the pluglet making the request.
* @param pluglet the pluglet making the request.
* If null, the URL is fetched in the background.
* @param url the URL to fetch
* @param target the target window into which to load the URL
@ -65,7 +65,7 @@ public class PlugletManagerImpl implements PlugletManager {
* 'javascript:' URLs, even if the user currently has JavaScript
* disabled (usually specify false)
*/
public native void getURL(PlugletInstance plugletInst,
public native void getURL(Pluglet pluglet,
URL url, String target,
PlugletStreamListener streamListener,
String altHost, URL referrer,
@ -73,7 +73,7 @@ public class PlugletManagerImpl implements PlugletManager {
/**
* Posts to a URL with post data and/or post headers.
*
* @param plugletInst the pluglet making the request. If null, the URL
* @param pluglet the pluglet making the request. If null, the URL
* is fetched in the background.
* @param url the URL to fetch
* @param target the target window into which to load the URL
@ -96,7 +96,7 @@ public class PlugletManagerImpl implements PlugletManager {
* are no post headers
*/
public native void postURL(PlugletInstance plugletInst,
public native void postURL(Pluglet pluglet,
URL url,
int postDataLen,
byte[] postData,

View File

@ -1,28 +1,23 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (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/
* 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 Original Code is mozilla.org code.
* 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.
*
* Contributor(s):
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*/
package org.mozilla.pluglet.mozilla;
import java.io.OutputStream;
public interface PlugletInstancePeer {
public interface PlugletPeer {
public static final int NETSCAPE_WINDOW = 3;
/**
* Returns the MIME type of the pluglet instance.

View File

@ -1,30 +1,25 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (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/
* 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 Original Code is mozilla.org code.
* 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.
*
* Contributor(s):
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*/
package org.mozilla.pluglet.mozilla;
import java.io.OutputStream;
public class PlugletInstancePeerImpl implements PlugletInstancePeer {
public class PlugletPeerImpl implements PlugletPeer {
private long peer = 0;
public PlugletInstancePeerImpl(long peer) {
public PlugletPeerImpl(long peer) {
this.peer = peer;
nativeInitialize();
}

View File

@ -35,7 +35,7 @@ OBJS = \
.\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletStreamInfoImpl.obj \
.\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletInputStream.obj \
.\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletOutputStream.obj \
.\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.obj \
.\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletPeerImpl.obj \
.\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletManagerImpl.obj \
.\$(OBJDIR)\org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl.obj \
.\$(OBJDIR)\PlugletTagInfo2.obj \

View File

@ -1,106 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (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 Original Code is mozilla.org code.
*
* 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.
*
* Contributor(s):
*/
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl */
#ifndef _Included_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
#define _Included_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Method: getMIMEType
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_getMIMEType
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Method: getMode
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_getMode
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Method: getValue
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_getValue
(JNIEnv *, jobject, jint);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Method: newStream
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/io/OutputStream;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_newStream
(JNIEnv *, jobject, jstring, jstring);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Method: showStatus
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_showStatus
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Method: setWindowSize
* Signature: (II)V
*/
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
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_nativeFinalize
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Method: nativeInitialize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_nativeInitialize
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -71,7 +71,7 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_us
/*
* Class: org_mozilla_pluglet_mozilla_PlugletManagerImpl
* Method: getURL
* Signature: (Lorg/mozilla/pluglet/PlugletInstance;Ljava/net/URL;Ljava/lang/String;Lorg/mozilla/pluglet/PlugletStreamListener;Ljava/lang/String;Ljava/net/URL;Z)V
* Signature: (Lorg/mozilla/pluglet/Pluglet;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 *env, jobject jthis, jobject, jobject, jstring, jobject, jstring, jobject, jboolean) {
@ -82,7 +82,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_getUR
/*
* Class: org_mozilla_pluglet_mozilla_PlugletManagerImpl
* Method: postURL
* 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
* Signature: (Lorg/mozilla/pluglet/Pluglet;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 *env, jobject jthis, jobject, jobject, jint, jbyteArray, jboolean, jstring, jobject, jstring, jobject, jboolean, jint, jbyteArray) {

View File

@ -54,7 +54,7 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_us
/*
* Class: org_mozilla_pluglet_mozilla_PlugletManagerImpl
* Method: getURL
* Signature: (Lorg/mozilla/pluglet/PlugletInstance;Ljava/net/URL;Ljava/lang/String;Lorg/mozilla/pluglet/PlugletStreamListener;Ljava/lang/String;Ljava/net/URL;Z)V
* Signature: (Lorg/mozilla/pluglet/Pluglet;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);
@ -62,7 +62,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletManagerImpl_getUR
/*
* Class: org_mozilla_pluglet_mozilla_PlugletManagerImpl
* Method: postURL
* 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
* Signature: (Lorg/mozilla/pluglet/Pluglet;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);

View File

@ -1,37 +1,32 @@
/* -*- 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.1 (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/
* 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 Original Code is mozilla.org code.
* 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.
*
* Contributor(s):
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*/
#include "nsIPluginInstancePeer.h"
#include "nsIPluginTagInfo2.h"
#include "PlugletOutputStream.h"
#include "PlugletTagInfo2.h"
#include "org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl.h"
#include "org_mozilla_pluglet_mozilla_PlugletPeerImpl.h"
static jfieldID peerFID = NULL;
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: getMIMEType
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_getMIMEType
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_getMIMEType
(JNIEnv *env, jobject jthis) {
nsIPluginInstancePeer * instancePeer = (nsIPluginInstancePeer*)env->GetLongField(jthis, peerFID);
if (!instancePeer) {
@ -45,31 +40,31 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerIm
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: getMode
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_getMode
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_getMode
(JNIEnv *, jobject) {
return 1; //nb
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: getValue
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_getValue
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_getValue
(JNIEnv *, jobject, jint) {
return NULL; //nb
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: newStream
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/io/OutputStream;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_newStream
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_newStream
(JNIEnv *env, jobject jthis, jstring _type, jstring _target) {
nsMIMEType mimeType = NULL;
if ( _type == NULL
@ -102,11 +97,11 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerIm
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: showStatus
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_showStatus
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_showStatus
(JNIEnv *env, jobject jthis, jstring _msg) {
nsIPluginInstancePeer * instancePeer = (nsIPluginInstancePeer*)env->GetLongField(jthis, peerFID);
if (!instancePeer) {
@ -121,11 +116,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: setWindowSize
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_setWindowSize
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_setWindowSize
(JNIEnv *env, jobject jthis, jint width, jint height) {
nsIPluginInstancePeer * instancePeer = (nsIPluginInstancePeer*)env->GetLongField(jthis, peerFID);
if (!instancePeer) {
@ -139,11 +134,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_
static NS_DEFINE_IID(kIPluginTagInfo2,NS_IPLUGINTAGINFO2_IID);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: getTagInfo
* Signature: ()Lorg/mozilla/pluglet/mozilla/PlugletTagInfo;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_getTagInfo
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_getTagInfo
(JNIEnv *env, jobject jthis) {
nsIPluginInstancePeer * instancePeer = (nsIPluginInstancePeer*)env->GetLongField(jthis, peerFID);
nsIPluginTagInfo2 * info = NULL;
@ -154,11 +149,11 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerIm
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: nativeFinalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_nativeFinalize
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_nativeFinalize
(JNIEnv *env, jobject jthis) {
nsIPluginInstancePeer * instancePeer = (nsIPluginInstancePeer*)env->GetLongField(jthis, peerFID);
if (instancePeer) {
@ -168,11 +163,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: nativeInitialize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl_nativeInitialize
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_nativeInitialize
(JNIEnv *env, jobject jthis) {
if(!peerFID) {
peerFID = env->GetFieldID(env->GetObjectClass(jthis),"peer","J");

View File

@ -0,0 +1,101 @@
/*
* 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_PlugletPeerImpl */
#ifndef _Included_org_mozilla_pluglet_mozilla_PlugletPeerImpl
#define _Included_org_mozilla_pluglet_mozilla_PlugletPeerImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: getMIMEType
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_getMIMEType
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletInstancePeerImpl
* Method: getMode
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_getMode
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: getValue
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_getValue
(JNIEnv *, jobject, jint);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: newStream
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/io/OutputStream;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_newStream
(JNIEnv *, jobject, jstring, jstring);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: showStatus
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_showStatus
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: setWindowSize
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_setWindowSize
(JNIEnv *, jobject, jint, jint);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: getTagInfo
* Signature: ()Lorg/mozilla/pluglet/mozilla/PlugletTagInfo;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_getTagInfo
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: nativeFinalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_nativeFinalize
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletPeerImpl
* Method: nativeInitialize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_pluglet_mozilla_PlugletPeerImpl_nativeInitialize
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

68
java/plugins/src/List.cpp Normal file
View File

@ -0,0 +1,68 @@
/*
* 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"List.h"
List::List() {
head = tail = NULL;
}
List::~List() {
ListNode *tmp;
for(ListNode * current=head;!current;tmp = current,current = current->next, delete tmp)
;
}
List::ListNode::ListNode(void *v,List::ListNode *n) {
value = v; next = n;
}
void List::Add(void *v) {
if (!v) {
return;
}
if (!tail) {
head = tail = new ListNode(v);
} else {
tail->next = new ListNode(v);
if (tail->next) {
tail = tail->next;
}
}
}
ListIterator * List::GetIterator(void) {
return new ListIterator(this);
}
ListIterator::ListIterator(List *list) {
current = list->head;
}
void * ListIterator::Get(void) {
void * result = NULL;
if (current) {
result = current->value;
}
return result;
}
void * ListIterator::Next(void) {
void * result = NULL;
if (current) {
current = current->next;
result = Get();
}
return result;
}

46
java/plugins/src/List.h Normal file
View File

@ -0,0 +1,46 @@
/*
* 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 __List_h__
#define __List_h__
#include <stdlib.h> //in order to have NULL definition
class ListIterator;
class List {
friend class ListIterator;
public:
List();
~List();
void Add(void *value);
ListIterator * GetIterator(void);
private:
struct ListNode {
ListNode(void *v,ListNode *n = NULL);
void * value;
ListNode * next;
};
ListNode * head;
ListNode * tail;
};
class ListIterator {
public:
ListIterator(List *list);
void * Get(void);
void * Next(void);
private:
List::ListNode *current;
};
#endif /* __List_h__ */

View File

@ -1,4 +1,4 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
@ -20,161 +20,170 @@
*/
#include "Pluglet.h"
#include "PlugletEngine.h"
#include "PlugletLoader.h"
#include "PlugletInstance.h"
#include "string.h"
#include "PlugletStreamListener.h"
#include "PlugletPeer.h"
#include "Registry.h"
jmethodID Pluglet::createPlugletInstanceMID = NULL;
jmethodID Pluglet::initializeMID = NULL;
jmethodID Pluglet::shutdownMID = NULL;
jmethodID Pluglet::initializeMID = NULL;
jmethodID Pluglet::startMID = NULL;
jmethodID Pluglet::stopMID = NULL;
jmethodID Pluglet::destroyMID = NULL;
jmethodID Pluglet::newStreamMID = NULL;
jmethodID Pluglet::setWindowMID = NULL;
jmethodID Pluglet::printMID = NULL;
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
nsresult Pluglet::CreatePluginInstance(const char* aPluginMIMEType, void **aResult) {
if(!aResult
|| Initialize() != NS_OK) {
return NS_ERROR_FAILURE;
}
JNIEnv *env = PlugletEngine::GetJNIEnv();
if(!env) {
return NS_ERROR_FAILURE;
}
jstring jstr = env->NewStringUTF(aPluginMIMEType);
jobject obj = env->CallObjectMethod(jthis,createPlugletInstanceMID, jstr);
if (!obj) {
return NS_ERROR_FAILURE;
}
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
nsISupports * instance = new PlugletInstance(obj);
NS_ADDREF(instance);
*aResult = instance;
NS_IMPL_ISUPPORTS(Pluglet, kIPluginInstanceIID);
Pluglet::Pluglet(jobject object) {
NS_INIT_REFCNT();
jthis = PlugletEngine::GetJNIEnv()->NewGlobalRef(object);
//nb check for null
peer = NULL;
view = new PlugletView();
Registry::SetPeer(jthis,(jlong)this);
}
Pluglet::~Pluglet() {
Registry::Remove(jthis);
PlugletEngine::GetJNIEnv()->DeleteGlobalRef(jthis);
NS_RELEASE(peer);
}
NS_METHOD Pluglet::HandleEvent(nsPluginEvent* event, PRBool* handled) {
//nb we do not need it under win32
return NS_OK;
}
nsresult Pluglet::Initialize(void) {
NS_METHOD Pluglet::Initialize(nsIPluginInstancePeer* _peer) {
JNIEnv *env = PlugletEngine::GetJNIEnv();
if(!env) {
return NS_ERROR_FAILURE;
}
if (!initializeMID) {
if (!printMID) {
jclass clazz = env->FindClass("org/mozilla/pluglet/Pluglet");
if(!clazz) {
return NS_ERROR_FAILURE;
}
createPlugletInstanceMID = env->GetMethodID(clazz,"createPlugletInstance","(Ljava/lang/String;)Lorg/mozilla/pluglet/PlugletInstance;");
if (!createPlugletInstanceMID) {
return NS_ERROR_FAILURE;
}
shutdownMID = env->GetMethodID(clazz,"shutdown","()V");
if (!shutdownMID) {
return NS_ERROR_FAILURE;
}
initializeMID = env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletManager;)V");
if (!initializeMID) {
return NS_ERROR_FAILURE;
}
}
if (!jthis) {
jthis = PlugletLoader::GetPluglet(path);
if (!jthis) {
return NS_ERROR_FAILURE;
}
env->CallVoidMethod(jthis,initializeMID,PlugletEngine::GetPlugletManager());
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
initializeMID = env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletPeer;)V");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
startMID = env->GetMethodID(clazz,"start","()V");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
stopMID = env->GetMethodID(clazz,"stop","()V");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
destroyMID = env->GetMethodID(clazz,"destroy","()V");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
newStreamMID = env->GetMethodID(clazz,"newStream","()Lorg/mozilla/pluglet/PlugletStreamListener;");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
setWindowMID = env->GetMethodID(clazz,"setWindow","(Ljava/awt/Frame;)V");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
printMID = env->GetMethodID(clazz,"print","(Ljava/awt/print/PrinterJob;)V");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
}
peer = _peer;
peer->AddRef();
jobject obj = PlugletPeer::GetJObject(peer);
if (!obj) {
return NS_ERROR_FAILURE;
}
env->CallVoidMethod(jthis,initializeMID,obj);
return NS_OK;
}
nsresult Pluglet::Shutdown(void) {
if(!jthis) {
return NS_ERROR_FAILURE;
}
JNIEnv *env = PlugletEngine::GetJNIEnv();
if(!env) {
return NS_ERROR_FAILURE;
}
env->CallVoidMethod(jthis,shutdownMID);
NS_METHOD Pluglet::GetPeer(nsIPluginInstancePeer* *result) {
peer->AddRef();
*result = peer;
return NS_OK;
}
NS_METHOD Pluglet::Start(void) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
env->CallVoidMethod(jthis,startMID);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_METHOD Pluglet::Stop(void) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
env->CallVoidMethod(jthis,stopMID);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_METHOD Pluglet::Destroy(void) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
env->CallVoidMethod(jthis,destroyMID);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_METHOD Pluglet::NewStream(nsIPluginStreamListener** listener) {
if(!listener) {
return NS_ERROR_FAILURE;
}
JNIEnv * env = PlugletEngine::GetJNIEnv();
jobject obj = env->CallObjectMethod(jthis,newStreamMID);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
if (obj) {
*listener = new PlugletStreamListener(obj);
(*listener)->AddRef();
}
return NS_OK;
}
nsresult Pluglet::GetMIMEDescription(const char* *result) {
if(!result) {
return NS_ERROR_FAILURE;
}
*result = mimeDescription;
return (*result) ? NS_OK : NS_ERROR_FAILURE;
NS_METHOD Pluglet::GetValue(nsPluginInstanceVariable variable, void *value) {
return NS_ERROR_FAILURE;
}
Pluglet::Pluglet(const char *mimeDescription, const char *path) {
jthis = NULL;
this->path = new char[strlen(path)+1];
strcpy(this->path,path);
this->mimeDescription = new char[strlen(mimeDescription)+1];
strcpy(this->mimeDescription,mimeDescription);
}
Pluglet::~Pluglet(void) {
if (path != NULL) {
delete[] path;
}
if (mimeDescription != NULL) {
delete[] mimeDescription;
}
NS_METHOD Pluglet::SetWindow(nsPluginWindow* window) {
JNIEnv *env = PlugletEngine::GetJNIEnv();
if (env != NULL) {
env->DeleteGlobalRef(jthis);
if (view->SetWindow(window)) {
env->CallVoidMethod(jthis,setWindowMID,view->GetJObject());
}
return NS_OK;
}
Pluglet * Pluglet::Load(const char * path) {
char * mime = PlugletLoader::GetMIMEDescription(path);
Pluglet * result = NULL;
if (mime) {
result = new Pluglet(mime,path);
//delete[] mime; //nb we have a strange exception here
}
return result;
}
/*
1 if good
0 if not good
*/
int Pluglet::Compare(const char *mimeType) {
/* mimedDescription mimeTypes:extensions:description
mimeTypes mimeType;mimeType;...
extensions extension;extension;...
*/
if (!mimeType) {
return 0;
}
char * terminator = strchr(mimeDescription,':'); // terminator have to be not equal to NULL;
char *p1 = mimeDescription;
char *p2 = strchr(p1,';');
while ( p1 != NULL && p1 < terminator ) {
size_t n = sizeof(char) * ( ( (p2 == NULL) ? terminator : p2) - p1 );
if (PL_strncasecmp(p1,mimeType,n) == 0) {
return 1;
}
p1 = p2 ;
if (p2 != NULL) {
p2 = strchr(++p2,';');
p1++;
}
}
return 0;
NS_METHOD Pluglet::Print(nsPluginPrint* platformPrint) {
//nb
return NS_OK;
}

View File

@ -22,26 +22,35 @@
#define __Pluglet_h__
#include "nsplugin.h"
#include "jni.h"
#include "PlugletView.h"
class Pluglet {
class Pluglet : public nsIPluginInstance {
public:
nsresult CreatePluginInstance(const char* aPluginMIMEType, void **aResult);
nsresult Initialize(void);
nsresult Shutdown(void);
nsresult GetMIMEDescription(const char* *result);
/*****************************************/
~Pluglet(void);
int Compare(const char * mimeType);
static Pluglet * Load(const char * path);
NS_IMETHOD HandleEvent(nsPluginEvent* event, PRBool* handled);
NS_IMETHOD Initialize(nsIPluginInstancePeer* peer);
NS_IMETHOD GetPeer(nsIPluginInstancePeer* *result);
NS_IMETHOD Start(void);
NS_IMETHOD Stop(void);
NS_IMETHOD Destroy(void);
NS_IMETHOD NewStream(nsIPluginStreamListener** listener);
NS_IMETHOD SetWindow(nsPluginWindow* window);
NS_IMETHOD Print(nsPluginPrint* platformPrint);
NS_IMETHOD GetValue(nsPluginInstanceVariable variable, void *value);
NS_DECL_ISUPPORTS
Pluglet(jobject object);
virtual ~Pluglet(void);
private:
jobject jthis;
static jmethodID createPlugletInstanceMID;
static jmethodID initializeMID;
static jmethodID shutdownMID;
/*****************************************/
char *mimeDescription;
char *path;
Pluglet(const char *mimeDescription,const char * path);
};
static jmethodID initializeMID;
static jmethodID startMID;
static jmethodID stopMID;
static jmethodID destroyMID;
static jmethodID newStreamMID;
static jmethodID setWindowMID;
static jmethodID printMID;
static jmethodID getValueMID;
nsIPluginInstancePeer *peer;
PlugletView *view;
};
#endif /* __Pluglet_h__ */

View File

@ -70,14 +70,14 @@ NS_METHOD PlugletEngine::CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID
if (!aResult) {
return NS_ERROR_FAILURE;
}
Pluglet * pluglet = NULL;
PlugletFactory * plugletFactory = NULL;
nsresult res = NS_ERROR_NULL_POINTER;
if ((res = dir->GetPluglet(aPluginMIMEType,&pluglet)) != NS_OK
|| !pluglet) {
if ((res = dir->GetPlugletFactory(aPluginMIMEType,&plugletFactory)) != NS_OK
|| !plugletFactory) {
return res;
}
//we do not delete pluglet because we do not allocate new memory in dir->GetPluglet()
return pluglet->CreatePluginInstance(aPluginMIMEType,aResult);
return plugletFactory->CreatePluginInstance(aPluginMIMEType,aResult);
}
NS_METHOD PlugletEngine::GetMIMEDescription(const char* *result) {

View File

@ -0,0 +1,181 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (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 Original Code is mozilla.org code.
*
* 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.
*
* Contributor(s):
*/
#include "PlugletFactory.h"
#include "PlugletEngine.h"
#include "PlugletLoader.h"
#include "Pluglet.h"
#include "string.h"
jmethodID PlugletFactory::createPlugletMID = NULL;
jmethodID PlugletFactory::initializeMID = NULL;
jmethodID PlugletFactory::shutdownMID = NULL;
nsresult PlugletFactory::CreatePluginInstance(const char* aPluginMIMEType, void **aResult) {
if(!aResult
|| Initialize() != NS_OK) {
return NS_ERROR_FAILURE;
}
JNIEnv *env = PlugletEngine::GetJNIEnv();
if(!env) {
return NS_ERROR_FAILURE;
}
jstring jstr = env->NewStringUTF(aPluginMIMEType);
jobject obj = env->CallObjectMethod(jthis,createPlugletMID, jstr);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
nsISupports * instance = new Pluglet(obj);
NS_ADDREF(instance);
*aResult = instance;
return NS_OK;
}
nsresult PlugletFactory::Initialize(void) {
JNIEnv *env = PlugletEngine::GetJNIEnv();
if(!env) {
return NS_ERROR_FAILURE;
}
if (!initializeMID) {
jclass clazz = env->FindClass("org/mozilla/pluglet/PlugletFactory");
if(!clazz) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
createPlugletMID = env->GetMethodID(clazz,"createPluglet","(Ljava/lang/String;)Lorg/mozilla/pluglet/Pluglet;");
if (!createPlugletMID) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
shutdownMID = env->GetMethodID(clazz,"shutdown","()V");
if (!shutdownMID) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
initializeMID = env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletManager;)V");
if (!initializeMID) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
}
if (!jthis) {
jthis = PlugletLoader::GetPluglet(path);
if (!jthis) {
return NS_ERROR_FAILURE;
}
env->CallVoidMethod(jthis,initializeMID,PlugletEngine::GetPlugletManager());
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}
nsresult PlugletFactory::Shutdown(void) {
if(!jthis) {
return NS_ERROR_FAILURE;
}
JNIEnv *env = PlugletEngine::GetJNIEnv();
if(!env) {
return NS_ERROR_FAILURE;
}
env->CallVoidMethod(jthis,shutdownMID);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
return NS_OK;
}
nsresult PlugletFactory::GetMIMEDescription(const char* *result) {
if(!result) {
return NS_ERROR_FAILURE;
}
*result = mimeDescription;
return (*result) ? NS_OK : NS_ERROR_FAILURE;
}
PlugletFactory::PlugletFactory(const char *mimeDescription, const char *path) {
jthis = NULL;
this->path = new char[strlen(path)+1];
strcpy(this->path,path);
this->mimeDescription = new char[strlen(mimeDescription)+1];
strcpy(this->mimeDescription,mimeDescription);
}
PlugletFactory::~PlugletFactory(void) {
if (path != NULL) {
delete[] path;
}
if (mimeDescription != NULL) {
delete[] mimeDescription;
}
JNIEnv *env = PlugletEngine::GetJNIEnv();
if (env != NULL) {
env->DeleteGlobalRef(jthis);
}
}
PlugletFactory * PlugletFactory::Load(const char * path) {
char * mime = PlugletLoader::GetMIMEDescription(path);
PlugletFactory * result = NULL;
if (mime) {
result = new PlugletFactory(mime,path);
//delete[] mime; //nb we have a strange exception here
}
return result;
}
/*
1 if good
0 if not good
*/
int PlugletFactory::Compare(const char *mimeType) {
/* mimedDescription mimeTypes:extensions:description
mimeTypes mimeType;mimeType;...
extensions extension;extension;...
*/
if (!mimeType) {
return 0;
}
char * terminator = strchr(mimeDescription,':'); // terminator have to be not equal to NULL;
char *p1 = mimeDescription;
char *p2 = strchr(p1,';');
while ( p1 != NULL && p1 < terminator ) {
size_t n = sizeof(char) * ( ( (p2 == NULL) ? terminator : p2) - p1 );
if (PL_strncasecmp(p1,mimeType,n) == 0) {
return 1;
}
p1 = p2 ;
if (p2 != NULL) {
p2 = strchr(++p2,';');
p1++;
}
}
return 0;
}

View File

@ -0,0 +1,47 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (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 Original Code is mozilla.org code.
*
* 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.
*
* Contributor(s):
*/
#ifndef __PlugletFactory_h__
#define __PlugletFactory_h__
#include "nsplugin.h"
#include "jni.h"
class PlugletFactory {
public:
nsresult CreatePluginInstance(const char* aPluginMIMEType, void **aResult);
nsresult Initialize(void);
nsresult Shutdown(void);
nsresult GetMIMEDescription(const char* *result);
/*****************************************/
~PlugletFactory(void);
int Compare(const char * mimeType);
static PlugletFactory * Load(const char * path);
private:
jobject jthis;
static jmethodID createPlugletMID;
static jmethodID initializeMID;
static jmethodID shutdownMID;
/*****************************************/
char *mimeDescription;
char *path;
PlugletFactory(const char *mimeDescription,const char * path);
};
#endif /* __PlugletFactory_h__ */

View File

@ -1,146 +0,0 @@
/* -*- 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.1 (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 Original Code is mozilla.org code.
*
* 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.
*
* Contributor(s):
*/
#include "PlugletInstance.h"
#include "PlugletEngine.h"
#include "PlugletStreamListener.h"
#include "PlugletInstancePeer.h"
#include "Registry.h"
jmethodID PlugletInstance::initializeMID = NULL;
jmethodID PlugletInstance::startMID = NULL;
jmethodID PlugletInstance::stopMID = NULL;
jmethodID PlugletInstance::destroyMID = NULL;
jmethodID PlugletInstance::newStreamMID = NULL;
jmethodID PlugletInstance::setWindowMID = NULL;
jmethodID PlugletInstance::printMID = NULL;
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
NS_IMPL_ISUPPORTS(PlugletInstance, kIPluginInstanceIID);
PlugletInstance::PlugletInstance(jobject object) {
NS_INIT_REFCNT();
jthis = PlugletEngine::GetJNIEnv()->NewGlobalRef(object);
//nb check for null
peer = NULL;
view = new PlugletInstanceView();
Registry::SetPeer(jthis,(jlong)this);
}
PlugletInstance::~PlugletInstance() {
Registry::Remove(jthis);
PlugletEngine::GetJNIEnv()->DeleteGlobalRef(jthis);
NS_RELEASE(peer);
}
NS_METHOD PlugletInstance::HandleEvent(nsPluginEvent* event, PRBool* handled) {
//nb we do not need it under win32
return NS_OK;
}
NS_METHOD PlugletInstance::Initialize(nsIPluginInstancePeer* _peer) {
JNIEnv *env = PlugletEngine::GetJNIEnv();
if (!printMID) {
//nb check for null after each and every JNI call
jclass clazz = env->FindClass("org/mozilla/pluglet/PlugletInstance");
initializeMID = env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletInstancePeer;)V");
startMID = env->GetMethodID(clazz,"start","()V");
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/Frame;)V");
printMID = env->GetMethodID(clazz,"print","(Ljava/awt/print/PrinterJob;)V");
}
peer = _peer;
peer->AddRef();
jobject obj = PlugletInstancePeer::GetJObject(peer);
if (!obj) {
return NS_ERROR_FAILURE;
}
env->CallVoidMethod(jthis,initializeMID,obj);
return NS_OK;
}
NS_METHOD PlugletInstance::GetPeer(nsIPluginInstancePeer* *result) {
peer->AddRef();
*result = peer;
return NS_OK;
}
NS_METHOD PlugletInstance::Start(void) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
env->CallVoidMethod(jthis,startMID);
//nb check for JNI exception
return NS_OK;
}
NS_METHOD PlugletInstance::Stop(void) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
env->CallVoidMethod(jthis,stopMID);
//nb check for JNI exception
return NS_OK;
}
NS_METHOD PlugletInstance::Destroy(void) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
env->CallVoidMethod(jthis,destroyMID);
//nb check for JNI exception
return NS_OK;
}
NS_METHOD PlugletInstance::NewStream(nsIPluginStreamListener** listener) {
if(!listener) {
return NS_ERROR_FAILURE;
}
JNIEnv * env = PlugletEngine::GetJNIEnv();
jobject obj = env->CallObjectMethod(jthis,newStreamMID);
//nb check for JNI exception
if (obj) {
*listener = new PlugletStreamListener(obj);
(*listener)->AddRef();
}
return NS_OK;
}
NS_METHOD PlugletInstance::GetValue(nsPluginInstanceVariable variable, void *value) {
return NS_ERROR_FAILURE;
}
NS_METHOD PlugletInstance::SetWindow(nsPluginWindow* window) {
JNIEnv *env = PlugletEngine::GetJNIEnv();
if (view->SetWindow(window)) {
env->CallVoidMethod(jthis,setWindowMID,view->GetJObject());
}
return NS_OK;
}
NS_METHOD PlugletInstance::Print(nsPluginPrint* platformPrint) {
//nb
return NS_OK;
}

View File

@ -1,63 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (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 Original Code is mozilla.org code.
*
* 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.
*
* Contributor(s):
*/
#ifndef __PlugletInstance_h__
#define __PlugletInstance_h__
#include "nsplugin.h"
#include "jni.h"
#include "PlugletInstanceView.h"
class PlugletInstance : public nsIPluginInstance {
public:
NS_IMETHOD HandleEvent(nsPluginEvent* event, PRBool* handled);
NS_IMETHOD Initialize(nsIPluginInstancePeer* peer);
NS_IMETHOD GetPeer(nsIPluginInstancePeer* *result);
NS_IMETHOD Start(void);
NS_IMETHOD Stop(void);
NS_IMETHOD Destroy(void);
NS_IMETHOD NewStream(nsIPluginStreamListener** listener);
NS_IMETHOD SetWindow(nsPluginWindow* window);
NS_IMETHOD Print(nsPluginPrint* platformPrint);
NS_IMETHOD GetValue(nsPluginInstanceVariable variable, void *value);
NS_DECL_ISUPPORTS
PlugletInstance(jobject object);
virtual ~PlugletInstance(void);
private:
jobject jthis;
static jmethodID initializeMID;
static jmethodID startMID;
static jmethodID stopMID;
static jmethodID destroyMID;
static jmethodID newStreamMID;
static jmethodID setWindowMID;
static jmethodID printMID;
static jmethodID getValueMID;
nsIPluginInstancePeer *peer;
PlugletInstanceView *view;
};
#endif /* __PlugletInstance_h__ */

View File

@ -1,72 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (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 Original Code is mozilla.org code.
*
* 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.
*
* Contributor(s):
*/
#include"PlugletList.h"
PlugletList::PlugletList() {
head = tail = NULL;
}
PlugletList::~PlugletList() {
for(PlugletListNode * current=head;!current;delete current,current = current->next)
;
}
PlugletList::PlugletListNode::PlugletListNode(Pluglet *v,PlugletList::PlugletListNode *n) {
value = v; next = n;
}
void PlugletList::Add(Pluglet *pluglet) {
if (!pluglet) {
return;
}
if (!tail) {
head = tail = new PlugletListNode(pluglet);
} else {
tail->next = new PlugletListNode(pluglet);
if (tail->next) {
tail = tail->next;
}
}
}
PlugletListIterator * PlugletList::GetIterator(void) {
return new PlugletListIterator(this);
}
PlugletListIterator::PlugletListIterator(PlugletList *list) {
current = list->head;
}
Pluglet * PlugletListIterator::Get(void) {
Pluglet * result = NULL;
if (current) {
result = current->value;
}
return result;
}
Pluglet * PlugletListIterator::Next(void) {
Pluglet * result = NULL;
if (current) {
current = current->next;
result = Get();
}
return result;
}

View File

@ -59,7 +59,7 @@ void PlugletLoader::Initialize(void) {
clazz = NULL;
return;
}
getPlugletMID = env->GetStaticMethodID(clazz,"getPluglet","(Ljava/lang/String;)Lorg/mozilla/pluglet/Pluglet;");
getPlugletMID = env->GetStaticMethodID(clazz,"getPluglet","(Ljava/lang/String;)Lorg/mozilla/pluglet/PlugletFactory;");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
clazz = NULL;

View File

@ -19,15 +19,15 @@
* Contributor(s):
*/
#include "nsISupports.h"
#include "PlugletInstancePeer.h"
#include "PlugletPeer.h"
#include "PlugletEngine.h"
jclass PlugletInstancePeer::clazz = NULL;
jmethodID PlugletInstancePeer::initMID = NULL;
jclass PlugletPeer::clazz = NULL;
jmethodID PlugletPeer::initMID = NULL;
void PlugletInstancePeer::Initialize(void) {
void PlugletPeer::Initialize(void) {
JNIEnv * env = PlugletEngine::GetJNIEnv();
clazz = env->FindClass("org/mozilla/pluglet/mozilla/PlugletInstancePeerImpl");
clazz = env->FindClass("org/mozilla/pluglet/mozilla/PlugletPeerImpl");
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
clazz = NULL;
@ -43,7 +43,7 @@ void PlugletInstancePeer::Initialize(void) {
}
}
void PlugletInstancePeer::Destroy(void) {
void PlugletPeer::Destroy(void) {
//nb who gonna cal it?
JNIEnv * env = PlugletEngine::GetJNIEnv();
if(clazz) {
@ -51,7 +51,7 @@ void PlugletInstancePeer::Destroy(void) {
}
}
jobject PlugletInstancePeer::GetJObject(const nsIPluginInstancePeer *stream) {
jobject PlugletPeer::GetJObject(const nsIPluginInstancePeer *peer) {
jobject res = NULL;
JNIEnv *env = PlugletEngine::GetJNIEnv();
if(!clazz) {
@ -60,7 +60,7 @@ jobject PlugletInstancePeer::GetJObject(const nsIPluginInstancePeer *stream) {
return NULL;
}
}
res = env->NewObject(clazz,initMID,(jlong)stream);
res = env->NewObject(clazz,initMID,(jlong)peer);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
res = NULL;

View File

@ -18,12 +18,12 @@
*
* Contributor(s):
*/
#ifndef __PlugletInstancePeer_h__
#define __PlugletInstancePeer_h__
#ifndef __PlugletPeer_h__
#define __PlugletPeer_h__
#include "nsIPluginInstancePeer.h"
#include "jni.h"
class PlugletInstancePeer {
class PlugletPeer {
public:
static jobject GetJObject(const nsIPluginInstancePeer *instancePeer);
private:
@ -32,4 +32,4 @@ class PlugletInstancePeer {
static jclass clazz;
static jmethodID initMID;
};
#endif /* __PlugletInputStream_h__ */
#endif /* __PlugletPeer_h__ */

View File

@ -1,4 +1,4 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
@ -19,19 +19,19 @@
* Contributor(s):
*/
#include <windows.h>
#include "PlugletInstanceView.h"
#include "PlugletView.h"
#include "PlugletEngine.h"
jclass PlugletInstanceView::clazz = NULL;
jmethodID PlugletInstanceView::initMID = NULL;
jclass PlugletView::clazz = NULL;
jmethodID PlugletView::initMID = NULL;
PlugletInstanceView::PlugletInstanceView() {
PlugletView::PlugletView() {
hWND = NULL;
frame = NULL;
isCreated = FALSE;
}
void PlugletInstanceView::Initialize() {
void PlugletView::Initialize() {
JNIEnv *env = PlugletEngine::GetJNIEnv();
clazz = env->FindClass("sun/awt/windows/WEmbeddedFrame");
if (!clazz) {
@ -46,7 +46,7 @@ void PlugletInstanceView::Initialize() {
}
}
BOOLEAN PlugletInstanceView::SetWindow(nsPluginWindow* window) {
BOOLEAN PlugletView::SetWindow(nsPluginWindow* window) {
if (!window || !window->window) {
if (isCreated) {
isCreated = FALSE;
@ -78,7 +78,7 @@ BOOLEAN PlugletInstanceView::SetWindow(nsPluginWindow* window) {
return TRUE;
}
jobject PlugletInstanceView::GetJObject() {
jobject PlugletView::GetJObject() {
return frame;
}

View File

@ -18,15 +18,15 @@
*
* Contributor(s):
*/
#ifndef __PlugletInstanceView_h__
#define __PlugletInstanceView_h__
#ifndef __PlugletView_h__
#define __PlugletView_h__
#include <windows.h>
#include "nsplugindefs.h"
#include "jni.h"
class PlugletInstanceView {
class PlugletView {
public:
PlugletInstanceView(void);
PlugletView(void);
jobject GetJObject(void);
BOOLEAN SetWindow(nsPluginWindow* window);
private:

View File

@ -28,7 +28,7 @@ PlugletsDir::PlugletsDir(void) {
PlugletsDir::~PlugletsDir(void) {
if (list) {
for (PlugletListIterator *iter = list->GetIterator();iter->Get();delete iter->Get(),iter->Next())
for (ListIterator *iter = list->GetIterator();iter->Get();delete iter->Get(),iter->Next())
;
delete list;
}
@ -36,10 +36,10 @@ PlugletsDir::~PlugletsDir(void) {
void PlugletsDir::LoadPluglets() {
if (!list) {
list = new PlugletList();
list = new List();
char * path = PR_GetEnv("PLUGLET");
int pathLength = strlen(path);
Pluglet *pluglet;
PlugletFactory *plugletFactory;
nsFileSpec dir(path);
for (nsDirectoryIterator iter(dir,PR_TRUE); iter.Exists(); iter++) {
const nsFileSpec& file = iter;
@ -49,25 +49,25 @@ void PlugletsDir::LoadPluglets() {
|| strcmp(name+length - 4,".jar") ) {
continue;
}
if ( (pluglet = Pluglet::Load(name)) ) {
list->Add(pluglet);
if ( (plugletFactory = PlugletFactory::Load(name)) ) {
list->Add(plugletFactory);
}
}
}
}
nsresult PlugletsDir::GetPluglet(const char * mimeType, Pluglet **pluglet) {
if(!pluglet) {
nsresult PlugletsDir::GetPlugletFactory(const char * mimeType, PlugletFactory **plugletFactory) {
if(!plugletFactory) {
return NS_ERROR_NULL_POINTER;
}
*pluglet = NULL;
*plugletFactory = NULL;
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();
for (ListIterator *iter = list->GetIterator();iter->Get();iter->Next()) {
if(((PlugletFactory*)(iter->Get()))->Compare(mimeType)) {
*plugletFactory = (PlugletFactory*)iter->Get();
res = NS_OK;
break;
}

View File

@ -20,8 +20,8 @@
*/
#ifndef __PlugletsDir_h__
#define __PlugletsDir_h__
#include "Pluglet.h"
#include "PlugletList.h"
#include "PlugletFactory.h"
#include "List.h"
class PlugletsDir {
friend class PlugletsDirIterator;
@ -29,9 +29,9 @@ class PlugletsDir {
PlugletsDir(void);
~PlugletsDir(void);
void LoadPluglets();
nsresult GetPluglet(const char * mimeType,Pluglet **pluglet);
nsresult GetPlugletFactory(const char * mimeType,PlugletFactory **plugletFactory);
private:
PlugletList * list;
List * list;
};
#endif /* __PlugletsDir_h__ */

View File

@ -53,16 +53,16 @@ REQUIRES = java plug xpcom raptor
OBJS = \
.\$(OBJDIR)\Pluglet.obj \
.\$(OBJDIR)\PlugletEngine.obj \
.\$(OBJDIR)\PlugletList.obj \
.\$(OBJDIR)\List.obj \
.\$(OBJDIR)\PlugletLoader.obj \
.\$(OBJDIR)\PlugletsDir.obj \
.\$(OBJDIR)\PlugletInstance.obj \
.\$(OBJDIR)\PlugletFactory.obj \
.\$(OBJDIR)\PlugletStreamListener.obj \
.\$(OBJDIR)\PlugletStreamInfo.obj \
.\$(OBJDIR)\PlugletInstancePeer.obj \
.\$(OBJDIR)\PlugletPeer.obj \
.\$(OBJDIR)\PlugletManager.obj \
.\$(OBJDIR)\PlugletInputStream.obj \
.\$(OBJDIR)\PlugletInstanceView.obj \
.\$(OBJDIR)\PlugletView.obj \
!ifndef OJI_DISABLE
.\$(OBJDIR)\PlugletSecurityContext.obj \
!endif

View File

@ -25,7 +25,7 @@ import java.awt.event.*;
import java.awt.print.*;
import java.io.*;
public class test implements Pluglet {
public class test implements PlugletFactory {
public test() {
org.mozilla.util.Debug.print("--test.test()\n");
}
@ -34,7 +34,7 @@ public class test implements Pluglet {
* allows different impelementations to be created depending on
* the specified MIME type.
*/
public PlugletInstance createPlugletInstance(String mimeType) {
public Pluglet createPluglet(String mimeType) {
org.mozilla.util.Debug.print("--test.createPlugletInstance\n");
return new TestInstance();
}
@ -54,11 +54,11 @@ public class test implements Pluglet {
}
}
class TestInstance implements PlugletInstance {
class TestInstance implements Pluglet {
Panel panel;
Button button;
List list;
PlugletInstancePeer peer;
PlugletPeer peer;
public TestInstance() {
org.mozilla.util.Debug.print("--TestInstance.TestInstance() \n");
panel = new Panel();
@ -89,7 +89,7 @@ class TestInstance implements PlugletInstance {
* @param peer the corresponding pluglet instance peer
*/
public void initialize(PlugletInstancePeer peer) {
public void initialize(PlugletPeer peer) {
this.peer = peer;
org.mozilla.util.Debug.print("--TestInstance.initialize\n");
peer.showStatus("Hello world");
@ -131,6 +131,7 @@ class TestInstance implements PlugletInstance {
* window containing this page in the history is being closed.
*/
public void destroy() {
org.mozilla.util.Debug.print("--TestInstance.destroy\n");
}
/**
* Called to tell the pluglet that the initial src/data stream is