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_final-


From: Gabriele Giacone
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-1825-g093ae92
Date: Wed, 08 Jan 2014 18:09:27 +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  093ae927d709fead64fcd9df0501156ccc82f276 (commit)
       via  b283d6b21a7241f90d167944a3a9837c3280b06a (commit)
      from  43f1f85878b53b0cce817957a16e3c6044b2b716 (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=093ae927d709fead64fcd9df0501156ccc82f276


commit 093ae927d709fead64fcd9df0501156ccc82f276
Author: Gabriele Giacone <address@hidden>
Date:   Fri Oct 18 19:39:58 2013 +0200

    Replace GNASH_COOKIES_IN with -C option, remove cookies when child dies.
    
    To make plugin keeping track of cookiefiles to remove when children die,
    replace GNASH_COOKIE_IN with command line option (-C) and global var to
    pass cookiefile from plugin to standalone.
    
    * doc/C/gnash.man-xml: Add -C option description.
    * doc/C/preformatted/gnash.1.in: Likewise.
    * doc/C/preformatted/gnashuser.html.in: Likewise.
    * doc/C/usermanual/usage.xml: Likewise.
    * gui/Player.h (setCookiesIn): New function.
    * gui/gnash.cpp (setupCookiesIn): New function.
      (getSupportedOptions): Add -C option.
    * libbase/NetworkAdapter.cpp (importCookies): Get cookiefile path with
      NetworkAdapter::getCookiesIn.
    * libbase/NetworkAdapter.h (setCookiesIn,getCookiesIn): New functions.
    * plugin/npapi/plugin.cpp (~nsPluginInstance): Remove cookiefile if
      writelauncher is not set.
      (create_standalone_launcher): Replace GNASH_COOKIES_IN envvar with -C
      option.
      (setupCookies): Don't set GNASH_COOKIES_IN anymore.
      (getCmdLine): Add -C option.
      (startProc): Store pid-cookiefile association.
    
    Reviewed-by: Sandro Santilli <address@hidden>

diff --git a/doc/C/gnash.man-xml b/doc/C/gnash.man-xml
index 49cc3f0..02cc158 100644
--- a/doc/C/gnash.man-xml
+++ b/doc/C/gnash.man-xml
@@ -312,13 +312,25 @@ gnash [option]... [URL]
     <listitem>
       <para>
        Set file descriptors to use for external communications. x is
-       use by the player to send commands to the plugin, y is used
+       used by the player to send commands to the plugin, y is used
        by the plugin to send commands to the standalone player.
       </para>
     </listitem>
   </varlistentry>
 
   <varlistentry>
+    <term>-C file</term>
+    <term>--cookie-file file</term>
+    <listitem>
+      <para>
+        Set cookiefile path. Cookiefile contains HTTP cookies to send to
+        the server. Primary use for this switch is for the NPAPI plugin
+        to pass received HTTP cookies to the standalone player.
+      </para>
+    </listitem>
+  </varlistentry>
+
+  <varlistentry>
     <term>--max-advances num</term>
     <listitem>
       <para>
diff --git a/doc/C/preformatted/gnash.1.in b/doc/C/preformatted/gnash.1.in
index 8f5d92d..a66c05d 100644
--- a/doc/C/preformatted/gnash.1.in
+++ b/doc/C/preformatted/gnash.1.in
@@ -113,6 +113,11 @@ Set file descriptors to use for external communications. x 
is
 use by the player to send commands to the plugin, y is used
 by the plugin to send commands to the standalone player.
 .TP 
+-C file, --cookie-file file
+Set cookiefile path. Cookiefile contains HTTP cookies to send to
+the server. Primary use for this switch is for the NPAPI plugin
+to pass received HTTP cookies to the standalone player.
+.TP
 --max-advances num
 Exit after specified number of frame advances.
 .TP 
diff --git a/doc/C/preformatted/gnashuser.html.in 
b/doc/C/preformatted/gnashuser.html.in
index dfd94a4..d7b24fe 100644
--- a/doc/C/preformatted/gnashuser.html.in
+++ b/doc/C/preformatted/gnashuser.html.in
@@ -253,6 +253,12 @@
              Primary use for this switch is for the NPAPI plugin to properly
              support javascript and target windows in geturl requests.
            </td></tr><tr><td align="left">
+             <code class="option">-C, --cookie-file</code> <em 
class="replaceable"><code>&lt;file&gt;</code></em>
+           </td><td align="left">
+              Set cookiefile path. Cookiefile contains HTTP cookies to send to
+              the server. Primary use for this switch is for the NPAPI plugin
+              to pass received HTTP cookies to the standalone player.
+           </td></tr><tr><td align="left">
              <code class="option">--max-advances</code> <em 
class="replaceable"><code>&lt;num&gt;</code></em>
            </td><td align="left">
           Exit after the specified number of frame advances.
diff --git a/doc/C/usermanual/usage.xml b/doc/C/usermanual/usage.xml
index f90055c..6278b60 100644
--- a/doc/C/usermanual/usage.xml
+++ b/doc/C/usermanual/usage.xml
@@ -320,6 +320,16 @@
          </row>
          <row>
            <entry>
+             <option>-C, --cookie-file</option> 
<replaceable>&lt;file&gt;</replaceable>
+           </entry>
+           <entry>
+              Set cookiefile path. Cookiefile contains HTTP cookies to send to
+              the server. Primary use for this switch is for the NPAPI plugin
+              to pass received HTTP cookies to the standalone player.
+           </entry>
+         </row>
+         <row>
+           <entry>
              <option>--max-advances</option> 
<replaceable>&lt;num&gt;</replaceable>
            </entry>
            <entry>
diff --git a/gui/Player.h b/gui/Player.h
index d11f0f1..3763e2d 100644
--- a/gui/Player.h
+++ b/gui/Player.h
@@ -27,6 +27,7 @@
 #include "HostInterface.h"              // for HostInterface, FsCallback, etc
 #include "StringPredicates.h"           // for StringNoCaseLessThan
 #include "movie_definition.h"
+#include "NetworkAdapter.h"             // for setCookiesIn
 
 #include <boost/intrusive_ptr.hpp>
 #include <string>
@@ -160,6 +161,10 @@ public:
         return _controlfd;
     }
 
