gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_start-


From: Rob Savoye
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_start-62-g3240ec3
Date: Mon, 14 Feb 2011 16:56:29 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  3240ec352539a3c119d3c73fbb948f92b058988f (commit)
       via  0aecfe8e43995f5de3b0d5890b6a52a9895e2d51 (commit)
      from  147329a931cd7d80d3b69cf8bfb392b2a88dab6b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=3240ec352539a3c119d3c73fbb948f92b058988f


commit 3240ec352539a3c119d3c73fbb948f92b058988f
Author: Rob Savoye <address@hidden>
Date:   Mon Feb 14 09:55:43 2011 -0700

    handle multiple messages in a packet.

diff --git a/plugin/npapi/external.cpp b/plugin/npapi/external.cpp
index a60e771..ac8dffb 100644
--- a/plugin/npapi/external.cpp
+++ b/plugin/npapi/external.cpp
@@ -20,6 +20,10 @@
 #include "gnashconfig.h"
 #endif
 
+#include <boost/algorithm/string/erase.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
+
 #include <string>
 #include <sstream>
 #include <vector>
@@ -32,8 +36,6 @@
 #include "external.h"
 #include "plugin.h"
 
-#include <boost/algorithm/string/erase.hpp>
-
 namespace gnash {
 namespace plugin {
 
@@ -198,19 +200,19 @@ ExternalInterface::makeObject (std::map<std::string, 
std::string> &args)
 //              <number>135.78</number>
 //      </arguments>
 // </invoke>
-ExternalInterface::invoke_t *
+boost::shared_ptr<ExternalInterface::invoke_t>
 ExternalInterface::parseInvoke(const std::string &xml)
 {
+    boost::shared_ptr<ExternalInterface::invoke_t> invoke;
     if (xml.empty()) {
-        return 0;
+        return invoke;
     }
-    
-    ExternalInterface::invoke_t *invoke = new invoke_t;
-    
+
+    invoke.reset(new invoke_t);
     std::string::size_type start = 0;
     std::string::size_type end;
     std::string tag;
-
+    
     // Look for the ending > in the first part of the data for the tag
     end = xml.find(">");
     if (end != std::string::npos) {
@@ -220,37 +222,44 @@ ExternalInterface::parseInvoke(const std::string &xml)
         if (tag.substr(0, 7) == "<invoke") {
             // extract the name of the method to invoke
             start = tag.find("name=");
-            if ( start == std::string::npos ) return invoke;
+            if ( start == std::string::npos ) {
+                return invoke;
+            }
             start += 5;
             end   = tag.find(" ", start);
-            if ( end == std::string::npos ) return invoke;
+            if ( end == std::string::npos ) {
+                return invoke;
+            }
             invoke->name  = tag.substr(start, end-start);
             // Ignore any quote characters around the string
             boost::erase_first(invoke->name, "\"");
             boost::erase_last(invoke->name, "\"");
-
+            
             // extract the return type of the method
             start = tag.find("returntype=");
-            if ( start == std::string::npos ) return invoke;
+            if ( start == std::string::npos ) {
+                return invoke;
+            }
             start += 11;
             end   = tag.find(">", start);
-            if ( end == std::string::npos ) return invoke;
+            if ( end == std::string::npos ) {
+                return invoke;
+            }
             invoke->type  = tag.substr(start, end-start);
             // Ignore any quote characters around the string
             boost::erase_first(invoke->type, "\"");
             boost::erase_last(invoke->type, "\"");
-
+            
             // extract the arguments to the method
             start = xml.find("<arguments>");
             end   = xml.find("</invoke");
-            if (start != std::string::npos && end != std::string::npos )
-            {
-              tag   = xml.substr(start, end-start);
-              invoke->args = parseArguments(tag);
-            }
+            if (start != std::string::npos && end != std::string::npos) {
+                    tag   = xml.substr(start, end-start);
+                    invoke->args = parseArguments(tag);
+                }
         }
     }
-
+    
     return invoke;
 }
 
diff --git a/plugin/npapi/external.h b/plugin/npapi/external.h
index a0df10e..4bd117b 100644
--- a/plugin/npapi/external.h
+++ b/plugin/npapi/external.h
@@ -27,6 +27,8 @@
 #include <sstream>
 #include <vector>
 #include <map>
+#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
 
 #include "npapi.h"
 #include "npruntime.h"
@@ -62,7 +64,7 @@ struct ExternalInterface
     static std::string makeObject (std::map<std::string, std::string> &args);
     
     static GnashNPVariant parseXML(const std::string &xml);
-    static invoke_t *parseInvoke(const std::string &xml);
+    static boost::shared_ptr<invoke_t> parseInvoke(const std::string &xml);
     
     static std::map<std::string, GnashNPVariant> parseProperties(const 
std::string &xml);
     static std::vector<GnashNPVariant> parseArguments(const std::string &xml);
diff --git a/plugin/npapi/plugin.cpp b/plugin/npapi/plugin.cpp
index 5c4b15d..f615163 100644
--- a/plugin/npapi/plugin.cpp
+++ b/plugin/npapi/plugin.cpp
@@ -24,7 +24,9 @@
 #include <boost/format.hpp>
 #include <boost/scoped_array.hpp>
 #include <boost/algorithm/string/replace.hpp>
+#include <boost/algorithm/string/find.hpp>
 #include <cassert>
+#include <string>
 #include <cstdlib> // getenv
 #include <stdlib.h> // putenv
 #include <sys/types.h>
@@ -715,7 +717,6 @@ nsPluginInstance::handlePlayerRequests(GIOChannel* iochan, 
GIOCondition cond)
         // looping here forever, so this is our escape from that loop.
         if (retries-- <= 0) {
             gnash::log_error("Too many attempts to read from the player!");
-            return false;
         }
         error = 0;
         request = 0;
@@ -760,6 +761,8 @@ nsPluginInstance::handlePlayerRequests(GIOChannel* iochan, 
GIOCondition cond)
     return true;
 }
 
+// There may be multiple Invoke messages in a single packet, so each
+// packet needs to be broken up into separate messages to be parsed.
 bool
 nsPluginInstance::processPlayerRequest(gchar* buf, gsize linelen)
 {
@@ -776,134 +779,155 @@ nsPluginInstance::processPlayerRequest(gchar* buf, 
gsize linelen)
         }
         return false;
     }
