gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r9900: Add a query to XPCOM code to


From: Russell Nelson
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9900: Add a query to XPCOM code to get our XPI install directory. Install via XPI now works!
Date: Wed, 01 Oct 2008 21:34:00 -0400
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9900
committer: Russell Nelson <address@hidden>
branch nick: trunk
timestamp: Wed 2008-10-01 21:34:00 -0400
message:
  Add a query to XPCOM code to get our XPI install directory.  Install via XPI 
now works!
modified:
  macros/xpcom.m4
  packaging/xpi.am
  plugin/Makefile.am
  plugin/plugin.cpp
  plugin/xpcom/GnashComponent.h
=== modified file 'macros/xpcom.m4'
--- a/macros/xpcom.m4   2008-09-01 20:33:39 +0000
+++ b/macros/xpcom.m4   2008-10-02 01:34:00 +0000
@@ -57,7 +57,12 @@
   if test x$xpcom = xyes; then
     if test x$cross_compiling = xno; then
       if test x"$PKG_CONFIG" != x -a x"${ac_cv_path_xpcom_incl}" = x; then
-        $PKG_CONFIG --exists libxul && ac_cv_path_xpcom_incl="`$PKG_CONFIG 
--cflags-only-I libxul`"
+        # prefer libxul-unstable for cflags.
+        if $PKG_CONFIG --exists libxul-unstable; then
+          ac_cv_path_xpcom_incl="`$PKG_CONFIG --cflags-only-I libxul-unstable`"
+        else
+          $PKG_CONFIG --exists libxul && ac_cv_path_xpcom_incl="`$PKG_CONFIG 
--cflags-only-I libxul`"
+        fi
         $PKG_CONFIG --exists libxul && ac_cv_path_xpcom_lib="`$PKG_CONFIG 
--libs libxul`"
         $PKG_CONFIG --exists libxul && ac_cv_path_xpidl="`$PKG_CONFIG 
--libs-only-L libxul`"
       fi
@@ -69,6 +74,7 @@
     XPCOM_IDL_CFLAGS=`echo $XPCOM_CFLAGS | sed -e 's:include:share/idl:'`
     XPIDL=`echo ${ac_cv_path_xpidl} | sed -e 's:-L::' -e 's:sdk-::' -e 
