gcjwebplugin-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcjwebplugin-devel] Patch: FYI: finish gcjwebplugin.cc


From: Thomas Fitzsimmons
Subject: [Gcjwebplugin-devel] Patch: FYI: finish gcjwebplugin.cc
Date: Tue, 28 Mar 2006 06:29:43 -0500

Hi,

I audited gcjwebplugin.cc to make it more robust against failures.  I
cleaned up our data allocation and destruction patterns and installed
SIGHUP handlers on the pipes.  While I was at it I added showDocument
and showStatus support.

With this patch I can't make the browser crash when going between applet
pages.  The worst scenario is a leftover gcjappletviewer process and
leftover pipes in /tmp.  But gcjwebplugin will no longer crash the
browser.

I turned on debugging support unconditionally.  There's no harm in this
since Firefox suppresses plugin output unless it is run with -g.  The
benefits are easier debugging and better bug reports.

Some of the headers gcjwebplugin.cc shared with the OJI plugin seemed
superfluous.  I included the defines inline in gcjwebplugin.cc so it is
now one self-contained file.  The headers still exist but in the OJI
directory.

I now consider gcjwebplugin.cc complete and ready to be merged into GNU
Classpath.  The patch is attached, tested with make distcheck and by
manually visiting web pages.

Tom

2006-03-28  Thomas Fitzsimmons  <address@hidden>

        * Makefile.am (libgcjwebplugin_la_CFLAGS): Remove variable.
        (libgcjwebplugin_la_CXXFLAGS): Add -Wall and -D for
        GCJAPPLETVIEWER_EXECUTABLE.
        (check_PROGRAMS): Remove test.cc.
        (EXTRA_DIST): Include pluginDebug.h, pluginMeta.h and jniHelp.h.
        * configure.ac: Comment out GCJWEBPLUGIN_ENABLE_DEBUG.  Remove
        GCJAPPLETVIEWER_EXECUTABLE define.
        * src/gcjwebplugin.cc: Refactor.  Audit for memory
        allocation/deallocation.  Enable debugging unconditionally.
        Implement showDocument and showStatus.  Watch pipes for SIGHUP.
        * src/jniHelp.h: Move to ...
        * src/gnu/gcjwebplugin/oji/jniHelp.h: New file.
        * src/pluginDebug.h: Move to ...
        * src/gnu/gcjwebplugin/oji/pluginDebug.h: New file.
        * src/pluginMeta.h: Move to ...
        * src/gnu/gcjwebplugin/oji/pluginMeta.h: New file.
        * src/test.cc: Remove file.
        * src/gnu/gcjwebplugin/PluginAppletContext.java (showDocument):
        Implement.
        (showStatus): Likewise.
        * src/gnu/gcjwebplugin/PluginAppletViewer.java (start): Rename xid
        "handle".
        * src/gnu/gcjwebplugin/UserConfiguration.java (showJavaConsole):
        Return false.

Index: Makefile.am
===================================================================
RCS file: /sources/gcjwebplugin/gcjwebplugin/Makefile.am,v
retrieving revision 1.18
diff -u -r1.18 Makefile.am
--- Makefile.am 15 Feb 2006 07:10:53 -0000      1.18
+++ Makefile.am 28 Mar 2006 11:11:51 -0000
@@ -129,8 +129,9 @@
 
 libgcjwebplugin_la_SOURCES = src/gcjwebplugin.cc
 
-libgcjwebplugin_la_CFLAGS = $(MOZILLA_CFLAGS) $(GLIB_CFLAGS) $(LIBGCJ_CFLAGS)
-libgcjwebplugin_la_CXXFLAGS = $(MOZILLA_CFLAGS) $(GLIB_CFLAGS) $(LIBGCJ_CFLAGS)
+libgcjwebplugin_la_CXXFLAGS = \
+       -Wall -DGCJAPPLETVIEWER_EXECUTABLE="\"$(bindir)/gcjappletviewer\"" \
+       $(MOZILLA_CFLAGS) $(GLIB_CFLAGS) $(LIBGCJ_CFLAGS)
 
 libgcjwebplugin_la_LDFLAGS = -avoid-version \
        $(GLIB_LIBS) \
@@ -143,12 +144,6 @@
 uninstall-libLTLIBRARIES:
        rm -f $(DESTDIR)@PLUGIN_DIR@/libgcjwebplugin.so
 
-check_PROGRAMS = test
-
-test_SOURCES = src/test.cc
-test_CXXFLAGS = $(MOZILLA_CFLAGS)
-test_LDFLAGS = -lgcjwebplugin
-
 MESSAGE_BUNDLE_SRCS = \
        $(srcdir)/src/gnu/getopt/MessagesBundle.properties \
        $(srcdir)/src/gnu/getopt/MessagesBundle_cs.properties \
@@ -248,10 +243,11 @@
        src/gnu/gcjwebplugin/oji/GCJPluginFactory.h \
        src/gnu/gcjwebplugin/oji/GCJPluginInstance.h \
        src/gnu/gcjwebplugin/oji/GCJSecureEnv.h \
+       src/gnu/gcjwebplugin/oji/jniHelp.h \
        src/gnu/gcjwebplugin/oji/oji.h \
+       src/gnu/gcjwebplugin/oji/pluginDebug.h \
+       src/gnu/gcjwebplugin/oji/pluginMeta.h \
        src/manifest.txt \
-       src/pluginDebug.h \
-       src/pluginMeta.h \
        src/gnu/getopt/MessagesBundle.properties \
        src/gnu/getopt/MessagesBundle_cs.properties \
        src/gnu/getopt/MessagesBundle_de.properties \
Index: configure.ac
===================================================================
RCS file: /sources/gcjwebplugin/gcjwebplugin/configure.ac,v
retrieving revision 1.55
diff -u -r1.55 configure.ac
--- configure.ac        4 Sep 2005 20:33:49 -0000       1.55
+++ configure.ac        28 Mar 2006 11:11:51 -0000
@@ -24,7 +24,7 @@
 
 dnl Disable for now because its not supported yet.
 dnl GCJWEBPLUGIN_ENABLE_XPCOM_API
-GCJWEBPLUGIN_ENABLE_DEBUG
+dnl GCJWEBPLUGIN_ENABLE_DEBUG
 GCJWEBPLUGIN_ENABLE_EXTERNAL_MOZILLA_INCLUDES
 
 GCJWEBPLUGIN_WITH_PLUGIN_DIR
@@ -44,8 +44,6 @@
 AM_CONDITIONAL([BUILD_NATIVE_VIEWER],
                [test "x${gcj_present}" = xyes -a "x${enable_native_viewer}" = 
xyes])
 
-AC_DEFINE(GCJAPPLETVIEWER_EXECUTABLE,"gcjappletviewer", [gcjappletviewer 
executable])
-
 GCJWEBPLUGIN_CHECK_JAVA
 GCJWEBPLUGIN_CHECK_JAVAC
 GCJWEBPLUGIN_CHECK_JAVAH
Index: src/gcjwebplugin.cc
===================================================================
RCS file: /sources/gcjwebplugin/gcjwebplugin/src/gcjwebplugin.cc,v
retrieving revision 1.35
diff -u -r1.35 gcjwebplugin.cc
--- src/gcjwebplugin.cc 22 Feb 2006 21:34:42 -0000      1.35
+++ src/gcjwebplugin.cc 28 Mar 2006 11:11:52 -0000
@@ -1,4 +1,4 @@
-/* gcjwebplugin - web browser plug-in to execute Java (tm) applets
+/* gcjwebplugin.cc -- web browser plugin to execute Java applets
    Copyright (C) 2003, 2004, 2006  Michael Koch <address@hidden>
                                    Thomas Fitzsimmons <address@hidden>
 
@@ -34,503 +34,1273 @@
    obligated to do so.  If you do not wish to do so, delete this
    exception statement from your version. */
 
-
-// System includes
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
+// System includes.
 #include <errno.h>
-#include <sys/types.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
 
-// Netscape plugin API includes
+// Netscape plugin API includes.
 #include <npapi.h>
 #include <npupp.h>
 
-// GLib includes
+// GLib includes.
 #include <glib.h>
 
-// gcjwebplugin includes
+// gcjwebplugin includes.
 #include "config.h"
-#include "pluginDebug.h"
-#include "pluginMeta.h"
 
-// Support hack to get documentbase.
+// Documentbase retrieval includes.
 #include <nsIPluginInstance.h>
 #include <nsIPluginInstancePeer.h>
 #include <nsIPluginTagInfo2.h>
 
+// Debugging macros.
+#define PLUGIN_DEBUG(message)                                           \
+  g_print ("GCJ PLUGIN: thread %p: %s\n", g_thread_self (), message)
+
+#define PLUGIN_DEBUG_TWO(first, second)                                 \
+  g_print ("GCJ PLUGIN: thread %p: %s %s\n", g_thread_self (),          \
+           first, second)
+
+// Error reporting macros.
+#define PLUGIN_ERROR(message)                                       \
+  g_printerr ("%s:%d: thread %p: Error: %s\n", __FILE__, __LINE__,  \
+              g_thread_self (), message)
+
+#define PLUGIN_ERROR_TWO(first, second)                                 \
+  g_printerr ("%s:%d: thread %p: Error: %s: %s\n", __FILE__, __LINE__,  \
+              g_thread_self (), first, second)
+
+// Plugin information passed to about:plugins.
+#define PLUGIN_NAME "GCJ Web Browser Plugin"
+#define PLUGIN_DESC "The " PLUGIN_NAME " executes Java applets."
+#define PLUGIN_MIME_DESC                                           \
+  "application/x-java-vm:class,jar:GCJ;"                           \
+  "application/x-java-applet:class,jar:GCJ;"                       \
+  "application/x-java-applet;version=1.1:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.1.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.1.2:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.1.3:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.2:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.2.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.2.2:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.3:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.3.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.4:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.4.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.4.2:class,jar:GCJ;"         \
+  "application/x-java-applet;jpi-version=1.4.2_01:class,jar:GCJ;"  \
+  "application/x-java-bean:class,jar:GCJ;"                         \
+  "application/x-java-bean;version=1.1:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.1.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.1.2:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.1.3:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.2:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.2.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.2.2:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.3:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.3.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.4:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.4.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.4.2:class,jar:GCJ;"           \
+  "application/x-java-bean;jpi-version=1.4.2_01:class,jar:GCJ;"
+#define PLUGIN_URL NS_INLINE_PLUGIN_CONTRACTID_PREFIX NS_JVM_MIME_TYPE
+#define PLUGIN_MIME_TYPE "application/x-java-vm"
+#define PLUGIN_FILE_EXTS "class,jar,zip"
+#define PLUGIN_MIME_COUNT 1
+
+// Directory in which named pipes are created.
+#define PIPE_DIRECTORY "/tmp"
+
+// Documentbase retrieval required definition.
 static NS_DEFINE_IID (kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID);
 
+// Browser function table.
 static NPNetscapeFuncs browserFunctions;
 
