[Swfdec] configure.ac src/Makefile.am src/plugin.c

Benjamin Otte company at kemper.freedesktop.org
Tue Nov 6 12:30:19 PST 2007


 configure.ac    |    2 +-
 src/Makefile.am |    5 +++--
 src/plugin.c    |   26 ++++++++++++++++++++++----
 3 files changed, 26 insertions(+), 7 deletions(-)

New commits:
commit ca13a1daef653a80e89250e273496ca01dfccddd
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Nov 6 21:29:54 2007 +0100

    make sure the plugin is never unloaded (#13110, reported by Tom Parker)
    
    It seems NPPVpluginKeepLibraryInMemory is just an optimization hint. The docs
    at least aren't clear on it.

diff --git a/configure.ac b/configure.ac
index 49a3f73..6c74a5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,7 +58,7 @@ dnl Check for essential libraries first:
 dnl ====================================
 
 SWFDEC_REQUIRES=0.5.3.1
-PKG_CHECK_MODULES(SWFDEC, swfdec-gtk-$SWFDEC_MAJORMINOR = $SWFDEC_REQUIRES, HAVE_SWFDEC=yes, HAVE_SWFDEC=no)
+PKG_CHECK_MODULES(SWFDEC, gmodule-2.0 swfdec-gtk-$SWFDEC_MAJORMINOR = $SWFDEC_REQUIRES, HAVE_SWFDEC=yes, HAVE_SWFDEC=no)
 if test "$HAVE_SWFDEC" = "no"; then
   AC_MSG_ERROR([cannot find swfdec-$SWFDEC_MAJORMINOR $SWFDEC_REQUIRES, which is required for build])
 fi
diff --git a/src/Makefile.am b/src/Makefile.am
index 24bce9c..bbfc043 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,10 +2,11 @@ plugindir = $(PLUGIN_DIR)
 plugin_LTLIBRARIES = libswfdecmozilla.la
 
 libswfdecmozilla_la_CFLAGS = $(GLOBAL_CFLAGS) $(MOZILLA_CFLAGS) $(SWFDEC_CFLAGS) \
-	$(AUDIO_CFLAGS) $(CAIRO_CFLAGS) $(GTK_CFLAGS)
+	-DPLUGIN_DIR=\""$(PLUGIN_DIR)"\"
+
 libswfdecmozilla_la_LDFLAGS = \
 	-module -avoid-version -export-symbols $(srcdir)/plugin.symbols \
-	$(SWFDEC_LIBS) $(AUDIO_LIBS) $(CAIRO_LIBS) $(GTK_LIBS)
+	$(SWFDEC_LIBS)
 
 libswfdecmozilla_la_SOURCES = \
 	plugin.c \
diff --git a/src/plugin.c b/src/plugin.c
index 5cf4c5a..bec4741 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -128,6 +128,25 @@ NP_GetValue (void* reserved, NPPVariable var, void* out)
   return NPERR_NO_ERROR;
 }
 
+static gboolean
+make_sure_this_thing_stays_in_memory (void)
+{
+  static gboolean inited = FALSE;
+  GModule *module;
+    
+  if (inited)
+    return TRUE;
+  inited = TRUE;
+  if (!g_module_supported ())
+    return FALSE;
+  module = g_module_open (PLUGIN_DIR G_DIR_SEPARATOR_S "libswfdecmozilla." G_MODULE_SUFFIX, 0);
+  if (module == NULL)
+    return FALSE;
+  g_module_make_resident (module);
+  g_module_close (module);
+  return TRUE;
+}
+
 static NPError
 plugin_new (NPMIMEType mime_type, NPP instance,
     uint16_t mode, int16_t argc, char *argn[], char *argv[],
@@ -138,9 +157,8 @@ plugin_new (NPMIMEType mime_type, NPP instance,
   if (instance == NULL)
     return NPERR_INVALID_INSTANCE_ERROR;
 
-  if (CallNPN_SetValueProc (mozilla_funcs.setvalue, instance,
-	NPPVpluginKeepLibraryInMemory, (void *) PR_TRUE))
-    return NPERR_INCOMPATIBLE_VERSION_ERROR;
+  if (!make_sure_this_thing_stays_in_memory ())
+    return NPERR_INVALID_INSTANCE_ERROR;
 #if 0
   /* see https://bugzilla.mozilla.org/show_bug.cgi?id=137189 for why this doesn't work
    * probably needs user agent sniffing to make this work correctly (iff gecko 
@@ -404,7 +422,7 @@ NP_Initialize (NPNetscapeFuncs * moz_funcs, NPPluginFuncs * plugin_funcs)
 NPError
 NP_Shutdown (void)
 {
-  g_printerr ("You should not see this text until you've closed your browser\n");
+  /* Haha, we stay in memory anyway, no way to get rid of us! */
   return NPERR_NO_ERROR;
 }
 


More information about the Swfdec mailing list