Index: ChangeLog
===================================================================
RCS file: /cvsroot/gcjwebplugin/gcjwebplugin/ChangeLog,v
retrieving revision 1.58
diff -u -r1.58 ChangeLog
--- ChangeLog 6 Aug 2003 02:27:06 -0000 1.58
+++ ChangeLog 15 Sep 2003 02:40:57 -0000
@@ -1,3 +1,20 @@
+2003-09-13 Thomas Fitzsimmons
+
+ * configure.ac: Add check for GLib package.
+ (AC_OUTPUT): Add getopt Makefile.
+ * src/GCJPluginInstance.cc: Replace JNI implementation with
+ stub implementation that spawns appletviewer process.
+ * src/gcjwebplugin.cc: Likewise.
+ * src/GCJPluginInstance.h: Replace JNI object pointers with
+ pointers to applet tag information.
+ * src/Makefile.am: Add appletviewer target. Add GLib flags to
+ libgcjwebplugin compile and link lines.
+ * src/gnu/Makefile.am (SUBDIRS): Add getopt.
+ * src/gnu/applet/AppletLoader.java: Replace EmbeddedWindow
+ declarations with Frame declarations.
+ * src/gnu/applet/AppletViewer.java: New file.
+ * src/gnu/getopt: New directory.
+
2003-08-05 Thomas Fitzsimmons
* README.Mozilla: Add section on debugging gcjwebplugin in
Index: configure.ac
===================================================================
RCS file: /cvsroot/gcjwebplugin/gcjwebplugin/configure.ac,v
retrieving revision 1.13
diff -u -r1.13 configure.ac
--- configure.ac 30 Jul 2003 05:12:28 -0000 1.13
+++ configure.ac 15 Sep 2003 02:40:57 -0000
@@ -25,8 +25,18 @@
LDFLAGS="$LDFLAGS $LIBGCJ_LDFLAGS"
],
[
- AC_MSG_ERROR([Couldn't find libgcj library!])
+ AC_MSG_ERROR([Could not locate libgcj.])
])
+
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.0,
+ [
+ CXXFLAGS="$CXXFLAGS $GLIB_CFLAGS"
+ LDFLAGS="$LDFLAGS $GLIB_LDFLAGS"
+ ],
+ [
+ AC_MSG_ERROR([Could not locate GLib.])
+ ])
+
# For some reason, with automake-1.6 these variables are not being
# substituted properly by the PKG_CHECK_MODULES macro. So substitute
# them manually.
@@ -60,4 +70,5 @@
src/Makefile \
src/gnu/Makefile \
src/gnu/applet/Makefile \
+ src/gnu/getopt/Makefile \
)
Index: src/GCJPluginInstance.cc
===================================================================
RCS file: /cvsroot/gcjwebplugin/gcjwebplugin/src/GCJPluginInstance.cc,v
retrieving revision 1.13
diff -u -r1.13 GCJPluginInstance.cc
--- src/GCJPluginInstance.cc 29 Jul 2003 04:20:20 -0000 1.13
+++ src/GCJPluginInstance.cc 15 Sep 2003 02:40:57 -0000
@@ -35,6 +35,7 @@
#include
+#include
#include
#include
@@ -43,7 +44,6 @@
#include
#include "GCJPluginInstance.h"
-#include "jniHelp.h"
#include "pluginDebug.h"
NS_IMPL_ISUPPORTS1 (GCJPluginInstance, nsIJVMPluginInstance)
@@ -53,10 +53,6 @@
GCJPluginInstance::GCJPluginInstance (GCJPluginFactory* factory, JNIEnv* jniEnv)
: m_peer (NULL)
- , m_jniEnv (jniEnv)
- , m_applet (NULL)
- , m_appletLoader (NULL)
- , m_embeddedWindow (NULL)
{
PLUGIN_DEBUG ("GCJPluginInstance::GCJPluginInstance\n");
}
@@ -74,11 +70,6 @@
m_peer = peer;
m_peer->AddRef ();
- jstring code;
- jstring codeBase;
- jstring documentBase;
- jstring archive;
-
nsresult result;
nsIJVMPluginTagInfo* pluginTagInfo;
nsIPluginTagInfo2* pluginTagInfo2;
@@ -89,118 +80,17 @@
if (NS_SUCCEEDED (result))
{
- const char* tmp_code = NULL;
- const char* tmp_codeBase = NULL;
- const char* tmp_documentBase = NULL;
- const char* tmp_archive = NULL;
-
- PRUint16 numParams;
- const char* const* tmp_paramNames = NULL;
- const char* const* tmp_paramValues = NULL;
-
- // Extract plugin data got from web browser
- //
- pluginTagInfo->GetCode (&tmp_code);
- pluginTagInfo->GetCodeBase (&tmp_codeBase);
- pluginTagInfo->GetArchive (&tmp_archive);
- pluginTagInfo2->GetDocumentBase (&tmp_documentBase);
- pluginTagInfo2->GetParameters (numParams, tmp_paramNames, tmp_paramValues);
-
- if (tmp_code != NULL)
- code = m_jniEnv->NewStringUTF (tmp_code);
-
- if (tmp_codeBase != NULL)
- codeBase = m_jniEnv->NewStringUTF (tmp_codeBase);
-
- if (tmp_documentBase != NULL)
- documentBase = m_jniEnv->NewStringUTF (tmp_documentBase);
-
- if (tmp_archive != NULL)
- archive = m_jniEnv->NewStringUTF (tmp_archive);
-
- // Get references to classes and methods via JNI
- //
- jclass appletLoader_cl = m_jniEnv->FindClass ("gnu/applet/AppletLoader");
- assert (appletLoader_cl != NULL);
-
- jmethodID appletLoader_init = m_jniEnv->GetMethodID (appletLoader_cl, "", "()V");
- assert (appletLoader_init != NULL);
-
- jmethodID appletLoader_setCode = m_jniEnv->GetMethodID (appletLoader_cl, "setCode", "(Ljava.lang.String;)V");
- assert (appletLoader_setCode != NULL);
-
- jmethodID appletLoader_setCodeBase = m_jniEnv->GetMethodID (appletLoader_cl, "setCodeBase", "(Ljava.lang.String;)V");
- assert (appletLoader_setCodeBase != NULL);
-
- jmethodID appletLoader_setDocumentBase = m_jniEnv->GetMethodID (appletLoader_cl, "setDocumentBase", "(Ljava.lang.String;)V");
- assert (appletLoader_setDocumentBase != NULL);
-
- jmethodID appletLoader_setArchive = m_jniEnv->GetMethodID (appletLoader_cl, "setArchive", "(Ljava.lang.String;)V");
- assert (appletLoader_setArchive != NULL);
-
- jmethodID appletLoader_addParameter = m_jniEnv->GetMethodID (appletLoader_cl, "addParameter", "(Ljava.lang.String;Ljava.lang.String;)V");
- assert (appletLoader_addParameter != NULL);
-
- jmethodID appletLoader_loadApplet = m_jniEnv->GetMethodID (appletLoader_cl, "loadApplet", "()Ljava.applet.Applet;");
- assert (appletLoader_loadApplet != NULL);
-
- // Load applet
- //
- PLUGIN_DEBUG ("GCJPluginInstance::Initialize: AppletLoader.\n");
- JNI_NewObject0 (m_jniEnv, appletLoader_cl, appletLoader_init, m_appletLoader);
-
- if (tmp_code != NULL)
- {
- PLUGIN_DEBUG ("GCJPluginInstance::Initialize: AppletLoader.setCode\n");
- JNI_CallVoidMethod1 (m_jniEnv, m_appletLoader, appletLoader_setCode, code);
- }
-
- if (tmp_codeBase != NULL)
- {
- PLUGIN_DEBUG ("GCJPluginInstance::Initialize: AppletLoader.setCodeBase\n");
- JNI_CallVoidMethod1 (m_jniEnv, m_appletLoader, appletLoader_setCodeBase, codeBase);
- }
-
- if (tmp_documentBase != NULL)
- {
- PLUGIN_DEBUG ("GCJPluginInstance::Initialize: AppletLoader.setDocumentBase\n");
- JNI_CallVoidMethod1 (m_jniEnv, m_appletLoader, appletLoader_setDocumentBase, documentBase);
- }
-
- if (tmp_archive != NULL)
- {
- PLUGIN_DEBUG ("GCJPluginInstance::Initialize: AppletLoader.setArchive\n");
- JNI_CallVoidMethod1 (m_jniEnv, m_appletLoader, appletLoader_setArchive, archive);
- }
-
- for (int count = 0; count < numParams; count++)
- {
- PLUGIN_DEBUG ("GCJPluginInstance::Initialize: AppletLoader.addParameter\n");
- JNI_CallVoidMethod2 (m_jniEnv, m_appletLoader, appletLoader_addParameter,
- m_jniEnv->NewStringUTF (tmp_paramNames [count]),
- m_jniEnv->NewStringUTF (tmp_paramValues [count]));
- }
-
- PLUGIN_DEBUG ("GCJPluginInstance::Initialize: AppletLoader.loadApplet\n");
- JNI_CallObjectMethod0 (m_jniEnv, m_appletLoader, appletLoader_loadApplet, m_applet);
+ // Extract tag data from web browser.
+ pluginTagInfo->GetCode (&code);
+ pluginTagInfo->GetCodeBase (&codebase);
+ pluginTagInfo->GetArchive (&archive);
+ pluginTagInfo2->GetDocumentBase (&documentbase);
+ pluginTagInfo2->GetParameters (numParams, paramNames, paramValues);
}
pluginTagInfo->Release();
pluginTagInfo2->Release();
- if (m_applet == NULL)
- {
- PLUGIN_DEBUG ("GCJPluginInstance::Initialize: Applet couldn't be loaded\n");
- return NS_ERROR_FAILURE;
- }
-
- jclass applet_cl;
- jmethodID applet_init;
-
- JNI_GetObjectClass (m_jniEnv, m_applet, applet_cl);
- JNI_GetMethodID (m_jniEnv, applet_cl, "init", "()V", applet_init);
- JNI_CallVoidMethod0 (m_jniEnv, m_applet, applet_init);
-
return NS_OK;
}
@@ -218,16 +108,8 @@
{
PLUGIN_DEBUG ("GCJPluginInstance::Start\n");
- if (m_applet != NULL)
- {
- jclass applet_cl;
- jmethodID applet_start;
-
- JNI_GetObjectClass (m_jniEnv, m_applet, applet_cl);
- JNI_GetMethodID (m_jniEnv, applet_cl, "start", "()V", applet_start);
- JNI_CallVoidMethod0 (m_jniEnv, m_applet, applet_start);
- }
-
+ // FIXME: call applet's start method via protocol
+
return NS_OK;
}
@@ -236,16 +118,8 @@
{
PLUGIN_DEBUG ("GCJPluginInstance::Stop\n");
- if (m_applet != NULL)
- {
- jclass applet_cl;
- jmethodID applet_stop;
-
- JNI_GetObjectClass (m_jniEnv, m_applet, applet_cl);
- JNI_GetMethodID (m_jniEnv, applet_cl, "stop", "()V", applet_stop);
- JNI_CallVoidMethod0 (m_jniEnv, m_applet, applet_stop);
- }
-
+ // FIXME: call applet's stop method via protocol
+
return NS_OK;
}
@@ -253,16 +127,8 @@
GCJPluginInstance::Destroy ()
{
PLUGIN_DEBUG ("GCJPluginInstance::Destroy\n");
-
- if (m_applet != NULL)
- {
- jclass applet_cl;
- jmethodID applet_destroy;
-
- JNI_GetObjectClass (m_jniEnv, m_applet, applet_cl);
- JNI_GetMethodID (m_jniEnv, applet_cl, "destroy", "()V", applet_destroy);
- JNI_CallVoidMethod0 (m_jniEnv, m_applet, applet_destroy);
- }
+
+ // FIXME: kill spawned process
return NS_OK;
}
@@ -272,58 +138,29 @@
{
PLUGIN_DEBUG ("GCJPluginInstance::SetWindow\n");
- if (m_applet != NULL)
- {
- // First, create an embedded window.
- PLUGIN_DEBUG (" Finding EmbeddedWindow methods...\n");
-
- jclass embeddedWindow_cl;
- jmethodID embeddedWindow_init;
- jmethodID embeddedWindow_setSize;
-
- JNI_FindClass (m_jniEnv, "gnu/java/awt/EmbeddedWindow",
- embeddedWindow_cl);
- JNI_GetMethodID (m_jniEnv, embeddedWindow_cl, "", "(I)V",
- embeddedWindow_init);
- JNI_GetMethodID (m_jniEnv, embeddedWindow_cl, "setSize", "(II)V",
- embeddedWindow_setSize);
-
- PLUGIN_DEBUG2 (" Initializing EmbeddedWindow: %d...\n", (unsigned long) window->window);
-
- JNI_NewObject1 (m_jniEnv, embeddedWindow_cl, embeddedWindow_init,
- (jint) window->window, m_embeddedWindow);
-
- PLUGIN_DEBUG2 (" Setting EmbeddedWindow size: width %d...\n", (unsigned long) window->width);
- PLUGIN_DEBUG2 (" Setting EmbeddedWindow size: height %d...\n", (unsigned long) window->height);
-
- JNI_CallVoidMethod2 (m_jniEnv, m_embeddedWindow, embeddedWindow_setSize,
- (jint) (window->width), (jint) (window->height));
-
- PLUGIN_DEBUG (" Finding AppletLoader...\n");
-
- /* Now add the applet to this window. */
- jclass appletLoader_cl;
- jmethodID appletLoader_setEmbeddedWindow;
-
- JNI_FindClass (m_jniEnv, "gnu/applet/AppletLoader", appletLoader_cl);
-
- PLUGIN_DEBUG (" Finding setEmbeddedWindow...\n");
-
- JNI_GetMethodID (m_jniEnv, appletLoader_cl, "setEmbeddedWindow",
- "(Lgnu.java.awt.EmbeddedWindow;)V", appletLoader_setEmbeddedWindow);
-
- PLUGIN_DEBUG (" Calling setEmbeddedWindow...\n");
-
- if (!m_appletLoader)
- PLUGIN_DEBUG (" no m_appletLoader!...\n");
-
- if (!m_embeddedWindow)
- PLUGIN_DEBUG (" no m_embeddedWindow!...\n");
-
- JNI_CallVoidMethod1 (m_jniEnv, m_appletLoader,
- appletLoader_setEmbeddedWindow, m_embeddedWindow);
-
- }
+ width = window->width;
+ height = window->height;
+ xid = (int)(window->window);
+
+ // FIXME: select only initialized arguments
+ gchar *cmd_line = g_strdup_printf ("/home/fitzsim/build/plugin-bld/src/appletviewer "
+ "--code=%s "
+ "--archive=%s "
+ "--width=%d "
+ "--height=%d "
+ "--xid=%d ",
+ code,
+ archive,
+ width,
+ height,
+ xid);
+
+ printf ("Running: %s\n", cmd_line);
+ GError *err;
+
+ // FIXME: open input and output pipes
+ if (!g_spawn_command_line_async (cmd_line, &err))
+ fprintf (stderr, "SetWindow error: %s\n", err->message);
return NS_OK;
}
@@ -393,7 +230,6 @@
{
PLUGIN_DEBUG ("GCJPluginInstance::GetJavaObject\n");
- (*result) = (jobject) m_applet;
return NS_OK;
}
Index: src/GCJPluginInstance.h
===================================================================
RCS file: /cvsroot/gcjwebplugin/gcjwebplugin/src/GCJPluginInstance.h,v
retrieving revision 1.4
diff -u -r1.4 GCJPluginInstance.h
--- src/GCJPluginInstance.h 27 Jul 2003 19:03:22 -0000 1.4
+++ src/GCJPluginInstance.h 15 Sep 2003 02:40:57 -0000
@@ -66,11 +66,17 @@
private:
nsIPluginInstancePeer* m_peer;
- JNIEnv* m_jniEnv;
- int m_windowCreated;
- jobject m_applet;
- jobject m_appletLoader;
- jobject m_embeddedWindow;
+ const char* code;
+ const char* codebase;
+ const char* archive;
+ const char* documentbase;
+ PRUint16 numParams;
+ const char* const* paramNames;
+ const char* const* paramValues;
+ int width;
+ int height;
+ int xid;
+
};
#endif // __GCJPLUGININSTANCE_H__
Index: src/Makefile.am
===================================================================
RCS file: /cvsroot/gcjwebplugin/gcjwebplugin/src/Makefile.am,v
retrieving revision 1.14
diff -u -r1.14 Makefile.am
--- src/Makefile.am 30 Jul 2003 05:14:24 -0000 1.14
+++ src/Makefile.am 15 Sep 2003 02:40:57 -0000
@@ -1,6 +1,5 @@
MOZILLA_CFLAGS = `$(MOZILLA_CONFIG) --cflags caps java liveconnect plugin oji xpcom`
-
SUBDIRS = gnu
EXTRA_DIST = \
@@ -13,6 +12,14 @@
pluginDebug.h \
oji.h
+noinst_PROGRAMS = appletviewer
+
+appletviewer_SOURCES = gnu/applet/AppletViewer.java
+appletviewer_LDADD = gnu/applet/libgnuapplet.la gnu/getopt/libgnugetopt.la
+appletviewer_GCJFLAGS = --classpath $(top_srcdir)/src $(LIBGCJ_CFLAGS)
+appletviewer_LDFLAGS = \
+ --main=gnu.applet.AppletViewer \
+ $(LIBGCJ_LIBS)
lib_LTLIBRARIES = libgcjwebplugin.la
@@ -32,11 +39,12 @@
libgcjwebplugin_la_DEPENDENCIES = gnu/applet/libgnuapplet.la
-libgcjwebplugin_la_CFLAGS = $(MOZILLA_CFLAGS) $(LIBGCJ_CFLAGS)
+libgcjwebplugin_la_CFLAGS = $(MOZILLA_CFLAGS) $(LIBGCJ_CFLAGS) $(GLIB_CFLAGS)
-libgcjwebplugin_la_CXXFLAGS = $(MOZILLA_CFLAGS) $(LIBGCJ_CFLAGS)
+libgcjwebplugin_la_CXXFLAGS = $(MOZILLA_CFLAGS) $(LIBGCJ_CFLAGS) $(GLIB_CFLAGS)
libgcjwebplugin_la_LDFLAGS = \
+ $(GLIB_LIBS) \
$(LIBGCJ_LIBS) \
$(top_builddir)/src/gnu/applet/libgnuapplet.la
Index: src/gcjwebplugin.cc
===================================================================
RCS file: /cvsroot/gcjwebplugin/gcjwebplugin/src/gcjwebplugin.cc,v
retrieving revision 1.2
diff -u -r1.2 gcjwebplugin.cc
--- src/gcjwebplugin.cc 30 Jul 2003 05:40:36 -0000 1.2
+++ src/gcjwebplugin.cc 15 Sep 2003 02:40:57 -0000
@@ -36,34 +36,33 @@
#include
#include
-
-#include
-
-#include "jniHelp.h"
+#include
#include "config.h"
#define PLUGIN_NAME "GCJ web browser plugin " PACKAGE_VERSION
#define PLUGIN_DESC "GCJ web browser plugin executes Java applets in Mozilla and other web browsers"
#define PLUGIN_MIME_TYPE "application/x-java-applet"
-#define PLUGIN_MIME_DESC "application/x-java-applet::Java(tm) Plug-in"
+#define PLUGIN_MIME_DESC "application/x-java-applet:class,jar:GCJ Java Plugin"
+#define PLUGIN_FILE_EXTS "class,jar"
-#define PLUGIN_DEBUG(arg) ;
+#define PLUGIN_DEBUG(arg) printf("%s", arg)
struct GCJPluginData
{
- JNIEnv* jniEnv;
-
- jclass embeddedWindow_class;
- jclass applet_class;
-
- jobject embeddedWindow;
- jobject applet;
+ char *code;
+ char *codebase;
+ char *archive;
+ char *documentbase;
+ char *parameters;
+ int width;
+ int height;
+ int xid;
};
char*
NPP_GetMIMEDescription()
{
- PLUGIN_DEBUG ("NPP_GetMimeDexcription\n");
+ PLUGIN_DEBUG ("NPP_GetMimeDescription\n");
return PLUGIN_MIME_DESC;
}
@@ -77,11 +76,23 @@
switch (variable)
{
- case NPPVpluginNameString: // plugin name
- case NPPVpluginDescriptionString: // plugin description
+ case NPPVpluginNameString:
+ case NPPVpluginDescriptionString:
*((char**) value) = "GCJ web browser plugin " VERSION;
break;
+ case NPPVpluginWindowBool:
+ *(PRBool*) value = PR_FALSE;
+ break;
+
+ case NPPVpluginTransparentBool:
+ *(PRBool*) value = PR_FALSE;
+ break;
+
+ case NPPVpluginNeedsXEmbed:
+ *(PRBool*) value = PR_TRUE;
+ break;
+
default:
result = NPERR_GENERIC_ERROR;
break;
@@ -118,22 +129,30 @@
if (!data)
return NPERR_OUT_OF_MEMORY_ERROR;
- data->jniEnv = NULL;
- data->applet_class = NULL;
- data->embeddedWindow = NULL;
- data->applet = NULL;
-
- JNI_FindClass (data->jniEnv, "gnu/java/awt/EmbeddedWindow",
- data->embeddedWindow_class);
-
- jmethodID embeddedWindow_init;
- JNI_GetMethodID (data->jniEnv, data->embeddedWindow_class, "", "(I)V", embeddedWindow_init);
+ for (int i = 0; i < argc; i++)
+ {
+ // FIXME: Use glib functions here.
+ if (!strcmp (argn[i], "code"))
+ data->code = argv[i];
+ else if (!strcmp (argn[i], "codebase"))
+ data->codebase = argv[i];
+ else if (!strcmp (argn[i], "archive"))
+ data->archive = argv[i];
+ else if (!strcmp (argn[i], "documentbase"))
+ data->documentbase = argv[i];
+ else if (!strcmp (argn[i], "parameters"))
+ // FIXME: need to handle multiple params
+ data->documentbase = argv[i];
+ else if (!strcmp (argn[i], "width"))
+ data->width = atoi (argv[i]);
+ else if (!strcmp (argn[i], "height"))
+ data->width = atoi (argv[i]);
+ else
+ printf ("GCJWebPlugin: unrecognized tag\n");
+ }
- int window_id = 0;
- JNI_NewObject1 (data->jniEnv, data->embeddedWindow_class, embeddedWindow_init, window_id, data->embeddedWindow);
-
instance->pdata = data;
-
+
return NPERR_GENERIC_ERROR;
}
@@ -154,12 +173,9 @@
jmethodID embeddedWindow_init;
GCJPluginData* data = (GCJPluginData*) instance->pdata;
-
- JNI_GetMethodID (data->jniEnv, data->embeddedWindow_class, "", "(I)V",
- embeddedWindow_init);
- JNI_NewObject1 (data->jniEnv, data->embeddedWindow_class, embeddedWindow_init,
- (jint) window->window, data->embeddedWindow);
-
+
+ data->xid = (int) window->window;
+
return NPERR_NO_ERROR;
}
Index: src/gnu/Makefile.am
===================================================================
RCS file: /cvsroot/gcjwebplugin/gcjwebplugin/src/gnu/Makefile.am,v
retrieving revision 1.1
diff -u -r1.1 Makefile.am
--- src/gnu/Makefile.am 8 Jul 2003 08:26:25 -0000 1.1
+++ src/gnu/Makefile.am 15 Sep 2003 02:40:57 -0000
@@ -1 +1 @@
-SUBDIRS = applet
+SUBDIRS = applet getopt
Index: src/gnu/applet/AppletLoader.java
===================================================================
RCS file: /cvsroot/gcjwebplugin/gcjwebplugin/src/gnu/applet/AppletLoader.java,v
retrieving revision 1.5
diff -u -r1.5 AppletLoader.java
--- src/gnu/applet/AppletLoader.java 27 Jul 2003 19:03:22 -0000 1.5
+++ src/gnu/applet/AppletLoader.java 15 Sep 2003 02:40:57 -0000
@@ -41,7 +41,7 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Hashtable;
-import gnu.java.awt.EmbeddedWindow;
+import java.awt.Frame;
import java.awt.GridLayout;
public class AppletLoader
@@ -84,14 +84,14 @@
private String archive;
private Hashtable params = new Hashtable();
private Applet applet;
- private EmbeddedWindow window;
+ private Frame window;
public AppletLoader()
{
// Do nothing here.
}
- public void setEmbeddedWindow (EmbeddedWindow window)
+ public void setFrame (Frame window)
{
this.window = window;
if (applet != null)
Index: src/gnu/applet/AppletViewer.java
===================================================================
RCS file: src/gnu/applet/AppletViewer.java
diff -N src/gnu/applet/AppletViewer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/gnu/applet/AppletViewer.java 15 Sep 2003 02:40:57 -0000
@@ -0,0 +1,173 @@
+/* gcjwebplugin - Webbrowser plugin to execute Java (tm) applets.
+ Copyright (C) 2003 Thomas Fitzsimmons
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.applet;
+
+import java.applet.Applet;
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+import gnu.java.awt.EmbeddedWindow;
+import java.awt.Frame;
+
+public class AppletViewer extends Frame
+{
+ String code;
+ String codebase;
+ String archive;
+ String documentbase;
+ String parameters;
+ int width = 200;
+ int height = 200;
+ int xid;
+ Frame frame;
+ Applet applet;
+
+ AppletLoader loader = new AppletLoader();
+
+ AppletViewer ()
+ {
+ }
+
+ void loadApplet ()
+ {
+ if (code != null)
+ loader.setCode (code);
+ if (codebase != null)
+ loader.setCodeBase (codebase);
+ if (archive != null)
+ loader.setArchive (archive);
+ if (documentbase != null)
+ loader.setDocumentBase (documentbase);
+ applet = loader.loadApplet();
+ applet.init();
+ }
+
+ void showApplet ()
+ {
+ if (frame != null)
+ {
+ System.out.println ("AppletViewer: showing applet");
+ loader.setFrame (frame);
+ frame.setSize(width,height);
+ frame.show();
+ }
+ applet.start();
+ }
+
+ void parseArgs (String [] args)
+ {
+ LongOpt[] longOptions = new LongOpt[]
+ {
+ new LongOpt ("code", LongOpt.REQUIRED_ARGUMENT, null, 0),
+ new LongOpt ("codebase", LongOpt.REQUIRED_ARGUMENT, null, 0),
+ new LongOpt ("archive", LongOpt.REQUIRED_ARGUMENT, null, 0),
+ new LongOpt ("documentbase", LongOpt.REQUIRED_ARGUMENT, null, 0),
+ new LongOpt ("parameters", LongOpt.REQUIRED_ARGUMENT, null, 0),
+ new LongOpt ("width", LongOpt.REQUIRED_ARGUMENT, null, 0),
+ new LongOpt ("height", LongOpt.REQUIRED_ARGUMENT, null, 0),
+ new LongOpt ("xid", LongOpt.REQUIRED_ARGUMENT, null, 0),
+ };
+
+ int optVal;
+ String arg;
+ int longIndex;
+
+ Getopt opts = new Getopt("appletviewer", args, "", longOptions);
+
+ while ((optVal = opts.getopt()) != -1)
+ {
+ if (optVal == 0)
+ {
+ longIndex = opts.getLongind();
+ switch (longIndex)
+ {
+ case 0:
+ code = opts.getOptarg();
+ break;
+ case 1:
+ codebase = opts.getOptarg();
+ break;
+ case 2:
+ archive = opts.getOptarg();
+ break;
+ case 3:
+ documentbase = opts.getOptarg();
+ break;
+ case 4:
+ // FIXME: Handle multiple parameters.
+ parameters = opts.getOptarg();
+ break;
+ case 5:
+ width = Integer.parseInt(opts.getOptarg());
+ break;
+ case 6:
+ height = Integer.parseInt(opts.getOptarg());
+ break;
+ case 7:
+ xid = Integer.parseInt(opts.getOptarg());
+
+ break;
+ }
+ }
+ }
+ if (xid != 0)
+ {
+ System.out.println ("AppletViewer: plugin mode: xid = " + xid);
+ frame = new EmbeddedWindow (xid);
+ }
+ else
+ {
+ System.out.println ("AppletViewer: standalone mode");
+ frame = this;
+ }
+
+ System.out.println ("AppletViewer: code: " + code + "\n" +
+ "codebase: " + codebase + "\n" +
+ "archive: " + archive + "\n" +
+ "documentbase: " + documentbase + "\n" +
+ "parameters: " + parameters + "\n" +
+ "width: " + width + "\n" +
+ "height: " + height + "\n");
+ }
+
+ public static void main (String[] args)
+ {
+ AppletViewer viewer = new AppletViewer ();
+ viewer.parseArgs(args);
+ viewer.loadApplet();
+ viewer.showApplet();
+ }
+}