-    
-    plugin::ExternalInterface::invoke_t *invoke =
-        plugin::ExternalInterface::parseInvoke(buf);
 
-    if (!invoke) return false;
-
-    if (!invoke->name.empty()) {
-        gnash::log_debug("Requested method is: %s", invoke->name);
-    }
-    
-    if (invoke->name == "getURL") {
-        // gnash::log_debug("Got a getURL() request: %", 
invoke->args[0].get());
-
-        assert(invoke->args.size() > 1);
-
-        // The first argument is the URL string.
-        std::string url = NPStringToString(NPVARIANT_TO_STRING(
-                                               invoke->args[0].get()));
-        // The second is the method, namely GET or POST.
-        std::string op = NPStringToString(NPVARIANT_TO_STRING(
-                                              invoke->args[1].get()));
-        // The third is the optional target, which is something like
-        // _blank or _self.
-        std::string target;
-
-        // The fourth is the optional data. If there is data, the target
-        // field is always set so this argument is on the correct index.
-        std::string data;
-
-        if (invoke->args.size() >= 3) {
-            target = NPStringToString(NPVARIANT_TO_STRING(
-                                          invoke->args[2].get()));
+    std::string packet(buf, linelen);
+    do {
+        std::string term = "</invoke>";
+        std::string::size_type pos = packet.find(term);
+        // no terminator, bad message
+        if (pos == std::string::npos) {
+            gnash::log_error("No terminator, bad Invoke message");
+            return false;
         }
+        // Extract a message from the packet
+        std::string msg = packet.substr(0, pos + term.size());
+        boost::shared_ptr<plugin::ExternalInterface::invoke_t> invoke =
+            plugin::ExternalInterface::parseInvoke(msg);
 
-        // An empty target defaults to "_self"
-        // This is _required_ for chromium,
-        // see https://savannah.gnu.org/bugs/?32425
-        if ( target.empty() ) target = "_self";
-
-        if (invoke->args.size() == 4) {
-            data = NPStringToString(NPVARIANT_TO_STRING(
-                                        invoke->args[3].get()));
+        // drop the parsed message from the packet
+        packet.erase(0, msg.size());
+        
+        if (!invoke) {
+            return false;
         }
-        if (op == "GET") {
-            gnash::log_debug("Asked to getURL '%s' in target %s", url,
-                             target);
-            NPN_GetURL(_instance, url.c_str(), target.c_str());
-        } else if (op == "POST") {                
-            gnash::log_debug("Asked to postURL '%s' this data %s", url,
-                             data);
-            NPN_PostURL(_instance, url.c_str(), target.c_str(), data.size(),
-                        data.c_str(), false);
-            return true;
+
+        // size_t invoke_size = invoke->name.size() + invoke->type.size() +
+        //     (invoke->args.size() * sizeof(GnashNPVariant));
+        
+        if (!invoke->name.empty()) {
+            gnash::log_debug("Requested method is: %s", invoke->name);
         }
         
-        return true;
-    } else if (invoke->name == "fsCommand") {
-
-        assert(invoke->args.size() > 1);
-        std::string command = NPStringToString(NPVARIANT_TO_STRING(
+        if (invoke->name == "getURL") {
+            // gnash::log_debug("Got a getURL() request: %", 
invoke->args[0].get());
+            
+            assert(invoke->args.size() > 1);
+            
+            // The first argument is the URL string.
+            std::string url = NPStringToString(NPVARIANT_TO_STRING(
                                                    invoke->args[0].get()));
-        std::string arg = NPStringToString(NPVARIANT_TO_STRING(
-                                               invoke->args[1].get()));        
    
-        std::string name = _name; 
-        std::stringstream jsurl;
-        jsurl << "javascript:" << name << "_DoFSCommand('" << command
-              << "','" << arg <<"')";
-        
-        // TODO: check if _self is a good target for this
-        static const char* tgt = "_self";
+            // The second is the method, namely GET or POST.
+            std::string op = NPStringToString(NPVARIANT_TO_STRING(
+                                                  invoke->args[1].get()));
+            // The third is the optional target, which is something like
+            // _blank or _self.
+            std::string target;
+            
+            // The fourth is the optional data. If there is data, the target
+            // field is always set so this argument is on the correct index.
+            std::string data;
+            
+            if (invoke->args.size() >= 3) {
+                target = NPStringToString(NPVARIANT_TO_STRING(
+                                              invoke->args[2].get()));
+            }
+            
+            // An empty target defaults to "_self"
+            // This is _required_ for chromium,
+            // see https://savannah.gnu.org/bugs/?32425
+            if ( target.empty() ) target = "_self";
+            
+            if (invoke->args.size() == 4) {
+                data = NPStringToString(NPVARIANT_TO_STRING(
+                                            invoke->args[3].get()));
+            }
+            if (op == "GET") {
+                gnash::log_debug("Asked to getURL '%s' in target %s", url,
+                                 target);
+                NPN_GetURL(_instance, url.c_str(), target.c_str());
+            } else if (op == "POST") {                
+                gnash::log_debug("Asked to postURL '%s' this data %s", url,
+                                 data);
+                NPN_PostURL(_instance, url.c_str(), target.c_str(), 
data.size(),
+                            data.c_str(), false);
+                return true;
+            }
+            
+            return true;
+        } else if (invoke->name == "fsCommand") {
+            
+            assert(invoke->args.size() > 1);
+            std::string command = NPStringToString(NPVARIANT_TO_STRING(
+                                                       invoke->args[0].get()));
+            std::string arg = NPStringToString(NPVARIANT_TO_STRING(
+                                                   invoke->args[1].get()));    
        
+            std::string name = _name; 
+            std::stringstream jsurl;
+            jsurl << "javascript:" << name << "_DoFSCommand('" << command
+                  << "','" << arg <<"')";
+            
+            // TODO: check if _self is a good target for this
+            static const char* tgt = "_self";
+            
+            gnash::log_debug("Calling NPN_GetURL(%s, %s)",
+                             jsurl.str(), tgt);
+            
+            NPN_GetURL(_instance, jsurl.str().c_str(), tgt);
+            return true;
+        } else if (invoke->name == "addMethod") {
+            
+            assert(!invoke->args.empty());
+            // Make this flash function accessible to Javascript. The
+            // actual callback lives in libcore/movie_root, but it
+            // needs to be on the list of supported remote methods so
+            // it can be called by Javascript.
+            std::string method = NPStringToString(NPVARIANT_TO_STRING(
+                                                      invoke->args[0].get()));
+            NPIdentifier id = NPN_GetStringIdentifier(method.c_str());
+            // log_debug("SCRIPT OBJECT addMethod: %x, %s", (void 
*)_scriptObject, method);
+            this->getScriptObject()->AddMethod(id, remoteCallback);
+            return true;
+        }
         
-        gnash::log_debug("Calling NPN_GetURL(%s, %s)",
-                         jsurl.str(), tgt);
+        NPVariant result;
+        VOID_TO_NPVARIANT(result);
+        bool invokeResult = false;
         
-        NPN_GetURL(_instance, jsurl.str().c_str(), tgt);
-        return true;
-    } else if (invoke->name == "addMethod") {
-
-        assert(!invoke->args.empty());
-        // Make this flash function accessible to Javascript. The
-        // actual callback lives in libcore/movie_root, but it
-        // needs to be on the list of supported remote methods so
-        // it can be called by Javascript.
-        std::string method = NPStringToString(NPVARIANT_TO_STRING(
-                                                  invoke->args[0].get()));
-        NPIdentifier id = NPN_GetStringIdentifier(method.c_str());
-        // log_debug("SCRIPT OBJECT addMethod: %x, %s", (void *)_scriptObject, 
method);
-        this->getScriptObject()->AddMethod(id, remoteCallback);
-        return true;
-    }
-
-    NPVariant result;
-    VOID_TO_NPVARIANT(result);
-    bool invokeResult = false;
-
-    // This is the player invoking a method in Javascript
-    if (!invoke->name.empty() && !invoke->args.empty()) {
-        //Convert the as_value argument to NPVariant
-        const size_t count = invoke->args.size() - 1;
-        boost::scoped_array<NPVariant> args(new NPVariant[count]);
-        //Skip the first argument
-        for (size_t i = 0; i < count; ++i) {
-            invoke->args[i+1].copy(args[i]);
+        // This is the player invoking a method in Javascript
+        if (!invoke->name.empty() && !invoke->args.empty()) {
+            //Convert the as_value argument to NPVariant
+            const size_t count = invoke->args.size() - 1;
+            boost::scoped_array<NPVariant> args(new NPVariant[count]);
+            //Skip the first argument
+            for (size_t i = 0; i < count; ++i) {
+                invoke->args[i+1].copy(args[i]);
+            }
+            
+            NPIdentifier id = NPN_GetStringIdentifier(invoke->name.c_str());
+            gnash::log_debug("Invoking JavaScript method %s", invoke->name);
+            NPObject* windowObject;
+            NPN_GetValue(_instance, NPNVWindowNPObject, &windowObject);
+            invokeResult=NPN_Invoke(_instance, windowObject, id, args.get(),
+                                    count, &result);
+            NPN_ReleaseObject(windowObject);
         }
-
-        NPIdentifier id = NPN_GetStringIdentifier(invoke->name.c_str());
-        gnash::log_debug("Invoking JavaScript method %s", invoke->name);
-        NPObject* windowObject;
-        NPN_GetValue(_instance, NPNVWindowNPObject, &windowObject);
-        invokeResult=NPN_Invoke(_instance, windowObject, id, args.get(),
-                count, &result);
-        NPN_ReleaseObject(windowObject);
-    }
-    // We got a result from invoking the Javascript method
-    std::stringstream ss;
-    if (invokeResult) {
-        ss << plugin::ExternalInterface::convertNPVariant(&result);
-        NPN_ReleaseVariantValue(&result);
-    } else {
-        // Send response
-        // FIXME: "securityError" also possible, check domain
-        ss << plugin::ExternalInterface::makeString("Error");
-    }
-    size_t ret = _scriptObject->writePlayer(ss.str());
-    if (ret != ss.str().size()) {
-        log_error("Couldn't write the response to Gnash, network problems.");
-        return false;
-    }
+        // We got a result from invoking the Javascript method
+        std::stringstream ss;
+        if (invokeResult) {
+            ss << plugin::ExternalInterface::convertNPVariant(&result);
+            NPN_ReleaseVariantValue(&result);
+        } else {
+            // Send response
+            // FIXME: "securityError" also possible, check domain
+            ss << plugin::ExternalInterface::makeString("Error");
+        }
+        size_t ret = _scriptObject->writePlayer(ss.str());
+        if (ret != ss.str().size()) {
+            log_error("Couldn't write the response to Gnash, network 
problems.");
+            return false;
+        }
+    } while (!packet.empty());
+    
     return true;
 }
 
diff --git a/plugin/npapi/plugin.h b/plugin/npapi/plugin.h
index 007df68..9801f93 100644
--- a/plugin/npapi/plugin.h
+++ b/plugin/npapi/plugin.h
@@ -144,7 +144,7 @@ private:
 //  0: no messages at all
 //  1: fatal errors (errors preventing the plugin from working as it should)
 //  2: informational messages
-#define GNASH_PLUGIN_DEBUG 1
+#define GNASH_PLUGIN_DEBUG 2
 
 // This following logging code is copied from libbase/log.h, but
 // duplicated here because the plugin only needs a more trimmed down

http://git.savannah.gnu.org/cgit//commit/?id=0aecfe8e43995f5de3b0d5890b6a52a9895e2d51


commit 0aecfe8e43995f5de3b0d5890b6a52a9895e2d51
Author: Rob Savoye <address@hidden>
Date:   Mon Feb 14 09:46:19 2011 -0700

    properly handle 64 vs 32 bit for the plugin directory

diff --git a/macros/kde4.m4 b/macros/kde4.m4
index 40383cc..2825877 100644
--- a/macros/kde4.m4
+++ b/macros/kde4.m4
@@ -192,9 +192,17 @@ AC_DEFUN([GNASH_PATH_KDE4],
     fi
 
     if test x"${with_kde4_plugindir}" != x ; then 
-      KDE4_PLUGINDIR="${with_kde4_plugindir}/lib/kde4"
+      if test -d ${with_kde4_plugindir}/lib64; then
+        KDE4_PLUGINDIR="${with_kde4_plugindir}/lib64/kde4"
+      else
+        KDE4_PLUGINDIR="${with_kde4_plugindir}/lib/kde4"
+      fi
     else
-      KDE4_PLUGINDIR="${KDE4_PREFIX}/lib/kde4"
+      if test -d ${KDE4_PREFIX}/lib64; then
+        KDE4_PLUGINDIR="${KDE4_PREFIX}/lib64/kde4"
+      else
+        KDE4_PLUGINDIR="${KDE4_PREFIX}/lib/kde4"
+      fi
     fi
     if test x"${with_kde4_servicesdir}" != x ; then 
       KDE4_SERVICESDIR="${with_kde4_servicesdir}/share/kde4/services"

-----------------------------------------------------------------------

Summary of changes:
 macros/kde4.m4            |   12 ++-
 plugin/npapi/external.cpp |   49 +++++----
 plugin/npapi/external.h   |    4 +-
 plugin/npapi/plugin.cpp   |  262 ++++++++++++++++++++++++--------------------
 plugin/npapi/plugin.h     |    2 +-
 5 files changed, 186 insertions(+), 143 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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