-static GMutex *mutex_appletviewer_process = NULL;
-static gint send_message_to_appletviewer (gchar const* value);
-static gint receive_message_from_appletviewer (gchar* string);
-static gboolean callbackViewerRead (GIOChannel* source,
-                                   GIOCondition condition,
-                                   gpointer data);
-
+// GCJPluginData stores all the data associated with a single plugin
+// instance.  A separate plugin instance is created for each <APPLET>
+// tag.  For now, each plugin instance spawns its own applet viewer
+// process but this may need to change if we find pages containing
+// multiple applets that expect to be running in the same VM.
 struct GCJPluginData
 {
-  char *code;
-  char *codebase;
-  char *archive;
-  char *documentbase;
-  char *parameters;
-  char *width;
-  char *height;
-  // The xid of the plugin window, encoded in hexadecimal.
-  char *xid;
-  char *instance_id;
+  // A unique identifier for this plugin window.
+  gchar* instance_string;
+  // Applet viewer input pipe name.
+  gchar* in_pipe_name;
+  // Applet viewer input channel.
+  GIOChannel* in_from_appletviewer;
+  // Applet viewer input watch source.
+  gint in_watch_source;
+  // Applet viewer output pipe name.
+  gchar* out_pipe_name;
+  // Applet viewer output channel.
+  GIOChannel* out_to_appletviewer;
+  // Applet viewer output watch source.
+  gint out_watch_source;
+  // Mutex to protect appletviewer_alive.
+  GMutex* appletviewer_mutex;
+  // Back-pointer to the plugin instance to which this data belongs.
+  // This should not be freed but instead simply set to NULL.
+  NPP owner;
+  // FALSE if the applet viewer process has died.  All code
+  // communicating with the applet viewer should check this flag
+  // before attempting to read from/write to the applet viewer pipes.
+  gboolean appletviewer_alive;
+  // The address of the plugin window.  This should not be freed but
+  // instead simply set to NULL.
+  gpointer window_handle;
+  // The last plugin window width sent to us by the browser.
+  guint32 window_width;
+  // The last plugin window height sent to us by the browser.
+  guint32 window_height;
 };
 
-static NPError start_appletviewer_process (void);
-
-static GIOChannel *output_to_appletviewer = NULL;
-static GIOChannel *input_from_appletviewer = NULL;
-
-static int instance_counter = 0;
-
-static guint viewer_watch = 0;
-
-static void gcjplugindata_new (GCJPluginData ** data);
-static void gcjplugindata_destroy (GCJPluginData ** data);
-
-NPError
-GCJ_GetValue (NPP instance, NPPVariable variable, void* value)
+// Documentbase retrieval type-punning union.
+typedef union
 {
-  PLUGIN_DEBUG ("GCJ_GetValue\n");
-
-  switch (variable)
-    {
-    // This plug-in needs XEmbed support.
-    case NPPVpluginNeedsXEmbed:
-      PLUGIN_DEBUG ("GCJ_GetValue: Returning Plug-in NeedsXEmbed value\n");
-      *((PRBool*) value) = PR_TRUE;
-      break;
-
-    default:
-      PLUGIN_DEBUG ("GCJ_GetValue: Unknown Plug-in value requested\n");
-      return NPERR_GENERIC_ERROR;
-      break;
-    }
-  
-  PLUGIN_DEBUG ("GCJ_GetValue: No error\n");
-  return NPERR_NO_ERROR;
-}
-
+  void** void_field;
+  nsIPluginTagInfo2** info_field;
+} info_union;
+
+// Static instance helper functions.
+// Have the browser allocate a new GCJPluginData structure.
+static void plugin_data_new (GCJPluginData** data);
+// Documentbase retrieval.
+static gchar* plugin_get_documentbase (NPP instance);
+// Callback used to monitor input pipe status.
+static gboolean plugin_in_pipe_callback (GIOChannel* source,
+                                         GIOCondition condition,
+                                         gpointer plugin_data);
+// Callback used to monitor output pipe status.
+static gboolean plugin_out_pipe_callback (GIOChannel* source,
+                                          GIOCondition condition,
+                                          gpointer plugin_data);
+static void plugin_start_appletviewer (GCJPluginData* data);
+static gchar* plugin_create_applet_tag (int16 argc, char* argn[],
+                                        char* argv[]);
+static void plugin_send_message_to_appletviewer (GCJPluginData* data,
+                                                 gchar const* message);
+static void plugin_stop_appletviewer (GCJPluginData* data);
+// Uninitialize GCJPluginData structure and delete pipes.
+static void plugin_data_destroy (GCJPluginData** data);
+
+// Global instance counter.
+// Mutex to protect plugin_instance_counter.
+static GMutex* plugin_instance_mutex = NULL;
+// A counter used to create uniquely named pipes.
+static gulong plugin_instance_counter = 0;
+
+// Functions prefixed by GCJ_ are instance functions.  They are called
+// by the browser and operate on instances of GCJPluginData.
+// Functions prefixed by plugin_ are static helper functions.
+// Functions prefixed by NP_ are factory functions.  They are called
+// by the browser and provide functionality needed to create plugin
+// instances.
+
+// INSTANCE FUNCTIONS
+
+// Creates a new gcjwebplugin instance.  This function creates a
+// GCJPluginData* and stores it in instance->pdata.  The following
+// GCJPluginData fiels are initialized: instance_string, in_pipe_name,
+// in_from_appletviewer, in_watch_source, out_pipe_name,
+// out_to_appletviewer, out_watch_source, appletviewer_mutex, owner,
+// appletviewer_alive.  In addition two pipe files are created.  All
+// of those fields must be properly destroyed, and the pipes deleted,
+// by GCJ_Destroy.  If an error occurs during initialization then this
+// function will free anything that's been allocated so far, set
+// instance->pdata to NULL and return an error code.
 NPError
 GCJ_New (NPMIMEType pluginType, NPP instance, uint16 mode,
          int16 argc, char* argn[], char* argv[],
          NPSavedData* saved)
 {
-  PLUGIN_DEBUG ("GCJ_New\n");
+  PLUGIN_DEBUG ("GCJ_New");
+
+  NPError np_error = NPERR_NO_ERROR;
+  GCJPluginData* data = NULL;
+  GError* channel_error = NULL;
+  gchar* documentbase = NULL;
+  gchar* read_message = NULL;
+  gchar* applet_tag = NULL;
+  gchar* tag_message = NULL;
 
   if (!instance)
     {
-      PLUGIN_DEBUG ("GCJ_New: Invalid instance\n");
-      return NPERR_INVALID_INSTANCE_ERROR;
+      PLUGIN_ERROR ("Browser-provided instance pointer is NULL.");
+      np_error = NPERR_INVALID_INSTANCE_ERROR;
+      goto cleanup_done;
     }
 
   // Initialize threads (needed for mutexes).
   if (!g_thread_supported ())
     g_thread_init (NULL);
-  
-  NPError tmp = NPERR_NO_ERROR;
-  
-  g_mutex_lock (mutex_appletviewer_process);
-  if (! output_to_appletviewer) // Start appletviewer process if necessary.
-    tmp = start_appletviewer_process();
-  g_mutex_unlock (mutex_appletviewer_process);
 
-  if (tmp != NPERR_NO_ERROR)
+  // data
+  plugin_data_new (&data);
+  if (data == NULL)
     {
-      PLUGIN_DEBUG ("GCJ_New: Unknown error\n");
-      return tmp;
+      PLUGIN_ERROR ("Failed to allocate plugin data.");
+      np_error = NPERR_OUT_OF_MEMORY_ERROR;
+      goto cleanup_done;
     }
 
-  GCJPluginData* data = NULL;
+  // Initialize data->instance_string.
+  //
+  // instance_string should be unique for this process so we use a
+  // combination of getpid and plugin_instance_counter.
+  //
+  // Critical region.  Reference and increment plugin_instance_counter
+  // global.
+  g_mutex_lock (plugin_instance_mutex);
+
+  // data->instance_string
+  data->instance_string = g_strdup_printf ("instance-%d-%ld",
+                                           getpid (),
+                                           plugin_instance_counter++);
 
-  gcjplugindata_new (&data);
+  g_mutex_unlock (plugin_instance_mutex);
 
-  if (!data)
+  // data->appletviewer_mutex
+  data->appletviewer_mutex = g_mutex_new ();
+
+  // Documentbase retrieval.
+  documentbase = plugin_get_documentbase (instance);
+  if (!documentbase)
     {
-      PLUGIN_DEBUG ("GCJ_New: OutOfMemoryError\n");
-      return NPERR_OUT_OF_MEMORY_ERROR;
+      PLUGIN_ERROR ("Documentbase retrieval failed."
+                    " Browser not Mozilla-based?");
+      goto cleanup_appletviewer_mutex;
     }
 
-  // This little hack gets the current document's documentbase.  It
-  // will only work when the plugin is loaded in Mozilla, because it
-  // relys on browser-private data.
-  nsIPluginInstance* xpcom_instance = (nsIPluginInstance *) (instance->ndata);
-  nsIPluginInstancePeer* peer = NULL;
-  xpcom_instance->GetPeer (&peer);
+  // Create appletviewer-to-plugin pipe which we refer to as the input
+  // pipe.
 
-  nsresult result;
-  nsIPluginTagInfo2* pluginTagInfo2;
-  result = peer->QueryInterface (kIPluginTagInfo2IID, (void**) 
&pluginTagInfo2);
+  // data->in_pipe_name
+  data->in_pipe_name = g_strdup_printf (PIPE_DIRECTORY
+                                        "/gcj-%s-appletviewer-to-plugin",
+                                        data->instance_string);
+  if (!data->in_pipe_name)
+    {
+      PLUGIN_ERROR ("Failed to create input pipe name.");
+      np_error = NPERR_OUT_OF_MEMORY_ERROR;
+      // If data->in_pipe_name is NULL then the g_free at
+      // cleanup_in_pipe_name will simply return.
+      goto cleanup_in_pipe_name;
+    }
 
-  char const* documentbase;
-  pluginTagInfo2->GetDocumentBase (&documentbase);
+  if (mkfifo (data->in_pipe_name, 0700) == -1 && errno != EEXIST)
+    {
+      PLUGIN_ERROR_TWO ("Failed to create input pipe", strerror (errno));
+      np_error = NPERR_GENERIC_ERROR;
+      goto cleanup_in_pipe_name;
+    }
 
-  data->documentbase = g_strdup (documentbase);
+  // Create plugin-to-appletviewer pipe which we refer to as the
+  // output pipe.
 
-  // Release references.
-  NS_RELEASE (peer);
-  NS_RELEASE (pluginTagInfo2);
+  // data->out_pipe_name
+  data->out_pipe_name = g_strdup_printf (PIPE_DIRECTORY
+                                         "/gcj-%s-plugin-to-appletviewer",
+                                         data->instance_string);
 
-  gchar *applet_tag = g_strdup ("<APPLET ");
-  gchar *parameters = g_strdup ("");
+  if (!data->out_pipe_name)
+    {
+      PLUGIN_ERROR ("Failed to create output pipe name.");
+      np_error = NPERR_OUT_OF_MEMORY_ERROR;
+      goto cleanup_out_pipe_name;
+    }
 
-  for (int i = 0; i < argc; i++)
+  if (mkfifo (data->out_pipe_name, 0700) == -1 && errno != EEXIST)
     {
-      if (!g_ascii_strcasecmp (argn[i], "code"))
-       {
-         data->code = g_strdup (argv[i]);
-         applet_tag = g_strconcat (applet_tag,
-                                   g_strdup_printf ("CODE=\"%s\" ", argv[i]), 
NULL);
-       }
-      else if (!g_ascii_strcasecmp (argn[i], "codebase"))
-       {
-         data->codebase = g_strdup (argv[i]);
-         applet_tag = g_strconcat (applet_tag,
-                                   g_strdup_printf ("CODEBASE=\"%s\" ", 
argv[i]), NULL);
-       }
-      else if (!g_ascii_strcasecmp (argn[i], "archive"))
-       {
-         data->archive = g_strdup (argv[i]);
-         applet_tag = g_strconcat (applet_tag,
-                                   g_strdup_printf ("ARCHIVE=\"%s\" ", 
argv[i]), NULL);
-       }
-      else if (!g_ascii_strcasecmp (argn[i], "width"))
-       {
-         data->width = g_strdup (argv[i]);
-         applet_tag = g_strconcat (applet_tag,
-                                   g_strdup_printf ("WIDTH=\"%s\" ", argv[i]), 
NULL);
-       }
-      else if (!g_ascii_strcasecmp (argn[i], "height"))
-       {
-         data->height = g_strdup (argv[i]);
-         applet_tag = g_strconcat (applet_tag,
-                                   g_strdup_printf ("HEIGHT=\"%s\" ", 
argv[i]), NULL);
-       }
-      else
-        {
-          // Escape the parameter value so that line termination
-          // characters will pass through the pipe.
-          if (argv[i] != '\0')
-            parameters = g_strconcat (parameters, "<PARAM NAME=\"", argn[i],
-                                      "\" VALUE=\"",
-                                      g_strescape (argv[i], NULL),
-                                      "\">", NULL);
-        }
+      PLUGIN_ERROR_TWO ("Failed to create output pipe", strerror (errno));
+      np_error = NPERR_GENERIC_ERROR;
+      goto cleanup_out_pipe_name;
+    }
+
+  // Start a separate appletviewer process for each applet, even if
+  // there are multiple applets in the same page.  We may need to
+  // change this behaviour if we find pages with multiple applets that
+  // rely on being run in the same VM.
+
+  // Critical region.  Hold appletviewer_mutex while we start the
+  // appletviewer, create the IO channels and install the channel
+  // watch callbacks.
+  g_mutex_lock (data->appletviewer_mutex);
+
+  plugin_start_appletviewer (data);
+
+  // Create plugin-to-appletviewer channel.
+  // data->out_to_appletviewer
+  data->out_to_appletviewer = g_io_channel_new_file (data->out_pipe_name,
+                                                     "w", &channel_error);
+  if (!data->out_to_appletviewer)
+    {
+      PLUGIN_ERROR_TWO ("Failed to create output channel",
+                        channel_error->message);
+      np_error = NPERR_GENERIC_ERROR;
+      goto cleanup_out_to_appletviewer;
+    }
+  if (channel_error)
+    {
+      g_error_free (channel_error);
+      channel_error = NULL;
+    }
+
+  // Watch for hangup and error signals on the output pipe.
+  data->out_watch_source =
+    g_io_add_watch (data->out_to_appletviewer,
+                    (GIOCondition) (G_IO_ERR | G_IO_HUP),
+                    plugin_out_pipe_callback, (gpointer) data);
+
+  // Create appletviewer-to-plugin channel.
+  // data->in_from_appletviewer
+  data->in_from_appletviewer = g_io_channel_new_file (data->in_pipe_name,
+                                                      "r", &channel_error);
+  if (!data->in_from_appletviewer)
+    {
+      PLUGIN_ERROR_TWO ("Failed to create input channel",
+                        channel_error->message);
+      np_error = NPERR_GENERIC_ERROR;
+      goto cleanup_in_from_appletviewer;
+    }
+  if (channel_error)
+    {
+      g_error_free (channel_error);
+      channel_error = NULL;
+    }
+
+  // Watch for hangup and error signals on the input pipe.
+  data->in_watch_source =
+    g_io_add_watch (data->in_from_appletviewer,
+                    (GIOCondition) (G_IO_IN | G_IO_ERR | G_IO_HUP),
+                    plugin_in_pipe_callback, (gpointer) data);
+
+  // Wait until we receive confirmation that the appletviewer has
+  // started.
+  if (g_io_channel_read_line (data->in_from_appletviewer,
+                              &read_message, NULL, NULL,
+                              &channel_error)
+      != G_IO_STATUS_NORMAL)
+    {
+      PLUGIN_ERROR_TWO ("Receiving confirmation from appletviewer failed",
+                        channel_error->message);
+      np_error = NPERR_GENERIC_ERROR;
+      goto cleanup_in_watch_source;
+    }
+  if (channel_error)
+    {
+      g_error_free (channel_error);
+      channel_error = NULL;
     }
 
-  applet_tag = g_strconcat (applet_tag, g_strdup_printf (">"), parameters,
-                           g_strdup_printf ("</EMBED>"), NULL);
+  PLUGIN_DEBUG ("GCJ_New: got confirmation that appletviewer is running.");
+  data->appletviewer_alive = TRUE;
 
-  data->instance_id = g_strdup_printf ("instance applet%d", 
instance_counter++);
+  // Send applet tag message to appletviewer.
+  applet_tag = plugin_create_applet_tag (argc, argn, argv);
+  tag_message = g_strconcat ("tag ", documentbase, " ", applet_tag, NULL);
 
+  plugin_send_message_to_appletviewer (data, data->instance_string);
+  plugin_send_message_to_appletviewer (data, tag_message);
+
+  g_mutex_unlock (data->appletviewer_mutex);
+
+  // If initialization succeeded entirely then we store the plugin
+  // data in the instance structure and return.  Otherwise we free the
+  // data we've allocated so far and set instance->pdata to NULL.
+
+  // Set back-pointer to owner instance.
+  data->owner = instance;
   instance->pdata = data;
+  goto cleanup_done;
 
-  char* tag = g_strdup_printf ("tag %s %s", data->documentbase, applet_tag);
+  // An error occurred while initializing the plugin data or spawning
+  // the appletviewer so we free the data we've already allocated.
 
-  send_message_to_appletviewer (data->instance_id);
-  send_message_to_appletviewer (tag);
+ cleanup_in_watch_source:
+  // Removing a source is harmless if it fails since it just means the
+  // source has already been removed.
+  g_source_remove (data->in_watch_source);
+  data->in_watch_source = 0;
+
+ cleanup_in_from_appletviewer:
+  if (data->in_from_appletviewer)
+    g_io_channel_unref (data->in_from_appletviewer);
+  data->in_from_appletviewer = NULL;
+
+  // cleanup_out_watch_source:
+  g_source_remove (data->out_watch_source);
+  data->out_watch_source = 0;
+
+ cleanup_out_to_appletviewer:
+  if (data->out_to_appletviewer)
+    g_io_channel_unref (data->out_to_appletviewer);
+  data->out_to_appletviewer = NULL;
+
+  // cleanup_out_pipe:
+  // Delete output pipe.
+  unlink (data->out_pipe_name);
+
+ cleanup_out_pipe_name:
+  g_free (data->out_pipe_name);
+  data->out_pipe_name = NULL;
+
+  // cleanup_in_pipe:
+  // Delete input pipe.
+  unlink (data->in_pipe_name);
+
+ cleanup_in_pipe_name:
+  g_free (data->in_pipe_name);
+  data->in_pipe_name = NULL;
+
+ cleanup_appletviewer_mutex:
+  g_free (data->appletviewer_mutex);
+  data->appletviewer_mutex = NULL;
+
+  // cleanup_instance_string:
+  g_free (data->instance_string);
+  data->instance_string = NULL;
+
+  // cleanup_data:
+  // Eliminate back-pointer to plugin instance.
+  data->owner = NULL;
+  (*browserFunctions.memfree) (data);
+  data = NULL;
+
+  // Initialization failed so return a NULL pointer for the browser
+  // data.
+  instance->pdata = NULL;
+
+ cleanup_done:
+
+  g_free (tag_message);
+  tag_message = NULL;
+  g_free (applet_tag);
+  applet_tag = NULL;
+  g_free (read_message);
+  read_message = NULL;
+  g_free (documentbase);
+  documentbase = NULL;
 
-  PLUGIN_DEBUG ("GCJ_New: No error\n");
-  return NPERR_NO_ERROR;
+  PLUGIN_DEBUG ("GCJ_New return");
+
+  return np_error;
 }
 
