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
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef GNASH_PLUGIN_SCRIPT_OBJECT_H
00036 #define GNASH_PLUGIN_SCRIPT_OBJECT_H
00037
00038 #include <map>
00039 #include <string>
00040
00041 #include <glib.h>
00042 #include "npapi.h"
00043 #include "npruntime.h"
00044 #include "GnashNPVariant.h"
00045
00046 #define READFD 0
00047 #define WRITEFD 1
00048
00049 namespace gnash {
00050
00054 void
00055 CopyVariantValue(const NPVariant& from, NPVariant& to);
00056
00057 class GnashPluginScriptObject : public NPObject
00058 {
00059 public:
00060
00061 GnashPluginScriptObject();
00062 GnashPluginScriptObject(NPP npp);
00063 ~GnashPluginScriptObject();
00064
00065 static NPClass *marshalGetNPClass();
00066
00067
00068
00069 static NPObject *marshalAllocate (NPP npp, NPClass *aClass);
00070 static void marshalDeallocate (NPObject *npobj);
00071 static void marshalInvalidate (NPObject *npobj);
00072 static bool marshalHasMethod (NPObject *npobj, NPIdentifier name);
00073 static bool marshalInvoke (NPObject *npobj, NPIdentifier name,
00074 const NPVariant *args, uint32_t argCount,
00075 NPVariant *result);
00076 static bool marshalInvokeDefault (NPObject *npobj, const NPVariant *args,
00077 uint32_t argCount, NPVariant *result);
00078 static bool marshalHasProperty (NPObject *npobj, NPIdentifier name);
00079 static bool marshalGetProperty (NPObject *npobj, NPIdentifier name,
00080 NPVariant *result);
00081 static bool marshalSetProperty (NPObject *npobj, NPIdentifier name,
00082 const NPVariant *value);
00083 static bool marshalRemoveProperty (NPObject *npobj, NPIdentifier name);
00084 static bool marshalEnumerate (NPObject *npobj, void***identifier,
00085 uint32_t *count);
00086 static bool marshalConstruct (NPObject *npobj, const NPVariant *data,
00087 uint32_t count, NPVariant *result);
00088
00089 static NPClass _npclass;
00090
00093
00097 void setControlFD(int x);
00098 int getControlFD();
00099
00103 void setHostFD(int x);
00104 int getHostFD();
00105
00113 bool SetVariable(const std::string &name, const NPVariant& value);
00114
00120 GnashNPVariant GetVariable(const std::string &name);
00121
00122
00123 int getReadFD() { return _hostfd; };
00124 int getWriteFD() { return _controlfd; };
00125
00126
00127 int writePlayer(const std::string &data);
00128 int writePlayer(int fd, const std::string &data);
00129
00130
00131 std::string readPlayer();
00132 std::string readPlayer(int fd);
00133
00134 bool Invoke(NPObject *npobj, NPIdentifier name, const NPVariant *args,
00135 uint32_t argCount, NPVariant *result);
00136 bool AddMethod(NPIdentifier name, NPInvokeFunctionPtr func);
00137 void AddProperty(const std::string &name, const std::string &str);
00138 void AddProperty(const std::string &name, double num);
00139 void AddProperty(const std::string &name, int num);
00140
00141 protected:
00142
00143 void Deallocate();
00144 void Invalidate();
00145 bool HasMethod(NPIdentifier name);
00146
00147 bool InvokeDefault(const NPVariant *args, uint32_t argCount,
00148 NPVariant *result);
00149 bool HasProperty(NPIdentifier name);
00150 bool GetProperty(NPIdentifier name, NPVariant *result);
00151 bool SetProperty(NPIdentifier name, const NPVariant& value);
00152 bool RemoveProperty(NPIdentifier name);
00153 bool Enumerate(NPIdentifier **identifier, uint32_t *count);
00154 bool Construct(const NPVariant *data, uint32_t argCount, NPVariant *result);
00155
00156 private:
00157 void initializeIdentifiers();
00158 void setInstance(NPP inst) { _nppinstance = inst; };
00159
00160
00161 NPP _nppinstance;
00162
00163 std::map<NPIdentifier, GnashNPVariant> _properties;
00164 std::map<NPIdentifier, NPInvokeFunctionPtr> _methods;
00165
00166
00170 int _controlfd;
00174 int _hostfd;
00175 };
00176
00177 }
00178
00179 #endif // GNASH_PLUGIN_SCRIPT_OBJECT_H
00180
00181
00182
00183
00184