Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GNASH_PLUGIN_H
00021 #define GNASH_PLUGIN_H
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include "gnashconfig.h"
00025 #endif
00026
00027 #ifndef HAVE_FUNCTION
00028 # ifndef HAVE_func
00029 # define dummystr(x) # x
00030 # define dummyestr(x) dummystr(x)
00031 # define __FUNCTION__ __FILE__":"dummyestr(__LINE__)
00032 # else
00033 # define __FUNCTION__ __func__
00034 # endif
00035 #endif
00036
00037 #ifndef HAVE_PRETTY_FUNCTION
00038 # define __PRETTY_FUNCTION__ __FUNCTION__
00039 #endif
00040
00041
00042 #include <X11/Xlib.h>
00043
00044 #include <X11/cursorfont.h>
00045 #include <glib.h>
00046 #include <string>
00047 #include <map>
00048 #include <vector>
00049 #include <boost/format.hpp>
00050 #include <boost/preprocessor/arithmetic/inc.hpp>
00051 #include <boost/preprocessor/repetition/enum_params.hpp>
00052 #include <boost/preprocessor/repetition/repeat.hpp>
00053 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
00054 #include <boost/preprocessor/seq/for_each.hpp>
00055
00056 #include "pluginbase.h"
00057 #include "pluginScriptObject.h"
00058
00059 namespace gnash {
00060
00061 extern NPBool plugInitialized;
00062
00063 class nsPluginInstance : public nsPluginInstanceBase
00064 {
00065 public:
00066 nsPluginInstance(nsPluginCreateData* );
00067 virtual ~nsPluginInstance();
00068
00069
00070 NPBool init(NPWindow *aWindow);
00071 NPBool isInitialized() { return plugInitialized; }
00072 void shut();
00073
00074 NPError GetValue(NPPVariable variable, void *value);
00075 NPError SetWindow(NPWindow *aWindow);
00076
00078 NPError NewStream(NPMIMEType type, NPStream *stream, NPBool seekable,
00079 uint16_t *stype);
00081 NPError DestroyStream(NPStream * stream, NPError reason);
00082
00084 int32_t WriteReady(NPStream *stream);
00085 int32_t Write(NPStream *stream, int32_t offset, int32_t len, void *buffer);
00086 NPObject *getScriptableObject();
00087 const char *getEmbedURL() const;
00088
00089 GnashPluginScriptObject *getScriptObject() { return _scriptObject; };
00090
00091 private:
00092 NPError startProc();
00093 std::vector<std::string> getCmdLine(int hostfd, int controlfd);
00094
00095 void setupCookies(const std::string& pageURL);
00096 void setupProxy(const std::string& pageURL);
00097
00099 std::string getDocumentProp(const std::string& propname) const;
00100
00101 static bool handlePlayerRequestsWrapper(GIOChannel* iochan, GIOCondition cond, nsPluginInstance* plugin);
00102
00103 bool handlePlayerRequests(GIOChannel* iochan, GIOCondition cond);
00104
00110 void setupIOChannel(int fd, GIOFunc handler, GIOCondition signals) const;
00111
00112
00114
00117 bool processPlayerRequest();
00118
00119
00120
00121 std::map<std::string, std::string> _params;
00122
00123 NPP _instance;
00124 Window _window;
00125 std::string _swf_url;
00126 std::string _swf_file;
00127 unsigned int _width;
00128 unsigned int _height;
00129 std::map<std::string, std::string> _options;
00134 int _streamfd;
00135 pid_t _childpid;
00136 int _filefd;
00137
00139 std::string _name;
00140 GnashPluginScriptObject *_scriptObject;
00141
00145
00146 std::string _requestbuf;
00147
00148 std::string getCurrentPageURL() const;
00149 };
00150
00151
00152
00153
00154
00155
00156
00157 #define GNASH_PLUGIN_DEBUG 1
00158
00159
00160
00161
00162
00163 DSOEXPORT void processLog_error(const boost::format& fmt);
00164 DSOEXPORT void processLog_debug(const boost::format& fmt);
00165 DSOEXPORT void processLog_trace(const boost::format& fmt);
00166
00169
00172 #define TOKENIZE_FORMAT(z, n, t) % t##n
00173
00177 #define TOKENIZE_ARGS(z, n, t) BOOST_PP_COMMA_IF(n) const T##n& t##n
00178
00182 #define LOG_TYPES (error) (debug) (trace)
00183
00184
00185 #define ARG_NUMBER 4
00186 #define LOG_TEMPLATES(z, n, data)\
00187 template<BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), typename T)>\
00188 inline void log_##data(BOOST_PP_REPEAT(BOOST_PP_INC(n), TOKENIZE_ARGS, t)) \
00189 {\
00190 if (GNASH_PLUGIN_DEBUG < 1) return; \
00191 boost::format f(t0); \
00192 using namespace boost::io; \
00193 f.exceptions(all_error_bits ^ (too_many_args_bit | \
00194 too_few_args_bit | \
00195 bad_format_string_bit)); \
00196 processLog_##data(f BOOST_PP_REPEAT_FROM_TO(1, \
00197 BOOST_PP_INC(n), \
00198 TOKENIZE_FORMAT, t));\
00199 }
00200
00204 #define GENERATE_LOG_TYPES(r, _, t) \
00205 BOOST_PP_REPEAT(ARG_NUMBER, LOG_TEMPLATES, t)
00206
00209 BOOST_PP_SEQ_FOR_EACH(GENERATE_LOG_TYPES, _, LOG_TYPES)
00210
00211
00212 #endif
00213
00214 }
00215
00216
00217
00218
00219