-static void
-gcjplugindata_new (GCJPluginData ** data)
+NPError
+GCJ_GetValue (NPP instance, NPPVariable variable, void* value)
 {
-  *data = (GCJPluginData*)
-    (* browserFunctions.memalloc) (sizeof (struct GCJPluginData));
+  PLUGIN_DEBUG ("GCJ_GetValue");
+
+  NPError np_error = NPERR_NO_ERROR;
 
-  memset (*data, 0, sizeof (struct GCJPluginData));
+  switch (variable)
+    {
+    // This plugin needs XEmbed support.
+    case NPPVpluginNeedsXEmbed:
+      {
+        PLUGIN_DEBUG ("GCJ_GetValue: returning TRUE for NeedsXEmbed.");
+        PRBool* bool_value = (PRBool*) value;
+        *bool_value = PR_TRUE;
+      }
+      break;
+
+    default:
+      PLUGIN_ERROR ("Unknown plugin value requested.");
+      np_error = NPERR_GENERIC_ERROR;
+      break;
+    }
+
+  PLUGIN_DEBUG ("GCJ_GetValue return");
+
+  return np_error;
 }
 
 NPError
 GCJ_Destroy (NPP instance, NPSavedData** save)
 {
-  PLUGIN_DEBUG ("GCJ_Destroy\n");
+  PLUGIN_DEBUG ("GCJ_Destroy");
 
   GCJPluginData* data = (GCJPluginData*) instance->pdata;
 
-  send_message_to_appletviewer ("destroy");
+  if (data)
+    {
+      // Critical region.  Stop the appletviewer.
+      g_mutex_lock (data->appletviewer_mutex);
 
-  gcjplugindata_destroy (&data);
+      // Tell the appletviewer to destroy its embedded plugin window.
+      plugin_send_message_to_appletviewer (data, "destroy");
+      // Shut down the appletviewer.
+      plugin_stop_appletviewer (data);
 
-  PLUGIN_DEBUG ("GCJ_Destroy: No error\n");
-  return NPERR_NO_ERROR;
-}
+      g_mutex_unlock (data->appletviewer_mutex);
 
-static void
-gcjplugindata_destroy (GCJPluginData ** data)
-{
-  GCJPluginData *tofree = *data;
+      // Free plugin data.
+      plugin_data_destroy (&data);
+    }
 
-  g_free (tofree->code);
-  g_free (tofree->codebase);
-  g_free (tofree->archive);
-  g_free (tofree->documentbase);
-  g_free (tofree->parameters);
-  g_free (tofree->width);
-  g_free (tofree->height);
-  g_free (tofree->xid);
-  g_free (tofree->instance_id);
+  PLUGIN_DEBUG ("GCJ_Destroy return");
 
-  (* browserFunctions.memfree) (tofree);
-  tofree = NULL;
+  return NPERR_NO_ERROR;
 }
 
 NPError
 GCJ_SetWindow (NPP instance, NPWindow* window)
 {
-  PLUGIN_DEBUG ("GCJ_SetWindow\n");
+  PLUGIN_DEBUG ("GCJ_SetWindow");
 
   if (instance == NULL)
     {
-      PLUGIN_DEBUG ("GCJ_SetWindow: Invalid instance\n");
+      PLUGIN_ERROR ("Invalid instance.");
+
       return NPERR_INVALID_INSTANCE_ERROR;
     }
 
-  GCJPluginData* data = (GCJPluginData *)instance->pdata;
+  GCJPluginData* data = (GCJPluginData*) instance->pdata;
 
+  // Simply return if we receive a NULL window.
   if ((window == NULL) || (window->window == NULL))
     {
-      PLUGIN_DEBUG ("GCJ_SetWindow: Got null window\n");
+      PLUGIN_DEBUG ("GCJ_SetWindow: got NULL window.");
+
       return NPERR_NO_ERROR;
     }
 
-  if (data->xid)
+  if (data->window_handle)
     {
       // The window already exists.
-      if (atol (data->xid) == (unsigned long) window->window)
+      if (data->window_handle == window->window)
        {
-         if (output_to_appletviewer
-             && input_from_appletviewer)
+          // The parent window is the same as in previous calls.
+          PLUGIN_DEBUG ("GCJ_SetWindow: window already exists.");
+
+          // Critical region.  Read data->appletviewer_mutex and send
+          // a message to the appletviewer.
+          g_mutex_lock (data->appletviewer_mutex);
+
+         if (data->appletviewer_alive)
            {
              // The window is the same as it was for the last
              // SetWindow call.
-             char* width = g_strdup_printf ("width %d", window->width);
-             if (g_ascii_strcasecmp (width, data->width))
+             if (window->width != data->window_width)
                {
+                  PLUGIN_DEBUG ("GCJ_SetWindow: window width changed.");
                  // The width of the plugin window has changed.
-                 send_message_to_appletviewer (data->instance_id);
-                 send_message_to_appletviewer (data->width);
+
+                  // Send the new width to the appletviewer.
+                 plugin_send_message_to_appletviewer (data,
+                                                       data->instance_string);
+                  gchar* width_message = g_strdup_printf ("width %d",
+                                                          window->width);
+                 plugin_send_message_to_appletviewer (data, width_message);
+                  g_free (width_message);
+
+                  // Store the new width.
+                  data->window_width = window->width;
                }
 
-             char* height = g_strdup_printf ("height %d", window->height);
-             if (g_ascii_strcasecmp (height, data->height))
+             if (window->height != data->window_height)
                {
+                  PLUGIN_DEBUG ("GCJ_SetWindow: window height changed.");
                  // The height of the plugin window has changed.
-                 send_message_to_appletviewer (data->instance_id);
-                 send_message_to_appletviewer (data->height);
+
+                  // Send the new height to the appletviewer.
+                 plugin_send_message_to_appletviewer (data,
+                                                       data->instance_string);
+                  gchar* height_message = g_strdup_printf ("height %d",
+                                                           window->height);
+                 plugin_send_message_to_appletviewer (data, height_message);
+                  g_free (height_message);
+
+                  // Store the new height.
+                  data->window_height = window->height;
                }
            }
          else
            {
-             PLUGIN_DEBUG ("GCJ_SetWindow: "
-                           GCJAPPLETVIEWER_EXECUTABLE
-                           " not spawned\n");
+              // The appletviewer is not running.
+             PLUGIN_DEBUG ("GCJ_SetWindow: appletviewer is not running.");
            }
+
+          g_mutex_unlock (data->appletviewer_mutex);
        }
       else
        {
-         // The parent window has changed.  We don't handle this,
-         // since it's not supposed to happen.
-         PLUGIN_DEBUG ("GCJ_SetWindow: parent changed\n");
+         // The parent window has changed.  This branch does run but
+         // doing nothing in response seems to be sufficient.
+         PLUGIN_DEBUG ("GCJ_SetWindow: parent window changed.");
        }
     }
   else
     {
-      PLUGIN_DEBUG ("GCJ_SetWindow: setting window\n");
-#if SIZEOF_VOID_P == 4 // We are on a 32-bit architecture.
-      data->xid = g_strdup_printf ("xid %d", (int) (window->window));
-#elif SIZEOF_VOID_P == 8 // We are on a 64-bit architecture.
-      data->xid = g_strdup_printf ("xid %ld", (long) (window->window));
-#else // We are on an architecture with unkown pointer size.
-#error "Unknown pointer size."
-#endif
+      PLUGIN_DEBUG ("GCJ_SetWindow: setting window.");
+
+      // Critical region.  Send messages to appletviewer.
+      g_mutex_lock (data->appletviewer_mutex);
+
+      plugin_send_message_to_appletviewer (data, data->instance_string);
+      gchar *window_message = g_strdup_printf ("handle %ld",
+                                               (gulong) window->window);
+      plugin_send_message_to_appletviewer (data, window_message);
+      g_free (window_message);
 
-      send_message_to_appletviewer (data->instance_id);
-      send_message_to_appletviewer (data->xid);
+      g_mutex_unlock (data->appletviewer_mutex);
+
+      // Store the window handle.
+      data->window_handle = window->window;
     }
 
-  PLUGIN_DEBUG ("GCJ_SetWindow: No error\n");
+  PLUGIN_DEBUG ("GCJ_SetWindow return");
+
   return NPERR_NO_ERROR;
 }
 
 NPError