+    void setCookiesIn(const std::string& filename) {
+        NetworkAdapter::setCookiesIn(filename);
+    }
+
     void setStartFullscreen(bool x) {
         _startFullscreen = x;
     }
diff --git a/gui/gnash.cpp b/gui/gnash.cpp
index f99ce50..94ed3b0 100644
--- a/gui/gnash.cpp
+++ b/gui/gnash.cpp
@@ -50,6 +50,7 @@
 #include "MediaHandler.h"
 #include "utility.h"
 #include "accumulator.h"
+#include "GnashFileUtilities.h"
 
 using std::endl;
 using std::cout;
@@ -75,6 +76,7 @@ namespace {
     void setupFlashVars(gnash::Player& p,
         const std::vector<std::string>& params);
     void setupFDs(gnash::Player& p, const std::string& fds);
+    void setupCookiesIn(gnash::Player& p, const std::string& cookiesIn);
 
     void usage_gui_keys(std::ostream& os);
     void usage(std::ostream& os, const po::options_description& opts);
@@ -224,6 +226,18 @@ setupFDs(gnash::Player& p, const std::string& fds)
 }
 
 void
+setupCookiesIn(gnash::Player& p, const std::string& cookiesIn) {
+    struct stat cstat;
+    if ((stat(cookiesIn.c_str(), &cstat) == -1) ||
+        ((cstat.st_mode & S_IFMT) != S_IFREG)) {
+        std::cerr << boost::format(_("Cookiefile %s does not exist or is not a"
+            " regular file\n")) % cookiesIn;
+        std::exit(EXIT_FAILURE);
+    }
+    p.setCookiesIn(cookiesIn);
+}
+
+void
 setupSoundAndRendering(gnash::Player& p, int i)
 {
     switch (i) {
@@ -424,6 +438,10 @@ getSupportedOptions(gnash::Player& p)
         + string(" <fd>:<fd>")
         ).c_str())
 
