changeset 284:68a6e5d41dfc

made compatible with rhel5 libraries
author Jiri Vanek <jvanek@redhat.com>
date Thu, 01 Sep 2011 12:18:55 +0200
parents 7afd916031fa
children 418a9e44fce7
files ChangeLog Makefile.am acinclude.m4 configure.ac plugin/icedteanp/IcedTeaNPPlugin.cc
diffstat 5 files changed, 60 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Aug 29 17:02:36 2011 -0400
+++ b/ChangeLog	Thu Sep 01 12:18:55 2011 +0200
@@ -1,3 +1,16 @@
+2011-09-01 Jiri Vanek<jvanek@redhat.com>
+	Added functionality to allow icedtea web to be buildable with
+	 rhel5 libraries.
+	*configure.ac: added IT_CHECK_GLIB_VERSION check.
+	*acinclude.m4: added IT_CHECK_GLIB_VERSION definition block to test.
+	  version of glib installed and add LEGACY_GLIB define macro into
+	  variable DEFS if version is <2.16.
+	*plugin/icedteanp/IcedTeaNPPlugin.cc: added replacements for incompatible
+	 functions (g_strcmp0 and find_first_item_in_hash_table)if LEGACY_GLIB
+	 is defined. Added define sections for use this function instead of glib ones.
+	 Duplicated code moved into function getFirstInTableInstance(GHashTble* table).
+	*Makefile.am: ($(PLUGIN_DIR)/%.o): using DEFS setted by configure for compilation 
+
 2011-08-29  Deepak Bhole <dbhole@redhat.com>
 
 	RH734081: Javaws cannot use proxy settings from Firefox
--- a/Makefile.am	Mon Aug 29 17:02:36 2011 -0400
+++ b/Makefile.am	Thu Sep 01 12:18:55 2011 +0200
@@ -210,6 +210,7 @@
 	mkdir -p $(PLUGIN_DIR) && \
 	cd $(PLUGIN_DIR) && \
 	$(CXX) $(CXXFLAGS) \
+	   $(DEFS) \
 	  -DJDK_UPDATE_VERSION="\"$(JDK_UPDATE_VERSION)\"" \
 	  -DPLUGIN_NAME="\"IcedTea-Web Plugin\"" \
 	  -DPLUGIN_VERSION="\"$(PLUGIN_VERSION)\"" \
--- a/acinclude.m4	Mon Aug 29 17:02:36 2011 -0400
+++ b/acinclude.m4	Thu Sep 01 12:18:55 2011 +0200
@@ -484,6 +484,10 @@
 AC_SUBST(PKGVERSION)
 ])
 
+AC_DEFUN_ONCE([IT_CHECK_GLIB_VERSION],[
+   PKG_CHECK_MODULES([GLIB2_V_216],[glib-2.0 >= 2.16],[],[AC_DEFINE([LEGACY_GLIB])])
+ ])
+
 AC_DEFUN([IT_CHECK_WITH_GCJ],
 [
   AC_MSG_CHECKING([whether to compile ecj natively])
--- a/configure.ac	Mon Aug 29 17:02:36 2011 -0400
+++ b/configure.ac	Thu Sep 01 12:18:55 2011 +0200
@@ -80,6 +80,7 @@
 IT_CHECK_FOR_CLASS(COM_SUN_JNDI_TOOLKIT_URL_URLUTIL, [com.sun.jndi.toolkit.url.UrlUtil])
 IT_CHECK_FOR_CLASS(SUN_APPLET_APPLETIMAGEREF, [sun.applet.AppletImageRef])
 IT_CHECK_FOR_APPLETVIEWERPANEL_HOLE
+IT_CHECK_GLIB_VERSION
 
 #
 # Find optional depedencies
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc	Mon Aug 29 17:02:36 2011 -0400
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc	Thu Sep 01 12:18:55 2011 +0200
@@ -249,6 +249,45 @@
 
 pthread_cond_t cond_message_available = PTHREAD_COND_INITIALIZER;
 
+
+#ifdef LEGACY_GLIB
+// Returns key from first item stored in hashtable
+gboolean
+find_first_item_in_hash_table(gpointer key, gpointer value, gpointer user_data)
+{
+    user_data = key;
+    return (gboolean)TRUE;
+}
+
+int
+g_strcmp0(char *str1, char *str2)
+{
+   if (str1 != NULL)
+     return str2 != NULL ? strcmp(str1, str2) : 1;
+   else // str1 == NULL
+     return str2 != NULL ? 1 : 0;
+}
+
+
+#endif
+
+
+/* 
+ * Find first member in GHashTable* depending on version of glib
+ */
+gpointer getFirstInTableInstance(GHashTable* table)
+{
+      gpointer id, instance;
+      #ifndef LEGACY_GLIB
+        GHashTableIter iter;
+        g_hash_table_iter_init (&iter, table);
+        g_hash_table_iter_next (&iter, &instance, &id);
+      #else
+        g_hash_table_find(table, (GHRFunc)find_first_item_in_hash_table, &instance);
+      #endif
+        return instance;
+}
+
 // Functions prefixed by ITNP_ are instance functions.  They are called
 // by the browser and operate on instances of ITNPPluginData.
 // Functions prefixed by plugin_ are static helper functions.
@@ -915,12 +954,7 @@
 
   if (browser_functions.getvalueforurl)
   {
-      GHashTableIter iter;
-      gpointer id, instance;
-
-      g_hash_table_iter_init (&iter, instance_to_id_map);
-      g_hash_table_iter_next (&iter, &instance, &id);
-
+      gpointer instance=getFirstInTableInstance(instance_to_id_map);
       return browser_functions.getvalueforurl((NPP) instance, NPNURLVCookie, siteAddr, cookieString, len);
   } else
   {
@@ -1367,12 +1401,7 @@
   {
 
       // As in get_cookie_info, we use the first active instance
-      GHashTableIter iter;
-      gpointer id, instance;
-
-      g_hash_table_iter_init (&iter, instance_to_id_map);
-      g_hash_table_iter_next (&iter, &instance, &id);
-
+      gpointer instance=getFirstInTableInstance(instance_to_id_map);
       browser_functions.getvalueforurl((NPP) instance, NPNURLVProxy, siteAddr, proxy, len);
   } else
   {