• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

ExternalInterface.h

Go to the documentation of this file.
00001 // ExternalInterface.h:  ActionScript "ExternalInterface" support
00002 //
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00004 //   Foundation, Inc
00005 //
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 //
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 
00021 #ifndef GNASH_EXTERNALINTERFACE_H
00022 #define GNASH_EXTERNALINTERFACE_H
00023 
00024 #include <string>
00025 #include <vector>
00026 #include <map>
00027 #include <boost/shared_ptr.hpp>
00028 
00029 #include "dsodefs.h" /* For DSOEXPORT */
00030 
00031 namespace gnash {
00032 
00033 class as_object;
00034 class as_value;
00035 struct ObjectURI;
00036 class Global_as;
00037 class movie_root;
00038 class IOChannel;
00039 }
00040 
00041 namespace gnash {
00042 
00043 struct DSOEXPORT ExternalInterface
00044 {
00045     typedef struct DSOLOCAL {
00046         std::string name;
00047         std::string type;
00048         std::vector<as_value> args;
00049     } invoke_t;
00050 
00051     // Some of these appear to be undocumented helper functions of this class
00052     // that while probably designed to be used internally, get used
00053     // by ActionScript coders.
00054 
00056     DSOEXPORT static std::string toXML(const as_value &obj);
00057     
00059     DSOEXPORT static as_value toAS(Global_as& as, const std::string &xml);
00060 
00062     DSOEXPORT static std::map<std::string, as_value> propertiesToAS(Global_as& gl,
00063                                                    std::string &xml);
00064     
00065     DSOEXPORT static as_value argumentsToXML(std::vector<as_value> &args);
00066 //    as_value argumentsToAS();
00067     
00068     DSOEXPORT static std::string objectToXML(as_object *obj);
00069     DSOEXPORT static as_value objectToAS(Global_as& gl, const std::string &xml);
00070 //  std::string objectToJS(as_object &obj);
00071 //  as_value toJS(const std::string &xml);;
00072     
00073     DSOEXPORT static std::string arrayToXML(as_object *obj);
00074 
00075 //  static std::string arrayToJS();
00076 //  static as_value arrayToAS();
00077 
00078 //  static std::string jsQuoteString();
00079 //  static void initJS();
00080 //  static bool evalJS();
00081     
00082 //  static callOut"));
00083 //  static callIn"));
00084 
00085     static std::string escapeXML(as_object &obj);
00086     static std::string unescapeXML(as_object &obj);
00087 
00088     static as_value parseXML(const std::string &xml);
00089     static std::vector<as_value> parseArguments(const std::string &xml);
00090 
00091     // Parse the XML Invoke message.
00092     static boost::shared_ptr<invoke_t> parseInvoke(const std::string &str);
00093     // Check for data from the browser and parse it.
00094     DSOEXPORT static boost::shared_ptr<invoke_t> ExternalEventCheck(int fd);
00095 
00096     // These methods are for constructing Invoke messages.
00097     // Create an Invoke message for the standalone Gnash
00098     DSOEXPORT static std::string makeInvoke (const std::string &method,
00099                                              const std::vector<as_value> &args);
00100     
00101     static std::string makeNull ();
00102     static std::string makeTrue ();
00103     static std::string makeFalse ();
00104     static std::string makeString (const std::string &str);
00105     static std::string makeProperty (const std::string &str, const std::string &data);
00106     static std::string makeProperty (const std::string &str, double num);
00107     static std::string makeProperty (const std::string &str, int num);
00108     static std::string makeNumber (double num);
00109     static std::string makeNumber (int num);
00110     static std::string makeNumber (unsigned int num);
00111     static std::string makeArray (std::vector<std::string> &args);
00112     static std::string makeObject (std::map<std::string, std::string> &args);
00113 
00114     DSOEXPORT static size_t writeBrowser(int fd, const std::string &xml);
00115     DSOEXPORT static std::string readBrowser(int fd);
00116 };
00117 
00118 } // end of gnash namespace
00119 
00120 // __GNASH_ASOBJ_EXTERNALINTERFACE_H__
00121 #endif
00122 
00123 // local Variables:
00124 // mode: C++
00125 // indent-tabs-mode: nil
00126 // End:

Generated on Fri Mar 16 2012 15:46:09 for Gnash by  doxygen 1.7.1