changeset 643:76930f38dddf

All occurences of hardcoded paths to java repalced by call of functions * plugin/icedteanp/IcedTeaNPPlugin.cc: (appletviewer_executable) renamed to (appletviewer_default_executable). (appletviewer_default_rtjar) new variable to keep default rt.jar path. (get_plugin_executable) and (string get_plugin_rt_jar) new functions, returniong the default variables for now.
author Jiri Vanek <jvanek@redhat.com>
date Wed, 20 Mar 2013 15:35:22 +0100
parents 1a6aed3d44dd
children b4362a2987f8
files ChangeLog plugin/icedteanp/IcedTeaNPPlugin.cc
diffstat 2 files changed, 33 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Mar 19 12:25:12 2013 -0400
+++ b/ChangeLog	Wed Mar 20 15:35:22 2013 +0100
@@ -1,3 +1,12 @@
+2012-20-03  Jiri Vanek <jvanek@redhat.com>
+
+	All occurences of hardcoded paths to java repalced by call of functions
+	* plugin/icedteanp/IcedTeaNPPlugin.cc:  (appletviewer_executable) renamed
+	to (appletviewer_default_executable). (appletviewer_default_rtjar) new
+	variable to keep default rt.jar path.
+	(get_plugin_executable) and (string get_plugin_rt_jar) new functions, 
+	returniong the default variables for now.
+
 2013-19-03  Adam Domurad  <adomurad@redhat.com>
 
 	* Makefile.am
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc	Tue Mar 19 12:25:12 2013 -0400
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc	Wed Mar 20 15:35:22 2013 +0100
@@ -43,6 +43,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <string>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -156,8 +157,9 @@
 // Data directory for plugin.
 static std::string data_directory;
 
-// Fully-qualified appletviewer executable.
-static const char* appletviewer_executable = ICEDTEA_WEB_JRE "/bin/java";
+// Fully-qualified appletviewer default  executable and rt.jar
+static const char* appletviewer_default_executable = ICEDTEA_WEB_JRE "/bin/java";
+static const char* appletviewer_default_rtjar = ICEDTEA_WEB_JRE "/lib/rt.jar";
 
 // Applet viewer input channel (needs to be static because it is used in plugin_in_pipe_callback)
 static GIOChannel* in_from_appletviewer = NULL;
@@ -284,6 +286,16 @@
 
 #endif
 
+static std::string get_plugin_executable(){
+      return std::string (appletviewer_default_executable);
+      
+}
+
+static std::string get_plugin_rt_jar(){
+      return std::string (appletviewer_default_rtjar);
+      
+}
+
 
 /* 
  * Find first member in GHashTable* depending on version of glib
@@ -1517,13 +1529,14 @@
 static NPError
 plugin_test_appletviewer ()
 {
-  PLUGIN_DEBUG ("plugin_test_appletviewer: %s\n", appletviewer_executable);
+
+  PLUGIN_DEBUG ("plugin_test_appletviewer: %s\n", get_plugin_executable().c_str());
   NPError error = NPERR_NO_ERROR;
 
   gchar* command_line[3] = { NULL, NULL, NULL };
   gchar** environment;
 
-  command_line[0] = g_strdup (appletviewer_executable);
+  command_line[0] = g_strdup (get_plugin_executable().c_str());
   command_line[1] = g_strdup("-version");
   command_line[2] = NULL;
 
@@ -1570,7 +1583,7 @@
 
   // Construct command line parameters
 
-  command_line.push_back(appletviewer_executable);
+  command_line.push_back(get_plugin_executable());
 
   //Add JVM args to command_line
   for (int i = 0; i < jvm_args->size(); i++)
@@ -1581,7 +1594,7 @@
   command_line.push_back(PLUGIN_BOOTCLASSPATH);
   // set the classpath to avoid using the default (cwd).
   command_line.push_back("-classpath");
-  command_line.push_back(ICEDTEA_WEB_JRE "/lib/rt.jar");
+  command_line.push_back(get_plugin_rt_jar());
 
   // Enable coverage agent if we are running instrumented plugin
 #ifdef COVERAGE_AGENT
@@ -1652,10 +1665,10 @@
   gchar *output = NULL;
   std::vector<std::string*>* tokenOutput = NULL;
 
-  commands.push_back(appletviewer_executable);
+  commands.push_back(get_plugin_executable());
   commands.push_back(PLUGIN_BOOTCLASSPATH);
   commands.push_back("-classpath");
-  commands.push_back(ICEDTEA_WEB_JRE "/lib/rt.jar");
+  commands.push_back(get_plugin_rt_jar());
   commands.push_back("net.sourceforge.jnlp.controlpanel.CommandLine");
   commands.push_back("get");
   commands.push_back("deployment.plugin.jvm.arguments");
@@ -2175,11 +2188,11 @@
     }
 
   // Set appletviewer_executable.
-  PLUGIN_DEBUG("Executing java at %s\n", appletviewer_executable);
+  PLUGIN_DEBUG("Executing java at %s\n", get_plugin_executable().c_str());
   np_error = plugin_test_appletviewer ();
   if (np_error != NPERR_NO_ERROR)
     {
-      fprintf(stderr, "Unable to find java executable %s\n", appletviewer_executable);
+      fprintf(stderr, "Unable to find java executable %s\n", get_plugin_executable().c_str());
       return np_error;
     }
 
@@ -2191,7 +2204,7 @@
 
   plugin_instance_mutex = g_mutex_new ();
 
-  PLUGIN_DEBUG ("NP_Initialize: using %s\n", appletviewer_executable);
+  PLUGIN_DEBUG ("NP_Initialize: using %s\n", get_plugin_executable().c_str());
 
   plugin_req_proc = new PluginRequestProcessor();
   java_req_proc = new JavaMessageSender();