I fixed gcjwebplugin to determine the data directory at runtime, instead
of when the plugin is installed.
2006-06-08 Lillian Angel <[EMAIL PROTECTED]>
* native/plugin/Makefile.am:
Removed DATA_DIRECTORY.
* native/plugin/gcjwebplugin.cc:
Added new global fields for whitelist_file
and data_directory. Removed WHITELIST_FILE.
(NP_Initialize): Initialized new fields. Also,
Changed to use new fields.
(NP_Shutdown): Freed data_directory.
(GCJ_New): Changed to use new fields.
(plugin_ask_user_about_documentbase): Likewise.
Index: native/plugin/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/native/plugin/Makefile.am,v
retrieving revision 1.3
diff -u -r1.3 Makefile.am
--- native/plugin/Makefile.am 8 Jun 2006 20:27:54 -0000 1.3
+++ native/plugin/Makefile.am 8 Jun 2006 21:38:46 -0000
@@ -4,7 +4,6 @@
libgcjwebplugin_la_CXXFLAGS = \
-Wall -DAPPLETVIEWER_EXECUTABLE="\"$(bindir)/appletviewer\"" \
- -DDATA_DIRECTORY="\"$(HOME)/.gcjwebplugin\"" \
$(MOZILLA_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS)
libgcjwebplugin_la_LDFLAGS = -avoid-version \
Index: native/plugin/gcjwebplugin.cc
===================================================================
RCS file: /cvsroot/classpath/classpath/native/plugin/gcjwebplugin.cc,v
retrieving revision 1.8
diff -u -r1.8 gcjwebplugin.cc
--- native/plugin/gcjwebplugin.cc 8 Jun 2006 20:27:54 -0000 1.8
+++ native/plugin/gcjwebplugin.cc 8 Jun 2006 21:38:46 -0000
@@ -120,7 +120,6 @@
// Security dialog messages.
#define RESPONSE_TRUST_APPLET "Trust Applet"
#define RESPONSE_TRUST_APPLET_ADD_TO_LIST "Trust Applet and Add to Whitelist"
-#define WHITELIST_FILENAME DATA_DIRECTORY "/whitelist.txt"
#define SECURITY_WARNING \
"%s wants to load an applet.\n" \
"GNU Classpath's security implementation is not complete.\n" \
@@ -132,7 +131,7 @@
" and run this applet from now on, without asking.\n" \
"The whitelist is a list of the URLs from which you trust" \
" applets.\n" \
- "Your whitelist file is \"" WHITELIST_FILENAME "\"."
+ "Your whitelist file is \" %s \"."
#define FAILURE_MESSAGE \
"This page wants to load an applet.\n" \
"The appletviewer is missing or not installed properly in \"" \
@@ -144,9 +143,15 @@
// Browser function table.
static NPNetscapeFuncs browserFunctions;
+// Data directory for plugin.
+static gchar* data_directory;
+
+// Whitelist filename
+static gchar* whitelist_filename;
+
// Keeps track of initialization. NP_Initialize should only be
// called once.
-bool initialized = false;
+gboolean initialized = false;
// GCJPluginData stores all the data associated with a single plugin
// instance. A separate plugin instance is created for each <APPLET>
@@ -326,9 +331,8 @@
// pipe.
// data->in_pipe_name
- data->in_pipe_name = g_strdup_printf (DATA_DIRECTORY
- "/gcj-%s-appletviewer-to-plugin",
- data->instance_string);
+ data->in_pipe_name = g_strdup_printf ("%s/gcj-%s-appletviewer-to-plugin",
+ data_directory, data->instance_string);
if (!data->in_pipe_name)
{
PLUGIN_ERROR ("Failed to create input pipe name.");
@@ -349,9 +353,8 @@
// output pipe.
// data->out_pipe_name
- data->out_pipe_name = g_strdup_printf (DATA_DIRECTORY
- "/gcj-%s-plugin-to-appletviewer",
- data->instance_string);
+ data->out_pipe_name = g_strdup_printf ("%s/gcj-%s-plugin-to-appletviewer",
+ data_directory, data->instance_string);
if (!data->out_pipe_name)
{
@@ -1061,7 +1064,7 @@
SECURITY_WARNING,
documentbase);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- SECURITY_DESCRIPTION);
+ SECURITY_DESCRIPTION, whitelist_filename);
cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_CANCEL,
@@ -1577,7 +1580,7 @@
return NPERR_INVALID_FUNCTABLE_ERROR;
}
-
+
// 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.
@@ -1606,39 +1609,41 @@
return NPERR_INVALID_FUNCTABLE_ERROR;
}
+ data_directory = g_strconcat(getenv("HOME"), "/.gcjwebplugin", NULL);
+ whitelist_filename = g_strconcat (data_directory, "/whitelist.txt", NULL);
+
// Make sure the plugin data directory exists, creating it if
// necessary.
- if (!g_file_test (DATA_DIRECTORY,
+ if (!g_file_test (data_directory,
(GFileTest) (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
{
int file_error = 0;
- file_error = g_mkdir (DATA_DIRECTORY, 0700);
+ file_error = g_mkdir (data_directory, 0700);
if (file_error != 0)
{
- PLUGIN_ERROR_TWO ("Failed to create data directory "
- DATA_DIRECTORY " ",
+ PLUGIN_ERROR_TWO (g_strconcat("Failed to create data directory ",
+ data_directory, NULL),
strerror (errno));
return NPERR_GENERIC_ERROR;
}
}
// Open the user's documentbase whitelist.
- whitelist_file = g_io_channel_new_file (WHITELIST_FILENAME,
+ whitelist_file = g_io_channel_new_file (whitelist_filename,
"a+", &channel_error);
if (!whitelist_file)
{
if (channel_error)
{
- PLUGIN_ERROR_TWO ("Failed to open whitelist file "
- WHITELIST_FILENAME " ",
+ PLUGIN_ERROR_TWO (g_strconcat("Failed to open whitelist file ",
+ whitelist_filename, NULL),
channel_error->message);
g_error_free (channel_error);
channel_error = NULL;
}
else
- PLUGIN_ERROR ("Failed to open whitelist file "
- WHITELIST_FILENAME);
+ PLUGIN_ERROR (g_strconcat("Failed to open whitelist file ",
+ whitelist_filename, NULL));
return NPERR_GENERIC_ERROR;
}
@@ -1750,6 +1755,12 @@
g_io_channel_close (whitelist_file);
whitelist_file = NULL;
}
+
+ if (data_directory)
+ {
+ g_free (data_directory);
+ data_directory = NULL;
+ }
initialized = false;