+    ("cookie-file,C", po::value<string>()
+        ->notifier(boost::bind(&setupCookiesIn, boost::ref(p), _1)),
+        _("Cookiefile to use"))
+
     ("max-advances", po::value<size_t>()
         ->notifier(boost::bind(&Player::setMaxAdvances, &p, _1)),
         _("Exit after specified number of frame advances"))
diff --git a/libbase/NetworkAdapter.cpp b/libbase/NetworkAdapter.cpp
index b5bdab4..881f4f4 100644
--- a/libbase/NetworkAdapter.cpp
+++ b/libbase/NetworkAdapter.cpp
@@ -35,6 +35,8 @@
 
 #include <iostream> // std::cerr
 
+std::string gnash::NetworkAdapter::CookiesIn;
+
 #ifndef USE_CURL
 
 namespace gnash {
@@ -181,16 +183,16 @@ private:
 
     /// Import cookies, if requested
     //
-    /// This method will lookup GNASH_COOKIES_IN
-    /// in the environment, and if existing, will
-    /// parse the file sending each line to a fake
-    /// easy handle created ad-hoc
+    /// This method will look up CookiesIn variable and will parse cookiefile
+    /// sending each line to a fake easy handle created ad-hoc.
+    /// For backward compatibility, GNASH_COOKIES_IN environment variable
+    /// will be looked up as well.
     ///
     void importCookies();
 
     /// Export cookies, if requested
     //
-    /// This method will lookup GNASH_COOKIES_OUT
+    /// This method will look up GNASH_COOKIES_OUT
     /// in the environment, and if existing, will
     /// create the file writing any cookie currently
     /// in the jar
@@ -1219,8 +1221,17 @@ CurlStreamFile::size() const
 void
 CurlSession::importCookies()
 {
-    const char* cookiesIn = std::getenv("GNASH_COOKIES_IN");
-    if ( ! cookiesIn ) return; // nothing to do
+    std::string cookiesIn = NetworkAdapter::getCookiesIn();
+
+    if (cookiesIn.empty()) {
+        // GNASH_COOKIES_IN envvar backward compatibility
+        const char* cookiesInEnv = std::getenv("GNASH_COOKIES_IN");
+        if (cookiesInEnv) {
+            cookiesIn = cookiesInEnv;
+        } else {
+            return; // nothing to do
+        }
+    }
 
     ////////////////////////////////////////////////////////////////
     //
@@ -1251,7 +1262,7 @@ CurlSession::importCookies()
     }
 
     // Configure the fake handle to read cookies from the specified file
-    ccode = curl_easy_setopt(fakeHandle, CURLOPT_COOKIEFILE, cookiesIn);
+    ccode = curl_easy_setopt(fakeHandle, CURLOPT_COOKIEFILE, 
cookiesIn.c_str());
     if ( ccode != CURLE_OK ) {
         throw GnashException(curl_easy_strerror(ccode));
     }
diff --git a/libbase/NetworkAdapter.h b/libbase/NetworkAdapter.h
index da4f287..5e83afb 100644
--- a/libbase/NetworkAdapter.h
+++ b/libbase/NetworkAdapter.h
@@ -89,7 +89,26 @@ public:
         return (names.find(headerName) == names.end());
     }
 
+    /// \brief
+    /// Set CookiesIn variable to cookiefile path.
+    //
+    /// @param cookiesin      Cookiefile path
+    static void setCookiesIn(const std::string& cookiesin) {
+        NetworkAdapter::CookiesIn = cookiesin;
+    }
+
+    /// \brief
+    /// Get CookiesIn variable, cookiefile path.
+    //
+    /// Returns the cookiefile path.
+    static const std::string& getCookiesIn() {
+        return NetworkAdapter::CookiesIn;
+    }
+
 private:
+    /// \brief
+    /// Variable to pass cookiefile path from command line to curl.
+    static std::string CookiesIn;
 
     static const ReservedNames& reservedNames();
 
