summaryrefslogtreecommitdiff
path: root/native
diff options
context:
space:
mode:
authorLillian Angel <langel@redhat.com>2006-06-08 21:43:44 +0000
committerLillian Angel <langel@redhat.com>2006-06-08 21:43:44 +0000
commit4b914def9fea5c18e35f62676c61dc55ce03984e (patch)
tree192ca257bdd0b043edbbd70eaeeffa30add00168 /native
parent03e889390dd4a61c1bd981fd746018de47b5351b (diff)
downloadclasspath-4b914def9fea5c18e35f62676c61dc55ce03984e.tar.gz
2006-06-08 Lillian Angel <langel@redhat.com>
* 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.
Diffstat (limited to 'native')
-rw-r--r--native/plugin/Makefile.am1
-rw-r--r--native/plugin/gcjwebplugin.cc51
2 files changed, 31 insertions, 21 deletions
diff --git a/native/plugin/Makefile.am b/native/plugin/Makefile.am
index 381be1407..e1331fe45 100644
--- a/native/plugin/Makefile.am
+++ b/native/plugin/Makefile.am
@@ -4,7 +4,6 @@ libgcjwebplugin_la_SOURCES = gcjwebplugin.cc
libgcjwebplugin_la_CXXFLAGS = \
-Wall -DAPPLETVIEWER_EXECUTABLE="\"$(bindir)/appletviewer\"" \
- -DDATA_DIRECTORY="\"$(HOME)/.gcjwebplugin\"" \
$(MOZILLA_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS)
libgcjwebplugin_la_LDFLAGS = -avoid-version \
diff --git a/native/plugin/gcjwebplugin.cc b/native/plugin/gcjwebplugin.cc
index ac7471832..295255b7e 100644
--- a/native/plugin/gcjwebplugin.cc
+++ b/native/plugin/gcjwebplugin.cc
@@ -120,7 +120,6 @@ exception statement from your version. */
// 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 @@ exception statement from your version. */
" 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 @@ static NS_DEFINE_IID (kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID);
// 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 @@ GCJ_New (NPMIMEType pluginType, NPP instance, uint16 mode,
// 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 @@ GCJ_New (NPMIMEType pluginType, NPP instance, uint16 mode,
// 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 @@ plugin_ask_user_about_documentbase (char* documentbase)
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 @@ NP_Initialize (NPNetscapeFuncs* browserTable, NPPluginFuncs* pluginTable)
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 @@ NP_Initialize (NPNetscapeFuncs* browserTable, NPPluginFuncs* pluginTable)
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 @@ NP_Shutdown (void)
g_io_channel_close (whitelist_file);
whitelist_file = NULL;
}
+
+ if (data_directory)
+ {
+ g_free (data_directory);
+ data_directory = NULL;
+ }
initialized = false;