• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 COMPUTER, 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 COMPUTER, 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 #if defined(ANDROID_PLUGINS)
32 #include "nativehelper/jni.h"
33 #endif
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #if defined(XP_WIN)
40 #define EXPORTED_CALLBACK(_type, _name) _type (__stdcall * _name)
41 #else
42 #define EXPORTED_CALLBACK(_type, _name) _type (* _name)
43 #endif
44 
45 typedef NPError (*NPN_GetURLNotifyProcPtr)(NPP instance, const char* URL, const char* window, void* notifyData);
46 typedef NPError (*NPN_PostURLNotifyProcPtr)(NPP instance, const char* URL, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData);
47 typedef NPError (*NPN_RequestReadProcPtr)(NPStream* stream, NPByteRange* rangeList);
48 typedef NPError (*NPN_NewStreamProcPtr)(NPP instance, NPMIMEType type, const char* window, NPStream** stream);
49 typedef int32 (*NPN_WriteProcPtr)(NPP instance, NPStream* stream, int32 len, void* buffer);
50 typedef NPError (*NPN_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason);
51 typedef void (*NPN_StatusProcPtr)(NPP instance, const char* message);
52 typedef const char*(*NPN_UserAgentProcPtr)(NPP instance);
53 typedef void* (*NPN_MemAllocProcPtr)(uint32 size);
54 typedef void (*NPN_MemFreeProcPtr)(void* ptr);
55 typedef uint32 (*NPN_MemFlushProcPtr)(uint32 size);
56 typedef void (*NPN_ReloadPluginsProcPtr)(NPBool reloadPages);
57 typedef NPError (*NPN_GetValueProcPtr)(NPP instance, NPNVariable variable, void *ret_value);
58 typedef NPError (*NPN_SetValueProcPtr)(NPP instance, NPPVariable variable, void *value);
59 typedef void (*NPN_InvalidateRectProcPtr)(NPP instance, NPRect *rect);
60 typedef void (*NPN_InvalidateRegionProcPtr)(NPP instance, NPRegion region);
61 typedef void (*NPN_ForceRedrawProcPtr)(NPP instance);
62 typedef NPError (*NPN_GetURLProcPtr)(NPP instance, const char* URL, const char* window);
63 typedef NPError (*NPN_PostURLProcPtr)(NPP instance, const char* URL, const char* window, uint32 len, const char* buf, NPBool file);
64 typedef void* (*NPN_GetJavaEnvProcPtr)(void);
65 typedef void* (*NPN_GetJavaPeerProcPtr)(NPP instance);
66 typedef void  (*NPN_PushPopupsEnabledStateProcPtr)(NPP instance, NPBool enabled);
67 typedef void  (*NPN_PopPopupsEnabledStateProcPtr)(NPP instance);
68 typedef void (*NPN_PluginThreadAsyncCallProcPtr)(NPP npp, void (*func)(void *), void *userData);
69 typedef uint32 (*NPN_ScheduleTimerProcPtr)(NPP npp, uint32 interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32 timerID));
70 typedef void (*NPN_UnscheduleTimerProcPtr)(NPP npp, uint32 timerID);
71 typedef NPError (*NPN_PopUpContextMenuProcPtr)(NPP instance, NPMenu* menu);
72 
73 typedef void (*NPN_ReleaseVariantValueProcPtr) (NPVariant *variant);
74 
75 typedef NPIdentifier (*NPN_GetStringIdentifierProcPtr) (const NPUTF8 *name);
76 typedef void (*NPN_GetStringIdentifiersProcPtr) (const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers);
77 typedef NPIdentifier (*NPN_GetIntIdentifierProcPtr) (int32_t intid);
78 typedef int32_t (*NPN_IntFromIdentifierProcPtr) (NPIdentifier identifier);
79 typedef bool (*NPN_IdentifierIsStringProcPtr) (NPIdentifier identifier);
80 typedef NPUTF8 *(*NPN_UTF8FromIdentifierProcPtr) (NPIdentifier identifier);
81 
82 typedef NPObject* (*NPN_CreateObjectProcPtr) (NPP, NPClass *aClass);
83 typedef NPObject* (*NPN_RetainObjectProcPtr) (NPObject *obj);
84 typedef void (*NPN_ReleaseObjectProcPtr) (NPObject *obj);
85 typedef bool (*NPN_InvokeProcPtr) (NPP npp, NPObject *obj, NPIdentifier methodName, const NPVariant *args, unsigned argCount, NPVariant *result);
86 typedef bool (*NPN_InvokeDefaultProcPtr) (NPP npp, NPObject *obj, const NPVariant *args, unsigned argCount, NPVariant *result);
87 typedef bool (*NPN_EvaluateProcPtr) (NPP npp, NPObject *obj, NPString *script, NPVariant *result);
88 typedef bool (*NPN_GetPropertyProcPtr) (NPP npp, NPObject *obj, NPIdentifier  propertyName, NPVariant *result);
89 typedef bool (*NPN_SetPropertyProcPtr) (NPP npp, NPObject *obj, NPIdentifier  propertyName, const NPVariant *value);
90 typedef bool (*NPN_HasPropertyProcPtr) (NPP, NPObject *npobj, NPIdentifier propertyName);
91 typedef bool (*NPN_HasMethodProcPtr) (NPP npp, NPObject *npobj, NPIdentifier methodName);
92 typedef bool (*NPN_RemovePropertyProcPtr) (NPP npp, NPObject *obj, NPIdentifier propertyName);
93 typedef void (*NPN_SetExceptionProcPtr) (NPObject *obj, const NPUTF8 *message);
94 typedef bool (*NPN_EnumerateProcPtr) (NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count);
95 typedef bool (*NPN_ConstructProcPtr)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
96 
97 typedef NPError (*NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
98 typedef NPError (*NPP_DestroyProcPtr)(NPP instance, NPSavedData** save);
99 typedef NPError (*NPP_SetWindowProcPtr)(NPP instance, NPWindow* window);
100 typedef NPError (*NPP_NewStreamProcPtr)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
101 typedef NPError (*NPP_DestroyStreamProcPtr)(NPP instance, NPStream* stream, NPReason reason);
102 typedef void (*NPP_StreamAsFileProcPtr)(NPP instance, NPStream* stream, const char* fname);
103 typedef int32 (*NPP_WriteReadyProcPtr)(NPP instance, NPStream* stream);
104 typedef int32 (*NPP_WriteProcPtr)(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer);
105 typedef void (*NPP_PrintProcPtr)(NPP instance, NPPrint* platformPrint);
106 typedef int16 (*NPP_HandleEventProcPtr)(NPP instance, void* event);
107 typedef void (*NPP_URLNotifyProcPtr)(NPP instance, const char* URL, NPReason reason, void* notifyData);
108 typedef NPError (*NPP_GetValueProcPtr)(NPP instance, NPPVariable variable, void *ret_value);
109 typedef NPError (*NPP_SetValueProcPtr)(NPP instance, NPNVariable variable, void *value);
110 
111 typedef void *(*NPP_GetJavaClassProcPtr)(void);
112 typedef void* JRIGlobalRef; //not using this right now
113 
114 typedef struct _NPNetscapeFuncs {
115     uint16 size;
116     uint16 version;
117 
118     NPN_GetURLProcPtr geturl;
119     NPN_PostURLProcPtr posturl;
120     NPN_RequestReadProcPtr requestread;
121     NPN_NewStreamProcPtr newstream;
122     NPN_WriteProcPtr write;
123     NPN_DestroyStreamProcPtr destroystream;
124     NPN_StatusProcPtr status;
125     NPN_UserAgentProcPtr uagent;
126     NPN_MemAllocProcPtr memalloc;
127     NPN_MemFreeProcPtr memfree;
128     NPN_MemFlushProcPtr memflush;
129     NPN_ReloadPluginsProcPtr reloadplugins;
130     NPN_GetJavaEnvProcPtr getJavaEnv;
131     NPN_GetJavaPeerProcPtr getJavaPeer;
132     NPN_GetURLNotifyProcPtr geturlnotify;
133     NPN_PostURLNotifyProcPtr posturlnotify;
134     NPN_GetValueProcPtr getvalue;
135     NPN_SetValueProcPtr setvalue;
136     NPN_InvalidateRectProcPtr invalidaterect;
137     NPN_InvalidateRegionProcPtr invalidateregion;
138     NPN_ForceRedrawProcPtr forceredraw;
139 
140     NPN_GetStringIdentifierProcPtr getstringidentifier;
141     NPN_GetStringIdentifiersProcPtr getstringidentifiers;
142     NPN_GetIntIdentifierProcPtr getintidentifier;
143     NPN_IdentifierIsStringProcPtr identifierisstring;
144     NPN_UTF8FromIdentifierProcPtr utf8fromidentifier;
145     NPN_IntFromIdentifierProcPtr intfromidentifier;
146     NPN_CreateObjectProcPtr createobject;
147     NPN_RetainObjectProcPtr retainobject;
148     NPN_ReleaseObjectProcPtr releaseobject;
149     NPN_InvokeProcPtr invoke;
150     NPN_InvokeDefaultProcPtr invokeDefault;
151     NPN_EvaluateProcPtr evaluate;
152     NPN_GetPropertyProcPtr getproperty;
153     NPN_SetPropertyProcPtr setproperty;
154     NPN_RemovePropertyProcPtr removeproperty;
155     NPN_HasPropertyProcPtr hasproperty;
156     NPN_HasMethodProcPtr hasmethod;
157     NPN_ReleaseVariantValueProcPtr releasevariantvalue;
158     NPN_SetExceptionProcPtr setexception;
159     NPN_PushPopupsEnabledStateProcPtr pushpopupsenabledstate;
160     NPN_PopPopupsEnabledStateProcPtr poppopupsenabledstate;
161     NPN_EnumerateProcPtr enumerate;
162     NPN_PluginThreadAsyncCallProcPtr pluginthreadasynccall;
163     NPN_ConstructProcPtr construct;
164     NPN_ScheduleTimerProcPtr scheduletimer;
165     NPN_UnscheduleTimerProcPtr unscheduletimer;
166     NPN_PopUpContextMenuProcPtr popupcontextmenu;
167 } NPNetscapeFuncs;
168 
169 typedef struct _NPPluginFuncs {
170     uint16 size;
171     uint16 version;
172     NPP_NewProcPtr newp;
173     NPP_DestroyProcPtr destroy;
174     NPP_SetWindowProcPtr setwindow;
175     NPP_NewStreamProcPtr newstream;
176     NPP_DestroyStreamProcPtr destroystream;
177     NPP_StreamAsFileProcPtr asfile;
178     NPP_WriteReadyProcPtr writeready;
179     NPP_WriteProcPtr write;
180     NPP_PrintProcPtr print;
181     NPP_HandleEventProcPtr event;
182     NPP_URLNotifyProcPtr urlnotify;
183     JRIGlobalRef javaClass;
184     NPP_GetValueProcPtr getvalue;
185     NPP_SetValueProcPtr setvalue;
186 } NPPluginFuncs;
187 
188 typedef EXPORTED_CALLBACK(NPError, NP_GetEntryPointsFuncPtr)(NPPluginFuncs*);
189 typedef EXPORTED_CALLBACK(void, NPP_ShutdownProcPtr)(void);
190 
191 #if defined(XP_MACOSX)
192 typedef void (*BP_CreatePluginMIMETypesPreferencesFuncPtr)(void);
193 typedef NPError (*MainFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownProcPtr*);
194 #endif
195 
196 #if defined(XP_UNIX)
197 typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*);
198 typedef EXPORTED_CALLBACK(char*, NP_GetMIMEDescriptionFuncPtr)(void);
199 #elif defined(ANDROID_PLUGINS)
200 typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv *java_environment, jobject application_context);
201 typedef EXPORTED_CALLBACK(char*, NP_GetMIMEDescriptionFuncPtr)(void);
202 #else
203 typedef EXPORTED_CALLBACK(NPError, NP_InitializeFuncPtr)(NPNetscapeFuncs*);
204 #endif
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif
211