|
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef npfunctions_h_ |
|
7 #define npfunctions_h_ |
|
8 |
|
9 #include "npapi.h" |
|
10 #include "npruntime.h" |
|
11 |
|
12 #ifdef MOZ_WIDGET_ANDROID |
|
13 #include <jni.h> |
|
14 #endif |
|
15 |
|
16 typedef NPError (* NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved); |
|
17 typedef NPError (* NPP_DestroyProcPtr)(NPP instance, NPSavedData** save); |
|
18 typedef NPError (* NPP_SetWindowProcPtr)(NPP instance, NPWindow* window); |
|
19 typedef NPError (* NPP_NewStreamProcPtr)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype); |
|
20 typedef NPError (* NPP_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason); |
|
21 typedef int32_t (* NPP_WriteReadyProcPtr)(NPP instance, NPStream* stream); |
|
22 typedef int32_t (* NPP_WriteProcPtr)(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer); |
|
23 typedef void (* NPP_StreamAsFileProcPtr)(NPP instance, NPStream* stream, const char* fname); |
|
24 typedef void (* NPP_PrintProcPtr)(NPP instance, NPPrint* platformPrint); |
|
25 typedef int16_t (* NPP_HandleEventProcPtr)(NPP instance, void* event); |
|
26 typedef void (* NPP_URLNotifyProcPtr)(NPP instance, const char* url, NPReason reason, void* notifyData); |
|
27 /* Any NPObjects returned to the browser via NPP_GetValue should be retained |
|
28 by the plugin on the way out. The browser is responsible for releasing. */ |
|
29 typedef NPError (* NPP_GetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value); |
|
30 typedef NPError (* NPP_SetValueProcPtr)(NPP instance, NPNVariable variable, void *value); |
|
31 typedef NPBool (* NPP_GotFocusPtr)(NPP instance, NPFocusDirection direction); |
|
32 typedef void (* NPP_LostFocusPtr)(NPP instance); |
|
33 typedef void (* NPP_URLRedirectNotifyPtr)(NPP instance, const char* url, int32_t status, void* notifyData); |
|
34 typedef NPError (* NPP_ClearSiteDataPtr)(const char* site, uint64_t flags, uint64_t maxAge); |
|
35 typedef char** (* NPP_GetSitesWithDataPtr)(void); |
|
36 typedef void (* NPP_DidCompositePtr)(NPP instance); |
|
37 |
|
38 typedef NPError (*NPN_GetValueProcPtr)(NPP instance, NPNVariable variable, void *ret_value); |
|
39 typedef NPError (*NPN_SetValueProcPtr)(NPP instance, NPPVariable variable, void *value); |
|
40 typedef NPError (*NPN_GetURLNotifyProcPtr)(NPP instance, const char* url, const char* window, void* notifyData); |
|
41 typedef NPError (*NPN_PostURLNotifyProcPtr)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData); |
|
42 typedef NPError (*NPN_GetURLProcPtr)(NPP instance, const char* url, const char* window); |
|
43 typedef NPError (*NPN_PostURLProcPtr)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file); |
|
44 typedef NPError (*NPN_RequestReadProcPtr)(NPStream* stream, NPByteRange* rangeList); |
|
45 typedef NPError (*NPN_NewStreamProcPtr)(NPP instance, NPMIMEType type, const char* window, NPStream** stream); |
|
46 typedef int32_t (*NPN_WriteProcPtr)(NPP instance, NPStream* stream, int32_t len, void* buffer); |
|
47 typedef NPError (*NPN_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason); |
|
48 typedef void (*NPN_StatusProcPtr)(NPP instance, const char* message); |
|
49 /* Browser manages the lifetime of the buffer returned by NPN_UserAgent, don't |
|
50 depend on it sticking around and don't free it. */ |
|
51 typedef const char* (*NPN_UserAgentProcPtr)(NPP instance); |
|
52 typedef void* (*NPN_MemAllocProcPtr)(uint32_t size); |
|
53 typedef void (*NPN_MemFreeProcPtr)(void* ptr); |
|
54 typedef uint32_t (*NPN_MemFlushProcPtr)(uint32_t size); |
|
55 typedef void (*NPN_ReloadPluginsProcPtr)(NPBool reloadPages); |
|
56 typedef void* (*NPN_GetJavaEnvProcPtr)(void); |
|
57 typedef void* (*NPN_GetJavaPeerProcPtr)(NPP instance); |
|
58 typedef void (*NPN_InvalidateRectProcPtr)(NPP instance, NPRect *rect); |
|
59 typedef void (*NPN_InvalidateRegionProcPtr)(NPP instance, NPRegion region); |
|
60 typedef void (*NPN_ForceRedrawProcPtr)(NPP instance); |
|
61 typedef NPIdentifier (*NPN_GetStringIdentifierProcPtr)(const NPUTF8* name); |
|
62 typedef void (*NPN_GetStringIdentifiersProcPtr)(const NPUTF8** names, int32_t nameCount, NPIdentifier* identifiers); |
|
63 typedef NPIdentifier (*NPN_GetIntIdentifierProcPtr)(int32_t intid); |
|
64 typedef bool (*NPN_IdentifierIsStringProcPtr)(NPIdentifier identifier); |
|
65 typedef NPUTF8* (*NPN_UTF8FromIdentifierProcPtr)(NPIdentifier identifier); |
|
66 typedef int32_t (*NPN_IntFromIdentifierProcPtr)(NPIdentifier identifier); |
|
67 typedef NPObject* (*NPN_CreateObjectProcPtr)(NPP npp, NPClass *aClass); |
|
68 typedef NPObject* (*NPN_RetainObjectProcPtr)(NPObject *obj); |
|
69 typedef void (*NPN_ReleaseObjectProcPtr)(NPObject *obj); |
|
70 typedef bool (*NPN_InvokeProcPtr)(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result); |
|
71 typedef bool (*NPN_InvokeDefaultProcPtr)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); |
|
72 typedef bool (*NPN_EvaluateProcPtr)(NPP npp, NPObject *obj, NPString *script, NPVariant *result); |
|
73 typedef bool (*NPN_GetPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result); |
|
74 typedef bool (*NPN_SetPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value); |
|
75 typedef bool (*NPN_RemovePropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); |
|
76 typedef bool (*NPN_HasPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); |
|
77 typedef bool (*NPN_HasMethodProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName); |
|
78 typedef void (*NPN_ReleaseVariantValueProcPtr)(NPVariant *variant); |
|
79 typedef void (*NPN_SetExceptionProcPtr)(NPObject *obj, const NPUTF8 *message); |
|
80 typedef void (*NPN_PushPopupsEnabledStateProcPtr)(NPP npp, NPBool enabled); |
|
81 typedef void (*NPN_PopPopupsEnabledStateProcPtr)(NPP npp); |
|
82 typedef bool (*NPN_EnumerateProcPtr)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count); |
|
83 typedef void (*NPN_PluginThreadAsyncCallProcPtr)(NPP instance, void (*func)(void *), void *userData); |
|
84 typedef bool (*NPN_ConstructProcPtr)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); |
|
85 typedef NPError (*NPN_GetValueForURLPtr)(NPP npp, NPNURLVariable variable, const char *url, char **value, uint32_t *len); |
|
86 typedef NPError (*NPN_SetValueForURLPtr)(NPP npp, NPNURLVariable variable, const char *url, const char *value, uint32_t len); |
|
87 typedef NPError (*NPN_GetAuthenticationInfoPtr)(NPP npp, const char *protocol, const char *host, int32_t port, const char *scheme, const char *realm, char **username, uint32_t *ulen, char **password, uint32_t *plen); |
|
88 typedef uint32_t (*NPN_ScheduleTimerPtr)(NPP instance, uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID)); |
|
89 typedef void (*NPN_UnscheduleTimerPtr)(NPP instance, uint32_t timerID); |
|
90 typedef NPError (*NPN_PopUpContextMenuPtr)(NPP instance, NPMenu* menu); |
|
91 typedef NPBool (*NPN_ConvertPointPtr)(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace); |
|
92 typedef NPBool (*NPN_HandleEventPtr)(NPP instance, void *event, NPBool handled); |
|
93 typedef NPBool (*NPN_UnfocusInstancePtr)(NPP instance, NPFocusDirection direction); |
|
94 typedef void (*NPN_URLRedirectResponsePtr)(NPP instance, void* notifyData, NPBool allow); |
|
95 typedef NPError (*NPN_InitAsyncSurfacePtr)(NPP instance, NPSize *size, NPImageFormat format, void *initData, NPAsyncSurface *surface); |
|
96 typedef NPError (*NPN_FinalizeAsyncSurfacePtr)(NPP instance, NPAsyncSurface *surface); |
|
97 typedef void (*NPN_SetCurrentAsyncSurfacePtr)(NPP instance, NPAsyncSurface *surface, NPRect *changed); |
|
98 |
|
99 typedef struct _NPPluginFuncs { |
|
100 uint16_t size; |
|
101 uint16_t version; |
|
102 NPP_NewProcPtr newp; |
|
103 NPP_DestroyProcPtr destroy; |
|
104 NPP_SetWindowProcPtr setwindow; |
|
105 NPP_NewStreamProcPtr newstream; |
|
106 NPP_DestroyStreamProcPtr destroystream; |
|
107 NPP_StreamAsFileProcPtr asfile; |
|
108 NPP_WriteReadyProcPtr writeready; |
|
109 NPP_WriteProcPtr write; |
|
110 NPP_PrintProcPtr print; |
|
111 NPP_HandleEventProcPtr event; |
|
112 NPP_URLNotifyProcPtr urlnotify; |
|
113 void* javaClass; |
|
114 NPP_GetValueProcPtr getvalue; |
|
115 NPP_SetValueProcPtr setvalue; |
|
116 NPP_GotFocusPtr gotfocus; |
|
117 NPP_LostFocusPtr lostfocus; |
|
118 NPP_URLRedirectNotifyPtr urlredirectnotify; |
|
119 NPP_ClearSiteDataPtr clearsitedata; |
|
120 NPP_GetSitesWithDataPtr getsiteswithdata; |
|
121 NPP_DidCompositePtr didComposite; |
|
122 } NPPluginFuncs; |
|
123 |
|
124 typedef struct _NPNetscapeFuncs { |
|
125 uint16_t size; |
|
126 uint16_t version; |
|
127 NPN_GetURLProcPtr geturl; |
|
128 NPN_PostURLProcPtr posturl; |
|
129 NPN_RequestReadProcPtr requestread; |
|
130 NPN_NewStreamProcPtr newstream; |
|
131 NPN_WriteProcPtr write; |
|
132 NPN_DestroyStreamProcPtr destroystream; |
|
133 NPN_StatusProcPtr status; |
|
134 NPN_UserAgentProcPtr uagent; |
|
135 NPN_MemAllocProcPtr memalloc; |
|
136 NPN_MemFreeProcPtr memfree; |
|
137 NPN_MemFlushProcPtr memflush; |
|
138 NPN_ReloadPluginsProcPtr reloadplugins; |
|
139 NPN_GetJavaEnvProcPtr getJavaEnv; |
|
140 NPN_GetJavaPeerProcPtr getJavaPeer; |
|
141 NPN_GetURLNotifyProcPtr geturlnotify; |
|
142 NPN_PostURLNotifyProcPtr posturlnotify; |
|
143 NPN_GetValueProcPtr getvalue; |
|
144 NPN_SetValueProcPtr setvalue; |
|
145 NPN_InvalidateRectProcPtr invalidaterect; |
|
146 NPN_InvalidateRegionProcPtr invalidateregion; |
|
147 NPN_ForceRedrawProcPtr forceredraw; |
|
148 NPN_GetStringIdentifierProcPtr getstringidentifier; |
|
149 NPN_GetStringIdentifiersProcPtr getstringidentifiers; |
|
150 NPN_GetIntIdentifierProcPtr getintidentifier; |
|
151 NPN_IdentifierIsStringProcPtr identifierisstring; |
|
152 NPN_UTF8FromIdentifierProcPtr utf8fromidentifier; |
|
153 NPN_IntFromIdentifierProcPtr intfromidentifier; |
|
154 NPN_CreateObjectProcPtr createobject; |
|
155 NPN_RetainObjectProcPtr retainobject; |
|
156 NPN_ReleaseObjectProcPtr releaseobject; |
|
157 NPN_InvokeProcPtr invoke; |
|
158 NPN_InvokeDefaultProcPtr invokeDefault; |
|
159 NPN_EvaluateProcPtr evaluate; |
|
160 NPN_GetPropertyProcPtr getproperty; |
|
161 NPN_SetPropertyProcPtr setproperty; |
|
162 NPN_RemovePropertyProcPtr removeproperty; |
|
163 NPN_HasPropertyProcPtr hasproperty; |
|
164 NPN_HasMethodProcPtr hasmethod; |
|
165 NPN_ReleaseVariantValueProcPtr releasevariantvalue; |
|
166 NPN_SetExceptionProcPtr setexception; |
|
167 NPN_PushPopupsEnabledStateProcPtr pushpopupsenabledstate; |
|
168 NPN_PopPopupsEnabledStateProcPtr poppopupsenabledstate; |
|
169 NPN_EnumerateProcPtr enumerate; |
|
170 NPN_PluginThreadAsyncCallProcPtr pluginthreadasynccall; |
|
171 NPN_ConstructProcPtr construct; |
|
172 NPN_GetValueForURLPtr getvalueforurl; |
|
173 NPN_SetValueForURLPtr setvalueforurl; |
|
174 NPN_GetAuthenticationInfoPtr getauthenticationinfo; |
|
175 NPN_ScheduleTimerPtr scheduletimer; |
|
176 NPN_UnscheduleTimerPtr unscheduletimer; |
|
177 NPN_PopUpContextMenuPtr popupcontextmenu; |
|
178 NPN_ConvertPointPtr convertpoint; |
|
179 NPN_HandleEventPtr handleevent; |
|
180 NPN_UnfocusInstancePtr unfocusinstance; |
|
181 NPN_URLRedirectResponsePtr urlredirectresponse; |
|
182 NPN_InitAsyncSurfacePtr initasyncsurface; |
|
183 NPN_FinalizeAsyncSurfacePtr finalizeasyncsurface; |
|
184 NPN_SetCurrentAsyncSurfacePtr setcurrentasyncsurface; |
|
185 } NPNetscapeFuncs; |
|
186 |
|
187 #ifdef XP_MACOSX |
|
188 /* |
|
189 * Mac OS X version(s) of NP_GetMIMEDescription(const char *) |
|
190 * These can be called to retreive MIME information from the plugin dynamically |
|
191 * |
|
192 * Note: For compatibility with Quicktime, BPSupportedMIMEtypes is another way |
|
193 * to get mime info from the plugin only on OSX and may not be supported |
|
194 * in furture version -- use NP_GetMIMEDescription instead |
|
195 */ |
|
196 enum |
|
197 { |
|
198 kBPSupportedMIMETypesStructVers_1 = 1 |
|
199 }; |
|
200 typedef struct _BPSupportedMIMETypes |
|
201 { |
|
202 SInt32 structVersion; /* struct version */ |
|
203 Handle typeStrings; /* STR# formated handle, allocated by plug-in */ |
|
204 Handle infoStrings; /* STR# formated handle, allocated by plug-in */ |
|
205 } BPSupportedMIMETypes; |
|
206 OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags); |
|
207 #define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription" |
|
208 typedef const char* (*NP_GetMIMEDescriptionProcPtr)(void); |
|
209 typedef OSErr (*BP_GetSupportedMIMETypesProcPtr)(BPSupportedMIMETypes*, UInt32); |
|
210 #endif |
|
211 |
|
212 #if defined(_WIN32) |
|
213 #define OSCALL WINAPI |
|
214 #else |
|
215 #define OSCALL |
|
216 #endif |
|
217 |
|
218 #if defined(XP_UNIX) |
|
219 /* GCC 3.3 and later support the visibility attribute. */ |
|
220 #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) |
|
221 #define NP_VISIBILITY_DEFAULT __attribute__((visibility("default"))) |
|
222 #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) |
|
223 #define NP_VISIBILITY_DEFAULT __global |
|
224 #else |
|
225 #define NP_VISIBILITY_DEFAULT |
|
226 #endif |
|
227 #define NP_EXPORT(__type) NP_VISIBILITY_DEFAULT __type |
|
228 #endif |
|
229 |
|
230 #if defined(_WIN32) |
|
231 #ifdef __cplusplus |
|
232 extern "C" { |
|
233 #endif |
|
234 /* plugin meta member functions */ |
|
235 typedef NPError (OSCALL *NP_GetEntryPointsFunc)(NPPluginFuncs*); |
|
236 NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs); |
|
237 typedef NPError (OSCALL *NP_InitializeFunc)(NPNetscapeFuncs*); |
|
238 NPError OSCALL NP_Initialize(NPNetscapeFuncs* bFuncs); |
|
239 typedef NPError (OSCALL *NP_ShutdownFunc)(void); |
|
240 NPError OSCALL NP_Shutdown(void); |
|
241 typedef const char* (*NP_GetMIMEDescriptionFunc)(void); |
|
242 const char* NP_GetMIMEDescription(void); |
|
243 #ifdef __cplusplus |
|
244 } |
|
245 #endif |
|
246 #endif |
|
247 |
|
248 #ifdef XP_UNIX |
|
249 #ifdef __cplusplus |
|
250 extern "C" { |
|
251 #endif |
|
252 typedef char* (*NP_GetPluginVersionFunc)(void); |
|
253 NP_EXPORT(char*) NP_GetPluginVersion(void); |
|
254 typedef const char* (*NP_GetMIMEDescriptionFunc)(void); |
|
255 NP_EXPORT(const char*) NP_GetMIMEDescription(void); |
|
256 #ifdef XP_MACOSX |
|
257 typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*); |
|
258 NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs); |
|
259 typedef NPError (*NP_GetEntryPointsFunc)(NPPluginFuncs*); |
|
260 NP_EXPORT(NPError) NP_GetEntryPoints(NPPluginFuncs* pFuncs); |
|
261 #else |
|
262 #ifdef MOZ_WIDGET_ANDROID |
|
263 typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv* pEnv); |
|
264 NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, JNIEnv* pEnv); |
|
265 #else |
|
266 typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*); |
|
267 NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs); |
|
268 #endif |
|
269 #endif |
|
270 typedef NPError (*NP_ShutdownFunc)(void); |
|
271 NP_EXPORT(NPError) NP_Shutdown(void); |
|
272 typedef NPError (*NP_GetValueFunc)(void *, NPPVariable, void *); |
|
273 NP_EXPORT(NPError) NP_GetValue(void *future, NPPVariable aVariable, void *aValue); |
|
274 #ifdef __cplusplus |
|
275 } |
|
276 #endif |
|
277 #endif |
|
278 |
|
279 #endif /* npfunctions_h_ */ |