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:
Definition: ExternalInterface.h:42
static std::string toXML(const as_value &obj)
Convert an AS object to an XML string.
Definition: ExternalInterface.h:51
Definition: ExternalInterface.h:44
ActionScript value type.
Definition: as_value.h:94
std::string type
Definition: ExternalInterface.h:46
std::string name
Definition: ExternalInterface.h:45
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
The base class for all ActionScript objects.
Definition: as_object.h:161
std::vector< as_value > args
Definition: ExternalInterface.h:47
static std::string makeString(const std::string &str)
Definition: ExternalInterface.h:69
#define DSOEXPORT
Definition: dsodefs.h:55
#define DSOLOCAL
Definition: dsodefs.h:56