[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10385: Another NetConnection method
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10385: Another NetConnection method. |
Date: |
Wed, 03 Dec 2008 22:35:39 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10385
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2008-12-03 22:35:39 +0100
message:
Another NetConnection method.
modified:
libcore/asobj/NetConnection.cpp
libcore/asobj/NetConnection.h
libcore/asobj/NetStream_as.cpp
testsuite/actionscript.all/NetConnection.as
------------------------------------------------------------
revno: 10383.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2008-12-03 22:22:15 +0100
message:
Implement NetConnection.uri, drop some mystifyingly wrong functions.
modified:
libcore/asobj/NetConnection.cpp
libcore/asobj/NetConnection.h
libcore/asobj/NetStream_as.cpp
testsuite/actionscript.all/NetConnection.as
=== modified file 'libcore/asobj/NetConnection.cpp'
--- a/libcore/asobj/NetConnection.cpp 2008-12-03 19:41:19 +0000
+++ b/libcore/asobj/NetConnection.cpp 2008-12-03 21:22:15 +0000
@@ -500,6 +500,7 @@
{
}
+
void
NetConnection::markReachableResources() const
{
@@ -507,23 +508,13 @@
markAsObjectReachable();
}
-/*public*/
+
std::string
-NetConnection::validateURL(const std::string& url)
+NetConnection::validateURL() const
{
- std::string completeUrl;
- if (_prefixUrl.size() > 0) {
- if(url.size() > 0) {
- completeUrl += _prefixUrl + "/" + url;
- } else {
- completeUrl += _prefixUrl;
- }
- } else {
- completeUrl += url;
- }
const movie_root& mr = _vm.getRoot();
- URL uri(completeUrl, mr.runInfo().baseURL());
+ URL uri(_uri, mr.runInfo().baseURL());
std::string uriStr(uri.str());
assert(uriStr.find("://") != std::string::npos);
@@ -540,19 +531,6 @@
}
void
-NetConnection::addToURL(const std::string& url)
-{
- // What is this ? It is NOT documented in the header !!
- //if (url == "null" || url == "NULL") return;
-
- // If there already is something in _prefixUrl, then we already have a url,
- // so no need to renew it. This may not correct, needs some testing.
- if (_prefixUrl.size() > 0) return;
-
- _prefixUrl += url;
-}
-
-void
NetConnection::notifyStatus(StatusCode code)
{
std::pair<std::string, std::string> info;
@@ -633,7 +611,7 @@
//
// For URLs starting with anything other than "rtmp://" no connection is
// initiated, but the uri is still set.
- addToURL(uri);
+ setURI(uri);
_isConnected = false;
_inError = true;
@@ -655,6 +633,13 @@
void
+NetConnection::setURI(const std::string& uri)
+{
+ init_readonly_property("uri", &netconnection_uri);
+ _uri = uri;
+}
+
+void
NetConnection::call(as_object* asCallback, const std::string& callNumber,
const SimpleBuffer& buf)
{
@@ -664,8 +649,8 @@
hexify(buf->data(), buf->size(), false));
#endif
- // FIXME check that ptr->_prefixURL is valid
- URL url(validateURL(""));
+ // FIXME check that ptr->_uri is valid
+ URL url(validateURL());
// FIXME check if it's possible for the URL of a NetConnection
// to change between call()s
@@ -848,19 +833,8 @@
{
boost::intrusive_ptr<NetConnection> ptr =
ensureType<NetConnection>(fn.this_ptr);
- UNUSED(ptr);
-
- if ( fn.nargs == 0 ) // getter
- {
- log_unimpl("NetConnection.uri get");
- return as_value();
- }
- else // setter
- {
- log_unimpl("NetConnection.uri set");
- return as_value();
- }
-
+
+ return as_value(ptr->getURI());
}
void
@@ -876,7 +850,6 @@
attachProperties(as_object& o)
{
o.init_readonly_property("isConnected", &netconnection_isConnected);
- o.init_property("uri", &netconnection_uri, &netconnection_uri);
}
as_object*
@@ -939,14 +912,12 @@
const as_value& uri = fn.arg(0);
const VM& vm = ptr->getVM();
+ const std::string& uriStr = uri.to_string_versioned(vm.getSWFVersion());
// Check first arg for validity
- if (uri.is_null() || (vm.getSWFVersion() > 6 && uri.is_undefined()))
- {
- // Null URL was passed. This is expected. Of course, it also makes this
- // function (and, this class) rather useless. We return true,
- // even though returning true has no meaning.
+ if (uri.is_null() || (vm.getSWFVersion() > 6 && uri.is_undefined())) {
ptr->connect();
+ ptr->setURI(uriStr);
}
else {
if ( fn.nargs > 1 )
@@ -955,7 +926,7 @@
log_unimpl("NetConnection.connect(%s): args after the first are "
"not supported", ss.str());
}
- ptr->connect(uri.to_string());
+ ptr->connect(uriStr);
}
return as_value(ptr->isConnected());
=== modified file 'libcore/asobj/NetConnection.h'
--- a/libcore/asobj/NetConnection.h 2008-12-03 19:41:19 +0000
+++ b/libcore/asobj/NetConnection.h 2008-12-03 21:22:15 +0000
@@ -54,24 +54,8 @@
NetConnection();
~NetConnection();
- /// Open a connection to stream FLV files.
- //
- /// If already connected an error is raised and false
- /// is returned. Otherwise, a connection is attempted
- /// using a separate thread that starts loading data
- /// caching it.
- ///
- /// @param url
- /// An url portion to append to the base url (???)
- ///
- /// @return true on success, false on error.
- ///
- /// @note Older Flash movies can only take a NULL value as
- /// the parameter, which therefor only connects to the localhost using
- /// RTMP. Newer Flash movies have a parameter to connect which is a
- /// URL string like rtmp://foobar.com/videos/bar.flv
- ///
- std::string validateURL(const std::string& url);
+ /// Make the stored URI into a valid and checked URL.
+ std::string validateURL() const;
void call(as_object* asCallback, const std::string& callNumber,
const SimpleBuffer& buf);
@@ -89,6 +73,12 @@
return _isConnected;
}
+ void setURI(const std::string& uri);
+
+ const std::string& getURI() const {
+ return _uri;
+ }
+
/// Notify the NetConnection onStatus handler of a change.
void notifyStatus(StatusCode code);
@@ -111,10 +101,7 @@
std::auto_ptr<AMFQueue> _callQueue;
/// the url prefix optionally passed to connect()
- std::string _prefixUrl;
-
- /// the complete url of the file
- std::string _completeUrl;
+ std::string _uri;
bool _isConnected;
=== modified file 'libcore/asobj/NetStream_as.cpp'
--- a/libcore/asobj/NetStream_as.cpp 2008-12-03 11:25:09 +0000
+++ b/libcore/asobj/NetStream_as.cpp 2008-12-03 21:22:15 +0000
@@ -780,8 +780,6 @@
url = url.substr(4);
}
- // TODO: check what is this needed for, I'm not sure it would be needed..
- url = _netCon->validateURL(url);
if (url.empty())
{
log_error("Couldn't load URL %s", c_url);
=== modified file 'testsuite/actionscript.all/NetConnection.as'
--- a/testsuite/actionscript.all/NetConnection.as 2008-12-03 18:51:57
+0000
+++ b/testsuite/actionscript.all/NetConnection.as 2008-12-03 21:22:15
+0000
@@ -49,6 +49,8 @@
check_equals(tmp.__proto__, NetConnection.prototype);
check(tmp instanceof NetConnection);
check_equals(typeof(tmp.isConnected), 'boolean');
+check_equals(typeof(tmp.uri), 'undefined');
+check_equals(tmp.uri, undefined);
check_equals(tmp.isConnected, false);
tmp.isConnected = true;
@@ -58,7 +60,6 @@
check_equals(tmp.isConnected, false);
// test the NetConnection::connect method
-tmp.connect();
if ( !
tmp.connect("rtmp://www.mediacollege.com/flash/media-player/testclip-4sec.flv")
)
{
// FIXME: this would fail in the reference player too...
@@ -83,24 +84,49 @@
check_equals(result, "");
check_equals(level, "");
+ret = tmp.connect("");
+check_equals(ret, false);
+check_equals(tmp.isConnected, false);
+check_equals(result, "NetConnection.Connect.Failed");
+check_equals(level, "error");
+check_equals(typeof(tmp.uri), "string");
+check_equals(tmp.uri, "");
+
+ret = tmp.connect("null");
+check_equals(ret, false);
+check_equals(tmp.isConnected, false);
+check_equals(result, "NetConnection.Connect.Failed");
+check_equals(level, "error");
+check_equals(typeof(tmp.uri), "string");
+check_equals(tmp.uri, "null");
ret = tmp.connect(null, "another argument");
check_equals(ret, true);
check_equals(tmp.isConnected, true);
check_equals(result, "NetConnection.Connect.Success");
check_equals(level, "status");
+check_equals(typeof(tmp.uri), "string");
+check_equals(tmp.uri, "null");
+
+// Can't set
+tmp.uri = 6;
+check_equals(tmp.uri, "null");
ret = tmp.connect(1);
check_equals(ret, false);
check_equals(tmp.isConnected, false);
check_equals(result, "NetConnection.Connect.Failed");
check_equals(level, "error");
+check_equals(typeof(tmp.uri), "string");
+check_equals(tmp.uri, "1");
ret = tmp.connect("string");
check_equals(ret, false);
check_equals(tmp.isConnected, false);
check_equals(result, "NetConnection.Connect.Failed");
check_equals(level, "error");
+check_equals(typeof(tmp.uri), "string");
+check_equals(tmp.uri, "string");
ret = tmp.connect(undefined);
@@ -109,11 +135,15 @@
check_equals(tmp.isConnected, true);
check_equals(result, "NetConnection.Connect.Success");
check_equals(level, "status");
+check_equals(typeof(tmp.uri), "string");
+check_equals(tmp.uri, "undefined");
#else
check_equals(ret, false);
check_equals(tmp.isConnected, false);
check_equals(result, "NetConnection.Connect.Failed");
check_equals(level, "error");
+check_equals(typeof(tmp.uri), "string");
+check_equals(tmp.uri, "");
#endif
ret = tmp.connect(null);
@@ -208,7 +238,7 @@
check_equals(result, "NetConnection.Connect.Failed");
check_equals(level, "error");
-check_totals(84);
+check_totals(107);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10385: Another NetConnection method.,
Benjamin Wolsey <=