Gnash  0.8.11dev
ExternalInterface.h
Go to the documentation of this file.
1 // ExternalInterface.h: ActionScript "ExternalInterface" support
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 
21 #ifndef GNASH_EXTERNALINTERFACE_H
22 #define GNASH_EXTERNALINTERFACE_H
23 
24 #include <memory>
25 #include <string>
26 #include <vector>
27 #include <set>
28 
29 #include "dsodefs.h" /* For DSOEXPORT */
30 
31 namespace gnash {
32  class as_object;
33  class as_value;
34  struct ObjectURI;
35  class Global_as;
36  class movie_root;
37  class IOChannel;
38 }
39 
40 namespace gnash {
41 
43 {
44  struct DSOLOCAL invoke_t {
45  std::string name;
46  std::string type;
47  std::vector<as_value> args;
48  };
49 
51  static std::string toXML(const as_value &obj) {
53  return ei._toXML(obj);
54  }
55 
56  static as_value parseXML(const std::string &xml);
57  static std::vector<as_value> parseArguments(const std::string &xml);
58 
59  // Parse the XML Invoke message.
60  static std::unique_ptr<invoke_t> parseInvoke(const std::string &str);
61  // Check for data from the browser and parse it.
62  DSOEXPORT static std::unique_ptr<invoke_t> ExternalEventCheck(int fd);
63 
64  // These methods are for constructing Invoke messages.
65  // Create an Invoke message for the standalone Gnash
66  DSOEXPORT static std::string makeInvoke (const std::string &method,
67  const std::vector<as_value> &args);
68 
69  static std::string makeString (const std::string &str) {
70  return "<string>" + str + "</string>";
71  }
72 
73  DSOEXPORT static size_t writeBrowser(int fd, const std::string &xml);
74  DSOEXPORT static std::string readBrowser(int fd);
75 
76 private:
77 
78  DSOEXPORT std::string _toXML(const as_value &obj);
79  DSOEXPORT std::string _objectToXML(as_object* obj);
80  DSOEXPORT std::string _arrayToXML(as_object *obj);
81 
82  std::set<as_object*> _visited;
83 };
84 
85 } // end of gnash namespace
86 
87 #endif
88 
89 // local Variables:
90 // mode: C++
91 // indent-tabs-mode: nil
92 // End:
gnash::ExternalInterface::writeBrowser
static DSOEXPORT size_t writeBrowser(int fd, const std::string &xml)
Definition: ExternalInterface.cpp:326
gnash::ExternalInterface::invoke_t::args
std::vector< as_value > args
Definition: ExternalInterface.h:47
movie_root.h
name
std::string name
Definition: LocalConnection_as.cpp:149
gnash::as_object
The base class for all ActionScript objects.
Definition: as_object.h:162
as_object.h
dsodefs.h
gnash::log_debug
void log_debug(StringType msg, Args... args)
Definition: log.h:301
gnash::ExternalInterface::makeInvoke
static DSOEXPORT std::string makeInvoke(const std::string &method, const std::vector< as_value > &args)
Definition: ExternalInterface.cpp:302
gnash::key::i
@ i
Definition: GnashKey.h:155
rc.h
_
#define _(String)
Definition: log.h:44
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
PropertyList.h
as_value.h
gnash::ExternalInterface
Definition: ExternalInterface.h:43
gnash::as_value::set_double
void set_double(double val)
Set to a primitive number.
Definition: as_value.cpp:739
start
@ start
Definition: klash_part.cpp:330
Global_as.h
gnash::ExternalInterface::toXML
static std::string toXML(const as_value &obj)
Convert an AS object to an XML string.
Definition: ExternalInterface.h:51
gnash::getVM
VM & getVM(const as_environment &env)
Definition: as_environment.h:222
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::as_value::set_string
void set_string(const std::string &str)
Set to a primitive string.
Definition: as_value.cpp:732
gnash::ExternalInterface::parseArguments
static std::vector< as_value > parseArguments(const std::string &xml)
Definition: ExternalInterface.cpp:270
gnash::amf::write
void write(SimpleBuffer &buf, const std::string &str)
Write a string to an AMF buffer.
Definition: AMF.cpp:161
GnashSystemNetHeaders.h
StringPredicates.h
gnash::invoke
DSOEXPORT as_value invoke(const as_value &method, const as_environment &env, as_object *this_ptr, fn_call::Args &args, as_object *super=nullptr, const movie_definition *callerDef=nullptr)
Call an as_value on an as_object.
Definition: Global_as.h:166
ExternalInterface.h
gnash::as_value::set_undefined
void set_undefined()
Set to undefined.
Definition: as_value.cpp:519
gnash::ExternalInterface::invoke_t
Definition: ExternalInterface.h:44
gnash::ExternalInterface::makeString
static std::string makeString(const std::string &str)
Definition: ExternalInterface.h:69
gnash::as_value
ActionScript value type.
Definition: as_value.h:95
VM.h
gnash::ExternalInterface::parseInvoke
static std::unique_ptr< invoke_t > parseInvoke(const std::string &str)
Definition: ExternalInterface.cpp:179
gnash::as_value::set_bool
void set_bool(bool val)
Set to a primitive boolean.
Definition: as_value.cpp:746
XML_as.h
log.h
gnash::ExternalInterface::invoke_t::type
std::string type
Definition: ExternalInterface.h:46
fn_call.h
gnash::image::end
pixel_iterator< T > end(GnashImage &im)
Definition: ImageIterators.h:198
namedStrings.h
DSOEXPORT
#define DSOEXPORT
Definition: dsodefs.h:55
gnash::ExternalInterface::parseXML
static as_value parseXML(const std::string &xml)
Definition: ExternalInterface.cpp:226
gnash::ExternalInterface::invoke_t::name
std::string name
Definition: ExternalInterface.h:45
Array_as.h
GnashSystemFDHeaders.h
gnash::ExternalInterface::ExternalEventCheck
static DSOEXPORT std::unique_ptr< invoke_t > ExternalEventCheck(int fd)
Definition: ExternalInterface.cpp:142
gnash::as_value::set_null
void set_null()
Set this value to the NULL value.
Definition: as_value.cpp:526
DSOLOCAL
#define DSOLOCAL
Definition: dsodefs.h:56
gnash::key::u
@ u
Definition: GnashKey.h:167
data
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
gnash::key::e
@ e
Definition: GnashKey.h:151
gnash::ExternalInterface::readBrowser
static DSOEXPORT std::string readBrowser(int fd)
Definition: ExternalInterface.cpp:336