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 <string>
25 #include <vector>
26 #include <map>
27 #include <set>
28 #include <boost/shared_ptr.hpp>
29 
30 #include "dsodefs.h" /* For DSOEXPORT */
31 
32 namespace gnash {
33  class as_object;
34  class as_value;
35  struct ObjectURI;
36  class Global_as;
37  class movie_root;
38  class IOChannel;
39 }
40 
41 namespace gnash {
42 
44 {
45  struct DSOLOCAL invoke_t {
46  std::string name;
47  std::string type;
48  std::vector<as_value> args;
49  };
50 
52  static std::string toXML(const as_value &obj) {
54  return ei._toXML(obj);
55  }
56 
57  static as_value parseXML(const std::string &xml);
58  static std::vector<as_value> parseArguments(const std::string &xml);
59 
60  // Parse the XML Invoke message.
61  static boost::shared_ptr<invoke_t> parseInvoke(const std::string &str);
62  // Check for data from the browser and parse it.
63  DSOEXPORT static boost::shared_ptr<invoke_t> ExternalEventCheck(int fd);
64 
65  // These methods are for constructing Invoke messages.
66  // Create an Invoke message for the standalone Gnash
67  DSOEXPORT static std::string makeInvoke (const std::string &method,
68  const std::vector<as_value> &args);
69 
70  static std::string makeString (const std::string &str) {
71  return "<string>" + str + "</string>";
72  }
73 
74  DSOEXPORT static size_t writeBrowser(int fd, const std::string &xml);
75  DSOEXPORT static std::string readBrowser(int fd);
76 
77 private:
78 
79  DSOEXPORT std::string _toXML(const as_value &obj);
80  DSOEXPORT std::string _objectToXML(as_object* obj);
81  DSOEXPORT std::string _arrayToXML(as_object *obj);
82 
83  std::set<as_object*> _visited;
84 };
85 
86 } // end of gnash namespace
87 
88 #endif
89 
90 // local Variables:
91 // mode: C++
92 // indent-tabs-mode: nil
93 // End: