FreeWRL/FreeX3D  3.0.0
npn_gate.cpp
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: NPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Netscape Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/NPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is mozilla.org code.
16  *
17  * The Initial Developer of the Original Code is
18  * Netscape Communications Corporation.
19  * Portions created by the Initial Developer are Copyright (C) 1998
20  * the Initial Developer. All Rights Reserved.
21  *
22  * Contributor(s):
23  *
24  * Alternatively, the contents of this file may be used under the terms of
25  * either the GNU General Public License Version 2 or later (the "GPL"), or
26  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27  * in which case the provisions of the GPL or the LGPL are applicable instead
28  * of those above. If you wish to allow use of your version of this file only
29  * under the terms of either the GPL or the LGPL, and not to allow others to
30  * use your version of this file under the terms of the NPL, indicate your
31  * decision by deleting the provisions above and replace them with the notice
32  * and other provisions required by the GPL or the LGPL. If you do not delete
33  * the provisions above, a recipient may use your version of this file under
34  * the terms of any one of the NPL, the GPL or the LGPL.
35  *
36  * ***** END LICENSE BLOCK ***** */
37 
39 //
40 // Implementation of Netscape entry points (NPN_*)
41 //
42 #include "npapi.h"
43 #include "npfunctions.h"
44 
45 #ifndef HIBYTE
46 #define HIBYTE(x) ((((uint32_t)(x)) & 0xff00) >> 8)
47 #endif
48 
49 #ifndef LOBYTE
50 #define LOBYTE(W) ((W) & 0xFF)
51 #endif
52 
53 extern NPNetscapeFuncs NPNFuncs;
54 
55 void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
56 {
57  *plugin_major = NP_VERSION_MAJOR;
58  *plugin_minor = NP_VERSION_MINOR;
59  *netscape_major = HIBYTE(NPNFuncs.version);
60  *netscape_minor = LOBYTE(NPNFuncs.version);
61 }
62 
63 NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
64 {
65  int navMinorVers = NPNFuncs.version & 0xFF;
66  NPError rv = NPERR_NO_ERROR;
67 
68  if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
69  rv = NPNFuncs.geturlnotify(instance, url, target, notifyData);
70  else
71  rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
72 
73  return rv;
74 }
75 
76 NPError NPN_GetURL(NPP instance, const char *url, const char *target)
77 {
78  NPError rv = NPNFuncs.geturl(instance, url, target);
79  return rv;
80 }
81 
82 NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData)
83 {
84  int navMinorVers = NPNFuncs.version & 0xFF;
85  NPError rv = NPERR_NO_ERROR;
86 
87  if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
88  rv = NPNFuncs.posturlnotify(instance, url, window, len, buf, file, notifyData);
89  else
90  rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
91 
92  return rv;
93 }
94 
95 NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file)
96 {
97  NPError rv = NPNFuncs.posturl(instance, url, window, len, buf, file);
98  return rv;
99 }
100 
101 NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
102 {
103  NPError rv = NPNFuncs.requestread(stream, rangeList);
104  return rv;
105 }
106 
107 NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
108 {
109  int navMinorVersion = NPNFuncs.version & 0xFF;
110 
111  NPError rv = NPERR_NO_ERROR;
112 
113  if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
114  rv = NPNFuncs.newstream(instance, type, target, stream);
115  else
116  rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
117 
118  return rv;
119 }
120 
121 int32_t NPN_Write(NPP instance, NPStream *stream, int32_t len, void *buffer)
122 {
123  int navMinorVersion = NPNFuncs.version & 0xFF;
124  int32_t rv = 0;
125 
126  if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
127  rv = NPNFuncs.write(instance, stream, len, buffer);
128  else
129  rv = -1;
130 
131  return rv;
132 }
133 
134 NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
135 {
136  int navMinorVersion = NPNFuncs.version & 0xFF;
137  NPError rv = NPERR_NO_ERROR;
138 
139  if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
140  rv = NPNFuncs.destroystream(instance, stream, reason);
141  else
142  rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
143 
144  return rv;
145 }
146 
147 void NPN_Status(NPP instance, const char *message)
148 {
149  NPNFuncs.status(instance, message);
150 }
151 
152 const char* NPN_UserAgent(NPP instance)
153 {
154  const char * rv = NULL;
155  rv = NPNFuncs.uagent(instance);
156  return rv;
157 }
158 
159 void* NPN_MemAlloc(uint32_t size)
160 {
161  void * rv = NULL;
162  rv = NPNFuncs.memalloc(size);
163  return rv;
164 }
165 
166 void NPN_MemFree(void* ptr)
167 {
168  NPNFuncs.memfree(ptr);
169 }
170 
171 uint32_t NPN_MemFlush(uint32_t size)
172 {
173  uint32_t rv = NPNFuncs.memflush(size);
174  return rv;
175 }
176 
177 void NPN_ReloadPlugins(NPBool reloadPages)
178 {
179  NPNFuncs.reloadplugins(reloadPages);
180 }
181 
182 //JRIEnv* NPN_GetJavaEnv(void)
183 //{
184 // JRIEnv * rv = NULL;
185 // rv = NPNFuncs.getJavaEnv();
186 // return rv;
187 //}
188 //
189 //jref NPN_GetJavaPeer(NPP instance)
190 //{
191 // jref rv;
192 // rv = NPNFuncs.getJavaPeer(instance);
193 // return rv;
194 //}
195 
196 NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
197 {
198  NPError rv = NPNFuncs.getvalue(instance, variable, value);
199  return rv;
200 }
201 
202 NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
203 {
204  NPError rv = NPNFuncs.setvalue(instance, variable, value);
205  return rv;
206 }
207 
208 void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
209 {
210  NPNFuncs.invalidaterect(instance, invalidRect);
211 }
212 
213 void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
214 {
215  NPNFuncs.invalidateregion(instance, invalidRegion);
216 }
217 
218 void NPN_ForceRedraw(NPP instance)
219 {
220  NPNFuncs.forceredraw(instance);
221 }
222 
223 NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
224 {
225  return NPNFuncs.getstringidentifier(name);
226 }
227 
228 void NPN_GetStringIdentifiers(const NPUTF8 **names, uint32_t nameCount,
229  NPIdentifier *identifiers)
230 {
231  return NPNFuncs.getstringidentifiers(names, nameCount, identifiers);
232 }
233 
234 NPIdentifier NPN_GetStringIdentifier(int32_t intid)
235 {
236  return NPNFuncs.getintidentifier(intid);
237 }
238 
239 bool NPN_IdentifierIsString(NPIdentifier identifier)
240 {
241  return NPNFuncs.identifierisstring(identifier);
242 }
243 
244 NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
245 {
246  return NPNFuncs.utf8fromidentifier(identifier);
247 }
248 
249 int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
250 {
251  return NPNFuncs.intfromidentifier(identifier);
252 }
253 
254 NPObject *NPN_CreateObject(NPP npp, NPClass *aClass)
255 {
256  return NPNFuncs.createobject(npp, aClass);
257 }
258 
259 NPObject *NPN_RetainObject(NPObject *obj)
260 {
261  return NPNFuncs.retainobject(obj);
262 }
263 
264 void NPN_ReleaseObject(NPObject *obj)
265 {
266  return NPNFuncs.releaseobject(obj);
267 }
268 
269 bool NPN_Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
270  const NPVariant *args, uint32_t argCount, NPVariant *result)
271 {
272  return NPNFuncs.invoke(npp, obj, methodName, args, argCount, result);
273 }
274 
275 bool NPN_InvokeDefault(NPP npp, NPObject* obj, const NPVariant *args,
276  uint32_t argCount, NPVariant *result)
277 {
278  return NPNFuncs.invokeDefault(npp, obj, args, argCount, result);
279 }
280 
281 bool NPN_Evaluate(NPP npp, NPObject* obj, NPString *script,
282  NPVariant *result)
283 {
284  return NPNFuncs.evaluate(npp, obj, script, result);
285 }
286 
287 bool NPN_GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
288  NPVariant *result)
289 {
290  return NPNFuncs.getproperty(npp, obj, propertyName, result);
291 }
292 
293 bool NPN_SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
294  const NPVariant *value)
295 {
296  return NPNFuncs.setproperty(npp, obj, propertyName, value);
297 }
298 
299 bool NPN_RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
300 {
301  return NPNFuncs.removeproperty(npp, obj, propertyName);
302 }
303 
304 bool NPN_Enumerate(NPP npp, NPObject *obj, NPIdentifier **identifier,
305  uint32_t *count)
306 {
307  return NPNFuncs.enumerate(npp, obj, identifier, count);
308 }
309 
310 bool NPN_Construct(NPP npp, NPObject *obj, const NPVariant *args,
311  uint32_t argCount, NPVariant *result)
312 {
313  return NPNFuncs.construct(npp, obj, args, argCount, result);
314 }
315 
316 bool NPN_HasProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
317 {
318  return NPNFuncs.hasproperty(npp, obj, propertyName);
319 }
320 
321 bool NPN_HasMethod(NPP npp, NPObject* obj, NPIdentifier methodName)
322 {
323  return NPNFuncs.hasmethod(npp, obj, methodName);
324 }
325 
326 void NPN_ReleaseVariantValue(NPVariant *variant)
327 {
328  NPNFuncs.releasevariantvalue(variant);
329 }
330 
331 void NPN_SetException(NPObject* obj, const NPUTF8 *message)
332 {
333  NPNFuncs.setexception(obj, message);
334 }
Definition: npapi.h:189
Definition: npapi.h:148