#! /bin/sh /usr/share/dpatch/dpatch-run
## 30_dlopen_noremove_dbus_glib.dpatch by  <asac@>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad totem-2.16.2~/browser-plugin/totemPlugin.cpp totem-2.16.2/browser-plugin/totemPlugin.cpp
--- totem-2.16.2~/browser-plugin/totemPlugin.cpp	2007-03-06 15:15:47.000000000 +0000
+++ totem-2.16.2/browser-plugin/totemPlugin.cpp	2007-03-06 15:16:24.000000000 +0000
@@ -30,6 +30,7 @@
 #include <sys/wait.h>
 #include <sys/poll.h>
 #include <string.h>
+#include <dlfcn.h>
 
 #include <glib.h>
 #include <libgnomevfs/gnome-vfs-mime-handlers.h>
@@ -412,11 +413,6 @@
 	if (instance == NULL)
 		return NPERR_INVALID_INSTANCE_ERROR;
 
-	/* Make sure the plugin stays resident to avoid crashers when 
-	 * reloading the GObject types */
-	mozilla_functions.setvalue (instance,
-			NPPVpluginKeepLibraryInMemory, (void *)TRUE);
-
 	instance->pdata = mozilla_functions.memalloc(sizeof(totemPlugin));
 	plugin = (totemPlugin *) instance->pdata;
 
@@ -998,6 +994,15 @@
 	if (plugin_funcs->size < sizeof (NPPluginFuncs))
 		return NPERR_INVALID_FUNCTABLE_ERROR;
 
+	/* we want to open libdbus-glib-1.so.2 in such a way
+	 * in such a way that it becomes permanentely resident */
+	void *handle;
+	handle = dlopen ("libdbus-glib-1.so.2", RTLD_NOW | RTLD_NODELETE);
+	if (!handle) {
+		fprintf (stderr, "%s\n", dlerror()); 
+		return NPERR_MODULE_LOAD_FAILED_ERROR;
+	}
+
 	/*
 	 * Copy all of the fields of the Mozilla function table into our
 	 * copy so we can call back into Mozilla later.  Note that we need