-GCJ_NewStream (NPP instance, NPMIMEType type, NPStream* stream, NPBool 
seekable, uint16* stype)
+GCJ_NewStream (NPP instance, NPMIMEType type, NPStream* stream,
+               NPBool seekable, uint16* stype)
 {
-  PLUGIN_DEBUG ("GCJ_NewStream\n");
+  PLUGIN_DEBUG ("GCJ_NewStream");
+
+  PLUGIN_DEBUG ("GCJ_NewStream return");
 
-  PLUGIN_DEBUG ("GCJ_NewStream: No error\n");
   return NPERR_NO_ERROR;
 }
 
 void
 GCJ_StreamAsFile (NPP instance, NPStream* stream, const char* filename)
 {
-  PLUGIN_DEBUG ("GCJ_StreamAsFile\n");
+  PLUGIN_DEBUG ("GCJ_StreamAsFile");
 
-  PLUGIN_DEBUG ("GCJ_StreamAsFile: No error\n");
+  PLUGIN_DEBUG ("GCJ_StreamAsFile return");
 }
 
 NPError
 GCJ_DestroyStream (NPP instance, NPStream* stream, NPReason reason)
 {
-  PLUGIN_DEBUG ("GCJ_DestroyStream\n");
+  PLUGIN_DEBUG ("GCJ_DestroyStream");
+
+  PLUGIN_DEBUG ("GCJ_DestroyStream return");
 
-  PLUGIN_DEBUG ("GCJ_DestroyStream: No error\n");
   return NPERR_NO_ERROR;
 }
 
 int32
 GCJ_WriteReady (NPP instance, NPStream* stream)
 {
-  PLUGIN_DEBUG ("GCJ_WriteReady\n");
+  PLUGIN_DEBUG ("GCJ_WriteReady");
+
+  PLUGIN_DEBUG ("GCJ_WriteReady return");
 
-  PLUGIN_DEBUG ("GCJ_WriteReady: No error\n");
   return 0;
 }
 
 int32
-GCJ_Write (NPP instance, NPStream* stream, int32 offset, int32 len, void* 
buffer)
+GCJ_Write (NPP instance, NPStream* stream, int32 offset, int32 len,
+           void* buffer)
 {
-  PLUGIN_DEBUG ("GCJ_Write\n");
+  PLUGIN_DEBUG ("GCJ_Write");
+
+  PLUGIN_DEBUG ("GCJ_Write return");
 
-  PLUGIN_DEBUG ("GCJ_Write: No error\n");
   return 0;
 }
 
 void
 GCJ_Print (NPP instance, NPPrint* platformPrint)
 {
-  PLUGIN_DEBUG ("GCJ_Print\n");
+  PLUGIN_DEBUG ("GCJ_Print");
 
-  PLUGIN_DEBUG ("GCJ_Print: No error\n");
+  PLUGIN_DEBUG ("GCJ_Print return");
 }
 
 int16
 GCJ_HandleEvent (NPP instance, void* event)
 {
-  PLUGIN_DEBUG ("GCJ_HandleEvent\n");
+  PLUGIN_DEBUG ("GCJ_HandleEvent");
+
+  PLUGIN_DEBUG ("GCJ_HandleEvent return");
 
-  PLUGIN_DEBUG ("GCJ_HandleEvent: No error\n");
   return 0;
 }
 
 void
-GCJ_URLNotify (NPP instance, const char* url, NPReason reason, void* 
notifyData)
+GCJ_URLNotify (NPP instance, const char* url, NPReason reason,
+               void* notifyData)
 {
-  PLUGIN_DEBUG ("GCJ_URLNotify\n");
+  PLUGIN_DEBUG ("GCJ_URLNotify");
 
-  PLUGIN_DEBUG ("GCJ_URLNotify: No error\n");
+  PLUGIN_DEBUG ("GCJ_URLNotify return");
 }
 
 jref
 GCJ_GetJavaClass (void)
 {
-  PLUGIN_DEBUG ("GCJ_GetJavaClass\n");
+  PLUGIN_DEBUG ("GCJ_GetJavaClass");
+
+  PLUGIN_DEBUG ("GCJ_GetJavaClass return");
 
-  PLUGIN_DEBUG ("GCJ_GetJavaClass: No error\n");
   return 0;
 }
 
-static gint
-send_message_to_appletviewer (gchar const* name)
+// HELPER FUNCTIONS
+
+static void
+plugin_data_new (GCJPluginData** data)
 {
-  GError *err = NULL;
-  gsize bytes_written;
-  NPError np_error;
+  PLUGIN_DEBUG ("plugin_data_new");
 
-  // Send name of attribute to gcjappletviewer.
-  gchar *name_buf = g_strdup_printf ("%s\n", name);
+  *data = (GCJPluginData*)
+    (*browserFunctions.memalloc) (sizeof (struct GCJPluginData));
 
-  if (g_io_channel_write_chars (output_to_appletviewer,
-                                name_buf, -1, &bytes_written, &err)
-      != G_IO_STATUS_NORMAL)
+  // appletviewer_alive is false until the applet viewer is spawned.
+  if (*data)
+    memset (*data, 0, sizeof (struct GCJPluginData));
+
+  PLUGIN_DEBUG ("plugin_data_new return");
+}
+
+// Documentbase retrieval.  This function gets the current document's
+// documentbase.  This function relies on browser-private data so it
+// will only work when the plugin is loaded in a Mozilla-based
+// browser.  We could not find a way to retrieve the documentbase
+// using the original Netscape plugin API so we use the XPCOM API
+// instead.
+static gchar*
+plugin_get_documentbase (NPP instance)
+{
+  PLUGIN_DEBUG ("plugin_get_documentbase");
+
+  nsIPluginInstance* xpcom_instance = NULL;
+  nsIPluginInstancePeer* peer = NULL;
+  nsresult result = 0;
+  nsIPluginTagInfo2* pluginTagInfo2 = NULL;
+  info_union u = { NULL };
+  char const* documentbase = NULL;
+  gchar* documentbase_copy = NULL;
+
+  xpcom_instance = (nsIPluginInstance*) (instance->ndata);
+  if (!xpcom_instance)
     {
-      g_printerr ("send_message_to_appletviewer: Error: %s\n", err->message);
-      return NPERR_GENERIC_ERROR;
+      PLUGIN_ERROR ("xpcom_instance is NULL.");
+      goto cleanup_done;
     }
 
-  if (g_io_channel_flush (output_to_appletviewer, &err)
-      != G_IO_STATUS_NORMAL)
+  xpcom_instance->GetPeer (&peer);
+  if (!peer)
     {
-      g_printerr ("send_message_to_appletviewer: Error: %s\n", err->message);
-      return NPERR_GENERIC_ERROR;
+      PLUGIN_ERROR ("peer is NULL.");
+      goto cleanup_done;
     }
 
-  return NPERR_NO_ERROR;
+  u.info_field = &pluginTagInfo2;
+
+  result = peer->QueryInterface (kIPluginTagInfo2IID,
+                                 u.void_field);
+  if (result || !pluginTagInfo2)
+    {
+      PLUGIN_ERROR ("pluginTagInfo2 retrieval failed.");
+      goto cleanup_peer;
+    }
+
+  pluginTagInfo2->GetDocumentBase (&documentbase);
+
+  if (!documentbase)
+    {
+      PLUGIN_ERROR ("documentbase is NULL.");
+      goto cleanup_plugintaginfo2;
+    }
+
+  documentbase_copy = g_strdup (documentbase);
+
+  // Release references.
+ cleanup_plugintaginfo2:
+  NS_RELEASE (pluginTagInfo2);
+
+ cleanup_peer:
+  NS_RELEASE (peer);
+
+ cleanup_done:
+  PLUGIN_DEBUG ("plugin_get_documentbase return");
+
+  return documentbase_copy;
+}
+
+// plugin_in_pipe_callback is called when data is available on the
+// input pipe, or when the appletviewer crashes or is killed.  It may
+// be called after data has been destroyed in which case it simply
+// returns FALSE to remove itself from the glib main loop.
+static gboolean
+plugin_in_pipe_callback (GIOChannel* source,
+                         GIOCondition condition,
+                         gpointer plugin_data)
+{
+  PLUGIN_DEBUG ("plugin_in_pipe_callback");
+
+  GCJPluginData* data = (GCJPluginData*) plugin_data;
+  gboolean keep_installed = TRUE;
+
+  // If data is NULL then GCJ_Destroy has already been called and
+  // plugin_in_pipe_callback is being called after plugin
+  // destruction.  In that case all we need to do is return FALSE so
+  // that the plugin_in_pipe_callback watch is removed.
+  if (data)
+    {
+      // Critical region. Set or clear data->appletviewer_alive.
+      g_mutex_lock (data->appletviewer_mutex);
+
+      if (condition & G_IO_IN)
+        {
+          GError* channel_error = NULL;
+          gchar* message = NULL;
+
+          if (g_io_channel_read_line (data->in_from_appletviewer,
+                                      &message, NULL, NULL,
+                                      &channel_error)
+              != G_IO_STATUS_NORMAL)
+            {
+              PLUGIN_ERROR_TWO ("Failed to read line from input channel",
+                                channel_error->message);
+            }
+          else
+            {
+              if (g_str_has_prefix (message, "url "))
+                {
+                  gchar** parts = g_strsplit (message, " ", 3);
+                  PLUGIN_DEBUG_TWO ("plugin_in_pipe_callback:"
+                                    " opening URL", parts[1]);
+                  PLUGIN_DEBUG_TWO ("plugin_in_pipe_callback:"
+                                    " URL target", parts[2]);
+                  // Open the URL in a new browser window.
+                  NPError np_error =
+                    (*browserFunctions.geturl) (data->owner, parts[1], 
parts[2]);
+                  if (np_error != NPERR_NO_ERROR)
+                    PLUGIN_ERROR ("Failed to load URL.");
+                  g_strfreev (parts);
+                  parts = NULL;
+                }
+              else if (g_str_has_prefix (message, "status "))
+                {
+                  gchar** parts = g_strsplit (message, " ", 2);
+
+                  PLUGIN_DEBUG_TWO ("plugin_in_pipe_callback:"
+                                    " setting status", parts[1]);
+                  (*browserFunctions.status) (data->owner, parts[1]);
+                  g_strfreev (parts);
+                  parts = NULL;
+                }
+              g_printerr ("  PIPE: plugin read %s\n", message);
+            }
+
+          if (channel_error)
+            {
+              g_error_free (channel_error);
+              channel_error = NULL;
+            }
+
+          g_free (message);
+          message = NULL;
+
+          keep_installed = TRUE;
+        }
+
+      if (condition & (G_IO_ERR | G_IO_HUP))
+        {
+          PLUGIN_DEBUG ("appletviewer has stopped.");
+          data->appletviewer_alive = FALSE;
+          keep_installed = FALSE;
+        }
+      g_mutex_unlock (data->appletviewer_mutex);
+    }
+
+  PLUGIN_DEBUG ("plugin_in_pipe_callback return");
+
+  return keep_installed;
 }
 
-static gint
-receive_message_from_appletviewer (gchar *str)
+// plugin_out_pipe_callback is called when the appletviewer crashes or
+// is killed.  It may be called after data has been destroyed in which
+// case it simply returns FALSE to remove itself from the glib main
+// loop.
+static gboolean
+plugin_out_pipe_callback (GIOChannel* source,
+                          GIOCondition condition,
+                          gpointer plugin_data)
 {
-  GError *err = NULL;
+  PLUGIN_DEBUG ("plugin_out_pipe_callback");
 
-  // Receive message from gcjappletviewer.
-  gchar *read_buf;
-  if (g_io_channel_read_line (input_from_appletviewer,
-                              &read_buf, NULL, NULL, &err)
-      != G_IO_STATUS_NORMAL)
+  GCJPluginData* data = (GCJPluginData*) plugin_data;
+
+  // If data is NULL then GCJ_Destroy has already been called and
+  // plugin_out_pipe_callback is being called after plugin
+  // destruction.  In that case all we need to do is return FALSE so
+  // that the plugin_out_pipe_callback watch is removed.
+  if (data)
     {
-      g_printerr ("receive_message_from_appletviewer: Error: %s\n", 
err->message);
-      return NPERR_GENERIC_ERROR;
+      // Critical region.  Clear data->appletviewer_alive.
+      g_mutex_lock (data->appletviewer_mutex);
+
+      PLUGIN_DEBUG ("plugin_out_pipe_callback: appletviewer has stopped.");
+      data->appletviewer_alive = FALSE;
+
+      g_mutex_unlock (data->appletviewer_mutex);
     }
 
-  PIPE_INPUT_DEBUG (read_buf);
+  PLUGIN_DEBUG ("plugin_out_pipe_callback return");
 
-  return NPERR_NO_ERROR;
+  return FALSE;
+}
+
+static void
+plugin_start_appletviewer (GCJPluginData* data)
+{
+  PLUGIN_DEBUG ("plugin_start_appletviewer");
+
+  if (!data->appletviewer_alive)
+    {
+      GError* spawn_error = NULL;
+      gchar* command_line[3] = { NULL, NULL, NULL };
+
+      command_line[0] = g_strdup (GCJAPPLETVIEWER_EXECUTABLE);
+      // Output from plugin's perspective is appletviewer's input.
+      // Input from plugin's perspective is appletviewer's output.
+      command_line[1] = g_strdup_printf ("--plugin=%s,%s",
+                                         data->out_pipe_name,
+                                         data->in_pipe_name);
+      command_line[2] = NULL;
+
+      if (!g_spawn_async (NULL, command_line, NULL, (GSpawnFlags) 0,
+                          NULL, NULL, NULL, &spawn_error))
+        {
+          PLUGIN_ERROR_TWO ("Failed to spawn applet viewer",
+                            spawn_error->message);
+          goto cleanup;
+        }
+
+    cleanup:
+      g_free (command_line[0]);
+      g_free (command_line[1]);
+      g_free (command_line[2]);
+      if (spawn_error)
+        {
+          g_error_free (spawn_error);
+          spawn_error = NULL;
+        }
+    }
+
+  PLUGIN_DEBUG ("plugin_start_appletviewer return");
+}
+
+// Build up the applet tag string that we'll send to the applet
+// viewer.
+static gchar*
+plugin_create_applet_tag (int16 argc, char* argn[], char* argv[])
+{
+  PLUGIN_DEBUG ("plugin_create_applet_tag");
+
+  gchar* applet_tag = g_strdup ("<EMBED ");
+  gchar* parameters = g_strdup ("");
+
+  for (int16 i = 0; i < argc; i++)
+    {
+      if (!g_ascii_strcasecmp (argn[i], "code"))
+        {
+          gchar* code = g_strdup_printf ("CODE=\"%s\" ", argv[i]);
+         applet_tag = g_strconcat (applet_tag, code, NULL);
+          g_free (code);
+       }
+      else if (!g_ascii_strcasecmp (argn[i], "codebase"))
+       {
+          gchar* codebase = g_strdup_printf ("CODEBASE=\"%s\" ", argv[i]);
+         applet_tag = g_strconcat (applet_tag, codebase, NULL);
+          g_free (codebase);
+       }
+      else if (!g_ascii_strcasecmp (argn[i], "archive"))
+       {
+          gchar* archive = g_strdup_printf ("ARCHIVE=\"%s\" ", argv[i]);
+         applet_tag = g_strconcat (applet_tag, archive, NULL);
+          g_free (archive);
+       }
+      else if (!g_ascii_strcasecmp (argn[i], "width"))
+       {
+          gchar* width = g_strdup_printf ("WIDTH=\"%s\" ", argv[i]);
+         applet_tag = g_strconcat (applet_tag, width, NULL);
+          g_free (width);
+       }
+      else if (!g_ascii_strcasecmp (argn[i], "height"))
+       {
+          gchar* height = g_strdup_printf ("HEIGHT=\"%s\" ", argv[i]);
+         applet_tag = g_strconcat (applet_tag, height, NULL);
+          g_free (height);
+       }
+      else
+        {
+          // Escape the parameter value so that line termination
+          // characters will pass through the pipe.
+          if (argv[i] != '\0')
+            {
+              gchar* escaped = g_strescape (argv[i], NULL);
+              parameters = g_strconcat (parameters, "<PARAM NAME=\"", argn[i],
+                                        "\" VALUE=\"", escaped, "\">", NULL);
+              g_free (escaped);
+            }
+        }
+    }
+
+  applet_tag = g_strconcat (applet_tag, ">", parameters, "</EMBED>", NULL);
+
+  g_free (parameters);
+  parameters = NULL;
+
+  PLUGIN_DEBUG ("plugin_create_applet_tag return");
+
+  return applet_tag;
+}
+
+// plugin_send_message_to_appletviewer must be called while holding
+// data->appletviewer_mutex.
+static void
+plugin_send_message_to_appletviewer (GCJPluginData* data, gchar const* message)
+{
+  PLUGIN_DEBUG ("plugin_send_message_to_appletviewer");
+
+  if (data->appletviewer_alive)
+    {
+      GError* channel_error = NULL;
+      gchar* newline_message = NULL;
+      gsize bytes_written = 0;
+
+      // Send message to gcjappletviewer.
+      newline_message = g_strdup_printf ("%s\n", message);
+
+      // g_io_channel_write_chars will return something other than
+      // G_IO_STATUS_NORMAL if not all the data is written.  In that
+      // case we fail rather than retrying.
+      if (g_io_channel_write_chars (data->out_to_appletviewer,
+                                    newline_message, -1, &bytes_written,
+                                    &channel_error)
+          != G_IO_STATUS_NORMAL)
+        PLUGIN_ERROR_TWO ("Failed to write bytes to output channel",
+                          channel_error->message);
+
+      if (channel_error)
+        {
+          g_error_free (channel_error);
+          channel_error = NULL;
+        }
+
+      if (g_io_channel_flush (data->out_to_appletviewer, &channel_error)
+          != G_IO_STATUS_NORMAL)
+        PLUGIN_ERROR_TWO ("Failed to flush bytes to output channel",
+                          channel_error->message);
+
+      if (channel_error)
+        {
+          g_error_free (channel_error);
+          channel_error = NULL;
+        }
+      g_free (newline_message);
+
+      g_printerr ("  PIPE: plugin wrote %s", message);
+    }
+
+  PLUGIN_DEBUG ("plugin_send_message_to_appletviewer return");
+}
+
+// Stop the appletviewer process.  When this is called the
+// appletviewer can be in any of three states: running, crashed or
+// hung.  If the appletviewer is running then sending it "shutdown"
+// will cause it to exit.  This will cause
+// plugin_out_pipe_callback/plugin_in_pipe_callback to be called and
+// the input and output channels to be shut down.  If the appletviewer
+// has crashed then plugin_out_pipe_callback/plugin_in_pipe_callback
+// would already have been called and data->appletviewer_alive cleared
+// in which case this function simply returns.  If the appletviewer is
+// hung then this function will be successful and the input and output
+// watches will be removed by plugin_data_destroy.
+// plugin_stop_appletviewer must be called with
+// data->appletviewer_mutex held.
+static void
+plugin_stop_appletviewer (GCJPluginData* data)
+{
+  PLUGIN_DEBUG ("plugin_stop_appletviewer");
+
+  if (data->appletviewer_alive)
+    {
+      // Shut down the appletviewer.
+      GError* channel_error = NULL;
+      gsize bytes_written = 0;
+
+      if (data->out_to_appletviewer)
+        {
+          if (g_io_channel_write_chars (data->out_to_appletviewer, "shutdown",
+                                        -1, &bytes_written, &channel_error)
+              != G_IO_STATUS_NORMAL)
+            PLUGIN_ERROR_TWO ("Failed to write shutdown message to"
+                              " appletviewer", channel_error->message);
+
+          if (channel_error)
+            {
+              g_error_free (channel_error);
+              channel_error = NULL;
+            }
+
+          if (g_io_channel_flush (data->out_to_appletviewer, &channel_error)
+              != G_IO_STATUS_NORMAL)
+            PLUGIN_ERROR_TWO ("Failed to write shutdown message to"
+                              " appletviewer", channel_error->message);
+
+          if (channel_error)
+            {
+              g_error_free (channel_error);
+              channel_error = NULL;
+            }
+
+          if (g_io_channel_shutdown (data->out_to_appletviewer,
+                                     TRUE, &channel_error)
+              != G_IO_STATUS_NORMAL)
+            PLUGIN_ERROR_TWO ("Failed to shut down appletviewer"
+                              " output channel", channel_error->message);
+
+          if (channel_error)
+            {
+              g_error_free (channel_error);
+              channel_error = NULL;
+            }
+        }
+
+      if (data->in_from_appletviewer)
+        {
+          if (g_io_channel_shutdown (data->in_from_appletviewer,
+                                     TRUE, &channel_error)
+              != G_IO_STATUS_NORMAL)
+            PLUGIN_ERROR_TWO ("Failed to shut down appletviewer"
+                              " input channel", channel_error->message);
+
+          if (channel_error)
+            {
+              g_error_free (channel_error);
+              channel_error = NULL;
+            }
+        }
+    }
+
+  PLUGIN_DEBUG ("plugin_stop_appletviewer return");
 }
 
