• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
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 MPL, 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 MPL, the GPL or the LGPL.
35  *
36  * ***** END LICENSE BLOCK ***** */
37 
38 #include "xp.h"
39 
40 #include "npapi.h"
41 #include "npupp.h"
42 
43 #include "logger.h"
44 
45 extern Logger * logger;
46 extern NPNetscapeFuncs NPNFuncs;
47 
NPN_Version(int * plugin_major,int * plugin_minor,int * netscape_major,int * netscape_minor)48 void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
49 {
50   if(logger)
51     logger->logCall(action_npn_version, (DWORD)plugin_major, (DWORD)plugin_minor, (DWORD)netscape_major, (DWORD)netscape_minor);
52 
53   *plugin_major   = NP_VERSION_MAJOR;
54   *plugin_minor   = NP_VERSION_MINOR;
55   *netscape_major = HIBYTE(NPNFuncs.version);
56   *netscape_minor = LOBYTE(NPNFuncs.version);
57 
58   if(logger)
59     logger->logReturn(action_npn_version);
60 }
61 
NPN_GetURLNotify(NPP instance,const char * url,const char * target,void * notifyData)62 NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
63 {
64 	int navMinorVers = NPNFuncs.version & 0xFF;
65 
66   NPError rv = NPERR_NO_ERROR;
67 
68   if(logger)
69     logger->logCall(action_npn_get_url_notify, (DWORD)instance, (DWORD)url, (DWORD)target, (DWORD)notifyData);
70 
71   if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
72 		rv = NPNFuncs.geturlnotify(instance, url, target, notifyData);
73 	else
74 		rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
75 
76   if(logger)
77     logger->logReturn(action_npn_get_url_notify, rv);
78 
79   return rv;
80 }
81 
NPN_GetURL(NPP instance,const char * url,const char * target)82 NPError NPN_GetURL(NPP instance, const char *url, const char *target)
83 {
84   if(logger)
85     logger->logCall(action_npn_get_url, (DWORD)instance, (DWORD)url, (DWORD)target);
86 
87   NPError rv = NPNFuncs.geturl(instance, url, target);
88 
89   if(logger)
90     logger->logReturn(action_npn_get_url, rv);
91 
92   return rv;
93 }
94 
NPN_PostURLNotify(NPP instance,const char * url,const char * window,uint32 len,const char * buf,NPBool file,void * notifyData)95 NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
96 {
97 	int navMinorVers = NPNFuncs.version & 0xFF;
98 
99   NPError rv = NPERR_NO_ERROR;
100 
101   if(logger)
102     logger->logCall(action_npn_post_url_notify, (DWORD)instance, (DWORD)url, (DWORD)window, (DWORD)len, (DWORD)buf, (DWORD)file, (DWORD)notifyData);
103 
104 	if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
105 		rv = NPNFuncs.posturlnotify(instance, url, window, len, buf, file, notifyData);
106 	else
107 		rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
108 
109   if(logger)
110     logger->logReturn(action_npn_post_url_notify, rv);
111 
112   return rv;
113 }
114 
NPN_PostURL(NPP instance,const char * url,const char * window,uint32 len,const char * buf,NPBool file)115 NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
116 {
117   if(logger)
118     logger->logCall(action_npn_post_url, (DWORD)instance, (DWORD)url, (DWORD)window, (DWORD)len, (DWORD)buf, (DWORD)file);
119 
120   NPError rv = NPNFuncs.posturl(instance, url, window, len, buf, file);
121 
122   if(logger)
123     logger->logReturn(action_npn_post_url, rv);
124 
125   return rv;
126 }
127 
NPN_RequestRead(NPStream * stream,NPByteRange * rangeList)128 NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
129 {
130   if(logger)
131     logger->logCall(action_npn_request_read, (DWORD)stream, (DWORD)rangeList);
132 
133   NPError rv = NPNFuncs.requestread(stream, rangeList);
134 
135   if(logger)
136     logger->logReturn(action_npn_request_read, rv);
137 
138   return rv;
139 }
140 
NPN_NewStream(NPP instance,NPMIMEType type,const char * target,NPStream ** stream)141 NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
142 {
143 	int navMinorVersion = NPNFuncs.version & 0xFF;
144 
145   NPError rv = NPERR_NO_ERROR;
146 
147   if(logger)
148     logger->logCall(action_npn_new_stream, (DWORD)instance, (DWORD)type, (DWORD)target, (DWORD)stream);
149 
150 	if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
151 		rv = NPNFuncs.newstream(instance, type, target, stream);
152 	else
153 		rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
154 
155   if(logger)
156     logger->logReturn(action_npn_new_stream, rv);
157 
158   return rv;
159 }
160 
NPN_Write(NPP instance,NPStream * stream,int32 len,void * buffer)161 int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
162 {
163 	int navMinorVersion = NPNFuncs.version & 0xFF;
164 
165   int32 rv = 0;
166 
167   if(logger)
168     logger->logCall(action_npn_write, (DWORD)instance, (DWORD)stream, (DWORD)len, (DWORD)buffer);
169 
170   if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
171 		rv = NPNFuncs.write(instance, stream, len, buffer);
172 	else
173 		rv = -1;
174 
175   if(logger)
176     logger->logReturn(action_npn_write, rv);
177 
178   return rv;
179 }
180 
NPN_DestroyStream(NPP instance,NPStream * stream,NPError reason)181 NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
182 {
183 	int navMinorVersion = NPNFuncs.version & 0xFF;
184 
185   NPError rv = NPERR_NO_ERROR;
186 
187   if(logger)
188     logger->logCall(action_npn_destroy_stream, (DWORD)instance, (DWORD)stream, (DWORD)reason);
189 
190   if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
191 		rv = NPNFuncs.destroystream(instance, stream, reason);
192 	else
193 		rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
194 
195   if(logger)
196     logger->logReturn(action_npn_destroy_stream, rv);
197 
198   return rv;
199 }
200 
NPN_Status(NPP instance,const char * message)201 void NPN_Status(NPP instance, const char *message)
202 {
203   if(logger)
204     logger->logCall(action_npn_status, (DWORD)instance, (DWORD)message);
205 
206   NPNFuncs.status(instance, message);
207 }
208 
NPN_UserAgent(NPP instance)209 const char* NPN_UserAgent(NPP instance)
210 {
211   static const char * rv = NULL;
212 
213   if(logger)
214     logger->logCall(action_npn_user_agent, (DWORD)instance);
215 
216   rv = NPNFuncs.uagent(instance);
217 
218   if(logger)
219     logger->logReturn(action_npn_user_agent);
220 
221   return rv;
222 }
223 
NPN_MemAlloc(uint32 size)224 void* NPN_MemAlloc(uint32 size)
225 {
226   void * rv = NULL;
227 
228   if(logger)
229     logger->logCall(action_npn_mem_alloc, (DWORD)size);
230 
231   rv = NPNFuncs.memalloc(size);
232 
233   if(logger)
234     logger->logReturn(action_npn_mem_alloc);
235 
236   return rv;
237 }
238 
NPN_MemFree(void * ptr)239 void NPN_MemFree(void* ptr)
240 {
241   if(logger)
242     logger->logCall(action_npn_mem_free, (DWORD)ptr);
243 
244   NPNFuncs.memfree(ptr);
245 }
246 
NPN_MemFlush(uint32 size)247 uint32 NPN_MemFlush(uint32 size)
248 {
249   if(logger)
250     logger->logCall(action_npn_mem_flush, (DWORD)size);
251 
252   uint32 rv = NPNFuncs.memflush(size);
253 
254   if(logger)
255     logger->logReturn(action_npn_mem_flush, rv);
256 
257   return rv;
258 }
259 
NPN_ReloadPlugins(NPBool reloadPages)260 void NPN_ReloadPlugins(NPBool reloadPages)
261 {
262   if(logger)
263     logger->logCall(action_npn_reload_plugins, (DWORD)reloadPages);
264 
265   NPNFuncs.reloadplugins(reloadPages);
266 }
267 
268 #ifdef OJI
NPN_GetJavaEnv(void)269 JRIEnv* NPN_GetJavaEnv(void)
270 {
271   JRIEnv * rv = NULL;
272 
273   if(logger)
274     logger->logCall(action_npn_get_java_env);
275 
276 	rv = NPNFuncs.getJavaEnv();
277 
278   if(logger)
279     logger->logReturn(action_npn_get_java_env);
280 
281   return rv;
282 }
283 
NPN_GetJavaPeer(NPP instance)284 jref NPN_GetJavaPeer(NPP instance)
285 {
286   jref rv;
287 
288   if(logger)
289     logger->logCall(action_npn_get_java_peer, (DWORD)instance);
290 
291 	rv = NPNFuncs.getJavaPeer(instance);
292 
293   if(logger)
294     logger->logReturn(action_npn_get_java_peer);
295 
296   return rv;
297 }
298 #else
NPN_GetJavaEnv(void)299 void* NPN_GetJavaEnv(void)
300 {
301   JRIEnv * rv = NULL;
302 
303   if(logger)
304     logger->logCall(action_npn_get_java_env);
305 
306 	rv = NULL;
307 
308   if(logger)
309     logger->logReturn(action_npn_get_java_env);
310 
311   return rv;
312 }
313 
NPN_GetJavaPeer(NPP instance)314 void* NPN_GetJavaPeer(NPP instance)
315 {
316   jref rv;
317 
318   if(logger)
319     logger->logCall(action_npn_get_java_peer, (DWORD)instance);
320 
321 	rv = NULL;
322 
323   if(logger)
324     logger->logReturn(action_npn_get_java_peer);
325 
326   return rv;
327 }
328 #endif
329 
NPN_GetValue(NPP instance,NPNVariable variable,void * value)330 NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
331 {
332   NPError rv = NPERR_NO_ERROR;
333 
334   rv = NPNFuncs.getvalue(instance, variable, value);
335 
336   if(logger)
337     logger->logCall(action_npn_get_value, (DWORD)instance, (DWORD)variable, (DWORD)value);
338 
339   if(logger)
340     logger->logReturn(action_npn_get_value, rv);
341 
342   return rv;
343 }
344 
NPN_SetValue(NPP instance,NPPVariable variable,void * value)345 NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
346 {
347   NPError rv = NPERR_NO_ERROR;
348 
349   if(logger)
350     logger->logCall(action_npn_set_value, (DWORD)instance, (DWORD)variable, (DWORD)value);
351 
352   rv = NPNFuncs.setvalue(instance, variable, value);
353 
354   if(logger)
355     logger->logReturn(action_npn_set_value, rv);
356 
357   return rv;
358 }
359 
NPN_InvalidateRect(NPP instance,NPRect * invalidRect)360 void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
361 {
362   if(logger)
363     logger->logCall(action_npn_invalidate_rect, (DWORD)instance, (DWORD)invalidRect);
364 
365   NPNFuncs.invalidaterect(instance, invalidRect);
366 }
367 
NPN_InvalidateRegion(NPP instance,NPRegion invalidRegion)368 void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
369 {
370   if(logger)
371     logger->logCall(action_npn_invalidate_region, (DWORD)instance, (DWORD)invalidRegion);
372 
373   NPNFuncs.invalidateregion(instance, invalidRegion);
374 }
375 
NPN_ForceRedraw(NPP instance)376 void NPN_ForceRedraw(NPP instance)
377 {
378   if(logger)
379     logger->logCall(action_npn_force_redraw, (DWORD)instance);
380 
381   NPNFuncs.forceredraw(instance);
382 }
383 
NPN_GetStringIdentifier(const NPUTF8 * name)384 NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
385 {
386   if(logger)
387     logger->logCall(action_npn_get_string_identifier, (DWORD)name);
388 
389   NPIdentifier rv = NPNFuncs.getstringidentifier(name);
390 
391   if(logger)
392     logger->logReturn(action_npn_get_string_identifier, (DWORD)(rv));
393 
394   return rv;
395 }
396 
NPN_Enumerate(NPP id,NPObject * obj,NPIdentifier ** identifier,uint32_t * val)397 bool NPN_Enumerate(NPP id, NPObject* obj, NPIdentifier** identifier, uint32_t*val)
398 {
399   if(logger)
400     logger->logCall(action_npn_enumerate);
401 
402   bool rv = NPNFuncs.enumerate(id, obj, identifier, val);
403 
404   if(logger)
405     logger->logReturn(action_npn_enumerate, rv);
406 
407   return rv;
408 }
409 
NPN_PopPopupsEnabledState(NPP id)410 bool NPN_PopPopupsEnabledState(NPP id)
411 {
412   if(logger)
413     logger->logCall(action_npn_pop_popups_enabled_state, (DWORD)id);
414 
415   bool rv = NPNFuncs.poppopupsenabledstate(id);
416 
417   if(logger)
418     logger->logReturn(action_npn_pop_popups_enabled_state, rv);
419 
420   return rv;
421 }
422 
NPN_PushPopupsEnabledState(NPP id,NPBool enabled)423 bool NPN_PushPopupsEnabledState(NPP id, NPBool enabled)
424 {
425   if(logger)
426     logger->logCall(action_npn_push_popups_enabled_state, (DWORD)id);
427 
428   bool rv = NPNFuncs.pushpopupsenabledstate(id, enabled);
429 
430   if(logger)
431     logger->logReturn(action_npn_push_popups_enabled_state, rv);
432 
433   return rv;
434 }
435 
NPN_SetException(NPObject * obj,const NPUTF8 * message)436 void NPN_SetException(NPObject*obj, const NPUTF8*message)
437 {
438   if(logger)
439     logger->logCall(action_npn_set_exception, (DWORD)message);
440 
441   NPNFuncs.setexception(obj,message);
442 }
443 
NPN_ReleaseVariantValue(NPVariant * variant)444 void NPN_ReleaseVariantValue(NPVariant*variant)
445 {
446   if(logger)
447     logger->logCall(action_npn_release_variant_value, (DWORD)variant);
448 
449   NPNFuncs.releasevariantvalue(variant);
450 }
451 
NPN_HasMethod(NPP id,NPObject * object,NPIdentifier identifier)452 bool NPN_HasMethod(NPP id, NPObject* object, NPIdentifier identifier)
453 {
454   if(logger)
455     logger->logCall(action_npn_has_method, (DWORD)identifier);
456 
457   bool rv = NPNFuncs.hasmethod(id, object, identifier);
458 
459   if(logger)
460     logger->logReturn(action_npn_has_method, rv);
461 
462   return rv;
463 }
464 
NPN_HasProperty(NPP id,NPObject * object,NPIdentifier identifier)465 bool NPN_HasProperty(NPP id, NPObject* object, NPIdentifier identifier)
466 {
467   if(logger)
468     logger->logCall(action_npn_has_property, (DWORD)identifier);
469 
470   bool rv = NPNFuncs.hasmethod(id, object, identifier);
471 
472   if(logger)
473     logger->logReturn(action_npn_has_property, rv);
474 
475   return rv;
476 }
477 
NPN_RemoveProperty(NPP id,NPObject * object,NPIdentifier identifier)478 bool NPN_RemoveProperty(NPP id, NPObject* object, NPIdentifier identifier)
479 {
480   if(logger)
481     logger->logCall(action_npn_remove_property, (DWORD)identifier);
482 
483   bool rv = NPNFuncs.hasmethod(id, object, identifier);
484 
485   return rv;
486 }
487 
NPN_SetProperty(NPP id,NPObject * obj,NPIdentifier identifier,const NPVariant * variant)488 bool NPN_SetProperty(NPP id, NPObject* obj, NPIdentifier identifier, const NPVariant *variant)
489 {
490   if(logger)
491     logger->logCall(action_npn_set_property, (DWORD)identifier);
492 
493   bool rv = NPNFuncs.setproperty(id, obj, identifier, variant);
494 
495   return rv;
496 }
497 
NPN_GetProperty(NPP id,NPObject * obj,NPIdentifier identifier,NPVariant * variant)498 bool NPN_GetProperty(NPP id, NPObject* obj, NPIdentifier identifier, NPVariant *variant)
499 {
500   if(logger)
501     logger->logCall(action_npn_get_property, (DWORD)identifier);
502 
503   bool rv = NPNFuncs.getproperty(id, obj, identifier, variant);
504 
505   return rv;
506 }
507 
NPN_Evaluate(NPP id,NPObject * obj,NPString * str,NPVariant * variant)508 bool NPN_Evaluate(NPP id, NPObject* obj, NPString* str, NPVariant* variant)
509 {
510   if(logger)
511     logger->logCall(action_npn_evaluate, (DWORD)str);
512 
513   bool rv = NPNFuncs.evaluate(id, obj, str, variant);
514 
515   if(logger)
516     logger->logReturn(action_npn_evaluate, rv);
517 
518   return rv;
519 }
520 
NPN_InvokeDefault(NPP id,NPObject * obj,const NPVariant * args,uint32_t count,NPVariant * result)521 bool NPN_InvokeDefault(NPP id, NPObject* obj, const NPVariant* args, uint32_t count, NPVariant*result)
522 {
523   if(logger)
524     logger->logCall(action_npn_invoke_default, (DWORD)obj);
525 
526   bool rv = NPNFuncs.invokeDefault(id, obj, args, count, result);
527 
528   if(logger)
529     logger->logReturn(action_npn_invoke_default, rv);
530 
531   return rv;
532 }
533 
NPN_Invoke(NPP id,NPObject * obj,NPIdentifier identifier,const NPVariant * args,uint32_t count,NPVariant * result)534 bool NPN_Invoke(NPP id, NPObject* obj, NPIdentifier identifier, const NPVariant *args, uint32_t count, NPVariant*result)
535 {
536   if(logger)
537     logger->logCall(action_npn_invoke, (DWORD)obj);
538 
539   bool rv = NPNFuncs.invoke(id, obj, identifier, args, count, result);
540 
541   if(logger)
542     logger->logReturn(action_npn_invoke, rv);
543 
544   return rv;
545 }
546 
NPN_ReleaseObject(NPObject * obj)547 void NPN_ReleaseObject(NPObject *obj)
548 {
549   if(logger)
550     logger->logCall(action_npn_release_object, (DWORD)obj);
551 
552   NPNFuncs.releaseobject(obj);
553 }
554 
NPN_RetainObject(NPObject * obj)555 NPObject *NPN_RetainObject(NPObject* obj)
556 {
557   if(logger)
558     logger->logCall(action_npn_retain_object, (DWORD)obj);
559 
560   NPObject *rv = NPNFuncs.retainobject(obj);
561 
562   return rv;
563 }
564 
NPN_CreateObject(NPP id,NPClass * cl)565 NPObject* NPN_CreateObject(NPP id, NPClass *cl)
566 {
567   if(logger)
568     logger->logCall(action_npn_create_object, (DWORD)cl);
569 
570   NPObject *rv = NPNFuncs.createobject(id, cl);
571 
572   if(logger)
573     logger->logReturn(action_npn_create_object, (DWORD)rv);
574 
575   return rv;
576 }
577 
NPN_IntFromIdentifier(NPIdentifier identifier)578 int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
579 {
580   if(logger)
581     logger->logCall(action_npn_int_from_identifier, (DWORD)identifier);
582 
583   int32_t rv = NPNFuncs.intfromidentifier(identifier);
584 
585   if(logger)
586     logger->logReturn(action_npn_int_from_identifier, rv);
587 
588   return rv;
589 }
590 
NPN_UTF8FromIdentifier(NPIdentifier identifier)591 NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
592 {
593   if(logger)
594     logger->logCall(action_npn_utf8_from_identifier, (DWORD)identifier);
595 
596   NPUTF8 *rv = NPNFuncs.utf8fromidentifier(identifier);
597 
598   if(logger)
599     logger->logReturn(action_npn_utf8_from_identifier, 1234567890);
600 
601   return rv;
602 }
603 
NPN_IdentifierIsString(NPIdentifier identifier)604 bool NPN_IdentifierIsString(NPIdentifier identifier)
605 {
606   if(logger)
607     logger->logCall(action_npn_identifier_is_string, (DWORD)identifier);
608 
609   bool rv = NPNFuncs.identifierisstring(identifier);
610 
611   if(logger)
612     logger->logReturn(action_npn_identifier_is_string, rv);
613 
614   return rv;
615 }
616 
NPN_GetIntIdentifier(int32_t value)617 NPIdentifier NPN_GetIntIdentifier(int32_t value)
618 {
619   if(logger)
620     logger->logCall(action_npn_get_int_identifer, (DWORD)value);
621 
622   NPIdentifier rv = NPNFuncs.getintidentifier(value);
623 
624   if(logger)
625     logger->logReturn(action_npn_get_int_identifer, (DWORD)rv);
626 
627   return rv;
628 }
629 
NPN_GetStringIdentifiers(const NPUTF8 ** names,int32_t count,NPIdentifier * identifiers)630 void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t count, NPIdentifier *identifiers)
631 {
632   if(logger)
633     logger->logCall(action_npn_get_string_identifiers);
634 
635   NPNFuncs.getstringidentifiers(names, count, identifiers);
636 }