totem r5441 - in trunk: . bindings/python browser-plugin browser-plugin/idl src/plugins/bemused



Author: chpe
Date: Fri May 30 17:35:08 2008
New Revision: 5441
URL: http://svn.gnome.org/viewvc/totem?rev=5441&view=rev

Log:
Bug 520629 â deCOMtaminate plugins


Added:
   trunk/.gitignore
   trunk/browser-plugin/marshal.list
      - copied, changed from r5440, /trunk/browser-plugin/totempluginviewer-marshal.list
   trunk/browser-plugin/npapi.h
   trunk/browser-plugin/npruntime.h
   trunk/browser-plugin/npupp.h
   trunk/browser-plugin/totemComplexPlayer.cpp
   trunk/browser-plugin/totemComplexPlayer.h
   trunk/browser-plugin/totemCone.cpp
   trunk/browser-plugin/totemCone.h
   trunk/browser-plugin/totemConeAudio.cpp
   trunk/browser-plugin/totemConeAudio.h
   trunk/browser-plugin/totemConeInput.cpp
   trunk/browser-plugin/totemConeInput.h
      - copied, changed from r5440, /trunk/browser-plugin/totemGMPError.h
   trunk/browser-plugin/totemConePlaylist.cpp
   trunk/browser-plugin/totemConePlaylist.h
   trunk/browser-plugin/totemConePlaylistItems.cpp
   trunk/browser-plugin/totemConePlaylistItems.h
   trunk/browser-plugin/totemConeVideo.cpp
   trunk/browser-plugin/totemConeVideo.h
   trunk/browser-plugin/totemGMPControls.cpp
   trunk/browser-plugin/totemGMPControls.h
   trunk/browser-plugin/totemGMPErrorItem.cpp
   trunk/browser-plugin/totemGMPErrorItem.h
      - copied, changed from r5440, /trunk/browser-plugin/totemGMPError.h
   trunk/browser-plugin/totemGMPNetwork.cpp
   trunk/browser-plugin/totemGMPNetwork.h
   trunk/browser-plugin/totemGMPPlayer.cpp
   trunk/browser-plugin/totemGMPPlayer.h
   trunk/browser-plugin/totemNPClass.cpp
   trunk/browser-plugin/totemNPClass.h
   trunk/browser-plugin/totemNPNGlue.cpp
   trunk/browser-plugin/totemNPObject.cpp
   trunk/browser-plugin/totemNPObject.h
   trunk/browser-plugin/totemNPObjectWrapper.h
   trunk/browser-plugin/totemNPVariantWrapper.h
Removed:
   trunk/browser-plugin/idl/Makefile.am
   trunk/browser-plugin/totemClassInfo.h
   trunk/browser-plugin/totemConePlugin.cpp
   trunk/browser-plugin/totemConePlugin.h
   trunk/browser-plugin/totemDebug.h
   trunk/browser-plugin/totemGMPPlugin.cpp
   trunk/browser-plugin/totemGMPPlugin.h
   trunk/browser-plugin/totemPluginGlue.h
   trunk/browser-plugin/totemStringGlue.h
   trunk/browser-plugin/totempluginviewer-marshal.list
Modified:
   trunk/bindings/python/totem.override
   trunk/browser-plugin/Makefile.am
   trunk/browser-plugin/test-glow-button.c
   trunk/browser-plugin/totem-glow-button.c
   trunk/browser-plugin/totem-glow-button.h
   trunk/browser-plugin/totem-plugin-viewer.c
   trunk/browser-plugin/totemBasicPlugin.cpp
   trunk/browser-plugin/totemBasicPlugin.h
   trunk/browser-plugin/totemComplexPlugin.cpp
   trunk/browser-plugin/totemComplexPlugin.h
   trunk/browser-plugin/totemGMPError.cpp
   trunk/browser-plugin/totemGMPError.h
   trunk/browser-plugin/totemGMPPlaylist.cpp
   trunk/browser-plugin/totemGMPPlaylist.h
   trunk/browser-plugin/totemGMPSettings.cpp
   trunk/browser-plugin/totemGMPSettings.h
   trunk/browser-plugin/totemMullYPlugin.cpp
   trunk/browser-plugin/totemMullYPlugin.h
   trunk/browser-plugin/totemNarrowSpacePlugin.cpp
   trunk/browser-plugin/totemNarrowSpacePlugin.h
   trunk/browser-plugin/totemPlugin.cpp
   trunk/browser-plugin/totemPlugin.h
   trunk/browser-plugin/totemPluginGlue.cpp
   trunk/configure.in
   trunk/src/plugins/bemused/totem-bemused.c

Added: trunk/.gitignore
==============================================================================
--- (empty file)
+++ trunk/.gitignore	Fri May 30 17:35:08 2008
@@ -0,0 +1,55 @@
+INSTALL
+Makefile.in
+aclocal.m4
+autom4te.cache
+bindings/Makefile.in
+bindings/python/Makefile.in
+bindings/vala/Makefile.in
+browser-plugin/Makefile.in
+compile
+config.guess
+config.h.in
+config.sub
+configure
+data/Makefile.in
+data/icons/16x16/Makefile.in
+data/icons/22x22/Makefile.in
+data/icons/24x24/Makefile.in
+data/icons/32x32/Makefile.in
+data/icons/48x48/Makefile.in
+data/icons/Makefile.in
+data/icons/scalable/Makefile.in
+depcomp
+gnome-doc-utils.make
+help/Makefile.in
+help/bg/Makefile.in
+install-sh
+intltool-extract.in
+intltool-merge.in
+intltool-update.in
+lib/Makefile.in
+ltmain.sh
+missing
+mkinstalldirs
+po/Makefile.in.in
+src/Makefile.in
+src/backend/Makefile.in
+src/plugins/Makefile.in
+src/plugins/bemused/Makefile.in
+src/plugins/galago/Makefile.in
+src/plugins/gromit/Makefile.in
+src/plugins/lirc/Makefile.in
+src/plugins/media-player-keys/Makefile.in
+src/plugins/mythtv/Makefile.in
+src/plugins/ontop/Makefile.in
+src/plugins/properties/Makefile.in
+src/plugins/publish/Makefile.in
+src/plugins/sample-python/Makefile.in
+src/plugins/sample-vala/Makefile.in
+src/plugins/screensaver/Makefile.in
+src/plugins/sidebar-test/Makefile.in
+src/plugins/skipto/Makefile.in
+src/plugins/thumbnail/Makefile.in
+src/plugins/totem/Makefile.in
+src/plugins/tracker/Makefile.in
+src/plugins/youtube/Makefile.in

Modified: trunk/bindings/python/totem.override
==============================================================================
--- trunk/bindings/python/totem.override	(original)
+++ trunk/bindings/python/totem.override	Fri May 30 17:35:08 2008
@@ -9,6 +9,7 @@
 
 #include "override_common.h"
 #include "totem.h"
+#include "totem-interface.h"
 #include "totem-cell-renderer-video.h"
 #include "totem-video-list.h"
 #include "totem-disc.h"

Modified: trunk/browser-plugin/Makefile.am
==============================================================================
--- trunk/browser-plugin/Makefile.am	(original)
+++ trunk/browser-plugin/Makefile.am	Fri May 30 17:35:08 2008
@@ -1,67 +1,60 @@
-SUBDIRS = idl
-
-plugindir = $(MOZILLA_PLUGINDIR)
+plugindir = $(BROWSER_PLUGIN_DIR)
 plugin_LTLIBRARIES =
 
-BUILT_SOURCES =
-
 EXTRA_DIST =		\
 	plugin.symbols	\
+	marshal.list	\
 	TODO		\
 	README.browser-plugin
 
-CLEANFILES = $(BUILT_SOURCES)
+BUILT_SOURCES =
 
-gecko_include_subdirs = \
-	.		\
-	docshell	\
-	dom		\
-	necko		\
-	xpcom
+CLEANFILES = $(BUILT_SOURCES)
 
 # Marshaller
 
-MARSHALFILES = totempluginviewer-marshal.h totempluginviewer-marshal.c
-BUILT_SOURCES += $(MARSHALFILES)
-
-totempluginviewer-marshal.h: totempluginviewer-marshal.list
-	$(GLIB_GENMARSHAL) --prefix=totempluginviewer_marshal --header $< > $@
-totempluginviewer-marshal.c: totempluginviewer-marshal.list
-	$(GLIB_GENMARSHAL) --prefix=totempluginviewer_marshal --body --header $< > $@
-
-noinst_LTLIBRARIES = libtotempluginviewer_helper.la
-
-libtotempluginviewer_helper_la_SOURCES =	\
-	totempluginviewer-marshal.h		\
-	totempluginviewer-marshal.c		\
-	totem-glow-button.c			\
-	totem-glow-button.h
+BUILT_SOURCES += \
+	marshal.h \
+	marshal.c \
+	$(NULL)
+
+marshal.h: marshal.list
+	$(GLIB_GENMARSHAL) --prefix=totempluginviewer_marshal --internal --header $< > $@
+marshal.c: marshal.list
+	$(GLIB_GENMARSHAL) --prefix=totempluginviewer_marshal --internal --body --header $< > $@
+
+noinst_LTLIBRARIES = libtotembrowserplugin_helper.la
+
+libtotembrowserplugin_helper_la_SOURCES = \
+	marshal.h \
+	marshal.c \
+	$(NULL)
 
-libtotempluginviewer_helper_la_CPPFLAGS =	\
+libtotembrowserplugin_helper_la_CPPFLAGS =	\
 	$(DISABLE_DEPRECATED)			\
 	$(AM_CPPFLAGS)
 
-libtotempluginviewer_helper_la_CFLAGS =	\
+libtotembrowserplugin_helper_la_CFLAGS =	\
 	$(EXTRA_GNOME_CFLAGS)		\
 	$(WARN_CFLAGS)			\
 	$(AM_CFLAGS)
 
-libtotempluginviewer_helper_la_LIBADD = 	\
+libtotembrowserplugin_helper_la_LIBADD = 	\
 	$(EXTRA_GNOME_CFLAGS)			\
 	$(WARN_CFLAGS)				\
 	$(AM_CFLAGS)
 
-EXTRA_DIST += \
-	totempluginviewer-marshal.list
-
 # The Glow button test program
 
 noinst_PROGRAMS = test-glow-button
 
-test_glow_button_SOURCES = test-glow-button.c
+test_glow_button_SOURCES = \
+	totem-glow-button.c \
+	totem-glow-button.h \
+	test-glow-button.c
 
-test_glow_button_LDADD =			\
-	libtotempluginviewer_helper.la		\
+test_glow_button_LDADD = \
+	libtotembrowserplugin_helper.la		\
 	$(EXTRA_GNOME_LIBS)
 
 test_glow_button_CFLAGS =	\
@@ -78,10 +71,13 @@
 libexec_PROGRAMS = totem-plugin-viewer
 
 totem_plugin_viewer_SOURCES = \
+	totem-glow-button.c		\
+	totem-glow-button.h		\
 	totem-plugin-viewer.c		\
 	totem-plugin-viewer-interface.h	\
 	totem-plugin-viewer-constants.h	\
-	totem-plugin-viewer-options.h
+	totem-plugin-viewer-options.h	\
+	$(NULL)
 
 totem_plugin_viewer_CPPFLAGS = \
 	-D_REENTRANT					\
@@ -96,7 +92,6 @@
 	-DGCONF_PREFIX="\"/apps/totem\""		\
 	-DDATADIR="\"$(datadir)\""			\
 	-DLIBEXECDIR="\"$(libexecdir)\""		\
-	-DBINDIR="\"$(bindir)\""			\
 	-DSHAREDIR="\"$(pkgdatadir)\""			\
 	-DLOGO_NAME="\"totem_logo.png\""		\
 	-DG_LOG_DOMAIN=\""TotemEmbedded\""		\
@@ -115,7 +110,7 @@
 	$(top_builddir)/src/backend/libbaconvideowidget.la		\
 	$(top_builddir)/src/libtotem_player.la				\
 	$(top_builddir)/lib/libtotemscrsaver.la				\
-	libtotempluginviewer_helper.la					\
+	libtotembrowserplugin_helper.la					\
 	$(EXTRA_GNOME_LIBS)	\
 	$(SN_LIBS)		\
 	$(XVIDMODE_LIBS) 	\
@@ -140,15 +135,21 @@
 plugin_LTLIBRARIES += libtotem-basic-plugin.la
 
 libtotem_basic_plugin_la_SOURCES =	\
-	totemDebug.h			\
+	npapi.h				\
+	npruntime.h			\
+	npupp.h				\
+	totemNPNGlue.cpp		\
+	totemNPClass.cpp		\
+	totemNPClass.h			\
+	totemNPObject.cpp		\
+	totemNPObject.h			\
+	totemNPObjectWrapper.h		\
+	totemNPVariantWrapper.h		\
 	totemPluginGlue.cpp		\
-	totemPluginGlue.h		\
 	totemPlugin.cpp			\
 	totemPlugin.h			\
-	totemStringGlue.h		\
 	totemBasicPlugin.cpp		\
 	totemBasicPlugin.h		\
-	totemClassInfo.h		\
 	totem-plugin-viewer-constants.h
 
 libtotem_basic_plugin_la_CPPFLAGS = \
@@ -156,34 +157,28 @@
 	-I$(top_srcdir)/src/backend			\
 	-I$(top_builddir)/src				\
 	-I$(top_builddir)/src/backend			\
-	-Iidl						\
-	$(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs))	\
+	-DXP_UNIX					\
+	-DMOZ_X11					\
 	-DTOTEM_BASIC_PLUGIN				\
 	-DTOTEM_PL_PARSER_MINI				\
 	-D_REENTRANT					\
 	-DDBUS_API_SUBJECT_TO_CHANGE			\
-	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGCONF_PREFIX="\"/apps/totem\""		\
 	-DSYSCONFDIR="\"$(sysconfdir)\""		\
-	-DDATADIR="\"$(pkgdatadir)\""			\
 	-DLIBEXECDIR="\"$(libexecdir)\""		\
-	-DBINDIR="\"$(bindir)\""			\
 	$(DISABLE_DEPRECATED)				\
 	$(AM_CPPFLAGS)
 
 libtotem_basic_plugin_la_CXXFLAGS = \
 	$(BROWSER_PLUGIN_CFLAGS)	\
-	$(MOZILLA_XPCOM_CFLAGS)		\
 	$(DBUS_CFLAGS)			\
 	$(WARN_CXXFLAGS)		\
 	$(PLUGIN_EXTRA_WARN_CXXFLAGS)	\
 	$(AM_CXXFLAGS)
 
-libtotem_basic_plugin_la_LIBADD =					\
-	libtotempluginviewer_helper.la					\
-	$(DBUS_LIBS)	\
-	$(BROWSER_PLUGIN_LIBS)	\
-	$(LIBXPCOMGLUE_S)
+libtotem_basic_plugin_la_LIBADD = \
+	libtotembrowserplugin_helper.la	\
+	$(DBUS_LIBS)			\
+	$(BROWSER_PLUGIN_LIBS)
 
 libtotem_basic_plugin_la_LDFLAGS = \
 	-avoid-version	\
@@ -200,21 +195,30 @@
 plugin_LTLIBRARIES += libtotem-gmp-plugin.la
 
 libtotem_gmp_plugin_la_SOURCES =	\
-	totemDebug.h			\
+	npapi.h				\
+	npruntime.h			\
+	npupp.h				\
+	totemNPNGlue.cpp		\
+	totemNPClass.cpp		\
+	totemNPClass.h			\
+	totemNPObject.cpp		\
+	totemNPObject.h			\
+	totemNPObjectWrapper.h		\
+	totemGMPControls.cpp		\
+	totemGMPControls.h		\
 	totemGMPError.cpp		\
 	totemGMPError.h			\
+	totemGMPNetwork.cpp		\
+	totemGMPNetwork.h		\
+	totemGMPPlayer.cpp		\
+	totemGMPPlayer.h		\
 	totemGMPPlaylist.cpp		\
 	totemGMPPlaylist.h		\
 	totemGMPSettings.cpp		\
 	totemGMPSettings.h		\
 	totemPluginGlue.cpp		\
-	totemPluginGlue.h		\
 	totemPlugin.cpp			\
 	totemPlugin.h			\
-	totemStringGlue.h		\
-	totemGMPPlugin.cpp		\
-	totemGMPPlugin.h		\
-	totemClassInfo.h		\
 	totem-plugin-viewer-constants.h
 
 libtotem_gmp_plugin_la_CPPFLAGS = \
@@ -222,34 +226,28 @@
 	-I$(top_srcdir)/src/backend			\
 	-I$(top_builddir)/src				\
 	-I$(top_builddir)/src/backend			\
-	-Iidl						\
-	$(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs))	\
+	-DXP_UNIX					\
+	-DMOZ_X11					\
 	-DTOTEM_GMP_PLUGIN				\
 	-DTOTEM_PL_PARSER_MINI				\
 	-D_REENTRANT					\
 	-DDBUS_API_SUBJECT_TO_CHANGE			\
-	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGCONF_PREFIX="\"/apps/totem\""		\
 	-DSYSCONFDIR="\"$(sysconfdir)\""		\
-	-DDATADIR="\"$(pkgdatadir)\""			\
 	-DLIBEXECDIR="\"$(libexecdir)\""		\
-	-DBINDIR="\"$(bindir)\""			\
 	$(DISABLE_DEPRECATED)				\
 	$(AM_CPPFLAGS)
 
 libtotem_gmp_plugin_la_CXXFLAGS = \
 	$(BROWSER_PLUGIN_CFLAGS)	\
-	$(MOZILLA_XPCOM_CFLAGS)		\
 	$(DBUS_CFLAGS)			\
 	$(WARN_CXXFLAGS)		\
 	$(PLUGIN_EXTRA_WARN_CXXFLAGS)	\
 	$(AM_CXXFLAGS)
 
-libtotem_gmp_plugin_la_LIBADD =						\
-	libtotempluginviewer_helper.la	\
-	$(DBUS_LIBS)	\
-	$(BROWSER_PLUGIN_LIBS)	\
-	$(LIBXPCOMGLUE_S)
+libtotem_gmp_plugin_la_LIBADD = \
+	libtotembrowserplugin_helper.la	\
+	$(DBUS_LIBS)			\
+	$(BROWSER_PLUGIN_LIBS)
 
 libtotem_gmp_plugin_la_LDFLAGS = \
 	-avoid-version	\
@@ -266,15 +264,21 @@
 plugin_LTLIBRARIES += libtotem-complex-plugin.la
 
 libtotem_complex_plugin_la_SOURCES =	\
-	totemDebug.h			\
+	npapi.h				\
+	npruntime.h			\
+	npupp.h				\
+	totemNPNGlue.cpp		\
+	totemNPClass.cpp		\
+	totemNPClass.h			\
+	totemNPObject.cpp		\
+	totemNPObject.h			\
+	totemNPObjectWrapper.h		\
+	totemNPVariantWrapper.h		\
 	totemPluginGlue.cpp		\
-	totemPluginGlue.h		\
 	totemPlugin.cpp			\
 	totemPlugin.h			\
-	totemStringGlue.h		\
-	totemComplexPlugin.cpp		\
-	totemComplexPlugin.h		\
-	totemClassInfo.h		\
+	totemComplexPlayer.cpp		\
+	totemComplexPlayer.h		\
 	totem-plugin-viewer-constants.h
 
 libtotem_complex_plugin_la_CPPFLAGS = \
@@ -282,34 +286,28 @@
 	-I$(top_srcdir)/src/backend			\
 	-I$(top_builddir)/src				\
 	-I$(top_builddir)/src/backend			\
-	-Iidl						\
-	$(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs))	\
+	-DXP_UNIX					\
+	-DMOZ_X11					\
 	-DTOTEM_COMPLEX_PLUGIN				\
 	-DTOTEM_PL_PARSER_MINI				\
 	-D_REENTRANT					\
 	-DDBUS_API_SUBJECT_TO_CHANGE			\
-	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGCONF_PREFIX="\"/apps/totem\""		\
 	-DSYSCONFDIR="\"$(sysconfdir)\""		\
-	-DDATADIR="\"$(pkgdatadir)\""			\
 	-DLIBEXECDIR="\"$(libexecdir)\""		\
-	-DBINDIR="\"$(bindir)\""			\
 	$(DISABLE_DEPRECATED)				\
 	$(AM_CPPFLAGS)
 
 libtotem_complex_plugin_la_CXXFLAGS = \
 	$(BROWSER_PLUGIN_CFLAGS)	\
-	$(MOZILLA_XPCOM_CFLAGS)		\
 	$(DBUS_CFLAGS)			\
 	$(WARN_CXXFLAGS)		\
 	$(PLUGIN_EXTRA_WARN_CXXFLAGS)	\
 	$(AM_CXXFLAGS)
 
-libtotem_complex_plugin_la_LIBADD =					\
-	libtotempluginviewer_helper.la					\
-	$(DBUS_LIBS)	\
-	$(BROWSER_PLUGIN_LIBS)	\
-	$(LIBXPCOMGLUE_S)
+libtotem_complex_plugin_la_LIBADD = \
+	libtotembrowserplugin_helper.la	\
+	$(DBUS_LIBS)			\
+	$(BROWSER_PLUGIN_LIBS)
 
 libtotem_complex_plugin_la_LDFLAGS = \
 	-avoid-version	\
@@ -326,15 +324,21 @@
 plugin_LTLIBRARIES += libtotem-narrowspace-plugin.la
 
 libtotem_narrowspace_plugin_la_SOURCES = \
-	totemDebug.h			\
+	npapi.h				\
+	npruntime.h			\
+	npupp.h				\
+	totemNPNGlue.cpp		\
+	totemNPClass.cpp		\
+	totemNPClass.h			\
+	totemNPObject.cpp		\
+	totemNPObject.h			\
+	totemNPObjectWrapper.h		\
+	totemNPVariantWrapper.h		\
 	totemPluginGlue.cpp		\
-	totemPluginGlue.h		\
 	totemPlugin.cpp			\
 	totemPlugin.h			\
-	totemStringGlue.h		\
 	totemNarrowSpacePlugin.cpp	\
 	totemNarrowSpacePlugin.h	\
-	totemClassInfo.h		\
 	totem-plugin-viewer-constants.h
 
 libtotem_narrowspace_plugin_la_CPPFLAGS = \
@@ -342,34 +346,28 @@
 	-I$(top_srcdir)/src/backend			\
 	-I$(top_builddir)/src				\
 	-I$(top_builddir)/src/backend			\
-	-Iidl						\
-	$(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs))	\
+	-DXP_UNIX					\
+	-DMOZ_X11					\
 	-DTOTEM_NARROWSPACE_PLUGIN			\
 	-DTOTEM_PL_PARSER_MINI				\
 	-D_REENTRANT					\
 	-DDBUS_API_SUBJECT_TO_CHANGE			\
-	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGCONF_PREFIX="\"/apps/totem\""		\
 	-DSYSCONFDIR="\"$(sysconfdir)\""		\
-	-DDATADIR="\"$(pkgdatadir)\""			\
 	-DLIBEXECDIR="\"$(libexecdir)\""		\
-	-DBINDIR="\"$(bindir)\""			\
 	$(DISABLE_DEPRECATED)				\
 	$(AM_CPPFLAGS)
 
 libtotem_narrowspace_plugin_la_CXXFLAGS = \
 	$(BROWSER_PLUGIN_CFLAGS)	\
-	$(MOZILLA_XPCOM_CFLAGS)		\
 	$(DBUS_CFLAGS)			\
 	$(WARN_CXXFLAGS)		\
 	$(PLUGIN_EXTRA_WARN_CXXFLAGS)	\
 	$(AM_CXXFLAGS)
 
-libtotem_narrowspace_plugin_la_LIBADD =					\
-	libtotempluginviewer_helper.la					\
-	$(DBUS_LIBS)	\
-	$(BROWSER_PLUGIN_LIBS)	\
-	$(LIBXPCOMGLUE_S)
+libtotem_narrowspace_plugin_la_LIBADD = \
+	libtotembrowserplugin_helper.la	\
+	$(DBUS_LIBS)			\
+	$(BROWSER_PLUGIN_LIBS)
 
 libtotem_narrowspace_plugin_la_LDFLAGS = \
 	-avoid-version	\
@@ -386,15 +384,21 @@
 plugin_LTLIBRARIES += libtotem-mully-plugin.la
 
 libtotem_mully_plugin_la_SOURCES =	\
-	totemDebug.h			\
+	npapi.h				\
+	npruntime.h			\
+	npupp.h				\
+	totemNPNGlue.cpp		\
+	totemNPClass.cpp		\
+	totemNPClass.h			\
+	totemNPObject.cpp		\
+	totemNPObject.h			\
+	totemNPObjectWrapper.h		\
+	totemNPVariantWrapper.h		\
 	totemPluginGlue.cpp		\
-	totemPluginGlue.h		\
 	totemPlugin.cpp			\
 	totemPlugin.h			\
-	totemStringGlue.h		\
 	totemMullYPlugin.cpp		\
 	totemMullYPlugin.h		\
-	totemClassInfo.h		\
 	totem-plugin-viewer-constants.h
 
 libtotem_mully_plugin_la_CPPFLAGS = \
@@ -402,34 +406,28 @@
 	-I$(top_srcdir)/src/backend			\
 	-I$(top_builddir)/src				\
 	-I$(top_builddir)/src/backend			\
-	-Iidl						\
-	$(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs))	\
+	-DXP_UNIX					\
+	-DMOZ_X11					\
 	-DTOTEM_MULLY_PLUGIN				\
 	-DTOTEM_PL_PARSER_MINI				\
 	-D_REENTRANT					\
 	-DDBUS_API_SUBJECT_TO_CHANGE			\
-	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGCONF_PREFIX="\"/apps/totem\""		\
 	-DSYSCONFDIR="\"$(sysconfdir)\""		\
-	-DDATADIR="\"$(pkgdatadir)\""			\
 	-DLIBEXECDIR="\"$(libexecdir)\""		\
-	-DBINDIR="\"$(bindir)\""			\
 	$(DISABLE_DEPRECATED)				\
 	$(AM_CPPFLAGS)
 
 libtotem_mully_plugin_la_CXXFLAGS = \
 	$(BROWSER_PLUGIN_CFLAGS)	\
-	$(MOZILLA_XPCOM_CFLAGS)		\
 	$(DBUS_CFLAGS)			\
 	$(WARN_CXXFLAGS)		\
 	$(PLUGIN_EXTRA_WARN_CXXFLAGS)	\
 	$(AM_CXXFLAGS)
 
-libtotem_mully_plugin_la_LIBADD =					\
-	libtotempluginviewer_helper.la					\
-	$(DBUS_LIBS)	\
-	$(BROWSER_PLUGIN_LIBS)	\
-	$(LIBXPCOMGLUE_S)
+libtotem_mully_plugin_la_LIBADD = \
+	libtotembrowserplugin_helper.la	\
+	$(DBUS_LIBS)			\
+	$(BROWSER_PLUGIN_LIBS)
 
 libtotem_mully_plugin_la_LDFLAGS = \
 	-avoid-version	\
@@ -446,15 +444,31 @@
 plugin_LTLIBRARIES += libtotem-cone-plugin.la
 
 libtotem_cone_plugin_la_SOURCES =	\
-	totemDebug.h			\
+	npapi.h				\
+	npruntime.h			\
+	npupp.h				\
+	totemNPNGlue.cpp		\
+	totemNPClass.cpp		\
+	totemNPClass.h			\
+	totemNPObject.cpp		\
+	totemNPObject.h			\
+	totemNPObjectWrapper.h		\
+	totemNPVariantWrapper.h		\
+	totemConeAudio.cpp		\
+	totemConeAudio.h		\
+	totemCone.cpp			\
+	totemCone.h			\
+	totemConeInput.cpp		\
+	totemConeInput.h		\
+	totemConePlaylist.cpp		\
+	totemConePlaylist.h		\
+	totemConePlaylistItems.cpp	\
+	totemConePlaylistItems.h	\
+	totemConeVideo.cpp		\
+	totemConeVideo.h		\
 	totemPluginGlue.cpp		\
-	totemPluginGlue.h		\
 	totemPlugin.cpp			\
 	totemPlugin.h			\
-	totemStringGlue.h		\
-	totemConePlugin.cpp		\
-	totemConePlugin.h		\
-	totemClassInfo.h		\
 	totem-plugin-viewer-constants.h
 
 libtotem_cone_plugin_la_CPPFLAGS = \
@@ -462,34 +476,28 @@
 	-I$(top_srcdir)/src/backend			\
 	-I$(top_builddir)/src				\
 	-I$(top_builddir)/src/backend			\
-	-Iidl						\
-	$(addprefix -I$(MOZILLA_INCLUDE_ROOT)/,$(gecko_include_subdirs))	\
+	-DXP_UNIX					\
+	-DMOZ_X11					\
 	-DTOTEM_CONE_PLUGIN				\
 	-DTOTEM_PL_PARSER_MINI				\
 	-D_REENTRANT					\
 	-DDBUS_API_SUBJECT_TO_CHANGE			\
-	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGCONF_PREFIX="\"/apps/totem\""		\
 	-DSYSCONFDIR="\"$(sysconfdir)\""		\
-	-DDATADIR="\"$(pkgdatadir)\""			\
 	-DLIBEXECDIR="\"$(libexecdir)\""		\
-	-DBINDIR="\"$(bindir)\""			\
 	$(DISABLE_DEPRECATED)				\
 	$(AM_CPPFLAGS)
 
 libtotem_cone_plugin_la_CXXFLAGS = \
 	$(BROWSER_PLUGIN_CFLAGS)	\
-	$(MOZILLA_XPCOM_CFLAGS)		\
 	$(DBUS_CFLAGS)			\
 	$(WARN_CXXFLAGS)		\
 	$(PLUGIN_EXTRA_WARN_CXXFLAGS)	\
 	$(AM_CXXFLAGS)
 
-libtotem_cone_plugin_la_LIBADD =					\
-	libtotempluginviewer_helper.la					\
-	$(DBUS_LIBS)	\
-	$(BROWSER_PLUGIN_LIBS)	\
-	$(LIBXPCOMGLUE_S)
+libtotem_cone_plugin_la_LIBADD = \
+	libtotembrowserplugin_helper.la	\
+	$(DBUS_LIBS)			\
+	$(BROWSER_PLUGIN_LIBS)
 
 libtotem_cone_plugin_la_LDFLAGS = \
 	-avoid-version	\
@@ -498,4 +506,3 @@
 	$(AM_LDFLAGS)
 
 endif
-

Copied: trunk/browser-plugin/marshal.list (from r5440, /trunk/browser-plugin/totempluginviewer-marshal.list)
==============================================================================

Added: trunk/browser-plugin/npapi.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/npapi.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,807 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+ 
+ 
+ /*
+  *  Netscape client plug-in API spec
+  */
+ 
+
+#ifndef _NPAPI_H_
+#define _NPAPI_H_
+
+#ifdef INCLUDE_JAVA
+#include "jri.h"                /* Java Runtime Interface */
+#else
+#define jref    void *
+#define JRIEnv  void
+#endif
+
+#ifdef _WIN32
+#    ifndef XP_WIN
+#        define XP_WIN 1
+#    endif /* XP_WIN */
+#endif /* _WIN32 */
+
+#ifdef __MWERKS__
+#    define _declspec __declspec
+#    ifdef macintosh
+#        ifndef XP_MAC
+#            define XP_MAC 1
+#        endif /* XP_MAC */
+#    endif /* macintosh */
+#    ifdef __INTEL__
+#        undef NULL
+#        ifndef XP_WIN
+#            define XP_WIN 1
+#        endif /* __INTEL__ */
+#    endif /* XP_PC */
+#endif /* __MWERKS__ */
+
+#if defined(__APPLE_CC__) && !defined(__MACOS_CLASSIC__) && !defined(XP_UNIX)
+#   define XP_MACOSX
+#endif
+
+#ifdef XP_MAC
+    #include <Quickdraw.h>
+    #include <Events.h>
+#endif
+
+#if defined(XP_MACOSX) && defined(__LP64__)
+#define NP_NO_QUICKDRAW
+#define NP_NO_CARBON
+#endif
+
+#ifdef XP_MACOSX
+    #include <ApplicationServices/ApplicationServices.h>
+    #include <OpenGL/OpenGL.h>
+#ifndef NP_NO_CARBON
+    #include <Carbon/Carbon.h>
+#endif
+#endif
+
+#ifdef XP_UNIX
+    #include <X11/Xlib.h>
+    #include <X11/Xutil.h>
+    #include <stdio.h>
+#endif
+
+#ifdef XP_WIN
+    #include <windows.h>
+#endif
+
+/*----------------------------------------------------------------------*/
+/*             Plugin Version Constants                                 */
+/*----------------------------------------------------------------------*/
+
+#define NP_VERSION_MAJOR 0
+#define NP_VERSION_MINOR 20
+
+
+
+/*----------------------------------------------------------------------*/
+/*             Definition of Basic Types                                */
+/*----------------------------------------------------------------------*/
+
+#ifndef _UINT16
+#define _UINT16
+typedef unsigned short uint16;
+#endif
+
+#ifndef _UINT32
+#define _UINT32
+#ifdef __LP64__
+typedef unsigned int uint32;
+#else /* __LP64__ */
+typedef unsigned long uint32;
+#endif /* __LP64__ */
+#endif
+
+#ifndef _INT16
+#define _INT16
+typedef short int16;
+#endif
+
+#ifndef _INT32
+#define _INT32
+#ifdef __LP64__
+typedef int int32;
+#else /* __LP64__ */
+typedef long int32;
+#endif /* __LP64__ */
+#endif
+
+#ifndef FALSE
+#define FALSE (0)
+#endif
+#ifndef TRUE
+#define TRUE (1)
+#endif
+#ifndef NULL
+#define NULL (0L)
+#endif
+
+typedef unsigned char    NPBool;
+typedef int16            NPError;
+typedef int16            NPReason;
+typedef char*            NPMIMEType;
+
+
+
+/*----------------------------------------------------------------------*/
+/*             Structures and definitions             */
+/*----------------------------------------------------------------------*/
+
+#if !defined(__LP64__)
+#if defined(XP_MAC) || defined(XP_MACOSX)
+#pragma options align=mac68k
+#endif
+#endif /* __LP64__ */
+
+/*
+ *  NPP is a plug-in's opaque instance handle
+ */
+typedef struct _NPP
+{
+    void*    pdata;            /* plug-in private data */
+    void*    ndata;            /* netscape private data */
+} NPP_t;
+
+typedef NPP_t*    NPP;
+
+
+typedef struct _NPStream
+{
+    void*        pdata;        /* plug-in private data */
+    void*        ndata;        /* netscape private data */
+    const char*  url;
+    uint32       end;
+    uint32       lastmodified;
+    void*        notifyData;
+    const char*  headers;      /* Response headers from host.
+                                * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS.
+                                * Used for HTTP only; NULL for non-HTTP.
+                                * Available from NPP_NewStream onwards.
+                                * Plugin should copy this data before storing it.
+                                * Includes HTTP status line and all headers,
+                                * preferably verbatim as received from server,
+                                * headers formatted as in HTTP ("Header: Value"),
+                                * and newlines (\n, NOT \r\n) separating lines.
+                                * Terminated by \n\0 (NOT \n\n\0). */
+} NPStream;
+
+
+typedef struct _NPByteRange
+{
+    int32      offset;         /* negative offset means from the end */
+    uint32     length;
+    struct _NPByteRange* next;
+} NPByteRange;
+
+
+typedef struct _NPSavedData
+{
+    int32    len;
+    void*    buf;
+} NPSavedData;
+
+
+typedef struct _NPRect
+{
+    uint16    top;
+    uint16    left;
+    uint16    bottom;
+    uint16    right;
+} NPRect;
+
+
+#ifdef XP_UNIX
+/*
+ * Unix specific structures and definitions
+ */
+
+/*
+ * Callback Structures.
+ *
+ * These are used to pass additional platform specific information.
+ */
+enum {
+    NP_SETWINDOW = 1,
+    NP_PRINT
+};
+
+typedef struct
+{
+    int32        type;
+} NPAnyCallbackStruct;
+
+typedef struct
+{
+    int32           type;
+    Display*        display;
+    Visual*         visual;
+    Colormap        colormap;
+    unsigned int    depth;
+} NPSetWindowCallbackStruct;
+
+typedef struct
+{
+    int32            type;
+    FILE*            fp;
+} NPPrintCallbackStruct;
+
+#endif /* XP_UNIX */
+
+/*
+ *   The following masks are applied on certain platforms to NPNV and 
+ *   NPPV selectors that pass around pointers to COM interfaces. Newer 
+ *   compilers on some platforms may generate vtables that are not 
+ *   compatible with older compilers. To prevent older plugins from 
+ *   not understanding a new browser's ABI, these masks change the 
+ *   values of those selectors on those platforms. To remain backwards
+ *   compatible with differenet versions of the browser, plugins can 
+ *   use these masks to dynamically determine and use the correct C++
+ *   ABI that the browser is expecting. This does not apply to Windows 
+ *   as Microsoft's COM ABI will likely not change.
+ */
+
+#define NP_ABI_GCC3_MASK  0x10000000
+/*
+ *   gcc 3.x generated vtables on UNIX and OSX are incompatible with 
+ *   previous compilers.
+ */
+#if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3))
+#define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK
+#else
+#define _NP_ABI_MIXIN_FOR_GCC3 0
+#endif
+
+#define NP_ABI_MACHO_MASK 0x01000000
+/*
+ *   On OSX, the Mach-O executable format is significantly
+ *   different than CFM. In addition to having a different
+ *   C++ ABI, it also has has different C calling convention.
+ *   You must use glue code when calling between CFM and
+ *   Mach-O C functions. 
+ */
+#if (defined(TARGET_RT_MAC_MACHO))
+#define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK
+#else
+#define _NP_ABI_MIXIN_FOR_MACHO 0
+#endif
+
+
+#define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO)
+
+/*
+ * List of variable names for which NPP_GetValue shall be implemented
+ */
+typedef enum {
+    NPPVpluginNameString = 1,
+    NPPVpluginDescriptionString,
+    NPPVpluginWindowBool,
+    NPPVpluginTransparentBool,
+
+    NPPVjavaClass,                /* Not implemented in WebKit */
+    NPPVpluginWindowSize,         /* Not implemented in WebKit */
+    NPPVpluginTimerInterval,      /* Not implemented in WebKit */
+
+    NPPVpluginScriptableInstance = (10 | NP_ABI_MASK), /* Not implemented in WebKit */
+    NPPVpluginScriptableIID = 11, /* Not implemented in WebKit */
+
+    /* 12 and over are available on Mozilla builds starting with 0.9.9 */
+    NPPVjavascriptPushCallerBool = 12,  /* Not implemented in WebKit */
+    NPPVpluginKeepLibraryInMemory = 13, /* Not implemented in WebKit */
+    NPPVpluginNeedsXEmbed         = 14, /* Not implemented in WebKit */
+
+    /* Get the NPObject for scripting the plugin. */
+    NPPVpluginScriptableNPObject  = 15,
+
+    /* Get the plugin value (as \0-terminated UTF-8 string data) for
+     * form submission if the plugin is part of a form. Use
+     * NPN_MemAlloc() to allocate memory for the string data.
+     */
+    NPPVformValue = 16,    /* Not implemented in WebKit */
+#ifdef XP_MACOSX
+    /* Used for negotiating drawing models */
+    NPPVpluginDrawingModel = 1000,
+    /* Used for negotiating event models */
+    NPPVpluginEventModel = 1001,
+#endif
+} NPPVariable;
+
+/*
+ * List of variable names for which NPN_GetValue is implemented by Mozilla
+ */
+typedef enum {
+    NPNVxDisplay = 1,
+    NPNVxtAppContext,
+    NPNVnetscapeWindow,
+    NPNVjavascriptEnabledBool,
+    NPNVasdEnabledBool,
+    NPNVisOfflineBool,
+
+    /* 10 and over are available on Mozilla builds starting with 0.9.4 */
+    NPNVserviceManager = (10 | NP_ABI_MASK),  /* Not implemented in WebKit */
+    NPNVDOMElement     = (11 | NP_ABI_MASK),  /* Not implemented in WebKit */
+    NPNVDOMWindow      = (12 | NP_ABI_MASK),  /* Not implemented in WebKit */
+    NPNVToolkit        = (13 | NP_ABI_MASK),  /* Not implemented in WebKit */
+    NPNVSupportsXEmbedBool = 14,              /* Not implemented in WebKit */
+
+    /* Get the NPObject wrapper for the browser window. */
+    NPNVWindowNPObject = 15,
+
+    /* Get the NPObject wrapper for the plugins DOM element. */
+    NPNVPluginElementNPObject
+
+#ifdef XP_MACOSX
+    , NPNVpluginDrawingModel = 1000 /* The NPDrawingModel specified by the plugin */
+
+#ifndef NP_NO_QUICKDRAW
+    , NPNVsupportsQuickDrawBool = 2000 /* TRUE if the browser supports the QuickDraw drawing model */
+#endif
+    , NPNVsupportsCoreGraphicsBool = 2001 /* TRUE if the browser supports the CoreGraphics drawing model */
+    , NPNVsupportsOpenGLBool = 2002 /* TRUE if the browser supports the OpenGL drawing model (CGL on Mac) */
+    
+    , NPNVpluginEventModel = 1001 /* The NPEventModel specified by the plugin */
+#ifndef NP_NO_CARBON
+    , NPNVsupportsCarbonBool = 2003 /* TRUE if the browser supports the Carbon event model */
+#endif
+    , NPNVsupportsCocoaBool = 2004 /* TRUE if the browser supports the Cocoa event model */
+#endif /* XP_MACOSX */
+} NPNVariable;
+
+/*
+ * The type of a NPWindow - it specifies the type of the data structure
+ * returned in the window field.
+ */
+typedef enum {
+    NPWindowTypeWindow = 1,
+    NPWindowTypeDrawable
+} NPWindowType;
+
+#ifdef XP_MACOSX
+
+/*
+ * The drawing model for a Mac OS X plugin.  These are the possible values for the NPNVpluginDrawingModel variable.
+ */
+ 
+typedef enum {
+#ifndef NP_NO_QUICKDRAW
+    NPDrawingModelQuickDraw = 0,
+#endif
+    NPDrawingModelCoreGraphics = 1,
+    NPDrawingModelOpenGL = 2
+} NPDrawingModel;
+
+/*
+ * The event model for a Mac OS X plugin. These are the possible values for the NPNVpluginEventModel variable.
+ */
+
+typedef enum {
+#ifndef NP_NO_CARBON
+    NPEventModelCarbon = 0,
+#endif
+    NPEventModelCocoa = 1,
+} NPEventModel;
+
+typedef enum {
+    NPCocoaEventDrawRect = 1,
+    NPCocoaEventMouseDown,
+    NPCocoaEventMouseUp,
+    NPCocoaEventMouseMoved,
+    NPCocoaEventMouseEntered,
+    NPCocoaEventMouseExited,
+    NPCocoaEventMouseDragged,
+    NPCocoaEventKeyDown,
+    NPCocoaEventKeyUp,
+    NPCocoaEventFlagsChanged,
+    NPCocoaEventFocusChanged,
+    NPCocoaEventWindowFocusChanged,
+    NPCocoaEventScrollWheel,
+} NPCocoaEventType;
+
+typedef struct _NPNSString NPNSString;
+typedef struct _NPNSWindow NPNSWindow;
+
+typedef struct _NPCocoaEvent {
+    NPCocoaEventType type;
+    union {
+        struct {
+            uint32 modifierFlags;
+            double pluginX;
+            double pluginY;            
+            int32 buttonNumber;
+            int32 clickCount;
+            double deltaX;
+            double deltaY;
+            double deltaZ;
+        } mouse;
+        struct {
+            uint32 modifierFlags;
+            double pluginX;
+            double pluginY;            
+            NPNSString *characters;
+            NPNSString *charactersIgnoringModifiers;
+            NPBool isARepeat;
+            uint16 keyCode;
+        } key;
+        struct {
+            double x;
+            double y;
+            double width;
+            double height;
+        } draw;
+        struct {
+            NPBool hasFocus;
+        } focus;        
+    };
+} NPCocoaEvent;
+
+#endif
+
+typedef struct _NPWindow
+{
+    void*    window;     /* Platform specific window handle */
+    int32    x;            /* Position of top left corner relative */
+    int32    y;            /*    to a netscape page.                    */
+    uint32    width;        /* Maximum window size */
+    uint32    height;
+    NPRect    clipRect;    /* Clipping rectangle in port coordinates */
+                        /* Used by MAC only.              */
+#ifdef XP_UNIX
+    void *    ws_info;    /* Platform-dependent additonal data */
+#endif /* XP_UNIX */
+    NPWindowType type;    /* Is this a window or a drawable? */
+} NPWindow;
+
+
+typedef struct _NPFullPrint
+{
+    NPBool    pluginPrinted;    /* Set TRUE if plugin handled fullscreen */
+                            /*    printing                             */
+    NPBool    printOne;        /* TRUE if plugin should print one copy  */
+                            /*    to default printer                     */
+    void*    platformPrint;    /* Platform-specific printing info */
+} NPFullPrint;
+
+typedef struct _NPEmbedPrint
+{
+    NPWindow    window;
+    void*    platformPrint;    /* Platform-specific printing info */
+} NPEmbedPrint;
+
+typedef struct _NPPrint
+{
+    uint16    mode;                        /* NP_FULL or NP_EMBED */
+    union
+    {
+        NPFullPrint     fullPrint;        /* if mode is NP_FULL */
+        NPEmbedPrint    embedPrint;        /* if mode is NP_EMBED */
+    } print;
+} NPPrint;
+
+#if defined(XP_MAC) || defined(XP_MACOSX)
+
+#ifndef NP_NO_CARBON
+typedef EventRecord    NPEvent;
+#endif
+
+#elif defined(XP_WIN)
+typedef struct _NPEvent
+{
+    uint16   event;
+    uint32   wParam;
+    uint32   lParam;
+} NPEvent;
+#elif defined (XP_UNIX)
+typedef XEvent NPEvent;
+#else
+typedef void*            NPEvent;
+#endif /* XP_MAC */
+
+#if defined(XP_MAC)
+typedef RgnHandle NPRegion;
+#elif defined(XP_MACOSX)
+/* 
+ * NPRegion's type depends on the drawing model specified by the plugin (see NPNVpluginDrawingModel).
+ * NPQDRegion represents a QuickDraw RgnHandle and is used with the QuickDraw drawing model.
+ * NPCGRegion repesents a graphical region when using any other drawing model.
+ */
+typedef void *NPRegion;
+#ifndef NP_NO_QUICKDRAW
+typedef RgnHandle NPQDRegion;
+#endif
+typedef CGPathRef NPCGRegion;
+#elif defined(XP_WIN)
+typedef HRGN NPRegion;
+#elif defined(XP_UNIX)
+typedef Region NPRegion;
+#else
+typedef void *NPRegion;
+#endif /* XP_MAC */
+
+#ifdef XP_MACOSX
+
+/* 
+ * NP_CGContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelCoreGraphics
+ * as its drawing model.
+ */
+
+typedef struct NP_CGContext
+{
+    CGContextRef context;
+#ifdef NP_NO_CARBON
+    NPNSWindow *window;
+#else
+    void *window; // Can be either an NSWindow or a WindowRef depending on the event model
+#endif
+} NP_CGContext;
+
+/* 
+ * NP_GLContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelOpenGL as its
+ * drawing model.
+ */
+
+typedef struct NP_GLContext
+{
+    CGLContextObj context;
+#ifdef NP_NO_CARBON
+    NPNSWindow *window;
+#else
+    void *window; // Can be either an NSWindow or a WindowRef depending on the event model
+#endif
+} NP_GLContext;
+
+#endif /* XP_MACOSX */
+
+#if defined(XP_MAC) || defined(XP_MACOSX)
+
+/*
+ *  Mac-specific structures and definitions.
+ */
+
+#ifndef NP_NO_QUICKDRAW
+
+/* 
+ * NP_Port is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelQuickDraw as its
+ * drawing model, or the plugin does not specify a drawing model.
+ *
+ * It is not recommended that new plugins use NPDrawingModelQuickDraw or NP_Port, as QuickDraw has been
+ * deprecated in Mac OS X 10.5.  CoreGraphics is the preferred drawing API.
+ *
+ * NP_Port is not available in 64-bit.
+ */
+ 
+typedef struct NP_Port
+{
+    CGrafPtr     port;        /* Grafport */
+    int32        portx;        /* position inside the topmost window */
+    int32        porty;
+} NP_Port;
+
+#endif /* NP_NO_QUICKDRAW */
+
+/*
+ *  Non-standard event types that can be passed to HandleEvent
+ */
+#define getFocusEvent        (osEvt + 16)
+#define loseFocusEvent        (osEvt + 17)
+#define adjustCursorEvent   (osEvt + 18)
+
+#endif /* XP_MAC */
+
+
+/*
+ * Values for mode passed to NPP_New:
+ */
+#define NP_EMBED        1
+#define NP_FULL         2
+
+/*
+ * Values for stream type passed to NPP_NewStream:
+ */
+#define NP_NORMAL        1
+#define NP_SEEK         2
+#define NP_ASFILE        3
+#define NP_ASFILEONLY        4
+
+#define NP_MAXREADY    (((unsigned)(~0)<<1)>>1)
+
+#if !defined(__LP64__)
+#if defined(XP_MAC) || defined(XP_MACOSX)
+#pragma options align=reset
+#endif
+#endif /* __LP64__ */
+
+
+/*----------------------------------------------------------------------*/
+/*             Error and Reason Code definitions            */
+/*----------------------------------------------------------------------*/
+
+/*
+ *    Values of type NPError:
+ */
+#define NPERR_BASE                            0
+#define NPERR_NO_ERROR                        (NPERR_BASE + 0)
+#define NPERR_GENERIC_ERROR                    (NPERR_BASE + 1)
+#define NPERR_INVALID_INSTANCE_ERROR        (NPERR_BASE + 2)
+#define NPERR_INVALID_FUNCTABLE_ERROR        (NPERR_BASE + 3)
+#define NPERR_MODULE_LOAD_FAILED_ERROR        (NPERR_BASE + 4)
+#define NPERR_OUT_OF_MEMORY_ERROR            (NPERR_BASE + 5)
+#define NPERR_INVALID_PLUGIN_ERROR            (NPERR_BASE + 6)
+#define NPERR_INVALID_PLUGIN_DIR_ERROR        (NPERR_BASE + 7)
+#define NPERR_INCOMPATIBLE_VERSION_ERROR    (NPERR_BASE + 8)
+#define NPERR_INVALID_PARAM                (NPERR_BASE + 9)
+#define NPERR_INVALID_URL                    (NPERR_BASE + 10)
+#define NPERR_FILE_NOT_FOUND                (NPERR_BASE + 11)
+#define NPERR_NO_DATA                        (NPERR_BASE + 12)
+#define NPERR_STREAM_NOT_SEEKABLE            (NPERR_BASE + 13)
+
+/*
+ *    Values of type NPReason:
+ */
+#define NPRES_BASE                0
+#define NPRES_DONE                    (NPRES_BASE + 0)
+#define NPRES_NETWORK_ERR            (NPRES_BASE + 1)
+#define NPRES_USER_BREAK            (NPRES_BASE + 2)
+
+/*
+ *      Don't use these obsolete error codes any more.
+ */
+#define NP_NOERR  NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
+#define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
+#define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
+
+/*
+ * Version feature information
+ */
+#define NPVERS_HAS_STREAMOUTPUT     8
+#define NPVERS_HAS_NOTIFICATION     9
+#define NPVERS_HAS_LIVECONNECT        9
+#define NPVERS_WIN16_HAS_LIVECONNECT    9
+#define NPVERS_68K_HAS_LIVECONNECT    11
+#define NPVERS_HAS_WINDOWLESS       11
+#define NPVERS_HAS_XPCONNECT_SCRIPTING    13  /* Not implemented in WebKit */
+#define NPVERS_HAS_NPRUNTIME_SCRIPTING    14
+#define NPVERS_HAS_FORM_VALUES            15  /* Not implemented in WebKit; see bug 13061 */
+#define NPVERS_HAS_POPUPS_ENABLED_STATE   16  /* Not implemented in WebKit */
+#define NPVERS_HAS_RESPONSE_HEADERS       17
+#define NPVERS_HAS_NPOBJECT_ENUM          18
+#define NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL 19
+#define NPVERS_MACOSX_HAS_EVENT_MODELS    20
+
+/*----------------------------------------------------------------------*/
+/*             Function Prototypes                */
+/*----------------------------------------------------------------------*/
+
+#if defined(_WINDOWS) && !defined(WIN32)
+#define NP_LOADDS  _loadds
+#else
+#define NP_LOADDS
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * NPP_* functions are provided by the plugin and called by the navigator.
+ */
+
+#ifdef XP_UNIX
+char*                    NPP_GetMIMEDescription(void);
+#endif /* XP_UNIX */
+
+NPError     NPP_Initialize(void);
+void        NPP_Shutdown(void);
+NPError     NP_LOADDS    NPP_New(NPMIMEType pluginType, NPP instance,
+                                uint16 mode, int16 argc, char* argn[],
+                                char* argv[], NPSavedData* saved);
+NPError     NP_LOADDS    NPP_Destroy(NPP instance, NPSavedData** save);
+NPError     NP_LOADDS    NPP_SetWindow(NPP instance, NPWindow* window);
+NPError     NP_LOADDS    NPP_NewStream(NPP instance, NPMIMEType type,
+                                      NPStream* stream, NPBool seekable,
+                                      uint16* stype);
+NPError     NP_LOADDS    NPP_DestroyStream(NPP instance, NPStream* stream,
+                                          NPReason reason);
+int32        NP_LOADDS    NPP_WriteReady(NPP instance, NPStream* stream);
+int32        NP_LOADDS    NPP_Write(NPP instance, NPStream* stream, int32 offset,
+                                  int32 len, void* buffer);
+void        NP_LOADDS    NPP_StreamAsFile(NPP instance, NPStream* stream,
+                                         const char* fname);
+void        NP_LOADDS    NPP_Print(NPP instance, NPPrint* platformPrint);
+int16            NPP_HandleEvent(NPP instance, void* event);
+void        NP_LOADDS    NPP_URLNotify(NPP instance, const char* url,
+                                      NPReason reason, void* notifyData);
+jref        NP_LOADDS            NPP_GetJavaClass(void);
+NPError     NPP_GetValue(NPP instance, NPPVariable variable,
+                                     void *value);
+NPError     NPP_SetValue(NPP instance, NPNVariable variable,
+                                     void *value);
+
+/*
+ * NPN_* functions are provided by the navigator and called by the plugin.
+ */
+
+void        NPN_Version(int* plugin_major, int* plugin_minor,
+                            int* netscape_major, int* netscape_minor);
+NPError     NPN_GetURLNotify(NPP instance, const char* url,
+                                 const char* target, void* notifyData);
+NPError     NPN_GetURL(NPP instance, const char* url,
+                           const char* target);
+NPError     NPN_PostURLNotify(NPP instance, const char* url,
+                                  const char* target, uint32 len,
+                                  const char* buf, NPBool file,
+                                  void* notifyData);
+NPError     NPN_PostURL(NPP instance, const char* url,
+                            const char* target, uint32 len,
+                            const char* buf, NPBool file);
+NPError     NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
+NPError     NPN_NewStream(NPP instance, NPMIMEType type,
+                              const char* target, NPStream** stream);
+int32        NPN_Write(NPP instance, NPStream* stream, int32 len,
+                          void* buffer);
+NPError     NPN_DestroyStream(NPP instance, NPStream* stream,
+                                  NPReason reason);
+void        NPN_Status(NPP instance, const char* message);
+const char*    NPN_UserAgent(NPP instance);
+void*        NPN_MemAlloc(uint32 size);
+void        NPN_MemFree(void* ptr);
+uint32        NPN_MemFlush(uint32 size);
+void* NPN_MemDup (const void*, uint32);
+char* NPN_StrDup (const char *);
+void        NPN_ReloadPlugins(NPBool reloadPages);
+JRIEnv*     NPN_GetJavaEnv(void);
+jref        NPN_GetJavaPeer(NPP instance);
+NPError     NPN_GetValue(NPP instance, NPNVariable variable,
+                             void *value);
+NPError     NPN_SetValue(NPP instance, NPPVariable variable,
+                             void *value);
+void        NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
+void        NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
+void        NPN_ForceRedraw(NPP instance);
+void        NPN_PushPopupsEnabledState(NPP instance, NPBool enabled);
+void        NPN_PopPopupsEnabledState(NPP instance);
+void        NPN_PluginThreadAsyncCall(NPP instance, void (*func) (void *), void *userData);
+uint32      NPN_ScheduleTimer(NPP instance, uint32 interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32 timerID));
+void        NPN_UnscheduleTimer(NPP instance, uint32 timerID);
+
+#ifdef __cplusplus
+}  /* end extern "C" */
+#endif
+
+#endif /* _NPAPI_H_ */

Added: trunk/browser-plugin/npruntime.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/npruntime.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,351 @@
+/*
+ * Copyright (C) 2004, Apple Computer, Inc. and The Mozilla Foundation. 
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla
+ * Foundation ("Mozilla") nor the names of their contributors may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR
+ * THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Revision 1 (March 4, 2004):
+ * Initial proposal.
+ *
+ * Revision 2 (March 10, 2004):
+ * All calls into script were made asynchronous.  Results are
+ * provided via the NPScriptResultFunctionPtr callback.
+ *
+ * Revision 3 (March 10, 2004):
+ * Corrected comments to not refer to class retain/release FunctionPtrs.
+ *
+ * Revision 4 (March 11, 2004):
+ * Added additional convenience NPN_SetExceptionWithUTF8().
+ * Changed NPHasPropertyFunctionPtr and NPHasMethodFunctionPtr to take NPClass
+ * pointers instead of NPObject pointers.
+ * Added NPIsValidIdentifier().
+ *
+ * Revision 5 (March 17, 2004):
+ * Added context parameter to result callbacks from ScriptObject functions.
+ *
+ * Revision 6 (March 29, 2004):
+ * Renamed functions implemented by user agent to NPN_*.  Removed _ from
+ * type names.
+ * Renamed "JavaScript" types to "Script".
+ *
+ * Revision 7 (April 21, 2004):
+ * NPIdentifier becomes a void*, was int32_t
+ * Remove NP_IsValidIdentifier, renamed NP_IdentifierFromUTF8 to NP_GetIdentifier
+ * Added NPVariant and modified functions to use this new type.
+ *
+ * Revision 8 (July 9, 2004):
+ * Updated to joint Apple-Mozilla license.
+ *
+ * Revision 9 (August 12, 2004):
+ * Changed NPVariantType enum values to form PVariantType_XXX
+ * Added NPP arguments to NPObject functions.
+ * Replaced NPVariant functions with macros.
+ */
+#ifndef _NP_RUNTIME_H_
+#define _NP_RUNTIME_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include "npapi.h"
+
+/*
+    This API is used to facilitate binding code written in C to script
+    objects.  The API in this header does not assume the presence of a
+    user agent.  That is, it can be used to bind C code to scripting
+    environments outside of the context of a user agent.
+    
+    However, the normal use of the this API is in the context of a
+    scripting environment running in a browser or other user agent.
+    In particular it is used to support the extended Netscape
+    script-ability API for plugins (NP-SAP).  NP-SAP is an extension
+    of the Netscape plugin API.  As such we have adopted the use of
+    the "NP" prefix for this API.
+
+    The following NP{N|P}Variables were added to the Netscape plugin
+    API (in npapi.h):
+
+    NPNVWindowNPObject
+    NPNVPluginElementNPObject
+    NPPVpluginScriptableNPObject
+
+    These variables are exposed through NPN_GetValue() and
+    NPP_GetValue() (respectively) and are used to establish the
+    initial binding between the user agent and native code.  The DOM
+    objects in the user agent can be examined and manipulated using
+    the NPN_ functions that operate on NPObjects described in this
+    header.
+
+    To the extent possible the assumptions about the scripting
+    language used by the scripting environment have been minimized.
+*/
+
+
+/*
+    Objects (non-primitive data) passed between 'C' and script is
+    always wrapped in an NPObject.  The 'interface' of an NPObject is
+    described by an NPClass.
+*/
+typedef struct NPObject NPObject;
+typedef struct NPClass NPClass;
+
+typedef char NPUTF8;
+typedef struct _NPString {
+    const NPUTF8 *UTF8Characters;
+    uint32_t UTF8Length;
+} NPString;
+  
+typedef enum {
+    NPVariantType_Void,
+    NPVariantType_Null,
+    NPVariantType_Bool,
+    NPVariantType_Int32,
+    NPVariantType_Double,
+    NPVariantType_String,
+    NPVariantType_Object
+} NPVariantType;
+
+typedef struct _NPVariant {
+    NPVariantType type;
+    union {
+        bool boolValue;
+        int32_t intValue;
+        double doubleValue;
+        NPString stringValue;
+        NPObject *objectValue;
+    } value;
+} NPVariant;
+
+/*
+    NPN_ReleaseVariantValue is called on all 'out' parameters references.
+    Specifically it is called on variants that are resultant out parameters
+    in NPGetPropertyFunctionPtr and NPInvokeFunctionPtr.  Resultant variants
+    from these two functions should be initialized using the
+    NPN_InitializeVariantXXX() functions.
+    
+    After calling NPReleaseVariantValue, the type of the variant will
+    be set to NPVariantUndefinedType.
+*/
+void NPN_ReleaseVariantValue (NPVariant *variant);
+
+#define NPVARIANT_IS_VOID(_v)    ((_v).type == NPVariantType_Void)
+#define NPVARIANT_IS_NULL(_v)    ((_v).type == NPVariantType_Null)
+#define NPVARIANT_IS_BOOLEAN(_v) ((_v).type == NPVariantType_Bool)
+#define NPVARIANT_IS_INT32(_v)   ((_v).type == NPVariantType_Int32)
+#define NPVARIANT_IS_DOUBLE(_v)  ((_v).type == NPVariantType_Double)
+#define NPVARIANT_IS_STRING(_v)  ((_v).type == NPVariantType_String)
+#define NPVARIANT_IS_OBJECT(_v)  ((_v).type == NPVariantType_Object)
+
+#define NPVARIANT_TO_BOOLEAN(_v) ((_v).value.boolValue)
+#define NPVARIANT_TO_INT32(_v)   ((_v).value.intValue)
+#define NPVARIANT_TO_DOUBLE(_v)  ((_v).value.doubleValue)
+#define NPVARIANT_TO_STRING(_v)  ((_v).value.stringValue)
+#define NPVARIANT_TO_OBJECT(_v)  ((_v).value.objectValue)
+
+#define NP_BEGIN_MACRO  do {
+#define NP_END_MACRO    } while (0)
+
+#define VOID_TO_NPVARIANT(_v)                NP_BEGIN_MACRO (_v).type = NPVariantType_Void; (_v).value.objectValue = NULL; NP_END_MACRO
+#define NULL_TO_NPVARIANT(_v)                NP_BEGIN_MACRO (_v).type = NPVariantType_Null; (_v).value.objectValue = NULL; NP_END_MACRO
+#define BOOLEAN_TO_NPVARIANT(_val, _v)       NP_BEGIN_MACRO (_v).type = NPVariantType_Bool; (_v).value.boolValue = !!(_val); NP_END_MACRO
+#define INT32_TO_NPVARIANT(_val, _v)         NP_BEGIN_MACRO (_v).type = NPVariantType_Int32; (_v).value.intValue = _val; NP_END_MACRO
+#define DOUBLE_TO_NPVARIANT(_val, _v)        NP_BEGIN_MACRO (_v).type = NPVariantType_Double; (_v).value.doubleValue = _val; NP_END_MACRO
+#define STRINGZ_TO_NPVARIANT(_val, _v)       NP_BEGIN_MACRO (_v).type = NPVariantType_String; NPString str = { _val, strlen(_val) }; (_v).value.stringValue = str; NP_END_MACRO
+#define STRINGN_TO_NPVARIANT(_val, _len, _v) NP_BEGIN_MACRO (_v).type = NPVariantType_String; NPString str = { _val, _len }; (_v).value.stringValue = str; NP_END_MACRO
+#define OBJECT_TO_NPVARIANT(_val, _v)        NP_BEGIN_MACRO (_v).type = NPVariantType_Object; (_v).value.objectValue = _val; NP_END_MACRO
+
+/*
+        Type mappings (JavaScript types have been used for illustration
+    purposes):
+
+        JavaScript       to             C (NPVariant with type:)
+        undefined                       NPVariantType_Void
+        null                            NPVariantType_Null
+        Boolean                         NPVariantType_Bool
+        Number                          NPVariantType_Double or NPVariantType_Int32
+        String                          NPVariantType_String
+        Object                          NPVariantType_Object
+
+        C (NPVariant with type:)   to   JavaScript
+        NPVariantType_Void              undefined
+        NPVariantType_Null              null
+        NPVariantType_Bool              Boolean 
+        NPVariantType_Int32             Number
+        NPVariantType_Double            Number
+        NPVariantType_String            String
+        NPVariantType_Object            Object
+*/
+
+typedef void *NPIdentifier;
+
+/*
+    NPObjects have methods and properties.  Methods and properties are
+    identified with NPIdentifiers.  These identifiers may be reflected
+    in script.  NPIdentifiers can be either strings or integers, IOW,
+    methods and properties can be identified by either strings or
+    integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be
+    compared using ==.  In case of any errors, the requested
+    NPIdentifier(s) will be NULL.
+*/
+NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name);
+void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers);
+NPIdentifier NPN_GetIntIdentifier(int32_t intid);
+bool NPN_IdentifierIsString(NPIdentifier identifier);
+
+/*
+    The NPUTF8 returned from NPN_UTF8FromIdentifier SHOULD be freed.
+*/
+NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier);
+
+/*
+    Get the integer represented by identifier. If identifier is not an
+    integer identifier, the behaviour is undefined.
+*/
+int32_t NPN_IntFromIdentifier(NPIdentifier identifier);
+
+/*
+    NPObject behavior is implemented using the following set of
+    callback functions.
+
+    The NPVariant *result argument of these functions (where
+    applicable) should be released using NPN_ReleaseVariantValue().
+*/
+typedef NPObject *(*NPAllocateFunctionPtr)(NPP npp, NPClass *aClass);
+typedef void (*NPDeallocateFunctionPtr)(NPObject *obj);
+typedef void (*NPInvalidateFunctionPtr)(NPObject *obj);
+typedef bool (*NPHasMethodFunctionPtr)(NPObject *obj, NPIdentifier name);
+typedef bool (*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result);
+typedef bool (*NPInvokeDefaultFunctionPtr)(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+typedef bool (*NPHasPropertyFunctionPtr)(NPObject *obj, NPIdentifier name);
+typedef bool (*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *result);
+typedef bool (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *value);
+typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj, NPIdentifier name);
+typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value, uint32_t *count);
+
+/*
+    NPObjects returned by create have a reference count of one.  It is the caller's responsibility
+    to release the returned object.
+
+    NPInvokeFunctionPtr function may return false to indicate a the method could not be invoked.
+    
+    NPGetPropertyFunctionPtr and NPSetPropertyFunctionPtr may return false to indicate a property doesn't
+    exist.
+    
+    NPInvalidateFunctionPtr is called by the scripting environment when the native code is
+    shutdown.  Any attempt to message a NPObject instance after the invalidate
+    callback has been called will result in undefined behavior, even if the
+    native code is still retaining those NPObject instances.
+    (The runtime will typically return immediately, with 0 or NULL, from an attempt to
+    dispatch to a NPObject, but this behavior should not be depended upon.)
+    
+    The NPEnumerationFunctionPtr function may pass an array of                  
+    NPIdentifiers back to the caller. The callee allocs the memory of           
+    the array using NPN_MemAlloc(), and it's the caller's responsibility        
+    to release it using NPN_MemFree().           
+*/
+struct NPClass
+{
+    uint32_t structVersion;
+    NPAllocateFunctionPtr allocate;
+    NPDeallocateFunctionPtr deallocate;
+    NPInvalidateFunctionPtr invalidate;
+    NPHasMethodFunctionPtr hasMethod;
+    NPInvokeFunctionPtr invoke;
+    NPInvokeDefaultFunctionPtr invokeDefault;
+    NPHasPropertyFunctionPtr hasProperty;
+    NPGetPropertyFunctionPtr getProperty;
+    NPSetPropertyFunctionPtr setProperty;
+    NPRemovePropertyFunctionPtr removeProperty;
+    NPEnumerationFunctionPtr enumerate;
+};
+
+#define NP_CLASS_STRUCT_VERSION      2
+#define NP_CLASS_STRUCT_VERSION_ENUM 2                           
+#define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass)   \
+    ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM)
+
+struct NPObject {
+    NPClass *_class;
+    uint32_t referenceCount;
+    // Additional space may be allocated here by types of NPObjects
+};
+
+/*
+    If the class has an allocate function, NPN_CreateObject invokes that function,
+    otherwise a NPObject is allocated and returned.  If a class has an allocate
+    function it is the responsibility of that implementation to set the initial retain
+    count to 1.
+*/
+NPObject *NPN_CreateObject(NPP npp, NPClass *aClass);
+
+/*
+    Increment the NPObject's reference count.
+*/
+NPObject *NPN_RetainObject (NPObject *obj);
+
+/*
+    Decremented the NPObject's reference count.  If the reference
+    count goes to zero, the class's destroy function is invoke if
+    specified, otherwise the object is freed directly.
+*/
+void NPN_ReleaseObject (NPObject *obj);
+
+/*
+    Functions to access script objects represented by NPObject.
+
+    Calls to script objects are synchronous.  If a function returns a
+    value, it will be supplied via the result NPVariant
+    argument. Successful calls will return true, false will be
+    returned in case of an error.
+    
+    Calls made from plugin code to script must be made from the thread
+    on which the plugin was initialized.
+*/
+bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result);
+bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script, NPVariant *result);
+bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVariant *result);
+bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const NPVariant *value);
+bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
+bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
+bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName);
+bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count);
+bool NPN_Construct(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+
+/*
+    NPN_SetException may be called to trigger a script exception upon return
+    from entry points into NPObjects.
+*/
+void NPN_SetException (NPObject *obj, const NPUTF8 *message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Added: trunk/browser-plugin/npupp.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/npupp.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,719 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+/*
+ *  npupp.h $Revision: 3.26 $
+ *  function call mecahnics needed by platform specific glue code.
+ */
+
+
+#ifndef _NPUPP_H_
+#define _NPUPP_H_
+
+#if defined(__OS2__)
+#pragma pack(1)
+#endif
+
+#ifndef GENERATINGCFM
+#define GENERATINGCFM 0
+#endif
+
+#ifndef _NPAPI_H_
+#include "npapi.h"
+#endif
+
+#include "npruntime.h"
+
+#ifdef OJI
+#include "jri.h"
+#else
+typedef void*           JRIGlobalRef;
+#endif
+
+
+/******************************************************************************************
+   plug-in function table macros
+ 	        for each function in and out of the plugin API we define
+                    typedef NPP_FooUPP
+					#define NewNPP_FooProc
+					#define CallNPP_FooProc
+ *******************************************************************************************/
+
+
+/* NPP_Initialize */
+typedef void (* NP_LOADDS NPP_InitializeUPP)(void);
+#define NewNPP_InitializeProc(FUNC)		\
+		((NPP_InitializeUPP) (FUNC))
+#define CallNPP_InitializeProc(FUNC)		\
+		(*(FUNC))()
+
+/* NPP_Shutdown */
+typedef void (* NP_LOADDS NPP_ShutdownUPP)(void);
+#define NewNPP_ShutdownProc(FUNC)		\
+		((NPP_ShutdownUPP) (FUNC))
+#define CallNPP_ShutdownProc(FUNC)		\
+		(*(FUNC))()
+
+/* NPP_New */
+typedef NPError	(* NP_LOADDS NPP_NewUPP)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
+#define NewNPP_NewProc(FUNC)		\
+		((NPP_NewUPP) (FUNC))
+#define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
+
+/* NPP_Destroy */
+typedef NPError	(* NP_LOADDS NPP_DestroyUPP)(NPP instance, NPSavedData** save);
+#define NewNPP_DestroyProc(FUNC)		\
+		((NPP_DestroyUPP) (FUNC))
+#define CallNPP_DestroyProc(FUNC, ARG1, ARG2)		\
+		(*(FUNC))((ARG1), (ARG2))
+
+/* NPP_SetWindow */
+typedef NPError	(* NP_LOADDS NPP_SetWindowUPP)(NPP instance, NPWindow* window);
+#define NewNPP_SetWindowProc(FUNC)		\
+		((NPP_SetWindowUPP) (FUNC))
+#define CallNPP_SetWindowProc(FUNC, ARG1, ARG2)		\
+		(*(FUNC))((ARG1), (ARG2))
+
+/* NPP_NewStream */
+typedef NPError	(* NP_LOADDS NPP_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
+#define NewNPP_NewStreamProc(FUNC)		\
+		((NPP_NewStreamUPP) (FUNC))
+#define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
+
+/* NPP_DestroyStream */
+typedef NPError	(* NP_LOADDS NPP_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason);
+#define NewNPP_DestroyStreamProc(FUNC)		\
+		((NPP_DestroyStreamUPP) (FUNC))
+#define CallNPP_DestroyStreamProc(FUNC,  NPParg, NPStreamPtr, NPReasonArg)		\
+		(*(FUNC))((NPParg), (NPStreamPtr), (NPReasonArg))
+
+/* NPP_WriteReady */
+typedef int32 (* NP_LOADDS NPP_WriteReadyUPP)(NPP instance, NPStream* stream);
+#define NewNPP_WriteReadyProc(FUNC)		\
+		((NPP_WriteReadyUPP) (FUNC))
+#define CallNPP_WriteReadyProc(FUNC,  NPParg, NPStreamPtr)		\
+		(*(FUNC))((NPParg), (NPStreamPtr))
+
+/* NPP_Write */
+typedef int32 (* NP_LOADDS NPP_WriteUPP)(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
+#define NewNPP_WriteProc(FUNC)		\
+		((NPP_WriteUPP) (FUNC))
+#define CallNPP_WriteProc(FUNC,  NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr)		\
+		(*(FUNC))((NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr))
+
+/* NPP_StreamAsFile */
+typedef void (* NP_LOADDS NPP_StreamAsFileUPP)(NPP instance, NPStream* stream, const char* fname);
+#define NewNPP_StreamAsFileProc(FUNC)		\
+		((NPP_StreamAsFileUPP) (FUNC))
+#define CallNPP_StreamAsFileProc(FUNC,  ARG1, ARG2, ARG3)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3))
+
+/* NPP_Print */
+typedef void (* NP_LOADDS NPP_PrintUPP)(NPP instance, NPPrint* platformPrint);
+#define NewNPP_PrintProc(FUNC)		\
+		((NPP_PrintUPP) (FUNC))
+#define CallNPP_PrintProc(FUNC,  NPParg, NPPrintArg)		\
+		(*(FUNC))((NPParg), (NPPrintArg))
+
+/* NPP_HandleEvent */
+typedef int16 (* NP_LOADDS NPP_HandleEventUPP)(NPP instance, void* event);
+#define NewNPP_HandleEventProc(FUNC)		\
+		((NPP_HandleEventUPP) (FUNC))
+#define CallNPP_HandleEventProc(FUNC,  NPParg, voidPtr)		\
+		(*(FUNC))((NPParg), (voidPtr))
+
+/* NPP_URLNotify */
+typedef void (* NP_LOADDS NPP_URLNotifyUPP)(NPP instance, const char* url, NPReason reason, void* notifyData);
+#define NewNPP_URLNotifyProc(FUNC)		\
+		((NPP_URLNotifyUPP) (FUNC))
+#define CallNPP_URLNotifyProc(FUNC,  ARG1, ARG2, ARG3, ARG4)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+
+/* NPP_GetValue */
+typedef NPError	(* NP_LOADDS NPP_GetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
+#define NewNPP_GetValueProc(FUNC)		\
+		((NPP_GetValueUPP) (FUNC))
+#define CallNPP_GetValueProc(FUNC, ARG1, ARG2, ARG3)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3))
+
+/* NPP_SetValue */
+typedef NPError	(* NP_LOADDS NPP_SetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
+#define NewNPP_SetValueProc(FUNC)		\
+		((NPP_SetValueUPP) (FUNC))
+#define CallNPP_SetValueProc(FUNC, ARG1, ARG2, ARG3)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3))
+
+/*
+ *  Netscape entry points
+ */
+
+
+/* NPN_GetValue */
+typedef NPError	(* NP_LOADDS NPN_GetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
+#define NewNPN_GetValueProc(FUNC)		\
+		((NPN_GetValueUPP) (FUNC))
+#define CallNPN_GetValueProc(FUNC, ARG1, ARG2, ARG3)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3))
+
+/* NPN_SetValue */
+typedef NPError	(* NP_LOADDS NPN_SetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
+#define NewNPN_SetValueProc(FUNC)		\
+		((NPN_SetValueUPP) (FUNC))
+#define CallNPN_SetValueProc(FUNC, ARG1, ARG2, ARG3)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3))
+
+/* NPN_GetUrlNotify */
+typedef NPError	(* NP_LOADDS NPN_GetURLNotifyUPP)(NPP instance, const char* url, const char* window, void* notifyData);
+#define NewNPN_GetURLNotifyProc(FUNC)		\
+		((NPN_GetURLNotifyUPP) (FUNC))
+#define CallNPN_GetURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+
+/* NPN_PostUrlNotify */
+typedef NPError (* NP_LOADDS NPN_PostURLNotifyUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData);
+#define NewNPN_PostURLNotifyProc(FUNC)		\
+		((NPN_PostURLNotifyUPP) (FUNC))
+#define CallNPN_PostURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
+
+/* NPN_GetUrl */
+typedef NPError	(* NP_LOADDS NPN_GetURLUPP)(NPP instance, const char* url, const char* window);
+#define NewNPN_GetURLProc(FUNC)		\
+		((NPN_GetURLUPP) (FUNC))
+#define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3))
+
+/* NPN_PostUrl */
+typedef NPError (* NP_LOADDS NPN_PostURLUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file);
+#define NewNPN_PostURLProc(FUNC)		\
+		((NPN_PostURLUPP) (FUNC))
+#define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
+
+/* NPN_RequestRead */
+typedef NPError	(* NP_LOADDS NPN_RequestReadUPP)(NPStream* stream, NPByteRange* rangeList);
+#define NewNPN_RequestReadProc(FUNC)		\
+		((NPN_RequestReadUPP) (FUNC))
+#define CallNPN_RequestReadProc(FUNC, stream, range)		\
+		(*(FUNC))((stream), (range))
+
+/* NPN_NewStream */
+typedef NPError	(* NP_LOADDS NPN_NewStreamUPP)(NPP instance, NPMIMEType type, const char* window, NPStream** stream);
+#define NewNPN_NewStreamProc(FUNC)		\
+		((NPN_NewStreamUPP) (FUNC))
+#define CallNPN_NewStreamProc(FUNC, npp, type, window, stream)		\
+		(*(FUNC))((npp), (type), (window), (stream))
+
+/* NPN_Write */
+typedef int32 (* NP_LOADDS NPN_WriteUPP)(NPP instance, NPStream* stream, int32 len, void* buffer);
+#define NewNPN_WriteProc(FUNC)		\
+		((NPN_WriteUPP) (FUNC))
+#define CallNPN_WriteProc(FUNC, npp, stream, len, buffer)		\
+		(*(FUNC))((npp), (stream), (len), (buffer))
+
+/* NPN_DestroyStream */
+typedef NPError (* NP_LOADDS NPN_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason);
+#define NewNPN_DestroyStreamProc(FUNC)		\
+		((NPN_DestroyStreamUPP) (FUNC))
+#define CallNPN_DestroyStreamProc(FUNC, npp, stream, reason)		\
+		(*(FUNC))((npp), (stream), (reason))
+
+/* NPN_Status */
+typedef void (* NP_LOADDS NPN_StatusUPP)(NPP instance, const char* message);
+#define NewNPN_StatusProc(FUNC)		\
+		((NPN_StatusUPP) (FUNC))
+#define CallNPN_StatusProc(FUNC, npp, msg)		\
+		(*(FUNC))((npp), (msg))	
+
+/* NPN_UserAgent */
+typedef const char*	(* NP_LOADDS NPN_UserAgentUPP)(NPP instance);
+#define NewNPN_UserAgentProc(FUNC)              \
+                ((NPN_UserAgentUPP) (FUNC))
+#define CallNPN_UserAgentProc(FUNC, ARG1)               \
+                (*(FUNC))((ARG1))
+
+/* NPN_MemAlloc */
+typedef void* (* NP_LOADDS NPN_MemAllocUPP)(uint32 size);
+#define NewNPN_MemAllocProc(FUNC)		\
+		((NPN_MemAllocUPP) (FUNC))
+#define CallNPN_MemAllocProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))	
+
+/* NPN__MemFree */
+typedef void (* NP_LOADDS NPN_MemFreeUPP)(void* ptr);
+#define NewNPN_MemFreeProc(FUNC)		\
+		((NPN_MemFreeUPP) (FUNC))
+#define CallNPN_MemFreeProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))	
+
+/* NPN_MemFlush */
+typedef uint32 (* NP_LOADDS NPN_MemFlushUPP)(uint32 size);
+#define NewNPN_MemFlushProc(FUNC)		\
+		((NPN_MemFlushUPP) (FUNC))
+#define CallNPN_MemFlushProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))	
+
+/* NPN_ReloadPlugins */
+typedef void (* NP_LOADDS NPN_ReloadPluginsUPP)(NPBool reloadPages);
+#define NewNPN_ReloadPluginsProc(FUNC)		\
+		((NPN_ReloadPluginsUPP) (FUNC))
+#define CallNPN_ReloadPluginsProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))	
+
+/* NPN_GetJavaEnv */
+typedef JRIEnv* (* NP_LOADDS NPN_GetJavaEnvUPP)(void);
+#define NewNPN_GetJavaEnvProc(FUNC)		\
+		((NPN_GetJavaEnvUPP) (FUNC))
+#define CallNPN_GetJavaEnvProc(FUNC)		\
+		(*(FUNC))()	
+
+/* NPN_GetJavaPeer */
+typedef jref (* NP_LOADDS NPN_GetJavaPeerUPP)(NPP instance);
+#define NewNPN_GetJavaPeerProc(FUNC)		\
+		((NPN_GetJavaPeerUPP) (FUNC))
+#define CallNPN_GetJavaPeerProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))	
+
+/* NPN_InvalidateRect */
+typedef void (* NP_LOADDS NPN_InvalidateRectUPP)(NPP instance, NPRect *rect);
+#define NewNPN_InvalidateRectProc(FUNC)		\
+		((NPN_InvalidateRectUPP) (FUNC))
+#define CallNPN_InvalidateRectProc(FUNC, ARG1, ARG2)		\
+		(*(FUNC))((ARG1), (ARG2))	
+
+/* NPN_InvalidateRegion */
+typedef void (* NP_LOADDS NPN_InvalidateRegionUPP)(NPP instance, NPRegion region);
+#define NewNPN_InvalidateRegionProc(FUNC)		\
+		((NPN_InvalidateRegionUPP) (FUNC))
+#define CallNPN_InvalidateRegionProc(FUNC, ARG1, ARG2)		\
+		(*(FUNC))((ARG1), (ARG2))	
+
+/* NPN_ForceRedraw */
+typedef void (* NP_LOADDS NPN_ForceRedrawUPP)(NPP instance);
+#define NewNPN_ForceRedrawProc(FUNC)		\
+		((NPN_ForceRedrawUPP) (FUNC))
+#define CallNPN_ForceRedrawProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))	
+
+/* NPN_GetStringIdentifier */
+typedef NPIdentifier (* NP_LOADDS NPN_GetStringIdentifierUPP)(const NPUTF8* name);
+#define NewNPN_GetStringIdentifierProc(FUNC)		\
+		((NPN_GetStringIdentifierUPP) (FUNC))
+#define CallNPN_GetStringIdentifierProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))
+
+/* NPN_GetStringIdentifiers */
+typedef void (* NP_LOADDS NPN_GetStringIdentifiersUPP)(const NPUTF8** names,
+                                                 int32_t nameCount,
+                                                 NPIdentifier* identifiers);
+#define NewNPN_GetStringIdentifiersProc(FUNC)		\
+		((NPN_GetStringIdentifiersUPP) (FUNC))
+#define CallNPN_GetStringIdentifiersProc(FUNC, ARG1, ARG2, ARG3)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3))
+
+/* NPN_GetIntIdentifier */
+typedef NPIdentifier (* NP_LOADDS NPN_GetIntIdentifierUPP)(int32_t intid);
+#define NewNPN_GetIntIdentifierProc(FUNC)		\
+		((NPN_GetIntIdentifierUPP) (FUNC))
+#define CallNPN_GetIntIdentifierProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))
+
+/* NPN_IdentifierIsString */
+typedef bool (* NP_LOADDS NPN_IdentifierIsStringUPP)(NPIdentifier identifier);
+#define NewNPN_IdentifierIsStringProc(FUNC)		\
+		((NPN_IdentifierIsStringUPP) (FUNC))
+#define CallNPN_IdentifierIsStringProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))
+
+/* NPN_UTF8FromIdentifier */
+typedef NPUTF8* (* NP_LOADDS NPN_UTF8FromIdentifierUPP)(NPIdentifier identifier);
+#define NewNPN_UTF8FromIdentifierProc(FUNC)		\
+		((NPN_UTF8FromIdentifierUPP) (FUNC))
+#define CallNPN_UTF8FromIdentifierProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))
+
+/* NPN_IntFromIdentifier */
+typedef int32_t (* NP_LOADDS NPN_IntFromIdentifierUPP)(NPIdentifier identifier);
+#define NewNPN_IntFromIdentifierProc(FUNC)		\
+		((NPN_IntFromIdentifierUPP) (FUNC))
+#define CallNPN_IntFromIdentifierProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))
+
+/* NPN_CreateObject */
+typedef NPObject* (* NP_LOADDS NPN_CreateObjectUPP)(NPP npp, NPClass *aClass);
+#define NewNPN_CreateObjectProc(FUNC)		\
+		((NPN_CreateObjectUPP) (FUNC))
+#define CallNPN_CreateObjectProc(FUNC, ARG1, ARG2)		\
+		(*(FUNC))((ARG1), (ARG2))
+
+/* NPN_RetainObject */
+typedef NPObject* (* NP_LOADDS NPN_RetainObjectUPP)(NPObject *obj);
+#define NewNPN_RetainObjectProc(FUNC)		\
+		((NPN_RetainObjectUPP) (FUNC))
+#define CallNPN_RetainObjectProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))
+
+/* NPN_ReleaseObject */
+typedef void (* NP_LOADDS NPN_ReleaseObjectUPP)(NPObject *obj);
+#define NewNPN_ReleaseObjectProc(FUNC)		\
+		((NPN_ReleaseObjectUPP) (FUNC))
+#define CallNPN_ReleaseObjectProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))
+
+/* NPN_Invoke */
+typedef bool (* NP_LOADDS NPN_InvokeUPP)(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result);
+#define NewNPN_InvokeProc(FUNC)		\
+		((NPN_InvokeUPP) (FUNC))
+#define CallNPN_InvokeProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
+
+/* NPN_InvokeDefault */
+typedef bool (* NP_LOADDS NPN_InvokeDefaultUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+#define NewNPN_InvokeDefaultProc(FUNC)		\
+		((NPN_InvokeDefaultUPP) (FUNC))
+#define CallNPN_InvokeDefaultProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
+
+/* NPN_Evaluate */
+typedef bool (* NP_LOADDS NPN_EvaluateUPP)(NPP npp, NPObject *obj, NPString *script, NPVariant *result);
+#define NewNPN_EvaluateProc(FUNC)		\
+		((NPN_EvaluateUPP) (FUNC))
+#define CallNPN_EvaluateProc(FUNC, ARG1, ARG2, ARG3, ARG4)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+
+/* NPN_GetProperty */
+typedef bool (* NP_LOADDS NPN_GetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result);
+#define NewNPN_GetPropertyProc(FUNC)		\
+		((NPN_GetPropertyUPP) (FUNC))
+#define CallNPN_GetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+
+/* NPN_SetProperty */
+typedef bool (* NP_LOADDS NPN_SetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value);
+#define NewNPN_SetPropertyProc(FUNC)		\
+		((NPN_SetPropertyUPP) (FUNC))
+#define CallNPN_SetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+
+/* NPN_RemoveProperty */
+typedef bool (* NP_LOADDS NPN_RemovePropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
+#define NewNPN_RemovePropertyProc(FUNC)		\
+		((NPN_RemovePropertyUPP) (FUNC))
+#define CallNPN_RemovePropertyProc(FUNC, ARG1, ARG2, ARG3)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3))
+
+/* NPN_HasProperty */
+typedef bool (* NP_LOADDS NPN_HasPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
+#define NewNPN_HasPropertyProc(FUNC)		\
+		((NPN_HasPropertyUPP) (FUNC))
+#define CallNPN_HasPropertyProc(FUNC, ARG1, ARG2, ARG3)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3))
+
+/* NPN_HasMethod */
+typedef bool (* NP_LOADDS NPN_HasMethodUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
+#define NewNPN_HasMethodProc(FUNC)		\
+		((NPN_HasMethodUPP) (FUNC))
+#define CallNPN_HasMethodProc(FUNC, ARG1, ARG2, ARG3)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3))
+
+/* NPN_ReleaseVariantValue */
+typedef void (* NP_LOADDS NPN_ReleaseVariantValueUPP)(NPVariant *variant);
+#define NewNPN_ReleaseVariantValueProc(FUNC)		\
+		((NPN_ReleaseVariantValueUPP) (FUNC))
+#define CallNPN_ReleaseVariantValueProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))
+
+/* NPN_SetException */
+typedef void (* NP_LOADDS NPN_SetExceptionUPP)(NPObject *obj, const NPUTF8 *message);
+#define NewNPN_SetExceptionProc(FUNC)		\
+		((NPN_SetExceptionUPP) (FUNC))
+#define CallNPN_SetExceptionProc(FUNC, ARG1, ARG2)		\
+		(*(FUNC))((ARG1), (ARG2))	
+
+/* NPN_PushPopupsEnabledStateUPP */
+typedef bool (* NP_LOADDS NPN_PushPopupsEnabledStateUPP)(NPP npp, NPBool enabled);
+#define NewNPN_PushPopupsEnabledStateProc(FUNC)		\
+		((NPN_PushPopupsEnabledStateUPP) (FUNC))
+#define CallNPN_PushPopupsEnabledStateProc(FUNC, ARG1, ARG2)		\
+		(*(FUNC))((ARG1), (ARG2))
+
+/* NPN_PopPopupsEnabledState */
+typedef bool (* NP_LOADDS NPN_PopPopupsEnabledStateUPP)(NPP npp);
+#define NewNPN_PopPopupsEnabledStateProc(FUNC)		\
+		((NPN_PopPopupsEnabledStateUPP) (FUNC))
+#define CallNPN_PopPopupsEnabledStateProc(FUNC, ARG1)		\
+		(*(FUNC))((ARG1))
+
+/* NPN_Enumerate */
+typedef bool (* NP_LOADDS NPN_EnumerateUPP)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count);
+#define NewNPN_EnumerateProc(FUNC)		\
+		((NPN_EnumerateUPP) (FUNC))
+#define CallNPN_EnumerateProc(FUNC, ARG1, ARG2, ARG3, ARG4)		\
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
+
+/* NPN_PluginThreadAsyncCall */
+typedef void (* NP_LOADDS NPN_PluginThreadAsyncCallUPP)(NPP instance, void (*func)(void *), void *userData);
+#define NewNPN_PluginThreadAsyncCallProc(FUNC) \
+		((NPN_PluginThreadAsyncCallUPP) (FUNC))
+#define CallNPN_PluginThreadAsyncCallProc(FUNC, ARG1, ARG2, ARG3) \
+		(*(FUNC))((ARG1), (ARG2), (ARG3))
+
+/* NPN_Construct */
+typedef bool (* NP_LOADDS NPN_ConstructUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+#define NewNPN_ConstructProc(FUNC)		\
+		((NPN_ConstructUPP) (FUNC))
+#define CallNPN_ConstructProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5)      \
+		(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
+
+
+
+/******************************************************************************************
+ * The actual plugin function table definitions
+ *******************************************************************************************/
+
+typedef struct _NPPluginFuncs {
+    uint16 size;
+    uint16 version;
+    NPP_NewUPP newp;
+    NPP_DestroyUPP destroy;
+    NPP_SetWindowUPP setwindow;
+    NPP_NewStreamUPP newstream;
+    NPP_DestroyStreamUPP destroystream;
+    NPP_StreamAsFileUPP asfile;
+    NPP_WriteReadyUPP writeready;
+    NPP_WriteUPP write;
+    NPP_PrintUPP print;
+    NPP_HandleEventUPP event;
+    NPP_URLNotifyUPP urlnotify;
+    JRIGlobalRef javaClass;
+    NPP_GetValueUPP getvalue;
+    NPP_SetValueUPP setvalue;
+} NPPluginFuncs;
+
+typedef struct _NPNetscapeFuncs {
+    uint16 size;
+    uint16 version;
+    NPN_GetURLUPP geturl;
+    NPN_PostURLUPP posturl;
+    NPN_RequestReadUPP requestread;
+    NPN_NewStreamUPP newstream;
+    NPN_WriteUPP write;
+    NPN_DestroyStreamUPP destroystream;
+    NPN_StatusUPP status;
+    NPN_UserAgentUPP uagent;
+    NPN_MemAllocUPP memalloc;
+    NPN_MemFreeUPP memfree;
+    NPN_MemFlushUPP memflush;
+    NPN_ReloadPluginsUPP reloadplugins;
+    NPN_GetJavaEnvUPP getJavaEnv;
+    NPN_GetJavaPeerUPP getJavaPeer;
+    NPN_GetURLNotifyUPP geturlnotify;
+    NPN_PostURLNotifyUPP posturlnotify;
+    NPN_GetValueUPP getvalue;
+    NPN_SetValueUPP setvalue;
+    NPN_InvalidateRectUPP invalidaterect;
+    NPN_InvalidateRegionUPP invalidateregion;
+    NPN_ForceRedrawUPP forceredraw;
+    NPN_GetStringIdentifierUPP getstringidentifier;
+    NPN_GetStringIdentifiersUPP getstringidentifiers;
+    NPN_GetIntIdentifierUPP getintidentifier;
+    NPN_IdentifierIsStringUPP identifierisstring;
+    NPN_UTF8FromIdentifierUPP utf8fromidentifier;
+    NPN_IntFromIdentifierUPP intfromidentifier;
+    NPN_CreateObjectUPP createobject;
+    NPN_RetainObjectUPP retainobject;
+    NPN_ReleaseObjectUPP releaseobject;
+    NPN_InvokeUPP invoke;
+    NPN_InvokeDefaultUPP invokeDefault;
+    NPN_EvaluateUPP evaluate;
+    NPN_GetPropertyUPP getproperty;
+    NPN_SetPropertyUPP setproperty;
+    NPN_RemovePropertyUPP removeproperty;
+    NPN_HasPropertyUPP hasproperty;
+    NPN_HasMethodUPP hasmethod;
+    NPN_ReleaseVariantValueUPP releasevariantvalue;
+    NPN_SetExceptionUPP setexception;
+    NPN_PushPopupsEnabledStateUPP pushpopupsenabledstate;
+    NPN_PopPopupsEnabledStateUPP poppopupsenabledstate;
+    NPN_EnumerateUPP enumerate;
+    NPN_PluginThreadAsyncCallUPP pluginthreadasynccall;
+    NPN_ConstructUPP construct;
+} NPNetscapeFuncs;
+
+
+#ifdef XP_MACOSX
+/******************************************************************************************
+ * Mac platform-specific plugin glue stuff
+ *******************************************************************************************/
+
+/*
+ * Main entry point of the plugin.
+ * This routine will be called when the plugin is loaded. The function
+ * tables are passed in and the plugin fills in the NPPluginFuncs table
+ * and NPPShutdownUPP for Netscape's use.
+ */
+typedef NPError (* NP_LOADDS NPP_MainEntryUPP)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownUPP*);
+#define NewNPP_MainEntryProc(FUNC)		\
+		((NPP_MainEntryUPP) (FUNC))
+#define CallNPP_MainEntryProc(FUNC,  netscapeFunc, pluginFunc, shutdownUPP)		\
+		(*(FUNC))((netscapeFunc), (pluginFunc), (shutdownUPP))
+
+/*
+ * Mac OS X version(s) of NP_GetMIMEDescription(const char *)
+ * These can be called to retreive MIME information from the plugin dynamically
+ *
+ * Note: For compatibility with Quicktime, BPSupportedMIMEtypes is another way
+ *       to get mime info from the plugin only on OSX and may not be supported 
+ *       in furture version -- use NP_GetMIMEDescription instead
+ */
+
+enum
+{
+ kBPSupportedMIMETypesStructVers_1    = 1
+};
+
+typedef struct _BPSupportedMIMETypes
+{
+ SInt32    structVersion;      /* struct version */
+ Handle    typeStrings;        /* STR# formated handle, allocated by plug-in */
+ Handle    infoStrings;        /* STR# formated handle, allocated by plug-in */
+} BPSupportedMIMETypes;
+OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags);
+
+ /* NP_GetMIMEDescription */
+#define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription"
+typedef const char* (* NP_LOADDS NP_GetMIMEDescriptionUPP)();
+#define NewNP_GetMIMEDescEntryProc(FUNC)		\
+		((NP_GetMIMEDescriptionUPP) (FUNC))
+#define CallNP_GetMIMEDescEntryProc(FUNC)		\
+		(*(FUNC))()
+
+/* BP_GetSupportedMIMETypes */
+typedef OSErr (* NP_LOADDS BP_GetSupportedMIMETypesUPP)(BPSupportedMIMETypes*, UInt32);
+#define NewBP_GetSupportedMIMETypesEntryProc(FUNC)		\
+		((BP_GetSupportedMIMETypesUPP) (FUNC))
+#define CallBP_GetMIMEDescEntryProc(FUNC,  mimeInfo, flags)		\
+		(*(FUNC))((mimeInfo), (flags))
+
+#endif /* XP_MACOSX */
+
+#if defined(_WINDOWS)
+#define OSCALL WINAPI
+#else
+#if defined(__OS2__)
+#define OSCALL _System
+#else
+#define OSCALL
+#endif
+#endif
+
+#if defined(XP_UNIX)
+/* GCC 3.3 and later support the visibility attribute. */
+#if defined(__GNUC__) && \
+    ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
+#define NP_VISIBILITY_DEFAULT __attribute__((visibility("default")))
+#else
+#define NP_VISIBILITY_DEFAULT
+#endif
+
+#define NP_EXPORT(__type) NP_VISIBILITY_DEFAULT __type
+#endif
+
+#if defined( _WINDOWS ) || defined (__OS2__)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* plugin meta member functions */
+#if defined(__OS2__)
+
+typedef struct _NPPluginData {   /* Alternate OS2 Plugin interface */
+    char *pMimeTypes;
+    char *pFileExtents;
+    char *pFileOpenTemplate;
+    char *pProductName;
+    char *pProductDescription;
+    unsigned long dwProductVersionMS;
+    unsigned long dwProductVersionLS;
+} NPPluginData;
+
+NPError OSCALL NP_GetPluginData(NPPluginData * pPluginData);
+
+#endif
+
+NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs);
+
+NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs);
+
+NPError OSCALL NP_Shutdown();
+
+char*	NP_GetMIMEDescription();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _WINDOWS || __OS2__ */
+
+#if defined(__OS2__)
+#pragma pack()
+#endif
+
+#ifdef XP_UNIX
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* plugin meta member functions */
+
+NP_EXPORT(char*)   NP_GetMIMEDescription(void);
+NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs*, NPPluginFuncs*);
+NP_EXPORT(NPError) NP_Shutdown(void);
+NP_EXPORT(NPError) NP_GetValue(void *future, NPPVariable aVariable, void *aValue);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XP_UNIX */
+
+#endif /* _NPUPP_H_ */

Modified: trunk/browser-plugin/test-glow-button.c
==============================================================================
--- trunk/browser-plugin/test-glow-button.c	(original)
+++ trunk/browser-plugin/test-glow-button.c	Fri May 30 17:35:08 2008
@@ -2,7 +2,7 @@
 #include <gtk/gtk.h>
 #include "totem-glow-button.h"
 
-#if 1
+#if 0
 static gboolean
 idle_cb (gpointer data)
 {

Modified: trunk/browser-plugin/totem-glow-button.c
==============================================================================
--- trunk/browser-plugin/totem-glow-button.c	(original)
+++ trunk/browser-plugin/totem-glow-button.c	Fri May 30 17:35:08 2008
@@ -2,9 +2,9 @@
  * (C) Copyright 2007 Bastien Nocera <hadess hadess net>
  *
  * Glow code from libwnck/libwnck/tasklist.c:
- * Copyright (C) 2001 Havoc Pennington
- * Copyright (C) 2003 Kim Woelders
- * Copyright (C) 2003 Red Hat, Inc.
+ * Copyright  2001 Havoc Pennington
+ * Copyright  2003 Kim Woelders
+ * Copyright  2003 Red Hat, Inc.
  *
  *
  * This library is free software; you can redistribute it and/or

Modified: trunk/browser-plugin/totem-glow-button.h
==============================================================================
--- trunk/browser-plugin/totem-glow-button.h	(original)
+++ trunk/browser-plugin/totem-glow-button.h	Fri May 30 17:35:08 2008
@@ -2,9 +2,9 @@
  * (C) Copyright 2007 Bastien Nocera <hadess hadess net>
  *
  * Glow code from libwnck/libwnck/tasklist.c:
- * Copyright (C) 2001 Havoc Pennington
- * Copyright (C) 2003 Kim Woelders
- * Copyright (C) 2003 Red Hat, Inc.
+ * Copyright  2001 Havoc Pennington
+ * Copyright  2003 Kim Woelders
+ * Copyright  2003 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public

Modified: trunk/browser-plugin/totem-plugin-viewer.c
==============================================================================
--- trunk/browser-plugin/totem-plugin-viewer.c	(original)
+++ trunk/browser-plugin/totem-plugin-viewer.c	Fri May 30 17:35:08 2008
@@ -52,7 +52,7 @@
 
 #include "totem-plugin-viewer-constants.h"
 #include "totem-plugin-viewer-options.h"
-#include "totempluginviewer-marshal.h"
+#include "marshal.h"
 
 GtkWidget *totem_statusbar_create (void);
 GtkWidget *totem_volume_create (void);
@@ -665,6 +665,48 @@
 	return result;
 }
 
+static char *
+resolve_uri (const char *base_uri,
+             const char *relative_uri)
+{
+  char *uri, *scheme;
+  GFile *base_gfile, *base_parent_gfile, *resolved_gfile;
+
+  if (!relative_uri)
+    return g_strdup (base_uri);
+
+  if (!base_uri)
+    return g_strdup (relative_uri);
+
+  /* If |relative_uri| has a scheme, it's a full URI, just return it */
+  scheme = g_uri_parse_scheme (relative_uri);
+  if (scheme) {
+    g_free (scheme);
+    return g_strdup (relative_uri);
+  }
+
+  base_gfile = g_file_new_for_uri (base_uri);
+  base_parent_gfile = g_file_get_parent (base_gfile);
+  if (!base_parent_gfile) {
+    g_print ("Base URI %s has no parent!\n", base_uri);
+    g_object_unref (base_gfile);
+    return NULL;
+  }
+  g_object_unref (base_gfile);
+
+  resolved_gfile = g_file_resolve_relative_path (base_parent_gfile, relative_uri);
+  g_object_unref (base_parent_gfile);
+  if (!resolved_gfile) {
+    g_warning ("Failed to resolve relative URI '%s' against base '%s'\n", relative_uri, base_uri);
+    return NULL;
+  }
+
+  uri = g_file_get_uri (resolved_gfile);
+  g_object_unref (resolved_gfile);
+
+  return uri;
+}
+
 static void
 totem_embedded_set_uri (TotemEmbedded *emb,
 		        const char *uri,
@@ -677,11 +719,13 @@
 	old_base = emb->base_uri;
 	old_href = emb->href_uri;
 
-	emb->current_uri = g_strdup (uri);
 	emb->base_uri = g_strdup (base_uri);
+	emb->current_uri = resolve_uri (base_uri, uri);
 	emb->is_browser_stream = (is_browser_stream != FALSE);
 	emb->href_uri = NULL;
 
+        g_print ("totem_embedded_set_uri uri %s base %s => resolved %s\n", uri, base_uri, emb->current_uri);
+
 	g_free (old_uri);
 	g_free (old_base);
 	g_free (old_href);
@@ -1086,9 +1130,10 @@
 	license = totem_interface_get_license ();
 
 	emb->about = g_object_new (GTK_TYPE_ABOUT_DIALOG,
-				   "name", _("Totem Browser Plugin"),
+				   "program-name", _("Totem Browser Plugin"),
 				   "version", VERSION,
-				   "copyright", _("Copyright \xc2\xa9 2002-2007 Bastien Nocera"),
+				   "copyright", "Copyright  2002-2007 Bastien Nocera\n"
+                                                "Copyright  2006, 2007, 2008 Christian Persch",
 				   "comments", description,
 				   "authors", authors,
 				   "translator-credits", _("translator-credits"),

Modified: trunk/browser-plugin/totemBasicPlugin.cpp
==============================================================================
--- trunk/browser-plugin/totemBasicPlugin.cpp	(original)
+++ trunk/browser-plugin/totemBasicPlugin.cpp	Fri May 30 17:35:08 2008
@@ -1,8 +1,8 @@
 /* Totem Basic Plugin
  *
- * Copyright (C) 2004 Bastien Nocera <hadess hadess net>
- * Copyright (C) 2002 David A. Schleef <ds schleef org>
- * Copyright (C) 2006 Christian Persch
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -18,123 +18,62 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id$
  */
 
-#include <mozilla-config.h>
-#include "config.h"
+#include <config.h>
 
 #include <glib.h>
 
-#include <nsISupportsImpl.h>
-#include <nsMemory.h>
-#include <nsXPCOM.h>
-#include <nsIProgrammingLanguage.h>
-
-#define GNOME_ENABLE_DEBUG 1
-/* define GNOME_ENABLE_DEBUG for more debug spew */
-#include "debug.h"
-
-#include "totemClassInfo.h"
-
+#include "totemPlugin.h"
 #include "totemBasicPlugin.h"
 
-/* 11ef8fce-9eb4-494e-804e-d56eae788625 */
-static const nsCID kClassID = 
-  { 0x11ef8fce, 0x9eb4, 0x494e,
-    { 0x80, 0x4e, 0xd5, 0x6e, 0xae, 0x78, 0x86, 0x25 } };
-
-static const char kClassDescription[] = "totemBasicPlugin";
-static const char kPluginDescription[] = "Totem Web Browser Plugin " VERSION;
-
-static const totemPluginMimeEntry kMimeTypes[] = {
-	{ "application/x-ogg","ogg",NULL },
-	{ "application/ogg", "ogg", NULL },
-	{ "audio/ogg", "oga", NULL },
-	{ "audio/x-ogg", "ogg", NULL },
-	{ "video/ogg", "ogv", NULL },
-	{ "video/x-ogg", "ogg", NULL },
-	{ "application/annodex", "anx", NULL },
-	{ "audio/annodex", "axa", NULL },
-	{ "video/annodex", "axv", NULL },
-	{ "video/mpeg", "mpg, mpeg, mpe", NULL },
-	{ "audio/wav", "wav", NULL },
-	{ "audio/x-wav", "wav", NULL },
-	{ "audio/mpeg", "mp3", NULL },
-	{ "application/x-nsv-vp3-mp3", "nsv", "video/x-nsv" },
-	{ "video/flv", "flv", "application/x-flash-video" },
-	{ "application/x-totem-plugin", "", "application/octet-stream" },
+static const char *methodNames[] = {
+  "Play",
+  "Rewind",
+  "Stop"
 };
 
-totemScriptablePlugin::totemScriptablePlugin (totemPlugin *aPlugin)
-  : mPlugin(aPlugin)
-{
-  D ("%s ctor [%p]", kClassDescription, (void*) this);
-}
-
-totemScriptablePlugin::~totemScriptablePlugin ()
+totemBasicPlayer::totemBasicPlayer (NPP aNPP)
+  : totemNPObject (aNPP)
 {
-  D ("%s dtor [%p]", kClassDescription, (void*) this);
+  TOTEM_LOG_CTOR ();
 }
 
-/* static */ char *
-totemScriptablePlugin::PluginDescription ()
+totemBasicPlayer::~totemBasicPlayer ()
 {
-  return (char*) kPluginDescription;
+  TOTEM_LOG_DTOR ();
 }
 
-/* static */ char *
-totemScriptablePlugin::PluginLongDescription ()
+bool
+totemBasicPlayer::InvokeByIndex (int aIndex,
+                                 const NPVariant *argv,
+                                 uint32_t argc,
+                                 NPVariant *_result)
 {
-  return (char*) totem_plugin_get_long_description();
-}
-
-/* static */ void
-totemScriptablePlugin::PluginMimeTypes (const totemPluginMimeEntry **_entries,
-					PRUint32 *_count)
-{
-  *_entries = kMimeTypes;
-  *_count = G_N_ELEMENTS (kMimeTypes);
-}
+  TOTEM_LOG_INVOKE (aIndex, totemBasicPlayer);
 
-/* Interface implementations */
+  VOID_TO_NPVARIANT (*_result);
 
-NS_IMPL_ISUPPORTS2 (totemScriptablePlugin,
-		    totemIBasicPlayer,
-		    nsIClassInfo)
+  switch (Methods (aIndex)) {
+    case ePlay:
+      Plugin()->Command (TOTEM_COMMAND_PLAY);
+      return VoidVariant (_result);
 
-/* nsIClassInfo */
+    case eRewind:
+      Plugin()->Command (TOTEM_COMMAND_PAUSE);
+      return VoidVariant (_result);
 
-TOTEM_CLASSINFO_BEGIN (totemScriptablePlugin,
-		       1,
-		       kClassID,
-		       kClassDescription)
-  TOTEM_CLASSINFO_ENTRY (0, totemIBasicPlayer)
-TOTEM_CLASSINFO_END
+    case eStop:
+      Plugin()->Command (TOTEM_COMMAND_STOP);
+      return VoidVariant (_result);
+  }
 
-/* totemIBasicPlayer */
-
-NS_IMETHODIMP
-totemScriptablePlugin::Play ()
-{
-  NS_ENSURE_STATE (IsValid ());
-
-  return mPlugin->DoCommand (TOTEM_COMMAND_PLAY);
+  return false;
 }
 
-NS_IMETHODIMP
-totemScriptablePlugin::Rewind ()
-{
-  NS_ENSURE_STATE (IsValid ());
+/* totemBasicPlayerNPClass */
 
-  return mPlugin->DoCommand (TOTEM_COMMAND_PAUSE);
-}
-
-NS_IMETHODIMP
-totemScriptablePlugin::Stop ()
-{
-  NS_ENSURE_STATE (IsValid ());
-
-  return mPlugin->DoCommand (TOTEM_COMMAND_STOP);
-}
+TOTEM_IMPLEMENT_NPCLASS (totemBasicPlayer,
+                         NULL, 0,
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL)

Modified: trunk/browser-plugin/totemBasicPlugin.h
==============================================================================
--- trunk/browser-plugin/totemBasicPlugin.h	(original)
+++ trunk/browser-plugin/totemBasicPlugin.h	Fri May 30 17:35:08 2008
@@ -1,7 +1,8 @@
 /* Totem Basic Plugin
  *
- * Copyright (C) 2004 Bastien Nocera <hadess hadess net>
- * Copyright (C) 2002 David A. Schleef <ds schleef org>
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -17,38 +18,31 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id$
  */
 
 #ifndef __BASIC_PLUGIN_H__
 #define __BASIC_PLUGIN_H__
 
-#include <nsIClassInfo.h>
-
-#include "totemIBasicPlayer.h"
-#include "totemPlugin.h"
+#include "totemNPClass.h"
+#include "totemNPObject.h"
 
-class totemScriptablePlugin : public totemIBasicPlayer,
-			      public nsIClassInfo
+class totemBasicPlayer : public totemNPObject
 {
   public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_TOTEMIBASICPLAYER
-    NS_DECL_NSICLASSINFO
-
-    totemScriptablePlugin (totemPlugin *aPlugin);
-
-    PRBool IsValid () { return mPlugin != nsnull; }
-    void SetPlugin (totemPlugin *aPlugin) { mPlugin = aPlugin; }
-
-    static char *PluginDescription ();
-    static char *PluginLongDescription();
-    static void PluginMimeTypes (const totemPluginMimeEntry **, PRUint32 *);
+    totemBasicPlayer (NPP);
+    virtual ~totemBasicPlayer ();
+
   private:
-    ~totemScriptablePlugin ();
+  
+    enum Methods {
+      ePlay,
+      eRewind,
+      eStop
+    };
 
-    totemPlugin *mPlugin;
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
 };
 
+TOTEM_DEFINE_NPCLASS (totemBasicPlayer);
+
 #endif /* __BASIC_PLUGIN_H__ */

Added: trunk/browser-plugin/totemComplexPlayer.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemComplexPlayer.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,310 @@
+/* Totem Complex plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "npupp.h"
+
+#include "totemPlugin.h"
+#include "totemComplexPlayer.h"
+
+
+static const char *methodNames[] = {
+  "CanPause",
+  "CanPlay",
+  "CanStop",
+  "DoGotoURL",
+  "DoNextEntry",
+  "DoPause",
+  "DoPlay",
+  "DoPrevEntry",
+  "DoStop",
+  "GetAuthor",
+  "GetAutoGoToURL",
+  "GetAutoStart",
+  "GetBackgroundColor",
+  "GetBandwidthAverage",
+  "GetBandwidthCurrent",
+  "GetBufferingTimeElapsed",
+  "GetBufferingTimeRemaining",
+  "GetCanSeek",
+  "GetCenter",
+  "GetClipHeight",
+  "GetClipWidth",
+  "GetConnectionBandwidth",
+  "GetConsole",
+  "GetConsoleEvents",
+  "GetControls",
+  "GetCopyright",
+  "GetCurrentEntry",
+  "GetDoubleSize",
+  "GetDRMInfo",
+  "GetEnableContextMenu",
+  "GetEnableDoubleSize",
+  "GetEnableFullScreen",
+  "GetEnableOriginalSize",
+  "GetEntryAbstract",
+  "GetEntryAuthor",
+  "GetEntryCopyright",
+  "GetEntryTitle",
+  "GetFullScreen",
+  "GetImageStatus",
+  "GetIsPlus",
+  "GetLastErrorMoreInfoURL",
+  "GetLastErrorRMACode",
+  "GetLastErrorSeverity",
+  "GetLastErrorUserCode",
+  "GetLastErrorUserString",
+  "GetLastMessage",
+  "GetLastStatus",
+  "GetLength",
+  "GetLiveState",
+  "GetLoop",
+  "GetMaintainAspect",
+  "GetMute",
+  "GetNoLogo",
+  "GetNumEntries",
+  "GetNumLoop",
+  "GetNumSources",
+  "GetOriginalSize",
+  "GetPacketsEarly",
+  "GetPacketsLate",
+  "GetPacketsMissing",
+  "GetPacketsOutOfOrder",
+  "GetPacketsReceived",
+  "GetPacketsTotal",
+  "GetPlayState",
+  "GetPosition",
+  "GetPreferedLanguageID",
+  "GetPreferedLanguageString",
+  "GetPreferredLanguageID",
+  "GetPreferredLanguageString",
+  "GetPreFetch",
+  "GetShowAbout",
+  "GetShowPreferences",
+  "GetShowStatistics",
+  "GetShuffle",
+  "GetSource",
+  "GetSourceTransport",
+  "GetStereoState",
+  "GetTitle",
+  "GetUserCountryID",
+  "GetVersionInfo",
+  "GetVolume",
+  "GetWantErrors",
+  "GetWantKeyboardEvents",
+  "GetWantMouseEvents",
+  "HasNextEntry",
+  "HasPrevEntry",
+  "SetAuthor",
+  "SetAutoGoToURL",
+  "SetAutoStart",
+  "SetBackgroundColor",
+  "SetCanSeek",
+  "SetCenter",
+  "SetConsole",
+  "SetConsoleEvents",
+  "SetControls",
+  "SetCopyright",
+  "SetDoubleSize",
+  "SetEnableContextMenu",
+  "SetEnableDoubleSize",
+  "SetEnableFullScreen",
+  "SetEnableOriginalSize",
+  "SetFullScreen",
+  "SetImageStatus",
+  "SetLoop",
+  "SetMaintainAspect",
+  "SetMute",
+  "SetNoLogo",
+  "SetNumLoop",
+  "SetOriginalSize",
+  "SetPosition",
+  "SetPreFetch",
+  "SetShowAbout",
+  "SetShowPreferences",
+  "SetShowStatistics",
+  "SetShuffle",
+  "SetSource",
+  "SetTitle",
+  "SetVolume",
+  "SetWantErrors",
+  "SetWantKeyboardEvents",
+  "SetWantMouseEvents"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemComplexPlayer,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemComplexPlayer::totemComplexPlayer (NPP aNPP)
+  : totemNPObject (aNPP)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemComplexPlayer::~totemComplexPlayer ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemComplexPlayer::InvokeByIndex (int aIndex,
+                               const NPVariant *argv,
+                               uint32_t argc,
+                               NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemComplexPlayer);
+
+  switch (Methods (aIndex)) {
+    case eCanPause:
+    case eCanPlay:
+    case eCanStop:
+    case eDoGotoURL:
+    case eDoNextEntry:
+    case eDoPause:
+    case eDoPlay:
+    case eDoPrevEntry:
+    case eDoStop:
+    case eGetAuthor:
+    case eGetAutoGoToURL:
+    case eGetAutoStart:
+    case eGetBackgroundColor:
+    case eGetBandwidthAverage:
+    case eGetBandwidthCurrent:
+    case eGetBufferingTimeElapsed:
+    case eGetBufferingTimeRemaining:
+    case eGetCanSeek:
+    case eGetCenter:
+    case eGetClipHeight:
+    case eGetClipWidth:
+    case eGetConnectionBandwidth:
+    case eGetConsole:
+    case eGetConsoleEvents:
+    case eGetControls:
+    case eGetCopyright:
+    case eGetCurrentEntry:
+    case eGetDoubleSize:
+    case eGetDRMInfo:
+    case eGetEnableContextMenu:
+    case eGetEnableDoubleSize:
+    case eGetEnableFullScreen:
+    case eGetEnableOriginalSize:
+    case eGetEntryAbstract:
+    case eGetEntryAuthor:
+    case eGetEntryCopyright:
+    case eGetEntryTitle:
+    case eGetFullScreen:
+    case eGetImageStatus:
+    case eGetIsPlus:
+    case eGetLastErrorMoreInfoURL:
+    case eGetLastErrorRMACode:
+    case eGetLastErrorSeverity:
+    case eGetLastErrorUserCode:
+    case eGetLastErrorUserString:
+    case eGetLastMessage:
+    case eGetLastStatus:
+    case eGetLength:
+    case eGetLiveState:
+    case eGetLoop:
+    case eGetMaintainAspect:
+    case eGetMute:
+    case eGetNoLogo:
+    case eGetNumEntries:
+    case eGetNumLoop:
+    case eGetNumSources:
+    case eGetOriginalSize:
+    case eGetPacketsEarly:
+    case eGetPacketsLate:
+    case eGetPacketsMissing:
+    case eGetPacketsOutOfOrder:
+    case eGetPacketsReceived:
+    case eGetPacketsTotal:
+    case eGetPlayState:
+    case eGetPosition:
+    case eGetPreferedLanguageID:
+    case eGetPreferedLanguageString:
+    case eGetPreferredLanguageID:
+    case eGetPreferredLanguageString:
+    case eGetPreFetch:
+    case eGetShowAbout:
+    case eGetShowPreferences:
+    case eGetShowStatistics:
+    case eGetShuffle:
+    case eGetSource:
+    case eGetSourceTransport:
+    case eGetStereoState:
+    case eGetTitle:
+    case eGetUserCountryID:
+    case eGetVersionInfo:
+    case eGetVolume:
+    case eGetWantErrors:
+    case eGetWantKeyboardEvents:
+    case eGetWantMouseEvents:
+    case eHasNextEntry:
+    case eHasPrevEntry:
+    case eSetAuthor:
+    case eSetAutoGoToURL:
+    case eSetAutoStart:
+    case eSetBackgroundColor:
+    case eSetCanSeek:
+    case eSetCenter:
+    case eSetConsole:
+    case eSetConsoleEvents:
+    case eSetControls:
+    case eSetCopyright:
+    case eSetDoubleSize:
+    case eSetEnableContextMenu:
+    case eSetEnableDoubleSize:
+    case eSetEnableFullScreen:
+    case eSetEnableOriginalSize:
+    case eSetFullScreen:
+    case eSetImageStatus:
+    case eSetLoop:
+    case eSetMaintainAspect:
+    case eSetMute:
+    case eSetNoLogo:
+    case eSetNumLoop:
+    case eSetOriginalSize:
+    case eSetPosition:
+    case eSetPreFetch:
+    case eSetShowAbout:
+    case eSetShowPreferences:
+    case eSetShowStatistics:
+    case eSetShuffle:
+    case eSetSource:
+    case eSetTitle:
+    case eSetVolume:
+    case eSetWantErrors:
+    case eSetWantKeyboardEvents:
+    case eSetWantMouseEvents:
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemComplexPlayer);
+      return BoolVariant (_result, true);
+  }
+
+  return false;
+}

Added: trunk/browser-plugin/totemComplexPlayer.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemComplexPlayer.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,165 @@
+/* Totem Complex plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#ifndef __TOTEM_COMPLEX_PLAYER_H__
+#define __TOTEM_COMPLEX_PLAYER_H__
+
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+
+class totemComplexPlayer : public totemNPObject
+{
+  public:
+    totemComplexPlayer (NPP);
+    virtual ~totemComplexPlayer ();
+
+  private:
+    enum Methods {
+      eCanPause,
+      eCanPlay,
+      eCanStop,
+      eDoGotoURL,
+      eDoNextEntry,
+      eDoPause,
+      eDoPlay,
+      eDoPrevEntry,
+      eDoStop,
+      eGetAuthor,
+      eGetAutoGoToURL,
+      eGetAutoStart,
+      eGetBackgroundColor,
+      eGetBandwidthAverage,
+      eGetBandwidthCurrent,
+      eGetBufferingTimeElapsed,
+      eGetBufferingTimeRemaining,
+      eGetCanSeek,
+      eGetCenter,
+      eGetClipHeight,
+      eGetClipWidth,
+      eGetConnectionBandwidth,
+      eGetConsole,
+      eGetConsoleEvents,
+      eGetControls,
+      eGetCopyright,
+      eGetCurrentEntry,
+      eGetDoubleSize,
+      eGetDRMInfo,
+      eGetEnableContextMenu,
+      eGetEnableDoubleSize,
+      eGetEnableFullScreen,
+      eGetEnableOriginalSize,
+      eGetEntryAbstract,
+      eGetEntryAuthor,
+      eGetEntryCopyright,
+      eGetEntryTitle,
+      eGetFullScreen,
+      eGetImageStatus,
+      eGetIsPlus,
+      eGetLastErrorMoreInfoURL,
+      eGetLastErrorRMACode,
+      eGetLastErrorSeverity,
+      eGetLastErrorUserCode,
+      eGetLastErrorUserString,
+      eGetLastMessage,
+      eGetLastStatus,
+      eGetLength,
+      eGetLiveState,
+      eGetLoop,
+      eGetMaintainAspect,
+      eGetMute,
+      eGetNoLogo,
+      eGetNumEntries,
+      eGetNumLoop,
+      eGetNumSources,
+      eGetOriginalSize,
+      eGetPacketsEarly,
+      eGetPacketsLate,
+      eGetPacketsMissing,
+      eGetPacketsOutOfOrder,
+      eGetPacketsReceived,
+      eGetPacketsTotal,
+      eGetPlayState,
+      eGetPosition,
+      eGetPreferedLanguageID,
+      eGetPreferedLanguageString,
+      eGetPreferredLanguageID,
+      eGetPreferredLanguageString,
+      eGetPreFetch,
+      eGetShowAbout,
+      eGetShowPreferences,
+      eGetShowStatistics,
+      eGetShuffle,
+      eGetSource,
+      eGetSourceTransport,
+      eGetStereoState,
+      eGetTitle,
+      eGetUserCountryID,
+      eGetVersionInfo,
+      eGetVolume,
+      eGetWantErrors,
+      eGetWantKeyboardEvents,
+      eGetWantMouseEvents,
+      eHasNextEntry,
+      eHasPrevEntry,
+      eSetAuthor,
+      eSetAutoGoToURL,
+      eSetAutoStart,
+      eSetBackgroundColor,
+      eSetCanSeek,
+      eSetCenter,
+      eSetConsole,
+      eSetConsoleEvents,
+      eSetControls,
+      eSetCopyright,
+      eSetDoubleSize,
+      eSetEnableContextMenu,
+      eSetEnableDoubleSize,
+      eSetEnableFullScreen,
+      eSetEnableOriginalSize,
+      eSetFullScreen,
+      eSetImageStatus,
+      eSetLoop,
+      eSetMaintainAspect,
+      eSetMute,
+      eSetNoLogo,
+      eSetNumLoop,
+      eSetOriginalSize,
+      eSetPosition,
+      eSetPreFetch,
+      eSetShowAbout,
+      eSetShowPreferences,
+      eSetShowStatistics,
+      eSetShuffle,
+      eSetSource,
+      eSetTitle,
+      eSetVolume,
+      eSetWantErrors,
+      eSetWantKeyboardEvents,
+      eSetWantMouseEvents
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+};
+
+TOTEM_DEFINE_NPCLASS (totemComplexPlayer);
+
+#endif /* __TOTEM_COMPLEX_PLAYER_H__ */

Modified: trunk/browser-plugin/totemComplexPlugin.cpp
==============================================================================
--- trunk/browser-plugin/totemComplexPlugin.cpp	(original)
+++ trunk/browser-plugin/totemComplexPlugin.cpp	Fri May 30 17:35:08 2008
@@ -47,13 +47,6 @@
   { 0x91, 0x8c, 0x09, 0xaa, 0x92, 0x36, 0xe3, 0xbb } };
 
 static const char kClassDescription[] = "totemComplexPlugin";
-static const char kPluginDescription[] = "Helix DNA Plugin: RealPlayer G2 Plug-In Compatible (compatible; Totem)";
-
-#define TOTEM_COMPLEX_VERSION_BUILD "10.0"
-
-static const totemPluginMimeEntry kMimeTypes[] = {
-	{ "audio/x-pn-realaudio-plugin", "rpm", "audio/vnd.rn-realaudio" },
-};
 
 void*
 totemScriptablePlugin::operator new (size_t aSize) CPP_THROW_NEW
@@ -78,26 +71,6 @@
   D ("%s dtor [%p]", kClassDescription, (void*) this);
 }
 
-/* static */ char *
-totemScriptablePlugin::PluginDescription ()
-{
-  return (char*) kPluginDescription;
-}
-
-/* static */ char *
-totemScriptablePlugin::PluginLongDescription ()
-{
-  return (char*) totem_plugin_get_long_description();
-}
-
-/* static */ void
-totemScriptablePlugin::PluginMimeTypes (const totemPluginMimeEntry **_entries,
-					PRUint32 *_count)
-{
-  *_entries = kMimeTypes;
-  *_count = G_N_ELEMENTS (kMimeTypes);
-}
-
 /* Interface implementations */
 
 NS_IMPL_ISUPPORTS2 (totemScriptablePlugin,

Modified: trunk/browser-plugin/totemComplexPlugin.h
==============================================================================
--- trunk/browser-plugin/totemComplexPlugin.h	(original)
+++ trunk/browser-plugin/totemComplexPlugin.h	Fri May 30 17:35:08 2008
@@ -1,7 +1,7 @@
 /* Totem Complex Plugin scriptable
  *
- * Copyright (C) 2004 Bastien Nocera <hadess hadess net>
- * Copyright (C) 2002 David A. Schleef <ds schleef org>
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -44,9 +44,6 @@
     PRBool IsValid () { return mPlugin != nsnull; }
     void SetPlugin (totemPlugin *aPlugin) { mPlugin = aPlugin; }
 
-    static char *PluginDescription ();
-    static char *PluginLongDescription();
-    static void PluginMimeTypes (const totemPluginMimeEntry **, PRUint32 *);
   private:
     ~totemScriptablePlugin ();
 

Added: trunk/browser-plugin/totemCone.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemCone.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,118 @@
+/* Totem Cone plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "totemPlugin.h"
+#include "totemCone.h"
+
+static const char *propertyNames[] = {
+  "audio",
+  "input",
+  "iterator",
+  "log",
+  "messages",
+  "playlist",
+  "VersionInfo",
+  "video",
+};
+
+static const char *methodNames[] = {
+  "versionInfo"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemCone,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemCone::totemCone (NPP aNPP)
+  : totemNPObject (aNPP)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemCone::~totemCone ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemCone::InvokeByIndex (int aIndex,
+                          const NPVariant *argv,
+                          uint32_t argc,
+                          NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemCone);
+
+  switch (Methods (aIndex)) {
+    case eversionInfo:
+      return GetPropertyByIndex (eVersionInfo, _result);
+  }
+
+  return false;
+}
+
+bool
+totemCone::GetPropertyByIndex (int aIndex,
+                               NPVariant *_result)
+{
+  TOTEM_LOG_GETTER (aIndex, totemCone);
+
+  switch (Properties (aIndex)) {
+    case eAudio:
+      return ObjectVariant (_result, Plugin()->GetNPObject (totemPlugin::eConeAudio));
+
+    case eInput:
+      return ObjectVariant (_result, Plugin()->GetNPObject (totemPlugin::eConeInput));
+
+    case ePlaylist:
+      return ObjectVariant (_result, Plugin()->GetNPObject (totemPlugin::eConePlaylist));
+
+    case eVideo:
+      return ObjectVariant (_result, Plugin()->GetNPObject (totemPlugin::eConeVideo));
+
+    case eVersionInfo:
+      return StringVariant (_result, TOTEM_CONE_VERSION);
+
+    case eIterator:
+    case eLog:
+    case eMessages:
+      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, _result);
+      return NullVariant (_result);
+  }
+
+  return false;
+}
+
+bool
+totemCone::SetPropertyByIndex (int aIndex,
+                               const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemCone);
+
+  return ThrowPropertyNotWritable ();
+}

Added: trunk/browser-plugin/totemCone.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemCone.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,59 @@
+/* Totem Cone plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#ifndef __TOTEM_CONE__H__
+#define __TOTEM_CONE__H__
+
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+
+class totemCone : public totemNPObject
+{
+  public:
+    totemCone (NPP);
+    virtual ~totemCone ();
+
+  private:
+
+    enum Methods {
+      eversionInfo
+    };
+
+    enum Properties {
+      eAudio,
+      eInput,
+      eIterator,
+      eLog,
+      eMessages,
+      ePlaylist,
+      eVersionInfo,
+      eVideo,
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
+};
+
+TOTEM_DEFINE_NPCLASS (totemCone);
+
+#endif /* __TOTEM_CONE__H__ */

Added: trunk/browser-plugin/totemConeAudio.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemConeAudio.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,139 @@
+/* Totem Cone plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "totemPlugin.h"
+#include "totemConeAudio.h"
+
+static const char *propertyNames[] = {
+  "channel"
+  "mute",
+  "track",
+  "volume",
+};
+
+static const char *methodNames[] = {
+  "toggleMute"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemConeAudio,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemConeAudio::totemConeAudio (NPP aNPP)
+  : totemNPObject (aNPP),
+    mMute (false),
+    mSavedVolume (0.5)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemConeAudio::~totemConeAudio ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemConeAudio::InvokeByIndex (int aIndex,
+                               const NPVariant *argv,
+                               uint32_t argc,
+                               NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemConeAudio);
+
+  switch (Methods (aIndex)) {
+    case eToggleMute: {
+      /* FIXMEchpe this sucks */
+      NPVariant mute;
+      BOOLEAN_TO_NPVARIANT (!mMute, mute);
+      return SetPropertyByIndex (eMute, &mute);
+    }
+  }
+
+  return false;
+}
+
+bool
+totemConeAudio::GetPropertyByIndex (int aIndex,
+                                    NPVariant *_result)
+{
+  TOTEM_LOG_GETTER (aIndex, totemConeAudio);
+
+  switch (Properties (aIndex)) {
+    case eMute:
+      return BoolVariant (_result, Plugin()->IsMute());
+      
+    case eVolume:
+      return Int32Variant (_result, Plugin()->Volume() * 200.0);
+
+    case eChannel:
+    case eTrack:
+      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, _result);
+      return VoidVariant (_result);
+  }
+
+  return false;
+}
+
+bool
+totemConeAudio::SetPropertyByIndex (int aIndex,
+                                    const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemConeAudio);
+
+  switch (Properties (aIndex)) {
+    case eVolume: {
+      int32_t volume;
+      if (!GetInt32FromArguments (aValue, 1, 0, volume))
+        return false;
+
+      Plugin()->SetVolume ((double) CLAMP (volume, 0, 200) / 200.0);
+      return true;
+    }
+
+    case eMute: {
+      if (!GetBoolFromArguments (aValue, 1, 0, mMute))
+        return false;
+
+      if (mMute) {
+        mSavedVolume = Plugin()->Volume();
+        Plugin()->SetVolume (0.0);
+      } else {
+        Plugin()->SetVolume (mSavedVolume);
+      }
+      return true;
+    }
+
+    case eChannel:
+    case eTrack:
+      TOTEM_WARN_SETTER_UNIMPLEMENTED (aIndex, _result);
+      return true;
+  }
+
+  return false;
+}

Added: trunk/browser-plugin/totemConeAudio.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemConeAudio.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,58 @@
+/* Totem Cone plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#ifndef __TOTEM_CONE_AUDIO_H__
+#define __TOTEM_CONE_AUDIO_H__
+
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+
+class totemConeAudio : public totemNPObject
+{
+  public:
+    totemConeAudio (NPP);
+    virtual ~totemConeAudio ();
+
+  private:
+
+    enum Methods {
+      eToggleMute
+    };
+
+    enum Properties {
+      eChannel,
+      eMute,
+      eTrack,
+      eVolume
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
+
+    bool mMute;
+    double mSavedVolume;
+};
+
+TOTEM_DEFINE_NPCLASS (totemConeAudio);
+
+#endif /* __TOTEM_CONE_AUDIO_H__ */

Added: trunk/browser-plugin/totemConeInput.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemConeInput.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,121 @@
+/* Totem Cone plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "totemPlugin.h"
+#include "totemConeInput.h"
+
+static const char *propertyNames[] = {
+  "fps",
+  "hasVout",
+  "length",
+  "position",
+  "rate",
+  "state",
+  "time"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemConeInput,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         NULL, 0,
+                         NULL);
+
+totemConeInput::totemConeInput (NPP aNPP)
+  : totemNPObject (aNPP)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemConeInput::~totemConeInput ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemConeInput::GetPropertyByIndex (int aIndex,
+                                    NPVariant *_result)
+{
+  TOTEM_LOG_GETTER (aIndex, totemConeInput);
+
+  switch (Properties (aIndex)) {
+    case eState: {
+      int32_t state;
+
+      /* IDLE/CLOSE=0,
+       * OPENING=1,
+       * BUFFERING=2,
+       * PLAYING=3,
+       * PAUSED=4,
+       * STOPPING=5,
+       * ERROR=6
+       */
+      if (Plugin()->State() == TOTEM_STATE_PLAYING) {
+        state = 3;
+      } else if (Plugin()->State() == TOTEM_STATE_PAUSED) {
+        state = 4;
+      } else {
+        state = 0;
+      }
+
+      return Int32Variant (_result, state);
+    }
+
+    case eFps:
+    case eHasVout:
+    case eLength:
+    case ePosition:
+    case eRate:
+    case eTime:
+      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, _result);
+      return VoidVariant (_result);
+  }
+
+  return false;
+}
+
+bool
+totemConeInput::SetPropertyByIndex (int aIndex,
+                                    const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemConeInput);
+
+  switch (Properties (aIndex)) {
+    case ePosition:
+    case eRate:
+    case eState:
+    case eTime:
+      TOTEM_WARN_SETTER_UNIMPLEMENTED (aIndex, _result);
+      return true;
+
+    case eFps:
+    case eHasVout:
+    case eLength:
+      return ThrowPropertyNotWritable ();
+  }
+
+  return false;
+}

Copied: trunk/browser-plugin/totemConeInput.h (from r5440, /trunk/browser-plugin/totemGMPError.h)
==============================================================================
--- /trunk/browser-plugin/totemGMPError.h	(original)
+++ trunk/browser-plugin/totemConeInput.h	Fri May 30 17:35:08 2008
@@ -1,6 +1,8 @@
-/* Totem GMP plugin
+/* Totem Cone plugin
  *
- * Copyright  2006, 2007 Christian Persch
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -16,37 +18,36 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id: totemGMPPlugin.h 3717 2006-11-15 17:21:16Z chpe $
  */
 
-#ifndef __GMP_ERROR_H__
-#define __GMP_ERROR_H__
-
-#include <nsIClassInfo.h>
-
-#include "totemIGMPError.h"
-#include "totemIGMPErrorItem.h"
+#ifndef __TOTEM_CONE_INPUT_H__
+#define __TOTEM_CONE_INPUT_H__
 
-class totemScriptablePlugin;
+#include "totemNPClass.h"
+#include "totemNPObject.h"
 
-class totemGMPError : public totemIGMPError,
-		      public totemIGMPErrorItem,
-		      public nsIClassInfo
+class totemConeInput : public totemNPObject
 {
   public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_TOTEMIGMPERROR
-    NS_DECL_TOTEMIGMPERRORITEM
-    NS_DECL_NSICLASSINFO
-
-    totemGMPError (totemScriptablePlugin *aPlugin);
+    totemConeInput (NPP);
+    virtual ~totemConeInput ();
 
   private:
-    ~totemGMPError ();
 
-    totemScriptablePlugin *mPlugin;
-    PRInt32 mCount;
+    enum Properties {
+      eFps,
+      eHasVout,
+      eLength,
+      ePosition,
+      eRate,
+      eState,
+      eTime
+    };
+
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
 };
 
-#endif /* __GMP_ERROR_H__ */
+TOTEM_DEFINE_NPCLASS (totemConeInput);
+
+#endif /* __TOTEM_CONE_INPUT_H__ */

Added: trunk/browser-plugin/totemConePlaylist.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemConePlaylist.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,131 @@
+/* Totem Cone plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "totemPlugin.h"
+#include "totemConePlaylist.h"
+
+static const char *propertyNames[] = {
+  "isPlaying",
+  "items"
+};
+
+static const char *methodNames[] = {
+  "add",
+  "next",
+  "play",
+  "playItem",
+  "prev",
+  "removeItem",
+  "stop",
+  "togglePause"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemConePlaylist,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemConePlaylist::totemConePlaylist (NPP aNPP)
+  : totemNPObject (aNPP)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemConePlaylist::~totemConePlaylist ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemConePlaylist::InvokeByIndex (int aIndex,
+                                  const NPVariant *argv,
+                                  uint32_t argc,
+                                  NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemConePlaylist);
+
+  switch (Methods (aIndex)) {
+    case eAdd: {
+      /* long add (in AUTF8String MRL, [in AUTF8String name, in AUTF8String options]); */
+      if (!CheckArgc (argc, 1, 3))
+        return false;
+
+      const char *mrl;
+      if (!GetStringFromArguments (argv, argc, 0, mrl))
+        return false;
+
+      Plugin()->AddItem (mrl);
+      return Int32Variant (_result, 0);
+    }
+
+    case ePlay:
+      Plugin()->Command (TOTEM_COMMAND_PLAY);
+      return VoidVariant (_result);
+
+    case eStop:
+      Plugin()->Command (TOTEM_COMMAND_STOP);
+      return VoidVariant (_result);
+
+    case eNext:
+    case ePlayItem:
+    case ePrev:
+    case eRemoveItem:
+    case eTogglePause:
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemConePlaylist);
+      return VoidVariant (_result);
+  }
+
+  return false;
+}
+
+bool
+totemConePlaylist::GetPropertyByIndex (int aIndex,
+                                       NPVariant *_result)
+{
+  TOTEM_LOG_GETTER (aIndex, totemConePlaylist);
+
+  switch (Properties (aIndex)) {
+    case eItems:
+      return ObjectVariant (_result, Plugin()->GetNPObject (totemPlugin::eConePlaylistItems));
+
+    case eIsPlaying:
+      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, _result);
+      return BoolVariant (_result, true);
+  }
+
+  return false;
+}
+
+bool
+totemConePlaylist::SetPropertyByIndex (int aIndex,
+                                       const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemConePlaylist);
+
+  return ThrowPropertyNotWritable ();
+}

Added: trunk/browser-plugin/totemConePlaylist.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemConePlaylist.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,60 @@
+/* Totem Cone plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#ifndef __TOTEM_CONE_PLAYLIST_H__
+#define __TOTEM_CONE_PLAYLIST_H__
+
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+
+class totemConePlaylist : public totemNPObject
+{
+  public:
+    totemConePlaylist (NPP);
+    virtual ~totemConePlaylist ();
+
+  private:
+
+    enum Methods {
+      eAdd,
+      eNext,
+      ePlay,
+      ePlayItem,
+      ePrev,
+      eRemoveItem,
+      eStop,
+      eTogglePause
+    };
+
+    enum Properties {
+      eIsPlaying,
+      eItems
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
+};
+
+TOTEM_DEFINE_NPCLASS (totemConePlaylist);
+
+#endif /* __TOTEM_CONE_PLAYLIST_H__ */

Added: trunk/browser-plugin/totemConePlaylistItems.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemConePlaylistItems.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,95 @@
+/* Totem Cone plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "totemPlugin.h"
+#include "totemConePlaylistItems.h"
+
+static const char *propertyNames[] = {
+  "count"
+};
+
+static const char *methodNames[] = {
+  "clear"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemConePlaylistItems,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemConePlaylistItems::totemConePlaylistItems (NPP aNPP)
+  : totemNPObject (aNPP)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemConePlaylistItems::~totemConePlaylistItems ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemConePlaylistItems::InvokeByIndex (int aIndex,
+                                       const NPVariant *argv,
+                                       uint32_t argc,
+                                       NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemConePlaylistItems);
+
+  switch (Methods (aIndex)) {
+    case eClear:
+      Plugin()->ClearPlaylist ();
+      return VoidVariant (_result);
+  }
+
+  return false;
+}
+
+bool
+totemConePlaylistItems::GetPropertyByIndex (int aIndex,
+                                            NPVariant *_result)
+{
+  TOTEM_LOG_GETTER (aIndex, totemConePlaylistItems);
+
+  switch (Properties (aIndex)) {
+    case eCount:
+      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, totemConePlaylistItems);
+      return Int32Variant (_result, 1);
+  }
+
+  return false;
+}
+
+bool
+totemConePlaylistItems::SetPropertyByIndex (int aIndex,
+                                            const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemConePlaylistItems);
+
+  return ThrowPropertyNotWritable ();
+}

Added: trunk/browser-plugin/totemConePlaylistItems.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemConePlaylistItems.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,52 @@
+/* Totem Cone plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#ifndef __TOTEM_CONE_PLAYLIST_ITEMS_H__
+#define __TOTEM_CONE_PLAYLIST_ITEMS_H__
+
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+
+class totemConePlaylistItems : public totemNPObject
+{
+  public:
+    totemConePlaylistItems (NPP);
+    virtual ~totemConePlaylistItems ();
+
+  private:
+
+    enum Methods {
+      eClear
+    };
+
+    enum Properties {
+      eCount
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
+};
+
+TOTEM_DEFINE_NPCLASS (totemConePlaylistItems);
+
+#endif /* __TOTEM_CONE_PLAYLIST_ITEMS_H__ */

Added: trunk/browser-plugin/totemConeVideo.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemConeVideo.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,136 @@
+/* Totem Cone plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "totemPlugin.h"
+#include "totemConeVideo.h"
+
+static const char *propertyNames[] = {
+  "aspectRatio",
+  "fullscreen",
+  "height",
+  "subtitle",
+  "teletext",
+  "width",
+};
+
+static const char *methodNames[] = {
+  "toggleFullscreen",
+  "toggleTeletext"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemConeVideo,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemConeVideo::totemConeVideo (NPP aNPP)
+  : totemNPObject (aNPP)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemConeVideo::~totemConeVideo ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemConeVideo::InvokeByIndex (int aIndex,
+                               const NPVariant *argv,
+                               uint32_t argc,
+                               NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemConeVideo);
+
+  switch (Methods (aIndex)) {
+    case eToggleFullscreen: {
+      /* FIXMEchpe this sucks */
+      NPVariant fullscreen;
+      BOOLEAN_TO_NPVARIANT (!Plugin()->IsFullscreen(), fullscreen);
+      return SetPropertyByIndex (eFullscreen, &fullscreen);
+    }
+
+    case eToggleTeletext:
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemConeVideo);
+      return VoidVariant (_result);
+  }
+
+  return false;
+}
+
+bool
+totemConeVideo::GetPropertyByIndex (int aIndex,
+                                    NPVariant *_result)
+{
+  TOTEM_LOG_GETTER (aIndex, totemConeVideo);
+
+  switch (Properties (aIndex)) {
+    case eFullscreen:
+      return BoolVariant (_result, Plugin()->IsFullscreen());
+
+    case eAspectRatio:
+    case eHeight:
+    case eSubtitle:
+    case eTeletext:
+    case eWidth:
+      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, _result);
+      return VoidVariant (_result);
+  }
+
+  return false;
+}
+
+bool
+totemConeVideo::SetPropertyByIndex (int aIndex,
+                                    const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemConeVideo);
+
+  switch (Properties (aIndex)) {
+    case eFullscreen: {
+      bool fullscreen;
+      if (!GetBoolFromArguments (aValue, 1, 0, fullscreen))
+        return false;
+
+      Plugin()->SetFullscreen (fullscreen);
+      return true;
+    }
+
+    case eAspectRatio:
+    case eSubtitle:
+    case eTeletext:
+      TOTEM_WARN_SETTER_UNIMPLEMENTED (aIndex, _result);
+      return true;
+
+    case eHeight:
+    case eWidth:
+      return ThrowPropertyNotWritable ();
+  }
+
+  return false;
+}

Added: trunk/browser-plugin/totemConeVideo.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemConeVideo.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,61 @@
+/* Totem Cone plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#ifndef __TOTEM_CONE_VIDEO_H__
+#define __TOTEM_CONE_VIDEO_H__
+
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+
+class totemConeVideo : public totemNPObject
+{
+  public:
+    totemConeVideo (NPP);
+    virtual ~totemConeVideo ();
+
+  private:
+
+    enum Methods {
+      eToggleFullscreen,
+      eToggleTeletext
+    };
+
+    enum Properties {
+      eAspectRatio,
+      eFullscreen,
+      eHeight,
+      eSubtitle,
+      eTeletext,
+      eWidth
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
+
+    bool mMute;
+    double mSaveVolume;
+};
+
+TOTEM_DEFINE_NPCLASS (totemConeVideo);
+
+#endif /* __TOTEM_CONE_VIDEO_H__ */

Added: trunk/browser-plugin/totemGMPControls.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemGMPControls.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,200 @@
+/* Totem GMP plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "totemPlugin.h"
+#include "totemGMPControls.h"
+
+static const char *propertyNames[] = {
+  "audioLanguageCount",
+  "currentAudioLanguage",
+  "currentAudioLanguageIndex",
+  "currentItem",
+  "currentMarker",
+  "currentPosition",
+  "currentPositionString",
+  "currentPositionTimecode"
+};
+
+static const char *methodNames[] = {
+  "fastForward",
+  "fastReverse",
+  "getAudioLanguageDescription",
+  "getAudioLanguageID",
+  "getLanguageName",
+  "isAvailable",
+  "next",
+  "pause",
+  "play",
+  "playItem",
+  "previous",
+  "step",
+  "stop"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemGMPControls,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemGMPControls::totemGMPControls (NPP aNPP)
+  : totemNPObject (aNPP)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemGMPControls::~totemGMPControls ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemGMPControls::InvokeByIndex (int aIndex,
+                                 const NPVariant *argv,
+                                 uint32_t argc,
+                                 NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemGMPControls);
+
+  switch (Methods (aIndex)) {
+    case ePause:
+      /* void pause (); */
+      Plugin()->Command (TOTEM_COMMAND_PAUSE);
+      return VoidVariant (_result);
+
+    case ePlay:
+      /* void play (); */
+      Plugin()->Command (TOTEM_COMMAND_PLAY);
+      return VoidVariant (_result);
+
+    case eStop:
+      /* void stop (); */
+      Plugin()->Command (TOTEM_COMMAND_PAUSE);
+      return VoidVariant (_result);
+
+    case eGetAudioLanguageDescription:
+      /* AUTF8String getAudioLanguageDescription (in long index); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex,totemGMPControls);
+      return StringVariant (_result, "English");
+
+    case eGetLanguageName:
+      /* AUTF8String getLanguageName (in long LCID); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex,totemGMPControls);
+      return StringVariant (_result, "English");
+
+    case eIsAvailable:
+      /* boolean isAvailable (in ACString name); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex,totemGMPControls);
+      return BoolVariant (_result, true);
+
+    case eFastForward:
+      /* void fastForward (); */
+    case eFastReverse:
+      /* void fastReverse (); */
+    case eGetAudioLanguageID:
+      /* long getAudioLanguageID (in long index); */
+    case eNext:
+      /* void next (); */
+    case ePlayItem:
+      /* void playItem (in totemIGMPMedia theMediaItem); */
+    case ePrevious:
+      /* void previous (); */
+    case eStep:
+      /* void step (in long frameCount); */
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex,totemGMPControls);
+      return VoidVariant (_result);
+  }
+
+  return false;
+}
+
+bool
+totemGMPControls::GetPropertyByIndex (int aIndex,
+                                      NPVariant *_result)
+{
+  TOTEM_LOG_SETTER (aIndex, totemGMPControls);
+
+  switch (Properties (aIndex)) {
+    case eCurrentPosition:
+      /* attribute double currentPosition; */
+      return DoubleVariant (_result, double (Plugin()->Time()) / 1000.0);
+
+    case eCurrentItem:
+      /* attribute totemIGMPMedia currentItem; */
+    case eCurrentPositionTimecode:
+      /* attribute ACString currentPositionTimecode; */
+    case eCurrentPositionString:
+      /* readonly attribute ACString currentPositionString; */
+      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, totemGMPControls);
+      return StringVariant (_result, "");
+
+    case eAudioLanguageCount:
+      /* readonly attribute long audioLanguageCount; */
+    case eCurrentAudioLanguage:
+      /* attribute long currentAudioLanguage; */
+    case eCurrentAudioLanguageIndex:
+      /* attribute long currentAudioLanguageIndex; */
+    case eCurrentMarker:
+      /* attribute long currentMarker; */
+      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, totemGMPControls);
+      return Int32Variant (_result, 0);
+  }
+
+  return false;
+}
+
+bool
+totemGMPControls::SetPropertyByIndex (int aIndex,
+                                      const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemGMPControls);
+
+  switch (Properties (aIndex)) {
+    case eCurrentAudioLanguage:
+      /* attribute long currentAudioLanguage; */
+    case eCurrentAudioLanguageIndex:
+      /* attribute long currentAudioLanguageIndex; */
+    case eCurrentItem:
+      /* attribute totemIGMPMedia currentItem; */
+    case eCurrentMarker:
+      /* attribute long currentMarker; */
+    case eCurrentPosition:
+      /* attribute double currentPosition; */
+    case eCurrentPositionTimecode:
+      /* attribute ACString currentPositionTimecode; */
+      TOTEM_WARN_SETTER_UNIMPLEMENTED(aIndex, totemGMPControls);
+      return true;
+
+    case eAudioLanguageCount:
+      /* readonly attribute long audioLanguageCount; */
+    case eCurrentPositionString:
+      /* readonly attribute ACString currentPositionString; */
+      return ThrowPropertyNotWritable ();
+  }
+
+  return false;
+}

Added: trunk/browser-plugin/totemGMPControls.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemGMPControls.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,71 @@
+/* Totem GMP plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#ifndef __TOTEM_GMP_CONTROLS_H__
+#define __TOTEM_GMP_CONTROLS_H__
+
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+
+class totemGMPControls : public totemNPObject
+{
+  public:
+    totemGMPControls (NPP);
+    virtual ~totemGMPControls ();
+
+  private:
+
+    enum Methods {
+      eFastForward,
+      eFastReverse,
+      eGetAudioLanguageDescription,
+      eGetAudioLanguageID,
+      eGetLanguageName,
+      eIsAvailable,
+      eNext,
+      ePause,
+      ePlay,
+      ePlayItem,
+      ePrevious,
+      eStep,
+      eStop
+    };
+
+    enum Properties {
+      eAudioLanguageCount,
+      eCurrentAudioLanguage,
+      eCurrentAudioLanguageIndex,
+      eCurrentItem,
+      eCurrentMarker,
+      eCurrentPosition,
+      eCurrentPositionString,
+      eCurrentPositionTimecode
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
+};
+
+TOTEM_DEFINE_NPCLASS (totemGMPControls);
+
+#endif /* __TOTEM_GMP_CONTROLS_H__ */

Modified: trunk/browser-plugin/totemGMPError.cpp
==============================================================================
--- trunk/browser-plugin/totemGMPError.cpp	(original)
+++ trunk/browser-plugin/totemGMPError.cpp	Fri May 30 17:35:08 2008
@@ -1,6 +1,8 @@
 /* Totem GMP plugin
  *
- * Copyright  2006, 2007 Christian Persch
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -16,171 +18,87 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id: totemGMPPlugin.cpp 3928 2007-01-22 14:59:07Z chpe $
  */
 
-#include <mozilla-config.h>
-#include "config.h"
-
-#include <glib.h>
-
-#include <nsDOMError.h>
-#include <nsIProgrammingLanguage.h>
-#include <nsISupportsImpl.h>
-#include <nsMemory.h>
-#include <nsXPCOM.h>
-
-#define GNOME_ENABLE_DEBUG 1
-/* define GNOME_ENABLE_DEBUG for more debug spew */
-#include "debug.h"
+#include <config.h>
 
-#include "totemDebug.h"
-#include "totemClassInfo.h"
+#include <string.h>
 
-#include "totemGMPPlugin.h"
-#include "totemPlugin.h"
+#include <glib.h>
 
 #include "totemGMPError.h"
 
-/* 2908e683-6162-45ed-8167-f555579d2411 */
-static const nsCID kClassID =
-  { 0x2908e683, 0x6162, 0x45ed, \
-    { 0x81, 0x67, 0xf5, 0x55, 0x57, 0x9d, 0x24, 0x11 } };
-
-static const char kClassDescription[] = "totemGMPError";
-
-/* NOTE: For now we'll implement totemIGMPError and totemIGMPErrorItem on the same
- * object and only ever present at most _one_ error. If that ever changes,
- * we'll need to split this.
- */
+static const char *propertyNames[] = {
+  "errorCount",
+};
+
+static const char *methodNames[] = {
+  "clearErrorQueue",
+  "item",
+  "webHelp"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemGMPError,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
 
-totemGMPError::totemGMPError (totemScriptablePlugin *aPlugin)
-  : mPlugin(aPlugin),
-    mCount(0)
+totemGMPError::totemGMPError (NPP aNPP)
+  : totemNPObject (aNPP)
 {
-  D ("%s ctor [%p]", kClassDescription, (void*) this);
+  TOTEM_LOG_CTOR ();
 }
 
 totemGMPError::~totemGMPError ()
 {
-  D ("%s dtor [%p]", kClassDescription, (void*) this);
-}
-
-/* Interface implementations */
-
-NS_IMPL_ISUPPORTS3 (totemGMPError,
-		    totemIGMPError,
-		    totemIGMPErrorItem,
-		    nsIClassInfo)
-
-/* nsIClassInfo */
-
-TOTEM_CLASSINFO_BEGIN (totemGMPError,
-		       2,
-		       kClassID,
-		       kClassDescription)
-  TOTEM_CLASSINFO_ENTRY (0, totemIGMPError)
-  TOTEM_CLASSINFO_ENTRY (1, totemIGMPErrorItem)
-TOTEM_CLASSINFO_END
-
-/* totemIGMPError */
-
-#undef TOTEM_SCRIPTABLE_INTERFACE
-#define TOTEM_SCRIPTABLE_INTERFACE "totemIGMPError"
-
-/* void clearErrorQueue (); */
-NS_IMETHODIMP 
-totemGMPError::ClearErrorQueue()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  mCount = 0;
-  return NS_OK;
-}
-
-/* readonly attribute long errorCount; */
-NS_IMETHODIMP 
-totemGMPError::GetErrorCount(PRInt32 *aErrorCount)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  *aErrorCount = mCount;
-  return NS_OK;
-}
-
-/* totemIGMPErrorItem item (in long index); */
-NS_IMETHODIMP 
-totemGMPError::Item(PRInt32 index, totemIGMPErrorItem **_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  if (index < 0 || index >= mCount)
-    return NS_ERROR_ILLEGAL_VALUE;
-
-  return CallQueryInterface (this, _retval);
-}
-
-/* void webHelp (); */
-NS_IMETHODIMP 
-totemGMPError::WebHelp()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_OK;
+  TOTEM_LOG_DTOR ();
 }
 
-/* totemIGMPErrorItem */
-
-#undef TOTEM_SCRIPTABLE_INTERFACE
-#define TOTEM_SCRIPTABLE_INTERFACE "totemIGMPErrorItem"
-
-/* readonly attribute long condition; */
-NS_IMETHODIMP 
-totemGMPError::GetCondition(PRInt32 *aCondition)
+bool
+totemGMPError::InvokeByIndex (int aIndex,
+                              const NPVariant *argv,
+                              uint32_t argc,
+                              NPVariant *_result)
 {
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  *aCondition = 0;
-  return NS_OK;
-}
+  TOTEM_LOG_INVOKE (aIndex, totemGMPError);
 
-/* readonly attribute AUTF8String customURL; */
-NS_IMETHODIMP 
-totemGMPError::GetCustomURL(nsACString & aCustomURL)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
+  switch (Methods (aIndex)) {
+    case eClearErrorQueue:
+      /* void clearErrorQueue (); */
+    case eWebHelp:
+      /* void webHelp (); */
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemGMPError);
+      return VoidVariant (_result);
+  
+    case eItem:
+      /* totemIGMPErrorItem item (in long index); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex, totemGMPError);
+      return NullVariant (_result);
+  }
 
-  aCustomURL.Assign ("http://www.gnome.org/projects/totem";);
-  return NS_OK;
+  return false;
 }
 
-/* readonly attribute long errorCode; */
-NS_IMETHODIMP 
-totemGMPError::GetErrorCode(PRInt32 *aErrorCode)
+bool
+totemGMPError::GetPropertyByIndex (int aIndex,
+                                   NPVariant *_result)
 {
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  *aErrorCode = 0;
-  return NS_OK;
-}
+  TOTEM_LOG_GETTER (aIndex, totemGMPError);
 
-/* readonly attribute AUTF8String errorContext; */
-NS_IMETHODIMP 
-totemGMPError::GetErrorContext(nsACString & aErrorContext)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
+  switch (Properties (aIndex)) {
+    case eErrorCount:
+      /* readonly attribute long errorCount; */
+      return Int32Variant (_result, 0);
+  }
 
-  aErrorContext.Assign ("");
-  return NS_OK;
+  return false;
 }
 
-/* readonly attribute AUTF8String errorDescription; */
-NS_IMETHODIMP
-totemGMPError::GetErrorDescription(nsACString & aErrorDescription)
+bool
+totemGMPError::SetPropertyByIndex (int aIndex,
+                                   const NPVariant *aValue)
 {
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
+  TOTEM_LOG_SETTER (aIndex, totemGMPError);
 
-  aErrorDescription.Assign ("");
-  return NS_OK;
+  return ThrowPropertyNotWritable ();
 }

Modified: trunk/browser-plugin/totemGMPError.h
==============================================================================
--- trunk/browser-plugin/totemGMPError.h	(original)
+++ trunk/browser-plugin/totemGMPError.h	Fri May 30 17:35:08 2008
@@ -1,6 +1,8 @@
 /* Totem GMP plugin
  *
- * Copyright  2006, 2007 Christian Persch
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -16,37 +18,37 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id: totemGMPPlugin.h 3717 2006-11-15 17:21:16Z chpe $
  */
 
-#ifndef __GMP_ERROR_H__
-#define __GMP_ERROR_H__
-
-#include <nsIClassInfo.h>
-
-#include "totemIGMPError.h"
-#include "totemIGMPErrorItem.h"
+#ifndef __TOTEM_GMP_ERROR_H__
+#define __TOTEM_GMP_ERROR_H__
 
-class totemScriptablePlugin;
+#include "totemNPClass.h"
+#include "totemNPObject.h"
 
-class totemGMPError : public totemIGMPError,
-		      public totemIGMPErrorItem,
-		      public nsIClassInfo
+class totemGMPError : public totemNPObject
 {
   public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_TOTEMIGMPERROR
-    NS_DECL_TOTEMIGMPERRORITEM
-    NS_DECL_NSICLASSINFO
-
-    totemGMPError (totemScriptablePlugin *aPlugin);
+    totemGMPError (NPP);
+    virtual ~totemGMPError ();
 
   private:
-    ~totemGMPError ();
 
-    totemScriptablePlugin *mPlugin;
-    PRInt32 mCount;
+    enum Methods {
+      eClearErrorQueue,
+      eItem,
+      eWebHelp
+    };
+
+    enum Properties {
+      eErrorCount
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
 };
 
-#endif /* __GMP_ERROR_H__ */
+TOTEM_DEFINE_NPCLASS (totemGMPError);
+
+#endif /* __TOTEM_GMP_ERROR_H__ */

Added: trunk/browser-plugin/totemGMPErrorItem.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemGMPErrorItem.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,89 @@
+/* Totem GMP plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "totemGMPErrorItem.h"
+
+static const char *propertyNames[] = {
+  "condition",
+  "customURL",
+  "errorCode",
+  "errorContext",
+  "errorDescription",
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemGMPErrorItem,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         NULL, 0,
+                         NULL);
+
+totemGMPErrorItem::totemGMPErrorItem (NPP aNPP)
+  : totemNPObject (aNPP)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemGMPErrorItem::~totemGMPErrorItem ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemGMPErrorItem::GetPropertyByIndex (int aIndex,
+                                       NPVariant *_result)
+{
+  TOTEM_LOG_GETTER (aIndex, totemGMPErrorItem);
+
+  switch (Properties (aIndex)) {
+    case eCondition:
+      /* readonly attribute long condition; */
+    case eErrorCode:
+      /* readonly attribute long errorCode; */
+      return Int32Variant (_result, 0);
+
+    case eErrorContext:
+      /* readonly attribute AUTF8String errorContext; */
+    case eErrorDescription:
+      /* readonly attribute AUTF8String errorDescription; */
+      return StringVariant (_result, "Error<1>");
+
+    case eCustomURL:
+      /* readonly attribute AUTF8String customURL; */
+      return StringVariant (_result, "http://www.gnome.org/projects/totem";);
+  }
+
+  return false;
+}
+
+bool
+totemGMPErrorItem::SetPropertyByIndex (int aIndex,
+                                       const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemGMPErrorItem);
+
+  return ThrowPropertyNotWritable ();
+}

Copied: trunk/browser-plugin/totemGMPErrorItem.h (from r5440, /trunk/browser-plugin/totemGMPError.h)
==============================================================================
--- /trunk/browser-plugin/totemGMPError.h	(original)
+++ trunk/browser-plugin/totemGMPErrorItem.h	Fri May 30 17:35:08 2008
@@ -1,6 +1,8 @@
 /* Totem GMP plugin
  *
- * Copyright  2006, 2007 Christian Persch
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -16,37 +18,34 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id: totemGMPPlugin.h 3717 2006-11-15 17:21:16Z chpe $
  */
 
-#ifndef __GMP_ERROR_H__
-#define __GMP_ERROR_H__
-
-#include <nsIClassInfo.h>
-
-#include "totemIGMPError.h"
-#include "totemIGMPErrorItem.h"
+#ifndef __TOTEM_GMP_ERROR_ITEM_H__
+#define __TOTEM_GMP_ERROR_ITEM_H__
 
-class totemScriptablePlugin;
+#include "totemNPClass.h"
+#include "totemNPObject.h"
 
-class totemGMPError : public totemIGMPError,
-		      public totemIGMPErrorItem,
-		      public nsIClassInfo
+class totemGMPErrorItem : public totemNPObject
 {
   public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_TOTEMIGMPERROR
-    NS_DECL_TOTEMIGMPERRORITEM
-    NS_DECL_NSICLASSINFO
-
-    totemGMPError (totemScriptablePlugin *aPlugin);
+    totemGMPErrorItem (NPP);
+    virtual ~totemGMPErrorItem ();
 
   private:
-    ~totemGMPError ();
 
-    totemScriptablePlugin *mPlugin;
-    PRInt32 mCount;
+    enum Properties {
+      eCondition,
+      eCustomURL,
+      eErrorCode,
+      eErrorContext,
+      eErrorDescription
+    };
+
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
 };
 
-#endif /* __GMP_ERROR_H__ */
+TOTEM_DEFINE_NPCLASS (totemGMPErrorItem);
+
+#endif /* __TOTEM_GMP_ERROR_ITEM_H__ */

Added: trunk/browser-plugin/totemGMPNetwork.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemGMPNetwork.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,171 @@
+/* Totem GMP plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "npupp.h"
+
+#include "totemPlugin.h"
+#include "totemGMPNetwork.h"
+
+static const char *propertyNames[] = {
+  "bandWidth",
+  "bitRate",
+  "bufferingCount",
+  "bufferingProgress",
+  "bufferingTime",
+  "downloadProgress",
+  "encodedFrameRate",
+  "frameRate",
+  "framesSkipped",
+  "lostPackets",
+  "maxBandwidth",
+  "maxBitRate",
+  "receivedPackets",
+  "receptionQuality",
+  "recoveredPackets",
+  "sourceProtocol"
+};
+
+static const char *methodNames[] = {
+  "getProxyBypassForLocal",
+  "getProxyExceptionList",
+  "getProxyName",
+  "getProxyPort",
+  "getProxySettings",
+  "setProxyBypassForLocal",
+  "setProxyExceptionList",
+  "setProxyName",
+  "setProxyPort",
+  "setProxySettings"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemGMPNetwork,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemGMPNetwork::totemGMPNetwork (NPP aNPP)
+  : totemNPObject (aNPP)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemGMPNetwork::~totemGMPNetwork ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemGMPNetwork::InvokeByIndex (int aIndex,
+                                const NPVariant *argv,
+                                uint32_t argc,
+                                NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemGMPNetwork);
+
+  switch (Methods (aIndex)) {
+    case eGetProxyBypassForLocal:
+    case eGetProxyExceptionList:
+    case eGetProxyName:
+    case eGetProxyPort:
+    case eGetProxySettings:
+    case eSetProxyBypassForLocal:
+    case eSetProxyExceptionList:
+    case eSetProxyName:
+    case eSetProxyPort:
+    case eSetProxySettings:
+      return ThrowSecurityError ();
+  }
+
+  return false;
+}
+
+bool
+totemGMPNetwork::GetPropertyByIndex (int aIndex,
+                                     NPVariant *_result)
+{
+  TOTEM_LOG_GETTER (aIndex, totemGMPNetwork);
+
+  switch (Properties (aIndex)) {
+    case eBandWidth:
+      /* readonly attribute long bandWidth; */
+      return Int32Variant (_result, Plugin()->Bandwidth() / 1024);
+
+    case eBitRate:
+    case eBufferingCount:
+    case eBufferingProgress:
+    case eBufferingTime:
+    case eDownloadProgress:
+    case eEncodedFrameRate:
+    case eFrameRate:
+    case eFramesSkipped:
+    case eLostPackets:
+    case eMaxBandwidth:
+    case eMaxBitRate:
+    case eReceivedPackets:
+    case eReceptionQuality:
+    case eRecoveredPackets:
+    case eSourceProtocol:
+      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, totemGMPNetwork);
+      return Int32Variant (_result, 0);
+  }
+
+  return false;
+}
+
+bool
+totemGMPNetwork::SetPropertyByIndex (int aIndex,
+                                     const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemGMPNetwork);
+
+  switch (Properties (aIndex)) {
+    case eBufferingTime:
+    case eMaxBandwidth:
+      TOTEM_WARN_SETTER_UNIMPLEMENTED (aIndex, totemGMPNetwork);
+      return true;
+
+    case eBandWidth:
+      /* readonly attribute long bandWidth; */
+    case eBitRate:
+    case eBufferingCount:
+    case eBufferingProgress:
+    case eDownloadProgress:
+    case eEncodedFrameRate:
+    case eFrameRate:
+    case eFramesSkipped:
+    case eLostPackets:
+    case eMaxBitRate:
+    case eReceivedPackets:
+    case eReceptionQuality:
+    case eRecoveredPackets:
+    case eSourceProtocol:
+      return ThrowPropertyNotWritable ();
+  }
+
+  return false;
+}

Added: trunk/browser-plugin/totemGMPNetwork.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemGMPNetwork.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,81 @@
+/* Totem GMP plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#ifndef __TOTEM_GMP_NETWORK_H__
+#define __TOTEM_GMP_NETWORK_H__
+
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+
+class totemGMPSettings;
+
+class totemGMPNetwork : public totemNPObject
+{
+  public:
+    totemGMPNetwork (NPP);
+    virtual ~totemGMPNetwork ();
+
+  private:
+
+    enum Methods {
+      eGetProxyBypassForLocal,
+      eGetProxyExceptionList,
+      eGetProxyName,
+      eGetProxyPort,
+      eGetProxySettings,
+      eSetProxyBypassForLocal,
+      eSetProxyExceptionList,
+      eSetProxyName,
+      eSetProxyPort,
+      eSetProxySettings
+    };
+
+    enum Properties {
+      eBandWidth,
+      eBitRate,
+      eBufferingCount,
+      eBufferingProgress,
+      eBufferingTime,
+      eDownloadProgress,
+      eEncodedFrameRate,
+      eFrameRate,
+      eFramesSkipped,
+      eLostPackets,
+      eMaxBandwidth,
+      eMaxBitRate,
+      eReceivedPackets,
+      eReceptionQuality,
+      eRecoveredPackets,
+      eSourceProtocol
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
+
+    char *mSrc;
+    bool mWindowlessVideo;
+};
+
+TOTEM_DEFINE_NPCLASS (totemGMPNetwork);
+
+#endif /* __TOTEM_GMP_NETWORK_H__ */

Added: trunk/browser-plugin/totemGMPPlayer.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemGMPPlayer.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,314 @@
+/* Totem GMP plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+
+#include "npupp.h"
+
+#include "totemPlugin.h"
+#include "totemGMPPlayer.h"
+
+static const char *propertyNames[] = {
+  "cdromCollection",
+  "closedCaption",
+  "controls",
+  "currentMedia",
+  "currentPlaylist",
+  "dvd",
+  "enableContextMenu",
+  "enabled",
+  "error",
+  "fullScreen",
+  "isOnline",
+  "isRemote",
+  "mediaCollection",
+  "network",
+  "openState",
+  "playerApplication",
+  "playlistCollection",
+  "playState",
+  "settings",
+  "status",
+  "stretchToFit",
+  "uiMode",
+  "URL",
+  "versionInfo",
+  "windowlessVideo",
+};
+
+static const char *methodNames[] = {
+  "close",
+  "launchURL",
+  "newMedia",
+  "newPlaylist",
+  "openPlayer"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemGMPPlayer,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemGMPPlayer::totemGMPPlayer (NPP aNPP)
+  : totemNPObject (aNPP)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemGMPPlayer::~totemGMPPlayer ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemGMPPlayer::InvokeByIndex (int aIndex,
+                               const NPVariant *argv,
+                               uint32_t argc,
+                               NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemGMPPlayer);
+
+  switch (Methods (aIndex)) {
+    case eNewPlaylist:
+      /* totemIGMPPlaylist newPlaylist (in AUTF8String name, in AUTF8String URL); */
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemGMPPlayer);
+      return NullVariant (_result);
+
+    case eClose:
+      /* void close (); */
+    case eNewMedia:
+      /* totemIGMPMedia newMedia (in AUTF8String URL); */
+    case eOpenPlayer:
+      /* void openPlayer (in AUTF8String URL); */
+    case eLaunchURL:
+      /* void launchURL (in AUTF8String URL); */
+      return ThrowSecurityError ();
+  }
+
+  return false;
+}
+
+bool
+totemGMPPlayer::GetPropertyByIndex (int aIndex,
+                                    NPVariant *_result)
+{
+  TOTEM_LOG_GETTER (aIndex, totemGMPPlayer);
+
+  switch (Properties (aIndex)) {
+    case eControls:
+      /* readonly attribute totemIGMPControls controls; */
+      return ObjectVariant (_result, Plugin()->GetNPObject (totemPlugin::eGMPControls));
+
+    case eNetwork:
+      /* readonly attribute totemIGMPNetwork network; */
+      return ObjectVariant (_result, Plugin()->GetNPObject (totemPlugin::eGMPNetwork));
+
+    case eSettings:
+      /* readonly attribute totemIGMPSettings settings; */
+      return ObjectVariant (_result, Plugin()->GetNPObject (totemPlugin::eGMPSettings));
+
+    case eVersionInfo:
+      /* readonly attribute ACString versionInfo; */
+      return StringVariant (_result, TOTEM_GMP_VERSION_BUILD);
+
+    case eFullScreen:
+      /* attribute boolean fullScreen; */
+      return BoolVariant (_result, Plugin()->IsFullscreen());
+
+    case eWindowlessVideo:
+      /* attribute boolean windowlessVideo; */
+      return BoolVariant (_result, Plugin()->IsWindowless());
+
+    case eIsOnline:
+      /* readonly attribute boolean isOnline; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPPlayer);
+      return BoolVariant (_result, true);
+
+    case eEnableContextMenu:
+      /* attribute boolean enableContextMenu; */
+      return BoolVariant (_result, Plugin()->AllowContextMenu());
+
+    case eClosedCaption:
+      /* readonly attribute totemIGMPClosedCaption closedCaption; */
+    case eCurrentMedia:
+      /* attribute totemIGMPMedia currentMedia; */
+    case eCurrentPlaylist:
+      /* attribute totemIGMPPlaylist currentPlaylist; */
+    case eError:
+      /* readonly attribute totemIGMPError error; */
+      TOTEM_WARN_GETTER_UNIMPLEMENTED (aIndex, totemGMPPlayer);
+      return NullVariant (_result);
+
+    case eStatus:
+      /* readonly attribute AUTF8String status; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPPlayer);
+      return StringVariant (_result, "OK");
+
+    case eURL:
+      /* attribute AUTF8String URL; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPPlayer);
+      return StringVariant (_result, Plugin()->Src()); /* FIXMEchpe use URL()? */
+
+    case eEnabled:
+      /* attribute boolean enabled; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPPlayer);
+      return BoolVariant (_result, true);
+
+    case eOpenState:
+      /* readonly attribute long openState; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPPlayer);
+      return Int32Variant (_result, 0);
+
+    case ePlayState:
+      /* readonly attribute long playState; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPPlayer);
+      return Int32Variant (_result, 0);
+
+    case eStretchToFit:
+      /* attribute boolean stretchToFit; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPPlayer);
+      return BoolVariant (_result, false);
+
+    case eUiMode:
+      /* attribute ACString uiMode; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPPlayer);
+      return VoidVariant (_result);
+
+    case eCdromCollection:
+      /* readonly attribute totemIGMPCdromCollection cdromCollection; */
+    case eDvd:
+      /* readonly attribute totemIGMPDVD dvd; */
+    case eMediaCollection:
+      /* readonly attribute totemIGMPMediaCollection mediaCollection; */
+    case ePlayerApplication:
+      /* readonly attribute totemIGMPPlayerApplication playerApplication; */
+    case ePlaylistCollection:
+      /* readonly attribute totemIGMPPlaylistCollection playlistCollection; */
+    case eIsRemote:
+      /* readonly attribute boolean isRemote; */
+      return ThrowSecurityError ();
+  }
+
+  return false;
+}
+
+bool
+totemGMPPlayer::SetPropertyByIndex (int aIndex,
+                                    const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemGMPPlayer);
+
+  switch (Properties (aIndex)) {
+    case eFullScreen: {
+      /* attribute boolean fullScreen; */
+      bool enabled;
+      if (!GetBoolFromArguments (aValue, 1, 0, enabled))
+        return false;
+
+      Plugin()->SetFullscreen (enabled);
+      return true;
+    }
+
+    case eWindowlessVideo: {
+      /* attribute boolean windowlessVideo; */
+      bool enabled;
+      if (!GetBoolFromArguments (aValue, 1, 0, enabled))
+        return false;
+
+      Plugin()->SetIsWindowless(enabled);
+      return true;
+    }
+
+    case eURL: {
+      /* attribute AUTF8String URL; */
+      const char* url;
+      if (!GetStringFromArguments (aValue, 1, 0, url))
+        return false;
+
+      Plugin()->SetSrc (url); /* FIXMEchpe: use SetURL instead?? */
+      return true;
+    }
+
+    case eEnableContextMenu: {
+      /* attribute boolean enableContextMenu; */
+      bool enabled;
+      if (!GetBoolFromArguments (aValue, 1, 0, enabled))
+        return false;
+
+      Plugin()->SetAllowContextMenu (enabled);
+      return true;
+    }
+
+    case eCurrentMedia:
+      /* attribute totemIGMPMedia currentMedia; */
+    case eCurrentPlaylist:
+      /* attribute totemIGMPPlaylist currentPlaylist; */
+    case eEnabled:
+      /* attribute boolean enabled; */
+    case eStretchToFit:
+      /* attribute boolean stretchToFit; */
+    case eUiMode:
+      /* attribute ACString uiMode; */
+      TOTEM_WARN_SETTER_UNIMPLEMENTED (aIndex, totemGMPPlayer);
+      return true;
+
+    case eCdromCollection:
+      /* readonly attribute totemIGMPCdromCollection cdromCollection; */
+    case eClosedCaption:
+      /* readonly attribute totemIGMPClosedCaption closedCaption; */
+    case eControls:
+      /* readonly attribute totemIGMPControls controls; */
+    case eDvd:
+      /* readonly attribute totemIGMPDVD dvd; */
+    case eError:
+      /* readonly attribute totemIGMPError error; */
+    case eIsOnline:
+      /* readonly attribute boolean isOnline; */
+    case eIsRemote:
+      /* readonly attribute boolean isRemote; */
+    case eMediaCollection:
+      /* readonly attribute totemIGMPMediaCollection mediaCollection; */
+    case eNetwork:
+      /* readonly attribute totemIGMPNetwork network; */
+    case eOpenState:
+      /* readonly attribute long openState; */
+    case ePlayerApplication:
+      /* readonly attribute totemIGMPPlayerApplication playerApplication; */
+    case ePlaylistCollection:
+      /* readonly attribute totemIGMPPlaylistCollection playlistCollection; */
+    case ePlayState:
+      /* readonly attribute long playState; */
+    case eSettings:
+      /* readonly attribute totemIGMPSettings settings; */
+    case eStatus:
+      /* readonly attribute AUTF8String status; */
+    case eVersionInfo:
+      /* readonly attribute ACString versionInfo; */
+      return ThrowPropertyNotWritable ();
+  }
+
+  return false;
+}

Added: trunk/browser-plugin/totemGMPPlayer.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemGMPPlayer.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,82 @@
+/* Totem GMP plugin
+ *
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301  USA.
+ */
+
+#ifndef __TOTEM_GMP_PLAYER_H__
+#define __TOTEM_GMP_PLAYER_H__
+
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+
+class totemGMPSettings;
+
+class totemGMPPlayer : public totemNPObject
+{
+  public:
+    totemGMPPlayer (NPP);
+    virtual ~totemGMPPlayer ();
+
+  private:
+
+    enum Methods {
+      eClose,
+      eLaunchURL,
+      eNewMedia,
+      eNewPlaylist,
+      eOpenPlayer
+    };
+
+    enum Properties {
+      eCdromCollection,
+      eClosedCaption,
+      eControls,
+      eCurrentMedia,
+      eCurrentPlaylist,
+      eDvd,
+      eEnableContextMenu,
+      eEnabled,
+      eError,
+      eFullScreen,
+      eIsOnline,
+      eIsRemote,
+      eMediaCollection,
+      eNetwork,
+      eOpenState,
+      ePlayerApplication,
+      ePlaylistCollection,
+      ePlayState,
+      eSettings,
+      eStatus,
+      eStretchToFit,
+      eUiMode,
+      eURL,
+      eVersionInfo,
+      eWindowlessVideo
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
+};
+
+TOTEM_DEFINE_NPCLASS (totemGMPPlayer);
+
+#endif /* __TOTEM_GMP_PLAYER_H__ */

Modified: trunk/browser-plugin/totemGMPPlaylist.cpp
==============================================================================
--- trunk/browser-plugin/totemGMPPlaylist.cpp	(original)
+++ trunk/browser-plugin/totemGMPPlaylist.cpp	Fri May 30 17:35:08 2008
@@ -1,8 +1,8 @@
-/* Totem Basic Plugin
+/* Totem GMP plugin
  *
- * Copyright (C) 2004 Bastien Nocera <hadess hadess net>
- * Copyright (C) 2002 David A. Schleef <ds schleef org>
- * Copyright (C) 2006 Christian Persch
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -18,201 +18,141 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id: totemGMPPlugin.cpp 3790 2006-12-15 23:08:57Z chpe $
  */
 
-#include <mozilla-config.h>
-#include "config.h"
-
-#include <nsDOMError.h>
-#include <nsIProgrammingLanguage.h>
-#include <nsISupportsImpl.h>
-#include <nsMemory.h>
-#include <nsXPCOM.h>
-
-#define GNOME_ENABLE_DEBUG 1
-/* define GNOME_ENABLE_DEBUG for more debug spew */
-#include "debug.h"
+#include <config.h>
 
-#include "totemDebug.h"
+#include <string.h>
 
-#include "totemGMPPlugin.h"
-#include "totemClassInfo.h"
+#include <glib.h>
 
 #include "totemGMPPlaylist.h"
 
-/* cf079ca3-c94f-4676-a9ae-6d9bffd765bd */
-static const nsCID kClassID = 
-  { 0xcf079ca3, 0xc94f, 0x4676, \
-    { 0xa9, 0xae, 0x6d, 0x9b, 0xff, 0xd7, 0x65, 0xbd } };
-
-static const char kClassDescription[] = "totemGMPPlaylist";
-
-totemGMPPlaylist::totemGMPPlaylist (totemScriptablePlugin *aScriptable)
+static const char *propertyNames[] = {
+  "attributeCount",
+  "count",
+  "name"
+};
+
+static const char *methodNames[] = {
+  "appendItem",
+  "attributeName",
+  "getAttributeName",
+  "getItemInfo",
+  "insertItem",
+  "isIdentical",
+  "item",
+  "moveItem",
+  "removeItem",
+  "setItemInfo"
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemGMPPlaylist,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemGMPPlaylist::totemGMPPlaylist (NPP aNPP)
+  : totemNPObject (aNPP),
+    mName (NPN_StrDup ("Playlist"))
 {
-  D ("%s ctor [%p]", kClassDescription, (void*) this);
-
-  /* We keep a reference to the main scriptable, so the code won't be unloaded unless it's ok to do so */
-  mScriptable = aScriptable;
-  NS_ADDREF (mScriptable);
+  TOTEM_LOG_CTOR ();
 }
 
 totemGMPPlaylist::~totemGMPPlaylist ()
 {
-  D ("%s dtor [%p]", kClassDescription, (void*) this);
-
-  NS_RELEASE (mScriptable);
-  mScriptable = nsnull;
-}
-
-/* Interface implementations */
-
-NS_IMPL_ISUPPORTS2 (totemGMPPlaylist,
-		    totemIGMPPlaylist,
-		    nsIClassInfo)
-
-/* nsIClassInfo */
-
-TOTEM_CLASSINFO_BEGIN (totemGMPPlaylist,
-		       1,
-		       kClassID,
-		       kClassDescription)
-  TOTEM_CLASSINFO_ENTRY (0, totemIGMPPlaylist)
-TOTEM_CLASSINFO_END
-
-/* totemIGMPPlayer */
-
-#undef TOTEM_SCRIPTABLE_INTERFACE
-#define TOTEM_SCRIPTABLE_INTERFACE "totemIGMPPlaylist"
-
-/* void appendItem (in totemIGMPMedia item); */
-NS_IMETHODIMP 
-totemGMPPlaylist::AppendItem(totemIGMPMedia *item)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_OK;
-}
-
-/* readonly attribute long attributeCount; */
-NS_IMETHODIMP 
-totemGMPPlaylist::GetAttributeCount(PRInt32 *aAttributeCount)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  *aAttributeCount = 0;
-  return NS_OK;
-}
-
-/* AUTF8String attributeName (in long index); */
-NS_IMETHODIMP 
-totemGMPPlaylist::AttributeName(PRInt32 index, nsACString & _retval)
-{
-  return GetAttributeName (index, _retval);
-}
-
-/* AUTF8String getattributeName (in long index); */
-NS_IMETHODIMP 
-totemGMPPlaylist::GetAttributeName(PRInt32 index, nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  _retval.Assign ("");
-  return NS_OK;
-}
-
-/* readonly attribute long count; */
-NS_IMETHODIMP 
-totemGMPPlaylist::GetCount(PRInt32 *aCount)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
+  TOTEM_LOG_DTOR ();
 
-  *aCount = 0;
-  return NS_OK;
+  g_free (mName);
 }
 
-/* AUTF8String getItemInfo (in AUTF8String name); */
-NS_IMETHODIMP 
-totemGMPPlaylist::GetItemInfo(const nsACString & name, nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  _retval.Assign ("");
-  return NS_OK;
-}
-
-/* void insertItem (in long index, in totemIGMPMedia item); */
-NS_IMETHODIMP 
-totemGMPPlaylist::InsertItem(PRInt32 index, totemIGMPMedia *item)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_OK;
-}
-
-/* boolean isIdentical (in totemIGMPPlaylist playlist); */
-NS_IMETHODIMP 
-totemGMPPlaylist::IsIdentical(totemIGMPPlaylist *playlist, PRBool *_retval)
-{
-  nsISupports *thisPlaylist = static_cast<nsISupports*>
-                                         (static_cast<totemIGMPPlaylist*>(this));
-
-  *_retval = thisPlaylist == playlist;
-  return NS_OK;
-}
-
-/* totemIGMPMedia item (in long index); */
-NS_IMETHODIMP 
-totemGMPPlaylist::Item(PRInt32 index, totemIGMPMedia **_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void moveItem (in long oldIndex, in long newIndex); */
-NS_IMETHODIMP 
-totemGMPPlaylist::MoveItem(PRInt32 oldIndex, PRInt32 newIndex)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_OK;
-}
-
-/* attribute AUTF8String name; */
-NS_IMETHODIMP 
-totemGMPPlaylist::GetName(nsACString & aName)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  aName = mName;
-  return NS_OK;
-}
-
-NS_IMETHODIMP 
-totemGMPPlaylist::SetName(const nsACString & aName)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  mName = aName;
-  return NS_OK;
-}
-
-/* void removeItem (in totemIGMPMedia item); */
-NS_IMETHODIMP 
-totemGMPPlaylist::RemoveItem(totemIGMPMedia *item)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_OK;
-}
-
-/* void setItemInfo (in AUTF8String name, in AUTF8String value); */
-NS_IMETHODIMP 
-totemGMPPlaylist::SetItemInfo(const nsACString & name, const nsACString & value)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
+bool
+totemGMPPlaylist::InvokeByIndex (int aIndex,
+                                 const NPVariant *argv,
+                                 uint32_t argc,
+                                 NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemGMPPlaylist);
+
+  switch (Methods (aIndex)) {
+    case eAttributeName:
+      /* AUTF8String attributeName (in long index); */
+    case eGetAttributeName:
+      /* AUTF8String getAttributeName (in long index); */
+    case eGetItemInfo:
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemGMPPlaylist);
+      /* AUTF8String getItemInfo (in AUTF8String name); */
+      return StringVariant (_result, "");
+
+    case eIsIdentical: {
+      /* boolean isIdentical (in totemIGMPPlaylist playlist); */
+      NPObject *other;
+      if (!GetObjectFromArguments (argv, argc, 0, other))
+        return false;
+
+      return BoolVariant (_result, other == static_cast<NPObject*>(this));
+    }
+
+    case eItem:
+      /* totemIGMPMedia item (in long index); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex, totemGMPPlaylist);
+      return NullVariant (_result);
+
+    case eAppendItem:
+      /* void appendItem (in totemIGMPMedia item); */
+    case eInsertItem:
+      /* void insertItem (in long index, in totemIGMPMedia item); */
+    case eMoveItem:
+      /* void moveItem (in long oldIndex, in long newIndex); */
+    case eRemoveItem:
+      /* void removeItem (in totemIGMPMedia item); */
+    case eSetItemInfo:
+      /* void setItemInfo (in AUTF8String name, in AUTF8String value); */
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemGMPPlaylist);
+      return VoidVariant (_result);
+  }
+
+  return false;
+}
+
+bool
+totemGMPPlaylist::GetPropertyByIndex (int aIndex,
+                                      NPVariant *_result)
+{
+  TOTEM_LOG_GETTER (aIndex, totemGMPPlaylist);
+
+  switch (Properties (aIndex)) {
+    case eAttributeCount:
+      /* readonly attribute long attributeCount; */
+    case eCount:
+      /* readonly attribute long count; */
+      return Int32Variant (_result, 0);
+
+    case eName:
+      /* attribute AUTF8String name; */
+      return StringVariant (_result, mName);
+  }
+
+  return false;
+}
+
+bool
+totemGMPPlaylist::SetPropertyByIndex (int aIndex,
+                                      const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemGMPPlaylist);
+
+  switch (Properties (aIndex)) {
+    case eName:
+      /* attribute AUTF8String name; */
+      return DupStringFromArguments (aValue, 1, 0, mName);
+
+    case eAttributeCount:
+      /* readonly attribute long attributeCount; */
+    case eCount:
+      /* readonly attribute long count; */
+      return ThrowPropertyNotWritable ();
+  }
 
-  return NS_OK;
+  return false;
 }

Modified: trunk/browser-plugin/totemGMPPlaylist.h
==============================================================================
--- trunk/browser-plugin/totemGMPPlaylist.h	(original)
+++ trunk/browser-plugin/totemGMPPlaylist.h	Fri May 30 17:35:08 2008
@@ -1,7 +1,8 @@
-/* Totem Basic Plugin
+/* Totem GMP plugin
  *
- * Copyright (C) 2004 Bastien Nocera <hadess hadess net>
- * Copyright (C) 2002 David A. Schleef <ds schleef org>
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -17,34 +18,48 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id: totemScriptablePlugin.h 3717 2006-11-15 17:21:16Z chpe $
  */
 
-#ifndef __GMP_PLAYLIST_H__
-#define __GMP_PLAYLIST_H__
-
-#include <nsIClassInfo.h>
-
-#include "totemIGMPPlaylist.h"
+#ifndef __TOTEM_GMP_PLAYLIST_H__
+#define __TOTEM_GMP_PLAYLIST_H__
 
-#include "totemGMPPlugin.h"
+#include "totemNPClass.h"
+#include "totemNPObject.h"
 
-class totemGMPPlaylist : public totemIGMPPlaylist,
-			 public nsIClassInfo
+class totemGMPPlaylist : public totemNPObject
 {
   public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_TOTEMIGMPPLAYLIST
-    NS_DECL_NSICLASSINFO
+    totemGMPPlaylist (NPP);
+    virtual ~totemGMPPlaylist ();
 
-    totemGMPPlaylist (totemScriptablePlugin *aScriptable);
-  
   private:
-    ~totemGMPPlaylist ();
 
-    totemScriptablePlugin *mScriptable;
-    nsCString mName;
+    enum Methods {
+      eAppendItem,
+      eAttributeName,
+      eGetAttributeName,
+      eGetItemInfo,
+      eInsertItem,
+      eIsIdentical,
+      eItem,
+      eMoveItem,
+      eRemoveItem,
+      eSetItemInfo
+    };
+
+    enum Properties {
+      eAttributeCount,
+      eCount,
+      eName
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
+
+    char *mName;
 };
 
-#endif /* __GMP_PLAYLIST_H__ */
+TOTEM_DEFINE_NPCLASS (totemGMPPlaylist);
+
+#endif /* __TOTEM_GMP_PLAYLIST_H__ */

Modified: trunk/browser-plugin/totemGMPSettings.cpp
==============================================================================
--- trunk/browser-plugin/totemGMPSettings.cpp	(original)
+++ trunk/browser-plugin/totemGMPSettings.cpp	Fri May 30 17:35:08 2008
@@ -16,300 +16,208 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id: totemGMPPlugin.cpp 3928 2007-01-22 14:59:07Z chpe $
  */
 
-#include <mozilla-config.h>
-#include "config.h"
+#include <config.h>
 
-#include <glib.h>
-
-#include <nsDOMError.h>
-#include <nsIProgrammingLanguage.h>
-#include <nsISupportsImpl.h>
-#include <nsMemory.h>
-#include <nsXPCOM.h>
-
-#define GNOME_ENABLE_DEBUG 1
-/* define GNOME_ENABLE_DEBUG for more debug spew */
-#include "debug.h"
+#include <string.h>
 
-#include "totemIGMPControls.h"
-
-#include "totemDebug.h"
-#include "totemClassInfo.h"
+#include <glib.h>
 
-#include "totemGMPPlugin.h"
 #include "totemPlugin.h"
-
 #include "totemGMPSettings.h"
 
-/* 693329d8-866e-469a-805c-718c4291be70 */
-static const nsCID kClassID =
-  { 0x693329d8, 0x866e, 0x469a, \
-    { 0x80, 0x5c, 0x71, 0x8c, 0x42, 0x91, 0xbe, 0x70 } };
-
-static const char kClassDescription[] = "totemGMPSettings";
-
-totemGMPSettings::totemGMPSettings (totemScriptablePlugin *aPlugin)
-  : mPlugin(aPlugin)
+static const char *propertyNames[] = {
+  "autostart",
+  "balance",
+  "baseURL",
+  "defaultAudioLanguage",
+  "defaultFrame",
+  "enableErrorDialogs",
+  "invokeURLs",
+  "mediaAccessRights",
+  "mute",
+  "playCount",
+  "rate",
+  "volume"
+};
+
+static const char *methodNames[] = {
+  "getMode",
+  "isAvailable",
+  "requestMediaAccessRights",
+  "setMode",
+};
+
+TOTEM_IMPLEMENT_NPCLASS (totemGMPSettings,
+                         propertyNames, G_N_ELEMENTS (propertyNames),
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemGMPSettings::totemGMPSettings (NPP aNPP)
+  : totemNPObject (aNPP),
+    mMute (false)
 {
-  D ("%s ctor [%p]", kClassDescription, (void*) this);
+  TOTEM_LOG_CTOR ();
 }
 
 totemGMPSettings::~totemGMPSettings ()
 {
-  D ("%s dtor [%p]", kClassDescription, (void*) this);
-}
-
-/* Interface implementations */
-
-NS_IMPL_ISUPPORTS2 (totemGMPSettings,
-		    totemIGMPSettings,
-		    nsIClassInfo)
-
-/* nsIClassInfo */
-
-TOTEM_CLASSINFO_BEGIN (totemGMPSettings,
-		       1,
-		       kClassID,
-		       kClassDescription)
-  TOTEM_CLASSINFO_ENTRY (0, totemIGMPSettings)
-TOTEM_CLASSINFO_END
-
-/* totemIGMPSettings */
-
-#undef TOTEM_SCRIPTABLE_INTERFACE
-#define TOTEM_SCRIPTABLE_INTERFACE "totemIGMPSettings"
-
-/* attribute boolean autoStart; */
-NS_IMETHODIMP 
-totemGMPSettings::GetAutoStart(PRBool *aAutoStart)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP 
-totemGMPSettings::SetAutoStart(PRBool aAutoStart)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* attribute AUTF8String baseURL; */
-NS_IMETHODIMP 
-totemGMPSettings::GetBaseURL(nsACString & aBaseURL)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP 
-totemGMPSettings::SetBaseURL(const nsACString & aBaseURL)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* readonly attribute long defaultAudioLanguage; */
-NS_IMETHODIMP 
-totemGMPSettings::GetDefaultAudioLanguage(PRInt32 *aDefaultAudioLanguage)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* attribute AUTF8String defaultFrame; */
-NS_IMETHODIMP 
-totemGMPSettings::GetDefaultFrame(nsACString & aDefaultFrame)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP 
-totemGMPSettings::SetDefaultFrame(const nsACString & aDefaultFrame)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* attribute boolean enableErrorDialogs; */
-NS_IMETHODIMP 
-totemGMPSettings::GetEnableErrorDialogs(PRBool *aEnableErrorDialogs)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP 
-totemGMPSettings::SetEnableErrorDialogs(PRBool aEnableErrorDialogs)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* attribute boolean invokeURLs; */
-NS_IMETHODIMP 
-totemGMPSettings::GetInvokeURLs(PRBool *aInvokeURLs)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP 
-totemGMPSettings::SetInvokeURLs(PRBool aInvokeURLs)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* readonly attribute ACString mediaAccessRights; */
-NS_IMETHODIMP 
-totemGMPSettings::GetMediaAccessRights(nsACString & aMediaAccessRights)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* attribute boolean mute; */
-NS_IMETHODIMP 
-totemGMPSettings::GetMute(PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  *_retval = mMute;
-  return NS_OK;
-}
-
-NS_IMETHODIMP 
-totemGMPSettings::SetMute(PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  mMute = enabled != PR_FALSE;
-  return NS_OK;
-}
-
-/* attribute long playCount; */
-NS_IMETHODIMP 
-totemGMPSettings::GetPlayCount(PRInt32 *aPlayCount)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP 
-totemGMPSettings::SetPlayCount(PRInt32 aPlayCount)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* attribute double rate; */
-NS_IMETHODIMP 
-totemGMPSettings::GetRate(double *aRate)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP 
-totemGMPSettings::SetRate(double aRate)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
+  TOTEM_LOG_DTOR ();
 }
 
-/* attribute long balance; */
-NS_IMETHODIMP 
-totemGMPSettings::GetBalance(PRInt32 *aBalance)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-NS_IMETHODIMP 
-totemGMPSettings::SetBalance(PRInt32 aBalance)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* attribute long volume; */
-NS_IMETHODIMP 
-totemGMPSettings::GetVolume(PRInt32 *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  NS_ENSURE_STATE (IsValid ());
-
-  *_retval = mPlugin->mPlugin->mVolume;
-  return NS_OK;
-}
-NS_IMETHODIMP 
-totemGMPSettings::SetVolume(PRInt32 volume)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  NS_ENSURE_STATE (IsValid ());
-
-  nsresult rv = mPlugin->mPlugin->SetVolume ((double) volume / 100);
-
-  /* Volume passed in is 0 through to 100 */
-  mPlugin->mPlugin->mVolume = volume;
-
-  return NS_OK;
-}
-
-/* boolean isAvailable (in ACString setting); */
-NS_IMETHODIMP 
-totemGMPSettings::IsAvailable(const nsACString & setting, PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  *_retval = PR_FALSE;
-  return NS_OK;
-}
-
-/* boolean getMode (in ACString mode); */
-NS_IMETHODIMP 
-totemGMPSettings::GetMode(const nsACString & mode, PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  *_retval = PR_FALSE;
-  return NS_OK;
-}
-
-/* void setMode (in ACString mode, in boolean enabled); */
-NS_IMETHODIMP 
-totemGMPSettings::SetMode(const nsACString & mode, PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_OK;
-}
-
-/* boolean requestMediaAccessRights (in ACString mode); */
-NS_IMETHODIMP 
-totemGMPSettings::RequestMediaAccessRights (const nsACString & mode, PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
+bool
+totemGMPSettings::InvokeByIndex (int aIndex,
+                                 const NPVariant *argv,
+                                 uint32_t argc,
+                                 NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemGMPSettings);
+
+  switch (Methods (aIndex)) {
+    case eIsAvailable:
+      /* boolean isAvailable (in ACString name); */
+    case eGetMode:
+      /* boolean getMode (in ACString modeName); */
+    case eSetMode:
+      /* void setMode (in ACString modeName, in boolean state); */
+    case eRequestMediaAccessRights:
+      /* boolean requestMediaAccessRights (in ACString access); */
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemGMPSettings);
+      return BoolVariant (_result, false);
+  }
+
+  return false;
+}
+
+bool
+totemGMPSettings::GetPropertyByIndex (int aIndex,
+                                      NPVariant *_result)
+{
+  TOTEM_LOG_GETTER (aIndex, totemGMPSettings);
+
+  switch (Properties (aIndex)) {
+    case eMute:
+      /* attribute boolean mute; */
+      return BoolVariant (_result, Plugin()->IsMute());
+
+    case eVolume:
+      /* attribute long volume; */
+      return Int32Variant (_result, Plugin()->Volume () * 100.0);
+
+    case eAutostart:
+      /* attribute boolean autoStart; */
+      return BoolVariant (_result, Plugin()->AutoPlay());
+
+    case eBalance:
+      /* attribute long balance; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPSettings);
+      return Int32Variant (_result, 0);
+
+    case eBaseURL:
+      /* attribute AUTF8String baseURL; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPSettings);
+      return StringVariant (_result, "");
+
+    case eDefaultAudioLanguage:
+      /* readonly attribute long defaultAudioLanguage; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPSettings);
+      return Int32Variant (_result, 0); /* FIXME */
+
+    case eDefaultFrame:
+      /* attribute AUTF8String defaultFrame; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPSettings);
+      return StringVariant (_result, "");
+
+    case eEnableErrorDialogs:
+      /* attribute boolean enableErrorDialogs; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPSettings);
+      return BoolVariant (_result, true);
+
+    case eInvokeURLs:
+      /* attribute boolean invokeURLs; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPSettings);
+      return BoolVariant (_result, true);
+
+    case eMediaAccessRights:
+      /* readonly attribute ACString mediaAccessRights; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPSettings);
+      return StringVariant (_result, "");
+
+    case ePlayCount:
+      /* attribute long playCount; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPSettings);
+      return Int32Variant (_result, 1);
+
+    case eRate:
+      /* attribute double rate; */
+      TOTEM_WARN_1_GETTER_UNIMPLEMENTED (aIndex, totemGMPSettings);
+      return DoubleVariant (_result, 1.0);
+  }
+
+  return false;
+}
+
+bool
+totemGMPSettings::SetPropertyByIndex (int aIndex,
+                                      const NPVariant *aValue)
+{
+  TOTEM_LOG_SETTER (aIndex, totemGMPSettings);
+
+  switch (Properties (aIndex)) {
+    case eMute: {
+      /* attribute boolean mute; */
+      bool enabled;
+      if (!GetBoolFromArguments (aValue, 1, 0, enabled))
+        return false;
+
+      Plugin()->SetMute (enabled);
+      return true;
+    }
+
+    case eVolume: {
+      /* attribute long volume; */
+      int32_t volume;
+      if (!GetInt32FromArguments (aValue, 1, 0, volume))
+        return false;
+
+      Plugin()->SetVolume ((double) CLAMP (volume, 0, 100) / 100.0);
+      return true;
+    }
+
+    case eAutostart: {
+      /* attribute boolean autoStart; */
+      bool enabled;
+      if (!GetBoolFromArguments (aValue, 1, 0, enabled))
+        return false;
+
+      Plugin()->SetAutoPlay (enabled);
+      return true;
+    }
+
+    case eBalance:
+      /* attribute long balance; */
+    case eBaseURL:
+      /* attribute AUTF8String baseURL; */
+    case eDefaultFrame:
+      /* attribute AUTF8String defaultFrame; */
+    case eEnableErrorDialogs:
+      /* attribute boolean enableErrorDialogs; */
+    case eInvokeURLs:
+      /* attribute boolean invokeURLs; */
+    case ePlayCount:
+      /* attribute long playCount; */
+    case eRate:
+      /* attribute double rate; */
+      TOTEM_WARN_SETTER_UNIMPLEMENTED (aIndex, totemGMPSettings);
+      return true;
+
+    case eDefaultAudioLanguage:
+      /* readonly attribute long defaultAudioLanguage; */
+    case eMediaAccessRights:
+      /* readonly attribute ACString mediaAccessRights; */
+      return ThrowPropertyNotWritable ();
+  }
 
-  *_retval = PR_FALSE;
-  return NS_OK;
+  return false;
 }

Modified: trunk/browser-plugin/totemGMPSettings.h
==============================================================================
--- trunk/browser-plugin/totemGMPSettings.h	(original)
+++ trunk/browser-plugin/totemGMPSettings.h	Fri May 30 17:35:08 2008
@@ -1,6 +1,8 @@
 /* Totem GMP plugin
  *
- * Copyright  2006, 2007 Christian Persch
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2007, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -16,37 +18,51 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id: totemGMPPlugin.h 3717 2006-11-15 17:21:16Z chpe $
  */
 
-#ifndef __GMP_SETTINGS_H__
-#define __GMP_SETTINGS_H__
-
-#include <nsIClassInfo.h>
-
-#include "totemIGMPSettings.h"
+#ifndef __TOTEM_GMP_SETTINGS_H__
+#define __TOTEM_GMP_SETTINGS_H__
 
-class totemScriptablePlugin;
+#include "totemNPClass.h"
+#include "totemNPObject.h"
 
-class totemGMPSettings : public totemIGMPSettings,
-			 public nsIClassInfo
+class totemGMPSettings : public totemNPObject
 {
   public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_TOTEMIGMPSETTINGS
-    NS_DECL_NSICLASSINFO
-
-    totemGMPSettings (totemScriptablePlugin *aPlugin);
-
-    PRBool IsValid () { return mPlugin != nsnull && mPlugin->mPlugin != nsnull ; }
+    totemGMPSettings (NPP);
+    virtual ~totemGMPSettings ();
 
   private:
-    ~totemGMPSettings ();
 
-    PRUint32 mMute : 1;
+    enum Methods {
+      eGetMode,
+      eIsAvailable,
+      eRequestMediaAccessRights,
+      eSetMode
+    };
+
+    enum Properties {
+      eAutostart,
+      eBalance,
+      eBaseURL,
+      eDefaultAudioLanguage,
+      eDefaultFrame,
+      eEnableErrorDialogs,
+      eInvokeURLs,
+      eMediaAccessRights,
+      eMute,
+      ePlayCount,
+      eRate,
+      eVolume
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex (int aIndex, const NPVariant *aValue);
 
-    totemScriptablePlugin *mPlugin;
+    bool mMute;
 };
 
-#endif /* __GMP_SETTINGS_H__ */
+TOTEM_DEFINE_NPCLASS (totemGMPSettings);
+
+#endif /* __TOTEM_GMP_SETTINGS_H__ */

Modified: trunk/browser-plugin/totemMullYPlugin.cpp
==============================================================================
--- trunk/browser-plugin/totemMullYPlugin.cpp	(original)
+++ trunk/browser-plugin/totemMullYPlugin.cpp	Fri May 30 17:35:08 2008
@@ -1,8 +1,8 @@
 /* Totem MullY Plugin
  *
- * Copyright (C) 2004 Bastien Nocera <hadess hadess net>
- * Copyright (C) 2002 David A. Schleef <ds schleef org>
- * Copyright (C) 2006 Christian Persch
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -18,505 +18,162 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id$
  */
 
-#include <mozilla-config.h>
-#include "config.h"
+#include <config.h>
 
 #include <glib.h>
 
-#include <nsIProgrammingLanguage.h>
-#include <nsISupportsImpl.h>
-#include <nsMemory.h>
-#include <nsXPCOM.h>
-
-#define GNOME_ENABLE_DEBUG 1
-/* define GNOME_ENABLE_DEBUG for more debug spew */
-#include "debug.h"
-
-#include "totemIMullYPlayer.h"
-
-#include "totemDebug.h"
-#include "totemClassInfo.h"
-
+#include "totemPlugin.h"
 #include "totemMullYPlugin.h"
 
-/* 67DABFBF-D0AB-41fa-9C46-CC0F21721616 */
-static const nsCID kClassID = 
-  { 0x67dabfbf, 0xd0ab, 0x41fa,
-    { 0x9c, 0x46, 0xcc, 0x0f, 0x21, 0x72, 0x16, 0x16 } };
-
-static const char kClassDescription[] = "totemMullYPlugin";
-static const char kPluginDescription[] = "DivX\xC2\xAE Web Player";
-#define TOTEM_MULLY_VERSION "1.4.0.233"
-static const char kPluginLongDescription[] = "DivX Web Player version " TOTEM_MULLY_VERSION;
-
-static const totemPluginMimeEntry kMimeTypes[] = {
-	{ "video/divx", "divx", "video/x-msvideo" },
+static const char *methodNames[] = {
+  "GetVersion",
+  "SetMinVersion",
+  "SetMode",
+  "SetAllowContextMenu",
+  "SetAutoPlay",
+  "SetLoop",
+  "SetBufferingMode",
+  "SetBannerEnabled",
+  "SetVolume",
+  "SetMovieTitle",
+  "SetPreviewImage",
+  "SetPreviewMessage",
+  "SetPreviewMessageFontSize",
+  "Open",
+  "Play",
+  "Pause",
+  "StepForward",
+  "StepBackward",
+  "FF",
+  "RW",
+  "Stop",
+  "Mute",
+  "UnMute",
+  "Seek",
+  "About",
+  "ShowPreferences",
+  "ShowContextMenu",
+  "GoEmbedded",
+  "GoWindowed",
+  "GoFullscreen",
+  "Resize",
+  "GetTotalTime",
+  "GetVideoWidth",
+  "GetVideoHeight",
+  "GetTotalVideoFrames",
+  "GetVideoFramerate",
+  "GetNumberOfAudioTracks",
+  "GetNumberOfSubtitleTracks",
+  "GetAudioTrackLanguage",
+  "GetSubtitleTrackLanguage",
+  "GetAudioTrackName",
+  "GetSubtitleTrackName",
+  "GetCurrentAudioTrack",
+  "GetCurrentSubtitleTrack",
+  "SetCurrentAudioTrack",
+  "SetCurrentSubtitleTrack"
 };
 
-totemScriptablePlugin::totemScriptablePlugin (totemPlugin *aPlugin)
-  : mPlugin(aPlugin)
-{
-  D ("%s ctor [%p]", kClassDescription, (void*) this);
-}
-
-totemScriptablePlugin::~totemScriptablePlugin ()
-{
-  D ("%s dtor [%p]", kClassDescription, (void*) this);
-}
-
-/* static */ char *
-totemScriptablePlugin::PluginDescription ()
-{
-  return (char*) kPluginDescription;
-}
-
-/* static */ char *
-totemScriptablePlugin::PluginLongDescription ()
-{
-  return (char*) kPluginLongDescription;
-}
-
-/* static */ void
-totemScriptablePlugin::PluginMimeTypes (const totemPluginMimeEntry **_entries,
-					PRUint32 *_count)
-{
-  *_entries = kMimeTypes;
-  *_count = G_N_ELEMENTS (kMimeTypes);
-}
-
-/* Interface implementations */
-
-NS_IMPL_ISUPPORTS2 (totemScriptablePlugin,
-		    totemIMullYPlayer,
-		    nsIClassInfo)
-
-/* nsIClassInfo */
-
-TOTEM_CLASSINFO_BEGIN (totemScriptablePlugin,
-		       1,
-		       kClassID,
-		       kClassDescription)
-  TOTEM_CLASSINFO_ENTRY (0, totemIMullYPlayer)
-TOTEM_CLASSINFO_END
-
-/* totemIMullYPlayer */
-
-#define TOTEM_SCRIPTABLE_INTERFACE "totemIMullYPlayer"
-
-/* ACString GetVersion (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetVersion(nsACString & aVersion)
-{
-  aVersion.Assign (TOTEM_MULLY_VERSION);
-  return NS_OK;
-}
-
-/* void SetMinVersion (in ACString version); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetMinVersion(const nsACString & aVersion)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetMode (in ACString mode); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetMode(const nsACString & aMode)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetAllowContextMenu (in boolean allow); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetAllowContextMenu(PRBool allowed)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetAutoPlay (in boolean play); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetAutoPlay(PRBool aPlay)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetLoop (in boolean loop); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetLoop(PRBool aLoop)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetBufferingMode (in ACString mode); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetBufferingMode(const nsACString & aMode)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetBannerEnabled (in boolean enabled); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetBannerEnabled(PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetVolume (in unsigned long volume); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetVolume(PRUint32 aVolume)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetMovieTitle (in AUTF8String movieTitle); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetMovieTitle (const nsACString & aMovieTitle)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetPreviewImage (in AUTF8String imageURL); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetPreviewImage (const nsACString & aImageURL)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetPreviewMessage (in AUTF8String message); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetPreviewMessage (const nsACString & aMessage)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetPreviewMessageFontSize (in unsigned long size); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetPreviewMessageFontSize(PRUint32 aSize)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void Open (in AUTF8String URL); */
-NS_IMETHODIMP
-totemScriptablePlugin::Open(const nsACString & aURL)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void Play (); */
-NS_IMETHODIMP
-totemScriptablePlugin::Play ()
-{
-  NS_ENSURE_STATE (IsValid ());
-
-  return mPlugin->DoCommand (TOTEM_COMMAND_PLAY);
-}
-
-/* void Pause (); */
-NS_IMETHODIMP
-totemScriptablePlugin::Pause ()
-{
-  NS_ENSURE_STATE (IsValid ());
-
-  return mPlugin->DoCommand (TOTEM_COMMAND_PAUSE);
-}
-
-/* void StepForward (); */
-NS_IMETHODIMP
-totemScriptablePlugin::StepForward()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void StepBackward (); */
-NS_IMETHODIMP
-totemScriptablePlugin::StepBackward()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void FF (); */
-NS_IMETHODIMP
-totemScriptablePlugin::FF()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
+TOTEM_IMPLEMENT_NPCLASS (totemMullYPlayer,
+                         NULL, 0,
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemMullYPlayer::totemMullYPlayer (NPP aNPP)
+  : totemNPObject (aNPP)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemMullYPlayer::~totemMullYPlayer ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemMullYPlayer::InvokeByIndex (int aIndex,
+                                 const NPVariant *argv,
+                                 uint32_t argc,
+                                 NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemMullYPlayer);
+
+  switch (Methods (aIndex)) {
+    case eGetVersion:
+      return StringVariant (_result, TOTEM_MULLY_VERSION);
+
+    case ePlay:
+      Plugin()->Command (TOTEM_COMMAND_PLAY);
+      return VoidVariant (_result);
+
+    case ePause:
+      Plugin()->Command (TOTEM_COMMAND_PAUSE);
+      return VoidVariant (_result);
+
+    case eStop:
+      Plugin()->Command (TOTEM_COMMAND_STOP);
+      return VoidVariant (_result);
+
+    case eSetVolume: {
+      // FIXMEchpe where's getVolume?
+          break;
+    }
+
+    case eMute:
+      Plugin()->SetMute (true);
+      return VoidVariant (_result);
+
+    case eUnMute:
+      Plugin()->SetMute (false);
+      return VoidVariant (_result);
+
+    case eSetMinVersion:
+    case eSetMode:
+    case eSetAllowContextMenu:
+    case eSetAutoPlay:
+    case eSetLoop:
+    case eSetBufferingMode:
+    case eSetBannerEnabled:
+    case eSetMovieTitle:
+    case eSetPreviewImage:
+    case eSetPreviewMessage:
+    case eSetPreviewMessageFontSize:
+    case eOpen:
+    case eStepForward:
+    case eStepBackward:
+    case eFF:
+    case eRW:
+    case eSeek:
+    case eResize:
+    case eGetTotalTime:
+    case eGetVideoWidth:
+    case eGetVideoHeight:
+    case eGetTotalVideoFrames:
+    case eGetVideoFramerate:
+    case eGetNumberOfAudioTracks:
+    case eGetNumberOfSubtitleTracks:
+    case eGetAudioTrackLanguage:
+    case eGetSubtitleTrackLanguage:
+    case eGetAudioTrackName:
+    case eGetSubtitleTrackName:
+    case eGetCurrentAudioTrack:
+    case eGetCurrentSubtitleTrack:
+    case eSetCurrentAudioTrack:
+    case eSetCurrentSubtitleTrack:
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemMullYPlayer);
+      return VoidVariant (_result);
+
+    case eGoEmbedded:
+    case eGoWindowed:
+    case eGoFullscreen:
+    case eAbout:
+    case eShowPreferences:
+    case eShowContextMenu:
+      /* We don't allow the page's JS to do this. Don't throw though, just silently do nothing. */
+      return VoidVariant (_result);
+  }
 
-  return NS_ERROR_NOT_IMPLEMENTED;
+  return false;
 }
-
-/* void RW (); */
-NS_IMETHODIMP
-totemScriptablePlugin::RW()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void Stop (); */
-NS_IMETHODIMP
-totemScriptablePlugin::Stop()
-{
-  NS_ENSURE_STATE (IsValid ());
-
-  return mPlugin->DoCommand (TOTEM_COMMAND_STOP);
-}
-
-/* void Mute (); */
-NS_IMETHODIMP
-totemScriptablePlugin::Mute()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void UnMute (); */
-NS_IMETHODIMP
-totemScriptablePlugin::UnMute()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void Seek (in ACString method, in unsigned long percent); */
-NS_IMETHODIMP
-totemScriptablePlugin::Seek(const nsACString & aMethod, PRUint32 aPercent)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void About (); */
-NS_IMETHODIMP
-totemScriptablePlugin::About()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void ShowPreferences (); */
-NS_IMETHODIMP
-totemScriptablePlugin::ShowPreferences()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void ShowContextMenu (); */
-NS_IMETHODIMP
-totemScriptablePlugin::ShowContextMenu()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void GoEmbedded (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GoEmbedded()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void GoWindowed (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GoWindowed()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void GoFullscreen (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GoFullscreen()
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void Resize (in unsigned long width, in unsigned long height); */
-NS_IMETHODIMP
-totemScriptablePlugin::Resize(PRUint32 aWidth, PRUint32 aHeight)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* unsigned long GetTotalTime (); */
-NS_IMETHODIMP 
-totemScriptablePlugin::GetTotalTime(PRUint32 *aTime)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* unsigned long GetVideoWidth (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetVideoWidth(PRUint32 *aWidth)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* unsigned long GetVideoHeight (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetVideoHeight(PRUint32 *aHeight)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* double GetTotalVideoFrames (); */
-NS_IMETHODIMP 
-totemScriptablePlugin::GetTotalVideoFrames(double *aPosition)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* double GetVideoFramerate (); */
-NS_IMETHODIMP 
-totemScriptablePlugin::GetVideoFramerate(double *aPosition)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* unsigned long GetNumberOfAudioTracks (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetNumberOfAudioTracks(PRUint32 *aNumAudioTracks)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* unsigned long GetNumberOfSubtitleTracks (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetNumberOfSubtitleTracks(PRUint32 *aNumSubtitleTracks)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* ACString GetAudioTrackLanguage (in unsigned long trackIndex); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetAudioTrackLanguage(PRUint32 trackIndex, nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* ACString GetSubtitleTrackLanguage (in unsigned long trackIndex); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetSubtitleTrackLanguage(PRUint32 trackIndex, nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* AUTF8String GetAudioTrackName (in unsigned long trackIndex); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetAudioTrackName(PRUint32 trackIndex, nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* AUTF8String GetSubtitleTrackName (in unsigned long trackIndex); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetSubtitleTrackName(PRUint32 trackIndex, nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* long GetCurrentAudioTrack (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetCurrentAudioTrack(PRInt32 *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* long GetCurrentSubtitleTrack (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetCurrentSubtitleTrack(PRInt32 *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetCurrentAudioTrack (in long index); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetCurrentAudioTrack(PRInt32 index)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void SetCurrentSubtitleTrack (in long index); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetCurrentSubtitleTrack(PRInt32 index)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-

Modified: trunk/browser-plugin/totemMullYPlugin.h
==============================================================================
--- trunk/browser-plugin/totemMullYPlugin.h	(original)
+++ trunk/browser-plugin/totemMullYPlugin.h	Fri May 30 17:35:08 2008
@@ -1,7 +1,8 @@
 /* Totem MullY Plugin
  *
- * Copyright (C) 2004 Bastien Nocera <hadess hadess net>
- * Copyright (C) 2002 David A. Schleef <ds schleef org>
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -17,39 +18,87 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id$
  */
 
-#ifndef __MULLY_PLUGIN_H__
-#define __MULLY_PLUGIN_H__
-
-#include <nsIClassInfo.h>
-
-#include "totemIMullYPlayer.h"
+#ifndef __TOTEM_MULLY_PLUGIN_H__
+#define __TOTEM_MULLY_PLUGIN_H__
 
-#include "totemPlugin.h"
+#include "totemNPClass.h"
+#include "totemNPObject.h"
 
-class totemScriptablePlugin : public totemIMullYPlayer,
-			      public nsIClassInfo
+class totemMullYPlayer : public totemNPObject
 {
   public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_TOTEMIMULLYPLAYER
-    NS_DECL_NSICLASSINFO
-
-    totemScriptablePlugin (totemPlugin *aPlugin);
-
-    PRBool IsValid () { return mPlugin != nsnull; }
-    void SetPlugin (totemPlugin *aPlugin) { mPlugin = aPlugin; }
-
-    static char *PluginDescription ();
-    static char *PluginLongDescription();
-    static void PluginMimeTypes (const totemPluginMimeEntry **, PRUint32 *);
+    totemMullYPlayer (NPP);
+    virtual ~totemMullYPlayer ();
+
   private:
-    ~totemScriptablePlugin ();
 
-    totemPlugin *mPlugin;
+    enum Methods {
+      /* Version */
+      eGetVersion,
+
+      /* Setup */
+      eSetMinVersion,
+      eSetMode,
+      eSetAllowContextMenu,
+      eSetAutoPlay,
+      eSetLoop,
+      eSetBufferingMode,
+      eSetBannerEnabled,
+      eSetVolume,
+      eSetMovieTitle,
+      eSetPreviewImage,
+      eSetPreviewMessage,
+      eSetPreviewMessageFontSize,
+
+      /* Media management */
+      eOpen,
+
+      /* Playback */
+      ePlay,
+      ePause,
+      eStepForward,
+      eStepBackward,
+      eFF,
+      eRW,
+      eStop,
+      eMute,
+      eUnMute,
+      eSeek,
+
+      /* Windowing */
+      eAbout,
+      eShowPreferences,
+      eShowContextMenu,
+      eGoEmbedded,
+      eGoWindowed,
+      eGoFullscreen,
+      eResize,
+
+      /* Media information */
+      eGetTotalTime,
+      eGetVideoWidth,
+      eGetVideoHeight,
+      eGetTotalVideoFrames,
+      eGetVideoFramerate,
+      eGetNumberOfAudioTracks,
+      eGetNumberOfSubtitleTracks,
+      eGetAudioTrackLanguage,
+      eGetSubtitleTrackLanguage,
+      eGetAudioTrackName,
+      eGetSubtitleTrackName,
+      eGetCurrentAudioTrack,
+      eGetCurrentSubtitleTrack,
+
+      /* Media management */
+      eSetCurrentAudioTrack,
+      eSetCurrentSubtitleTrack,
+    };
+
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
 };
 
-#endif /* __MULLY_PLUGIN_H__ */
+TOTEM_DEFINE_NPCLASS (totemMullYPlayer);
+
+#endif /* __TOTEM_MULLY_PLUGIN_H__ */

Added: trunk/browser-plugin/totemNPClass.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemNPClass.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,207 @@
+/*
+ * Copyright  2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <string.h>
+
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+
+totemNPClass_base::totemNPClass_base (const char *aPropertNames[],
+                                      uint32_t aPropertyCount,
+                                      const char *aMethodNames[],
+                                      uint32_t aMethodCount,
+                                      const char *aDefaultMethodName) :
+  mPropertyNameIdentifiers (GetIdentifiersForNames (aPropertNames, aPropertyCount)),
+  mMethodNameIdentifiers (GetIdentifiersForNames (aMethodNames, aMethodCount)),
+  mDefaultMethodIndex (aDefaultMethodName ? GetMethodIndex (NPN_GetStringIdentifier (aDefaultMethodName)) : -1)
+{
+  structVersion  = NP_CLASS_STRUCT_VERSION_ENUM;
+  allocate       = Allocate;
+  deallocate     = Deallocate;
+  invalidate     = Invalidate;
+  hasMethod      = HasMethod;
+  invoke         = Invoke;
+  invokeDefault  = InvokeDefault;
+  hasProperty    = HasProperty;
+  getProperty    = GetProperty;
+  setProperty    = SetProperty;
+  removeProperty = RemoveProperty;
+#if defined(NP_CLASS_STRUCT_VERSION_ENUM) && (NP_CLASS_STRUCT_VERSION >= NP_CLASS_STRUCT_VERSION_ENUM)
+  enumerate      = Enumerate;
+#endif
+#if defined(NP_CLASS_STRUCT_VERSION_CTOR) && (NP_CLASS_STRUCT_VERSION >= NP_CLASS_STRUCT_VERSION_CTOR)
+  /* FIXMEchpe find out what's this supposed to do */
+  /* construct      = Construct; */
+  construct = NULL;
+#endif
+}
+
+totemNPClass_base::~totemNPClass_base ()
+{
+  NPN_MemFree (mPropertyNameIdentifiers);
+  NPN_MemFree (mMethodNameIdentifiers);
+}
+
+NPIdentifier*
+totemNPClass_base::GetIdentifiersForNames (const char *aNames[],
+                                           uint32_t aCount)
+{
+  if (aCount == 0)
+    return NULL;
+
+  NPIdentifier *identifiers = reinterpret_cast<NPIdentifier*>(NPN_MemAlloc (aCount * sizeof (NPIdentifier)));
+  if (!identifiers)
+    return NULL;
+
+  NPN_GetStringIdentifiers (aNames, aCount, identifiers);
+
+  return identifiers;
+}
+
+int
+totemNPClass_base::GetPropertyIndex (NPIdentifier aName)
+{
+  if (!mPropertyNameIdentifiers)
+    return -1;
+
+  for (int i = 0; mPropertyNameIdentifiers[i]; ++i) {
+    if (aName == mPropertyNameIdentifiers[i])
+      return i;
+  }
+
+  return -1;
+}
+
+int
+totemNPClass_base::GetMethodIndex (NPIdentifier aName)
+{
+  if (!mMethodNameIdentifiers)
+    return -1;
+
+  for (int i = 0; mMethodNameIdentifiers[i]; ++i) {
+    if (aName == mMethodNameIdentifiers[i])
+      return i;
+  }
+
+  return -1;
+}
+
+bool
+totemNPClass_base::EnumerateProperties (NPIdentifier **_result, uint32_t *_count)
+{
+  if (!mPropertyNameIdentifiers)
+    return false;
+
+  uint32_t bytes = mPropertyNamesCount * sizeof (NPIdentifier);
+  NPIdentifier *identifiers = reinterpret_cast<NPIdentifier*>(NPN_MemAlloc (bytes));
+  if (!identifiers)
+    return false;
+
+  memcpy (identifiers, mPropertyNameIdentifiers, bytes);
+
+  *_result = identifiers;
+  *_count = mPropertyNamesCount;
+
+  return true;
+}
+
+NPObject*
+totemNPClass_base::Allocate (NPP aNPP, NPClass *aClass)
+{
+  totemNPClass_base* _class = static_cast<totemNPClass_base*>(aClass);
+  return _class->InternalCreate (aNPP);
+}
+
+void
+totemNPClass_base::Deallocate (NPObject *aObject)
+{
+  totemNPObject* object = static_cast<totemNPObject*> (aObject);
+  delete object;
+}
+
+void
+totemNPClass_base::Invalidate (NPObject *aObject)
+{
+  totemNPObject* object = static_cast<totemNPObject*> (aObject);
+  object->Invalidate ();
+}
+
+bool
+totemNPClass_base::HasMethod (NPObject *aObject, NPIdentifier aName)
+{
+  totemNPObject* object = static_cast<totemNPObject*> (aObject);
+  return object->HasMethod (aName);
+}
+
+bool
+totemNPClass_base::Invoke (NPObject *aObject, NPIdentifier aName, const NPVariant *argv, uint32_t argc, NPVariant *_result)
+{
+  totemNPObject* object = static_cast<totemNPObject*> (aObject);
+  return object->Invoke (aName, argv, argc, _result);
+}
+
+bool
+totemNPClass_base::InvokeDefault (NPObject *aObject, const NPVariant *argv, uint32_t argc, NPVariant *_result)
+{
+  totemNPObject* object = static_cast<totemNPObject*> (aObject);
+  return object->InvokeDefault (argv, argc, _result);
+}
+
+bool
+totemNPClass_base::HasProperty (NPObject *aObject, NPIdentifier aName)
+{
+  totemNPObject* object = static_cast<totemNPObject*> (aObject);
+  return object->HasProperty (aName);
+}
+
+bool
+totemNPClass_base::GetProperty (NPObject *aObject, NPIdentifier aName, NPVariant *_result)
+{
+  totemNPObject* object = static_cast<totemNPObject*> (aObject);
+  return object->GetProperty (aName, _result);
+}
+
+bool
+totemNPClass_base::SetProperty (NPObject *aObject, NPIdentifier aName, const NPVariant *aValue)
+{
+  totemNPObject* object = static_cast<totemNPObject*> (aObject);
+  return object->SetProperty (aName, aValue);
+}
+
+bool
+totemNPClass_base::RemoveProperty (NPObject *aObject, NPIdentifier aName)
+{
+  totemNPObject* object = static_cast<totemNPObject*> (aObject);
+  return object->RemoveProperty (aName);
+}
+
+bool
+totemNPClass_base::Enumerate (NPObject *aObject, NPIdentifier **_result, uint32_t *_count)
+{
+  totemNPObject* object = static_cast<totemNPObject*> (aObject);
+  return object->Enumerate (_result, _count);
+}
+
+bool
+totemNPClass_base::Construct (NPObject *aObject, const NPVariant *argv, uint32_t argc, NPVariant *_result)
+{
+  totemNPObject* object = static_cast<totemNPObject*> (aObject);
+  return object->Construct (argv, argc, _result);
+}

Added: trunk/browser-plugin/totemNPClass.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemNPClass.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,156 @@
+/*
+ * Copyright  2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __TOTEM_NPCLASS_H__
+#define __TOTEM_NPCLASS_H__
+
+#include <assert.h>
+
+#include "npapi.h"
+#include "npruntime.h"
+
+class totemNPObject;
+
+class totemNPClass_base : public NPClass {
+
+  public:
+
+    NPObject* CreateInstance (NPP aNPP) {
+      return NPN_CreateObject (aNPP, this);
+    }
+
+  protected:
+    friend class totemNPObject;
+
+    totemNPClass_base (const char *aPropertNames[],
+                       uint32_t aPropertyCount,
+                       const char *aMethodNames[],
+                       uint32_t aMethodCount,
+                       const char *aDefaultMethodName);
+    virtual ~totemNPClass_base ();
+
+    virtual NPObject* InternalCreate (NPP aNPP) = 0;
+
+    int GetPropertyIndex (NPIdentifier aName);
+    int GetMethodIndex   (NPIdentifier aName);
+    int GetDefaultMethodIndex () const { return mDefaultMethodIndex; }
+    bool EnumerateProperties (NPIdentifier **_result, uint32_t *_count);
+
+  private:
+
+    static NPObject* Allocate  (NPP aNPP, NPClass *aClass);
+    static void Deallocate     (NPObject *aObject);
+    static void Invalidate     (NPObject *aObject);
+    static bool HasMethod      (NPObject *aObject, NPIdentifier aName);
+    static bool Invoke         (NPObject *aObject, NPIdentifier aName, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    static bool InvokeDefault  (NPObject *aObject, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    static bool HasProperty    (NPObject *aObject, NPIdentifier aName);
+    static bool GetProperty    (NPObject *aObject, NPIdentifier aName, NPVariant *_result);
+    static bool SetProperty    (NPObject *aObject, NPIdentifier aName, const NPVariant *aValue);
+    static bool RemoveProperty (NPObject *aObject, NPIdentifier aName);
+    static bool Enumerate      (NPObject *aObject, NPIdentifier **_result, uint32_t *_count);
+    static bool Construct      (NPObject *aObject, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+
+    NPIdentifier* GetIdentifiersForNames (const char *aNames[], uint32_t aCount);
+
+    NPIdentifier *mPropertyNameIdentifiers;
+    int mPropertyNamesCount;
+    NPIdentifier *mMethodNameIdentifiers;
+    int mMethodNamesCount;
+    int mDefaultMethodIndex;
+};
+
+template <class T>
+class totemNPClass : public totemNPClass_base {
+  
+  public:
+
+    typedef totemNPClass<T> class_type;
+
+    totemNPClass (const char *aPropertNames[],
+                  uint32_t aPropertyCount,
+                  const char *aMethodNames[],
+                  uint32_t aMethodCount,
+                  const char *aDefaultMethodName) :
+      totemNPClass_base (aPropertNames, aPropertyCount,
+                         aMethodNames, aMethodCount,
+                         aDefaultMethodName) {
+    }
+
+    virtual ~totemNPClass () { }
+
+  protected:
+
+    virtual NPObject* InternalCreate (NPP aNPP) {
+      return new T (aNPP);
+    }
+};
+
+/* Helper macros */
+
+#define TOTEM_DEFINE_NPCLASS(T) \
+class T##NPClass : public totemNPClass<T> {\
+\
+  public:\
+\
+    T##NPClass () throw ();\
+    virtual ~T##NPClass ();\
+\
+    static class_type* Instance () throw ();\
+    static void Shutdown ();\
+\
+  private:\
+    static class_type* sInstance;\
+}
+
+#define TOTEM_IMPLEMENT_NPCLASS(T, propertyNames, propertyNamesCount, methodNames, methodNamesCount, defaultMethodName) \
+\
+T##NPClass::class_type* T##NPClass::sInstance = 0; \
+\
+T##NPClass::T##NPClass () throw ()\
+  : totemNPClass<T> (propertyNames,\
+                     propertyNamesCount,\
+                     methodNames,\
+                     methodNamesCount,\
+                     defaultMethodName)\
+{\
+}\
+\
+T##NPClass::~T##NPClass ()\
+{\
+}\
+\
+T##NPClass::class_type* \
+T##NPClass::Instance () throw ()\
+{\
+  if (!sInstance) {\
+    sInstance = new T##NPClass ();\
+  }\
+\
+  return sInstance;\
+}\
+\
+void \
+T##NPClass::Shutdown ()\
+{\
+  delete sInstance;\
+  sInstance = 0;\
+}
+
+#endif /* __TOTEM_NPCLASS_H__ */

Added: trunk/browser-plugin/totemNPNGlue.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemNPNGlue.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,303 @@
+/*
+ * Copyright  1998 Netscape Communications Corporation.
+ * Copyright  2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * ===========================================================================
+ * Derived from MPL/LGPL/GPL tri-licensed code
+ * [mozilla/odules/plugin/samples/4x-scriptable/npn_gate.cpp];
+ * used here under LGPL 2+, as permitted by the relicensing clause.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright  1998
+ * the Initial Developer. All Rights Reserved.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include "npapi.h"
+#include "npupp.h"
+
+#ifndef HIBYTE
+#define HIBYTE(x) ((((uint32_t)(x)) & 0xff00) >> 8)
+#endif
+
+#ifndef LOBYTE
+#define LOBYTE(W) ((W) & 0xFF)
+#endif
+
+extern NPNetscapeFuncs NPNFuncs;
+
+void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
+{
+  *plugin_major   = NP_VERSION_MAJOR;
+  *plugin_minor   = NP_VERSION_MINOR;
+  *netscape_major = HIBYTE(NPNFuncs.version);
+  *netscape_minor = LOBYTE(NPNFuncs.version);
+}
+
+NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
+{
+  return NPNFuncs.geturlnotify(instance, url, target, notifyData);
+}
+
+NPError NPN_GetURL(NPP instance, const char *url, const char *target)
+{
+  return NPNFuncs.geturl(instance, url, target);
+}
+
+NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData)
+{
+  return NPNFuncs.posturlnotify(instance, url, window, len, buf, file, notifyData);
+}
+
+NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file)
+{
+  return NPNFuncs.posturl(instance, url, window, len, buf, file);
+} 
+
+NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
+{
+  return NPNFuncs.requestread(stream, rangeList);
+}
+
+NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
+{
+  return NPNFuncs.newstream(instance, type, target, stream);
+}
+
+int32_t NPN_Write(NPP instance, NPStream *stream, int32_t len, void *buffer)
+{
+  return NPNFuncs.write(instance, stream, len, buffer);
+}
+
+NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
+{
+  return NPNFuncs.destroystream(instance, stream, reason);
+}
+
+void NPN_Status(NPP instance, const char *message)
+{
+  NPNFuncs.status(instance, message);
+}
+
+const char* NPN_UserAgent(NPP instance)
+{
+  return NPNFuncs.uagent(instance);
+}
+
+void* NPN_MemAlloc(uint32 size)
+{
+  return NPNFuncs.memalloc(size);
+}
+
+void NPN_MemFree(void* ptr)
+{
+  /* Make it null-safe */
+  if (!ptr)
+    return;
+
+  NPNFuncs.memfree(ptr);
+}
+
+uint32_t NPN_MemFlush(uint32_t size)
+{
+  return NPNFuncs.memflush(size);
+}
+
+void NPN_ReloadPlugins(NPBool reloadPages)
+{
+  NPNFuncs.reloadplugins(reloadPages);
+}
+
+JRIEnv* NPN_GetJavaEnv(void)
+{
+  return NPNFuncs.getJavaEnv();
+}
+
+jref NPN_GetJavaPeer(NPP instance)
+{
+  return NPNFuncs.getJavaPeer(instance);
+}
+
+NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
+{
+  return NPNFuncs.getvalue(instance, variable, value);
+}
+
+NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
+{
+  return NPNFuncs.setvalue(instance, variable, value);
+}
+
+void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
+{
+  NPNFuncs.invalidaterect(instance, invalidRect);
+}
+
+void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
+{
+  NPNFuncs.invalidateregion(instance, invalidRegion);
+}
+
+void NPN_ForceRedraw(NPP instance)
+{
+  NPNFuncs.forceredraw(instance);
+}
+
+NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
+{
+  return NPNFuncs.getstringidentifier(name);
+}
+
+void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
+                              NPIdentifier *identifiers)
+{
+  return NPNFuncs.getstringidentifiers(names, nameCount, identifiers);
+}
+
+NPIdentifier NPN_GetStringIdentifier(int32_t intid)
+{
+  return NPNFuncs.getintidentifier(intid);
+}
+
+bool NPN_IdentifierIsString(NPIdentifier identifier)
+{
+  return NPNFuncs.identifierisstring(identifier);
+}
+
+NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
+{
+  return NPNFuncs.utf8fromidentifier(identifier);
+}
+
+int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
+{
+  return NPNFuncs.intfromidentifier(identifier);
+}
+
+NPObject *NPN_CreateObject(NPP npp, NPClass *aClass)
+{
+  return NPNFuncs.createobject(npp, aClass);
+}
+
+NPObject *NPN_RetainObject(NPObject *obj)
+{
+  return NPNFuncs.retainobject(obj);
+}
+
+void NPN_ReleaseObject(NPObject *obj)
+{
+  return NPNFuncs.releaseobject(obj);
+}
+
+bool NPN_Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
+                const NPVariant *args, uint32_t argCount, NPVariant *result)
+{
+  return NPNFuncs.invoke(npp, obj, methodName, args, argCount, result);
+}
+
+bool NPN_InvokeDefault(NPP npp, NPObject* obj, const NPVariant *args,
+                       uint32_t argCount, NPVariant *result)
+{
+  return NPNFuncs.invokeDefault(npp, obj, args, argCount, result);
+}
+
+bool NPN_Evaluate(NPP npp, NPObject* obj, NPString *script,
+                  NPVariant *result)
+{
+  return NPNFuncs.evaluate(npp, obj, script, result);
+}
+
+bool NPN_GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
+                     NPVariant *result)
+{
+  return NPNFuncs.getproperty(npp, obj, propertyName, result);
+}
+
+bool NPN_SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
+                     const NPVariant *value)
+{
+  return NPNFuncs.setproperty(npp, obj, propertyName, value);
+}
+
+bool NPN_RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
+{
+  return NPNFuncs.removeproperty(npp, obj, propertyName);
+}
+
+bool NPN_Enumerate(NPP npp, NPObject *obj, NPIdentifier **identifier,
+                   uint32_t *count)
+{
+#if defined(NPVERS_HAS_NPOBJECT_ENUM) && (NP_VERSION_MINOR >= NPVERS_HAS_NPOBJECT_ENUM)
+  if ((NPNFuncs.version & 0xFF) >= NPVERS_HAS_NPOBJECT_ENUM)
+    return NPNFuncs.enumerate(npp, obj, identifier, count);
+#endif
+  return false;
+}
+
+bool NPN_Construct(NPP npp, NPObject *obj, const NPVariant *args,
+                   uint32_t argCount, NPVariant *result)
+{
+#if defined(NPVERS_HAS_NPOBJECT_ENUM) && (NP_VERSION_MINOR >= NPVERS_HAS_NPOBJECT_ENUM)
+  if ((NPNFuncs.version & 0xFF) >= NPVERS_HAS_NPOBJECT_ENUM)
+    return NPNFuncs.construct(npp, obj, args, argCount, result);
+#endif
+  return false;
+}
+
+bool NPN_HasProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
+{
+  return NPNFuncs.hasproperty(npp, obj, propertyName);
+}
+
+bool NPN_HasMethod(NPP npp, NPObject* obj, NPIdentifier methodName)
+{
+  return NPNFuncs.hasmethod(npp, obj, methodName);
+}
+
+void NPN_ReleaseVariantValue(NPVariant *variant)
+{
+  NPNFuncs.releasevariantvalue(variant);
+}
+
+void NPN_SetException(NPObject* obj, const NPUTF8 *message)
+{
+  NPNFuncs.setexception(obj, message);
+}
+
+void* NPN_MemDup (const void* aMem, uint32 aLen)
+{
+  if (!aMem || !aLen)
+    return NULL;
+
+  void* dup = NPN_MemAlloc (aLen);
+  if (!dup)
+    return NULL;
+
+  return memcpy (dup, aMem, aLen);
+}
+
+char* NPN_StrDup (const char* aString)
+{
+  return (char*) NPN_MemDup (aString, strlen (aString) + 1);
+}

Added: trunk/browser-plugin/totemNPObject.cpp
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemNPObject.cpp	Fri May 30 17:35:08 2008
@@ -0,0 +1,584 @@
+/*
+ * Copyright  2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include <glib.h>
+
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+
+#ifdef DEBUG_PLUGIN
+#define NOTE(x) x
+#else
+#define NOTE(x)
+#endif
+
+static const char *variantTypes[] = {
+  "void",
+  "null",
+  "bool",
+  "int32",
+  "double",
+  "string",
+  "object",
+  "unknown"
+};
+
+#define VARIANT_TYPE(type) (variantTypes[MIN (type, NPVariantType_Object + 1)])
+
+void*
+totemNPObject::operator new (size_t aSize) throw ()
+{
+  void *instance = ::operator new (aSize);
+  if (instance) {
+    memset (instance, 0, aSize);
+  }
+
+  return instance;
+}
+
+totemNPObject::totemNPObject (NPP aNPP)
+  : mNPP (aNPP),
+    mPlugin (reinterpret_cast<totemPlugin*>(aNPP->pdata))
+{
+  NOTE (g_print ("totemNPObject ctor [%p]\n", (void*) this));
+}
+
+totemNPObject::~totemNPObject ()
+{
+  NOTE (g_print ("totemNPObject dtor [%p]\n", (void*) this));
+}
+
+bool
+totemNPObject::Throw (const char *aMessage)
+{
+  NOTE (g_print ("totemNPObject::Throw [%p] : %s\n", (void*) this, aMessage));
+
+  NPN_SetException (this, aMessage);
+  return false;
+}
+
+bool
+totemNPObject::ThrowPropertyNotWritable ()
+{
+  return Throw ("Property not writable");
+}
+
+bool
+totemNPObject::ThrowSecurityError ()
+{
+  return Throw ("Access denied");
+}
+
+bool
+totemNPObject::CheckArgc (uint32_t argc,
+                          uint32_t minArgc,
+                          uint32_t maxArgc,
+                          bool doThrow)
+{
+  if (argc >= minArgc && argc <= maxArgc)
+    return true;
+
+  if (argc < minArgc) {
+    if (doThrow)
+      return Throw ("Not enough arguments");
+
+    return false;
+  }
+
+  if (doThrow)
+    return Throw ("Too many arguments");
+
+  return false;
+}
+
+bool
+totemNPObject::CheckArgType (NPVariantType argType,
+                             NPVariantType expectedType,
+                             uint32_t argNum)
+{
+  bool conforms;
+
+  switch (argType) {
+    case NPVariantType_Void:
+    case NPVariantType_Null:
+      conforms = (argType == expectedType);
+      break;
+
+    case NPVariantType_Bool:
+      conforms = (argType == NPVariantType_Bool ||
+                  argType == NPVariantType_Int32 ||
+                  argType == NPVariantType_Double);
+      break;
+
+    case NPVariantType_Int32:
+    case NPVariantType_Double:
+      /* FIXMEchpe: also accept NULL or VOID ? */
+      conforms = (argType == NPVariantType_Int32 ||
+                  argType == NPVariantType_Double);
+      break;
+
+    case NPVariantType_String:
+    case NPVariantType_Object:
+      conforms = (argType == expectedType ||
+                  argType == NPVariantType_Null ||
+                  argType == NPVariantType_Void);
+      break;
+  }
+
+  if (!conforms) {
+      char msg[128];
+      g_snprintf (msg, sizeof (msg),
+                  "Wrong type of argument %d: expected %s but got %s\n",
+                  argNum, VARIANT_TYPE (expectedType), VARIANT_TYPE (argType));
+
+      return Throw (msg);
+  }
+
+  return true;
+}
+
+bool
+totemNPObject::CheckArg (const NPVariant *argv,
+                         uint32_t argc,
+                         uint32_t argNum,
+                         NPVariantType type)
+{
+  if (!CheckArgc (argc, argNum + 1))
+    return false;
+
+  return CheckArgType (argv[argNum].type, type, argNum);
+}
+
+bool
+totemNPObject::CheckArgv (const NPVariant* argv,
+                          uint32_t argc,
+                          uint32_t expectedArgc,
+                          ...)
+{
+  if (!CheckArgc (argc, expectedArgc, expectedArgc))
+    return false;
+
+  va_list type_args;
+  va_start (type_args, expectedArgc);
+
+  for (uint32_t i = 0; i < argc; ++i) {
+    NPVariantType type = NPVariantType (va_arg (type_args, int /* promotion */));
+
+    if (!CheckArgType (argv[i].type, type)) {
+      va_end (type_args);
+      return false;
+    }
+  }
+
+  va_end (type_args);
+
+  return true;
+}
+
+bool
+totemNPObject::GetBoolFromArguments (const NPVariant* argv,
+                                     uint32_t argc,
+                                     uint32_t argNum,
+                                     bool& _result)
+{
+  if (!CheckArg (argv, argc, argNum, NPVariantType_Bool))
+    return false;
+
+  NPVariant arg = argv[argNum];
+  if (NPVARIANT_IS_BOOLEAN (arg)) {
+    _result = NPVARIANT_TO_BOOLEAN (arg);
+  } else if (NPVARIANT_IS_INT32 (arg)) {
+    _result = NPVARIANT_TO_INT32 (arg) != 0;
+  } else if (NPVARIANT_IS_DOUBLE (arg)) {
+    _result = NPVARIANT_TO_DOUBLE (arg) != 0.0;
+  } else {
+    /* void/null */
+    _result = false;
+  }
+
+  return true;
+}
+
+bool
+totemNPObject::GetInt32FromArguments (const NPVariant* argv,
+                                      uint32_t argc,
+                                      uint32_t argNum,
+                                      int32_t& _result)
+{
+  if (!CheckArg (argv, argc, argNum, NPVariantType_Int32))
+    return false;
+
+  NPVariant arg = argv[argNum];
+  if (NPVARIANT_IS_INT32 (arg)) {
+    _result = NPVARIANT_TO_INT32 (arg);
+  } else if (NPVARIANT_IS_DOUBLE (arg)) {
+    _result = int32_t (NPVARIANT_TO_DOUBLE (arg));
+    /* FIXMEchpe: overflow? */
+  }
+
+  return true;
+}
+
+bool
+totemNPObject::GetDoubleFromArguments (const NPVariant* argv,
+                                       uint32_t argc,
+                                       uint32_t argNum,
+                                       double& _result)
+{
+  if (!CheckArg (argv, argc, argNum, NPVariantType_Double))
+    return false;
+
+  NPVariant arg = argv[argNum];
+  if (NPVARIANT_IS_DOUBLE (arg)) {
+    _result = NPVARIANT_TO_DOUBLE (arg);
+  } else if (NPVARIANT_IS_INT32 (arg)) {
+    _result = double (NPVARIANT_TO_INT32 (arg));
+  }
+
+  return true;
+}
+
+bool
+totemNPObject::GetStringFromArguments (const NPVariant* argv,
+                                       uint32_t argc,
+                                       uint32_t argNum,
+                                       const char*& _result)
+{
+  if (!CheckArg (argv, argc, argNum, NPVariantType_String))
+    return false;
+
+  NPVariant arg = argv[argNum];
+  if (NPVARIANT_IS_STRING (arg)) {
+    NPString string = NPVARIANT_TO_STRING (arg);
+    // FIXMEchpe this assumes it's 0-terminated, check that this holds!
+    _result = string.UTF8Characters;
+  } else if (NPVARIANT_IS_NULL (arg) ||
+             NPVARIANT_IS_VOID (arg)) {
+    _result = NULL;
+  }
+
+  return true;
+}
+
+bool
+totemNPObject::DupStringFromArguments (const NPVariant* argv,
+                                       uint32_t argc,
+                                       uint32_t argNum,
+                                       char*& _result)
+{
+  NPN_MemFree (_result);
+  _result = NULL;
+
+  const char *newValue;
+  if (!GetStringFromArguments (argv, argc, argNum, newValue))
+    return false;
+
+  /* This assumes every NPString is 0-terminated. FIXMEchpe check that this holds! */
+  _result = NPN_StrDup (newValue);
+  return true;
+}
+
+bool
+totemNPObject::GetObjectFromArguments (const NPVariant* argv,
+                                        uint32_t argc,
+                                        uint32_t argNum,
+                                        NPObject*& _result)
+{
+  if (!CheckArg (argv, argc, argNum, NPVariantType_Object))
+    return false;
+
+  NPVariant arg = argv[argNum];
+  if (NPVARIANT_IS_STRING (arg)) {
+    _result = NPVARIANT_TO_OBJECT (arg);
+  } else if (NPVARIANT_IS_NULL (arg) ||
+             NPVARIANT_IS_VOID (arg)) {
+    _result = NULL;
+  }
+
+  return true;
+}
+
+bool
+totemNPObject::VoidVariant (NPVariant* _result)
+{
+  VOID_TO_NPVARIANT (*_result);
+  return true;
+}
+
+bool
+totemNPObject::NullVariant (NPVariant* _result)
+{
+  NULL_TO_NPVARIANT (*_result);
+  return true;
+}
+
+bool
+totemNPObject::BoolVariant (NPVariant* _result,
+                            bool value)
+{
+  BOOLEAN_TO_NPVARIANT (value, *_result);
+  return true;
+}
+
+bool
+totemNPObject::Int32Variant (NPVariant* _result,
+                             int32_t value)
+{
+  INT32_TO_NPVARIANT (value, *_result);
+  return true;
+}
+
+bool
+totemNPObject::DoubleVariant (NPVariant* _result,
+                              double value)
+{
+  DOUBLE_TO_NPVARIANT (value, *_result);
+  return true;
+}
+
+bool
+totemNPObject::StringVariant (NPVariant* _result,
+                              const char* value,
+                              int32_t len)
+{
+  if (!value) {
+    NULL_TO_NPVARIANT (*_result);
+  } else {
+    char *dup;
+
+    if (len < 0) {
+      len = strlen (value);
+      dup = (char*) NPN_MemDup (value, len + 1);
+    } else {
+      dup = (char*) NPN_MemDup (value, len);
+    }
+
+    if (dup) {
+      STRINGN_TO_NPVARIANT (dup, len, *_result);
+    } else {
+      NULL_TO_NPVARIANT (*_result);
+    }
+  }
+
+  return true;
+}
+
+bool
+totemNPObject::ObjectVariant (NPVariant* _result,
+                              NPObject* object)
+{
+  if (object) {
+    NPN_RetainObject (object);
+    OBJECT_TO_NPVARIANT (object, *_result);
+  } else {
+    NULL_TO_NPVARIANT (*_result);
+  }
+
+  return true;
+}
+
+/* NPObject method default implementations */
+
+void
+totemNPObject::Invalidate ()
+{
+  NOTE (g_print ("totemNPObject %p invalidated\n", (void*) this));
+
+  mNPP = NULL;
+  mPlugin = NULL;
+}
+
+bool
+totemNPObject::HasMethod (NPIdentifier aName)
+{
+  if (!IsValid ())
+    return false;
+
+  NOTE (g_print ("totemNPObject::HasMethod [%p] %s\n", (void*) this, NPN_UTF8FromIdentifier (aName)));
+  if (GetClass()->GetMethodIndex (aName) >= 0)
+    return true;
+
+  if (aName == NPN_GetStringIdentifier ("__noSuchMethod__"))
+    return true;
+
+  return false;
+}
+
+bool
+totemNPObject::Invoke (NPIdentifier aName,
+                       const NPVariant *argv,
+                       uint32_t argc,
+                       NPVariant *_result)
+{
+  if (!IsValid ())
+    return false;
+
+  NOTE (g_print ("totemNPObject::Invoke [%p] %s\n", (void*) this, NPN_UTF8FromIdentifier (aName)));
+  int methodIndex = GetClass()->GetMethodIndex (aName);
+  if (methodIndex >= 0)
+    return InvokeByIndex (methodIndex, argv, argc, _result);
+
+  if (aName == NPN_GetStringIdentifier ("__noSuchMethod__")) {
+    /* http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object:_noSuchMethod */
+    if (!CheckArgv (argv, argc, 2, NPVariantType_String, NPVariantType_Object))
+      return false;
+
+    const char *id = NPVARIANT_TO_STRING (argv[0]).UTF8Characters;
+    g_message ("NOTE: site calls unknown function \"%s\" on totemNPObject %p\n", id ? id : "(null)", (void*) this);
+
+    /* Silently ignore the invocation */
+    VOID_TO_NPVARIANT (*_result);
+    return true;
+  }
+
+  return Throw ("No method with this name exists.");
+}
+
+bool
+totemNPObject::InvokeDefault (const NPVariant *argv,
+                              uint32_t argc,
+                              NPVariant *_result)
+{
+  if (!IsValid ())
+    return false;
+
+  NOTE (g_print ("totemNPObject::InvokeDefault [%p]\n", (void*) this));
+  int defaultMethodIndex = GetClass()->GetDefaultMethodIndex ();
+  if (defaultMethodIndex >= 0)
+    return InvokeByIndex (defaultMethodIndex, argv, argc, _result);
+
+  return false;
+}
+
+bool
+totemNPObject::HasProperty (NPIdentifier aName)
+{
+  if (!IsValid ())
+    return false;
+
+  NOTE (g_print ("totemNPObject::HasProperty [%p] %s\n", (void*) this, NPN_UTF8FromIdentifier (aName)));
+  if (GetClass()->GetPropertyIndex (aName) >= 0)
+    return true;
+
+  return false;
+}
+
+bool
+totemNPObject::GetProperty (NPIdentifier aName,
+                            NPVariant *_result)
+{
+  if (!IsValid ())
+    return false;
+
+  NOTE (g_print ("totemNPObject::GetProperty [%p] %s\n", (void*) this, NPN_UTF8FromIdentifier (aName)));
+  int propertyIndex = GetClass()->GetPropertyIndex (aName);
+  if (propertyIndex >= 0)
+    return GetPropertyByIndex (propertyIndex, _result);
+
+  return Throw ("No property with this name exists.");
+}
+
+bool
+totemNPObject::SetProperty (NPIdentifier aName,
+                            const NPVariant *aValue)
+{
+  if (!IsValid ())
+    return false;
+
+  NOTE (g_print ("totemNPObject::SetProperty [%p] %s\n", (void*) this, NPN_UTF8FromIdentifier (aName)));
+  int propertyIndex = GetClass()->GetPropertyIndex (aName);
+  if (propertyIndex >= 0)
+    return SetPropertyByIndex (propertyIndex, aValue);
+
+  return Throw ("No property with this name exists.");
+}
+
+bool
+totemNPObject::RemoveProperty (NPIdentifier aName)
+{
+  if (!IsValid ())
+    return false;
+
+  NOTE (g_print ("totemNPObject::RemoveProperty [%p] %s\n", (void*) this, NPN_UTF8FromIdentifier (aName)));
+  int propertyIndex = GetClass()->GetPropertyIndex (aName);
+  if (propertyIndex >= 0)
+    return RemovePropertyByIndex (propertyIndex);
+
+  return Throw ("No property with this name exists.");
+}
+
+bool
+totemNPObject::Enumerate (NPIdentifier **_result,
+                          uint32_t *_count)
+{
+  if (!IsValid ())
+    return false;
+
+  NOTE (g_print ("totemNPObject::Enumerate [%p]\n", (void*) this));
+  return GetClass()->EnumerateProperties (_result, _count);
+}
+
+bool
+totemNPObject::Construct (const NPVariant *argv,
+                          uint32_t argc,
+                          NPVariant *_result)
+{
+  if (!IsValid ())
+    return false;
+
+  NOTE (g_print ("totemNPObject::Construct [%p]\n", (void*) this));
+  return false; /* FIXMEchpe! */
+}
+
+/* by-index methods */
+
+bool
+totemNPObject::InvokeByIndex (int aIndex,
+                              const NPVariant *argv,
+                              uint32_t argc,
+                              NPVariant *_result)
+{
+  return false;
+}
+
+bool
+totemNPObject::GetPropertyByIndex (int aIndex,
+                                   NPVariant *_result)
+{
+  return false;
+}
+
+bool
+totemNPObject::SetPropertyByIndex (int aIndex,
+                                   const NPVariant *aValue)
+{
+  return false;
+}
+
+bool
+totemNPObject::RemovePropertyByIndex (int aIndex)
+{
+  return Throw ("Removing properties is not supported.");
+}

Added: trunk/browser-plugin/totemNPObject.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemNPObject.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,201 @@
+/*
+ * Copyright  2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __TOTEM_NPOBJECT_H__
+#define __TOTEM_NPOBJECT_H__
+
+#include <assert.h>
+
+#include "npapi.h"
+#include "npruntime.h"
+
+#include "debug.h"
+
+class totemPlugin;
+class totemNPObject;
+class totemNPClass_base;
+template<class T> class totemNPClass;
+
+class totemNPObject : public NPObject {
+  public:
+    totemNPObject (NPP);
+
+    virtual ~totemNPObject ();
+
+    void* operator new (size_t aSize) throw ();
+
+  protected:
+    friend class totemNPClass_base;
+
+    /* NPObject methods */
+    virtual void Invalidate     ();
+    virtual bool HasMethod      (NPIdentifier aName);
+    virtual bool Invoke         (NPIdentifier aName, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool InvokeDefault  (const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool HasProperty    (NPIdentifier aName);
+    virtual bool GetProperty    (NPIdentifier aName, NPVariant *_result);
+    virtual bool SetProperty    (NPIdentifier aName, const NPVariant *aValue);
+    virtual bool RemoveProperty (NPIdentifier aName);
+    virtual bool Enumerate      (NPIdentifier **_result, uint32_t *_count);
+    virtual bool Construct      (const NPVariant *argv, uint32_t argc, NPVariant *_result);
+
+    /* By Index methods */
+    virtual bool InvokeByIndex         (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
+    virtual bool GetPropertyByIndex    (int aIndex, NPVariant *_result);
+    virtual bool SetPropertyByIndex    (int aIndex, const NPVariant *aValue);
+    virtual bool RemovePropertyByIndex (int aIndex);
+
+  private:
+
+    NPP mNPP;
+    totemPlugin *mPlugin;
+
+  protected:
+
+    bool IsValid () const { return mPlugin != 0; }
+    totemPlugin* Plugin () const { assert (IsValid ()); return mPlugin; }
+
+    bool Throw (const char*);
+    bool ThrowPropertyNotWritable ();
+    bool ThrowSecurityError ();
+
+    bool CheckArgc (uint32_t, uint32_t, uint32_t = uint32_t(-1), bool = true);
+    bool CheckArgType (NPVariantType, NPVariantType, uint32_t = 0);
+    bool CheckArg (const NPVariant*, uint32_t, uint32_t, NPVariantType);
+    bool CheckArgv (const NPVariant*, uint32_t, uint32_t, ...);
+
+    bool GetBoolFromArguments (const NPVariant*, uint32_t, uint32_t, bool&);
+    bool GetInt32FromArguments (const NPVariant*, uint32_t, uint32_t, int32_t&);
+    bool GetDoubleFromArguments (const NPVariant*, uint32_t, uint32_t, double&);
+    bool GetStringFromArguments (const NPVariant*, uint32_t, uint32_t, const char*&);
+    bool DupStringFromArguments (const NPVariant*, uint32_t, uint32_t, char*&);
+    bool GetObjectFromArguments (const NPVariant*, uint32_t, uint32_t, NPObject*&);
+
+    bool VoidVariant (NPVariant*);
+    bool NullVariant (NPVariant*);
+    bool BoolVariant (NPVariant*, bool);
+    bool Int32Variant (NPVariant*, int32_t);
+    bool DoubleVariant (NPVariant*, double);
+    bool StringVariant (NPVariant*, const char*, int32_t = -1);
+    bool ObjectVariant (NPVariant*, NPObject*);
+
+  private:
+
+    totemNPClass_base* GetClass() const { return static_cast<totemNPClass_base*>(_class); }
+};
+
+/* Helper macros */
+
+#ifdef GNOME_ENABLE_DEBUG
+
+#define TOTEM_LOG_CTOR() D ("%s [%p]", __func__, (void*) this)
+#define TOTEM_LOG_DTOR() D ("%s [%p]", __func__, (void*) this)
+
+#define TOTEM_LOG_INVOKE(i, T) \
+{\
+  static bool logAccess[G_N_ELEMENTS (methodNames)];\
+  if (!logAccess[i]) {\
+    D ("NOTE: site calls function %s::%s", #T, methodNames[i]);\
+    logAccess[i] = true;\
+  }\
+}
+
+#define TOTEM_LOG_GETTER(i, T) \
+{\
+  static bool logAccess[G_N_ELEMENTS (propertyNames)];\
+  if (!logAccess[i]) {\
+    D ("NOTE: site gets property %s::%s", #T, propertyNames[i]);\
+    logAccess[i] = true;\
+  }\
+}
+
+#define TOTEM_LOG_SETTER(i, T) \
+{\
+  static bool logAccess[G_N_ELEMENTS (propertyNames)];\
+  if (!logAccess[i]) {\
+    D ("NOTE: site sets property %s::%s", #T, propertyNames[i]);\
+    logAccess[i] = true;\
+  }\
+}
+
+#else
+
+#define TOTEM_LOG_CTOR()
+#define TOTEM_LOG_DTOR()
+#define TOTEM_LOG_INVOKE(i, T)
+#define TOTEM_LOG_GETTER(i, T)
+#define TOTEM_LOG_SETTER(i, T)
+
+#endif /* GNOME_ENABLE_DEBUG */
+
+#define TOTEM_WARN_INVOKE_UNIMPLEMENTED(i, T) \
+{\
+  static bool logWarning[G_N_ELEMENTS (methodNames)];\
+  if (!logWarning[i]) {\
+    D ("WARNING: function %s::%s is unimplemented", #T, methodNames[i]);\
+    logWarning[i] = true;\
+  }\
+}
+
+#define TOTEM_WARN_1_INVOKE_UNIMPLEMENTED(i, T) \
+{\
+  static bool logWarning;\
+  if (!logWarning) {\
+    D ("WARNING: function %s::%s is unimplemented", #T, methodNames[i]);\
+    logWarning = true;\
+  }\
+}
+
+#define TOTEM_WARN_GETTER_UNIMPLEMENTED(i, T) \
+{\
+  static bool logWarning[G_N_ELEMENTS (propertyNames)];\
+  if (!logWarning[i]) {\
+    D ("WARNING: getter for property %s::%s is unimplemented", #T, propertyNames[i]);\
+    logWarning[i] = true;\
+  }\
+}
+
+#define TOTEM_WARN_1_GETTER_UNIMPLEMENTED(i, T) \
+{\
+  static bool logWarning;\
+  if (!logWarning) {\
+    D ("WARNING: getter for property %s::%s is unimplemented", #T, propertyNames[i]);\
+    logWarning = true;\
+  }\
+}
+
+#define TOTEM_WARN_SETTER_UNIMPLEMENTED(i, T) \
+{\
+  static bool logWarning[G_N_ELEMENTS (propertyNames)];\
+  if (!logWarning[i]) {\
+    D ("WARNING: setter for property %s::%s is unimplemented", #T, propertyNames[i]);\
+    logWarning[i] = true;\
+  }\
+}
+
+#define TOTEM_WARN_1_SETTER_UNIMPLEMENTED(i, T) \
+{\
+  static bool logWarning;\
+  if (!logWarning) {\
+    D ("WARNING: setter for property %s::%s is unimplemented", #T, propertyNames[i]);\
+    logWarning = true;\
+  }\
+}
+
+#endif /* __TOTEM_NPOBJECT_H__ */

Added: trunk/browser-plugin/totemNPObjectWrapper.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemNPObjectWrapper.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,124 @@
+/*
+ * Copyright  2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __TOTEM_NPOBJECT_WRAPPER_H__
+#define __TOTEM_NPOBJECT_WRAPPER_H__
+
+#include <npapi.h>
+#include <npruntime.h>
+
+#include <assert.h>
+
+class totemNPObjectWrapper {
+
+  public:
+
+    totemNPObjectWrapper () : mObject (0) { }
+    totemNPObjectWrapper (NPObject *aObject) : mObject (aObject) { } /* adopts */
+    totemNPObjectWrapper (const totemNPObjectWrapper& aOther) { Assign (aOther.mObject); }
+
+    ~totemNPObjectWrapper () { Assign (0); }
+
+    bool IsNull () const { return mObject == 0; }
+
+    totemNPObjectWrapper& operator= (NPObject *aObject) { Assign (aObject); return *this; }
+
+    operator void*() const { return reinterpret_cast<void*>(mObject); }
+    operator NPObject*() const { return mObject; }
+    NPObject* operator->() const { assert (!IsNull ()); return mObject; }
+
+    class GetterRetains {
+      public:
+       explicit GetterRetains (totemNPObjectWrapper& aTarget) : mTarget (aTarget) { VOID_TO_NPVARIANT (mVariant); }
+        ~GetterRetains () {
+          if (!NPVARIANT_IS_VOID (mVariant)) {
+            if (NPVARIANT_IS_OBJECT (mVariant)) {
+              mTarget = NPVARIANT_TO_OBJECT (mVariant);
+            }
+            NPN_ReleaseVariantValue (&mVariant);
+          }
+       }
+
+       operator void**() { return reinterpret_cast<void**> (mTarget.StartAssignment ()); } // FIXMEchpe this looks wrong...
+       operator NPObject**() { return mTarget.StartAssignment (); }
+       operator NPVariant*() { return &mVariant; }
+
+       /* NPN_GetValue uses void* which is broken */
+       operator void*() { return reinterpret_cast<void*> (mTarget.StartAssignment ()); }
+
+      private:
+        totemNPObjectWrapper& mTarget;
+        NPVariant mVariant;
+    };
+
+    class AlreadyRetained {
+      public:
+        explicit AlreadyRetained (NPObject *aObject) : mObject (aObject) { }
+        ~AlreadyRetained () { }
+
+        NPObject *Get () const { return mObject; }
+      private:
+        NPObject *mObject;
+    };
+
+    totemNPObjectWrapper& operator= (const AlreadyRetained& aRetainer) { Adopt (aRetainer.Get()); return *this; }
+
+  protected:
+
+    totemNPObjectWrapper& operator= (const totemNPObjectWrapper&); // not implemented
+
+    void Assign (NPObject *aObject) {
+      if (mObject) {
+        NPN_ReleaseObject (mObject);
+      }
+
+      mObject = aObject;
+      if (mObject) {
+        NPN_RetainObject (mObject);
+      }
+    }
+
+    void Adopt (NPObject *aObject) {
+      if (mObject) {
+        NPN_ReleaseObject (mObject);
+      }
+
+      mObject = aObject;
+    }
+
+    NPObject** StartAssignment () { Assign (0); return &mObject; }
+
+    NPObject *mObject;
+};
+
+inline totemNPObjectWrapper::GetterRetains
+getter_Retains (totemNPObjectWrapper &aTarget)
+{
+  return totemNPObjectWrapper::GetterRetains (aTarget);
+}
+
+inline totemNPObjectWrapper::AlreadyRetained
+do_CreateInstance (totemNPClass_base* aClass, NPP aNPP)
+{
+  assert (aClass);
+  assert (aNPP);
+  return totemNPObjectWrapper::AlreadyRetained (aClass->CreateInstance (aNPP));
+}
+
+#endif /* __TOTEM_NPOBJECT_WRAPPER_H__ */

Added: trunk/browser-plugin/totemNPVariantWrapper.h
==============================================================================
--- (empty file)
+++ trunk/browser-plugin/totemNPVariantWrapper.h	Fri May 30 17:35:08 2008
@@ -0,0 +1,112 @@
+/*
+ * Copyright  2008 Christian Persch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __TOTEM_NPVARIANT_WRAPPER_H__
+#define __TOTEM_NPVARIANT_WRAPPER_H__
+
+#include <assert.h>
+#include <string.h>
+
+#include "npapi.h"
+#include "npruntime.h"
+
+class totemNPVariantWrapper {
+
+  public:
+
+    totemNPVariantWrapper ()                  : mOwned (false) { VOID_TO_NPVARIANT (mVariant); }
+    totemNPVariantWrapper (bool aValue)       : mOwned (false) { BOOLEAN_TO_NPVARIANT (aValue, mVariant); }
+    totemNPVariantWrapper (uint32_t aValue)   : mOwned (false) { INT32_TO_NPVARIANT (aValue, mVariant);   }
+    totemNPVariantWrapper (double aValue)     : mOwned (false) { DOUBLE_TO_NPVARIANT (aValue, mVariant);  }
+    totemNPVariantWrapper (char *aValue)      : mOwned (false) { STRINGZ_TO_NPVARIANT (aValue, mVariant); }
+//     totemNPVariantWrapper (NPString *aValue)  : mOwned (false) { STRINGN_TO_NPVARIANT (aValue, mVariant); }
+    totemNPVariantWrapper (NPObject *aObject) : mOwned (false) { OBJECT_TO_NPVARIANT (aObject, mVariant); }
+
+    totemNPVariantWrapper (const totemNPVariantWrapper& aOther) : mVariant (aOther.mVariant), mOwned (false) { }
+
+    ~totemNPVariantWrapper () { Clear (); }
+
+    bool IsVoid    () const { return NPVARIANT_IS_VOID (mVariant);    }
+    bool IsNull    () const { return NPVARIANT_IS_NULL (mVariant);    }
+    bool IsBoolean () const { return NPVARIANT_IS_BOOLEAN (mVariant); }
+    bool IsInt32   () const { return NPVARIANT_IS_INT32 (mVariant);   }
+    bool IsDouble  () const { return NPVARIANT_IS_DOUBLE (mVariant);  }
+    bool IsString  () const { return NPVARIANT_IS_STRING (mVariant);  }
+    bool IsObject  () const { return NPVARIANT_IS_OBJECT (mVariant);  }
+
+    bool      GetBoolean  () const { return NPVARIANT_TO_BOOLEAN (mVariant); }
+    uint32_t  GetInt32    () const { return NPVARIANT_TO_INT32 (mVariant);   }
+    double    GetDouble   () const { return NPVARIANT_TO_DOUBLE (mVariant);  }
+    char *    GetString   () const { return (char *) NPVARIANT_TO_STRING (mVariant).UTF8Characters;  }
+    NPString  GetNPString () const { return NPVARIANT_TO_STRING (mVariant);  }
+    NPObject* GetObject   () const { return NPVARIANT_TO_OBJECT (mVariant);  }
+
+    void SetVoid    ()                  { Clear (); VOID_TO_NPVARIANT (mVariant);            }
+    void SetNull    ()                  { Clear (); NULL_TO_NPVARIANT (mVariant);            }
+    void SetBoolean (bool aValue)       { Clear (); BOOLEAN_TO_NPVARIANT (aValue, mVariant); }
+    void SetInt32   (uint32_t aValue)   { Clear (); INT32_TO_NPVARIANT (aValue, mVariant);   }
+    void SetDouble  (double aValue)     { Clear (); DOUBLE_TO_NPVARIANT (aValue, mVariant);  }
+    void SetString  (char *aValue)      { Clear (); STRINGZ_TO_NPVARIANT (aValue, mVariant); }
+//     void SetString  (NPString *aValue)  { Clear (); STRINGN_TO_NPVARIANT (aValue, mVariant); }
+    void SetObject  (NPObject *aObject) { Clear (); OBJECT_TO_NPVARIANT (aObject, mVariant); }
+
+    operator char*     () { return GetString   (); }
+    operator NPString  () { return GetNPString (); }
+    operator NPObject* () { return GetObject   (); }
+
+    operator NPVariant*() { return &mVariant; }
+    
+    class GetterCopies {
+      public:
+       explicit GetterCopies (totemNPVariantWrapper& aTarget) : mTarget (aTarget) { }
+        ~GetterCopies () { }
+
+       operator NPVariant*() { return mTarget.StartAssignment (); }
+
+      private:
+        totemNPVariantWrapper& mTarget;
+    };
+
+  private:
+
+    totemNPVariantWrapper& operator= (const totemNPVariantWrapper&); // not implemented
+
+    void Clear () {
+      if (mOwned) {
+        NPN_ReleaseVariantValue (&mVariant);
+        mOwned = false;
+      } else {
+        VOID_TO_NPVARIANT (mVariant);
+      }
+    }
+
+    NPVariant* StartAssignment () { Clear (); mOwned = true; return &mVariant; }
+
+  protected:
+    NPVariant mVariant;
+    bool mOwned;
+};
+
+inline totemNPVariantWrapper::GetterCopies
+getter_Copies (totemNPVariantWrapper &aTarget)
+{
+  return totemNPVariantWrapper::GetterCopies (aTarget);
+}
+
+#endif /* __TOTEM_NPVARIANT_WRAPPER_H__ */

Modified: trunk/browser-plugin/totemNarrowSpacePlugin.cpp
==============================================================================
--- trunk/browser-plugin/totemNarrowSpacePlugin.cpp	(original)
+++ trunk/browser-plugin/totemNarrowSpacePlugin.cpp	Fri May 30 17:35:08 2008
@@ -1,8 +1,8 @@
-/* Totem Basic Plugin
+/* Totem NarrowSpace Plugin
  *
- * Copyright (C) 2004 Bastien Nocera <hadess hadess net>
- * Copyright (C) 2002 David A. Schleef <ds schleef org>
- * Copyright (C) 2006 Christian Persch
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -18,975 +18,523 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id$
  */
 
-#include <mozilla-config.h>
-#include "config.h"
-
-#include <glib.h>
-
-#include <nsIProgrammingLanguage.h>
-#include <nsISupportsImpl.h>
-#include <nsMemory.h>
-#include <nsXPCOM.h>
-
-#define GNOME_ENABLE_DEBUG 1
-/* define GNOME_ENABLE_DEBUG for more debug spew */
-#include "debug.h"
-
-#include "totemDebug.h"
-#include "totemClassInfo.h"
+#include <config.h>
 
 #include "totemNarrowSpacePlugin.h"
+#include "totemPlugin.h"
 
-/* 2e390ee1-f0e3-423c-9764-f5ab50a40c06 */
-static const nsCID kClassID = 
-{ 0x2e390ee1, 0xf0e3, 0x423c, \
-  { 0x97, 0x64, 0xf5, 0xab, 0x50, 0xa4, 0x0c, 0x06 } };
-
-static const char kClassDescription[] = "totemNarrowSpacePlugin";
-#define QUICKTIME_VERSION "7.2.0"
-static const char kPluginDescription[] = "QuickTime Plug-in "QUICKTIME_VERSION;
-
-static const totemPluginMimeEntry kMimeTypes[] = {
-	{ "video/quicktime", "mov", NULL },
-	{ "video/mp4", "mp4", NULL },
-	{ "image/x-macpaint", "pntg", NULL },
-	{ "image/x-quicktime", "pict, pict1, pict2", "image/x-pict" },
-	{ "video/x-m4v", "m4v", NULL },
+static const char *methodNames[] = {
+  "GetAutoPlay",
+  "GetBgColor",
+  "GetComponentVersion",
+  "GetControllerVisible",
+  "GetDuration",
+  "GetEndTime",
+  "GetFieldOfView",
+  "GetHotpotTarget",
+  "GetHotpotUrl",
+  "GetHREF",
+  "GetIsLooping",
+  "GetIsQuickTimeRegistered",
+  "GetIsVRMovie",
+  "GetKioskMode",
+  "GetLanguage",
+  "GetLoopIsPalindrome",
+  "GetMatrix",
+  "GetMaxBytesLoaded",
+  "GetMaxTimeLoaded",
+  "GetMIMEType",
+  "GetMovieID",
+  "GetMovieName",
+  "GetMovieSize",
+  "GetMute",
+  "GetNodeCount",
+  "GetNodeID",
+  "GetPanAngle",
+  "GetPlayEveryFrame",
+  "GetPluginStatus",
+  "GetPluginVersion",
+  "GetQTNextUrl",
+  "GetQuickTimeConnectionSpeed",
+  "GetQuickTimeLanguage",
+  "GetQuickTimeVersion",
+  "GetRate",
+  "GetRectangle",
+  "GetResetPropertiesOnReload",
+  "GetSpriteTrackVariable",
+  "GetStartTime",
+  "GetTarget",
+  "GetTiltAngle",
+  "GetTime",
+  "GetTimeScale",
+  "GetTrackCount"
+  "GetTrackEnabled",
+  "GetTrackName",
+  "GetTrackType",
+  "GetURL",
+  "GetUserData",
+  "GetVolume",
+  "GoPreviousNode",
+  "Play",
+  "Rewind",
+  "SetAutoPlay",
+  "SetBgColor",
+  "SetControllerVisible",
+  "SetEndTime",
+  "SetFieldOfView",
+  "SetHotpotTarget",
+  "SetHotpotUrl",
+  "SetHREF",
+  "SetIsLooping",
+  "SetKioskMode",
+  "SetLanguage",
+  "SetLoopIsPalindrome",
+  "SetMatrix",
+  "SetMovieID",
+  "SetMovieName",
+  "SetMute",
+  "SetNodeID",
+  "SetPanAngle",
+  "SetPlayEveryFrame",
+  "SetQTNextUrl",
+  "SetRate",
+  "SetRectangle",
+  "SetResetPropertiesOnReload",
+  "SetSpriteTrackVariable",
+  "SetStartTime",
+  "SetTarget",
+  "SetTiltAngle",
+  "SetTime",
+  "SetTrackEnabled",
+  "SetURL",
+  "SetVolume",
+  "ShowDefaultView",
+  "Step",
+  "Stop"
 };
 
-void*
-totemScriptablePlugin::operator new (size_t aSize) CPP_THROW_NEW
-{
-  void *object = ::operator new (aSize);
-  if (object) {
-    memset (object, 0, aSize);
-  }
-
-  return object;
-}
-
-totemScriptablePlugin::totemScriptablePlugin (totemPlugin *aPlugin)
-  : mPluginState(eState_Waiting),
-    mPlugin(aPlugin)
-{
-  D ("%s ctor [%p]", kClassDescription, (void*) this);
-}
-
-totemScriptablePlugin::~totemScriptablePlugin ()
-{
-  D ("%s dtor [%p]", kClassDescription, (void*) this);
-}
-
-/* static */ char *
-totemScriptablePlugin::PluginDescription ()
-{
-  return (char*) kPluginDescription;
-}
-
-/* static */ char *
-totemScriptablePlugin::PluginLongDescription ()
-{
-  return (char*) totem_plugin_get_long_description();
-}
-
-/* static */ void
-totemScriptablePlugin::PluginMimeTypes (const totemPluginMimeEntry **_entries,
-					PRUint32 *_count)
-{
-  *_entries = kMimeTypes;
-  *_count = G_N_ELEMENTS (kMimeTypes);
-}
-
-/* Interface implementations */
-
-NS_IMPL_ISUPPORTS2 (totemScriptablePlugin,
-		    totemINarrowSpacePlayer,
-		    nsIClassInfo)
-
-/* nsIClassInfo */
-
-TOTEM_CLASSINFO_BEGIN (totemScriptablePlugin,
-		       1,
-		       kClassID,
-		       kClassDescription)
-  TOTEM_CLASSINFO_ENTRY (0, totemINarrowSpacePlayer)
-TOTEM_CLASSINFO_END
-
-/* totemINarrowSpacePlayer */
-
-#define TOTEM_SCRIPTABLE_INTERFACE "totemINarrowSpacePlayer"
-
-/* boolean GetAutoPlay (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetAutoPlay(PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  *_retval = mAutoPlay;
-  return NS_OK;
-}
-
-/* void SetAutoPlay (in boolean enabled); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetAutoPlay(PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  mAutoPlay = enabled != PR_FALSE;
-  return NS_OK;
-}
-
-/* ACString GetBgColor (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetBgColor(nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  _retval.Assign (mBackgroundColour);
-  return NS_OK;
-}
-
-/* void SetBgColor (in ACString colour); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetBgColor(const nsACString & colour)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  mBackgroundColour = colour;
-  return NS_OK;
-}
-
-/* ACString GetComponentVersion (in ACString type, in ACString subtype, in ACString vendor); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetComponentVersion (const nsACString & type,
-					    const nsACString & subtype,
-					    const nsACString & vendor,
-					    nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED ();
-  D ("GetComponentVersion [%s, %s, %s]",
-     nsCString(type).get(),
-     nsCString(subtype).get(),
-     nsCString(vendor).get());
-
-  _retval.Assign ("1.0");
-  return NS_OK;
-}
-
-/* boolean GetControllerVisible (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetControllerVisible(PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-  *_retval = mControllerVisible;
-  return NS_OK;
-}
-
-/* void SetControllerVisible (in boolean enabled); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetControllerVisible(PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  mControllerVisible = enabled != PR_FALSE;
-  return NS_OK;
-}
-
-/* unsigned long GetDuration (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetDuration(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  NS_ENSURE_STATE (IsValid());
-  *_retval = mPlugin->mDuration;
-  return NS_OK;
-}
-
-/* unsigned long GetEndTime (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetEndTime(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  *_retval = 0;
-  return NS_OK;
-}
-
-/* void SetEndTime (in unsigned long time); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetEndTime(PRUint32 time)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* float GetFieldOfView (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetFieldOfView (float *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* void SetFieldOfView (in float angle); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetFieldOfView(float angle)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* void GoPreviousNode (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GoPreviousNode()
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* AUTF8String GetHotspotTarget (in unsigned long id); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetHotspotTarget(PRUint32 id, nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* void SetHotspotTarget (in unsigned long id, in AUTF8String target); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetHotspotTarget(PRUint32 id, const nsACString & target)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* AUTF8String GetHotspotUrl (in unsigned long id); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetHotspotUrl(PRUint32 id, nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* void SetHotspotUrl (in unsigned long id, in AUTF8String url); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetHotspotUrl(PRUint32 id, const nsACString & url)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* AUTF8String GetHREF (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetHREF(nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* void SetHREF (in AUTF8String href); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetHREF(const nsACString & href)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* boolean GetIsLooping (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetIsLooping(PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  *_retval = mIsLooping;
-  return NS_OK;
-}
-
-/* void SetIsLooping (in boolean enabled); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetIsLooping(PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  mIsLooping = enabled != PR_FALSE;
-  return NS_OK;
-}
-
-/* boolean GetIsQuickTimeRegistered (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetIsQuickTimeRegistered(PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  *_retval = PR_FALSE;
-  return NS_OK;
-}
-
-/* boolean GetIsVRMovie (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetIsVRMovie(PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  *_retval = PR_FALSE;
-  return NS_OK;
-}
-
-/* boolean GetKioskMode (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetKioskMode(PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  *_retval = mKioskMode;
-  return NS_OK;
-}
-
-/* void SetKioskMode (in boolean enabled); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetKioskMode(PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  mKioskMode = enabled != PR_FALSE;
-  return NS_OK;
-}
-
-/* ACString GetLanguage (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetLanguage(nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  _retval.Assign ("English");
-  return NS_OK;
-}
-
-/* void SetLanguage (in ACString language); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetLanguage(const nsACString & language)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* boolean GetLoopIsPalindrome (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetLoopIsPalindrome(PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  *_retval = mLoopIsPalindrome;
-  return NS_OK;
-}
-
-/* void SetLoopIsPalindrome (in boolean enabled); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetLoopIsPalindrome(PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  mLoopIsPalindrome = enabled != PR_FALSE;
-  return NS_OK;
-}
-
-/* ACString GetMatrix (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetMatrix(nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  _retval.Assign (mMatrix);
-  return NS_OK;
-}
-
-/* void SetMatrix (in ACString matrix); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetMatrix(const nsACString & matrix)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  mMatrix = matrix;
-  return NS_OK;
-}
-
-/* unsigned long GetMaxBytesLoaded (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetMaxBytesLoaded(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  NS_ENSURE_STATE (IsValid());
-  *_retval = mPlugin->mBytesStreamed;
-  return NS_OK;
-}
-
-/* unsigned long GetMaxTimeLoaded (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetMaxTimeLoaded(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* ACString GetMIMEType (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetMIMEType(nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  _retval.Assign ("video/quicktime");
-  return NS_OK;
-}
-
-/* unsigned long GetMovieID (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetMovieID(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* void SetMovieID (in unsigned long id); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetMovieID(PRUint32 id)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* AUTF8String GetMovieName (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetMovieName(nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  _retval.Assign (mMovieName);
-  return NS_OK;
-}
-
-/* void SetMovieName (in AUTF8String name); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetMovieName(const nsACString & name)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  mMovieName = name;
-  return NS_OK;
-}
-
-/* unsigned long GetMovieSize (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetMovieSize(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  NS_ENSURE_STATE (IsValid());
-  *_retval = mPlugin->mBytesLength;
-  return NS_OK;
-}
-
-/* boolean GetMute (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetMute(PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  *_retval = mMute;
-  return NS_OK;
-}
-
-/* void SetMute (in boolean enabled); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetMute(PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  mMute = enabled != PR_FALSE;
-  return NS_OK;
-}
-
-/* unsigned long GetNodeCount (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetNodeCount(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* unsigned long GetNodeID (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetNodeID(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* void SetNodeID (in unsigned long id); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetNodeID(PRUint32 id)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* float GetPanAngle (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetPanAngle(float *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* void SetPanAngle (in float angle); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetPanAngle(float angle)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* void Play (); */
-NS_IMETHODIMP
-totemScriptablePlugin::Play ()
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  NS_ENSURE_STATE (IsValid ());
-
-  return mPlugin->DoCommand (TOTEM_COMMAND_PLAY);
-}
-
-/* boolean GetPlayEveryFrame (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetPlayEveryFrame(PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  *_retval = mPlayEveryFrame;
-  return NS_OK;
-}
-
-/* void SetPlayEveryFrame (in boolean enabled); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetPlayEveryFrame(PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  mPlayEveryFrame = enabled != PR_FALSE;
-  return NS_OK;
-}
-
-/* ACString GetPluginStatus (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetPluginStatus(nsACString & _retval)
-{
-  static const char *kState[] = {
-    "Complete",
-    "Error:<%d>",
-    "Loading",
-    "Playable",
-    "Waiting"
-  };
-
-  if (mPluginState != eState_Error) {
-    _retval.Assign (kState[mPluginState]);
-  } else {
-    /* FIXME */
-    _retval.Assign ("Error:<1>");
-  }
-  return NS_OK;
-}
-
-/* ACString GetPluginVersion (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetPluginVersion(nsACString & _retval)
-{
-  _retval.Assign (QUICKTIME_VERSION);
-  return NS_OK;
-}
-
-/* AUTF8String GetQTNEXTUrl (in unsigned long index); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetQTNEXTUrl (PRUint32 index,
-				     nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* void SetQTNEXTUrl (in unsigned long index, in AUTF8String url); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetQTNEXTUrl (PRUint32 index,
-				     const nsACString & url)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* unsigned long GetQuickTimeConnectionSpeed (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetQuickTimeConnectionSpeed(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  *_retval = 300000; /* FIXME */
-  return NS_OK;
-}
-
-/* ACString GetQuickTimeLanguage (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetQuickTimeLanguage(nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  _retval.Assign ("English"); /* FIXME */
-  return NS_OK;
-}
-
-/* ACString GetQuickTimeVersion (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetQuickTimeVersion(nsACString & _retval)
-{
-  _retval.Assign (QUICKTIME_VERSION);
-  return NS_OK;
-}
-
-/* float GetRate (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetRate(float *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  NS_ENSURE_STATE (IsValid());
-
-  if (mPlugin->mState == TOTEM_STATE_PLAYING) {
-    *_retval = 1.0;
-  } else {
-    *_retval = 0.0;
+TOTEM_IMPLEMENT_NPCLASS (totemNarrowSpacePlayer,
+                         NULL, 0,
+                         methodNames, G_N_ELEMENTS (methodNames),
+                         NULL);
+
+totemNarrowSpacePlayer::totemNarrowSpacePlayer (NPP aNPP)
+  : totemNPObject (aNPP),
+    mPluginState (eState_Waiting)
+{
+  TOTEM_LOG_CTOR ();
+}
+
+totemNarrowSpacePlayer::~totemNarrowSpacePlayer ()
+{
+  TOTEM_LOG_DTOR ();
+}
+
+bool
+totemNarrowSpacePlayer::InvokeByIndex (int aIndex,
+                                       const NPVariant *argv,
+                                       uint32_t argc,
+                                       NPVariant *_result)
+{
+  TOTEM_LOG_INVOKE (aIndex, totemNarrowSpacePlayer);
+
+  switch (Methods (aIndex)) {
+    case ePlay:
+      /* void Play (); */
+      Plugin()->Command (TOTEM_COMMAND_PLAY);
+      return VoidVariant (_result);
+
+    case eStop:
+      /* void Stop (); */
+      Plugin()->Command (TOTEM_COMMAND_STOP);
+      return VoidVariant (_result);
+
+    case eRewind:
+      /* void Rewind (); */
+      Plugin()->Command (TOTEM_COMMAND_PAUSE);
+      return VoidVariant (_result);
+
+    case eGetMaxBytesLoaded:
+      /* unsigned long GetMaxBytesLoaded (); */
+      return Int32Variant (_result, Plugin()->BytesStreamed());
+
+    case eGetMovieSize:
+      /* unsigned long GetMovieSize (); */
+      return Int32Variant (_result, Plugin()->BytesLength());
+
+    case eGetAutoPlay:
+      /* boolean GetAutoPlay (); */
+      return BoolVariant (_result, Plugin()->AutoPlay());
+
+    case eGetControllerVisible:
+      /* boolean GetControllerVisible (); */
+      return BoolVariant (_result, Plugin()->IsControllerVisible());
+
+    case eGetIsLooping:
+      /* boolean GetIsLooping (); */
+      return BoolVariant (_result, Plugin()->IsLooping());
+
+    case eGetKioskMode:
+      /* boolean GetKioskMode (); */
+      return BoolVariant (_result, Plugin()->IsKioskMode());
+
+    case eGetLoopIsPalindrome:
+      /* boolean GetLoopIsPalindrome (); */
+      return BoolVariant (_result, Plugin()->IsLoopPalindrome());
+
+    case eGetMute:
+      /* boolean GetMute (); */
+      return BoolVariant (_result, Plugin()->IsMute());
+
+    case eGetPlayEveryFrame:
+      /* boolean GetPlayEveryFrame (); */
+      return BoolVariant (_result, Plugin()->PlayEveryFrame());
+
+    case eSetAutoPlay: {
+      /* void SetAutoPlay (in boolean autoPlay); */
+      bool enabled;
+      if (!GetBoolFromArguments (argv, argc, 0, enabled))
+        return false;
+
+      Plugin()->SetAutoPlay (enabled);
+      return VoidVariant (_result);
+    }
+
+    case eSetControllerVisible: {
+      /* void SetControllerVisible (in boolean visible); */
+      bool enabled;
+      if (!GetBoolFromArguments (argv, argc, 0, enabled))
+        return false;
+
+      Plugin()->SetControllerVisible (enabled);
+      return VoidVariant (_result);
+    }
+
+    case eSetIsLooping: {
+      /* void SetIsLooping (in boolean loop); */
+      bool enabled;
+      if (!GetBoolFromArguments (argv, argc, 0, enabled))
+        return false;
+
+      Plugin()->SetLooping (enabled);
+      return VoidVariant (_result);
+    }
+
+    case eSetKioskMode: {
+      /* void SetKioskMode (in boolean kioskMode); */
+      bool enabled;
+      if (!GetBoolFromArguments (argv, argc, 0, enabled))
+        return false;
+
+      Plugin()->SetKioskMode (enabled);
+      return VoidVariant (_result);
+    }
+
+    case eSetLoopIsPalindrome: {
+      /* void SetLoopIsPalindrome (in boolean loop); */
+      bool enabled;
+      if (!GetBoolFromArguments (argv, argc, 0, enabled))
+        return false;
+
+      Plugin()->SetLoopIsPalindrome (enabled);
+      return VoidVariant (_result);
+    }
+
+    case eSetMute: {
+      /* void SetMute (in boolean mute); */
+      bool enabled;
+      if (!GetBoolFromArguments (argv, argc, 0, enabled))
+        return false;
+
+      Plugin()->SetMute (enabled);
+      return VoidVariant (_result);
+    }
+
+    case eSetPlayEveryFrame: {
+      /* void SetPlayEveryFrame (in boolean playAll); */
+      bool enabled;
+      if (!GetBoolFromArguments (argv, argc, 0, enabled))
+        return false;
+
+      Plugin()->SetPlayEveryFrame (enabled);
+      return VoidVariant (_result);
+    }
+
+    case eGetVolume:
+      /* unsigned long GetVolume (); */
+      return Int32Variant (_result, Plugin()->Volume() * 255.0);
+
+    case eSetVolume: {
+      /* void SetVolume (in unsigned long volume); */
+      int32_t volume;
+      if (!GetInt32FromArguments (argv, argc, 0, volume))
+        return false;
+
+      Plugin()->SetVolume ((double) CLAMP (volume, 0, 255) / 255.0);
+      return VoidVariant (_result);
+    }
+
+    case eGetBgColor: {
+      /* ACString GetBgColor (); */
+      const char *color = Plugin()->BackgroundColor();
+      if (color)
+        return StringVariant (_result, color);
+
+      return StringVariant (_result, "#000000");
+    }
+      
+    case eSetBgColor: {
+      /* void SetBgColor (in ACString color); */
+      const char *color;
+      if (!GetStringFromArguments (argv, argc, 0, color))
+        return false;
+
+      Plugin()->SetBackgroundColor (color);
+      return VoidVariant (_result);
+    }
+
+    case eGetDuration:
+      /* unsigned long GetDuration (); */
+      return Int32Variant (_result, Plugin()->Duration());
+
+    case eGetStartTime:
+      /* unsigned long GetStartTime (); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex, totemNarrowSpacePlayer);
+      return Int32Variant (_result, 0); /* FIXME */
+
+    case eGetTime:
+      /* unsigned long GetTime (); */
+      return Int32Variant (_result, Plugin()->Time());
+
+    case eGetEndTime:
+      /* unsigned long GetEndTime (); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex, totemNarrowSpacePlayer);
+      return Int32Variant (_result, 0);
+
+    case eGetTimeScale:
+      /* unsigned long GetTimeScale (); */
+      return Int32Variant (_result, 1000); /* FIXME? */
+
+    case eGetRate:
+      /* float GetRate (); */
+      return DoubleVariant (_result, Plugin()->Rate());
+
+    case eSetRate: {
+      /* void SetRate (in float rate); */
+      double rate;
+      if (!GetDoubleFromArguments (argv, argc, 0, rate))
+        return false;
+
+      Plugin()->SetRate (rate);
+      return VoidVariant (_result);
+    }
+
+    case eGetLanguage:
+      /* ACString GetLanguage (); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex, totemNarrowSpacePlayer);
+      return StringVariant (_result, "English");
+
+    case eGetComponentVersion:
+      /* ACString GetComponentVersion (in ACString type, in ACString subType, in ACString manufacturer); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex, totemNarrowSpacePlayer);
+      return StringVariant (_result, "1.0");
+
+    case eGetIsQuickTimeRegistered:
+      /* boolean GetIsQuickTimeRegistered (); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex, totemNarrowSpacePlayer);
+    case eGetIsVRMovie:
+      /* boolean GetIsVRMovie (); */
+      return BoolVariant (_result, false);
+
+    case eGetMIMEType:
+      /* ACString GetMIMEType (); */
+      return StringVariant (_result, "video/quicktime");
+
+    case eGetMatrix:
+      /* ACString GetMatrix (); */
+      return StringVariant (_result, Plugin()->Matrix());
+
+    case eSetMatrix: {
+      /* void SetMatrix (in ACString matrix); */
+      const char *matrix;
+      if (!GetStringFromArguments (argv, argc, 0, matrix))
+        return false;
+
+      Plugin()->SetMatrix (matrix);
+      return VoidVariant (_result);
+    }
+
+    case eGetMovieName:
+      /* AUTF8String GetMovieName (); */
+      return StringVariant (_result, Plugin()->MovieName());
+
+    case eSetMovieName: {
+      /* void SetMovieName (in AUTF8String movieName); */
+      const char *name;
+      if (!GetStringFromArguments (argv, argc, 0, name))
+        return false;
+
+      Plugin()->SetMovieName (name);
+      return VoidVariant (_result);
+    }
+
+    case eGetRectangle:
+      /* ACString GetRectangle (); */
+      return StringVariant (_result, Plugin()->Rectangle());
+
+    case eSetRectangle: {
+      /* void SetRectangle (in ACString rect); */
+      const char *rectangle;
+      if (!GetStringFromArguments (argv, argc, 0, rectangle))
+        return false;
+
+      Plugin()->SetRectangle (rectangle);
+      return VoidVariant (_result);
+    }
+
+    case eGetPluginStatus: {
+      return true;
+#if 0
+      /* ACString GetPluginStatus (); */
+      static const char *kState[] = {
+        "Complete",
+        NULL, /* "Error:<%d>", */
+        "Loading",
+        "Playable",
+        "Waiting"
+      };
+
+      if (Plugin()->State() == eState_Error)
+        return StringVariant (_result, "Error:<1>");
+
+      return StringVariant (_result, kState[Plugin()->State()]);
+#endif
+    }
+
+    case eGetTrackCount:
+      /* unsigned long GetTrackCount (); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex, totemNarrowSpacePlayer);
+      return Int32Variant (_result, 1);
+
+    case eGetTrackEnabled:
+      /* boolean GetTrackEnabled (in unsigned long index); */
+      TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex, totemNarrowSpacePlayer);
+      return BoolVariant (_result, true);
+
+    case eGetPluginVersion:
+      /* ACString GetPluginVersion (); */
+    case eGetQuickTimeVersion:
+      /* ACString GetQuickTimeVersion (); */
+      return StringVariant (_result, TOTEM_NARROWSPACE_VERSION);
+
+    case eGetQuickTimeConnectionSpeed:
+      /* unsigned long GetQuickTimeConnectionSpeed (); */
+      return Int32Variant (_result, Plugin()->Bandwidth());
+
+    case eGetResetPropertiesOnReload:
+      /* boolean GetResetPropertiesOnReload (); */
+      return BoolVariant (_result, Plugin()->ResetPropertiesOnReload());
+
+    case eSetResetPropertiesOnReload: {
+      /* void SetResetPropertiesOnReload (in boolean reset); */
+      bool enabled;
+      if (!GetBoolFromArguments (argv, argc, 0, enabled))
+        return false;
+
+      Plugin()->SetResetPropertiesOnReload (enabled);
+      return VoidVariant (_result);
+    }
+
+    case eGetMaxTimeLoaded:
+      /* unsigned long GetMaxTimeLoaded (); */
+    case eGetMovieID:
+      /* unsigned long GetMovieID (); */
+    case eGetNodeCount:
+      /* unsigned long GetNodeCount (); */
+    case eGetNodeID:
+      /* unsigned long GetNodeID (); */
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemNarrowSpacePlayer);
+      return Int32Variant (_result, 0);
+
+    case eGetFieldOfView:
+      /* float GetFieldOfView (); */
+    case eGetPanAngle:
+      /* float GetPanAngle (); */
+    case eGetTiltAngle:
+      /* float GetTiltAngle (); */
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemNarrowSpacePlayer);
+      return DoubleVariant (_result, 0.0);
+
+    case eGetTrackName:
+      /* AUTF8String GetTrackName (in unsigned long index); */
+    case eGetTrackType:
+      /* ACString GetTrackType (in unsigned long index); */
+    case eGetHotpotTarget:
+      /* AUTF8String GetHotspotTarget (in unsigned long hotspotID); */
+    case eGetHotpotUrl:
+      /* AUTF8String GetHotspotUrl (in unsigned long hotspotID); */
+    case eGetHREF:
+      /* AUTF8String GetHREF (); */
+    case eGetQTNextUrl:
+      /* AUTF8String GetQTNEXTUrl (in unsigned long index); */
+    case eGetQuickTimeLanguage:
+      /* ACString GetQuickTimeLanguage (); */
+    case eGetSpriteTrackVariable:
+      /* ACString GetSpriteTrackVariable (in unsigned long trackIndex, in unsigned long variableIndex); */
+    case eGetTarget:
+      /* AUTF8String GetTarget (); */
+    case eGetURL:
+      /* AUTF8String GetURL (); */
+    case eGetUserData:
+      /* AUTF8String GetUserData (in ACString type); */
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemNarrowSpacePlayer);
+      return StringVariant (_result, "");
+
+    case eGoPreviousNode:
+      /* void GoPreviousNode (); */
+    case eSetEndTime:
+      /* void SetEndTime (in unsigned long time); */
+    case eSetFieldOfView:
+      /* void SetFieldOfView (in float fov); */
+    case eSetHotpotTarget:
+      /* void SetHotspotTarget (in unsigned long hotspotID, in AUTF8String target); */
+    case eSetHotpotUrl:
+      /* void SetHotspotUrl (in unsigned long hotspotID, in AUTF8String url); */
+    case eSetHREF:
+      /* void SetHREF (in AUTF8String url); */
+    case eSetLanguage:
+      /* void SetLanguage (in ACString language); */
+    case eSetMovieID:
+      /* void SetMovieID (in unsigned long movieID); */
+    case eSetNodeID:
+      /* void SetNodeID (in unsigned long id); */
+    case eSetPanAngle:
+      /* void SetPanAngle (in float angle); */
+    case eSetQTNextUrl:
+      /* void SetQTNEXTUrl (in unsigned long index, in AUTF8String url); */
+    case eSetSpriteTrackVariable:
+      /* void SetSpriteTrackVariable (in unsigned long trackIndex, in unsigned long variableIndex, in ACString value); */
+    case eSetStartTime:
+      /* void SetStartTime (in unsigned long time); */
+    case eSetTarget:
+      /* void SetTarget (in AUTF8String target); */
+    case eSetTiltAngle:
+      /* void SetTiltAngle (in float angle); */
+    case eSetTime:
+      /* void SetTime (in unsigned long time); */
+    case eSetTrackEnabled:
+      /* void SetTrackEnabled (in unsigned long index, in boolean enabled); */
+    case eSetURL:
+      /* void SetURL (in AUTF8String url); */
+    case eStep:
+      /* void Step (in long count); */
+    case eShowDefaultView:
+      /* void ShowDefaultView (); */
+      TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemNarrowSpacePlayer);
+      return VoidVariant (_result);
   }
-  return NS_OK;
-}
-
-/* void SetRate (in float rate); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetRate(float rate)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  /* mRate = rate; FIXME */
-  return NS_OK;
-}
-
-/* void SetRectangle (in ACString rectangle); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetRectangle(const nsACString & rectangle)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
 
-  mRectangle = rectangle;
-  return NS_OK;
+  return false;
 }
-
-/* ACString GetRectangle (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetRectangle(nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  _retval.Assign (mRectangle);
-  return NS_OK;
-}
-
-/* boolean GetResetPropertiesOnReload (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetResetPropertiesOnReload(PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  *_retval = mResetPropertiesOnReload;
-  return NS_OK;
-}
-
-/* void SetResetPropertiesOnReload (in boolean enabled); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetResetPropertiesOnReload(PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  mResetPropertiesOnReload = enabled != PR_FALSE;
-  return NS_OK;
-}
-
-/* void Rewind (); */
-NS_IMETHODIMP
-totemScriptablePlugin::Rewind ()
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  NS_ENSURE_STATE (IsValid ());
-
-  return mPlugin->DoCommand (TOTEM_COMMAND_PAUSE);
-}
-
-/* void ShowDefaultView (); */
-NS_IMETHODIMP
-totemScriptablePlugin::ShowDefaultView()
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  return NS_OK;
-}
-
-/* ACString GetSpriteTrackVariable (in unsigned long track, in unsigned long index); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetSpriteTrackVariable (PRUint32 track,
-					       PRUint32 index,
-					       nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* void SetSpriteTrackVariable (in unsigned long track, in unsigned long index, in ACString value); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetSpriteTrackVariable (PRUint32 track,
-					       PRUint32 index,
-					       const nsACString & value)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* void SetStartTime (in unsigned long time); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetStartTime(PRUint32 time)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* unsigned long GetStartTime (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetStartTime (PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  *_retval = 0; /* FIXME */
-  return NS_OK;
-}
-
-/* void Step (in long steps); */
-NS_IMETHODIMP
-totemScriptablePlugin::Step(PRInt32 steps)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* void Stop (); */
-NS_IMETHODIMP
-totemScriptablePlugin::Stop ()
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  NS_ENSURE_STATE (IsValid ());
-
-  return mPlugin->DoCommand (TOTEM_COMMAND_PAUSE);
-}
-
-/* AUTF8String GetTarget (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetTarget(nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* void SetTarget (in AUTF8String target); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetTarget(const nsACString & target)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* float GetTiltAngle (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetTiltAngle(float *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* void SetTiltAngle (in float angle); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetTiltAngle(float angle)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-/* unsigned long GetTime (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetTime(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  *_retval = mPlugin->mTime;
-  return NS_OK;
-}
-
-/* void SetTime (in unsigned long time); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetTime(PRUint32 time)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* unsigned long GetTimeScale (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetTimeScale(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  *_retval = 1000;
-  return NS_OK;
-}
-
-/* unsigned long GetTrackCount (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetTrackCount(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  *_retval = 1;
-  return NS_OK;
-}
-
-/* boolean GetTrackEnabled (in unsigned long index); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetTrackEnabled (PRUint32 index,
-					PRBool *_retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  *_retval = PR_TRUE;
-  return NS_OK;
-}
-
-/* void SetTrackEnabled (in unsigned long index, in boolean enabled); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetTrackEnabled (PRUint32 index,
-					PRBool enabled)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* AUTF8String GetTrackName (in unsigned long index); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetTrackName (PRUint32 index,
-				     nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* AUTF8String GetTrackType (in unsigned long index); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetTrackType (PRUint32 index,
-				     nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* AUTF8String GetURL (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetURL (nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* void SetURL (in AUTF8String url); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetURL (const nsACString & url)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* AUTF8String GetUserData (in AUTF8String identifier); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetUserData  (const nsACString & identifier,
-				     nsACString & _retval)
-{
-  TOTEM_SCRIPTABLE_WARN_UNIMPLEMENTED();
-
-  return NS_OK;
-}
-
-/* unsigned long GetVolume (); */
-NS_IMETHODIMP
-totemScriptablePlugin::GetVolume(PRUint32 *_retval)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  NS_ENSURE_STATE (IsValid ());
-
-  *_retval = mPlugin->mVolume * 100.0;
-  return NS_OK;
-}
-
-/* void SetVolume (in unsigned long volume); */
-NS_IMETHODIMP
-totemScriptablePlugin::SetVolume(PRUint32 aVolume)
-{
-  TOTEM_SCRIPTABLE_LOG_ACCESS ();
-
-  NS_ENSURE_STATE (IsValid ());
-
-  nsresult rv = mPlugin->SetVolume ((double) aVolume / 100);
-
-  /* Volume passed in is 0 through to 100 */
-  mPlugin->mVolume = (double) aVolume / 100;
-
-  return rv;
-}
-

Modified: trunk/browser-plugin/totemNarrowSpacePlugin.h
==============================================================================
--- trunk/browser-plugin/totemNarrowSpacePlugin.h	(original)
+++ trunk/browser-plugin/totemNarrowSpacePlugin.h	Fri May 30 17:35:08 2008
@@ -1,7 +1,8 @@
 /* Totem NarrowSpace plugin scriptable
  *
- * Copyright (C) 2004 Bastien Nocera <hadess hadess net>
- * Copyright (C) 2002 David A. Schleef <ds schleef org>
+ * Copyright  2004 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -17,36 +18,19 @@
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301  USA.
- *
- * $Id$
  */
 
 #ifndef __NARROWSPACE_PLUGIN_H__
 #define __NARROWSPACE_PLUGIN_H__
 
-#include <nsIClassInfo.h>
-
-#include "totemINarrowSpacePlayer.h"
-#include "totemPlugin.h"
+#include "totemNPClass.h"
+#include "totemNPObject.h"
 
-class totemScriptablePlugin : public totemINarrowSpacePlayer,
-			      public nsIClassInfo
+class totemNarrowSpacePlayer : public totemNPObject
 {
   public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_TOTEMINARROWSPACEPLAYER
-    NS_DECL_NSICLASSINFO
-
-    void* operator new (size_t aSize) CPP_THROW_NEW;
-
-    totemScriptablePlugin (totemPlugin *aPlugin);
-
-    PRBool IsValid () { return mPlugin != nsnull; }
-    void SetPlugin (totemPlugin *aPlugin) { mPlugin = aPlugin; }
-
-    static char *PluginDescription ();
-    static char *PluginLongDescription();
-    static void PluginMimeTypes (const totemPluginMimeEntry **, PRUint32 *);
+    totemNarrowSpacePlayer (NPP);
+    virtual ~totemNarrowSpacePlayer ();
 
     enum PluginState {
       eState_Complete,
@@ -56,26 +40,103 @@
       eState_Waiting
     };
 
-    PRUint32 mPluginState : 3; /* enough bits for PluginState enum values */
+    PluginState mPluginState;
 
   private:
-    ~totemScriptablePlugin ();
 
-    totemPlugin *mPlugin;
+    enum Methods {
+      eGetAutoPlay,
+      eGetBgColor,
+      eGetComponentVersion,
+      eGetControllerVisible,
+      eGetDuration,
+      eGetEndTime,
+      eGetFieldOfView,
+      eGetHotpotTarget,
+      eGetHotpotUrl,
+      eGetHREF,
+      eGetIsLooping,
+      eGetIsQuickTimeRegistered,
+      eGetIsVRMovie,
+      eGetKioskMode,
+      eGetLanguage,
+      eGetLoopIsPalindrome,
+      eGetMatrix,
+      eGetMaxBytesLoaded,
+      eGetMaxTimeLoaded,
+      eGetMIMEType,
+      eGetMovieID,
+      eGetMovieName,
+      eGetMovieSize,
+      eGetMute,
+      eGetNodeCount,
+      eGetNodeID,
+      eGetPanAngle,
+      eGetPlayEveryFrame,
+      eGetPluginStatus,
+      eGetPluginVersion,
+      eGetQTNextUrl,
+      eGetQuickTimeConnectionSpeed,
+      eGetQuickTimeLanguage,
+      eGetQuickTimeVersion,
+      eGetRate,
+      eGetRectangle,
+      eGetResetPropertiesOnReload,
+      eGetSpriteTrackVariable,
+      eGetStartTime,
+      eGetTarget,
+      eGetTiltAngle,
+      eGetTime,
+      eGetTimeScale,
+      eGetTrackCount,
+      eGetTrackEnabled,
+      eGetTrackName,
+      eGetTrackType,
+      eGetURL,
+      eGetUserData,
+      eGetVolume,
+      eGoPreviousNode,
+      ePlay,
+      eRewind,
+      eSetAutoPlay,
+      eSetBgColor,
+      eSetControllerVisible,
+      eSetEndTime,
+      eSetFieldOfView,
+      eSetHotpotTarget,
+      eSetHotpotUrl,
+      eSetHREF,
+      eSetIsLooping,
+      eSetKioskMode,
+      eSetLanguage,
+      eSetLoopIsPalindrome,
+      eSetMatrix,
+      eSetMovieID,
+      eSetMovieName,
+      eSetMute,
+      eSetNodeID,
+      eSetPanAngle,
+      eSetPlayEveryFrame,
+      eSetQTNextUrl,
+      eSetRate,
+      eSetRectangle,
+      eSetResetPropertiesOnReload,
+      eSetSpriteTrackVariable,
+      eSetStartTime,
+      eSetTarget,
+      eSetTiltAngle,
+      eSetTime,
+      eSetTrackEnabled,
+      eSetURL,
+      eSetVolume,
+      eShowDefaultView,
+      eStep,
+      eStop
+    };
 
-    nsCString mBackgroundColour;
-    nsCString mMatrix;
-    nsCString mRectangle;
-    nsCString mMovieName;
-
-    PRUint32 mAutoPlay : 1;
-    PRUint32 mControllerVisible : 1;
-    PRUint32 mIsLooping : 1;
-    PRUint32 mKioskMode : 1;
-    PRUint32 mLoopIsPalindrome : 1;
-    PRUint32 mMute : 1;
-    PRUint32 mPlayEveryFrame : 1;
-    PRUint32 mResetPropertiesOnReload : 1;
+    virtual bool InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result);
 };
 
+TOTEM_DEFINE_NPCLASS (totemNarrowSpacePlayer);
+
 #endif /* __NARROWSPACE_PLUGIN_H__ */

Modified: trunk/browser-plugin/totemPlugin.cpp
==============================================================================
--- trunk/browser-plugin/totemPlugin.cpp	(original)
+++ trunk/browser-plugin/totemPlugin.cpp	Fri May 30 17:35:08 2008
@@ -2,7 +2,7 @@
  * 
  * Copyright  2004-2006 Bastien Nocera <hadess hadess net>
  * Copyright  2002 David A. Schleef <ds schleef org>
- * Copyright  2006, 2007 Christian Persch
+ * Copyright  2006, 2007, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -20,49 +20,29 @@
  * Boston, MA 02110-1301  USA.
  */
 
-#include <mozilla-config.h>
-#include "config.h"
+#include <config.h>
 
 #include <errno.h>
-#include <stdio.h>
+#include <fcntl.h>
 #include <stdint.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
-#include <fcntl.h>
-#include <sys/wait.h>
 #include <sys/poll.h>
-#include <string.h>
-#include <signal.h>
+#include <sys/wait.h>
 
 #include <glib.h>
 
 #include "totem-pl-parser-mini.h"
 #include "totem-plugin-viewer-options.h"
-#include "totempluginviewer-marshal.h"
+#include "marshal.h"
 
 #include "npapi.h"
+#include "npruntime.h"
 #include "npupp.h"
 
-#include <nsIDOMWindow.h>
-#include <nsIURI.h>
-#include <nsEmbedString.h>
-#include <nsIInterfaceRequestor.h>
-#include <nsIInterfaceRequestorUtils.h>
-#include <nsIWebNavigation.h>
-
-#include <nsIServiceManager.h>
-#include <nsIDOMDocument.h>
-#include <nsIDOMElement.h>
-#include <nsIDOM3Node.h>
-#include <nsIIOService.h>
-#include <nsITimer.h>
-#include <nsIComponentManager.h>
-#include <nsIProtocolHandler.h>
-#include <nsIExternalProtocolHandler.h>
-
-/* for NS_IOSERVICE_CONTRACTID */
-#include <nsNetCID.h>
-
-#define GNOME_ENABLE_DEBUG 1
 /* define GNOME_ENABLE_DEBUG for more debug spew */
 /* FIXME define D() so that it prints the |this| pointer, so we can differentiate between different concurrent plugins! */
 #include "debug.h"
@@ -74,15 +54,110 @@
 #define DD(args...)
 #endif
 
-#include "totemPluginGlue.h"
 #include "totemPlugin.h"
 
+#if defined(TOTEM_BASIC_PLUGIN)
+#include "totemBasicPlugin.h"
+#elif defined(TOTEM_GMP_PLUGIN)
+#include "totemGMPControls.h"
+#include "totemGMPNetwork.h"
+#include "totemGMPPlayer.h"
+#include "totemGMPSettings.h"
+#elif defined(TOTEM_COMPLEX_PLUGIN)
+#include "totemComplexPlayer.h"
+#elif defined(TOTEM_NARROWSPACE_PLUGIN)
+#include "totemNarrowSpacePlugin.h"
+#elif defined(TOTEM_MULLY_PLUGIN)
+#include "totemMullYPlugin.h"
+#elif defined(TOTEM_CONE_PLUGIN)
+#include "totemCone.h"
+#include "totemConeAudio.h"
+#include "totemConeInput.h"
+#include "totemConePlaylist.h"
+#include "totemConePlaylistItems.h"
+#include "totemConeVideo.h"
+#else
+#error Unknown plugin type
+#endif
+
 #define DASHES "--"
 
 /* How much data bytes to request */
 #define PLUGIN_STREAM_CHUNK_SIZE (8 * 1024)
 
-NPNetscapeFuncs totemPlugin::sNPN;
+static const totemPluginMimeEntry kMimeTypes[] = {
+#if defined(TOTEM_BASIC_PLUGIN)
+  { "application/x-ogg","ogg",NULL },
+  { "application/ogg", "ogg", NULL },
+  { "audio/ogg", "oga", NULL },
+  { "audio/x-ogg", "ogg", NULL },
+  { "video/ogg", "ogv", NULL },
+  { "video/x-ogg", "ogg", NULL },
+  { "application/annodex", "anx", NULL },
+  { "audio/annodex", "axa", NULL },
+  { "video/annodex", "axv", NULL },
+  { "video/mpeg", "mpg, mpeg, mpe", NULL },
+  { "audio/wav", "wav", NULL },
+  { "audio/x-wav", "wav", NULL },
+  { "audio/mpeg", "mp3", NULL },
+  { "application/x-nsv-vp3-mp3", "nsv", "video/x-nsv" },
+  { "video/flv", "flv", "application/x-flash-video" },
+  { "application/x-totem-plugin", "", "application/octet-stream" },
+#elif defined(TOTEM_GMP_PLUGIN)
+  { "application/x-mplayer2", "avi, wma, wmv", "video/x-msvideo" },
+  { "video/x-ms-asf-plugin", "asf, wmv", "video/x-ms-asf" },
+  { "video/x-msvideo", "asf, wmv", NULL },
+  { "video/x-ms-asf", "asf", NULL },
+  { "video/x-ms-wmv", "wmv", "video/x-ms-wmv" },
+  { "video/x-wmv", "wmv", "video/x-ms-wmv" },
+  { "video/x-ms-wvx", "wmv", "video/x-ms-wmv" },
+  { "video/x-ms-wm", "wmv", "video/x-ms-wmv" },
+  { "video/x-ms-wmp", "wmv", "video/x-ms-wmv" },
+  { "application/x-ms-wms", "wms", "video/x-ms-wmv" },
+  { "application/asx", "asx", "audio/x-ms-asx" },
+  { "audio/x-ms-wma", "wma", NULL }
+#elif defined(TOTEM_COMPLEX_PLUGIN)
+  { "audio/x-pn-realaudio-plugin", "rpm", "audio/vnd.rn-realaudio" },
+#elif defined(TOTEM_NARROWSPACE_PLUGIN)
+  { "video/quicktime", "mov", NULL },
+  { "video/mp4", "mp4", NULL },
+  { "image/x-macpaint", "pntg", NULL },
+  { "image/x-quicktime", "pict, pict1, pict2", "image/x-pict" },
+  { "video/x-m4v", "m4v", NULL },
+#elif defined(TOTEM_MULLY_PLUGIN)
+  { "video/divx", "divx", "video/x-msvideo" },
+#elif defined(TOTEM_CONE_PLUGIN)
+  { "application/x-vlc-plugin", "", "application/octet-stream" },
+  { "application/vlc", "", "application/octet-stream" },
+  { "video/x-google-vlc-plugin", "", "application/octet-stream" },
+#else
+#error Unknown plugin type
+#endif
+};
+
+static const char kPluginDescription[] =
+#if defined(TOTEM_BASIC_PLUGIN)
+  "Totem Web Browser Plugin " VERSION;
+#elif defined(TOTEM_GMP_PLUGIN)
+  "Windows Media Player Plug-in 10 (compatible; Totem)";
+#elif defined(TOTEM_COMPLEX_PLUGIN)
+  "Helix DNA Plugin: RealPlayer G2 Plug-In Compatible (compatible; Totem)";
+#elif defined(TOTEM_NARROWSPACE_PLUGIN)
+  "QuickTime Plug-in " TOTEM_NARROWSPACE_VERSION;
+#elif defined(TOTEM_MULLY_PLUGIN)
+  "DivX\xC2\xAE Web Player";
+#elif defined(TOTEM_CONE_PLUGIN)
+  "VLC Multimedia Plugin (compatible Totem " VERSION ")";
+#else
+#error Unknown plugin type
+#endif
+
+static const char kPluginLongDescription[] =
+#if defined(TOTEM_MULLY_PLUGIN)
+  "DivX Web Player version " TOTEM_MULLY_VERSION;
+#else
+  "The <a href=\"http://www.gnome.org/projects/totem/\";>Totem</a> " PACKAGE_VERSION " plugin handles video and audio streams.";
+#endif
 
 #if defined(TOTEM_COMPLEX_PLUGIN) && defined(HAVE_NSTARRAY_H)
 nsTArray<totemPlugin*> *totemPlugin::sPlugins;
@@ -113,7 +188,7 @@
 #endif /* TOTEM_COMPLEX_PLUGIN */
 
 void*
-totemPlugin::operator new (size_t aSize) CPP_THROW_NEW
+totemPlugin::operator new (size_t aSize) throw ()
 {
 	void *object = ::operator new (aSize);
 	if (object) {
@@ -123,24 +198,31 @@
 	return object;
 }
 
-totemPlugin::totemPlugin (NPP aInstance)
-:	mInstance (aInstance),
+totemPlugin::totemPlugin (NPP aNPP)
+:	mNPP (aNPP),
+        mMimeType (NULL),
+        mBaseURI (NULL),
+        mSrcURI (NULL),
+        mRequestBaseURI (NULL),
+        mRequestURI (NULL),
+        mViewerBusAddress (NULL),
+        mViewerServiceName (NULL),
+	mViewerFD (-1),
 	mWidth (-1),
 	mHeight (-1),
-	mViewerFD (-1),
-	mState (TOTEM_STATE_STOPPED),
 #ifdef TOTEM_COMPLEX_PLUGIN
-	mAutostart (PR_FALSE),
+	mAutoPlay (false),
 #else
-	mAutostart (PR_TRUE),
+	mAutoPlay (true),
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
-	mNeedViewer (PR_TRUE)
+	mNeedViewer (true),
+	mState (TOTEM_STATE_STOPPED)
 {
-	D ("totemPlugin ctor [%p]", (void*) this);
+        TOTEM_LOG_CTOR ();
 
 #if defined(TOTEM_COMPLEX_PLUGIN) && defined(HAVE_NSTARRAY_H)
 	/* Add |this| to the global plugins list */
-	NS_ASSERTION (sPlugins->IndexOf (this) == NoIndex, "WTF?");
+	assert (sPlugins->IndexOf (this) == NoIndex); //, "WTF?");
 	if (!sPlugins->AppendElement (this)) {
 		D ("Couldn't maintain plugin list!");
 	}
@@ -157,11 +239,7 @@
 	TransferConsole ();
 #endif /* TOTEM_COMPLEX_PLUGIN */
 
-	if (mScriptable) {
-		mScriptable->SetPlugin (nsnull);
-		NS_RELEASE (mScriptable);
-		mScriptable = nsnull;
-	}
+        /* FIXMEchpe invalidate the scriptable object, or is that done automatically? */
 
 	if (mBusProxy) {
 		dbus_g_proxy_disconnect_signal (mBusProxy,
@@ -174,133 +252,207 @@
 
 	ViewerCleanup ();
 
-	if (mTimer) {
-		mTimer->Cancel ();
-		NS_RELEASE (mTimer);
-		mTimer = nsnull;
+	if (mTimerID != 0) {
+                g_source_remove (mTimerID);
+                mTimerID = 0;
 	}
 
-	NS_IF_RELEASE (mServiceManager);
-	NS_IF_RELEASE (mIOService);
-	NS_IF_RELEASE (mPluginDOMElement);
-	NS_IF_RELEASE (mBaseURI);
-	NS_IF_RELEASE (mRequestBaseURI);
-	NS_IF_RELEASE (mRequestURI);
-	NS_IF_RELEASE (mSrcURI);
-
 #ifdef TOTEM_GMP_PLUGIN
-	NS_IF_RELEASE (mURLURI);
+	g_free (mURLURI);
 #endif
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
-	NS_IF_RELEASE (mHrefURI);
-	NS_IF_RELEASE (mQtsrcURI);
+        g_free (mHref);
+        g_free (mTarget);
+        g_free (mHrefURI);
+        g_free (mQtsrcURI);
 #endif
 
-#if defined(TOTEM_COMPLEX_PLUGIN) && defined(HAVE_NSTARRAY_H)
-	NS_IF_RELEASE (mPluginOwnerDocument);
-#endif /* TOTEM_COMPLEX_PLUGIN */
+        g_free (mMimeType);
 
-	D ("totemPlugin dtor [%p]", (void*) this);
+        g_free (mSrcURI);
+        g_free (mBaseURI);
+        g_free (mRequestURI);
+        g_free (mRequestBaseURI);
+
+        g_free (mViewerBusAddress);
+        g_free (mViewerServiceName);
+
+        g_free (mBackgroundColor);
+        g_free (mMatrix);
+        g_free (mRectangle);
+        g_free (mMovieName);
+
+        TOTEM_LOG_DTOR ();
 }
 
 /* public functions */
 
-nsresult
-totemPlugin::DoCommand (const char *aCommand)
+void
+totemPlugin::Command (const char *aCommand)
 {
-	D ("DoCommand '%s'", aCommand);
+	D ("Command '%s'", aCommand);
 
 	/* FIXME: queue the action instead */
 	if (!mViewerReady)
-		return NS_OK;
+		return;
 
-	NS_ASSERTION (mViewerProxy, "No viewer proxy");
+	assert (mViewerProxy);
 	dbus_g_proxy_call_no_reply (mViewerProxy,
 				    "DoCommand",
 				    G_TYPE_STRING, aCommand,
 				    G_TYPE_INVALID,
 				    G_TYPE_INVALID);
-
-	return NS_OK;
 }
 
-nsresult
-totemPlugin::SetVolume (gdouble aVolume)
+void
+totemPlugin::SetVolume (double aVolume)
 {
 	D ("SetVolume '%f'", aVolume);
 
+        mVolume = CLAMP (aVolume, 0.0, 1.0);
+
 	/* FIXME: queue the action instead */
 	if (!mViewerReady)
-		return NS_OK;
+		return;
 
-	NS_ASSERTION (mViewerProxy, "No viewer proxy");
+	assert (mViewerProxy);
 	dbus_g_proxy_call_no_reply (mViewerProxy,
 				    "SetVolume",
-				    G_TYPE_DOUBLE, aVolume,
+				    G_TYPE_DOUBLE, gdouble (Volume()),
 				    G_TYPE_INVALID,
 				    G_TYPE_INVALID);
-
-	return NS_OK;
 }
 
-nsresult
-totemPlugin::SetFullscreen (gboolean enabled)
+void
+totemPlugin::SetFullscreen (bool enabled)
 {
 	D ("SetFullscreen '%d'", enabled);
 
+        mIsFullscreen = enabled;
+
 	/* FIXME: queue the action instead */
 	if (!mViewerReady)
-		return NS_OK;
+		return;
 
-	NS_ASSERTION (mViewerProxy, "No viewer proxy");
+	assert (mViewerProxy);
 	dbus_g_proxy_call_no_reply (mViewerProxy,
 				    "SetFullscreen",
-				    G_TYPE_BOOLEAN, enabled,
+				    G_TYPE_BOOLEAN, gboolean (IsFullscreen()),
 				    G_TYPE_INVALID,
 				    G_TYPE_INVALID);
-
-	return NS_OK;
 }
 
-nsresult
-totemPlugin::ClearPlaylist (void)
+void
+totemPlugin::ClearPlaylist ()
 {
 	D ("ClearPlaylist");
 
 	/* FIXME: queue the action instead */
 	if (!mViewerReady)
-		return NS_OK;
+		return;
 
-	NS_ASSERTION (mViewerProxy, "No viewer proxy");
+	assert (mViewerProxy);
 	dbus_g_proxy_call_no_reply (mViewerProxy,
 				    "ClearPlaylist",
 				    G_TYPE_INVALID,
 				    G_TYPE_INVALID);
-
-	return NS_OK;
 }
 
-nsresult
-totemPlugin::AddItem (const nsACString &aURI)
+int32_t
+totemPlugin::AddItem (const char* aURI)
 {
-	const nsCString string (aURI);
-	const char *str = string.get ();
+        if (!aURI || !aURI[0])
+                return -1;
 
-	D ("AddItem '%s'", str);
+        /* FIXMEchpe: resolve against mBaseURI or mSrcURI ?? */
+
+	D ("AddItem '%s'", aURI);
 
 	/* FIXME: queue the action instead */
 	if (!mViewerReady)
-		return NS_OK;
+		return false;
 
-	NS_ASSERTION (mViewerProxy, "No viewer proxy");
+	assert (mViewerProxy);
 	dbus_g_proxy_call_no_reply (mViewerProxy,
 				    "AddItem",
-				    G_TYPE_STRING, str,
+				    G_TYPE_STRING, aURI,
 				    G_TYPE_INVALID,
 				    G_TYPE_INVALID);
 
-	return NS_OK;
+	return 0;
+}
+
+void
+totemPlugin::SetMute (bool enabled)
+{
+  mMute = enabled;
+  /* FIXMEchpe do stuff in the viewer! */
+}
+
+void
+totemPlugin::SetLooping (bool enabled)
+{
+  mIsLooping = enabled;
+  /* FIXMEchpe do stuff in the viewer! */
+}
+
+void
+totemPlugin::SetAutoPlay (bool enabled)
+{
+  mAutoPlay = enabled;
+}
+
+void
+totemPlugin::SetControllerVisible (bool enabled)
+{
+  mControllerHidden = !enabled; // FIXMEchpe
+}
+
+void
+totemPlugin::SetBackgroundColor (const char* color)
+{
+  g_free (mBackgroundColor);
+  mBackgroundColor = g_strdup (color);
+}
+
+void
+totemPlugin::SetMatrix (const char* matrix)
+{
+  g_free (mMatrix);
+  mMatrix = g_strdup (matrix);
+}
+
+void
+totemPlugin::SetRectangle (const char *rectangle)
+{
+  g_free (mRectangle);
+  mRectangle = g_strdup (rectangle);
+}
+
+void
+totemPlugin::SetMovieName (const char *name)
+{
+  g_free (mMovieName);
+  mMovieName = g_strdup (name);
+}
+
+void
+totemPlugin::SetRate (double rate)
+{
+  // FIXMEchpe
+}
+
+double
+totemPlugin::Rate () const
+{
+  double rate;
+  if (mState == TOTEM_STATE_PLAYING) {
+    rate = 1.0;
+  } else {
+    rate = 0.0;
+  }
+  return rate;
 }
 
 /* Viewer interaction */
@@ -314,8 +466,7 @@
 		return NPERR_NO_ERROR;
 #endif /* TOTEM_COMPLEX_PLUGIN */
 
-	const char *userAgent = CallNPN_UserAgentProc (sNPN.uagent,
-						       mInstance);
+	const char *userAgent = NPN_UserAgent (mNPP);
 	if (!userAgent) {
 		/* See https://bugzilla.mozilla.org/show_bug.cgi?id=328778 */
 		D ("User agent has more than 127 characters; fix your browser!");
@@ -374,9 +525,9 @@
 	}
 
 	/* FIXME: remove this */
-	if (!mMimeType.IsEmpty ()) {
+	if (mMimeType) {
 		g_ptr_array_add (arr, g_strdup (DASHES TOTEM_OPTION_MIMETYPE));
-		g_ptr_array_add (arr, g_strdup (mMimeType.get()));
+		g_ptr_array_add (arr, g_strdup (mMimeType));
 	}
 
 	if (mControllerHidden) {
@@ -399,7 +550,7 @@
 		g_ptr_array_add (arr, g_strdup (DASHES TOTEM_OPTION_AUDIOONLY));
 	}
 
-	if (!mAutostart) {
+	if (!mAutoPlay) {
 		g_ptr_array_add (arr, g_strdup (DASHES TOTEM_OPTION_NOAUTOSTART));
 	}
 
@@ -421,18 +572,13 @@
 	}
 #endif
 
-	mViewerReady = PR_FALSE;
+	mViewerReady = false;
 
 	/* Don't wait forever! */
-	const PRUint32 kViewerTimeout = 30 * 1000; /* ms */
-	nsresult rv = mTimer->InitWithFuncCallback (ViewerForkTimeoutCallback,
-						    reinterpret_cast<void*>(this),
-						    kViewerTimeout,
-						    nsITimer::TYPE_ONE_SHOT);
-	if (NS_FAILED (rv)) {
-		D ("Failed to initialise timer");
-		return NPERR_GENERIC_ERROR;
-	}
+	const guint kViewerTimeout = 30 * 1000; /* ms */
+        mTimerID = g_timeout_add (kViewerTimeout,
+                                  (GSourceFunc) ViewerForkTimeoutCallback,
+                                  reinterpret_cast<void*>(this));
 
 	/* FIXME: once gecko is multihead-safe, this should use gdk_spawn_on_screen_with_pipes */
 	GError *error = NULL;
@@ -476,18 +622,18 @@
 	if (mViewerSetUp)
 		return;
 
-	mViewerSetUp = PR_TRUE;
+	mViewerSetUp = true;
 
 	D ("ViewerSetup");
 
 	/* Cancel timeout */
-	nsresult rv = mTimer->Cancel ();
-	if (NS_FAILED (rv)) {
-		D ("Failed to cancel timer");
+        if (mTimerID != 0) {
+          g_source_remove (mTimerID);
+          mTimerID = 0;
 	}
 
 	mViewerProxy = dbus_g_proxy_new_for_name (mBusConnection,
-						  mViewerServiceName.get (),
+						  mViewerServiceName,
 						  TOTEM_PLUGIN_VIEWER_DBUS_PATH,
 						  TOTEM_PLUGIN_VIEWER_INTERFACE_NAME);
 
@@ -550,8 +696,8 @@
 
 #if defined(TOTEM_COMPLEX_PLUGIN) && defined(HAVE_NSTARRAY_H)
 	/* Notify all consoles */
-	PRUint32 count = sPlugins->Length ();
-	for (PRUint32 i = 0; i < count; ++i) {
+	uint32_t count = sPlugins->Length ();
+	for (uint32_t i = 0; i < count; ++i) {
 		totemPlugin *plugin = sPlugins->ElementAt (i);
 
 		if (plugin->mConsoleClassRepresentant == this)
@@ -564,10 +710,12 @@
 void
 totemPlugin::ViewerCleanup ()
 {
-	mViewerReady = PR_FALSE;
+	mViewerReady = false;
 
-	mViewerBusAddress.SetLength (0);
-	mViewerServiceName.SetLength (0);
+        g_free (mViewerBusAddress);
+        mViewerBusAddress = NULL;
+        g_free (mViewerServiceName);
+        mViewerServiceName = NULL;
 
 	if (mViewerPendingCall) {
 		dbus_g_proxy_cancel_call (mViewerProxy, mViewerPendingCall);
@@ -621,12 +769,12 @@
 
 	/* FIXME this shouldn't happen here */
 	if (mHidden) {
-		mWindowSet = PR_TRUE;
+		mWindowSet = true;
 		ViewerReady ();
 		return;
 	}
 
-	NS_ASSERTION (mViewerPendingCall == NULL, "Have a pending call");
+	assert (mViewerPendingCall == NULL); /* Have a pending call */
 
 	D ("Calling SetWindow");
 	mViewerPendingCall = 
@@ -641,11 +789,11 @@
 					 G_TYPE_STRING, "All",
 #endif
 					 G_TYPE_UINT, (guint) mWindow,
-					 G_TYPE_INT, (gint) mWidth,
-					 G_TYPE_INT, (gint) mHeight,
+					 G_TYPE_INT, mWidth,
+					 G_TYPE_INT, mHeight,
 					 G_TYPE_INVALID);
 		
-	mWindowSet = PR_TRUE;
+	mWindowSet = true;
 }
 
 void
@@ -653,23 +801,23 @@
 {
 	D ("ViewerReady");
 
-	NS_ASSERTION (!mViewerReady, "Viewer already ready");
+	assert (!mViewerReady);
 
-	mViewerReady = PR_TRUE;
+	mViewerReady = true;
 
-	if (mAutostart) {
-		RequestStream (PR_FALSE);
+	if (mAutoPlay) {
+		RequestStream (false);
 	} else {
-		mWaitingForButtonPress = PR_TRUE;
+		mWaitingForButtonPress = true;
 	}
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
 	/* Tell the viewer it has an href */
-	if (!mHref.IsEmpty ()) {
+	if (mHref) {
 		dbus_g_proxy_call_no_reply (mViewerProxy,
 					    "SetHref",
-					    G_TYPE_STRING, mHref.get (),
-					    G_TYPE_STRING, mTarget.get (),
+					    G_TYPE_STRING, mHref,
+					    G_TYPE_STRING, mTarget ? mTarget : "",
 					    G_TYPE_INVALID);
 	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
@@ -682,20 +830,22 @@
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
 	/* FIXME set href="" afterwards, so we don't try to launch again when the user clicks again? */
-	if (!mHref.IsEmpty ()) {
-		if (g_ascii_strcasecmp (mTarget.get (), "quicktimeplayer") == 0) {
-			D ("Opening movie '%s' in external player", mHref.get ());
+	if (mHref) {
+		if (mTarget &&
+                    g_ascii_strcasecmp (mTarget, "quicktimeplayer") == 0) {
+			D ("Opening movie '%s' in external player", mHref);
 			dbus_g_proxy_call_no_reply (mViewerProxy,
 						    "LaunchPlayer",
-						    G_TYPE_STRING, mHref.get (),
+						    G_TYPE_STRING, mHref,
 						    G_TYPE_UINT, time,
 						    G_TYPE_INVALID);
 			return;
 		}
-		if (g_ascii_strcasecmp (mTarget.get (), "myself") == 0 ||
-		    mTarget.Equals (NS_LITERAL_CSTRING ("_current")) ||
-		    mTarget.Equals (NS_LITERAL_CSTRING ("_self"))) {
-			D ("Opening movie '%s'", mHref.get ());
+                if (mTarget &&
+                    (g_ascii_strcasecmp (mTarget, "myself") == 0 ||
+                     g_ascii_strcasecmp (mTarget, "_current") == 0 ||
+                     g_ascii_strcasecmp (mTarget, "_self") == 0)) {
+                        D ("Opening movie '%s'", mHref);
 			dbus_g_proxy_call_no_reply (mViewerProxy,
 						    "SetHref",
 						    G_TYPE_STRING, NULL,
@@ -703,25 +853,22 @@
 						    G_TYPE_INVALID);
 			/* FIXME this isn't right, we should just create a mHrefURI and instruct to load that one */
 			SetQtsrc (mHref);
-			RequestStream (PR_TRUE);
+			RequestStream (true);
 			return;
 		}
 
 		/* Load URL in browser. This will either open a new website,
 		 * or execute some javascript.
 		 */
-		nsCString href;
+                const char *href = NULL;
 		if (mHrefURI) {
-			mHrefURI->GetSpec (href);
+			href = mHrefURI;
 		} else {
 			href = mHref;
 		}
 
-		if (CallNPN_GetURLProc (sNPN.geturl,
-					mInstance,
-					href.get (),
-					mTarget.get ()) != NPERR_NO_ERROR) {
-			D ("Failed to launch URL '%s' in browser", mHref.get ());
+		if (NPN_GetURL (mNPP, href, mTarget) != NPERR_NO_ERROR) {
+			D ("Failed to launch URL '%s' in browser", mHref);
 		}
 
 		return;
@@ -731,12 +878,12 @@
 	if (!mWaitingForButtonPress)
 		return;
 
-	mWaitingForButtonPress = PR_FALSE;
+	mWaitingForButtonPress = false;
 
 	/* Now is the time to start the stream */
-	if (!mAutostart &&
+	if (!mAutoPlay &&
 	    !mStream) {
-		RequestStream (PR_FALSE);
+		RequestStream (false);
 	}
 }
 
@@ -749,41 +896,40 @@
 		return;
 
 	/* Construct viewer interface name */
-	if (NS_UNLIKELY (mViewerServiceName.IsEmpty ())) {
-		char name[256];
-
-		g_snprintf (name, sizeof (name),
-			    TOTEM_PLUGIN_VIEWER_NAME_TEMPLATE,
-			    mViewerPID);
-		mViewerServiceName.Assign (name);
-
-		D ("Viewer DBus interface name is '%s'", mViewerServiceName.get ());
+	if (G_UNLIKELY (!mViewerServiceName)) {
+		mViewerServiceName = g_strdup_printf (TOTEM_PLUGIN_VIEWER_NAME_TEMPLATE, mViewerPID);
+		D ("Viewer DBus interface name is '%s'", mViewerServiceName);
 	}
 
-	if (!mViewerServiceName.Equals (nsDependentCString (aName)))
+	if (strcmp (mViewerServiceName, aName) != 0)
 		return;
 
 	D ("NameOwnerChanged old-owner '%s' new-owner '%s'", aOldOwner, aNewOwner);
 
 	if (aOldOwner[0] == '\0' /* empty */ &&
 	    aNewOwner[0] != '\0' /* non-empty */) {
-		if (mViewerBusAddress.Equals (nsDependentCString (aNewOwner))) {
+		if (mViewerBusAddress &&
+                    strcmp (mViewerBusAddress, aNewOwner) == 0) {
 			D ("Already have owner, why are we notified again?");
-		} else if (!mViewerBusAddress.IsEmpty ()) {
+                        g_free (mViewerBusAddress);
+		} else if (mViewerBusAddress) {
 			D ("WTF, new owner!?");
+                        g_free (mViewerBusAddress);
 		} else {
 			/* This is the regular case */
 			D ("Viewer now connected to the bus");
 		}
 
-		mViewerBusAddress.Assign (aNewOwner);
+		mViewerBusAddress = g_strdup (aNewOwner);
 
 		ViewerSetup ();
-	} else if (!mViewerBusAddress.IsEmpty () &&
-		   mViewerBusAddress.Equals (nsDependentCString (aOldOwner))) {
+	} else if (mViewerBusAddress &&
+		   strcmp (mViewerBusAddress, aOldOwner) == 0) {
 		D ("Viewer lost connection!");
 
-		mViewerBusAddress.SetLength (0); /* truncate */
+		g_free (mViewerBusAddress);
+                mViewerBusAddress = NULL;
+
 		/* FIXME */
 		/* ViewerCleanup () ? */
 		/* FIXME if we're not quitting, put up error viewer */
@@ -798,20 +944,19 @@
 void
 totemPlugin::ClearRequest ()
 {
-	if (mRequestBaseURI) {
-		NS_RELEASE (mRequestBaseURI);
-		mRequestBaseURI = nsnull;
-	}
-	if (mRequestURI) {
-		NS_RELEASE (mRequestURI);
-		mRequestURI = nsnull;
-	}
+  g_free (mRequestURI);
+  mRequestURI = NULL;
+
+  g_free (mRequestBaseURI);
+  mRequestBaseURI = NULL;
 }
 
 void
-totemPlugin::RequestStream (PRBool aForceViewer)
+totemPlugin::RequestStream (bool aForceViewer)
 {
-	NS_ASSERTION (mViewerReady, "Viewer not ready");
+//        assert (mViewerReady);
+        if (!mViewerReady)
+          return;//FIXMEchpe
 
 	if (mStream) {
 		D ("Unexpectedly have a stream!");
@@ -822,8 +967,8 @@
 	ClearRequest ();
 
 	/* Now work out which URL to request */
-	nsIURI *baseURI = nsnull;
-	nsIURI *requestURI = nsnull;
+	const char *baseURI = NULL;
+	const char *requestURI = NULL;
 
 #ifdef TOTEM_GMP_PLUGIN
 	/* Prefer filename over src */
@@ -848,7 +993,7 @@
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 
 #ifdef TOTEM_MULLY_PLUGIN
-	aForceViewer = PR_TRUE;
+	aForceViewer = true;
 #endif /* TOTEM_MULLY_PLUGIN */
 
 	/* Fallback */
@@ -859,25 +1004,16 @@
 		baseURI = mBaseURI;
 
 	/* Nothing to do */
-	if (!requestURI)
-		return;
-
-	NS_ADDREF (mRequestBaseURI = baseURI);
-	NS_ADDREF (mRequestURI = requestURI);
-
-	/* FIXME use the right base! */
-	nsCString baseSpec, spec;
-	baseURI->GetSpec (baseSpec);
-	requestURI->GetSpec (spec);
-
-	/* Shouldn't happen, but who knows */
-	if (spec.IsEmpty ())
+	if (!requestURI || !requestURI[0])
 		return;
 
 	/* If we don't have a proxy yet */
 	if (!mViewerReady)
 		return;
 
+        mRequestURI = g_strdup (requestURI);
+        mRequestBaseURI = g_strdup (baseURI);
+
 	/* If the URL is supported and the caller isn't asking us to make
 	 * the viewer open the stream, we call OpenStream, and
 	 * otherwise OpenURI. */
@@ -891,8 +1027,8 @@
 						 ViewerOpenStreamCallback,
 						 reinterpret_cast<void*>(this),
 						 NULL,
-						 G_TYPE_STRING, spec.get (),
-						 G_TYPE_STRING, baseSpec.get (),
+						 G_TYPE_STRING, requestURI,
+						 G_TYPE_STRING, baseURI,
 						 G_TYPE_INVALID);
 	} else {
 		mViewerPendingCall =
@@ -901,16 +1037,18 @@
 						 ViewerOpenURICallback,
 						 reinterpret_cast<void*>(this),
 						 NULL,
-						 G_TYPE_STRING, spec.get (),
-						 G_TYPE_STRING, baseSpec.get (),
+						 G_TYPE_STRING, requestURI,
+						 G_TYPE_STRING, baseURI,
 						 G_TYPE_INVALID);
 	}
 
 	/* FIXME: start playing in the callbacks ! */
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
-	if (mScriptable) {
-		mScriptable->mPluginState = totemScriptablePlugin::eState_Playable;
+        if (!mNPObjects[ePluginScriptable].IsNull ()) {
+                NPObject *object = mNPObjects[ePluginScriptable];
+                totemNarrowSpacePlayer *scriptable = static_cast<totemNarrowSpacePlayer*>(object);
+		scriptable->mPluginState = totemNarrowSpacePlayer::eState_Playable;
 	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 }
@@ -921,29 +1059,30 @@
 	if (!mStream)
 		return;
 
-	if (CallNPN_DestroyStreamProc (sNPN.destroystream,
-	    			       mInstance,
-				       mStream,
-				       NPRES_DONE) != NPERR_NO_ERROR) {
-		    g_warning ("Couldn't destroy the stream");
-		    /* FIXME: set mStream to NULL here too? */
-		    return;
+	if (NPN_DestroyStream (mNPP,
+                               mStream,
+                               NPRES_DONE) != NPERR_NO_ERROR) {
+                  g_warning ("Couldn't destroy the stream");
+                  /* FIXME: set mStream to NULL here too? */
+                  return;
 	}
 
 	/* Calling DestroyStream should already have set this to NULL */
-	NS_ASSERTION (!mStream, "Should not have a stream anymore");
-	mStream = nsnull; /* just to make sure */
+	assert (!mStream); /* Should not have a stream anymore */
+	mStream = NULL; /* just to make sure */
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
-	if (mScriptable) {
-		mScriptable->mPluginState = totemScriptablePlugin::eState_Waiting;
+        if (!mNPObjects[ePluginScriptable].IsNull ()) {
+                NPObject *object = mNPObjects[ePluginScriptable];
+                totemNarrowSpacePlayer *scriptable = static_cast<totemNarrowSpacePlayer*>(object);
+		scriptable->mPluginState = totemNarrowSpacePlayer::eState_Waiting;
 	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 }
 
 /* Callbacks */
 
-/* static */ void PR_CALLBACK 
+/* static */ void 
 totemPlugin::NameOwnerChangedCallback (DBusGProxy *proxy,
 				       const char *aName,
 				       const char *aOldOwner,
@@ -955,22 +1094,25 @@
 	plugin->NameOwnerChanged (aName, aOldOwner, aNewOwner);
 }
 
-/* static */ void PR_CALLBACK
-totemPlugin::ViewerForkTimeoutCallback (nsITimer *aTimer,
-				        void *aData)
+/* static */ gboolean
+totemPlugin::ViewerForkTimeoutCallback (void *aData)
 {
 	totemPlugin *plugin = reinterpret_cast<totemPlugin*>(aData);
 
+        plugin->mTimerID = 0;
+
 	D ("ViewerForkTimeoutCallback");
 
 	/* FIXME: can this really happen? */
-	NS_ASSERTION (!plugin->mViewerReady, "Viewer ready but timeout running?");
+	assert (!plugin->mViewerReady); /* Viewer ready but timeout running? */
 
 	plugin->ViewerCleanup ();
 	/* FIXME start error viewer */
+
+        return FALSE; /* don't run again */
 }
 
-/* static */ void PR_CALLBACK
+/* static */ void
 totemPlugin::ButtonPressCallback (DBusGProxy *proxy,
 				  guint aTimestamp,
 				  guint aButton,
@@ -983,7 +1125,7 @@
 	plugin->ViewerButtonPressed (aTimestamp, aButton);
 }
 
-/* static */ void PR_CALLBACK
+/* static */ void
 totemPlugin::StopStreamCallback (DBusGProxy *proxy,
 			         void *aData)
 {
@@ -994,7 +1136,7 @@
 	plugin->UnsetStream ();
 }
 
-/* static */ void PR_CALLBACK
+/* static */ void
 totemPlugin::TickCallback (DBusGProxy *proxy,
 			   guint aTime,
 			   guint aDuration,
@@ -1002,10 +1144,11 @@
 			   void *aData)
 {
 	totemPlugin *plugin = reinterpret_cast<totemPlugin*>(aData);
-	TotemStates state;
 	guint i;
 
-	NS_ASSERTION (aState != NULL, "aState is NULL probably garbage");
+	//assert (aState != NULL) /* aState is NULL probably garbage */
+        if (!aState)
+                return;
 
 	DD ("Tick signal received, aState %s, aTime %d, aDuration %d", aState, aTime, aDuration);
 
@@ -1020,7 +1163,7 @@
 	plugin->mDuration = aDuration;
 }
 
-/* static */ void PR_CALLBACK
+/* static */ void
 totemPlugin::PropertyChangeCallback (DBusGProxy  *proxy,
 				     const char *aType,
 				     GValue *value,
@@ -1028,7 +1171,9 @@
 {
 	totemPlugin *plugin = reinterpret_cast<totemPlugin*>(aData);
 
-	NS_ASSERTION (aType != NULL, "aType is NULL probably garbage");
+	//NS_ASSERTION (aType != NULL, "aType is NULL probably garbage");
+        if (!aType)
+                return;
 
 	DD ("PropertyChange signal received, aType %s", aType);
 
@@ -1039,7 +1184,7 @@
 	}
 }
 
-/* static */ void PR_CALLBACK
+/* static */ void
 totemPlugin::ViewerSetWindowCallback (DBusGProxy *aProxy,
 				      DBusGProxyCall *aCall,
 				      void *aData)
@@ -1048,13 +1193,15 @@
 
 	D ("SetWindow reply");
 
-	NS_ASSERTION (aCall == plugin->mViewerPendingCall, "SetWindow not the current call");
+	//assert (aCall == plugin->mViewerPendingCall, "SetWindow not the current call");
+        if (aCall != plugin->mViewerPendingCall)
+          return;
 
 	plugin->mViewerPendingCall = NULL;
 
 	GError *error = NULL;
 	if (!dbus_g_proxy_end_call (aProxy, aCall, &error, G_TYPE_INVALID)) {
-		/* FIXME: mViewerFailed = PR_TRUE */
+		/* FIXME: mViewerFailed = true */
 		g_warning ("SetWindow failed: %s", error->message);
 		g_error_free (error);
 		return;
@@ -1063,7 +1210,7 @@
 	plugin->ViewerReady ();
 }
 
-/* static */ void PR_CALLBACK
+/* static */ void
 totemPlugin::ViewerOpenStreamCallback (DBusGProxy *aProxy,
 				       DBusGProxyCall *aCall,
 				       void *aData)
@@ -1072,7 +1219,9 @@
 
 	D ("OpenStream reply");
 
-	NS_ASSERTION (aCall == plugin->mViewerPendingCall, "OpenStream not the current call");
+// 	assert (aCall == plugin->mViewerPendingCall, "OpenStream not the current call");
+        if (aCall != plugin->mViewerPendingCall)
+          return;
 
 	plugin->mViewerPendingCall = NULL;
 
@@ -1085,39 +1234,40 @@
 
 	/* FIXME this isn't the best way... */
 	if (plugin->mHidden &&
-	    plugin->mAutostart) {
-		plugin->DoCommand (TOTEM_COMMAND_PLAY);
+	    plugin->mAutoPlay) {
+		plugin->Command (TOTEM_COMMAND_PLAY);
 	}
 
-	NS_ASSERTION (!plugin->mExpectingStream, "Already expecting a stream");
-	NS_ENSURE_TRUE (plugin->mRequestURI, );
+	assert (!plugin->mExpectingStream); /* Already expecting a stream */
 
-	plugin->mExpectingStream = PR_TRUE;
+        //assert (plugin->mRequestURI);
+	if (!plugin->mRequestURI)
+          return;
 
-	nsCString spec;
-	plugin->mRequestURI->GetSpec (spec);
+	plugin->mExpectingStream = true;
 
 	/* Use GetURLNotify so we can reset mExpectingStream on failure */
-	NPError err = CallNPN_GetURLNotifyProc (sNPN.geturlnotify,
-						plugin->mInstance,
-						spec.get (),
-						nsnull,
-						nsnull);
+	NPError err = NPN_GetURLNotify (plugin->mNPP,
+                                        plugin->mRequestURI,
+                                        NULL,
+                                        NULL);
 	if (err != NPERR_NO_ERROR) {
-		plugin->mExpectingStream = PR_FALSE;
+		plugin->mExpectingStream = false;
 
-		D ("GetURLNotify '%s' failed with error %d", spec.get (), err);
+		D ("GetURLNotify '%s' failed with error %d", plugin->mRequestURI, err);
 		return;
 	}
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
-	if (plugin->mScriptable) {
-		plugin->mScriptable->mPluginState = totemScriptablePlugin::eState_Playable;
+        if (!plugin->mNPObjects[ePluginScriptable].IsNull ()) {
+                NPObject *object = plugin->mNPObjects[ePluginScriptable];
+                totemNarrowSpacePlayer *scriptable = static_cast<totemNarrowSpacePlayer*>(object);
+		scriptable->mPluginState = totemNarrowSpacePlayer::eState_Playable;
 	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 }
 
-/* static */ void PR_CALLBACK
+/* static */ void
 totemPlugin::ViewerOpenURICallback (DBusGProxy *aProxy,
 				    DBusGProxyCall *aCall,
 				    void *aData)
@@ -1126,7 +1276,9 @@
 
 	D ("OpenURI reply");
 
-	NS_ASSERTION (aCall == plugin->mViewerPendingCall, "OpenURI not the current call");
+// 	//assert (aCall == plugin->mViewerPendingCall, "OpenURI not the current call");
+        if (aCall != plugin->mViewerPendingCall)
+          return;
 
 	plugin->mViewerPendingCall = NULL;
 
@@ -1138,35 +1290,51 @@
 	}
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
-	if (plugin->mScriptable) {
-		plugin->mScriptable->mPluginState = totemScriptablePlugin::eState_Playable;
+        if (!plugin->mNPObjects[ePluginScriptable].IsNull ()) {
+                NPObject *object = plugin->mNPObjects[ePluginScriptable];
+                totemNarrowSpacePlayer *scriptable = static_cast<totemNarrowSpacePlayer*>(object);
+		scriptable->mPluginState = totemNarrowSpacePlayer::eState_Playable;
 	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 
 	/* FIXME this isn't the best way... */
-	if (plugin->mAutostart) {
-		plugin->DoCommand (TOTEM_COMMAND_PLAY);
+	if (plugin->mAutoPlay) {
+		plugin->Command (TOTEM_COMMAND_PLAY);
 	}
 }
 
 /* Auxiliary functions */
 
-void
-totemPlugin::GetRealMimeType (const char *mimetype,
-			      nsACString &_retval)
+
+/* static */ char *
+totemPlugin::PluginDescription ()
+{
+  return (char*) kPluginDescription;
+}
+
+/* static */ char *
+totemPlugin::PluginLongDescription ()
+{
+  return (char*) kPluginLongDescription;
+}
+
+/* static */ void
+totemPlugin::PluginMimeTypes (const totemPluginMimeEntry **_entries,
+					uint32_t *_count)
 {
-	_retval.Assign ("");
+  *_entries = kMimeTypes;
+  *_count = G_N_ELEMENTS (kMimeTypes);
+}
 
-	const totemPluginMimeEntry *mimetypes;
-	PRUint32 count;
-	totemScriptablePlugin::PluginMimeTypes (&mimetypes, &count);
-
-	for (PRUint32 i = 0; i < count; ++i) {
-		if (strcmp (mimetypes[i].mimetype, mimetype) == 0) {
-			if (mimetypes[i].mime_alias != NULL) {
-				_retval.Assign (mimetypes[i].mime_alias);
+void
+totemPlugin::SetRealMimeType (const char *mimetype)
+{
+	for (uint32_t i = 0; i < G_N_ELEMENTS (kMimeTypes); ++i) {
+		if (strcmp (kMimeTypes[i].mimetype, mimetype) == 0) {
+			if (kMimeTypes[i].mime_alias != NULL) {
+				mMimeType = g_strdup (kMimeTypes[i].mime_alias);
 			} else {
-				_retval.Assign (mimetype);
+				mMimeType = g_strdup (mimetype);
 			}
 			return;
 		}
@@ -1175,47 +1343,40 @@
 	D ("Real mime-type for '%s' not found", mimetype);
 }
 
-PRBool
-totemPlugin::IsSchemeSupported (nsIURI *aURI)
+bool
+totemPlugin::IsSchemeSupported (const char *aURI)
 {
-	if (!aURI)
-		return PR_FALSE;
+  if (!aURI)
+    return false;
 
-	nsCString scheme;
-	nsresult rv = aURI->GetScheme (scheme);
-	if (NS_FAILED (rv) || scheme.IsEmpty ())
-		return PR_FALSE;
+  char *scheme = g_uri_parse_scheme (aURI);
+  if (!scheme)
+    return false;
 
-	nsIProtocolHandler *handler = nsnull;
-	rv = mIOService->GetProtocolHandler (scheme.get (), &handler);
+  bool isSupported = false;
+  if (g_ascii_strcasecmp (scheme, "http") == 0 ||
+      g_ascii_strcasecmp (scheme, "https") == 0 ||
+      g_ascii_strcasecmp (scheme, "ftp") == 0)
+    isSupported = true;
 
-	/* Check that it's not the external protocol handler! */
-	nsIExternalProtocolHandler *extHandler = nsnull;
-	if (NS_SUCCEEDED (rv) && handler) {
-		CallQueryInterface (handler, &extHandler);
-	}
+  D("IsSchemeSupported scheme '%s': %s", scheme, isSupported ? "yes" : "no");
 
-	PRBool isSupported = NS_SUCCEEDED (rv) && handler && !extHandler;
+  g_free (scheme);
 
-	NS_IF_RELEASE (handler); /* this nullifies |handler| */
-	NS_IF_RELEASE (extHandler);
-
-	D ("IsSchemeSupported scheme '%s': %s", scheme.get (), isSupported ? "yes" : "no");
-
-	return isSupported;
+  return isSupported;
 }
 
-PRBool
+bool
 totemPlugin::ParseBoolean (const char *key,
 			   const char *value,
-			   PRBool default_val)
+			   bool default_val)
 {
 	if (value == NULL || strcmp (value, "") == 0)
 		return default_val;
 	if (g_ascii_strcasecmp (value, "false") == 0 || g_ascii_strcasecmp (value, "no") == 0)
-		return PR_FALSE;
+		return false;
 	if (g_ascii_strcasecmp (value, "true") == 0 || g_ascii_strcasecmp (value, "yes") == 0)
-		return PR_TRUE;
+		return true;
 
         char *endptr = NULL;
         errno = 0;
@@ -1229,10 +1390,10 @@
 	return default_val;
 }
 
-PRBool
+bool
 totemPlugin::GetBooleanValue (GHashTable *args,
 			      const char *key,
-			      PRBool default_val)
+			      bool default_val)
 {
 	const char *value;
 
@@ -1243,18 +1404,18 @@
 	return ParseBoolean (key, value, default_val);
 }
 
-PRUint32
+uint32_t
 totemPlugin::GetEnumIndex (GHashTable *args,
 			   const char *key,
 			   const char *values[],
-			   PRUint32 n_values,
-			   PRUint32 default_value)
+			   uint32_t n_values,
+			   uint32_t default_value)
 {
 	const char *value = (const char *) g_hash_table_lookup (args, key);
 	if (!value)
 		return default_value;
 
-	for (PRUint32 i = 0; i < n_values; ++i) {
+	for (uint32_t i = 0; i < n_values; ++i) {
 		if (g_ascii_strcasecmp (value, values[i]) == 0)
 			return i;
 	}
@@ -1264,120 +1425,87 @@
 
 /* Public functions for use by the scriptable plugin */
 
-nsresult
-totemPlugin::SetSrc (const nsACString& aURL)
+bool
+totemPlugin::SetSrc (const char* aURL)
 {
-	if (mSrcURI) {
-		NS_RELEASE (mSrcURI);
-		mSrcURI = nsnull;
-	}
-
-	mSrc = aURL;
+        g_free (mSrcURI);
 
 	/* If |src| is empty, don't resolve the URI! Otherwise we may
 	 * try to load an (probably iframe) html document as our video stream.
 	 */
-	if (mSrc.Length () == 0)
-		return NS_OK;
+	if (!aURL || !aURL[0]) {
+              mSrcURI = NULL;
+              return true;
+        }
 
-	nsresult rv = mIOService->NewURI (aURL, nsnull /* FIXME! use document charset */,
-					  mBaseURI, &mSrcURI);
-	if (NS_FAILED (rv)) {
-		D ("Failed to create src URI (rv=%x)", rv);
-		mSrcURI = nsnull;
-	} else {
-		if (mAutostart) {
-			RequestStream (PR_FALSE);
-		} else {
-			mWaitingForButtonPress = PR_TRUE;
-		}
-	}
+        mSrcURI = g_strdup (aURL);
+
+        if (mAutoPlay) {
+                RequestStream (false);
+        } else {
+                mWaitingForButtonPress = true;
+        }
 
-	return rv;
+        return true;
 }
 
 #ifdef TOTEM_GMP_PLUGIN
 
-nsresult
-totemPlugin::SetURL (const nsACString& aURL)
+void
+totemPlugin::SetURL (const char* aURL)
 {
-	if (mURLURI) {
-		NS_RELEASE (mURLURI);
-		mURLURI = nsnull;
-	}
+        g_free (mURLURI);
 
 	/* Don't allow empty URL */
-	if (aURL.Length () == 0)
-		return NS_OK;
-
-	/* FIXME: what is the correct base for the URL param? */
-	nsresult rv;
-	nsIURI *baseURI;
-	if (mSrcURI) {
-		baseURI = mSrcURI;
-	} else {
-		baseURI = mBaseURI;
-	}
+        if (!aURL || !aURL[0]) {
+                mURLURI = NULL;
+		return;
+        }
 
-	rv = mIOService->NewURI (aURL, nsnull /* FIXME document charset? */,
-				 baseURI, &mURLURI);
-	if (NS_FAILED (rv)) {
-		D ("Failed to create URL URI (rv=%x)", rv);
-	}
+        mURLURI = g_strdup (aURL);
 
+	/* FIXME: what is the correct base for the URL param? mSrcURI or mBaseURI? */
 	/* FIXME: security checks? */
-
-	return rv;
+        /* FIXMEchpe: resolve the URI here? */
 }
 
 #endif /* TOTEM_GMP_PLUGIN */
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
 
-nsresult
-totemPlugin::SetQtsrc (const nsCString& aURL)
+bool
+totemPlugin::SetQtsrc (const char* aURL)
 {
 	/* FIXME can qtsrc have URL extensions? */
 
-	if (mQtsrcURI) {
-		NS_RELEASE (mQtsrcURI);
-		mQtsrcURI = nsnull;
-	}
-
+        g_free (mQtsrcURI);
+        
 	/* Don't allow empty qtsrc */
-	if (aURL.Length () == 0)
-		return NS_OK;
-
-	nsresult rv;
-	nsIURI *baseURI;
-	if (mSrcURI) {
-		baseURI = mSrcURI;
-	} else {
-		baseURI = mBaseURI;
-	}
+	if (!aURL || !aURL[0]) {
+                mQtsrcURI = NULL;
+		return true;
+        }
 
-	rv = mIOService->NewURI (aURL, nsnull /* FIXME document charset? */,
-				 baseURI, &mQtsrcURI);
-	if (NS_FAILED (rv)) {
-		D ("Failed to create QTSRC URI (rv=%x)", rv);
-	}
+        mQtsrcURI = g_strdup (aURL);
 
 	/* FIXME: security checks? */
+        /* FIXMEchpe: resolve the URI here? */
 
-	return rv;
+        return true;
 }
 
-nsresult
-totemPlugin::SetHref (const nsCString& aURL)
+bool
+totemPlugin::SetHref (const char* aURL)
 {
-	nsCString url, target;
-	PRBool hasExtensions = ParseURLExtensions (aURL, url, target);
+	char *url = NULL, *target = NULL;
+	bool hasExtensions = ParseURLExtensions (aURL, &url, &target);
 
 	D ("SetHref '%s' has-extensions %d (url: '%s' target: '%s')",
-	   nsCString (aURL).get (), hasExtensions, url.get (), target.get ());
+	   aURL ? aURL : "", hasExtensions, url ? url : "", target ? target : "");
 
-	nsresult rv;
-	nsIURI *baseURI;
+#if 0
+// 	nsresult rv = NS_OK;
+	char *baseURI;
 	if (mQtsrcURI) {
 		baseURI = mQtsrcURI;
 	} else if (mSrcURI) {
@@ -1385,50 +1513,69 @@
 	} else {
 		baseURI = mBaseURI;
 	}
+#endif
 
 	if (hasExtensions) {
+                g_free (mHref);
+                mHref = g_strdup (url && url[0] ? url : NULL);
+#if 0
 		rv = baseURI->Resolve (url, mHref);
-
-		if (!target.IsEmpty ())
-			mTarget = target;
+#endif
+                g_free (mTarget);
+                mTarget = g_strdup (target);
 	} else {
+                g_free (mHref);
+                mHref = g_strdup (aURL && aURL[0] ? aURL : NULL);
+#if 0
 		rv = baseURI->Resolve (aURL, mHref);
+#endif
+
+                g_free (mTarget);
+                mTarget = NULL;
 	}
+#if 0
 	if (NS_SUCCEEDED (rv)) {
-		D ("Resolved HREF '%s'", mHref.get());
+		D ("Resolved HREF '%s'", mHref ? mHref : "");
 	} else {
 		D ("Failed to resolve HREF (rv=%x)", rv);
-		mHref = hasExtensions ? url : aURL; /* save unresolved HREF */
+		mHref = hasExtensions ? g_strdup (url) : g_strdup (aURL); /* save unresolved HREF */
 	}
+#endif
+
+        g_free (url);
+        g_free (target);
 
-	return rv;
+	return true; // FIXMEchpe
 }
 
-PRBool
-totemPlugin::ParseURLExtensions (const nsACString &aString,
-				 nsACString &_url,
-				 nsACString &_target)
+bool
+totemPlugin::ParseURLExtensions (const char* str,
+				 char **_url,
+				 char **_target)
 {
-	const nsCString string (aString);
+        if (!str || !str[0])
+                return false;
 
-	const char *str = string.get ();
+        /* FIXMEchpe allo whitespace in front? */
 	if (str[0] != '<')
-		return PR_FALSE;
+		return false;
 
 	/* The expected form is "<URL> T<target> E<name=value pairs>".
 	 * But since this is untrusted input from the web, we'll make sure it conforms to this!
 	 */
 	const char *end = strchr (str, '>');
 	if (!end)
-		return PR_FALSE;
+		return false;
 
-	_url = nsDependentCSubstring (string, 1, PRUint32 (end - str - 1));
+//	_url = nsDependentCSubstring (string, 1, uint32_t (end - str - 1));
+        *_url = g_strndup (str + 1, end - str - 1);
 
 	const char *ext = strstr (end, " T<");
 	if (ext) {
 		const char *extend = strchr (ext, '>');
 		if (extend) {
-			_target = nsDependentCSubstring (ext + 3, PRUint32 (extend - ext - 3));
+                        *_target = g_strndup (ext + 3, extend - ext - 3);
+		//	_target = nsDependentCSubstring (ext + 3, uint32_t (extend - ext - 3));
 		}
 	}
 
@@ -1437,12 +1584,12 @@
 	if (ext) {
 		const char *extend = strchr (ext, '>');
 		if (extend) {
-			D ("E = %s", nsCString (ext + 3, PRUint32 (extend - ext - 3)).get ());
+			D ("E = %s", nsCString (ext + 3, uint32_t (extend - ext - 3)).get ());
 		}
 	}
 #endif
 
-	return PR_TRUE;
+	return true;
 }
 
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
@@ -1458,17 +1605,17 @@
 	    mConsole.Equals (NS_LITERAL_CSTRING ("_unique")) ||
 	    mConsole.Equals (NS_LITERAL_CSTRING ("_master"))) {
 		D ("We're the representant for the console class");
-		return nsnull;
+		return NULL;
 	}
 
-	totemPlugin *representant = nsnull;
+	totemPlugin *representant = NULL;
 
 	/* Try to find a the representant of the console class */
-	PRUint32 count = sPlugins->Length ();
-	for (PRUint32 i = 0; i < count; ++i) {
+	uint32_t count = sPlugins->Length ();
+	for (uint32_t i = 0; i < count; ++i) {
 		totemPlugin *plugin = sPlugins->ElementAt (i);
 
-		PRBool equal = PR_FALSE;
+		bool equal = false;
 		/* FIXME: is this correct? Maybe we should use the toplevel document
 		 * to allow frames (and check the frames for same-origin, obviously) ?
 		 */
@@ -1492,36 +1639,39 @@
 	return representant;
 }
 
-nsresult
-totemPlugin::SetConsole (const nsACString &aConsole)
+bool
+totemPlugin::SetConsole (const char * aConsole)
 {
 	/* Can't change console group */
-	if (!mConsole.IsEmpty ())
-		return NS_ERROR_ALREADY_INITIALIZED;
+	if (mConsole) {
+// 		return NS_ERROR_ALREADY_INITIALIZED;
+          // FIXMEchpe set exception
+          return false;
+        }
 
 	/* FIXME: we might allow this, and kill the viewer instead.
 	 * Or maybe not spawn the viewer if we don't have a console yet?
 	 */
 	if (mViewerPID)
-		return NS_ERROR_ALREADY_INITIALIZED;
+		return false; // FIXMEchpe throw exception
 
-	mConsole = aConsole;
+        mConsole = g_strdup (aConsole);
 
-	NS_ASSERTION (mConsoleClassRepresentant == nsnull, "Already have a representant");
+// 	assert (mConsoleClassRepresentant == NULL, "Already have a representant");
 
 	mConsoleClassRepresentant = FindConsoleClassRepresentant ();
-	mNeedViewer = (nsnull == mConsoleClassRepresentant);
+	mNeedViewer = (NULL == mConsoleClassRepresentant);
 
-	return NS_OK;
+	return true;
 }
 
 void
 totemPlugin::TransferConsole ()
 {
 	/* Find replacement representant */
-	totemPlugin *representant = nsnull;
+	totemPlugin *representant = NULL;
 
-	PRUint32 i, count = sPlugins->Length ();
+	uint32_t i, count = sPlugins->Length ();
 	for (i = 0; i < count; ++i) {
 		totemPlugin *plugin = sPlugins->ElementAt (i);
 
@@ -1538,7 +1688,7 @@
 	D ("Transferring console from %p to %p", (void*) this, (void*) representant);
 
 	/* Store new representant in the plugins */
-	representant->mConsoleClassRepresentant = nsnull;
+	representant->mConsoleClassRepresentant = NULL;
 	/* We can start at i since we got out when we found the first one in the loop above */
 	for ( ; i < count; ++i) {
 		totemPlugin *plugin = sPlugins->ElementAt (i);
@@ -1548,14 +1698,16 @@
 	}
 
 	/* Now transfer viewer ownership */
+#if 0
 	if (mScriptable) {
-		NS_ASSERTION (!representant->mScriptable, "WTF");
+		assert (!representant->mScriptable, "WTF");
 		representant->mScriptable = mScriptable;
 		mScriptable->SetPlugin (representant);
-		mScriptable = nsnull;
+		mScriptable = NULL;
 	}
+#endif
 
-	representant->mNeedViewer = PR_TRUE;
+	representant->mNeedViewer = true;
 
 	representant->mViewerPID = mViewerPID;
 	mViewerPID = 0;
@@ -1563,8 +1715,8 @@
 	representant->mViewerFD = mViewerFD;
 	mViewerFD = -1;
 
-	representant->mViewerBusAddress = mViewerBusAddress;
-	representant->mViewerServiceName = mViewerServiceName;
+	representant->mViewerBusAddress = g_strdup (mViewerBusAddress);
+	representant->mViewerServiceName = g_strdup (mViewerServiceName);
 
 	/* FIXME correct condition? */
 	if (mViewerSetUp)
@@ -1578,11 +1730,11 @@
 	if (mUnownedViewerSetUp)
 		return;
 
-	mUnownedViewerSetUp = PR_TRUE;
+	mUnownedViewerSetUp = true;
 
 	D ("UnownedViewerSetup");
 
-	NS_ASSERTION (mConsoleClassRepresentant, "We own the viewer!?");
+	assert (mConsoleClassRepresentant); /* We own the viewer!? */
 
 	UnownedViewerSetWindow ();
 }
@@ -1598,20 +1750,20 @@
 		return;
 	}
 
-	NS_ASSERTION (mConsoleClassRepresentant, "We own the viewer!");
+	assert (mConsoleClassRepresentant); /* We own the viewer! */
 
-	NS_ENSURE_TRUE (mConsoleClassRepresentant->mViewerProxy, );
+	assert (mConsoleClassRepresentant->mViewerProxy);
 
 	/* FIXME: do we need a reply callback? */
 	dbus_g_proxy_call_no_reply (mConsoleClassRepresentant->mViewerProxy,
 				    "SetWindow",
 				    G_TYPE_STRING, mControls.get (),
 				    G_TYPE_UINT, (guint) mWindow,
-				    G_TYPE_INT, (gint) mWidth,
-				    G_TYPE_INT, (gint) mHeight,
+				    G_TYPE_INT, mWidth,
+				    G_TYPE_INT, mHeight,
 				    G_TYPE_INVALID);
 
-	mWindowSet = PR_TRUE;
+	mWindowSet = true;
 }
 
 void
@@ -1623,16 +1775,16 @@
 	if (!mUnownedViewerSetUp)
 		return;
 
-	NS_ASSERTION (mConsoleClassRepresentant, "We own the viewer!");
+	assert (mConsoleClassRepresentant); /* We own the viewer! */
 
-	NS_ENSURE_TRUE (mConsoleClassRepresentant->mViewerProxy, );
+	assert (mConsoleClassRepresentant->mViewerProxy);
 
 	dbus_g_proxy_call_no_reply (mConsoleClassRepresentant->mViewerProxy,
 				    "UnsetWindow",
 				    G_TYPE_UINT, (guint) mWindow,
 				    G_TYPE_INVALID);
 
-	mWindowSet = PR_FALSE;
+	mWindowSet = false;
 }
 
 #endif /* TOTEM_COMPLEX_PLUGIN */
@@ -1656,37 +1808,22 @@
 	 */
 
 	NPError err;
-	err = CallNPN_GetValueProc (sNPN.getvalue,
-				    mInstance, NPNVserviceManager,
-				    reinterpret_cast<void *>
-                        (reinterpret_cast<void **>(&mServiceManager)));
-	if (err != NPERR_NO_ERROR || !mServiceManager) {
-		D ("Failed to get the service manager");
-		return NPERR_GENERIC_ERROR;
-	}
-
-	nsresult rv;
-	rv = mServiceManager->GetServiceByContractID (NS_IOSERVICE_CONTRACTID,
-						      NS_GET_IID (nsIIOService),
-						      reinterpret_cast<void **>(&mIOService));
-	if (NS_FAILED (rv) || !mIOService) {
-		D ("Failed to get IO service");
-		return NPERR_GENERIC_ERROR;
-	}
-
-	err = CallNPN_GetValueProc (sNPN.getvalue,
-				    mInstance, NPNVDOMElement,
-				    reinterpret_cast<void *>
-                        (reinterpret_cast<void **>(&mPluginDOMElement)));
-	if (err != NPERR_NO_ERROR || !mPluginDOMElement) {
-		D ("Failed to get our DOM Element");
+        err = NPN_GetValue (mNPP,
+                            NPNVPluginElementNPObject,
+                            getter_Retains (mPluginElement));
+	if (err != NPERR_NO_ERROR || mPluginElement.IsNull ()) {
+		D ("Failed to get our DOM Element NPObject");
 		return NPERR_GENERIC_ERROR;
 	}
 
 #if defined(TOTEM_COMPLEX_PLUGIN) && defined(HAVE_NSTARRAY_H)
-	rv = mPluginDOMElement->GetOwnerDocument (&mPluginOwnerDocument);
-	if (NS_FAILED (rv) || !mPluginOwnerDocument) {
-		D ("Plugin in a document!?");
+        /* FIXMEchpe untested; test this! */
+        if (!NPN_GetProperty (mNPP,
+                              mPluginElement,
+                              NPN_GetStringIdentifier ("ownerDocument"),
+                              getter_Retains (mPluginOwnerDocument)) ||
+            mPluginOwnerDocument.IsNull ()) {
+		D ("Failed to get the plugin element's ownerDocument");
 		return NPERR_GENERIC_ERROR;
 	}
 #endif /* TOTEM_COMPLEX_PLUGIN */
@@ -1696,50 +1833,20 @@
 	 * for non-MOZILLA_INTERNAL_API code). nsIDOM3Node isn't frozen either,
 	 * but should be safe enough.
 	 */
-	nsIDOM3Node *dom3Node = nsnull;
-	rv = CallQueryInterface (mPluginDOMElement, &dom3Node);
-	if (NS_FAILED (rv) || !dom3Node) {
-		D ("Failed to QI the DOM element to nsIDOM3Node");
-		return NPERR_GENERIC_ERROR;
-	}
-
-        /* FIXME: can we cache this, or can it change (so we'll need to re-get every time we use it)? */
-	nsString baseASpec;
-	rv = dom3Node->GetBaseURI (baseASpec);
-	if (NS_FAILED (rv) || baseASpec.IsEmpty ()) {
-		/* We can't go on without a base URI ! */
-		D ("Failed to get base URI spec");
-		return NPERR_GENERIC_ERROR;
-	}
-
-	NS_ConvertUTF16toUTF8 baseSpec (baseASpec);
-
-	D ("Base URI is '%s'", baseSpec.get ());
-
-	rv = mIOService->NewURI (baseSpec, nsnull /* FIXME: use document charset */,
-				 nsnull, &mBaseURI);
-	if (NS_FAILED (rv) || !mBaseURI) {
-		D ("Failed to construct base URI");
-		return NPERR_GENERIC_ERROR;
-	}
-
-        /* Create timer */
-        nsIComponentManager *compMan = nsnull;
-	rv = CallQueryInterface (mServiceManager, &compMan);
-        if (NS_FAILED (rv) || !compMan) {
-                D ("Failed to get component manager");
-                return NPERR_GENERIC_ERROR;
+	
+        /* This is a property on nsIDOM3Node */
+        totemNPVariantWrapper baseURI;
+        if (!NPN_GetProperty (mNPP,
+                              mPluginElement,
+                              NPN_GetStringIdentifier ("baseURI"),
+                              getter_Copies (baseURI)) ||
+            !baseURI.IsString ()) {
+          D ("Failed to get the base URI");
+          return NPERR_GENERIC_ERROR;
         }
 
-        /* FIXME ? */
-        rv = compMan->CreateInstanceByContractID (NS_TIMER_CONTRACTID,
-                                                  nsnull,
-                                                  NS_GET_IID (nsITimer),
-                                                  reinterpret_cast<void **>(&mTimer));
-        if (NS_FAILED (rv) || !mTimer) {
-                D ("Failed to create timer: rv=%x", rv);
-                return NPERR_GENERIC_ERROR;
-        }
+        mBaseURI = g_strdup (baseURI.GetString ());
+	D ("Base URI is '%s'", mBaseURI ? mBaseURI : "");
 
 	/* Setup DBus connection handling */
 	GError *error = NULL;
@@ -1771,9 +1878,9 @@
 				     NULL);
 
 	/* Find the "real" mime-type */
-	GetRealMimeType (mimetype, mMimeType);
+	SetRealMimeType (mimetype);
 
-	D ("Real mimetype for '%s' is '%s'", mimetype, mMimeType.get());
+	D ("Real mimetype for '%s' is '%s'", mimetype, mMimeType ? mMimeType : "(null)");
 
 	/* Now parse the attributes */
 	/* Note: argv[i] is NULL for the "PARAM" arg which separates the attributes
@@ -1796,7 +1903,7 @@
 	/* We only use the size attributes to detect whether we're hidden;
 	 * we'll get our real size from SetWindow.
 	 */
-	PRInt32 width = -1, height = -1;
+	int width = -1, height = -1;
 
 	value = (const char *) g_hash_table_lookup (args, "width");
 	if (value != NULL) {
@@ -1821,7 +1928,7 @@
 	/* Are we hidden? */
 	/* Treat hidden without a value as TRUE */
 	mHidden = g_hash_table_lookup (args, "hidden") != NULL &&
-		  GetBooleanValue (args, "hidden", PR_TRUE);
+		  GetBooleanValue (args, "hidden", true);
 
 	/* Used as a replacement for HIDDEN=TRUE attribute.
 	 * See http://mxr.mozilla.org/mozilla/source/modules/plugin/base/src/ns4xPluginInstance.cpp#1135
@@ -1830,20 +1937,18 @@
 	 * as -1 is our value for unset/unknown sizes
 	 */
 	if (width == 0 || height == 0)
-		mHidden = PR_TRUE;
+		mHidden = true;
 
 	/* Whether to automatically stream and play the content */
-	mAutostart = GetBooleanValue (args, "autoplay",
-				      GetBooleanValue (args, "autostart", mAutostart));
+	mAutoPlay = GetBooleanValue (args, "autoplay",
+				      GetBooleanValue (args, "autostart", mAutoPlay));
 
 	/* Whether to loop */
 	mRepeat = GetBooleanValue (args, "repeat",
-				   GetBooleanValue (args, "loop", PR_FALSE));
+				   GetBooleanValue (args, "loop", false));
 
 	/* Now collect URI attributes */
-	const char *src = nsnull, *href = nsnull, *qtsrc = nsnull, *filename = nsnull;
-
-	src = (const char *) g_hash_table_lookup (args, "src");
+	const char *src = (const char *) g_hash_table_lookup (args, "src");
 	/* DATA is only used in OBJECTs, see:
 	 * http://developer.mozilla.org/en/docs/Gecko_Plugin_API_Reference:Plug-in_Basics#Plug-in_Display_Modes
 	 */
@@ -1854,36 +1959,36 @@
 	if (!src) {
 		src = (const char *) g_hash_table_lookup (args, "data");
 	}
-	if (src) {
-		SetSrc (nsDependentCString (src));
-	}
+
+        SetSrc (src);
 
 #ifdef TOTEM_GMP_PLUGIN
 	/* http://windowssdk.msdn.microsoft.com/en-us/library/aa392440(VS.80).aspx */
-	filename = (const char *) g_hash_table_lookup (args, "filename");
+	const char *filename = (const char *) g_hash_table_lookup (args, "filename");
 	if (!filename)
 		filename = (const char *) g_hash_table_lookup (args, "url");
-	if (filename) {
-		SetURL (nsDependentCString (filename));
-	}
+
+        if (filename) {
+                SetURL (filename);
+        }
 #endif /* TOTEM_GMP_PLUGIN */
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
 	/* Target */
 	value = (const char *) g_hash_table_lookup (args, "target");
 	if (value) {
-		mTarget.Assign (value);
+                mTarget = g_strdup (value);
 	}
 
-	href = (const char *) g_hash_table_lookup (args, "href");
+	const char *href = (const char *) g_hash_table_lookup (args, "href");
 	if (href) {
-		SetHref (nsDependentCString (href));
+		SetHref (href);
 	}
 
 	/* http://developer.apple.com/documentation/QuickTime/QT6WhatsNew/Chap1/chapter_1_section_13.html */
-	qtsrc = (const char *) g_hash_table_lookup (args, "qtsrc");
+	const char *qtsrc = (const char *) g_hash_table_lookup (args, "qtsrc");
 	if (qtsrc) {
-		SetQtsrc (nsDependentCString (qtsrc));
+		SetQtsrc (qtsrc);
 	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 
@@ -1891,14 +1996,14 @@
 #ifdef TOTEM_MULLY_PLUGIN
 	value = (const char *) g_hash_table_lookup (args, "video");
 	if (value) {
-		SetSrc (nsDependentCString (value));
+                SetSrc (value);
 	}
 #endif /* TOTEM_MULLY_PLUGIN */
 
 #ifdef TOTEM_CONE_PLUGIN
 	value = (const char *) g_hash_table_lookup (args, "target");
 	if (value) {
-		SetSrc (nsDependentCString (value));
+                SetSrc (value);
 	}
 #endif /* TOTEM_CONE_PLUGIN */
 
@@ -1909,25 +2014,27 @@
 		mHref = g_strdup (mSrc);
 #endif /* TOTEM_MULLY_PLUGIN */
 
+        /* FIXMEchpe: check if this doesn't work anymore because the URLs aren't fully resolved! */
 	/* If we're set to start automatically, we'll use the src stream */
 	if (mRequestURI &&
-	    mRequestURI == mSrcURI) {
-		mExpectingStream = mAutostart;
+            mSrcURI &&
+            strcmp (mRequestURI, mSrcURI) == 0) {
+		mExpectingStream = mAutoPlay;
 	}
 
 	/* Caching behaviour */
 #ifdef TOTEM_NARROWSPACE_PLUGIN
 	if (strcmp (mimetype, "video/quicktime") != 0) {
-		mCache = PR_TRUE;
+		mCache = true;
 	}
 
 	mCache = GetBooleanValue (args, "cache", mCache);
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 
 #if defined (TOTEM_NARROWSPACE_PLUGIN) || defined (TOTEM_BASIC_PLUGIN)
-	mControllerHidden = !GetBooleanValue (args, "controller", PR_TRUE);
+	mControllerHidden = !GetBooleanValue (args, "controller", true);
 
-	mAutoPlay = GetBooleanValue (args, "autoplay", PR_TRUE);
+	mAutoPlay = GetBooleanValue (args, "autoplay", true);
 
 #endif /* TOTEM_NARROWSPACE_PLUGIN || TOTEM_BASIC_PLUGIN */
 
@@ -1961,7 +2068,7 @@
 		"TACCtrl",
 		"VolumeSlider",
 	};
-	PRUint32 control = GetEnumIndex (args, "controls",
+	uint32_t control = GetEnumIndex (args, "controls",
 				         kControls, G_N_ELEMENTS (kControls),
 					 0);
 	mControls = kControls[control];
@@ -1974,11 +2081,11 @@
 	value = (char *) g_hash_table_lookup (args, "uimode");
 	if (value != NULL) {
 		if (g_ascii_strcasecmp (value, "none") == 0) {
-			mControllerHidden = PR_TRUE;
+			mControllerHidden = true;
 		} else if (g_ascii_strcasecmp (value, "invisible") == 0) {
-			mHidden = PR_TRUE;
+			mHidden = true;
 		} else if (g_ascii_strcasecmp (value, "full") == 0) {
-			mShowStatusbar = PR_TRUE;
+			mShowStatusbar = true;
 		} else if (g_ascii_strcasecmp (value, "mini") == 0) {
 			;
 		}
@@ -1988,7 +2095,7 @@
 	 * http://www.htmlcodetutorial.com/embeddedobjects/_EMBED_CONTROLLER.html */
 	/* ShowXXX parameters as per http://support.microsoft.com/kb/285154 */
 	mControllerHidden = !GetBooleanValue (args, "controller",
-					      GetBooleanValue (args, "showcontrols", PR_TRUE));
+					      GetBooleanValue (args, "showcontrols", true));
 
 	mShowStatusbar = GetBooleanValue (args, "showstatusbar", mShowStatusbar);
 #endif /* TOTEM_GMP_PLUGIN */
@@ -2004,35 +2111,35 @@
 	 * controllers need to be showing, otherwise it's useless */
 #ifdef TOTEM_GMP_PLUGIN
 	if (height == 40 && !mControllerHidden) {
-		mAudioOnly = PR_TRUE;
+		mAudioOnly = true;
 	}
 #endif /* TOTEM_GMP_PLUGIN */
 #if defined(TOTEM_NARROWSPACE_PLUGIN) || defined (TOTEM_BASIC_PLUGIN)
 	if (height <= 16 && !mControllerHidden) {
-		mAudioOnly = PR_TRUE;
+		mAudioOnly = true;
 	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN || TOTEM_BASIC_PLUGIN */
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
 	/* We need to autostart if we're using an HREF
 	 * otherwise the start image isn't shown */
-	if (!mHref.IsEmpty ()) {
-		mExpectingStream = PR_TRUE;
-		mAutostart = PR_TRUE;
+	if (mHref) {
+		mExpectingStream = true;
+		mAutoPlay = true;
 	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 
 	/* Dump some disagnostics */
-	D ("mSrc: %s", mSrc.get ());
+	D ("mSrcURI: %s", mSrcURI ? mSrcURI : "");
 	D ("mCache: %d", mCache);
 	D ("mControllerHidden: %d", mControllerHidden);
 	D ("mShowStatusbar: %d", mShowStatusbar);
 	D ("mHidden: %d", mHidden);
 	D ("mAudioOnly: %d", mAudioOnly);
-	D ("mAutostart: %d, mRepeat: %d", mAutostart, mRepeat);
+	D ("mAutoPlay: %d, mRepeat: %d", mAutoPlay, mRepeat);
 #ifdef TOTEM_NARROWSPACE_PLUGIN
-	D ("mHref: %s", mHref.get ());
-	D ("mTarget: %s", mTarget.get ());
+	D ("mHref: %s", mHref ? mHref : "");
+	D ("mTarget: %s", mTarget ? mTarget : "");
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 #if defined(TOTEM_COMPLEX_PLUGIN) && defined(HAVE_NSTARRAY_H)
 	D ("mConsole: %s", mConsole.get ());
@@ -2093,10 +2200,9 @@
 		 * since, using gecko trunk (1.9), this causes the plugin to be destroyed,
 		 * if this is the automatic |src| stream. Same for the other calls below.
 		 */
-		return CallNPN_DestroyStreamProc (sNPN.destroystream,
-						  mInstance,
-						  stream,
-						  NPRES_DONE);
+		return NPN_DestroyStream (mNPP,
+                                          stream,
+                                          NPRES_DONE);
 	}
 
 	/* Either:
@@ -2109,14 +2215,13 @@
 	if (!mExpectingStream) {
 		D ("Not expecting a new stream; aborting stream");
 
-		return CallNPN_DestroyStreamProc (sNPN.destroystream,
-						  mInstance,
-						  stream,
-						  NPRES_DONE);
+		return NPN_DestroyStream (mNPP,
+                                          stream,
+                                          NPRES_DONE);
 	}
 
 	/* This was an expected stream, no more expected */
-	mExpectingStream = PR_FALSE;
+	mExpectingStream = false;
 
 #if 1 // #if 0
 	// This is fixed now _except_ the "if (!mViewerReady)" problem in StreamAsFile
@@ -2129,10 +2234,9 @@
 	if (!mViewerReady) {
 		D ("Viewer not ready, aborting stream");
 
-		return CallNPN_DestroyStreamProc (sNPN.destroystream,
-						  mInstance,
-						  stream,
-						  NPRES_DONE);
+		return NPN_DestroyStream (mNPP,
+                                          stream,
+                                          NPRES_DONE);
 	}
 #endif
 
@@ -2147,15 +2251,17 @@
 	}
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
-	if (mScriptable) {
-		mScriptable->mPluginState = totemScriptablePlugin::eState_Loading;
+        if (!mNPObjects[ePluginScriptable].IsNull ()) {
+                NPObject *object = mNPObjects[ePluginScriptable];
+                totemNarrowSpacePlayer *scriptable = static_cast<totemNarrowSpacePlayer*>(object);
+		scriptable->mPluginState = totemNarrowSpacePlayer::eState_Loading;
 	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 
 	mStream = stream;
 
-	mCheckedForPlaylist = PR_FALSE;
-	mIsPlaylist = PR_FALSE;
+	mCheckedForPlaylist = false;
+	mIsPlaylist = false;
 
 	/* To track how many data we get from ::Write */
 	mBytesStreamed = 0;
@@ -2173,7 +2279,7 @@
 
 	D ("DestroyStream reason %d", reason);
 
-	mStream = nsnull;
+	mStream = NULL;
 	mBytesStreamed = 0;
 	mBytesLength = 0;
 
@@ -2188,7 +2294,7 @@
 	return NPERR_NO_ERROR;
 }
 
-int32
+int32_t
 totemPlugin::WriteReady (NPStream *stream)
 {
 	/* FIXME this could probably be an assertion instead */
@@ -2213,10 +2319,10 @@
 	return 0;
 }
 
-int32
+int32_t
 totemPlugin::Write (NPStream *stream,
-		    int32 offset,
-		    int32 len,
+		    int32_t offset,
+		    int32_t len,
 		    void *buffer)
 {
 	/* FIXME this could probably be an assertion instead */
@@ -2237,13 +2343,13 @@
 	 * So we can only do this at the start of the stream.
 	 */
 	if (!mCheckedForPlaylist) {
-		NS_ASSERTION (offset == 0, "Not checked for playlist but not at the start of the stream!?");
+		assert (offset == 0); /* Not checked for playlist but not at the start of the stream!? */
 
-		mCheckedForPlaylist = PR_TRUE;
+		mCheckedForPlaylist = true;
 
 		if (totem_pl_parser_can_parse_from_data ((const char *) buffer, len, TRUE /* FIXME */)) {
 			D ("Is playlist; need to wait for the file to be downloaded completely");
-			mIsPlaylist = PR_TRUE;
+			mIsPlaylist = true;
 
 			/* Close the viewer */
 			dbus_g_proxy_call_no_reply (mViewerProxy,
@@ -2260,7 +2366,7 @@
 	int ret = write (mViewerFD, buffer, len);
 	/* FIXME shouldn't we retry if errno is EINTR ? */
 
-	if (NS_UNLIKELY (ret < 0)) {
+	if (G_UNLIKELY (ret < 0)) {
 		int err = errno;
 		D ("Write failed with errno %d: %s", err, g_strerror (err));
 
@@ -2268,10 +2374,9 @@
 			/* fd://0 got closed, probably because the backend
 			 * crashed on us. Destroy the stream.
 			 */
-			if (CallNPN_DestroyStreamProc (sNPN.destroystream,
-			    			       mInstance,
-						       mStream,
-						       NPRES_DONE) != NPERR_NO_ERROR) {
+			if (NPN_DestroyStream (mNPP,
+                                               mStream,
+                                               NPRES_DONE) != NPERR_NO_ERROR) {
 				g_warning ("Couldn't destroy the stream");
 			}
 		}
@@ -2306,14 +2411,12 @@
 		return;
 	}
 
-	NS_ASSERTION (mViewerProxy, "No viewer proxy");
-	NS_ASSERTION (mViewerReady, "Viewer not ready");
-
-	NS_ENSURE_TRUE (mRequestBaseURI && mRequestURI, );
+	assert (mViewerProxy); /* No viewer proxy!? */
+	assert (mViewerReady); /* Viewer not ready? */
 
-	nsCString baseSpec, spec;
-	mRequestBaseURI->GetSpec (baseSpec);
-	mRequestURI->GetSpec (spec);
+	//assert (mRequestBaseURI && mRequestURI, );
+        if (!mRequestBaseURI || !mRequestURI)
+          return;
 
 	/* FIXME: these calls need to be async!!
 	 * But the file may be unlinked as soon as we return from this
@@ -2326,8 +2429,8 @@
 					    "SetPlaylist",
 					    &error,
 					    G_TYPE_STRING, fname,
-					    G_TYPE_STRING, spec.get (),
-					    G_TYPE_STRING, baseSpec.get (),
+					    G_TYPE_STRING, mRequestURI,
+					    G_TYPE_STRING, mRequestBaseURI,
 					    G_TYPE_INVALID,
 					    G_TYPE_INVALID);
 	}
@@ -2340,8 +2443,8 @@
 					    "SetLocalFile",
 					    &error,
 					    G_TYPE_STRING, fname,
-					    G_TYPE_STRING, spec.get (),
-					    G_TYPE_STRING, baseSpec.get (),
+					    G_TYPE_STRING, mRequestURI,
+					    G_TYPE_STRING, mRequestBaseURI,
 					    G_TYPE_INVALID,
 					    G_TYPE_INVALID);
 	}
@@ -2364,8 +2467,10 @@
 		return;
 	}
 #ifdef TOTEM_NARROWSPACE_PLUGIN
-	if (mScriptable) {
-		mScriptable->mPluginState = totemScriptablePlugin::eState_Complete;
+        if (!mNPObjects[ePluginScriptable].IsNull ()) {
+                NPObject *object = mNPObjects[ePluginScriptable];
+                totemNarrowSpacePlayer *scriptable = static_cast<totemNarrowSpacePlayer*>(object);
+		scriptable->mPluginState = totemNarrowSpacePlayer::eState_Complete;
 	}
 #endif /* TOTEM_NARROWSPACE_PLUGIN */
 }
@@ -2392,37 +2497,91 @@
 			/* FIXME: show error to user? */
 		}
 
-		mExpectingStream = PR_FALSE;
+		mExpectingStream = false;
 	}
 }
 
-NPError
-totemPlugin::GetScriptable (void *_retval)
+NPObject*
+totemPlugin::GetNPObject (ObjectEnum which)
 {
-	D ("GetScriptable [%p]", (void*) this);
+  if (!mNPObjects[which].IsNull ())
+    return mNPObjects[which];
 
-#if defined(TOTEM_COMPLEX_PLUGIN) && defined(HAVE_NSTARRAY_H)
-	if (mConsoleClassRepresentant) {
-		return mConsoleClassRepresentant->GetScriptable (_retval);
-	}
-#endif /* TOTEM_COMPLEX_PLUGIN */
+  totemNPClass_base *npclass = 0;
 
-	if (!mScriptable) {
-		mScriptable = new totemScriptablePlugin (this);
-		if (!mScriptable)
-			return NPERR_OUT_OF_MEMORY_ERROR;
+#if defined(TOTEM_BASIC_PLUGIN)
+  npclass = totemBasicPlayerNPClass::Instance();
+#elif defined(TOTEM_GMP_PLUGIN)
+  switch (which) {
+    case ePluginScriptable:
+      npclass = totemGMPPlayerNPClass::Instance();
+      break;
+    case eGMPControls:
+      npclass = totemGMPControlsNPClass::Instance();
+      break;
+    case eGMPNetwork:
+      npclass = totemGMPNetworkNPClass::Instance();
+      break;
+    case eGMPSettings:
+      npclass = totemGMPSettingsNPClass::Instance();
+      break;
+  }
+#elif defined(TOTEM_COMPLEX_PLUGIN)
+  npclass = totemComplexPlayerNPClass::Instance();
+#elif defined(TOTEM_NARROWSPACE_PLUGIN)
+  npclass = totemNarrowSpacePlayerNPClass::Instance();
+#elif defined(TOTEM_MULLY_PLUGIN)
+  npclass = totemMullYPlayerNPClass::Instance();
+#elif defined(TOTEM_CONE_PLUGIN)
+  switch (which) {
+    case ePluginScriptable:
+      npclass = totemConeNPClass::Instance();
+      break;
+    case eConeAudio:
+      npclass = totemConeAudioNPClass::Instance();
+      break;
+    case eConeInput:
+      npclass = totemConeInputNPClass::Instance();
+      break;
+    case eConePlaylist:
+      npclass = totemConePlaylistNPClass::Instance();
+      break;
+    case eConePlaylistItems:
+      npclass = totemConePlaylistItemsNPClass::Instance();
+      break;
+    case eConeVideo:
+      npclass = totemConeVideoNPClass::Instance();
+      break;
+  }
+#else
+#error Unknown plugin type
+#endif
 
-#ifdef TOTEM_NARROWSPACE_PLUGIN
-		mScriptable->mPluginState = totemScriptablePlugin::eState_Waiting;
-#endif /* TOTEM_NARROWSPACE_PLUGIN */
+  if (!npclass)
+    return NULL;
 
-		NS_ADDREF (mScriptable);
-	}
+  mNPObjects[which] = do_CreateInstance (npclass, mNPP);
+  if (mNPObjects[which].IsNull ()) {
+    D ("Creating scriptable NPObject failed!");
+    return NULL;
+  }
+
+  return mNPObjects[which];
+}
+
+NPError
+totemPlugin::GetScriptableNPObject (void *_retval)
+{
+  D ("GetScriptableNPObject [%p]", (void *) this);
 
-	nsresult rv = mScriptable->QueryInterface (NS_GET_IID (nsISupports),
-						   reinterpret_cast<void **>(_retval));
+  NPObject *scriptable = GetNPObject (ePluginScriptable);
+  if (!scriptable)
+    return NPERR_GENERIC_ERROR;
 
-	return NS_SUCCEEDED (rv) ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
+  NPN_RetainObject (scriptable);
+
+  *reinterpret_cast<NPObject**>(_retval) = scriptable;
+  return NPERR_NO_ERROR;
 }
 
 /* static */ NPError
@@ -2447,9 +2606,33 @@
 		}
 
 		delete sPlugins;
-		sPlugins = nsnull;
+		sPlugins = NULL;
 	}
 #endif /* TOTEM_COMPLEX_PLUGIN */
 
+#if defined(TOTEM_BASIC_PLUGIN)
+        totemBasicPlayerNPClass::Shutdown ();
+#elif defined(TOTEM_GMP_PLUGIN)
+        totemGMPPlayerNPClass::Shutdown ();
+        totemGMPControlsNPClass::Shutdown ();
+        totemGMPNetworkNPClass::Shutdown ();
+        totemGMPSettingsNPClass::Shutdown ();
+#elif defined(TOTEM_COMPLEX_PLUGIN)
+#error FIXME
+#elif defined(TOTEM_NARROWSPACE_PLUGIN)
+        totemNarrowSpacePlayerNPClass::Shutdown ();
+#elif defined(TOTEM_MULLY_PLUGIN)
+        totemMullYPlayerNPClass::Shutdown ();
+#elif defined(TOTEM_CONE_PLUGIN)
+        totemConeNPClass::Shutdown ();
+        totemConeAudioNPClass::Shutdown ();
+        totemConeInputNPClass::Shutdown ();
+        totemConePlaylistNPClass::Shutdown ();
+        totemConePlaylistItemsNPClass::Shutdown ();
+        totemConeVideoNPClass::Shutdown ();
+#else
+#error Unknown plugin type
+#endif
+
 	return NPERR_NO_ERROR;
 }

Modified: trunk/browser-plugin/totemPlugin.h
==============================================================================
--- trunk/browser-plugin/totemPlugin.h	(original)
+++ trunk/browser-plugin/totemPlugin.h	Fri May 30 17:35:08 2008
@@ -2,7 +2,7 @@
  *
  * Copyright  2004 Bastien Nocera <hadess hadess net>
  * Copyright  2002 David A. Schleef <ds schleef org>
- * Copyright  2006 Christian Persch
+ * Copyright  2006, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -25,49 +25,46 @@
 
 #include <stdint.h>
 #include <dbus/dbus-glib.h>
-#include <npapi.h>
 
-#include <nsStringAPI.h>
+#include "npapi.h"
 
-#ifdef NEED_STRING_GLUE
-#include "totemStringGlue.h"
-#endif
-
-#if defined(TOTEM_COMPLEX_PLUGIN) && defined(HAVE_NSTARRAY_H)
-#include <nsTArray.h>
-#endif /* TOTEM_COMPLEX_PLUGIN */
+#include "totemNPClass.h"
+#include "totemNPObject.h"
+#include "totemNPObjectWrapper.h"
+#include "totemNPVariantWrapper.h"
 
 #include "totem-plugin-viewer-constants.h"
 
-class nsIDOMDocument;
-class nsIDOMElement;
-class nsIIOService;
-class nsIServiceManager;
-class nsITimer;
-class nsIURI;
-class nsVoidArray;
-class totemScriptablePlugin;
-struct _NPNetscapeFuncs;
+#define TOTEM_COMPLEX_VERSION_BUILD "10.0"
+#define TOTEM_NARROWSPACE_VERSION   "7.2.0"
+#define TOTEM_MULLY_VERSION         "1.4.0.233"
+#define TOTEM_CONE_VERSION          "0.8.6"
+#define TOTEM_GMP_VERSION_BUILD     "11.0.0.1024"
+
+typedef struct {
+  const char *mimetype;
+  const char *extensions;
+  const char *mime_alias;
+} totemPluginMimeEntry;
+
+class totemBasicPlayer;
+class totemComplexPlayer;
+class totemConePlayer;
+class totemGMPControls;
+class totemGMPError;
+class totemGMPPlayer;
+class totemGMPSettings;
+class totemMullYPlayer;
+class totemNarrowSpacePlayer;
 
 class totemPlugin {
   public:
-    totemPlugin (NPP aInstance);
+    totemPlugin (NPP aNPP);
     ~totemPlugin ();
   
-    void* operator new (size_t aSize) CPP_THROW_NEW;
-
-    /* Interface to scriptable */
-
-    nsresult DoCommand (const char *aCommand);
-    nsresult SetVolume (gdouble aVolume);
-    nsresult ClearPlaylist (void);
-    nsresult AddItem (const nsACString &aURI);
-    nsresult SetFullscreen (gboolean enabled);
-
-    nsresult SetSrc (const nsACString &aURL);
+    void* operator new (size_t aSize) throw ();
 
     /* plugin glue */
-    static _NPNetscapeFuncs sNPN;
 
     static NPError Initialise ();
     static NPError Shutdown ();
@@ -88,11 +85,11 @@
     NPError DestroyStream (NPStream* stream,
                            NPError reason);
   
-    int32 WriteReady (NPStream *stream);
-    int32 Write (NPStream *stream,
-                int32 offset,
-                int32 len,
-                void *buffer);
+    int32_t WriteReady (NPStream *stream);
+    int32_t Write (NPStream *stream,
+                   int32_t offset,
+                   int32_t len,
+                   void *buffer);
     void StreamAsFile (NPStream *stream,
                        const char* fname);
 
@@ -100,44 +97,47 @@
 		    NPReason reason,
 		    void *notifyData);
 
-    NPError GetScriptable (void *_retval);
+    NPError GetScriptableNPObject (void *_retval);
+
+    static char *PluginDescription ();
+    static char *PluginLongDescription();
+    static void PluginMimeTypes (const totemPluginMimeEntry **, uint32_t *);
 
   private:
 
-    static void PR_CALLBACK NameOwnerChangedCallback (DBusGProxy *proxy,
+    static void NameOwnerChangedCallback (DBusGProxy *proxy,
 						      const char *svc,
 						      const char *old_owner,
 						      const char *new_owner,
 						      void *aData);
 
-    static void PR_CALLBACK ViewerForkTimeoutCallback (nsITimer *aTimer,
-						       void *aData);
+    static gboolean ViewerForkTimeoutCallback (void *aData);
 
-    static void PR_CALLBACK ButtonPressCallback (DBusGProxy  *proxy,
+    static void ButtonPressCallback (DBusGProxy  *proxy,
 						 guint aTimestamp,
 		    				 guint aButton,
 					         void *aData);
 
-    static void PR_CALLBACK StopStreamCallback (DBusGProxy  *proxy,
+    static void StopStreamCallback (DBusGProxy  *proxy,
 						void *aData);
 
-    static void PR_CALLBACK TickCallback (DBusGProxy  *proxy,
+    static void TickCallback (DBusGProxy  *proxy,
     					  guint aTime,
     					  guint aDuration,
     					  char *aState,
 					  void *aData);
-    static void PR_CALLBACK PropertyChangeCallback (DBusGProxy  *proxy,
+    static void PropertyChangeCallback (DBusGProxy  *proxy,
     						    const char *type,
 						    GValue *value,
 						    void *aData);
 
-    static void PR_CALLBACK ViewerSetWindowCallback (DBusGProxy *aProxy,
+    static void ViewerSetWindowCallback (DBusGProxy *aProxy,
 						     DBusGProxyCall *aCall,
 						     void *aData);
-    static void PR_CALLBACK ViewerOpenStreamCallback (DBusGProxy *aProxy,
+    static void ViewerOpenStreamCallback (DBusGProxy *aProxy,
 						      DBusGProxyCall *aCall,
 						      void *aData);
-    static void PR_CALLBACK ViewerOpenURICallback (DBusGProxy *aProxy,
+    static void ViewerOpenURICallback (DBusGProxy *aProxy,
 						   DBusGProxyCall *aCall,
 						   void *aData);
 
@@ -155,105 +155,141 @@
 
     void ComputeRequest ();
     void ClearRequest ();
-    void RequestStream (PRBool aForceViewer);
+    void RequestStream (bool aForceViewer);
     void UnsetStream ();
 
-    PRBool IsMimeTypeSupported (const char *aMimeType,
-				const char *aURL);
-    PRBool IsSchemeSupported (nsIURI *aURI);
-    void GetRealMimeType (const char *aMimeType,
-			  nsACString &_retval);
-    PRBool ParseBoolean (const char *key,
-			 const char *value,
-			 PRBool default_val);
-    PRBool GetBooleanValue (GHashTable *args,
-			    const char *key,
-			    PRBool default_val);
-    PRUint32 GetEnumIndex (GHashTable *args,
+    bool IsMimeTypeSupported (const char *aMimeType,
+                              const char *aURL);
+    bool IsSchemeSupported (const char *aURI);
+    void SetRealMimeType (const char *aMimeType);
+    bool ParseBoolean (const char *key,
+                       const char *value,
+                       bool default_val);
+    bool GetBooleanValue (GHashTable *args,
+                          const char *key,
+                          bool default_val);
+    uint32_t GetEnumIndex (GHashTable *args,
 			   const char *key,
 			   const char *values[],
-			   PRUint32 n_values,
-			   PRUint32 default_value);
+			   uint32_t n_values,
+			   uint32_t default_value);
 
-    NPP mInstance;
+    NPP mNPP;
 
-    /* FIXME make these use nsCOMPtr<> !! */
-    totemScriptablePlugin *mScriptable;
-    nsIServiceManager *mServiceManager;
-    nsIIOService *mIOService;
-    nsIDOMElement *mPluginDOMElement;
-    nsITimer *mTimer;
-    nsIURI *mBaseURI;
+    totemNPObjectWrapper mPluginElement;
 
-    nsIURI *mRequestBaseURI;
-    nsIURI *mRequestURI;
+    guint mTimerID;
 
     /* Stream data */
     NPStream *mStream;
   public:
-    PRUint32 mBytesStreamed;
-    PRUint32 mBytesLength;
+    uint32_t mBytesStreamed;
+    uint32_t mBytesLength;
   private:
-    PRUint8 mStreamType;
-
-    nsCString mMimeType;
+    uint8_t mStreamType;
 
-    nsCString mSrc;
-    nsIURI *mSrcURI;
+    char* mMimeType;
 
-    Window mWindow;
-    PRInt32 mWidth;
-    PRInt32 mHeight;
+    char* mBaseURI;
+    char* mSrcURI; /* relative to mBaseURI */
+    char* mRequestBaseURI;
+    char* mRequestURI; /* relative to mRequestBaseURI */
 
     DBusGConnection *mBusConnection;
     DBusGProxy *mBusProxy;
     DBusGProxy *mViewerProxy;
     DBusGProxyCall *mViewerPendingCall;
-    nsCString mViewerBusAddress;
-    nsCString mViewerServiceName;
+    char* mViewerBusAddress;
+    char* mViewerServiceName;
     int mViewerPID;
     int mViewerFD;
 
-  public:
-    PRUint32 mTime;
-    PRUint32 mDuration;
-    TotemStates mState;
+    Window mWindow;
+    int mWidth;
+    int mHeight;
+
+  private:
+
+    bool mAllowContextMenu;
+    bool mAudioOnly;
+    bool mAutoPlay;
+    bool mCache;
+    bool mCheckedForPlaylist;
+    bool mControllerHidden;
+    bool mControllerVisible;
+    bool mExpectingStream;
+    bool mHadStream;
+    bool mHidden;
+    bool mIsFullscreen;
+    bool mIsLooping;
+    bool mIsMute;
+    bool mIsPlaylist;
+    bool mIsSupportedSrc;
+    bool mIsWindowless;
+    bool mKioskMode;
+    bool mLoopIsPalindrome;
+    bool mMute;
+    bool mNeedViewer;
+    bool mPlayEveryFrame;
+    bool mRepeat;
+    bool mRequestIsSrc;
+    bool mResetPropertiesOnReload;
+    bool mShowStatusbar;
+    bool mTimerRunning;
+    bool mUnownedViewerSetUp;
+    bool mViewerReady;
+    bool mViewerSetUp;
+    bool mWaitingForButtonPress;
+    bool mWindowSet;
+
+    char *mBackgroundColor;
+    char *mMatrix;
+    char *mRectangle;
+    char *mMovieName;
+
     double mVolume;
-    PRBool mIsFullscreen;
+
+    TotemStates mState;
+
+    uint32_t mDuration;
+    uint32_t mTime;
 
 #ifdef TOTEM_GMP_PLUGIN
   public:
-    nsresult SetURL (const nsACString &aURL);
+    void SetURL (const char* aURL);
+    const char* URL() const { return mURLURI; }
 
   private:
-    nsIURI *mURLURI;
+    char* mURLURI;
 #endif
 
 #ifdef TOTEM_NARROWSPACE_PLUGIN
   public:
-    nsresult SetQtsrc (const nsCString &aURL);
-    nsresult SetHref (const nsCString& aURL);
+    bool SetQtsrc (const char* aURL);
+    bool SetHref (const char* aURL);
 
-  private:
-    PRBool ParseURLExtensions (const nsACString &aString,
-			       nsACString &_url,
-			       nsACString &_target);
-
-    void LaunchTotem (const nsCString &aURL,
-		      PRUint32 aTimestamp);
-
-    nsIURI *mQtsrcURI;
-
-    nsCString mHref;
-    nsIURI *mHrefURI;
+    const char* QtSrc () const { return mQtsrcURI; }
+    const char* Href () const { return mHref; }
+    const char* Target () const { return mTarget; }
 
-    nsCString mTarget;
+  private:
+    bool ParseURLExtensions (const char* aString,
+			     char* *_url,
+			     char* *_target);
+
+    void LaunchTotem (const char* aURL,
+		      uint32_t aTimestamp);
+
+    char* mQtsrcURI;
+    char* mHref;
+    char* mHrefURI;
+    char* mTarget;
 #endif
 
-#if defined(TOTEM_COMPLEX_PLUGIN) && defined(HAVE_NSTARRAY_H)
+#if 0 //defined(TOTEM_COMPLEX_PLUGIN) && defined(HAVE_NSTARRAY_H)
   public:
 
-    nsresult SetConsole (const nsACString &aConsole);
+    bool SetConsole (const char* aConsole);
 
   private:
 
@@ -264,9 +300,9 @@
     void UnownedViewerSetWindow ();
     void UnownedViewerUnsetWindow ();
 
-    nsIDOMDocument *mPluginOwnerDocument;
-    nsCString mConsole;
-    nsCString mControls;
+    totemNPObjectWrapper mPluginOwnerDocument;
+    char* mConsole;
+    char* mControls;
 
     /* nsnull if we're the representant ourself */
     totemPlugin *mConsoleClassRepresentant;
@@ -275,37 +311,101 @@
 
 #endif /* TOTEM_COMPLEX_PLUGIN */
 
+  public:
+
+    enum ObjectEnum {
+      ePluginScriptable,
+#if defined(TOTEM_GMP_PLUGIN)
+      eGMPControls,
+      eGMPNetwork,
+      eGMPSettings,
+#elif defined(TOTEM_CONE_PLUGIN)
+      eConeAudio,
+      eConeInput,
+      eConePlaylist,
+      eConePlaylistItems,
+      eConeVideo,
+#endif
+      eLastNPObject
+    };
+
   private:
 
-    PRUint32 mAutostart : 1;
-    PRUint32 mAutoPlay : 1;
-    PRUint32 mCache : 1;
-    PRUint32 mCheckedForPlaylist : 1;
-    PRUint32 mControllerHidden : 1;
-    PRUint32 mExpectingStream : 1;
-    PRUint32 mHadStream : 1;
-    PRUint32 mHidden : 1;
-    PRUint32 mIsPlaylist : 1;
-    PRUint32 mIsSupportedSrc : 1;
-    PRUint32 mNeedViewer : 1;
-    PRUint32 mRepeat : 1;
-    PRUint32 mRequestIsSrc : 1;
-    PRUint32 mShowStatusbar : 1;
-    PRUint32 mTimerRunning : 1;
-    PRUint32 mUnownedViewerSetUp : 1;
-    PRUint32 mViewerReady : 1;
-    PRUint32 mViewerSetUp : 1;
-    PRUint32 mWaitingForButtonPress : 1;
-    PRUint32 mWindowSet : 1;
-    PRUint32 mAudioOnly : 1;
-};
+    totemNPObjectWrapper mNPObjects[eLastNPObject];
 
-typedef struct {
-  const char *mimetype;
-  const char *extensions;
-  const char *mime_alias;
-} totemPluginMimeEntry;
+  public:
+
+    NPObject* GetNPObject (ObjectEnum which);
+
+    bool SetSrc (const char* aURL);
+    const char* Src() const { return mSrcURI; }
+
+    void Command (const char *aCommand);
+    void ClearPlaylist ();
+    int32_t AddItem (const char*);
+
+    void SetIsWindowless (bool enabled) { mIsWindowless = enabled; }
+    bool IsWindowless () const { return mIsWindowless; }
+
+    void SetVolume (double aVolume);
+    double Volume () const { return mVolume; }
+
+    void SetMute (bool mute);
+    bool IsMute () const { return mIsMute; }
+
+    void SetFullscreen (bool enabled);
+    bool IsFullscreen () const { return mIsFullscreen; }
+
+    void SetAllowContextMenu (bool enabled) { mAllowContextMenu = enabled; }
+    bool AllowContextMenu () const { return mAllowContextMenu; }
+
+    void SetLooping (bool enabled);
+    bool IsLooping () const { return mIsLooping; }
 
-const char *totem_plugin_get_long_description (void);
+    void SetAutoPlay (bool enabled);
+    bool AutoPlay () const { return mAutoPlay; }
+
+    void SetControllerVisible (bool enabled);
+    bool IsControllerVisible () const { return !mControllerHidden; }
+
+    void SetKioskMode (bool enabled) { mKioskMode = enabled; }
+    bool IsKioskMode () const { return mKioskMode; }
+
+    void SetLoopIsPalindrome (bool enabled) { mLoopIsPalindrome = enabled; }
+    bool IsLoopPalindrome () const { return mLoopIsPalindrome; }
+
+    void SetPlayEveryFrame (bool enabled) { mPlayEveryFrame = enabled; }
+    bool PlayEveryFrame () const { return mPlayEveryFrame; }
+
+    void SetBackgroundColor (const char* color);
+    const char *BackgroundColor () const { return mBackgroundColor; }
+
+    void SetMatrix (const char* matrix);
+    const char* Matrix () const { return mMatrix; }
+
+    void SetRectangle (const char *rectangle);
+    const char* Rectangle () const { return mRectangle; }
+
+    void SetMovieName (const char *name);
+    const char* MovieName () const { return mMovieName; }
+
+    void SetResetPropertiesOnReload (bool enabled) { mResetPropertiesOnReload = enabled; }
+    bool ResetPropertiesOnReload () const { return mResetPropertiesOnReload; }
+
+    void SetRate (double rate);
+    double Rate () const;
+
+    double Duration () const { return double (mDuration); }
+
+    int32_t BytesStreamed () const { return mBytesStreamed; }
+
+    int32_t BytesLength () const { return mBytesLength; }
+
+    uint32_t Time () const { return mTime; }
+
+    TotemStates State () const { return mState; }
+
+    uint32_t Bandwidth () const { return 300000; /* bit/s */ /* FIXMEchpe! */ }
+};
 
 #endif /* __TOTEM_PLUGIN_H__ */

Modified: trunk/browser-plugin/totemPluginGlue.cpp
==============================================================================
--- trunk/browser-plugin/totemPluginGlue.cpp	(original)
+++ trunk/browser-plugin/totemPluginGlue.cpp	Fri May 30 17:35:08 2008
@@ -1,8 +1,8 @@
 /* Totem Mozilla plugin
  * 
- * Copyright (C) 2004-2006 Bastien Nocera <hadess hadess net>
- * Copyright (C) 2002 David A. Schleef <ds schleef org>
- * Copyright (C) 2006 Christian Persch
+ * Copyright  2004-2006 Bastien Nocera <hadess hadess net>
+ * Copyright  2002 David A. Schleef <ds schleef org>
+ * Copyright  2006, 2008 Christian Persch
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -20,8 +20,9 @@
  * Boston, MA 02110-1301  USA.
  */
 
-#include <mozilla-config.h>
-#include "config.h"
+#include <config.h>
+
+#include <string.h>
 
 #include <gio/gio.h>
 #include <dlfcn.h>
@@ -29,13 +30,12 @@
 #include "npapi.h"
 #include "npupp.h"
 
-#define GNOME_ENABLE_DEBUG 1
-/* define GNOME_ENABLE_DEBUG for more debug spew */
 #include "debug.h"
 
-#include "totemPluginGlue.h"
 #include "totemPlugin.h"
 
+NPNetscapeFuncs NPNFuncs; /* used in npn_gate.cpp */
+
 static char *mime_list = NULL;
 
 static NPError
@@ -54,14 +54,14 @@
 	if (!plugin)
 		return NPERR_OUT_OF_MEMORY_ERROR;
 
+	instance->pdata = reinterpret_cast<void*> (plugin);
+
 	NPError rv = plugin->Init (mimetype, mode, argc, argn, argv, savedData);
 	if (rv != NPERR_NO_ERROR) {
 		delete plugin;
-		plugin = nsnull;
+		instance->pdata = 0;
 	}
 
-	instance->pdata = plugin;
-
 	return rv;
 }
 
@@ -72,13 +72,13 @@
 	if (!instance)
 		return NPERR_INVALID_INSTANCE_ERROR;
 
-	totemPlugin *plugin = (totemPlugin *) instance->pdata;
+	totemPlugin *plugin = reinterpret_cast<totemPlugin*> (instance->pdata);
 	if (!plugin)
 		return NPERR_NO_ERROR;
 
 	delete plugin;
 
-	instance->pdata = nsnull;
+	instance->pdata = 0;
 
 	return NPERR_NO_ERROR;
 }
@@ -90,7 +90,7 @@
 	if (!instance)
 		return NPERR_INVALID_INSTANCE_ERROR;
 
-	totemPlugin *plugin = (totemPlugin *) instance->pdata;
+	totemPlugin *plugin = reinterpret_cast<totemPlugin*> (instance->pdata);
 	if (!plugin)
 		return NPERR_INVALID_INSTANCE_ERROR;
 
@@ -107,7 +107,7 @@
 	if (!instance)
 		return NPERR_INVALID_INSTANCE_ERROR;
 
-	totemPlugin *plugin = (totemPlugin *) instance->pdata;
+	totemPlugin *plugin = reinterpret_cast<totemPlugin*> (instance->pdata);
 	if (!plugin)
 		return NPERR_INVALID_INSTANCE_ERROR;
 
@@ -125,38 +125,38 @@
 		return NPERR_NO_ERROR;
 	}
 
-	totemPlugin *plugin = (totemPlugin *) instance->pdata;
+	totemPlugin *plugin = reinterpret_cast<totemPlugin*> (instance->pdata);
 	if (!plugin)
 		return NPERR_INVALID_INSTANCE_ERROR;
 
 	return plugin->DestroyStream (stream, reason);
 }
 
-static int32
+static int32_t
 totem_plugin_write_ready (NPP instance,
 			  NPStream *stream)
 {
 	if (!instance)
 		return -1;
 
-	totemPlugin *plugin = (totemPlugin *) instance->pdata;
+	totemPlugin *plugin = reinterpret_cast<totemPlugin*> (instance->pdata);
 	if (!plugin)
 		return -1;
 
 	return plugin->WriteReady (stream);
 }
 
-static int32
+static int32_t
 totem_plugin_write (NPP instance,
 		    NPStream *stream,
-		    int32 offset,
-		    int32 len,
+		    int32_t offset,
+		    int32_t len,
 		    void *buffer)
 {
 	if (!instance)
 		return -1;
 
-	totemPlugin *plugin = (totemPlugin *) instance->pdata;
+	totemPlugin *plugin = reinterpret_cast<totemPlugin*> (instance->pdata);
 	if (!plugin)
 		return -1;
 
@@ -171,7 +171,7 @@
 	if (!instance)
 		return;
 
-	totemPlugin *plugin = (totemPlugin *) instance->pdata;
+	totemPlugin *plugin = reinterpret_cast<totemPlugin*> (instance->pdata);
 	if (!plugin)
 		return;
 
@@ -187,7 +187,7 @@
 	if (!instance)
 		return;
 
-	totemPlugin *plugin = (totemPlugin *) instance->pdata;
+	totemPlugin *plugin = reinterpret_cast<totemPlugin*> (instance->pdata);
 	if (!plugin)
 		return;
 
@@ -201,10 +201,12 @@
 	D ("Print");
 }
 
-const char *
-totem_plugin_get_long_description (void)
+static int16_t
+totem_plugin_handle_event (NPP instance,
+                           void* event)
 {
-	return "The <a href=\"http://www.gnome.org/projects/totem/\";>Totem</a> " PACKAGE_VERSION " plugin handles video and audio streams.";
+	D ("Handle event");
+        return FALSE;
 }
 
 static NPError
@@ -212,59 +214,39 @@
 			NPPVariable variable,
 		        void *value)
 {
-	totemPlugin *plugin = nsnull;
+	totemPlugin *plugin = 0;
 	NPError err = NPERR_NO_ERROR;
 
-	/* See NPPVariable in npapi.h */
-	D ("GetValue variable %d (%x)", variable, variable);
-
 	if (instance) {
-		plugin = (totemPlugin *) instance->pdata;
+                plugin = reinterpret_cast<totemPlugin*> (instance->pdata);
 	}
 
+	/* See NPPVariable in npapi.h */
 	switch (variable) {
 	case NPPVpluginNameString:
-		*((char **)value) = totemScriptablePlugin::PluginDescription ();
+		*((char **)value) = totemPlugin::PluginDescription ();
 		break;
 	case NPPVpluginDescriptionString:
-		*((char **)value) = totemScriptablePlugin::PluginLongDescription ();
+		*((char **)value) = totemPlugin::PluginLongDescription ();
 		break;
 	case NPPVpluginNeedsXEmbed:
+                // FIXMEchpe fix webkit which passes a (unsigned int*) here...
 		*((NPBool *)value) = TRUE;
 		break;
-	case NPPVpluginScriptableIID: {
-		nsIID* ptr = static_cast<nsIID *>(totemPlugin::sNPN.memalloc (sizeof (nsIID)));
-		if (ptr) {
-			*ptr = NS_GET_IID (nsISupports);
-			*static_cast<nsIID **>(value) = ptr;
-		} else {
-			err = NPERR_OUT_OF_MEMORY_ERROR;
-		}
-		break;
-	}
-	case NPPVpluginScriptableInstance: {
-		if (plugin) {
-			err = plugin->GetScriptable (value);
-		}
-		else {
-			err = NPERR_INVALID_PLUGIN_ERROR;
-		}
-		break;
-	}
-	case NPPVjavascriptPushCallerBool:
-		D ("Unhandled variable NPPVjavascriptPushCallerBool");
-		err = NPERR_INVALID_PARAM;
-		break;
-	case NPPVpluginKeepLibraryInMemory:
-		D ("Unhandled variable NPPVpluginKeepLibraryInMemory");
-		err = NPERR_INVALID_PARAM;
+	case NPPVpluginScriptableIID:
+	case NPPVpluginScriptableInstance:
+                /* XPCOM scripting, obsolete */
+                err = NPERR_GENERIC_ERROR;
 		break;
 	case NPPVpluginScriptableNPObject:
-		D ("Unhandled variable NPPVpluginScriptableNPObject");
-		err = NPERR_INVALID_PARAM;
+                if (plugin) {
+                        err = plugin->GetScriptableNPObject (value);
+                } else {
+			err = NPERR_INVALID_PLUGIN_ERROR;
+                }
 		break;
 	default:
-		D ("Unhandled variable");
+		D ("Unhandled variable %d instance %p", variable, plugin);
 		err = NPERR_INVALID_PARAM;
 		break;
 	}
@@ -323,6 +305,7 @@
 		}
 	}
 
+        // FIXME g_free (key);
 	return retval;
 }
 
@@ -365,9 +348,9 @@
 	g_free (user_ini_file);
 
 	const totemPluginMimeEntry *mimetypes;
-	PRUint32 count;
-	totemScriptablePlugin::PluginMimeTypes (&mimetypes, &count);
-	for (PRUint32 i = 0; i < count; ++i) {
+	uint32_t count;
+	totemPlugin::PluginMimeTypes (&mimetypes, &count);
+	for (uint32_t i = 0; i < count; ++i) {
 		char *desc;
 
 		if (totem_plugin_mimetype_is_disabled (mimetypes[i].mimetype, system, user))
@@ -399,42 +382,49 @@
 	return mime_list;
 }
 
+// FIXMEchpe!!!!
+typedef enum {
+  NPNVGtk12 = 1,
+  NPNVGtk2
+} NPNToolkitType;
+
 NPError
-NP_Initialize (NPNetscapeFuncs * aMozillaFuncs,
-	       NPPluginFuncs * plugin_funcs)
+NP_Initialize (NPNetscapeFuncs *aMozillaVTable,
+	       NPPluginFuncs *aPluginVTable)
 {
-	NPError err = NPERR_NO_ERROR;
-	NPBool supportsXEmbed = PR_FALSE;
-	NPNToolkitType toolkit = (NPNToolkitType) 0;
-
 	D ("NP_Initialize");
 
-	/* Do we support XEMBED? */
-	err = CallNPN_GetValueProc (aMozillaFuncs->getvalue, NULL,
-			NPNVSupportsXEmbedBool,
-			(void *)&supportsXEmbed);
-
-	if (err != NPERR_NO_ERROR || supportsXEmbed != PR_TRUE)
-		return NPERR_INCOMPATIBLE_VERSION_ERROR;
-
-	/* Are we using a GTK+ 2.x Moz? */
-	err = CallNPN_GetValueProc (aMozillaFuncs->getvalue, NULL,
-			NPNVToolkit, (void *)&toolkit);
+	if (aMozillaVTable == NULL || aPluginVTable == NULL)
+		return NPERR_INVALID_FUNCTABLE_ERROR;
 
-	if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2)
+	if ((aMozillaVTable->version >> 8) > NP_VERSION_MAJOR)
 		return NPERR_INCOMPATIBLE_VERSION_ERROR;
 
-	if(aMozillaFuncs == NULL || plugin_funcs == NULL)
+	if (aMozillaVTable->size < sizeof (NPNetscapeFuncs))
+		return NPERR_INVALID_FUNCTABLE_ERROR;
+	if (aPluginVTable->size < sizeof (NPPluginFuncs))
 		return NPERR_INVALID_FUNCTABLE_ERROR;
 
-	if ((aMozillaFuncs->version >> 8) > NP_VERSION_MAJOR)
+        /* Copy the function table. We can use memcpy here since we've already
+         * established that the aMozillaVTable is at least as big as the compile-
+         * time NPNetscapeFuncs.
+         */
+        memcpy (&NPNFuncs, aMozillaVTable, sizeof (NPNetscapeFuncs));
+        NPNFuncs.size = sizeof (NPNetscapeFuncs);
+#if 0 // FIXMEchpe
+	/* Do we support XEMBED? */
+	NPError err;
+	NPBool supportsXEmbed = 0;
+	err = NPN_GetValue (NULL, NPNVSupportsXEmbedBool, (void *) &supportsXEmbed);
+	if (err != NPERR_NO_ERROR || !supportsXEmbed)
 		return NPERR_INCOMPATIBLE_VERSION_ERROR;
-	/* FIXME: check instead: indexof (last known entry in NPNetscapeFuncs) */
-	if (aMozillaFuncs->size < sizeof (NPNetscapeFuncs))
-		return NPERR_INVALID_FUNCTABLE_ERROR;
-	if (plugin_funcs->size < sizeof (NPPluginFuncs))
-		return NPERR_INVALID_FUNCTABLE_ERROR;
 
+        /* Are we using a GTK+ 2.x Moz? */
+	NPNToolkitType toolkit = (NPNToolkitType) 0;
+	err = NPN_GetValue (NULL, NPNVToolkit, (void *) &toolkit);
+	if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2)
+		return NPERR_INCOMPATIBLE_VERSION_ERROR;
+#endif
 	/* we want to open libdbus-glib-1.so.2 in such a way
 	 * in such a way that it becomes permanentely resident */
 	void *handle;
@@ -446,69 +436,28 @@
 	/* RTLD_NODELETE allows us to close right away ... */
 	dlclose(handle);
 
-
-	/*
-	 * 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
-	 * to copy the fields one by one, rather than assigning the whole
-	 * structure, because the Mozilla function table could actually be
-	 * bigger than what we expect.
-	 */
-	totemPlugin::sNPN.size             = aMozillaFuncs->size;
-	totemPlugin::sNPN.version          = aMozillaFuncs->version;
-	totemPlugin::sNPN.geturl           = aMozillaFuncs->geturl;
-	totemPlugin::sNPN.posturl          = aMozillaFuncs->posturl;
-	totemPlugin::sNPN.requestread      = aMozillaFuncs->requestread;
-	totemPlugin::sNPN.newstream        = aMozillaFuncs->newstream;
-	totemPlugin::sNPN.write            = aMozillaFuncs->write;
-	totemPlugin::sNPN.destroystream    = aMozillaFuncs->destroystream;
-	totemPlugin::sNPN.status           = aMozillaFuncs->status;
-	totemPlugin::sNPN.uagent           = aMozillaFuncs->uagent;
-	totemPlugin::sNPN.memalloc         = aMozillaFuncs->memalloc;
-	totemPlugin::sNPN.memfree          = aMozillaFuncs->memfree;
-	totemPlugin::sNPN.memflush         = aMozillaFuncs->memflush;
-	totemPlugin::sNPN.reloadplugins    = aMozillaFuncs->reloadplugins;
-	totemPlugin::sNPN.getJavaEnv       = aMozillaFuncs->getJavaEnv;
-	totemPlugin::sNPN.getJavaPeer      = aMozillaFuncs->getJavaPeer;
-	totemPlugin::sNPN.geturlnotify     = aMozillaFuncs->geturlnotify;
-	totemPlugin::sNPN.posturlnotify    = aMozillaFuncs->posturlnotify;
-	totemPlugin::sNPN.getvalue         = aMozillaFuncs->getvalue;
-	totemPlugin::sNPN.setvalue         = aMozillaFuncs->setvalue;
-	totemPlugin::sNPN.invalidaterect   = aMozillaFuncs->invalidaterect;
-	totemPlugin::sNPN.invalidateregion = aMozillaFuncs->invalidateregion;
-	totemPlugin::sNPN.forceredraw      = aMozillaFuncs->forceredraw;
-
 	/*
 	 * Set up a plugin function table that Mozilla will use to call
 	 * into us.  Mozilla needs to know about our version and size and
 	 * have a UniversalProcPointer for every function we implement.
 	 */
 
-	plugin_funcs->size = sizeof(NPPluginFuncs);
-	plugin_funcs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
-	plugin_funcs->newp = NewNPP_NewProc(totem_plugin_new_instance);
-	plugin_funcs->destroy =
-		NewNPP_DestroyProc(totem_plugin_destroy_instance);
-	plugin_funcs->setwindow =
-		NewNPP_SetWindowProc(totem_plugin_set_window);
-	plugin_funcs->newstream =
-		NewNPP_NewStreamProc(totem_plugin_new_stream);
-	plugin_funcs->destroystream =
-		NewNPP_DestroyStreamProc(totem_plugin_destroy_stream);
-	plugin_funcs->asfile =
-		NewNPP_StreamAsFileProc(totem_plugin_stream_as_file);
-	plugin_funcs->writeready =
-		NewNPP_WriteReadyProc(totem_plugin_write_ready);
-	plugin_funcs->write = NewNPP_WriteProc(totem_plugin_write);
-	/* Printing ? */
-	plugin_funcs->print = NewNPP_PrintProc(totem_plugin_print);
-	/* What's that for ? */
-	plugin_funcs->event = NewNPP_HandleEventProc(NULL);
-	plugin_funcs->urlnotify =
-		NewNPP_URLNotifyProc(totem_plugin_url_notify);
-	plugin_funcs->javaClass = NULL;
-	plugin_funcs->getvalue = NewNPP_GetValueProc(totem_plugin_get_value);
-	plugin_funcs->setvalue = NewNPP_SetValueProc(totem_plugin_set_value);
+	aPluginVTable->size           = sizeof (NPPluginFuncs);
+	aPluginVTable->version        = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
+	aPluginVTable->newp           = NewNPP_NewProc (totem_plugin_new_instance);
+	aPluginVTable->destroy        = NewNPP_DestroyProc (totem_plugin_destroy_instance);
+	aPluginVTable->setwindow      = NewNPP_SetWindowProc (totem_plugin_set_window);
+	aPluginVTable->newstream      = NewNPP_NewStreamProc (totem_plugin_new_stream);
+	aPluginVTable->destroystream  = NewNPP_DestroyStreamProc (totem_plugin_destroy_stream);
+	aPluginVTable->asfile         = NewNPP_StreamAsFileProc (totem_plugin_stream_as_file);
+	aPluginVTable->writeready     = NewNPP_WriteReadyProc (totem_plugin_write_ready);
+	aPluginVTable->write          = NewNPP_WriteProc (totem_plugin_write);
+	aPluginVTable->print          = NewNPP_PrintProc (totem_plugin_print);
+	aPluginVTable->event          = NewNPP_HandleEventProc (totem_plugin_handle_event);
+	aPluginVTable->urlnotify      = NewNPP_URLNotifyProc (totem_plugin_url_notify);
+	aPluginVTable->javaClass      = NULL; 
+	aPluginVTable->getvalue       = NewNPP_GetValueProc (totem_plugin_get_value);
+	aPluginVTable->setvalue       = NewNPP_SetValueProc (totem_plugin_set_value);
 
 	D ("NP_Initialize succeeded");
 

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Fri May 30 17:35:08 2008
@@ -632,89 +632,20 @@
 
 AC_ARG_ENABLE([browser-plugins],
 	[AS_HELP_STRING([--enable-browser-plugins],[compile the totem browser plugins])],
-	[],[enable_browser_plugins=autodetect])
-
-# Backward compatibility
-AC_ARG_ENABLE([mozilla],[],[enable_browser_plugins=$enableval],[])
-
+	[],[enable_browser_plugins=yes])
 AC_MSG_RESULT([$enable_browser_plugins])
 
-# Check which mozilla to use
-
-if test "$enable_browser_plugins" != "no" ; then
-	AC_MSG_CHECKING([which gecko to use])
-
-	AC_ARG_WITH([gecko],
-		[AS_HELP_STRING([--with-gecko],[Which gecko engine to use (default: autodetect)])])
-
-	# backward compat
-	AC_ARG_WITH([mozilla],[],[with_gecko=$withval])
-
-	GECKOS="xulrunner firefox mozilla-firefox seamonkey mozilla"
-	gecko=$with_gecko
-
-	if test -z "$with_gecko"; then
-		dnl Autodetect gecko
-		for g in $GECKOS; do
-			if $PKG_CONFIG --exists $g-xpcom; then
-				gecko=$g
-				break;
-			fi
-		done
-	elif ! $PKG_CONFIG --exists $gecko-xpcom; then
-		AC_MSG_ERROR([Gecko "$gecko" not found])
-	fi
-
-	if test -z "$gecko" -a "$enable_browser_plugins" = "autodetect"; then
-		dnl No gecko found, disable plugin
-		AC_MSG_WARN([No gecko found, disabling plugin])
-		enable_browser_plugins=no
-	elif test -z "$gecko"; then
-		AC_MSG_ERROR([No gecko found])
-	elif ! ( echo "$GECKOS" | egrep "(^| )$gecko(\$| )" > /dev/null); then
-		AC_MSG_ERROR([Unknown gecko "$gecko" specified])
-	else
-		enable_browser_plugins=yes
-	fi
-
-	AC_MSG_RESULT([$gecko])
-
-	case "$gecko" in
-		mozilla) MOZILLA_VERSION_MIN=1.7 ;;
-		seamonkey) MOZILLA_VERSION_MIN=1.0 ;;
-		*firefox) MOZILLA_VERSION_MIN=1.0 ;;
-		xulrunner) MOZILLA_VERSION_MIN=1.8 ;;
-	esac
-
-	MOZILLA=$gecko
-	AC_SUBST([MOZILLA])
+if test "$enable_browser_plugins" = "yes" ; then
+	AC_DEFINE([ENABLE_BROWSER_PLUGINS],[1],[Define to build the browser plugin])
 
-	if test "$enable_cxx_warnings" != "no" -a "$GXX" = "yes"; then
-		PLUGIN_EXTRA_WARN_CXXFLAGS="-Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Woverloaded-virtual"
-	else
-		PLUGIN_EXTRA_WARN_CXXFLAGS=
-	fi
-	AC_SUBST([PLUGIN_EXTRA_WARN_CXXFLAGS])
-fi
+	BROWSER_PLUGIN_DIR="\${libdir}/mozilla/plugins"
+	AC_ARG_VAR([BROWSER_PLUGIN_DIR],[Where to install the plugin to])
 
-# Check for mozilla modules, but keep the CFLAGS and LIBS in
-# separate vars
-if test "$enable_browser_plugins" = "yes" ; then
-	PKG_CHECK_MODULES([MOZILLA_NOT_LINKED],
-		[$MOZILLA-xpcom >= $MOZILLA_VERSION_MIN \
-		 $MOZILLA-plugin],,
-                [enable_browser_plugins=no])
-fi
-# Check for other required modules, and merge CFLAGS, but not link
-# flags to avoid linking against -lxpcom -lplds4 -lplc4 -lnspr4
-if test "$enable_browser_plugins" = "yes" ; then
 	PKG_CHECK_MODULES([BROWSER_PLUGIN],
 		[glib-2.0
-		 gthread-2.0
 		 totem-plparser-mini >= $TOTEM_PLPARSER_REQS],
 		[],[enable_browser_plugins=no])
 
-	BROWSER_PLUGIN_CFLAGS="$MOZILLA_NOT_LINKED_CFLAGS $BROWSER_PLUGIN_CFLAGS"
 	AC_SUBST([BROWSER_PLUGIN_CFLAGS])
 	AC_SUBST([BROWSER_PLUGIN_LIBS])
 
@@ -724,9 +655,7 @@
 			[AC_MSG_ERROR([
 				The Browser plugin requires shared-mime-info
 				>= 0.22 to function.])])
-fi
 
-if test "$enable_browser_plugins" = "yes" ; then
 	PKG_CHECK_MODULES([DBUS], [dbus-glib-1 >= $DBUS_REQS],,
 			[enable_browser_plugins=no])
 	DBUSLIBDIR="`$PKG_CONFIG dbus-glib-1 --variable=libdir`"
@@ -736,108 +665,14 @@
 		AC_MSG_WARN([dbus-binding-tool not found])
 		enable_browser_plugins=no
 	fi
-fi
 
-if test "$enable_browser_plugins" = "yes" ; then
 	PKG_CHECK_MODULES([SN], [ libstartup-notification-1.0 >= 0.8 ], [enable_browser_plugins=yes], [enable_browser_plugins=no])
 	if test "x$enable_browser_plugins" != "xyes" ; then
 		AC_MSG_WARN([libstartup-notification not found, necessary to build the plugin viewer])
 	fi
-fi
-
-# Sets some variables, and check for xpidl
-if test "$enable_browser_plugins" = "yes" ; then
-	MOZILLA_PREFIX="`$PKG_CONFIG $MOZILLA-xpcom --variable=prefix`"
-	MOZILLA_LIBDIR="`$PKG_CONFIG $MOZILLA-xpcom --variable=libdir`"
-	MOZILLA_INCLUDE_ROOT="`$PKG_CONFIG --variable=includedir $MOZILLA-xpcom`"
-	MOZILLA_XPCOM_CFLAGS="-I`$PKG_CONFIG --variable=includedir $MOZILLA-xpcom`"
-	MOZILLA_PLUGINDIR="${MOZILLA_PLUGINDIR:-"\${libdir}/mozilla/plugins"}"
-
-	AC_PATH_PROG([MOZILLA_XPIDL], [xpidl], [no], [$MOZILLA_LIBDIR:$PATH])
-	if test "x$MOZILLA_XPIDL" = "xno"; then
-		AC_MSG_ERROR([xpidl compiler not found])
-	fi
-
-	AC_PATH_PROG([MOZILLA_XPT_LINK],[xpt_link],[no],[$MOZILLA_LIBDIR:$PATH])
-	if test "$MOZILLA_XPT_LINK" = "no"; then
-		AC_MSG_ERROR([xpt_link not found])
-	fi
 
-	AC_SUBST([MOZILLA_PREFIX])
-	AC_SUBST([MOZILLA_LIBDIR])
-	AC_SUBST([MOZILLA_XPCOM_CFLAGS])
-	AC_SUBST([MOZILLA_INCLUDE_ROOT])
-	AC_ARG_VAR([MOZILLA_PLUGINDIR],[Where to install the plugin to])
-fi
-
-# Search for the idl include directory
-if test "$enable_browser_plugins" = "yes" ; then
-	dnl This only works on gecko 1.8
-	MOZILLA_IDLDIR="`$PKG_CONFIG --variable=idldir $MOZILLA-xpcom`"
-	dnl Fallback for older versions
-	if test "x$MOZILLA_IDLDIR" = "x"; then
-		MOZILLA_IDLDIR="`echo $MOZILLA_LIBDIR | sed -e s!lib!share/idl!`"
-	fi
-	dnl Some distributions (Gentoo) have it in unusual places
-	if test "x$MOZILLA_IDLDIR" = "x"; then
-		MOZILLA_IDLDIR="$MOZILLA_INCLUDE_ROOT/idl"
-	fi
+        # check for -fno-rtti flag
 
-	AC_SUBST([MOZILLA_IDLDIR])
-fi
-
-if test "$enable_browser_plugins" = "yes" ; then
-	AC_DEFINE([ENABLE_BROWSER_PLUGINS],[1],[Define if you build the mozilla plugin])
-fi
-
-AM_CONDITIONAL([ENABLE_BROWSER_PLUGINS], [test "$enable_browser_plugins" = "yes"])
-
-# check for libxpcomglue_s
-
-LIBXPCOMGLUE_S=
-
-if test "$enable_browser_plugins" = "yes"; then
-	AC_LANG_PUSH([C++])
-	__SAVE_CPPFLAGS=$CPPFLAGS
-	__SAVE_CXXFLAGS=$CXXFLAGS
-	__SAVE_LIBS=$LIBS
-	__SAVE_LDFLAGS=$LDFLAGS
-
-	CPPFLAGS="$CPPFLAGS -I$MOZILLA_INCLUDE_ROOT"
-	CXXFLAGS="$CXXFLAGS $MOZILLA_NOT_LINKED_CFLAGS"
-	LIBS="$LIBS -L$MOZILLA_LIBDIR -lxpcom -lxpcomglue_s"
-	LDFLAGS="$LDFLAGS -Wl,--rpath -Wl,$MOZILLA_LIBDIR"
-
-	AC_MSG_CHECKING([for libxpcomglue_s])
-	AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-#include <mozilla-config.h>
-#include <nsStringAPI.h>
-		]],[[
-nsCString s;
-const char *t = s.get ();
-		]])],
-	[have_libxpcomglue_s=yes],
-	[have_libxpcomglue_s=no])
-	AC_MSG_RESULT([$have_libxpcomglue_s])
-
-	CPPFLAGS=$__SAVE_CPPFLAGS
-	CXXFLAGS=$__SAVE_CXXFLAGS
-	LIBS=$__SAVE_LIBS
-	LDFLAGS=$__SAVE_LDFLAGS
-	AC_LANG_POP([C++])
-
-	if test "$have_libxpcomglue_s" = "yes"; then
-		LIBXPCOMGLUE_S="-L$MOZILLA_LIBDIR -lxpcomglue_s"
-	else
-		AC_MSG_WARN([libxpcomglue_s not available; plugins may not be portable])
-	fi
-fi
-
-AC_SUBST([LIBXPCOMGLUE_S])
-
-# check for -fno-rtti flag
-
-if test "$enable_browser_plugins" = "yes"; then
 	AC_LANG_PUSH([C++])
 	__SAVE_CXXFLAGS=$CXXFLAGS
 	CXXFLAGS="-fno-rtti $CXXFLAGS"
@@ -854,31 +689,7 @@
 	fi
 fi
 
-# check for some additional xpcom headers and for string compatibility
-
-if test "$enable_browser_plugins" = "yes"; then
-	AC_LANG_PUSH([C++])
-	__SAVE_CPPFLAGS=$CPPFLAGS
-	CPPFLAGS="$CPPFLAGS $MOZILLA_NOT_LINKED_CFLAGS -I$MOZILLA_INCLUDE_ROOT -I$MOZILLA_INCLUDE_ROOT/xpcom"
-
-	AC_CHECK_HEADERS([nsTArray.h])
-
-	AC_MSG_CHECKING([whether we need string glue])
-	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
-				#include <mozilla-config.h>
-				#include <nsStringAPI.h>
-		],[
-				nsDependentCString test("Test");
-		])],[need_string_glue=no],[need_string_glue=yes])
-	AC_MSG_RESULT([$need_string_glue])
-
-	CPPFLAGS=$__SAVE_CPPFLAGS
-	AC_LANG_POP([C++])
-
-	if test "$need_string_glue" = "yes"; then
-		AC_DEFINE([NEED_STRING_GLUE],[1],[Define if we need string glue])
-	fi
-fi
+AM_CONDITIONAL([ENABLE_BROWSER_PLUGINS], [test "$enable_browser_plugins" = "yes"])
 
 # check which plugins to enable
 
@@ -899,7 +710,7 @@
 AC_MSG_CHECKING([whether to enable the Complex browser plugin])
 AC_ARG_ENABLE([complex-plugin],
 	AS_HELP_STRING([--enable-complex-plugin],[Whether to enable the complex browser plugin]),
-	[],[enable_complex_plugin=yes])
+	[],[enable_complex_plugin=no])
 AC_MSG_RESULT([$enable_complex_plugin])
 
 AC_MSG_CHECKING([whether to enable the NarrowSpace browser plugin])
@@ -1069,7 +880,6 @@
 src/plugins/publish/Makefile
 src/backend/Makefile
 browser-plugin/Makefile
-browser-plugin/idl/Makefile
 data/Makefile
 data/totem.desktop.in.in
 data/icons/Makefile

Modified: trunk/src/plugins/bemused/totem-bemused.c
==============================================================================
--- trunk/src/plugins/bemused/totem-bemused.c	(original)
+++ trunk/src/plugins/bemused/totem-bemused.c	Fri May 30 17:35:08 2008
@@ -413,7 +413,6 @@
 write_directory_listing (TotemBemusedPlugin *tp, GIOChannel *source, gboolean at_root)
 {
 	char *filename;
-	char *root;
 	char buf[2];
 
 	if (at_root == FALSE)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]