-// Factory functions.  Functions prefixed by NP_ provide functionality
-// that is common to the plug-in as a whole.  Instance functions
-// prefixed by GCJ_ operate on specific instances of GCJPluginData.
+static void
+plugin_data_destroy (GCJPluginData** data)
+{
+  PLUGIN_DEBUG ("plugin_data_destroy");
+
+  GCJPluginData* tofree = *data;
 
-// Provides the browser with pointers to the plug-in functions that we
+  tofree->window_handle = NULL;
+  tofree->window_height = 0;
+  tofree->window_width = 0;
+
+  // Copied from GCJ_New.
+
+  // cleanup_in_watch_source:
+  // Removing a source is harmless if it fails since it just means the
+  // source has already been removed.
+  g_source_remove (tofree->in_watch_source);
+  tofree->in_watch_source = 0;
+
+  // cleanup_in_from_appletviewer:
+  if (tofree->in_from_appletviewer)
+    g_io_channel_unref (tofree->in_from_appletviewer);
+  tofree->in_from_appletviewer = NULL;
+
+  // cleanup_out_watch_source:
+  g_source_remove (tofree->out_watch_source);
+  tofree->out_watch_source = 0;
+
+  // cleanup_out_to_appletviewer:
+  if (tofree->out_to_appletviewer)
+    g_io_channel_unref (tofree->out_to_appletviewer);
+  tofree->out_to_appletviewer = NULL;
+
+  // cleanup_out_pipe:
+  // Delete output pipe.
+  unlink (tofree->out_pipe_name);
+
+  // cleanup_out_pipe_name:
+  g_free (tofree->out_pipe_name);
+  tofree->out_pipe_name = NULL;
+
+  // cleanup_in_pipe:
+  // Delete input pipe.
+  unlink (tofree->in_pipe_name);
+
+  // cleanup_in_pipe_name:
+  g_free (tofree->in_pipe_name);
+  tofree->in_pipe_name = NULL;
+
+  // cleanup_appletviewer_mutex:
+  g_free (tofree->appletviewer_mutex);
+  tofree->appletviewer_mutex = NULL;
+
+  // cleanup_instance_string:
+  g_free (tofree->instance_string);
+  tofree->instance_string = NULL;
+
+  // cleanup_data:
+  // Eliminate back-pointer to plugin instance.
+  tofree->owner = NULL;
+  (*browserFunctions.memfree) (tofree);
+  tofree = NULL;
+
+  PLUGIN_DEBUG ("plugin_data_destroy return");
+}
+
+// FACTORY FUNCTIONS
+
+// Provides the browser with pointers to the plugin functions that we
 // implement and initializes a local table with browser functions that
 // we may wish to call.  Called once, after browser startup and before
-// the first plug-in instance is created.
+// the first plugin instance is created.
 NPError
