2
* Copyright © 1998 Netscape Communications Corporation.
3
* Copyright © 2008 Christian Persch
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public
16
* License along with this library; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
* Boston, MA 02111-1307, USA.
20
* ===========================================================================
21
* Derived from MPL/LGPL/GPL tri-licensed code
22
* [mozilla/odules/plugin/samples/4x-scriptable/npn_gate.cpp];
23
* used here under LGPL 2+, as permitted by the relicensing clause.
25
* The Original Code is mozilla.org code.
27
* The Initial Developer of the Original Code is
28
* Netscape Communications Corporation.
29
* Portions created by the Initial Developer are Copyright © 1998
30
* the Initial Developer. All Rights Reserved.
41
#define HIBYTE(x) ((((uint32_t)(x)) & 0xff00) >> 8)
45
#define LOBYTE(W) ((W) & 0xFF)
48
extern NPNetscapeFuncs NPNFuncs;
50
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
52
*plugin_major = NP_VERSION_MAJOR;
53
*plugin_minor = NP_VERSION_MINOR;
54
*netscape_major = HIBYTE(NPNFuncs.version);
55
*netscape_minor = LOBYTE(NPNFuncs.version);
58
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
60
return NPNFuncs.geturlnotify(instance, url, target, notifyData);
63
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
65
return NPNFuncs.geturl(instance, url, target);
68
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData)
70
return NPNFuncs.posturlnotify(instance, url, window, len, buf, file, notifyData);
73
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file)
75
return NPNFuncs.posturl(instance, url, window, len, buf, file);
78
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
80
return NPNFuncs.requestread(stream, rangeList);
83
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
85
return NPNFuncs.newstream(instance, type, target, stream);
88
int32_t NPN_Write(NPP instance, NPStream *stream, int32_t len, void *buffer)
90
return NPNFuncs.write(instance, stream, len, buffer);
93
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
95
return NPNFuncs.destroystream(instance, stream, reason);
98
void NPN_Status(NPP instance, const char *message)
100
NPNFuncs.status(instance, message);
103
const char* NPN_UserAgent(NPP instance)
105
return NPNFuncs.uagent(instance);
108
void* NPN_MemAlloc(uint32 size)
110
return NPNFuncs.memalloc(size);
113
void NPN_MemFree(void* ptr)
115
/* Make it null-safe */
119
NPNFuncs.memfree(ptr);
122
uint32_t NPN_MemFlush(uint32_t size)
124
return NPNFuncs.memflush(size);
127
void NPN_ReloadPlugins(NPBool reloadPages)
129
NPNFuncs.reloadplugins(reloadPages);
132
JRIEnv* NPN_GetJavaEnv(void)
134
return NPNFuncs.getJavaEnv();
137
jref NPN_GetJavaPeer(NPP instance)
139
return NPNFuncs.getJavaPeer(instance);
142
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
144
return NPNFuncs.getvalue(instance, variable, value);
147
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
149
return NPNFuncs.setvalue(instance, variable, value);
152
void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
154
NPNFuncs.invalidaterect(instance, invalidRect);
157
void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
159
NPNFuncs.invalidateregion(instance, invalidRegion);
162
void NPN_ForceRedraw(NPP instance)
164
NPNFuncs.forceredraw(instance);
167
NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
169
return NPNFuncs.getstringidentifier(name);
172
void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
173
NPIdentifier *identifiers)
175
return NPNFuncs.getstringidentifiers(names, nameCount, identifiers);
178
NPIdentifier NPN_GetStringIdentifier(int32_t intid)
180
return NPNFuncs.getintidentifier(intid);
183
bool NPN_IdentifierIsString(NPIdentifier identifier)
185
return NPNFuncs.identifierisstring(identifier);
188
NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
190
return NPNFuncs.utf8fromidentifier(identifier);
193
int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
195
return NPNFuncs.intfromidentifier(identifier);
198
NPObject *NPN_CreateObject(NPP npp, NPClass *aClass)
200
return NPNFuncs.createobject(npp, aClass);
203
NPObject *NPN_RetainObject(NPObject *obj)
205
return NPNFuncs.retainobject(obj);
208
void NPN_ReleaseObject(NPObject *obj)
210
return NPNFuncs.releaseobject(obj);
213
bool NPN_Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
214
const NPVariant *args, uint32_t argCount, NPVariant *result)
216
return NPNFuncs.invoke(npp, obj, methodName, args, argCount, result);
219
bool NPN_InvokeDefault(NPP npp, NPObject* obj, const NPVariant *args,
220
uint32_t argCount, NPVariant *result)
222
return NPNFuncs.invokeDefault(npp, obj, args, argCount, result);
225
bool NPN_Evaluate(NPP npp, NPObject* obj, NPString *script,
228
return NPNFuncs.evaluate(npp, obj, script, result);
231
bool NPN_GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
234
return NPNFuncs.getproperty(npp, obj, propertyName, result);
237
bool NPN_SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
238
const NPVariant *value)
240
return NPNFuncs.setproperty(npp, obj, propertyName, value);
243
bool NPN_RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
245
return NPNFuncs.removeproperty(npp, obj, propertyName);
248
bool NPN_Enumerate(NPP npp, NPObject *obj, NPIdentifier **identifier,
251
#if defined(NPVERS_HAS_NPOBJECT_ENUM) && (NP_VERSION_MINOR >= NPVERS_HAS_NPOBJECT_ENUM)
252
if ((NPNFuncs.version & 0xFF) >= NPVERS_HAS_NPOBJECT_ENUM)
253
return NPNFuncs.enumerate(npp, obj, identifier, count);
258
bool NPN_Construct(NPP npp, NPObject *obj, const NPVariant *args,
259
uint32_t argCount, NPVariant *result)
261
#if defined(NPVERS_HAS_NPOBJECT_ENUM) && (NP_VERSION_MINOR >= NPVERS_HAS_NPOBJECT_ENUM)
262
if ((NPNFuncs.version & 0xFF) >= NPVERS_HAS_NPOBJECT_ENUM)
263
return NPNFuncs.construct(npp, obj, args, argCount, result);
268
bool NPN_HasProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
270
return NPNFuncs.hasproperty(npp, obj, propertyName);
273
bool NPN_HasMethod(NPP npp, NPObject* obj, NPIdentifier methodName)
275
return NPNFuncs.hasmethod(npp, obj, methodName);
278
void NPN_ReleaseVariantValue(NPVariant *variant)
280
NPNFuncs.releasevariantvalue(variant);
283
void NPN_SetException(NPObject* obj, const NPUTF8 *message)
285
NPNFuncs.setexception(obj, message);
288
void* NPN_MemDup (const void* aMem, uint32 aLen)
293
void* dup = NPN_MemAlloc (aLen);
297
return memcpy (dup, aMem, aLen);
300
char* NPN_StrDup (const char* aString)
302
return (char*) NPN_MemDup (aString, strlen (aString) + 1);