gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/NetConnection.cpp ...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/NetConnection.cpp ...
Date: Fri, 04 May 2007 20:28:35 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/05/04 20:28:35

Modified files:
        .              : ChangeLog 
        server/asobj   : NetConnection.cpp NetConnection.h 

Log message:
                * server/asobj/NetConnection.{cpp,h}: Yay, another ActionScript 
class
                  layout version. As a side effect stubbed missing properties 
and
                  methods of the class + cleanups in the connect() method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3093&r2=1.3094
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.cpp?cvsroot=gnash&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.h?cvsroot=gnash&r1=1.25&r2=1.26

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3093
retrieving revision 1.3094
diff -u -b -r1.3093 -r1.3094
--- ChangeLog   4 May 2007 17:05:37 -0000       1.3093
+++ ChangeLog   4 May 2007 20:28:35 -0000       1.3094
@@ -1,5 +1,11 @@
 2007-05-03 Sandro Santilli <address@hidden>
 
+       * server/asobj/NetConnection.{cpp,h}: Yay, another ActionScript class
+         layout version. As a side effect stubbed missing properties and
+         methods of the class + cleanups in the connect() method.
+
+2007-05-03 Sandro Santilli <address@hidden>
+
        * configure.ac: rewording of ffmpeg warnings. Shows a bug in ffmpeg.m4
          failing to detect version and thus failing to accept it when
          passed explicit --with-ffmpeg-incl and --with-ffmpeg-lib.

Index: server/asobj/NetConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- server/asobj/NetConnection.cpp      3 May 2007 14:50:51 -0000       1.39
+++ server/asobj/NetConnection.cpp      4 May 2007 20:28:35 -0000       1.40
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: NetConnection.cpp,v 1.39 2007/05/03 14:50:51 strk Exp $ */
+/* $Id: NetConnection.cpp,v 1.40 2007/05/04 20:28:35 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -41,8 +41,7 @@
 namespace gnash {
 
 static as_value netconnection_new(const fn_call& fn);
-static as_value netconnection_connect(const fn_call& fn);
-static as_object* getNetConnectionInterface();
+//static as_object* getNetConnectionInterface();
 
 /// \class NetConnection
 /// \brief Opens a local connection through which you can play
@@ -57,6 +56,7 @@
        _owner(NULL),
        _loader(NULL)
 {
+       attachProperties();
 }
 
 NetConnection::~NetConnection() {
@@ -114,11 +114,12 @@
 
 /*public*/
 void
-NetConnection::addToURL(const char* url)
+NetConnection::addToURL(const std::string& url)
 {
-       if (strcmp(url, "null") != 0 && strcmp(url, "NULL") != 0) {
+       // What is this ? It is NOT documented in the header !!
+       if (url == "null" || url == "NULL") return;
+
                _url += url;
-       }
 }
 
 /*public*/
@@ -203,44 +204,153 @@
        return as_value(netconnection_obj);
 }
 
-static as_value
-netconnection_connect(const fn_call& fn)
+as_value
+NetConnection::connect_method(const fn_call& fn)
 {
        GNASH_REPORT_FUNCTION;
 
        boost::intrusive_ptr<NetConnection> ptr = 
ensureType<NetConnection>(fn.this_ptr); 
     
-       if (fn.nargs > 0) {
-               ptr->addToURL(fn.arg(0).to_string().c_str());
+       if (fn.nargs < 1)
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror(_("NetConnection.connect(): needs at least one 
argument"));
+               );
+               return as_value(false);
+       }
+
+       as_value& url_val = fn.arg(0);
+
+       // Check first arg for validity 
+       if ( url_val.is_null() || url_val.is_undefined() )
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+               std::stringstream ss; fn.dump_args(ss);
+               log_aserror(_("NetConnection.connect(%s): invalid first arg"), 
ss.str().c_str());
+               );
+               return as_value(false);
+       }
+
+       /// .. TODO: checkme ... addToURL ?? shoudnl't we attempt a connection 
??
+       ptr->addToURL(url_val.to_string(&fn.env()));
+
+       if ( fn.nargs > 1 )
+       {
+               std::stringstream ss; fn.dump_args(ss);
+               log_unimpl("NetConnection.connect(%s): args after the first are 
not supported", ss.str().c_str());
        }
+
+
+       // TODO: FIXME: should return true *or false* for RTMP connections
+       return as_value(true);
+}
+
+as_value
+NetConnection::addHeader_method(const fn_call& fn)
+{
+       boost::intrusive_ptr<NetConnection> ptr = 
ensureType<NetConnection>(fn.this_ptr); 
+       UNUSED(ptr);
+
+       log_unimpl("NetConnection.addHeader()");
        return as_value();
 }
 
