commit-classpath
[Top][All Lists]
Advanced

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

[commit-cp] classpath ChangeLog native/plugin/gcjwebplugin.cc


From: Lillian Angel
Subject: [commit-cp] classpath ChangeLog native/plugin/gcjwebplugin.cc
Date: Mon, 05 Jun 2006 18:20:15 +0000

CVSROOT:        /cvsroot/classpath
Module name:    classpath
Changes by:     Lillian Angel <langel>  06/06/05 18:20:15

Modified files:
        .              : ChangeLog 
        native/plugin  : gcjwebplugin.cc 

Log message:
        2006-06-05  Lillian Angel  <address@hidden>
        
                * native/plugin/gcjwebplugin.cc:
                Added new field to keep track of initialization.
                (plugin_start_appletviewer): Fixed to return an error value, if
                an error was encountered when loading the appletviewer.
                (GCJ_NEW): Added call to plugin_failed if the loading of the 
appletviewer
                has failed.
                (plugin_failed): New helper function. Shows a warning if the 
appletviewer
                has not been installed.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.7657&r2=1.7658
http://cvs.savannah.gnu.org/viewcvs/classpath/native/plugin/gcjwebplugin.cc?cvsroot=classpath&r1=1.2&r2=1.3

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.7657
retrieving revision 1.7658
diff -u -b -r1.7657 -r1.7658
--- ChangeLog   5 Jun 2006 14:19:59 -0000       1.7657
+++ ChangeLog   5 Jun 2006 18:20:14 -0000       1.7658
@@ -1,5 +1,16 @@
 2006-06-05  Lillian Angel  <address@hidden>
 
+       * native/plugin/gcjwebplugin.cc:
+       Added new field to keep track of initialization.
+       (plugin_start_appletviewer): Fixed to return an error value, if
+       an error was encountered when loading the appletviewer.
+       (GCJ_NEW): Added call to plugin_failed if the loading of the 
appletviewer
+       has failed.
+       (plugin_failed): New helper function. Shows a warning if the 
appletviewer
+       has not been installed.
+
+2006-06-05  Lillian Angel  <address@hidden>
+
        * native/plugin/Makefile.am:
        Fixed to use a set plugin directory in the .mozilla directory.
        All applet logs are now stored here, instead of /tmp.

Index: native/plugin/gcjwebplugin.cc
===================================================================
RCS file: /cvsroot/classpath/classpath/native/plugin/gcjwebplugin.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- native/plugin/gcjwebplugin.cc       5 Jun 2006 14:20:00 -0000       1.2
+++ native/plugin/gcjwebplugin.cc       5 Jun 2006 18:20:15 -0000       1.3
@@ -134,6 +134,9 @@
   "The whitelist is a list of the URLs from which you trust"            \
   " applets.\n"                                                         \
   "Your whitelist file is \"" WHITELIST_FILENAME "\"."
+#define FAILURE_MESSAGE                                                     \
+  "This page wants to load an applet.\n"                                    \
+  "There is no appletviewer installed in \"" APPLETVIEWER_EXECUTABLE "\"."  \
 
 // Documentbase retrieval required definition.
 static NS_DEFINE_IID (kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID);
@@ -141,6 +144,10 @@
 // Browser function table.
 static NPNetscapeFuncs browserFunctions;
 
+// Keeps track of initialization. NP_INITIALIZE should only be
+// called once.
+bool initialized = false;
+
 // 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
@@ -192,6 +199,8 @@
 static void plugin_data_new (GCJPluginData** data);
 // Documentbase retrieval.
 static gchar* plugin_get_documentbase (NPP instance);
+// plugin failure handling.
+static bool plugin_failed ();
 // Whitelist handling.
 static bool plugin_user_trusts_documentbase (char* documentbase);
 static bool plugin_ask_user_about_documentbase (char* documentbase);
@@ -204,7 +213,7 @@
 static gboolean plugin_out_pipe_callback (GIOChannel* source,
                                           GIOCondition condition,
                                           gpointer plugin_data);
-static void plugin_start_appletviewer (GCJPluginData* data);
+static NPError 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,
@@ -368,7 +377,15 @@
   // watch callbacks.
   g_mutex_lock (data->appletviewer_mutex);
 
-  plugin_start_appletviewer (data);
+  np_error = plugin_start_appletviewer (data);
+  
+  // If the appletviewer is not installed, then a dialog box will
+  // show up and the plugin will be killed.
+  if (np_error != NPERR_NO_ERROR)
+    {
+      if (plugin_failed ())
+        goto cleanup_applet_failure; 
+       }
 
   // Create plugin-to-appletviewer channel.  The default encoding for
   // the file is UTF-8.
@@ -493,6 +510,7 @@
   // Delete output pipe.
   unlink (data->out_pipe_name);
 
+ cleanup_applet_failure:
  cleanup_out_pipe_name:
   g_free (data->out_pipe_name);
   data->out_pipe_name = NULL;
@@ -879,6 +897,32 @@
   return documentbase_copy;
 }
 
+// This function shows a error message if the appletviewer has
+// not been installed. It returns true, if the user presses the
+// ok button.
+static bool
+plugin_failed ()
+{
+  GtkWidget* dialog = NULL;
+  GtkWidget* ok_button = NULL;
+
+  dialog = gtk_message_dialog_new (NULL,
+                                   GTK_DIALOG_MODAL,
+                                   GTK_MESSAGE_WARNING,
+                                   GTK_BUTTONS_NONE,
+                                   FAILURE_MESSAGE);
+  ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                     GTK_STOCK_OK,
+                                     GTK_RESPONSE_OK);
+  gtk_widget_show_all (dialog);
+  if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
+    {
+      gtk_widget_destroy (dialog);
+      return true;       
+    }
+  return false;
+}
+
 // plugin_user_trusts_documentbase returns true if the given
 // documentbase is in the documentbase whitelist.  Otherwise it asks
 // the user if he trusts the given documentbase by calling
@@ -1173,10 +1217,11 @@
   return FALSE;
 }
 
-static void
+static NPError
 plugin_start_appletviewer (GCJPluginData* data)
 {
   PLUGIN_DEBUG ("plugin_start_appletviewer");
+  NPError error = NPERR_NO_ERROR;
 
   if (!data->appletviewer_alive)
     {
@@ -1202,6 +1247,7 @@
             }
           else
             PLUGIN_ERROR ("Failed to spawn applet viewer");
+          error = NPERR_GENERIC_ERROR;
           goto cleanup;
         }
 
@@ -1215,6 +1261,7 @@
     }
 
   PLUGIN_DEBUG ("plugin_start_appletviewer return");
+  return error;
 }
 
 // Build up the applet tag string that we'll send to the applet
@@ -1517,7 +1564,9 @@
 {
   PLUGIN_DEBUG ("NP_Initialize");
 
-  if ((browserTable == NULL) || (pluginTable == NULL))
+  if (initialized)
+    return NPERR_NO_ERROR;
+  else if ((browserTable == NULL) || (pluginTable == NULL))
     {
       PLUGIN_ERROR ("Browser or plugin function table is NULL.");
 
@@ -1622,6 +1671,7 @@
   pluginTable->urlnotify = NewNPP_URLNotifyProc (GCJ_URLNotify);
   pluginTable->getvalue = NewNPP_GetValueProc (GCJ_GetValue);
 
+  initialized = true;
   plugin_instance_mutex = g_mutex_new ();
 
   PLUGIN_DEBUG ("NP_Initialize: using " APPLETVIEWER_EXECUTABLE ".");




reply via email to

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