[Spice-devel] [spice-xpi 9/9] Switch to using npapi-sdk headers rather than XUL

Christophe Fergeau cfergeau at redhat.com
Thu Mar 7 07:39:35 PST 2013


Using the XUL SDK to build a plugin is quite overkill as all that
is needed are a few headers. Using these headers means less dependencies,
which makes things easier to build spice-xpi on other platforms.
---
 SpiceXPI/src/plugin/Makefile.am  |  4 ++++
 SpiceXPI/src/plugin/np_entry.cpp |  7 -------
 SpiceXPI/src/plugin/plugin.cpp   |  7 -------
 configure.ac                     | 30 +-----------------------------
 4 files changed, 5 insertions(+), 43 deletions(-)

diff --git a/SpiceXPI/src/plugin/Makefile.am b/SpiceXPI/src/plugin/Makefile.am
index 0b40a37..c331b15 100644
--- a/SpiceXPI/src/plugin/Makefile.am
+++ b/SpiceXPI/src/plugin/Makefile.am
@@ -28,6 +28,10 @@ libnsISpicec_la_SOURCES =			\
 	glib-compat.h				\
 	controller.cpp				\
 	controller.h				\
+	npapi/npapi.h				\
+	npapi/npfunctions.h			\
+	npapi/npruntime.h			\
+	npapi/nptypes.h				\
 	np_entry.cpp				\
 	npn_gate.cpp				\
 	npp_gate.cpp				\
diff --git a/SpiceXPI/src/plugin/np_entry.cpp b/SpiceXPI/src/plugin/np_entry.cpp
index 7b4d666..949a9df 100644
--- a/SpiceXPI/src/plugin/np_entry.cpp
+++ b/SpiceXPI/src/plugin/np_entry.cpp
@@ -169,17 +169,10 @@ NPError NP_Initialize(NPNetscapeFuncs *aNPNFuncs, NPPluginFuncs *aNPPFuncs)
     return NS_PluginInitialize();
 }
 
-#ifdef NPAPI_USE_CONSTCHARS
 const char *NP_GetMIMEDescription()
 {
     return NPP_GetMIMEDescription();
 }
-#else
-char *NP_GetMIMEDescription()
-{
-    return NPP_GetMIMEDescription();
-}
-#endif
 
 NPError NP_GetValue(void *future, NPPVariable aVariable, void *aValue)
 {
diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
index 33765a7..98f2d8f 100644
--- a/SpiceXPI/src/plugin/plugin.cpp
+++ b/SpiceXPI/src/plugin/plugin.cpp
@@ -103,17 +103,10 @@ namespace {
     }
 }
 
-#ifdef NPAPI_USE_CONSTCHARS
 const char *NPP_GetMIMEDescription(void)
 {
     return const_cast<char *>(MIME_TYPES_DESCRIPTION.c_str());
 }
-#else
-char *NPP_GetMIMEDescription(void)
-{
-    return strdup(MIME_TYPES_DESCRIPTION.c_str());
-}
-#endif
 
 //////////////////////////////////////
 //
diff --git a/configure.ac b/configure.ac
index f02c695..4035f5c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,6 +16,7 @@ AC_PROG_LIBTOOL
 AM_PROG_CC_C_O
 
 AC_DEFINE([XP_UNIX], 1, [Building Linux plugin])
+AC_DEFINE([HAVE_XUL191], 1, [Build for newer XUL])
 
 dnl =========================================================================
 dnl Check deps
@@ -33,35 +34,6 @@ AC_SUBST(GLIB_LIBS)
 PKG_CHECK_MODULES(XUL, libxul-embedding >= 1.9 nspr >= 4.7.1)
 AC_SUBST(XUL_CFLAGS)
 AC_SUBST(XUL_LIBS)
-
-# test for const return value of NPP_GetMIMEDescription, based on gecko-mediaplayer
-AC_MSG_CHECKING([for const return value of NPP_GetMIMEDescription])
-oCFLAGS=$CFLAGS
-CFLAGS="$XUL_CFLAGS"
-AC_LANG_PUSH([C])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
-#ifndef XP_UNIX
-#define XP_UNIX 1
-#endif
-#include <npapi.h>
-#if NP_VERSION_MAJOR == 0 && NP_VERSION_MINOR < 27
-#error
-#else
-const char*NPP_GetMIMEDescription(void) {
-  return "test";
-}
-#endif
-],[
-const char *f=NPP_GetMIMEDescription();
-])],[
-    AC_MSG_RESULT([yes])
-    AC_DEFINE([NPAPI_USE_CONSTCHARS],[1],[Define if NPAPI declares NPP_GetMIMEDescription as a const char*])
-],[
-    AC_MSG_RESULT([no])
-])
-AC_LANG_POP([C])
-CFLAGS=$oCFLAGS
-
 # Find xpidl
 XPIDL=`pkg-config --variable=libdir libxul`/xpidl
 AM_CONDITIONAL([HAVE_XPIDL], [test -x "$XPIDL"])
-- 
1.8.1.4



More information about the Spice-devel mailing list