+as_value
+NetConnection::call_method(const fn_call& fn)
+{
+       boost::intrusive_ptr<NetConnection> ptr = 
ensureType<NetConnection>(fn.this_ptr); 
+       UNUSED(ptr);
+
+       log_unimpl("NetConnection.call()");
+       return as_value();
+}
+
+as_value
+NetConnection::close_method(const fn_call& fn)
+{
+       boost::intrusive_ptr<NetConnection> ptr = 
ensureType<NetConnection>(fn.this_ptr); 
+       UNUSED(ptr);
+
+       log_unimpl("NetConnection.close()");
+       return as_value();
+}
+
+as_value
+NetConnection::isConnected_getset(const fn_call& fn)
+{
+       boost::intrusive_ptr<NetConnection> ptr = 
ensureType<NetConnection>(fn.this_ptr); 
+       UNUSED(ptr);
+
+       if ( fn.nargs == 0 ) // getter
+       {
+               log_unimpl("NetConnection.isConnected get");
+               return as_value();
+       }
+       else // setter
+       {
+               log_unimpl("NetConnection.isConnected set");
+               return as_value();
+       }
+}
+
+as_value
+NetConnection::uri_getset(const fn_call& fn)
+{
+       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();
+       }
+
+}
+
 void
-attachNetConnectionInterface(as_object& o)
+NetConnection::attachNetConnectionInterface(as_object& o)
 {
+       o.init_member("connect", new 
builtin_function(NetConnection::connect_method));
+       o.init_member("addHeader", new 
builtin_function(NetConnection::addHeader_method));
+       o.init_member("call", new builtin_function(NetConnection::call_method));
+       o.init_member("close", new 
builtin_function(NetConnection::close_method));
 
-       o.init_member("connect", new builtin_function(netconnection_connect));
+}
+
+void
+NetConnection::attachProperties()
+{
+       boost::intrusive_ptr<builtin_function> gettersetter;
+
+       gettersetter = new builtin_function(NetConnection::isConnected_getset, 
NULL);
+       init_property("isConnected", *gettersetter, *gettersetter);
+
+       gettersetter = new builtin_function(NetConnection::uri_getset, NULL);
+       init_property("uri", *gettersetter, *gettersetter);
 
 }
 
-static as_object*
-getNetConnectionInterface()
+as_object*
+NetConnection::getNetConnectionInterface()
 {
 
        static boost::intrusive_ptr<as_object> o;
        if ( o == NULL )
        {
                o = new as_object();
-               attachNetConnectionInterface(*o);
+               NetConnection::attachNetConnectionInterface(*o);
        }
 
        return o.get();
 }
 
-
-// extern (used by Global.cpp)
-void netconnection_class_init(as_object& global)
+void
+NetConnection::registerConstructor(as_object& global)
 {
 
        // This is going to be the global NetConnection "class"/"function"
@@ -251,7 +361,8 @@
                cl=new builtin_function(&netconnection_new, 
getNetConnectionInterface());
                // replicate all interface to class, to be able to access
                // all methods as static functions
-               attachNetConnectionInterface(*cl);
+               // TODO: this is probably wrong !
+               NetConnection::attachNetConnectionInterface(*cl);
                     
        }
 
@@ -260,6 +371,12 @@
 
 }
 
+// extern (used by Global.cpp)
+void netconnection_class_init(as_object& global)
+{
+       NetConnection::registerConstructor(global);
+}
+
 
 } // end of gnash namespace
 

Index: server/asobj/NetConnection.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/asobj/NetConnection.h        19 Apr 2007 07:40:21 -0000      1.25
+++ server/asobj/NetConnection.h        4 May 2007 20:28:35 -0000       1.26
@@ -14,7 +14,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: NetConnection.h,v 1.25 2007/04/19 07:40:21 zoulunkai Exp $ */
+/* $Id: NetConnection.h,v 1.26 2007/05/04 20:28:35 strk Exp $ */
 
 #ifndef __NETCONNECTION_H__
 #define __NETCONNECTION_H__
@@ -71,9 +71,6 @@
        /// Report global position within the file
        size_t tell();
 
-       /// Extend the URL to be used for playing
-       void addToURL(const char* url);
-
        ///     Returns the number of bytes cached
        long getBytesLoaded();
 
@@ -85,8 +82,15 @@
 
        /// Returns whether the load is complete
        bool loadCompleted();
+
+       /// Register the "NetConnection" constructor to the given global object
+       static void registerConstructor(as_object& global);
+
 private:
 
+       /// Extend the URL to be used for playing
+       void addToURL(const std::string& url);
+
        /// the url of the file
        std::string _url;
 
@@ -95,6 +99,34 @@
 
        /// The file/stream loader thread and interface
        LoadThread* _loader;
+
+       /// Attach ActionScript instance properties
+       void attachProperties();
+
+       /// Attach ActionScript class interface
+       static void attachNetConnectionInterface(as_object& o);
+
+       /// Get ActionScript class interface
+       static as_object* getNetConnectionInterface();
+
+       /// NetConnection.isConnected ActionScript Property
+       static as_value isConnected_getset(const fn_call& fn);
+
+       /// NetConnection.uri ActionScript Property
+       static as_value uri_getset(const fn_call& fn);
+
+       /// NetConnection.connect() ActionScript Method
+       static as_value connect_method(const fn_call& fn);
+
+       /// NetConnection.close() ActionScript Method
+       static as_value close_method(const fn_call& fn);
+
+       /// NetConnection.call() ActionScript Method
+       static as_value call_method(const fn_call& fn);
+
+       /// NetConnection.addHeader() ActionScript Method
+       static as_value addHeader_method(const fn_call& fn);
+
 };
 
 void netconnection_class_init(as_object& global);




reply via email to

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