's:sdk/lib::' -e 's:-devel::' -e 's:lib$::'`
     XPIDL="${XPIDL}xpidl"
+    AC_DEFINE([HAVE_XPCOM], [1], [Use XPCOM in the NPAPI plugin])
   else
     XPCOM_CFLAGS=""
     XPIDL=""

=== modified file 'packaging/xpi.am'
--- a/packaging/xpi.am  2008-09-19 15:35:34 +0000
+++ b/packaging/xpi.am  2008-10-02 01:34:00 +0000
@@ -34,33 +34,20 @@
        --enable-gui=gtk \
        --with-npapi-plugindir=/tmp/plugin
 
-xpi-unpack: Makefile #$(top_builddir)/config.status
-       address@hidden -f xpi-*         # nuke everything, we're starting over
-       address@hidden -f xpi-unpack
-       rm -rf $(XPI_BUILD)
+xpi xpi-bundle:
+       rm -rf $(XPI_BUILD) # extract the tarball.
        tar jxf $(XPI_BUILD).tar.bz2
-       @touch xpi-unpack
-
-xpi-configure: xpi-unpack $(XPI_BUILD)
-       address@hidden -f ipkg-configure
-       cd $(XPI_BUILD); ./configure $(CONFIG_OPTS) --disable-shared 
--enable-static --enable-xpcom
-       @touch xpi-configure
-
-xpi-build: xpi-configure
-       address@hidden -f xpi-build
-       $(MAKE) -C $(XPI_BUILD) all
+
+       (cd $(XPI_BUILD); ./configure $(CONFIG_OPTS) --disable-shared 
--enable-static --enable-xpcom) # configure for speed.
+
+       $(MAKE) -C $(XPI_BUILD) all # build and install in temp
        $(MAKE) -C $(XPI_BUILD) install DESTDIR=$(XPI_TMP)
-       @touch xpi-build
 
-xpi-plugin: 
-       address@hidden -f xpi-plugin
-       cd $(XPI_BUILD); ./configure $(CONFIG_OPTS) --disable-static 
--enable-shared --enable-xpcom
-       $(MAKE) -C $(XPI_BUILD)/plugin clean all GNASHBINDIR=
+       (cd $(XPI_BUILD); ./configure $(CONFIG_OPTS) --disable-static 
--enable-shared --enable-xpcom) # configure for the plugin.
+       $(MAKE) -C $(XPI_BUILD)/plugin clean all GNASHBINDIR= # build and get 
the plugin
        $(MAKE) -C $(XPI_BUILD) install-plugin DESTDIR=$(XPI_TMP)
        $(MAKE) -C $(XPI_BUILD)/plugin/xpcom install-pkglib DESTDIR=$(XPI_TMP)
-       address@hidden xpi-plugin
 
-xpi xpi-bundle: xpi-build xpi-plugin
        if ! test -d $(XPI_BUNDLE)/ ; then \
          mkdir $(XPI_BUNDLE); \
         else \
@@ -72,6 +59,7 @@
        done;
        mkdir -p $(XPI_BUNDLE)/plugins
        cp -fr $(XPI_TMP)$(bindir)/*gnash $(XPI_BUNDLE)/plugins
+       strip $(XPI_BUNDLE)/plugins/gtk-gnash
        cp -fr $(XPI_TMP)$(localedir) $(XPI_BUNDLE)/
        cp -fr $(XPI_TMP)/tmp/plugin/libgnashplugin.so $(XPI_BUNDLE)/plugins
        cp -fr $(XPI_TMP)/tmp/plugin/extensions/*.xpt $(XPI_BUNDLE)/plugins

=== modified file 'plugin/Makefile.am'
--- a/plugin/Makefile.am        2008-08-10 22:22:53 +0000
+++ b/plugin/Makefile.am        2008-10-02 01:34:00 +0000
@@ -28,6 +28,11 @@
 SUBDIRS += mozilla-sdk
 
 if XPCOM
+AM_CXXFLAGS=-fshort-wchar
+INCLUDES = \
+        $(XPCOM_CFLAGS)
+AM_LDFLAGS = \
+        $(XPCOM_LIBS)
 SUBDIRS += xpcom
 endif
 if WIN32

=== modified file 'plugin/plugin.cpp'
--- a/plugin/plugin.cpp 2008-09-15 06:51:53 +0000
+++ b/plugin/plugin.cpp 2008-10-02 01:34:00 +0000
@@ -72,6 +72,15 @@
 #include "prerror.h"
 #include "prthread.h"
 
+#if HAVE_XPCOM
+#include "nscore.h"
+#include "nsISupports.h"
+#include "nsIServiceManager.h"
+#include "nsIExtensionManager.h"
+#include "nsIFile.h"
+#include "nsStringAPI.h"
+#endif
+
 using namespace std;
 
 extern NPNetscapeFuncs NPNFuncs;
@@ -742,11 +751,70 @@
        }
 }
 
+#if HAVE_XPCOM
+int
+getHome(string& gnashpath)
+{
+       nsresult rv;
+
+       // this is probably a good place to get the service manager
+       // note that Mozilla will add reference, so do not forget to release
+       nsISupports * sm = NULL;
+
+       // Get service manager
+       //cerr << "Getting Path" << NPN_GetValue(NULL, NPNVserviceManager, &sm) 
<< "\n";
+
+       // Mozilla returns nsIServiceManager so we can use it directly;
+       // doing QI on nsISupports here can still be more appropriate in
+       // case something is changed in the future so we don't need to 
+       // do casting of any sort.
+
+       // valid service manager
+       if(!sm) return -1;
+
+       nsIServiceManager * gServiceManager = NULL;
+       rv = sm->QueryInterface(NS_GET_IID(nsIServiceManager), 
(void**)&gServiceManager);
+
+       nsIFile *file = NULL;
+       nsIInstallLocation * installLocation = NULL;
+       nsIExtensionManager * nsExtensionService = NULL;
+
+       // Gets extension service
+       rv = 
gServiceManager->GetServiceByContractID("@mozilla.org/extensions/manager;1", 
NS_GET_IID(nsIExtensionManager), (void **)&nsExtensionService);
+       //cerr << "gSM" << rv << " " << (nsExtensionService == NULL) << "\n";
+       if (!nsExtensionService) return -2;
+       
+       // Gets install location object
+       rv = 
nsExtensionService->GetInstallLocation(NS_LITERAL_STRING("{2b70f2b1-fc72-4734-bb81-4eb2a7713e49}"),
 (nsIInstallLocation**)&installLocation);
+       //cerr << "nES" << rv << " " << (installLocation == NULL) << "\n";
+       if (!installLocation) return -3;
+
+       // Gets information on file in the extension - here, "address@hidden" 
is the ID of the plugin. install.rdf is a file stored in the plugin
+       rv = 
installLocation->GetItemFile(NS_LITERAL_STRING("{2b70f2b1-fc72-4734-bb81-4eb2a7713e49}"),
 NS_LITERAL_STRING("plugins/gnash"), (nsIFile**)&file);
+       //cerr << "iL" << rv << " " << (file == NULL) << "\n";
+       if (!file) return -4;
+
+       // We get the path (stored as unicode in nsName)
+       nsString sName;
+       file->GetPath(sName);
+
+               //const NPString& propValue = 
NS_LossyConvertUTF16toASCII(sName);
+       gnashpath = ToNewCString(NS_LossyConvertUTF16toASCII(sName));
+       //cerr << "Path" << gnashpath << "\n";
+       return 0;
+}
+#endif
+
 void
 nsPluginInstance::startProc(Window win)
 {
        string procname;
        char *gnash_env = std::getenv("GNASH_PLAYER");
+#if HAVE_XPCOM
+       if (getHome(procname) >= 0)
+               ;
+       else
+#endif
        if (gnash_env == NULL) {
                procname = GNASHBINDIR;
                procname += "/gtk-gnash";

=== modified file 'plugin/xpcom/GnashComponent.h'
--- a/plugin/xpcom/GnashComponent.h     2008-08-12 05:11:32 +0000
+++ b/plugin/xpcom/GnashComponent.h     2008-10-02 01:34:00 +0000
@@ -15,8 +15,8 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-#ifndef _MY_COMPONENT_H_
-#define _MY_COMPONENT_H_
+#ifndef GNASH_COMPONENT_H
+#define GNASH_COMPONENT_H
 
 #include "iGnashComponent.h"
 #include "nsStringAPI.h"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]