diff --git a/plugin/npapi/plugin.cpp b/plugin/npapi/plugin.cpp
index 0a270f4..cd0f7a3 100644
--- a/plugin/npapi/plugin.cpp
+++ b/plugin/npapi/plugin.cpp
@@ -125,6 +125,7 @@ extern NPPluginFuncs NPPFuncs;
 
 namespace gnash {
 NPBool plugInitialized = FALSE;
+std::string cookiefile;
 }
 
 /// \brief Return the MIME Type description for this plugin.
@@ -140,6 +141,8 @@ NPP_GetMIMEDescription(void)
 static bool waitforgdb = false;
 static bool createSaLauncher = false;
 
+static std::map<int, std::string> cookiemap;
+
 static const char* getPluginDescription();
 
 static const char*
@@ -518,6 +521,23 @@ nsPluginInstance::~nsPluginInstance()
         } else {
             gnash::log_debug("Child process exited with status %d", status);
         }
+
+        // Remove cookiefile if writelauncher not set
+        const char* options = std::getenv("GNASH_OPTIONS");
+        if ((!options || !strstr(options, "writelauncher")) &&
+            (!cookiefile.empty())) {
+            std::map<int, std::string>::iterator it = 
cookiemap.find(_childpid);
+            if (it != cookiemap.end()) {
+                if (remove(it->second.c_str())) {
+                    gnash::log_error("Cookiefile %s removal failed [pid %d]",
+                        it->second, _childpid);
+                } else {
+                    gnash::log_debug("Cookiefile %s removed [pid %d]",
+                        it->second, _childpid);
+                }
+                cookiemap.erase(it);
+            }
+        }
     }
     _childpid = 0;
 }
@@ -1009,14 +1029,14 @@ create_standalone_launcher(const std::string& page_url, 
const std::string& swf_u
     }
 
     saLauncher << "#!/bin/sh" << std::endl
-               << "export GNASH_COOKIES_IN="
-               << std::getenv("GNASH_COOKIES_IN") << std::endl
                << getGnashExecutable() << " ";
 
     if (!page_url.empty()) {
         saLauncher << "-U '" << page_url << "' ";
     }
-
+    if (!cookiefile.empty()) {
+        saLauncher << "-C " << cookiefile << " ";
+    }
     for (std::map<std::string,std::string>::const_iterator it = params.begin(),
         itEnd = params.end(); it != itEnd; ++it) {
         const std::string& nam = it->first; 
@@ -1129,20 +1149,22 @@ nsPluginInstance::setupCookies(const std::string& 
pageurl)
 
     if (ncookie.empty()) {
         gnash::log_debug("No stored Cookie for %s", url);
+        cookiefile.clear();
         return;
     }
 
     gnash::log_debug("The Cookie for %s is %s", url, ncookie);
-    char cookiename[] = "/tmp/gnash-cookies.XXXXXX";
-    boost::iostreams::file_descriptor_sink fdsink = getfdsink(cookiename);
+    char mkstemplate[] = "/tmp/gnash-cookie.XXXXXX";
+    boost::iostreams::file_descriptor_sink fdsink = getfdsink(mkstemplate);
 #if BOOST_VERSION >= 104400
     if (fdsink.handle() == -1) {
-        gnash::log_error("Failed to create sink: %s", cookiename);
+        gnash::log_error("Failed to create sink: %s", mkstemplate);
         return;
     }
 #endif
+    cookiefile = mkstemplate;
     boost::iostreams::stream<boost::iostreams::file_descriptor_sink>
-        cookiefile (fdsink);
+        cookiestream (fdsink);
 
     // Firefox provides cookies in the following format:
     //
@@ -1158,17 +1180,12 @@ nsPluginInstance::setupCookies(const std::string& 
pageurl)
     tokenizer tok(ncookie, char_sep(";"));
 
     for (tokenizer::iterator it=tok.begin(); it != tok.end(); ++it) {
-        cookiefile << "Set-Cookie: " << *it << std::endl;
+        cookiestream << "Set-Cookie: " << *it << std::endl;
     }
  
-    cookiefile.close();
+    cookiestream.close();
     fdsink.close();
-  
-    if (setenv("GNASH_COOKIES_IN", cookiename, 1) < 0) {
-        gnash::log_error(
-            "Couldn't set environment variable GNASH_COOKIES_IN to %s",
-            ncookie);
-    }
+    gnash::log_debug("Cookiefile is %s", cookiefile);
 }
 
 void
@@ -1261,6 +1278,9 @@ nsPluginInstance::getCmdLine(int hostfd, int controlfd)
         pars << " -F " << hostfd            // Socket to send commands to
              << ":"    << controlfd;        // Socket determining lifespan
     }
+    if (!cookiefile.empty()) {
+        pars << " -C " << cookiefile;
+    }
     std::string pars_str = pars.str();
     typedef boost::char_separator<char> char_sep;
     boost::tokenizer<char_sep> tok(pars_str, char_sep(" "));
@@ -1420,6 +1440,12 @@ nsPluginInstance::startProc()
                              _childpid);
         }
 
+        if (!cookiefile.empty()) {
+            cookiemap.insert(std::make_pair(_childpid, cookiefile));
+            gnash::log_debug("Pid %d associated with cookiefile %s",
+                _childpid, cookiefile);
+        }
+
         setupIOChannel(c2p_pipe[0], (GIOFunc)handlePlayerRequestsWrapper,
                                     (GIOCondition)(G_IO_IN|G_IO_HUP));
         

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


commit b283d6b21a7241f90d167944a3a9837c3280b06a
Author: Gabriele Giacone <address@hidden>
Date:   Wed Jan 8 18:57:21 2014 +0100

    Missing namespaces and return.

diff --git a/libcore/as_value.cpp b/libcore/as_value.cpp
index 4e05087..98b347c 100644
--- a/libcore/as_value.cpp
+++ b/libcore/as_value.cpp
@@ -1043,7 +1043,7 @@ operator<<(std::ostream& o, const as_value& v)
             return o << "[null]";
         case as_value::BOOLEAN:
         {
-            ios::fmtflags f(o.flags());
+            std::ios::fmtflags f(o.flags());
             o << "[bool:" << std::boolalpha << v.getBool() << "]";
             o.flags(f);
             return o;
diff --git a/libcore/parser/SWFParser.cpp b/libcore/parser/SWFParser.cpp
index 7a09a9b..d897efd 100644
--- a/libcore/parser/SWFParser.cpp
+++ b/libcore/parser/SWFParser.cpp
@@ -152,7 +152,7 @@ dumpTagBytes(SWFStream& in, std::ostream& os)
         }
         
         // Stream once as hex
-        ios::fmtflags f(os.flags());
+        std::ios::fmtflags f(os.flags());
         os << std::left << std::setw(3 * rowlength) << hexify(buf, got, false);
         
         // and once as ASCII
diff --git a/libcore/swf/SWF.cpp b/libcore/swf/SWF.cpp
index 81c71c4..fb65747 100644
--- a/libcore/swf/SWF.cpp
+++ b/libcore/swf/SWF.cpp
@@ -406,9 +406,10 @@ operator<<(std::ostream& os, const abc_action_type& opcode)
         case ABC_ACTION_CODEGENOP: return os << "CODEGENOP";
         case ABC_ACTION_VERIFYOP: return os << "VERIFYOP";
         default:
-            ios::fmtflags f(os.flags());
+            std::ios::fmtflags f(os.flags());
             os << "UNKNOWN " << std::hex << +opcode;
             os.flags(f);
+            return os;
     }
 }
 

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

Summary of changes:
 doc/C/gnash.man-xml                  |   14 ++++++++-
 doc/C/preformatted/gnash.1.in        |    5 +++
 doc/C/preformatted/gnashuser.html.in |    6 ++++
 doc/C/usermanual/usage.xml           |   10 ++++++
 gui/Player.h                         |    5 +++
 gui/gnash.cpp                        |   18 +++++++++++
 libbase/NetworkAdapter.cpp           |   27 +++++++++++-----
 libbase/NetworkAdapter.h             |   19 +++++++++++
 libcore/as_value.cpp                 |    2 +-
 libcore/parser/SWFParser.cpp         |    2 +-
 libcore/swf/SWF.cpp                  |    3 +-
 plugin/npapi/plugin.cpp              |   56 +++++++++++++++++++++++++---------
 12 files changed, 140 insertions(+), 27 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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