Gnash  0.8.11dev
NetConnection_as.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_NETCONNECTION_H
20 #define GNASH_NETCONNECTION_H
21 
22 
23 #include <vector>
24 #include <string>
25 #include <list>
26 #include <memory>
27 
28 #include "Relay.h"
29 
30 // Forward declarations
31 namespace gnash {
32  class Connection;
33  class as_object;
34  class as_value;
35  class IOChannel;
36  struct ObjectURI;
37 }
38 
39 namespace gnash {
40 
42 //
46 {
47 public:
48 
50  {
58  };
59 
61 
62  virtual ~NetConnection_as();
63 
65  virtual void update();
66 
68  std::string validateURL() const;
69 
70  void call(as_object* asCallback, const std::string& methodName,
71  const std::vector<as_value>& args);
72 
74  void close();
75 
77  //
80  bool connect(const std::string& uri);
81 
83  //
86  void connect();
87 
88  void setConnected() {
89  _isConnected = true;
90  }
91 
92  bool isConnected() const {
93  return _isConnected;
94  }
95 
96  void setURI(const std::string& uri);
97 
98  const std::string& getURI() const {
99  return _uri;
100  }
101 
104 
106  std::unique_ptr<IOChannel> getStream(const std::string& name);
107 
109  void markReachableResources() const;
110 
111 private:
112 
113  bool isRTMP();
114 
115  void createStream(as_object* asCallback);
116 
118  void addToURL(const std::string& url);
119 
120  typedef std::list<std::unique_ptr<Connection> > Connections;
121 
123  //
128  Connections _oldConnections;
129 
131  std::unique_ptr<Connection> _currentConnection;
132 
134  std::string _uri;
135 
136  bool _isConnected;
137 
138  void startAdvanceTimer();
139 
140  void stopAdvanceTimer();
141 };
142 
143 void netconnection_class_init(as_object& global, const ObjectURI& uri);
144 
145 } // end of gnash namespace
146 
147 #endif
148 
149 // local Variables:
150 // mode: C++
151 // indent-tabs-mode: nil
152 // End:
gnash::NSV::PROP_ON_RESULT
@ PROP_ON_RESULT
Definition: namedStrings.h:173
AMF.h
gnash::movie_root::removeAdvanceCallback
void removeAdvanceCallback(ActiveRelay *obj)
Definition: movie_root.cpp:1464
gnash::NetConnection_as::setConnected
void setConnected()
Definition: NetConnection_as.h:88
gnash::NetConnection_as::getStream
std::unique_ptr< IOChannel > getStream(const std::string &name)
Get an stream by name.
Definition: NetConnection_as.cpp:628
movie_root.h
name
std::string name
Definition: LocalConnection_as.cpp:149
gnash::NetConnection_as::update
virtual void update()
Process connection stuff.
Definition: NetConnection_as.cpp:675
gnash::as_object
The base class for all ActionScript objects.
Definition: as_object.h:162
gnash::GnashException
Top-level gnash exception.
Definition: GnashException.h:31
SimpleBuffer.h
AMFConverter.h
gnash::toObject
as_object * toObject(const as_value &v, VM &vm)
Convert an as_value to an object.
Definition: VM.cpp:457
gnash::NetConnection_as::CALL_BADVERSION
@ CALL_BADVERSION
Definition: NetConnection_as.h:57
gnash::log_debug
void log_debug(StringType msg, Args... args)
Definition: log.h:301
gnash::key::i
@ i
Definition: GnashKey.h:155
gnash::netconnection_class_init
void netconnection_class_init(as_object &where, const ObjectURI &uri)
Definition: NetConnection_as.cpp:424
gnash::typeName
std::string typeName(const T &inst)
Definition: utility.h:93
_
#define _(String)
Definition: log.h:44
gnash::ActiveRelay::owner
as_object & owner() const
Return the as_object that this Relay is attached to.
Definition: Relay.h:108
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::NetConnection_as::markReachableResources
void markReachableResources() const
Mark responders associated with remoting calls.
Definition: NetConnection_as.cpp:431
gnash::NetConnection_as::notifyStatus
void notifyStatus(StatusCode code)
Notify the NetConnection onStatus handler of a change.
Definition: NetConnection_as.cpp:464
gnash::NetConnection_as::NetConnection_as
NetConnection_as(as_object *owner)
Definition: NetConnection_as.cpp:410
gnash::amf::STRICT_ARRAY_AMF0
@ STRICT_ARRAY_AMF0
Definition: AMF.h:57
gnash::NetConnection_as::close
void close()
Process the close() method.
Definition: NetConnection_as.cpp:563
gnash::NetConnection_as::CONNECT_CLOSED
@ CONNECT_CLOSED
Definition: NetConnection_as.h:53
gnash::NetConnection_as::connect
void connect()
Carry out the connect(null) method.
Definition: NetConnection_as.cpp:484
RTMP.h
gnash::rtmp::sendServerBW
bool sendServerBW(RTMP &r)
Send the server bandwidth.
Definition: RTMP.cpp:402
gnash::amf::NULL_AMF0
@ NULL_AMF0
Definition: AMF.h:52
Global_as.h
gnash::amf::readNetworkShort
std::uint16_t readNetworkShort(const std::uint8_t *buf)
Read an unsigned 16-bit value in network byte order.
Definition: AMF.h:119
gnash::getGlobal
Global_as & getGlobal(const as_environment &env)
Definition: as_environment.cpp:651
gnash::getVM
VM & getVM(const as_environment &env)
Definition: as_environment.h:222
gnash::NetConnection_as
NetConnection ActionScript class.
Definition: NetConnection_as.h:46
gnash::VM::getPlayerVersion
const std::string & getPlayerVersion() const
Get version of the player, in a compatible representation.
Definition: VM.cpp:86
UNUSED
#define UNUSED(x)
Definition: utility.h:113
as_function.h
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::getMember
as_value getMember(as_object &o, const ObjectURI &uri)
Get a member of an object using AS lookup rules.
Definition: as_object.h:756
gnash::createObject
as_object * createObject(const Global_as &gl)
Definition: Global_as.cpp:303
gnash::SimpleBuffer::reserve
void reserve(size_t newCapacity)
Ensure at least 'newCapacity' bytes are allocated for this buffer.
Definition: SimpleBuffer.h:94
gnash::NetConnection_as::CONNECT_FAILED
@ CONNECT_FAILED
Definition: NetConnection_as.h:51
handleInvoke
bool handleInvoke(rtmp::RTMP &r, FakeNC &nc, const std::uint8_t *payload, const std::uint8_t *end)
Definition: rtmpget.cpp:541
gnash::fn_call
Parameters/environment for builtin or user-defined functions callable from ActionScript.
Definition: fn_call.h:118
gnash::callMethod
as_value callMethod(fn_call::Args &args, as_object *obj, const ObjectURI &uri)
Call a member function of this object in an AS-compatible way.
Definition: Global_as.h:219
gnash::key::r
@ r
Definition: GnashKey.h:164
gnash::amf::write
void write(SimpleBuffer &buf, const std::string &str)
Write a string to an AMF buffer.
Definition: AMF.cpp:161
gnash::StreamProvider
A StreamProvider makes IOChannels available to the core on request.
Definition: StreamProvider.h:50
gnash::StreamProvider::getStream
virtual std::unique_ptr< IOChannel > getStream(const URL &url, bool namedCacheFile=false) const
Returned stream ownership is transferred to caller.
Definition: StreamProvider.cpp:61
gnash::renderer::opengl::for_each
void for_each(C &container, R(T::*pmf)(const A &), const A &arg)
Definition: Renderer_ogl.cpp:690
GnashSystemNetHeaders.h
gnash::fn_call::dump_args
void dump_args(std::ostream &os) const
Dump arguments to given output stream.
Definition: fn_call.h:214
gnash::getRunResources
const RunResources & getRunResources(const as_object &o)
Get the RunResources from an as_object.
Definition: as_object.cpp:1142
gnash::NSV::PROP_ON_STATUS
@ PROP_ON_STATUS
Definition: namedStrings.h:179
gnash::rtmp::RTMPHeader::headerSize
static const size_t headerSize
The maximum header size of an RTMP packet.
Definition: RTMP.h:155
GnashAlgorithm.h
gnash::amf::readString
std::string readString(const std::uint8_t *&pos, const std::uint8_t *end)
Read a string value from the buffer.
Definition: AMF.cpp:87
IF_VERBOSE_ASCODING_ERRORS
#define IF_VERBOSE_ASCODING_ERRORS(x)
Definition: log.h:397
gnash::key::code
code
Definition: GnashKey.h:44
gnash::ActiveRelay
A native type that requires periodic updates from the core (movie_root).
Definition: Relay.h:80
gnash::NetConnection_as::CONNECT_APPSHUTDOWN
@ CONNECT_APPSHUTDOWN
Definition: NetConnection_as.h:55
gnash::key::h
@ h
Definition: GnashKey.h:154
gnash::NetConnection_as::setURI
void setURI(const std::string &uri)
Definition: NetConnection_as.cpp:584
gnash::amf::writePlainString
void writePlainString(SimpleBuffer &buf, const std::string &str, Type t)
Encode a plain short string to an AMF buffer.
Definition: AMF.cpp:133
URL.h
gnash::SimpleBuffer::size
size_t size() const
Return size of the buffer.
Definition: SimpleBuffer.h:75
gnash::SimpleBuffer::data
std::uint8_t * data()
Get a pointer to start of data. May be NULL if size==0.
Definition: SimpleBuffer.h:81
test.w
w
Definition: test.py:8
gnash::fn_call::nargs
Args::size_type nargs
Number of arguments to this ActionScript function call.
Definition: fn_call.h:178
gnash::amf::NUMBER_AMF0
@ NUMBER_AMF0
Definition: AMF.h:47
gnash::RcInitFile::saveStreamingMedia
void saveStreamingMedia(bool value)
Definition: rc.h:298
gnash::NetConnection_as::CONNECT_REJECTED
@ CONNECT_REJECTED
Definition: NetConnection_as.h:54
gnash::RunResources
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:54
gnash::as_value
ActionScript value type.
Definition: as_value.h:95
VM.h
gnash::as_object::init_readonly_property
void init_readonly_property(const std::string &key, as_function &getter, int flags=DefaultFlags)
Use this method for read-only properties.
Definition: as_object.cpp:734
gnash::NetConnection_as::isConnected
bool isConnected() const
Definition: NetConnection_as.h:92
gnash::fn_call::arg
const Args::value_type & arg(unsigned int n) const
Access a particular argument.
Definition: fn_call.h:194
replyBWCheck
void replyBWCheck(rtmp::RTMP &r, FakeNC &, double txn)
Definition: rtmpget.cpp:250
gnash::log_aserror
void log_aserror(StringType msg, Args... args)
Definition: log.h:331
Relay.h
log.h
gnash::getRoot
movie_root & getRoot(const as_environment &env)
Definition: as_environment.cpp:645
gnash::NetConnection_as::call
void call(as_object *asCallback, const std::string &methodName, const std::vector< as_value > &args)
Definition: NetConnection_as.cpp:591
fn_call.h
NetConnection_as.h
gnash::NetConnection_as::CALL_FAILED
@ CALL_FAILED
Definition: NetConnection_as.h:56
url
std::string url
Definition: gnash.cpp:59
gnash::SimpleBuffer::capacity
size_t capacity() const
Return capacity of the buffer.
Definition: SimpleBuffer.h:78
gnash::key::f
@ f
Definition: GnashKey.h:152
gnashconfig.h
gnash::image::end
pixel_iterator< T > end(GnashImage &im)
Definition: ImageIterators.h:198
gnash::RcInitFile::getDefaultInstance
static RcInitFile & getDefaultInstance()
Return the default instance of RC file.
Definition: rc.cpp:61
namedStrings.h
gnash::getSWFVersion
int getSWFVersion(const as_environment &env)
Definition: as_environment.cpp:657
gnash::registerBuiltinClass
as_object * registerBuiltinClass(as_object &where, Global_as::ASFunction ctor, Global_as::Properties p, Global_as::Properties c, const ObjectURI &uri)
Register a built-in class.
Definition: Global_as.h:144
RunResources.h
test.uri
uri
Definition: test.py:12
gnash::log_security
void log_security(StringType msg, Args... args)
Definition: log.h:319
gnash::NetConnection_as::~NetConnection_as
virtual ~NetConnection_as()
Definition: NetConnection_as.cpp:418
gnash::NetConnection_as::CONNECT_SUCCESS
@ CONNECT_SUCCESS
Definition: NetConnection_as.h:52
gnash::amf::STRING_AMF0
@ STRING_AMF0
Definition: AMF.h:49
gnash::foreachSecond
void foreachSecond(T begin, T end, U op)
Call a functor on the second element of each element in a range.
Definition: GnashAlgorithm.h:73
gnash::getURI
ObjectURI getURI(const VM &vm, const std::string &str, bool lowerCaseHint=false)
Definition: VM.h:290
gnash::StreamProvider::baseURL
const URL & baseURL() const
The base URL that should be used to resolve all relative URLs.
Definition: StreamProvider.h:117
gnash::NetworkAdapter::RequestHeaders
std::map< std::string, std::string, StringNoCaseLessThan > RequestHeaders
Definition: NetworkAdapter.h:43
gnash::amf::readNumber
double readNumber(const std::uint8_t *&pos, const std::uint8_t *end)
Read a number from an AMF buffer.
Definition: AMF.cpp:65
gnash::fn_call::getArgs
const Args::container_type & getArgs() const
Definition: fn_call.h:199
gnash::URL
Uniform Resource Locator.
Definition: URL.h:35
StreamProvider.h
gnash::key::o
@ o
Definition: GnashKey.h:161
gnash::log_unimpl
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
gnash::hexify
std::string hexify(const unsigned char *p, size_t length, bool ascii)
Convert a sequence of bytes to hex or ascii format.
Definition: log.cpp:48
gnash::ObjectURI
A URI for describing as_objects.
Definition: ObjectURI.h:45
gnash::SimpleBuffer::resize
void resize(size_t newSize)
Resize the buffer.
Definition: SimpleBuffer.h:87
gnash::NetConnection_as::getURI
const std::string & getURI() const
Definition: NetConnection_as.h:98
GnashException.h
gnash::NetConnection_as::StatusCode
StatusCode
Definition: NetConnection_as.h:50
gnash::key::b
@ b
Definition: GnashKey.h:148
IOChannel.h
gnash::key::e
@ e
Definition: GnashKey.h:151
gnash::movie_root::addAdvanceCallback
void addAdvanceCallback(ActiveRelay *obj)
Definition: movie_root.cpp:1458
gnash::RcInitFile
Definition: rc.h:44
gnash::RunResources::streamProvider
const StreamProvider & streamProvider() const
Get a StreamProvider instance.
Definition: RunResources.h:76
gnash::NetConnection_as::validateURL
std::string validateURL() const
Make the stored URI into a valid and checked URL.
Definition: NetConnection_as.cpp:444
gnash::GcResource::setReachable
void setReachable() const
Mark this resource as being reachable.
Definition: GC.h:92