1/*
2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25#ifndef NPFUNCTIONS_H
26#define NPFUNCTIONS_H
27
28
29#include "npruntime.h"
30#include "npapi.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#if defined(XP_WIN)
37#define EXPORTED_CALLBACK(_type, _name) _type (__stdcall * _name)
38#else
39#define EXPORTED_CALLBACK(_type, _name) _type (* _name)
40#endif
41
42typedef NPError (*NPN_GetURLNotifyProcPtr)(NPP instance, const char* URL, const char* window, void* notifyData);
43typedef NPError (*NPN_PostURLNotifyProcPtr)(NPP instance, const char* URL, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData);
44typedef NPError (*NPN_RequestReadProcPtr)(NPStream* stream, NPByteRange* rangeList);
45typedef NPError (*NPN_NewStreamProcPtr)(NPP instance, NPMIMEType type, const char* window, NPStream** stream);
46typedef int32_t (*NPN_WriteProcPtr)(NPP instance, NPStream* stream, int32_t len, void* buffer);
47typedef NPError (*NPN_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason);
48typedef void (*NPN_StatusProcPtr)(NPP instance, const char* message);
49typedef const char*(*NPN_UserAgentProcPtr)(NPP instance);
50typedef void* (*NPN_MemAllocProcPtr)(uint32_t size);
51typedef void (*NPN_MemFreeProcPtr)(void* ptr);
52typedef uint32_t (*NPN_MemFlushProcPtr)(uint32_t size);
53typedef void (*NPN_ReloadPluginsProcPtr)(NPBool reloadPages);
54typedef NPError (*NPN_GetValueProcPtr)(NPP instance, NPNVariable variable, void *ret_value);
55typedef NPError (*NPN_SetValueProcPtr)(NPP instance, NPPVariable variable, void *value);
56typedef void (*NPN_InvalidateRectProcPtr)(NPP instance, NPRect *rect);
57typedef void (*NPN_InvalidateRegionProcPtr)(NPP instance, NPRegion region);
58typedef void (*NPN_ForceRedrawProcPtr)(NPP instance);
59typedef NPError (*NPN_GetURLProcPtr)(NPP instance, const char* URL, const char* window);
60typedef NPError (*NPN_PostURLProcPtr)(NPP instance, const char* URL, const char* window, uint32_t len, const char* buf, NPBool file);
61typedef void* (*NPN_GetJavaEnvProcPtr)(void);
62typedef void* (*NPN_GetJavaPeerProcPtr)(NPP instance);
63typedef void (*NPN_PushPopupsEnabledStateProcPtr)(NPP instance, NPBool enabled);
64typedef void (*NPN_PopPopupsEnabledStateProcPtr)(NPP instance);
65typedef void (*NPN_PluginThreadAsyncCallProcPtr)(NPP npp, void (*func)(void *), void *userData);
66typedef NPError (*NPN_GetValueForURLProcPtr)(NPP npp, NPNURLVariable variable, const char* url, char** value, uint32_t* len);
67typedef NPError (*NPN_SetValueForURLProcPtr)(NPP npp, NPNURLVariable variable, const char* url, const char* value, uint32_t len);
68typedef NPError (*NPN_GetAuthenticationInfoProcPtr)(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);
69
70typedef uint32_t (*NPN_ScheduleTimerProcPtr)(NPP npp, uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID));
71typedef void (*NPN_UnscheduleTimerProcPtr)(NPP npp, uint32_t timerID);
72typedef NPError (*NPN_PopUpContextMenuProcPtr)(NPP instance, NPMenu* menu);
73typedef NPBool (*NPN_ConvertPointProcPtr)(NPP npp, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace);
74typedef NPBool (*NPN_HandleEventPtr)(NPP instance, void *event, NPBool handled);
75typedef NPBool (*NPN_UnfocusInstancePtr)(NPP instance, NPFocusDirection direction);
76typedef void (*NPN_URLRedirectResponsePtr)(NPP instance, void* notifyData, NPBool allow);
77
78typedef void (*NPN_ReleaseVariantValueProcPtr) (NPVariant *variant);
79
80typedef NPIdentifier (*NPN_GetStringIdentifierProcPtr) (const NPUTF8 *name);
81typedef void (*NPN_GetStringIdentifiersProcPtr) (const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers);
82typedef NPIdentifier (*NPN_GetIntIdentifierProcPtr) (int32_t intid);
83typedef int32_t (*NPN_IntFromIdentifierProcPtr) (NPIdentifier identifier);
84typedef bool (*NPN_IdentifierIsStringProcPtr) (NPIdentifier identifier);
85typedef NPUTF8 *(*NPN_UTF8FromIdentifierProcPtr) (NPIdentifier identifier);
86
87typedef NPObject* (*NPN_CreateObjectProcPtr) (NPP, NPClass *aClass);
88typedef NPObject* (*NPN_RetainObjectProcPtr) (NPObject *obj);
89typedef void (*NPN_ReleaseObjectProcPtr) (NPObject *obj);
90typedef bool (*NPN_InvokeProcPtr) (NPP npp, NPObject *obj, NPIdentifier methodName, const NPVariant *args, unsigned argCount, NPVariant *result);
91typedef bool (*NPN_InvokeDefaultProcPtr) (NPP npp, NPObject *obj, const NPVariant *args, unsigned argCount, NPVariant *result);
92typedef bool (*NPN_EvaluateProcPtr) (NPP npp, NPObject *obj, NPString *script, NPVariant *result);
93typedef bool (*NPN_GetPropertyProcPtr) (NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result);
94typedef bool (*NPN_SetPropertyProcPtr) (NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value);
95typedef bool (*NPN_HasPropertyProcPtr) (NPP, NPObject *npobj, NPIdentifier propertyName);
96typedef bool (*NPN_HasMethodProcPtr) (NPP npp, NPObject *npobj, NPIdentifier methodName);
97typedef bool (*NPN_RemovePropertyProcPtr) (NPP npp, NPObject *obj, NPIdentifier propertyName);
98typedef void (*NPN_SetExceptionProcPtr) (NPObject *obj, const NPUTF8 *message);
99typedef bool (*NPN_EnumerateProcPtr) (NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count);
100typedef bool (*NPN_ConstructProcPtr)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
101
102typedef NPError (*NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved);
103typedef NPError (*NPP_DestroyProcPtr)(NPP instance, NPSavedData** save);
104typedef NPError (*NPP_SetWindowProcPtr)(NPP instance, NPWindow* window);
105typedef NPError (*NPP_NewStreamProcPtr)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype);
106typedef NPError (*NPP_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason);
107typedef void (*NPP_StreamAsFileProcPtr)(NPP instance, NPStream* stream, const char* fname);
108typedef int32_t (*NPP_WriteReadyProcPtr)(NPP instance, NPStream* stream);
109typedef int32_t (*NPP_WriteProcPtr)(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer);
110typedef void (*NPP_PrintProcPtr)(NPP instance, NPPrint* platformPrint);
111typedef int16_t (*NPP_HandleEventProcPtr)(NPP instance, void* event);
112typedef void (*NPP_URLNotifyProcPtr)(NPP instance, const char* URL, NPReason reason, void* notifyData);
113typedef NPError (*NPP_GetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value);
114typedef NPError (*NPP_SetValueProcPtr)(NPP instance, NPNVariable variable, void *value);
115typedef NPBool (*NPP_GotFocusPtr)(NPP instance, NPFocusDirection direction);
116typedef void (*NPP_LostFocusPtr)(NPP instance);
117typedef void (*NPP_URLRedirectNotifyPtr)(NPP instance, const char* url, int32_t status, void* notifyData);
118typedef NPError (*NPP_ClearSiteDataPtr)(const char* site, uint64_t flags, uint64_t maxAge);
119typedef char** (*NPP_GetSitesWithDataPtr)(void);
120
121typedef void *(*NPP_GetJavaClassProcPtr)(void);
122typedef void* JRIGlobalRef; //not using this right now
123
124typedef struct _NPNetscapeFuncs {
125 uint16_t size;
126 uint16_t version;
127
128 NPN_GetURLProcPtr geturl;
129 NPN_PostURLProcPtr posturl;
130 NPN_RequestReadProcPtr requestread;
131 NPN_NewStreamProcPtr newstream;
132 NPN_WriteProcPtr write;
133 NPN_DestroyStreamProcPtr destroystream;
134 NPN_StatusProcPtr status;
135 NPN_UserAgentProcPtr uagent;
136 NPN_MemAllocProcPtr memalloc;
137 NPN_MemFreeProcPtr memfree;
138 NPN_MemFlushProcPtr memflush;
139 NPN_ReloadPluginsProcPtr reloadplugins;
140 NPN_GetJavaEnvProcPtr getJavaEnv;
141 NPN_GetJavaPeerProcPtr getJavaPeer;
142 NPN_GetURLNotifyProcPtr geturlnotify;
143 NPN_PostURLNotifyProcPtr posturlnotify;
144 NPN_GetValueProcPtr getvalue;
145 NPN_SetValueProcPtr setvalue;
146 NPN_InvalidateRectProcPtr invalidaterect;
147 NPN_InvalidateRegionProcPtr invalidateregion;
148 NPN_ForceRedrawProcPtr forceredraw;
149
150 NPN_GetStringIdentifierProcPtr getstringidentifier;
151 NPN_GetStringIdentifiersProcPtr getstringidentifiers;
152 NPN_GetIntIdentifierProcPtr getintidentifier;
153 NPN_IdentifierIsStringProcPtr identifierisstring;
154 NPN_UTF8FromIdentifierProcPtr utf8fromidentifier;
155 NPN_IntFromIdentifierProcPtr intfromidentifier;
156 NPN_CreateObjectProcPtr createobject;
157 NPN_RetainObjectProcPtr retainobject;
158 NPN_ReleaseObjectProcPtr releaseobject;
159 NPN_InvokeProcPtr invoke;
160 NPN_InvokeDefaultProcPtr invokeDefault;
161 NPN_EvaluateProcPtr evaluate;
162 NPN_GetPropertyProcPtr getproperty;
163 NPN_SetPropertyProcPtr setproperty;
164 NPN_RemovePropertyProcPtr removeproperty;
165 NPN_HasPropertyProcPtr hasproperty;
166 NPN_HasMethodProcPtr hasmethod;
167 NPN_ReleaseVariantValueProcPtr releasevariantvalue;
168 NPN_SetExceptionProcPtr setexception;
169 NPN_PushPopupsEnabledStateProcPtr pushpopupsenabledstate;
170 NPN_PopPopupsEnabledStateProcPtr poppopupsenabledstate;
171 NPN_EnumerateProcPtr enumerate;
172 NPN_PluginThreadAsyncCallProcPtr pluginthreadasynccall;
173 NPN_ConstructProcPtr construct;
174 NPN_GetValueForURLProcPtr getvalueforurl;
175 NPN_SetValueForURLProcPtr setvalueforurl;
176 NPN_GetAuthenticationInfoProcPtr getauthenticationinfo;
177 NPN_ScheduleTimerProcPtr scheduletimer;
178 NPN_UnscheduleTimerProcPtr unscheduletimer;
179 NPN_PopUpContextMenuProcPtr popupcontextmenu;
180 NPN_ConvertPointProcPtr convertpoint;
181 NPN_HandleEventPtr handleevent;
182 NPN_UnfocusInstancePtr unfocusinstance;
183 NPN_URLRedirectResponsePtr urlredirectresponse;
184} NPNetscapeFuncs;
185
186typedef struct _NPPluginFuncs {
187 uint16_t size;
188 uint16_t version;
189 NPP_NewProcPtr newp;
190 NPP_DestroyProcPtr destroy;
191 NPP_SetWindowProcPtr setwindow;
192 NPP_NewStreamProcPtr newstream;
193 NPP_DestroyStreamProcPtr destroystream;
194 NPP_StreamAsFileProcPtr asfile;
195 NPP_WriteReadyProcPtr writeready;
196 NPP_WriteProcPtr write;
197 NPP_PrintProcPtr print;
198 NPP_HandleEventProcPtr event;
199 NPP_URLNotifyProcPtr urlnotify;
200 JRIGlobalRef javaClass;
201 NPP_GetValueProcPtr getvalue;
202 NPP_SetValueProcPtr setvalue;
203 NPP_GotFocusPtr gotfocus;
204 NPP_LostFocusPtr lostfocus;
205 NPP_URLRedirectNotifyPtr urlredirectnotify;
206 NPP_ClearSiteDataPtr clearsitedata;
207 NPP_GetSitesWithDataPtr getsiteswithdata;
208} NPPluginFuncs;
209
210typedef EXPORTED_CALLBACK(NPError, NP_GetEntryPointsFuncPtr)(NPPluginFuncs*);
211typedef EXPORTED_CALLBACK(void, NPP_ShutdownProcPtr)(void);
212
213#if defined(XP_MACOSX)
214typedef void (*BP_CreatePluginMIMETypesPreferencesFuncPtr)(void);
215typedef NPError (*MainFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownProcPtr*);
216#endif
217
218#if defined(XP_UNIX)
219typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*);
220typedef EXPORTED_CALLBACK(const char*, NP_GetMIMEDescriptionFuncPtr)(void);
221#else
222typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*);
223#endif
224
225#ifdef __cplusplus
226}
227#endif
228
229#endif
230