-NP_Initialize(NPNetscapeFuncs* browserTable, NPPluginFuncs* pluginTable)
+NP_Initialize (NPNetscapeFuncs* browserTable, NPPluginFuncs* pluginTable)
 {
-  PLUGIN_DEBUG ("NP_Initialize\n");
+  PLUGIN_DEBUG ("NP_Initialize");
 
   if ((browserTable == NULL) || (pluginTable == NULL))
     {
-      PLUGIN_DEBUG ("NP_Initialize: Browser or plugin function table is 
NULL\n");
+      PLUGIN_ERROR ("Browser or plugin function table is NULL.");
+
       return NPERR_INVALID_FUNCTABLE_ERROR;
     }
 
-  // Ensure that the major version of the plug-in API that the browser
+  // Ensure that the major version of the plugin API that the browser
   // expects is not more recent than the major version of the API that
   // we've implemented.
   if ((browserTable->version >> 8) > NP_VERSION_MAJOR)
     {
-      PLUGIN_DEBUG ("NP_Initialize: Incompatible version\n");
+      PLUGIN_ERROR ("Incompatible version.");
+
       return NPERR_INCOMPATIBLE_VERSION_ERROR;
     }
 
-  // Ensure that the plug-in function table we've received is large
+  // Ensure that the plugin function table we've received is large
   // enough to store the number of functions that we may provide.
-  if (pluginTable->size < sizeof(NPPluginFuncs))      
+  if (pluginTable->size < sizeof (NPPluginFuncs))      
     {
-      PLUGIN_DEBUG ("NP_Initialize: Invalid plugin function table\n");
+      PLUGIN_ERROR ("Invalid plugin function table.");
+
       return NPERR_INVALID_FUNCTABLE_ERROR;
     }
 
   // Ensure that the browser function table is large enough to store
   // the number of browser functions that we may use.
-  if (browserTable->size < sizeof(NPNetscapeFuncs))
+  if (browserTable->size < sizeof (NPNetscapeFuncs))
     {
-      PLUGIN_DEBUG ("NP_Initialize: Invalid browser function table\n");
+      PLUGIN_ERROR ("Invalid browser function table.");
+
       return NPERR_INVALID_FUNCTABLE_ERROR;
     }
 
@@ -552,246 +1322,87 @@
   browserFunctions.reloadplugins = browserTable->reloadplugins;
   browserFunctions.getvalue = browserTable->getvalue;
 
-  // Return to the browser the plug-in functions that we implement.
+  // Return to the browser the plugin functions that we implement.
   pluginTable->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
-  pluginTable->size = sizeof(NPPluginFuncs);
-  pluginTable->newp = NewNPP_NewProc(GCJ_New);
-  pluginTable->destroy = NewNPP_DestroyProc(GCJ_Destroy);
-  pluginTable->setwindow = NewNPP_SetWindowProc(GCJ_SetWindow);
-  pluginTable->newstream = NewNPP_NewStreamProc(GCJ_NewStream);
-  pluginTable->destroystream = NewNPP_DestroyStreamProc(GCJ_DestroyStream);
-  pluginTable->asfile = NewNPP_StreamAsFileProc(GCJ_StreamAsFile);
-  pluginTable->writeready = NewNPP_WriteReadyProc(GCJ_WriteReady);
-  pluginTable->write = NewNPP_WriteProc(GCJ_Write);
-  pluginTable->print = NewNPP_PrintProc(GCJ_Print);
-  pluginTable->urlnotify = NewNPP_URLNotifyProc(GCJ_URLNotify);
-  pluginTable->getvalue = NewNPP_GetValueProc(GCJ_GetValue);
-
-  mutex_appletviewer_process = g_mutex_new ();
-  
-  PLUGIN_DEBUG ("NP_Initialize: No error\n");
-  return NPERR_NO_ERROR;
-}
+  pluginTable->size = sizeof (NPPluginFuncs);
+  pluginTable->newp = NewNPP_NewProc (GCJ_New);
+  pluginTable->destroy = NewNPP_DestroyProc (GCJ_Destroy);
+  pluginTable->setwindow = NewNPP_SetWindowProc (GCJ_SetWindow);
+  pluginTable->newstream = NewNPP_NewStreamProc (GCJ_NewStream);
+  pluginTable->destroystream = NewNPP_DestroyStreamProc (GCJ_DestroyStream);
+  pluginTable->asfile = NewNPP_StreamAsFileProc (GCJ_StreamAsFile);
+  pluginTable->writeready = NewNPP_WriteReadyProc (GCJ_WriteReady);
+  pluginTable->write = NewNPP_WriteProc (GCJ_Write);
+  pluginTable->print = NewNPP_PrintProc (GCJ_Print);
+  pluginTable->urlnotify = NewNPP_URLNotifyProc (GCJ_URLNotify);
+  pluginTable->getvalue = NewNPP_GetValueProc (GCJ_GetValue);
 
-static NPError
-start_appletviewer_process(void)
-{
-  PLUGIN_DEBUG ("start_appletviewer_process\n");
+  plugin_instance_mutex = g_mutex_new ();
 
-  // Add install prefix to PATH.
-  char *searchpath = getenv("PATH");
-  char *newpath = NULL;
-  
-  if (searchpath != NULL)
-    {
-      newpath = strcat(searchpath, ":" PREFIX "/bin");
-    }
-  else
-    {
-      newpath = ":" PREFIX "/bin";
-    }
-
-  setenv("PATH", newpath, 1);
-  
-  // Create named pipes.
-  gchar *pipename_in = g_strdup_printf ("/tmp/gcjwebplugin-%i-in", getpid ());
-  gchar *pipename_out = g_strdup_printf ("/tmp/gcjwebplugin-%i-out", getpid 
());
-  
-  if (mkfifo (pipename_in, 0700) == -1
-      && errno != EEXIST)
-    {
-      g_printerr ("start_appletviewer_process: Error: %s\n", strerror (errno));
-      return NPERR_GENERIC_ERROR;
-    }
+  PLUGIN_DEBUG ("NP_Initialize: using " GCJAPPLETVIEWER_EXECUTABLE ".");
 
-  if (mkfifo (pipename_out, 0700) == -1
-      && errno != EEXIST)
-    {
-      g_printerr ("start_appletviewer_process: Error: %s\n", strerror (errno));
-      return NPERR_GENERIC_ERROR;
-    }
+  PLUGIN_DEBUG ("NP_Initialize return");
 
-  GError *err = NULL;
-  gchar *command_line [3] = {
-    GCJAPPLETVIEWER_EXECUTABLE,
-    g_strdup_printf ("--plugin=%s,%s",
-                    pipename_in,
-                    pipename_out),
-    NULL
-  };
-
-  if (!g_spawn_async (NULL,
-                     command_line,
-                     NULL,
-                     G_SPAWN_SEARCH_PATH,
-                     NULL,
-                     NULL,
-                     NULL,
-                     &err))
-    {
-      g_printerr ("start_appletviewer_process: Error: %s\n", err->message);
-      return NPERR_GENERIC_ERROR;
-    }
-
-  g_printerr ("Spawned "
-             GCJAPPLETVIEWER_EXECUTABLE
-             " successfully.\n");
-
-  output_to_appletviewer = g_io_channel_new_file (pipename_in, "w", &err);
-  if (!output_to_appletviewer)
-    {
-      g_printerr ("start_appletviewer_process: Error: %s\n", err->message);
-      return NPERR_GENERIC_ERROR;
-    }
-  
-  input_from_appletviewer = g_io_channel_new_file (pipename_out, "r", &err);
-  if (!input_from_appletviewer)
-    {
-      g_printerr ("start_appletviewer_process: Error: %s\n", err->message);
-      return NPERR_GENERIC_ERROR;
-    }
-
-  NPError np_error;
-  if ((np_error = receive_message_from_appletviewer ("running")) != 
NPERR_NO_ERROR)
-    {
-      g_printerr ("start_appletviewer_process: Error\n");
-      return np_error;
-    }
-
-  g_printerr ("Got confirmation that gcjappletviewer is running.\n");
-
-  // Add callback to input channel from appletviewer.
-  viewer_watch = g_io_add_watch (input_from_appletviewer, G_IO_IN,
-                                callbackViewerRead, NULL);
-  
-  PLUGIN_DEBUG ("start_appletviewer_process: No error\n");
   return NPERR_NO_ERROR;
 }
 
-// Returns a string describing the MIME type that this plug-in
+// Returns a string describing the MIME type that this plugin
 // handles.
-char *
-NP_GetMIMEDescription(void)
+char*
+NP_GetMIMEDescription (void)
 {
-  PLUGIN_DEBUG ("NP_GetMIMEDescription\n");
+  PLUGIN_DEBUG ("NP_GetMIMEDescription");
+
+  PLUGIN_DEBUG ("NP_GetMIMEDescription return");
 
-  PLUGIN_DEBUG ("NP_GetMIMEDescription: No error\n");
-  return PLUGIN_MIME_DESC;
+  return (char*) PLUGIN_MIME_DESC;
 }
 
-// Returns a value relevant to the plug-in as a whole.  The browser
-// calls this function to obtain information about the plug-in.
+// Returns a value relevant to the plugin as a whole.  The browser
+// calls this function to obtain information about the plugin.
 NPError
-NP_GetValue(void* future, NPPVariable variable, void *value)
+NP_GetValue (void* future, NPPVariable variable, void* value)
 {
-  PLUGIN_DEBUG ("NP_GetValue\n");
+  PLUGIN_DEBUG ("NP_GetValue");
 
   NPError result = NPERR_NO_ERROR;
+  gchar** char_value = (gchar**) value;
 
   switch (variable)
     {
     case NPPVpluginNameString:
-      PLUGIN_DEBUG ("NP_GetValue: Returning plug-in NameString value\n");
-      *((char**) value) = PLUGIN_NAME " " PACKAGE_VERSION;
+      PLUGIN_DEBUG ("NP_GetValue: returning plugin name.");
+      *char_value = g_strdup (PLUGIN_NAME " " PACKAGE_VERSION);
       break;
 
     case NPPVpluginDescriptionString:
-      PLUGIN_DEBUG ("NP_GetValue: Returning plug-in DescriptionString 
value\n");
-      *((char**) value) = PLUGIN_DESC;
+      PLUGIN_DEBUG ("NP_GetValue: returning plugin description.");
+      *char_value = g_strdup (PLUGIN_DESC);
       break;
 
     default:
-      PLUGIN_DEBUG ("NP_GetValue: Unknown plug-in value requested\n");
+      PLUGIN_ERROR ("Unknown plugin value requested.");
       result = NPERR_GENERIC_ERROR;
       break;
     }
 
-  PLUGIN_DEBUG ("NP_GetValue: No error\n");
+  PLUGIN_DEBUG ("NP_GetValue return");
+
   return result;
 }
 
-// Shuts down the plug-in.  Called after the last plug-in instance is
+// Shuts down the plugin.  Called after the last plugin instance is
 // destroyed.
 NPError
-NP_Shutdown(void)
+NP_Shutdown (void)
 {
-  PLUGIN_DEBUG ("NP_Shutdown\n");
-
-  GError *err = NULL;
-  gsize bytes_written;
-
-  if (output_to_appletviewer)
-    {
-      if (g_io_channel_write_chars (output_to_appletviewer, "shutdown", -1,
-                                   &bytes_written, &err)
-         != G_IO_STATUS_NORMAL)
-       {
-         g_printerr ("send_message_to_appletviewer: Error: %s\n",
-                     err->message);
-         return NPERR_GENERIC_ERROR;
-       }
-
-      if (g_io_channel_flush (output_to_appletviewer,
-                             &err) != G_IO_STATUS_NORMAL)
-       {
-         g_printerr ("send_message_to_appletviewer: Error: %s\n",
-                     err->message);
-         return NPERR_GENERIC_ERROR;
-       }
-
-      if (g_io_channel_shutdown (output_to_appletviewer,
-                                TRUE, &err) != G_IO_STATUS_NORMAL)
-       {
-         g_printerr ("NP_Shutdown: Error: %s\n", err->message);
-         return NPERR_GENERIC_ERROR;
-       }
-
-      output_to_appletviewer = NULL;
-    }
-
-  if (input_from_appletviewer)
-    {
-      if (g_io_channel_shutdown (input_from_appletviewer,
-                                TRUE, &err) != G_IO_STATUS_NORMAL)
-       {
-         g_printerr ("NP_Shutdown: Error: %s\n", err->message);
-         return NPERR_GENERIC_ERROR;
-       }
-      
-      input_from_appletviewer = NULL;
-    }
+  PLUGIN_DEBUG ("NP_Shutdown");
 
   // Free mutex.
-  g_mutex_free (mutex_appletviewer_process);
-  mutex_appletviewer_process = NULL;
-  
-  // Delete named pipes.
-  gchar *pipename_in = g_strdup_printf ("/tmp/gcjwebplugin-%i-in", getpid ());
-  gchar *pipename_out = g_strdup_printf ("/tmp/gcjwebplugin-%i-out", getpid 
());
+  g_mutex_free (plugin_instance_mutex);
+  plugin_instance_mutex = NULL;
 
-  unlink (pipename_in);
-  unlink (pipename_out);
+  PLUGIN_DEBUG ("NP_Shutdown return");
 
-  g_printerr ("Done shutting down.\n");
-
-  PLUGIN_DEBUG ("NP_Shutdown: No error\n");
   return NPERR_NO_ERROR;
 }
-
-static gboolean
-callbackViewerRead (GIOChannel *source, GIOCondition condition, gpointer data)
-{
-  // Read pipe data.
-  GError *err = NULL;
-  gchar* read_buf;
-  if (g_io_channel_read_line (input_from_appletviewer,
-                              &read_buf, NULL, NULL, &err)
-      != G_IO_STATUS_NORMAL)
-    {
-      g_printerr ("receive_message_from_appletviewer: Error: %s\n", 
err->message);
-    }
-
-  // FIXME: Add handling of read input here.
-
-  return TRUE;
-}
Index: src/jniHelp.h
===================================================================
RCS file: src/jniHelp.h
diff -N src/jniHelp.h
--- src/jniHelp.h       28 Jul 2003 07:00:43 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,88 +0,0 @@
-/* gcjwebplugin - Webbrowser plugin to execute Java (tm) applets.
-   Copyright (C) 2003  Michael Koch <address@hidden>
-
-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. */
-
-
-#define CHECK_EXCEPTIONS(env) \
-  if (env->ExceptionOccurred ()) \
-    { \
-       env->ExceptionDescribe (); \
-       env->ExceptionClear (); \
-    }
-
-#define JNI_FindClass(env, name, result) \
-result = env->FindClass (name); \
-assert (result != NULL);
-
-#define JNI_GetObjectClass(env, obj, result) \
-result = env->GetObjectClass (obj); \
-assert (result != NULL);
-
-#define JNI_GetMethodID(env, clazz, name, sig, result) \
-result = env->GetMethodID (clazz, name, sig); \
-assert (result != NULL);
-
-#define JNI_NewObject0(env, clazz, method, result) \
-result = env->NewObject (clazz, method); \
-assert (result != NULL); \
-CHECK_EXCEPTIONS (env);
-
-#define JNI_NewObject1(env, clazz, method, arg1, result) \
-result = env->NewObject (clazz, method, arg1); \
-assert (result != NULL); \
-CHECK_EXCEPTIONS (env);
-
-#define JNI_CallObjectMethod0(env, clazz, method, result) \
-result = env->CallObjectMethod (clazz, method); \
-CHECK_EXCEPTIONS (env);
-
-#define JNI_CallObjectMethod1(env, clazz, method, arg1, result) \
-result = env->CallObjectMethod (clazz, method, arg1); \
-CHECK_EXCEPTIONS (env);
-
-#define JNI_CallVoidMethod0(env, clazz, method) \
-env->CallVoidMethod (clazz, method); \
-CHECK_EXCEPTIONS (env);
-
-#define JNI_CallVoidMethod1(env, clazz, method, arg1) \
-env->CallVoidMethod (clazz, method, arg1); \
-CHECK_EXCEPTIONS (env);
-
-#define JNI_CallVoidMethod2(env, clazz, method, arg1, arg2) \
-env->CallVoidMethod (clazz, method, arg1, arg2); \
-CHECK_EXCEPTIONS (env);
-
-#define JNI_CallVoidMethod3(env, clazz, method, arg1, arg2, arg3) \
-env->CallVoidMethod (clazz, method, arg1, arg2, arg3); \
-CHECK_EXCEPTIONS (env);
Index: src/pluginDebug.h
===================================================================
RCS file: src/pluginDebug.h
diff -N src/pluginDebug.h
--- src/pluginDebug.h   22 Feb 2006 21:17:31 -0000      1.7
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,54 +0,0 @@
-/* gcjwebplugin - Webbrowser plugin to execute Java (tm) applets.
-   Copyright (C) 2003, 2006  Michael Koch <address@hidden>
-
-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. */
-
-
-#include <glib.h>
-
-#ifdef DEBUG
-
-#define PLUGIN_DEBUG(arg)              g_printerr ("GCJ PLUGIN: %s", arg)
-#define PLUGIN_DEBUG2(output, arg)     g_printerr ("GCJ PLUGIN: " output, arg);
-
-#define PIPE_OUTPUT_DEBUG(arg)         g_printerr ("  PIPE: plugin wrote: 
%s\n", arg)
-#define PIPE_INPUT_DEBUG(arg)          g_printerr ("  PIPE: plugin read: 
%s\n",  arg)
-
-#else
-
-#define PLUGIN_DEBUG(output) ;
-#define PLUGIN_DEBUG2(output, arg) ;
-#define PIPE_INPUT_DEBUG(arg) ;
-#define PIPE_OUTPUT_DEBUG(arg) ;
-
-#endif
Index: src/pluginMeta.h
===================================================================
RCS file: src/pluginMeta.h
diff -N src/pluginMeta.h
--- src/pluginMeta.h    27 Nov 2003 13:40:29 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,76 +0,0 @@
-/* gcjwebplugin - Webbrowser plugin to execute Java (tm) applets.
-   Copyright (C) 2003  Michael Koch <address@hidden>
-
-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. */
-
-
-#include "config.h"
-
-#define PLUGIN_NAME "GCJ web browser plug-in"
-#define PLUGIN_DESC "The " PLUGIN_NAME \
-  " executes Java applets in Mozilla and other web browsers."
-#define PLUGIN_MIME_DESC                                           \
-  "application/x-java-vm:class,jar:GCJ;"                           \
-  "application/x-java-applet:class,jar:GCJ;"                       \
-  "application/x-java-applet;version=1.1:class,jar:GCJ;"           \
-  "application/x-java-applet;version=1.1.1:class,jar:GCJ;"         \
-  "application/x-java-applet;version=1.1.2:class,jar:GCJ;"         \
-  "application/x-java-applet;version=1.1.3:class,jar:GCJ;"         \
-  "application/x-java-applet;version=1.2:class,jar:GCJ;"           \
-  "application/x-java-applet;version=1.2.1:class,jar:GCJ;"         \
-  "application/x-java-applet;version=1.2.2:class,jar:GCJ;"         \
-  "application/x-java-applet;version=1.3:class,jar:GCJ;"           \
-  "application/x-java-applet;version=1.3.1:class,jar:GCJ;"         \
-  "application/x-java-applet;version=1.4:class,jar:GCJ;"           \
-  "application/x-java-applet;version=1.4.1:class,jar:GCJ;"         \
-  "application/x-java-applet;version=1.4.2:class,jar:GCJ;"         \
-  "application/x-java-applet;jpi-version=1.4.2_01:class,jar:GCJ;"  \
-  "application/x-java-bean:class,jar:GCJ;"                         \
-  "application/x-java-bean;version=1.1:class,jar:GCJ;"             \
-  "application/x-java-bean;version=1.1.1:class,jar:GCJ;"           \
-  "application/x-java-bean;version=1.1.2:class,jar:GCJ;"           \
-  "application/x-java-bean;version=1.1.3:class,jar:GCJ;"           \
-  "application/x-java-bean;version=1.2:class,jar:GCJ;"             \
-  "application/x-java-bean;version=1.2.1:class,jar:GCJ;"           \
-  "application/x-java-bean;version=1.2.2:class,jar:GCJ;"           \
-  "application/x-java-bean;version=1.3:class,jar:GCJ;"             \
-  "application/x-java-bean;version=1.3.1:class,jar:GCJ;"           \
-  "application/x-java-bean;version=1.4:class,jar:GCJ;"             \
-  "application/x-java-bean;version=1.4.1:class,jar:GCJ;"           \
-  "application/x-java-bean;version=1.4.2:class,jar:GCJ;"           \
-  "application/x-java-bean;jpi-version=1.4.2_01:class,jar:GCJ;"
-#define PLUGIN_URL NS_INLINE_PLUGIN_CONTRACTID_PREFIX NS_JVM_MIME_TYPE
-
-#define PLUGIN_MIME_TYPE "application/x-java-vm"
-#define PLUGIN_FILE_EXTS "class,jar,zip"
-#define PLUGIN_MIME_COUNT 1
Index: src/test.cc
===================================================================
RCS file: src/test.cc
diff -N src/test.cc
--- src/test.cc 4 Jul 2003 07:04:43 -0000       1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-/* gcjwebplugin - Webbrowser plugin to execute Java (tm) applets.
-   Copyright (C) 2003  Michael Koch <address@hidden>
-
-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. */
-
-
-typedef int nsID;
-
-class nsISupports;
-class nsIShutdownListener;
-
-namespace nsServiceManager
-{
-  void GetService(nsID const&, nsID const&, nsISupports**, 
nsIShutdownListener*)
-  {
-  }
-}
-
-int main (int argc, char** argv)
-{
-  return 0;
-}
Index: src/gnu/gcjwebplugin/PluginAppletContext.java
===================================================================
RCS file: 
/sources/gcjwebplugin/gcjwebplugin/src/gnu/gcjwebplugin/PluginAppletContext.java,v
retrieving revision 1.6
diff -u -r1.6 PluginAppletContext.java
--- src/gnu/gcjwebplugin/PluginAppletContext.java       3 Apr 2004 10:21:34 
-0000       1.6
+++ src/gnu/gcjwebplugin/PluginAppletContext.java       28 Mar 2006 11:11:52 
-0000
@@ -1,5 +1,5 @@
 /* PluginAppletContext.java -- an applet's context within a web browser
-   Copyright (C) 2003  Thomas Fitzsimmons <address@hidden>
+   Copyright (C) 2003, 2006  Thomas Fitzsimmons <address@hidden>
 
    This file is part of GCJ Applet Viewer.
 
@@ -21,7 +21,7 @@
 package gnu.gcjwebplugin;
 
 import java.net.URL;
-
+import java.io.IOException;
 
 /*
  * PluginAppletContext represents the context within a webpage of a
@@ -29,15 +29,27 @@
  */
 class PluginAppletContext extends CommonAppletContext
 {
-  // FIXME: implement.
   public void showDocument(URL url, String target)
   {
-    System.err.println("showDocument is not implemented in plugin mode");
+    try
+      {
+        PluginAppletViewer.write("url " + url + " " + target);
+      }
+    catch(IOException e)
+      {
+        System.err.println("showDocument failed: " + e);
+      }
   }
 
-  // FIXME: implement.
   public void showStatus(String status)
   {
-    System.err.println("showStatus is not implemented in plugin mode");
+    try
+      {
+        PluginAppletViewer.write("status " + status);
+      }
+    catch(IOException e)
+      {
+        System.err.println("showDocument failed: " + e);
+      }
   }
 }
Index: src/gnu/gcjwebplugin/PluginAppletViewer.java
===================================================================
RCS file: 
/sources/gcjwebplugin/gcjwebplugin/src/gnu/gcjwebplugin/PluginAppletViewer.java,v
retrieving revision 1.20
diff -u -r1.20 PluginAppletViewer.java
--- src/gnu/gcjwebplugin/PluginAppletViewer.java        15 Feb 2006 07:10:54 
-0000      1.20
+++ src/gnu/gcjwebplugin/PluginAppletViewer.java        28 Mar 2006 11:11:52 
-0000
@@ -1,5 +1,5 @@
 /* PluginAppletViewer.java - manages embeddable applet windows
-   Copyright (C) 2003  Thomas Fitzsimmons <address@hidden>
+   Copyright (C) 2003, 2006  Thomas Fitzsimmons <address@hidden>
 
    This file is part of GCJ Applet Viewer.
 
@@ -99,9 +99,9 @@
 
            currentWindow.setTag(tag, documentbase, "UTF8");
          }
-       else if (message.startsWith("xid"))
+       else if (message.startsWith("handle"))
          {
-           long handle = Long.parseLong(message.substring(4));
+           long handle = Long.parseLong(message.substring(7));
 
            currentWindow.setHandle(handle);
          }
Index: src/gnu/gcjwebplugin/UserConfiguration.java
===================================================================
RCS file: 
/sources/gcjwebplugin/gcjwebplugin/src/gnu/gcjwebplugin/UserConfiguration.java,v
retrieving revision 1.1
diff -u -r1.1 UserConfiguration.java
--- src/gnu/gcjwebplugin/UserConfiguration.java 15 Feb 2006 07:10:54 -0000      
1.1
+++ src/gnu/gcjwebplugin/UserConfiguration.java 28 Mar 2006 11:11:52 -0000
@@ -39,7 +39,7 @@
   public static boolean showJavaConsole()
   {
     // TODO: Implement me for real.
-    return true;
+    return false;
   }
 
   public static boolean showWarning()
Index: src/gnu/gcjwebplugin/oji/jniHelp.h
===================================================================
RCS file: src/gnu/gcjwebplugin/oji/jniHelp.h
diff -N src/gnu/gcjwebplugin/oji/jniHelp.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/gnu/gcjwebplugin/oji/jniHelp.h  28 Mar 2006 11:11:52 -0000
@@ -0,0 +1,88 @@
+/* gcjwebplugin - Webbrowser plugin to execute Java (tm) applets.
+   Copyright (C) 2003  Michael Koch <address@hidden>
+
+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. */
+
+
+#define CHECK_EXCEPTIONS(env) \
+  if (env->ExceptionOccurred ()) \
+    { \
+       env->ExceptionDescribe (); \
+       env->ExceptionClear (); \
+    }
+
+#define JNI_FindClass(env, name, result) \
+result = env->FindClass (name); \
+assert (result != NULL);
+
+#define JNI_GetObjectClass(env, obj, result) \
+result = env->GetObjectClass (obj); \
+assert (result != NULL);
+
+#define JNI_GetMethodID(env, clazz, name, sig, result) \
+result = env->GetMethodID (clazz, name, sig); \
+assert (result != NULL);
+
+#define JNI_NewObject0(env, clazz, method, result) \
+result = env->NewObject (clazz, method); \
+assert (result != NULL); \
+CHECK_EXCEPTIONS (env);
+
+#define JNI_NewObject1(env, clazz, method, arg1, result) \
+result = env->NewObject (clazz, method, arg1); \
+assert (result != NULL); \
+CHECK_EXCEPTIONS (env);
+
+#define JNI_CallObjectMethod0(env, clazz, method, result) \
+result = env->CallObjectMethod (clazz, method); \
+CHECK_EXCEPTIONS (env);
+
+#define JNI_CallObjectMethod1(env, clazz, method, arg1, result) \
+result = env->CallObjectMethod (clazz, method, arg1); \
+CHECK_EXCEPTIONS (env);
+
+#define JNI_CallVoidMethod0(env, clazz, method) \
+env->CallVoidMethod (clazz, method); \
+CHECK_EXCEPTIONS (env);
+
+#define JNI_CallVoidMethod1(env, clazz, method, arg1) \
+env->CallVoidMethod (clazz, method, arg1); \
+CHECK_EXCEPTIONS (env);
+
+#define JNI_CallVoidMethod2(env, clazz, method, arg1, arg2) \
+env->CallVoidMethod (clazz, method, arg1, arg2); \
+CHECK_EXCEPTIONS (env);
+
+#define JNI_CallVoidMethod3(env, clazz, method, arg1, arg2, arg3) \
+env->CallVoidMethod (clazz, method, arg1, arg2, arg3); \
+CHECK_EXCEPTIONS (env);
Index: src/gnu/gcjwebplugin/oji/pluginDebug.h
===================================================================
RCS file: src/gnu/gcjwebplugin/oji/pluginDebug.h
diff -N src/gnu/gcjwebplugin/oji/pluginDebug.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/gnu/gcjwebplugin/oji/pluginDebug.h      28 Mar 2006 11:11:52 -0000
@@ -0,0 +1,54 @@
+/* gcjwebplugin - Webbrowser plugin to execute Java (tm) applets.
+   Copyright (C) 2003, 2006  Michael Koch <address@hidden>
+
+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. */
+
+
+#include <glib.h>
+
+#ifdef DEBUG
+
+#define PLUGIN_DEBUG(arg)              g_printerr ("GCJ PLUGIN: %s", arg)
+#define PLUGIN_DEBUG2(output, arg)     g_printerr ("GCJ PLUGIN: " output, arg);
+
+#define PIPE_OUTPUT_DEBUG(arg)         g_printerr ("  PIPE: plugin wrote: 
%s\n", arg)
+#define PIPE_INPUT_DEBUG(arg)          g_printerr ("  PIPE: plugin read: 
%s\n",  arg)
+
+#else
+
+#define PLUGIN_DEBUG(output) ;
+#define PLUGIN_DEBUG2(output, arg) ;
+#define PIPE_INPUT_DEBUG(arg) ;
+#define PIPE_OUTPUT_DEBUG(arg) ;
+
+#endif
Index: src/gnu/gcjwebplugin/oji/pluginMeta.h
===================================================================
RCS file: src/gnu/gcjwebplugin/oji/pluginMeta.h
diff -N src/gnu/gcjwebplugin/oji/pluginMeta.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/gnu/gcjwebplugin/oji/pluginMeta.h       28 Mar 2006 11:11:52 -0000
@@ -0,0 +1,76 @@
+/* gcjwebplugin - Webbrowser plugin to execute Java (tm) applets.
+   Copyright (C) 2003  Michael Koch <address@hidden>
+
+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. */
+
+
+#include "config.h"
+
+#define PLUGIN_NAME "GCJ web browser plug-in"
+#define PLUGIN_DESC "The " PLUGIN_NAME \
+  " executes Java applets in Mozilla and other web browsers."
+#define PLUGIN_MIME_DESC                                           \
+  "application/x-java-vm:class,jar:GCJ;"                           \
+  "application/x-java-applet:class,jar:GCJ;"                       \
+  "application/x-java-applet;version=1.1:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.1.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.1.2:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.1.3:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.2:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.2.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.2.2:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.3:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.3.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.4:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.4.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.4.2:class,jar:GCJ;"         \
+  "application/x-java-applet;jpi-version=1.4.2_01:class,jar:GCJ;"  \
+  "application/x-java-bean:class,jar:GCJ;"                         \
+  "application/x-java-bean;version=1.1:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.1.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.1.2:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.1.3:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.2:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.2.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.2.2:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.3:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.3.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.4:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.4.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.4.2:class,jar:GCJ;"           \
+  "application/x-java-bean;jpi-version=1.4.2_01:class,jar:GCJ;"
+#define PLUGIN_URL NS_INLINE_PLUGIN_CONTRACTID_PREFIX NS_JVM_MIME_TYPE
+
+#define PLUGIN_MIME_TYPE "application/x-java-vm"
+#define PLUGIN_FILE_EXTS "class,jar,zip"
+#define PLUGIN_MIME_COUNT 1

reply via email to

[Prev in Thread] Current Thread [Next in Thread]