Author: miguel
Date: 2007-06-23 15:53:20 -0400 (Sat, 23 Jun 2007)
New Revision: 80602
Added:
trunk/moon/plugin/plugin-proxy.cpp
Modified:
trunk/moon/configure.ac
trunk/moon/plugin/Makefile.am
trunk/moon/plugin/mono.cpp
trunk/moon/plugin/moon-mono.h
trunk/moon/plugin/plugin-glue.cpp
trunk/moon/plugin/plugin.cpp
trunk/moon/plugin/plugin.h
Log:
i2007-06-23 Miguel de Icaza <[EMAIL PROTECTED]>
* plugin-proxy.cpp: This is the new entry point for the plugin
which can be loaded and unloaded as many times as desired, and
will keep the real plugin in $pkgdir/libmoonplugin.so loaded as
well as the Mono VM
This prevents the bugs where the code is unloaded, but we still
have a few places where we are triggering screen updates when the
objects have gone, those must be tracked down.
Modified: trunk/moon/configure.ac
===================================================================
--- trunk/moon/configure.ac 2007-06-23 17:28:10 UTC (rev 80601)
+++ trunk/moon/configure.ac 2007-06-23 19:53:20 UTC (rev 80602)
@@ -133,7 +133,9 @@
PLUGIN_CFLAGS=`pkg-config --cflags gtk+-2.0 $mozilla_nspr $mozilla_xpcom
$mozilla_plugin $MOON_PKGS mono`
PLUGIN_LIBS=`pkg-config --libs gtk+-2.0 $mozilla_nspr $mozilla_xpcom
$mozilla_plugin $MOON_PKGS mono`
-
+PLUGIN_CFLAGS="$PLUGIN_CFLAGS -DPLUGIN_DIR=\\\"\$(pkglibdir)\\\""
+echo THIS IS IT:
+echo $PLUGIN_CFLAGS
AC_SUBST(PLUGIN_CFLAGS)
AC_SUBST(PLUGIN_LIBS)
Modified: trunk/moon/plugin/Makefile.am
===================================================================
--- trunk/moon/plugin/Makefile.am 2007-06-23 17:28:10 UTC (rev 80601)
+++ trunk/moon/plugin/Makefile.am 2007-06-23 19:53:20 UTC (rev 80602)
@@ -1,7 +1,7 @@
SUBDIRS = test samples
pluginlibdir=$(pkglibdir)/plugin
-pluginlib_LTLIBRARIES = libmoonplugin.la
+pluginlib_LTLIBRARIES = libmoonplugin.la libmoonloader.la
pluginlib_DATA=README moonlight.exe
@@ -10,6 +10,14 @@
-I/usr/include/X11 \
$(PLUGIN_CFLAGS)
+libmoonloader_la_LDFLAGS = \
+ -avoid-version -module
+
+libmoonloader_la_LIBADD = $(PLUGIN_LIBS)
+
+libmoonloader_la_SOURCES = \
+ plugin-proxy.cpp
+
libmoonplugin_la_LDFLAGS = \
-avoid-version \
-module \
@@ -31,14 +39,15 @@
downloader.h
# custom install rule
-test-plugin: libmoonplugin.la moonlight.exe
+test-plugin: libmoonloader.la libmoonplugin.la moonlight.exe
mkdir -p ~/.mozilla/plugins
- -rm -f ~/.mozilla/plugins/libmoon.so
- cp .libs/libmoonplugin.so ~/.mozilla/plugins
+ -rm -f ~/.mozilla/plugins/libmoon.so ~/.mozilla/plugins/libmoonplugin.so
+ cp .libs/libmoonloader.so ~/.mozilla/plugins
cp moonlight.exe ~/.mozilla/plugins
untest-plugin:
- rm -rf ~/.mozilla/plugins/libmoonplugin.so
+ -rm -rf ~/.mozilla/plugins/libmoonplugin.so
+ -rm -rf ~/.mozilla/plugins/libmoonloader.so
rm -rf ~/.mozilla/plugin/moonlight.exe
EXTRA_DIST = moonlight.cs
Modified: trunk/moon/plugin/mono.cpp
===================================================================
--- trunk/moon/plugin/mono.cpp 2007-06-23 17:28:10 UTC (rev 80601)
+++ trunk/moon/plugin/mono.cpp 2007-06-23 19:53:20 UTC (rev 80602)
@@ -33,6 +33,8 @@
boot_assembly = g_build_path ("/", home, ".mozilla", "plugins",
"moonlight.exe", NULL);
//boot_assembly = g_build_path (home, ".mozilla", "plugins",
"moonlight.exe", NULL);
+
+
mono_config_parse (NULL);
moon_domain = mono_jit_init (boot_assembly);
mono_debug_init (MONO_DEBUG_FORMAT_MONO);
Modified: trunk/moon/plugin/moon-mono.h
===================================================================
--- trunk/moon/plugin/moon-mono.h 2007-06-23 17:28:10 UTC (rev 80601)
+++ trunk/moon/plugin/moon-mono.h 2007-06-23 19:53:20 UTC (rev 80602)
@@ -18,6 +18,7 @@
#include <mono/metadata/assembly.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/mono-debug.h>
+
extern MonoDomain *moon_domain;
extern MonoAssembly *moon_boot_assembly;
Modified: trunk/moon/plugin/plugin-glue.cpp
===================================================================
--- trunk/moon/plugin/plugin-glue.cpp 2007-06-23 17:28:10 UTC (rev 80601)
+++ trunk/moon/plugin/plugin-glue.cpp 2007-06-23 19:53:20 UTC (rev 80602)
@@ -35,7 +35,7 @@
NPError
NPP_Destroy (NPP instance, NPSavedData** save)
{
- DEBUGMSG ("NPP_Destroy");
+ DEBUGMSG ("NPP_Destroy, instance=%p\n");
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
@@ -219,12 +219,11 @@
already_initialized = true;
gtk_init (0, 0);
downloader_initialize ();
- #ifdef RUNTIME
+#ifdef RUNTIME
vm_init ();
- #endif
+#endif
+ runtime_init ();
}
-
- runtime_init ();
TimeManager::Instance()->Start();
return NPERR_NO_ERROR;
Added: trunk/moon/plugin/plugin-proxy.cpp
===================================================================
--- trunk/moon/plugin/plugin-proxy.cpp 2007-06-23 17:28:10 UTC (rev 80601)
+++ trunk/moon/plugin/plugin-proxy.cpp 2007-06-23 19:53:20 UTC (rev 80602)
@@ -0,0 +1,126 @@
+/*
+ * plugin-entry.cpp: MoonLight browser plugin.
+ *
+ * Author:
+ * Everaldo Canuto ([EMAIL PROTECTED])
+ *
+ * Copyright 2007 Novell, Inc. (http://www.novell.com)
+ *
+ * See the LICENSE file included with the distribution for details.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include "npapi.h"
+#include "npupp.h"
+
+#ifdef XP_UNIX
+typedef NPError (*np_initialize_func) (void *a, void *b);
+#else
+typedef NPError (*np_initialize_func) (void *a);
+#endif
+typedef NPError (*np_shutdown_func) ();
+typedef NPError (*np_getvalue_func) (void *, NPPVariable var, void *avalue);
+typedef char * (*np_getmime_func) ();
+
+static np_initialize_func initialize;
+static np_getvalue_func getvalue;
+static np_shutdown_func shutdown;
+static np_getmime_func getmime;
+
+static NPError
+load ()
+{
+ void *real_plugin = dlopen (PLUGIN_DIR "/libmoonplugin.so", RTLD_NOW);
+
+ if (real_plugin == NULL){
+ fprintf (stderr, "Unable to load the real plugin %s\n", dlerror
());
+ return FALSE;
+ }
+
+ initialize = (np_initialize_func) dlsym (real_plugin, "NP_Initialize");
+ if (initialize == NULL){
+ fprintf (stderr, "NP_Initialize not found %s", dlerror ());
+ return FALSE;
+ }
+
+
+ getvalue = (np_getvalue_func) dlsym (real_plugin, "NP_GetValue");
+ if (getvalue == NULL){
+ fprintf (stderr, "NP_GetValue not found %s\n", dlerror);
+ return FALSE;
+ }
+
+ getmime = (np_getmime_func) dlsym (real_plugin,
"NP_GetMIMEDescription");
+ if (getmime == NULL){
+ fprintf (stderr, "NP_GetMIMEDescription not found %s\n",
dlerror);
+ return FALSE;
+ }
+
+ shutdown = (np_shutdown_func) dlsym (real_plugin, "NP_Shutdown");
+ if (shutdown == NULL){
+ fprintf (stderr, "NP_Shutdown not found %s\n", dlerror);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+char*
+NP_GetMIMEDescription (void)
+{
+ if (getmime == NULL)
+ load ();
+
+ if (getmime != NULL){
+ return (*getmime)();
+ }
+ return "";
+}
+
+NPError
+NP_GetValue (void *future, NPPVariable variable, void *value)
+{
+ if (getvalue == NULL)
+ load ();
+
+ if (getvalue != NULL)
+ return (*getvalue) (future, variable, value);
+
+ return NPERR_GENERIC_ERROR;
+}
+
+NPError OSCALL
+#ifdef XP_UNIX
+NP_Initialize (NPNetscapeFuncs *mozilla_funcs, NPPluginFuncs *plugin_funcs)
+#else
+NP_Initialize (NPNetscapeFuncs *mozilla_funcs)
+#endif
+{
+ if (initialize == NULL)
+ load ();
+
+ if (initialize == NULL)
+ return NPERR_GENERIC_ERROR;
+
+ NPError res;
+
+#ifdef XP_UNIX
+ res = (*initialize) (mozilla_funcs, plugin_funcs);
+#else
+ res = (*initialize) (mozilla_funcs);
+#endif
+ return res;
+}
+
+NPError OSCALL
+NP_Shutdown (void)
+{
+ if (shutdown == NULL)
+ load ();
+ if (shutdown != NULL)
+ return (*shutdown) ();
+ return NPERR_GENERIC_ERROR;
+}
Property changes on: trunk/moon/plugin/plugin-proxy.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/moon/plugin/plugin.cpp
===================================================================
--- trunk/moon/plugin/plugin.cpp 2007-06-23 17:28:10 UTC (rev 80601)
+++ trunk/moon/plugin/plugin.cpp 2007-06-23 19:53:20 UTC (rev 80602)
@@ -97,11 +97,19 @@
PluginInstance::~PluginInstance ()
{
- // finalization code is under Finalize (), it was moved because we cant
- // free resources, it causes browser reload problems. It must be checked
- // and fixed later.
+ plugin_instances = g_slist_remove (plugin_instances, this->instance);
- plugin_instances = g_slist_remove (plugin_instances, this->instance);
+ //
+ // The code below was an attempt at fixing this, but we are still
getting spurious errors
+ // we might have another source of problems
+ //
+ fprintf (stderr, "Destroying the plugin: %p\n", surface);
+ if (surface != NULL){
+ //gdk_error_trap_push ();
+ surface_destroy (surface);
+ //gdk_display_sync (this->display);
+ //gdk_error_trap_pop ();
+ }
}
void
@@ -136,9 +144,6 @@
void
PluginInstance::Finalize ()
{
- // Container must be destroyed or we have segfault when browser's
closes.
- if (this->container != NULL)
- gtk_widget_destroy (this->container);
}
NPError
@@ -231,6 +236,7 @@
this->surface = surface_new (window->width, window->height);
surface_attach (this->surface, new Canvas ());
gtk_container_add (GTK_CONTAINER (container),
this->surface->drawing_area);
+ display = gdk_drawable_get_display
(this->surface->drawing_area->window);
gtk_widget_show_all (this->container);
this->UpdateSource ();
}
Modified: trunk/moon/plugin/plugin.h
===================================================================
--- trunk/moon/plugin/plugin.h 2007-06-23 17:28:10 UTC (rev 80601)
+++ trunk/moon/plugin/plugin.h 2007-06-23 19:53:20 UTC (rev 80602)
@@ -71,6 +71,7 @@
// Gtk controls
GtkWidget *container; // plugin container object
Surface *surface; // plugin surface object
+ GdkDisplay *display;
// Property getters and setters
char *getInitParams () { return this->initParams; }
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches