[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/gnash.h server/impl.cpp ...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/gnash.h server/impl.cpp ... |
Date: |
Wed, 20 Feb 2008 14:46:29 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/02/20 14:46:28
Modified files:
. : ChangeLog
server : gnash.h impl.cpp movie_root.cpp movie_root.h
sprite_instance.cpp sprite_instance.h
Log message:
Implement MovieClip.loadMovie(url, POST|GET)
the GETURL tag is still missing
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5703&r2=1.5704
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gnash.h?cvsroot=gnash&r1=1.114&r2=1.115
http://cvs.savannah.gnu.org/viewcvs/gnash/server/impl.cpp?cvsroot=gnash&r1=1.140&r2=1.141
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.161&r2=1.162
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.108&r2=1.109
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.479&r2=1.480
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.170&r2=1.171
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5703
retrieving revision 1.5704
diff -u -b -r1.5703 -r1.5704
--- ChangeLog 20 Feb 2008 14:33:03 -0000 1.5703
+++ ChangeLog 20 Feb 2008 14:46:26 -0000 1.5704
@@ -1,3 +1,14 @@
+2008-02-20 Sandro Santilli <address@hidden>
+
+ * server/: gnash.h, impl.cpp: add an additional optional
+ argument to create_movie and create_library_movie to
+ post data.
+ * server/movie_root.{cpp,h}: change loadMovie interface to
+ take an optional POST data string.
+ * server/sprite_instance.{cpp,h}: extend ::loadMovie to
+ take an aptional POST data string, fix MovieClip.loadMovie
+ to honour second argument [GET/POST].
+
2008-02-20 Rob Savoye <address@hidden>
* configure.ac: Don't build C/asspec/Makefile, it's never been
Index: server/gnash.h
===================================================================
RCS file: /sources/gnash/gnash/server/gnash.h,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -b -r1.114 -r1.115
--- server/gnash.h 5 Feb 2008 12:01:51 -0000 1.114
+++ server/gnash.h 20 Feb 2008 14:46:27 -0000 1.115
@@ -205,7 +205,10 @@
/// Initializing the VirtualMachine requires a target SWF version, which can
/// be found in the SWF header.
///
-movie_definition* create_movie(const URL& url, const char* real_url=NULL, bool
startLoaderThread=true);
+/// @param postdata
+/// If not NULL, use POST method (only valid for HTTP)
+///
+movie_definition* create_movie(const URL& url, const char* real_url=NULL, bool
startLoaderThread=true, const std::string* postdata=NULL);
/// Load a movie from an already opened stream.
//
@@ -300,7 +303,13 @@
/// Initializing the VirtualMachine requires a target SWF version, which can
/// be found in the SWF header.
///
-DSOEXPORT movie_definition* create_library_movie(const URL& url, const char*
real_url=NULL, bool startLoaderThread=true);
+/// @param postdata
+/// If not NULL, use POST method (only valid for HTTP).
+/// NOTE: when POSTing, the movies library won't be used.
+///
+DSOEXPORT movie_definition* create_library_movie(const URL& url,
+ const char* real_url=NULL, bool startLoaderThread=true,
+ const std::string* postdata=NULL);
/// Helper to pregenerate cached data (basically, shape tesselations).
Index: server/impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/impl.cpp,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -b -r1.140 -r1.141
--- server/impl.cpp 19 Feb 2008 19:20:53 -0000 1.140
+++ server/impl.cpp 20 Feb 2008 14:46:27 -0000 1.141
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: impl.cpp,v 1.140 2008/02/19 19:20:53 bwy Exp $ */
+/* $Id: impl.cpp,v 1.141 2008/02/20 14:46:27 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "gnashconfig.h"
@@ -539,7 +539,7 @@
}
movie_definition*
-create_movie(const URL& url, const char* reset_url, bool startLoaderThread)
+create_movie(const URL& url, const char* reset_url, bool startLoaderThread,
const std::string* postdata)
{
// URL::str() returns by value, save it to a local string
std::string url_str = url.str();
@@ -547,7 +547,9 @@
// log_debug(_("%s: url is %s"), __PRETTY_FUNCTION__, c_url);
- std::auto_ptr<tu_file> in ( globals::streamProvider.getStream(url) );
+ std::auto_ptr<tu_file> in;
+ if ( postdata ) in.reset( globals::streamProvider.getStream(url, *postdata)
);
+ else in.reset( globals::streamProvider.getStream(url) );
if ( ! in.get() )
{
log_error(_("failed to open '%s'; can't create movie"), c_url);
@@ -785,14 +787,15 @@
// loaded it already. Add it to our library on success, and
// return a pointer to it.
//
-movie_definition* create_library_movie(const URL& url, const char* real_url,
bool startLoaderThread)
+movie_definition* create_library_movie(const URL& url, const char* real_url,
bool startLoaderThread, const std::string* postdata)
{
// log_debug(_("%s: url is %s"), __PRETTY_FUNCTION__, url.str().c_str());
// Use real_url as label for cache if available
std::string cache_label = real_url ? URL(real_url).str() : url.str();
- // Is the movie already in the library?
+ // Is the movie already in the library? (don't check if we have post data!)
+ if ( ! postdata )
{
boost::intrusive_ptr<movie_definition> m;
if ( s_movie_library.get(cache_label, &m) )
@@ -806,7 +809,7 @@
// the loader thread now to avoid IMPORT tag loaders from
// calling create_library_movie() again and NOT finding
// the just-created movie.
- movie_definition* mov = create_movie(url, real_url, false);
+ movie_definition* mov = create_movie(url, real_url, false, postdata);
//log_debug(_("create_movie(%s, %s, false) returned %p"), url.str().c_str(),
real_url, mov);
if (mov == NULL)
@@ -817,8 +820,15 @@
}
// Movie is good, add to the library
+ if ( ! postdata ) // don't add if we POSTed
+ {
s_movie_library.add(cache_label, mov);
log_debug(_("Movie %s (SWF%d) added to library"), cache_label.c_str(),
mov->get_version());
+ }
+ else
+ {
+ log_debug(_("Movie %s (SWF%d) NOT added to library (resulted from a
POST)"), cache_label.c_str(), mov->get_version());
+ }
// Now complete the load if the movie is an SWF movie
//
Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -b -r1.161 -r1.162
--- server/movie_root.cpp 19 Feb 2008 19:20:53 -0000 1.161
+++ server/movie_root.cpp 20 Feb 2008 14:46:27 -0000 1.162
@@ -1762,10 +1762,10 @@
}
void
-movie_root::loadMovie(const URL& url, const std::string& target,
movie_root::LoadMethod method)
+movie_root::loadMovie(const URL& url, const std::string& target, const
std::string* postdata)
{
log_debug("movie_root::loadMovie(%s, %s)", url.str().c_str(),
target.c_str());
- _loadMovieRequests.push_front(LoadMovieRequest(url, target, method));
+ _loadMovieRequests.push_front(LoadMovieRequest(url, target, postdata));
}
void
@@ -1773,7 +1773,8 @@
{
const std::string& target = r.getTarget();
const URL& url = r.getURL();
- LoadMethod method = r.getMethod();
+ bool usePost = r.usePost();
+ const std::string& postData = r.getPostData();
if ( target.compare(0, 6, "_level") == 0 &&
target.find_first_not_of("0123456789", 7) == string::npos )
{
@@ -1797,12 +1798,14 @@
return;
}
- if ( method )
+ if ( usePost )
{
- log_unimpl("loadMovie with method %s", method == 1 ? "GET" : method ==
2 ? "POST" : "UNKWNOWN");
+ sp->loadMovie(url, &postData);
}
-
+ else
+ {
sp->loadMovie(url);
+ }
}
void
Index: server/movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -b -r1.108 -r1.109
--- server/movie_root.h 8 Feb 2008 11:58:55 -0000 1.108
+++ server/movie_root.h 20 Feb 2008 14:46:28 -0000 1.109
@@ -15,7 +15,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: movie_root.h,v 1.108 2008/02/08 11:58:55 strk Exp $ */
+/* $Id: movie_root.h,v 1.109 2008/02/20 14:46:28 strk Exp $ */
/// \page events_handling Handling of user events
///
@@ -619,17 +619,14 @@
/// @param target
/// Target to load into.
///
- /// @param method
- /// Load method.
- ///
- /// TODO: add an additional parameter containing the actual variables
- /// to send if method is POST or GET as tests show that if you
- /// queue a load request for a target which is unloaded at time
- /// of processing, you still get the original target variables
- /// posted, not the new ones !
+ /// @param postdata
+ /// If not null, the data to POST in an HTTP request.
+ /// Tests show that if you queue a load request for a target which
+ /// is unloaded at time of processing, you still get the original
+ /// target variables posted, not the new ones !
/// See http://savannah.gnu.org/bugs/index.php?22257
///
- void loadMovie(const URL& url, const std::string& target, LoadMethod
method=NONE);
+ void loadMovie(const URL& url, const std::string& target, const
std::string* postdata=NULL);
/// Return true if the given string can be interpreted as a _level name
//
@@ -665,21 +662,32 @@
/// A load movie request
class LoadMovieRequest {
public:
- LoadMovieRequest(const URL& u, const std::string& t, LoadMethod m)
+ /// @param postdata
+ /// If not null POST method will be used for HTTP.
+ ///
+ LoadMovieRequest(const URL& u, const std::string& t, const
std::string* postdata)
:
_target(t),
_url(u),
- _method(m)
- {}
+ _usePost(false)
+ {
+ if ( postdata )
+ {
+ _postData = *postdata;
+ _usePost = true;
+ }
+ }
const std::string& getTarget() const { return _target; }
const URL& getURL() const { return _url; }
- LoadMethod getMethod() const { return _method; }
+ const std::string& getPostData() const { return _postData; }
+ bool usePost() const { return _usePost; }
private:
std::string _target;
URL _url;
- LoadMethod _method;
+ bool _usePost;
+ std::string _postData;
};
/// Load movie requests
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.479
retrieving revision 1.480
diff -u -b -r1.479 -r1.480
--- server/sprite_instance.cpp 19 Feb 2008 19:20:53 -0000 1.479
+++ server/sprite_instance.cpp 20 Feb 2008 14:46:28 -0000 1.480
@@ -644,26 +644,65 @@
const URL& baseurl = get_base_url();
URL url(urlstr, baseurl);
- if (fn.nargs > 1)
- {
- // TODO: implement support for second argument
- log_unimpl(_("second argument of MovieClip.loadMovie(%s, <variables>) "
- "will be discarded"), urlstr.c_str());
- //return;
- }
-
movie_root& mr = sprite->getVM().getRoot();
std::string target = sprite->getTarget();
- // TODO: if GET/SET should send variables of *this* movie,
+
+
+ // TODO: if GET/POST should send variables of *this* movie,
// no matter if the target will be replaced by another movie !!
- mr.loadMovie(url, target); // ADD GET/SET !!
+ bool usePost = false;
+ bool sendVars = false;
+ if (fn.nargs > 1)
+ {
+ as_value arg = fn.arg(1);
+ std::string methodString = arg.to_string();
+ boost::to_lower(methodString);
+ if ( methodString == "post" )
+ {
+ usePost = true;
+ sendVars = true;
+ }
+ else if ( methodString == "get" )
+ {
+ sendVars = true;
+ }
+ else
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::stringstream ss;
+ fn.dump_args(ss);
+ log_aserror(_("MovieClip.loadMovie(%s): second argument (if
any) must be 'post' or 'get' [got %s]"),
+ ss.str().c_str(), methodString.c_str());
+ );
+ }
+ }
- //sprite->loadMovie(url);
- //log_debug("MovieClip.loadMovie(%s) - TESTING ", url.str().c_str());
+ if ( ! sendVars )
+ {
+ log_debug("Not sending vars");
+ mr.loadMovie(url, target);
+ }
+ else
+ {
+ std::string data;
+ sprite->getURLEncodedVars(data);
+ if ( usePost )
+ {
+ log_debug("Posting: %s", data.c_str());
+ mr.loadMovie(url, target, &data);
+ }
+ else
+ {
+ std::string qs = url.querystring();
+ if ( qs.empty() ) data.insert(0, 1, '?');
+ else data.insert(0, 1, '&');
+ url.set_querystring(qs+data);
+ log_debug("GETTIN: %s", url.str().c_str());
+ mr.loadMovie(url, target);
+ }
+ }
- //log_unimp("%s", __PRETTY_FUNCTION__);
- //moviecliploader_loadclip(fn);
return as_value();
}
@@ -4047,13 +4086,14 @@
}
bool
-sprite_instance::loadMovie(const URL& url)
+sprite_instance::loadMovie(const URL& url, const std::string* postdata)
{
// Get a pointer to our own parent
character* parent = get_parent();
if ( parent )
{
- boost::intrusive_ptr<movie_definition> md ( create_library_movie(url) );
+ if ( postdata ) log_debug("Posting data '%s' to url '%s'",
postdata->c_str(), url.str().c_str());
+ boost::intrusive_ptr<movie_definition> md ( create_library_movie(url,
NULL, true, postdata) );
if (md == NULL)
{
log_error(_("can't create movie_definition for %s"),
Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.170
retrieving revision 1.171
diff -u -b -r1.170 -r1.171
--- server/sprite_instance.h 19 Feb 2008 19:20:53 -0000 1.170
+++ server/sprite_instance.h 20 Feb 2008 14:46:28 -0000 1.171
@@ -574,9 +574,15 @@
/// Load a movie in this sprite, replacing it
//
+ /// @param url
+ /// The url to load the movie from. Can be a bitmap or an SWF.
+ ///
+ /// @param postdata
+ /// IF not NULL, use as the POST body for HTTP requests
+ ///
/// Return: true if it succeeded, false otherwise
///
- bool loadMovie(const URL& url);
+ bool loadMovie(const URL& url, const std::string* postdata=NULL);
/// \brief
/// Load url-encoded variables from the given url, optionally
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/gnash.h server/impl.cpp ...,
Sandro Santilli <=