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
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/
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
15 * The Original Code is mozilla.org code.
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.
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.
36 * ***** END LICENSE BLOCK ***** */
45 extern Logger
* logger
;
46 extern NPNetscapeFuncs NPNFuncs
;
48 void NPN_Version(int* plugin_major
, int* plugin_minor
, int* netscape_major
, int* netscape_minor
)
51 logger
->logCall(action_npn_version
, (DWORD
)plugin_major
, (DWORD
)plugin_minor
, (DWORD
)netscape_major
, (DWORD
)netscape_minor
);
53 *plugin_major
= NP_VERSION_MAJOR
;
54 *plugin_minor
= NP_VERSION_MINOR
;
55 *netscape_major
= HIBYTE(NPNFuncs
.version
);
56 *netscape_minor
= LOBYTE(NPNFuncs
.version
);
59 logger
->logReturn(action_npn_version
);
62 NPError
NPN_GetURLNotify(NPP instance
, const char *url
, const char *target
, void* notifyData
)
64 int navMinorVers
= NPNFuncs
.version
& 0xFF;
66 NPError rv
= NPERR_NO_ERROR
;
69 logger
->logCall(action_npn_get_url_notify
, (DWORD
)instance
, (DWORD
)url
, (DWORD
)target
, (DWORD
)notifyData
);
71 if( navMinorVers
>= NPVERS_HAS_NOTIFICATION
)
72 rv
= NPNFuncs
.geturlnotify(instance
, url
, target
, notifyData
);
74 rv
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
77 logger
->logReturn(action_npn_get_url_notify
, rv
);
82 NPError
NPN_GetURL(NPP instance
, const char *url
, const char *target
)
85 logger
->logCall(action_npn_get_url
, (DWORD
)instance
, (DWORD
)url
, (DWORD
)target
);
87 NPError rv
= NPNFuncs
.geturl(instance
, url
, target
);
90 logger
->logReturn(action_npn_get_url
, rv
);
95 NPError
NPN_PostURLNotify(NPP instance
, const char* url
, const char* window
, uint32 len
, const char* buf
, NPBool file
, void* notifyData
)
97 int navMinorVers
= NPNFuncs
.version
& 0xFF;
99 NPError rv
= NPERR_NO_ERROR
;
102 logger
->logCall(action_npn_post_url_notify
, (DWORD
)instance
, (DWORD
)url
, (DWORD
)window
, (DWORD
)len
, (DWORD
)buf
, (DWORD
)file
, (DWORD
)notifyData
);
104 if( navMinorVers
>= NPVERS_HAS_NOTIFICATION
)
105 rv
= NPNFuncs
.posturlnotify(instance
, url
, window
, len
, buf
, file
, notifyData
);
107 rv
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
110 logger
->logReturn(action_npn_post_url_notify
, rv
);
115 NPError
NPN_PostURL(NPP instance
, const char* url
, const char* window
, uint32 len
, const char* buf
, NPBool file
)
118 logger
->logCall(action_npn_post_url
, (DWORD
)instance
, (DWORD
)url
, (DWORD
)window
, (DWORD
)len
, (DWORD
)buf
, (DWORD
)file
);
120 NPError rv
= NPNFuncs
.posturl(instance
, url
, window
, len
, buf
, file
);
123 logger
->logReturn(action_npn_post_url
, rv
);
128 NPError
NPN_RequestRead(NPStream
* stream
, NPByteRange
* rangeList
)
131 logger
->logCall(action_npn_request_read
, (DWORD
)stream
, (DWORD
)rangeList
);
133 NPError rv
= NPNFuncs
.requestread(stream
, rangeList
);
136 logger
->logReturn(action_npn_request_read
, rv
);
141 NPError
NPN_NewStream(NPP instance
, NPMIMEType type
, const char* target
, NPStream
** stream
)
143 int navMinorVersion
= NPNFuncs
.version
& 0xFF;
145 NPError rv
= NPERR_NO_ERROR
;
148 logger
->logCall(action_npn_new_stream
, (DWORD
)instance
, (DWORD
)type
, (DWORD
)target
, (DWORD
)stream
);
150 if( navMinorVersion
>= NPVERS_HAS_STREAMOUTPUT
)
151 rv
= NPNFuncs
.newstream(instance
, type
, target
, stream
);
153 rv
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
156 logger
->logReturn(action_npn_new_stream
, rv
);
161 int32
NPN_Write(NPP instance
, NPStream
*stream
, int32 len
, void *buffer
)
163 int navMinorVersion
= NPNFuncs
.version
& 0xFF;
168 logger
->logCall(action_npn_write
, (DWORD
)instance
, (DWORD
)stream
, (DWORD
)len
, (DWORD
)buffer
);
170 if( navMinorVersion
>= NPVERS_HAS_STREAMOUTPUT
)
171 rv
= NPNFuncs
.write(instance
, stream
, len
, buffer
);
176 logger
->logReturn(action_npn_write
, rv
);
181 NPError
NPN_DestroyStream(NPP instance
, NPStream
* stream
, NPError reason
)
183 int navMinorVersion
= NPNFuncs
.version
& 0xFF;
185 NPError rv
= NPERR_NO_ERROR
;
188 logger
->logCall(action_npn_destroy_stream
, (DWORD
)instance
, (DWORD
)stream
, (DWORD
)reason
);
190 if( navMinorVersion
>= NPVERS_HAS_STREAMOUTPUT
)
191 rv
= NPNFuncs
.destroystream(instance
, stream
, reason
);
193 rv
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
196 logger
->logReturn(action_npn_destroy_stream
, rv
);
201 void NPN_Status(NPP instance
, const char *message
)
204 logger
->logCall(action_npn_status
, (DWORD
)instance
, (DWORD
)message
);
206 NPNFuncs
.status(instance
, message
);
209 const char* NPN_UserAgent(NPP instance
)
211 static const char * rv
= NULL
;
214 logger
->logCall(action_npn_user_agent
, (DWORD
)instance
);
216 rv
= NPNFuncs
.uagent(instance
);
219 logger
->logReturn(action_npn_user_agent
);
224 void* NPN_MemAlloc(uint32 size
)
229 logger
->logCall(action_npn_mem_alloc
, (DWORD
)size
);
231 rv
= NPNFuncs
.memalloc(size
);
234 logger
->logReturn(action_npn_mem_alloc
);
239 void NPN_MemFree(void* ptr
)
242 logger
->logCall(action_npn_mem_free
, (DWORD
)ptr
);
244 NPNFuncs
.memfree(ptr
);
247 uint32
NPN_MemFlush(uint32 size
)
250 logger
->logCall(action_npn_mem_flush
, (DWORD
)size
);
252 uint32 rv
= NPNFuncs
.memflush(size
);
255 logger
->logReturn(action_npn_mem_flush
, rv
);
260 void NPN_ReloadPlugins(NPBool reloadPages
)
263 logger
->logCall(action_npn_reload_plugins
, (DWORD
)reloadPages
);
265 NPNFuncs
.reloadplugins(reloadPages
);
269 JRIEnv
* NPN_GetJavaEnv(void)
274 logger
->logCall(action_npn_get_java_env
);
276 rv
= NPNFuncs
.getJavaEnv();
279 logger
->logReturn(action_npn_get_java_env
);
284 jref
NPN_GetJavaPeer(NPP instance
)
289 logger
->logCall(action_npn_get_java_peer
, (DWORD
)instance
);
291 rv
= NPNFuncs
.getJavaPeer(instance
);
294 logger
->logReturn(action_npn_get_java_peer
);
299 void* NPN_GetJavaEnv(void)
304 logger
->logCall(action_npn_get_java_env
);
309 logger
->logReturn(action_npn_get_java_env
);
314 void* NPN_GetJavaPeer(NPP instance
)
319 logger
->logCall(action_npn_get_java_peer
, (DWORD
)instance
);
324 logger
->logReturn(action_npn_get_java_peer
);
330 NPError
NPN_GetValue(NPP instance
, NPNVariable variable
, void *value
)
332 NPError rv
= NPERR_NO_ERROR
;
334 rv
= NPNFuncs
.getvalue(instance
, variable
, value
);
337 logger
->logCall(action_npn_get_value
, (DWORD
)instance
, (DWORD
)variable
, (DWORD
)value
);
340 logger
->logReturn(action_npn_get_value
, rv
);
345 NPError
NPN_SetValue(NPP instance
, NPPVariable variable
, void *value
)
347 NPError rv
= NPERR_NO_ERROR
;
350 logger
->logCall(action_npn_set_value
, (DWORD
)instance
, (DWORD
)variable
, (DWORD
)value
);
352 rv
= NPNFuncs
.setvalue(instance
, variable
, value
);
355 logger
->logReturn(action_npn_set_value
, rv
);
360 void NPN_InvalidateRect(NPP instance
, NPRect
*invalidRect
)
363 logger
->logCall(action_npn_invalidate_rect
, (DWORD
)instance
, (DWORD
)invalidRect
);
365 NPNFuncs
.invalidaterect(instance
, invalidRect
);
368 void NPN_InvalidateRegion(NPP instance
, NPRegion invalidRegion
)
371 logger
->logCall(action_npn_invalidate_region
, (DWORD
)instance
, (DWORD
)invalidRegion
);
373 NPNFuncs
.invalidateregion(instance
, invalidRegion
);
376 void NPN_ForceRedraw(NPP instance
)
379 logger
->logCall(action_npn_force_redraw
, (DWORD
)instance
);
381 NPNFuncs
.forceredraw(instance
);
384 NPIdentifier
NPN_GetStringIdentifier(const NPUTF8
*name
)
387 logger
->logCall(action_npn_get_string_identifier
, (DWORD
)name
);
389 NPIdentifier rv
= NPNFuncs
.getstringidentifier(name
);
392 logger
->logReturn(action_npn_get_string_identifier
, (DWORD
)(rv
));
397 bool NPN_Enumerate(NPP id
, NPObject
* obj
, NPIdentifier
** identifier
, uint32_t*val
)
400 logger
->logCall(action_npn_enumerate
);
402 bool rv
= NPNFuncs
.enumerate(id
, obj
, identifier
, val
);
405 logger
->logReturn(action_npn_enumerate
, rv
);
410 bool NPN_PopPopupsEnabledState(NPP id
)
413 logger
->logCall(action_npn_pop_popups_enabled_state
, (DWORD
)id
);
415 bool rv
= NPNFuncs
.poppopupsenabledstate(id
);
418 logger
->logReturn(action_npn_pop_popups_enabled_state
, rv
);
423 bool NPN_PushPopupsEnabledState(NPP id
, NPBool enabled
)
426 logger
->logCall(action_npn_push_popups_enabled_state
, (DWORD
)id
);
428 bool rv
= NPNFuncs
.pushpopupsenabledstate(id
, enabled
);
431 logger
->logReturn(action_npn_push_popups_enabled_state
, rv
);
436 void NPN_SetException(NPObject
*obj
, const NPUTF8
*message
)
439 logger
->logCall(action_npn_set_exception
, (DWORD
)message
);
441 NPNFuncs
.setexception(obj
,message
);
444 void NPN_ReleaseVariantValue(NPVariant
*variant
)
447 logger
->logCall(action_npn_release_variant_value
, (DWORD
)variant
);
449 NPNFuncs
.releasevariantvalue(variant
);
452 bool NPN_HasMethod(NPP id
, NPObject
* object
, NPIdentifier identifier
)
455 logger
->logCall(action_npn_has_method
, (DWORD
)identifier
);
457 bool rv
= NPNFuncs
.hasmethod(id
, object
, identifier
);
460 logger
->logReturn(action_npn_has_method
, rv
);
465 bool NPN_HasProperty(NPP id
, NPObject
* object
, NPIdentifier identifier
)
468 logger
->logCall(action_npn_has_property
, (DWORD
)identifier
);
470 bool rv
= NPNFuncs
.hasmethod(id
, object
, identifier
);
473 logger
->logReturn(action_npn_has_property
, rv
);
478 bool NPN_RemoveProperty(NPP id
, NPObject
* object
, NPIdentifier identifier
)
481 logger
->logCall(action_npn_remove_property
, (DWORD
)identifier
);
483 bool rv
= NPNFuncs
.hasmethod(id
, object
, identifier
);
488 bool NPN_SetProperty(NPP id
, NPObject
* obj
, NPIdentifier identifier
, const NPVariant
*variant
)
491 logger
->logCall(action_npn_set_property
, (DWORD
)identifier
);
493 bool rv
= NPNFuncs
.setproperty(id
, obj
, identifier
, variant
);
498 bool NPN_GetProperty(NPP id
, NPObject
* obj
, NPIdentifier identifier
, NPVariant
*variant
)
501 logger
->logCall(action_npn_get_property
, (DWORD
)identifier
);
503 bool rv
= NPNFuncs
.getproperty(id
, obj
, identifier
, variant
);
508 bool NPN_Evaluate(NPP id
, NPObject
* obj
, NPString
* str
, NPVariant
* variant
)
511 logger
->logCall(action_npn_evaluate
, (DWORD
)str
);
513 bool rv
= NPNFuncs
.evaluate(id
, obj
, str
, variant
);
516 logger
->logReturn(action_npn_evaluate
, rv
);
521 bool NPN_InvokeDefault(NPP id
, NPObject
* obj
, const NPVariant
* args
, uint32_t count
, NPVariant
*result
)
524 logger
->logCall(action_npn_invoke_default
, (DWORD
)obj
);
526 bool rv
= NPNFuncs
.invokeDefault(id
, obj
, args
, count
, result
);
529 logger
->logReturn(action_npn_invoke_default
, rv
);
534 bool NPN_Invoke(NPP id
, NPObject
* obj
, NPIdentifier identifier
, const NPVariant
*args
, uint32_t count
, NPVariant
*result
)
537 logger
->logCall(action_npn_invoke
, (DWORD
)obj
);
539 bool rv
= NPNFuncs
.invoke(id
, obj
, identifier
, args
, count
, result
);
542 logger
->logReturn(action_npn_invoke
, rv
);
547 void NPN_ReleaseObject(NPObject
*obj
)
550 logger
->logCall(action_npn_release_object
, (DWORD
)obj
);
552 NPNFuncs
.releaseobject(obj
);
555 NPObject
*NPN_RetainObject(NPObject
* obj
)
558 logger
->logCall(action_npn_retain_object
, (DWORD
)obj
);
560 NPObject
*rv
= NPNFuncs
.retainobject(obj
);
565 NPObject
* NPN_CreateObject(NPP id
, NPClass
*cl
)
568 logger
->logCall(action_npn_create_object
, (DWORD
)cl
);
570 NPObject
*rv
= NPNFuncs
.createobject(id
, cl
);
573 logger
->logReturn(action_npn_create_object
, (DWORD
)rv
);
578 int32_t NPN_IntFromIdentifier(NPIdentifier identifier
)
581 logger
->logCall(action_npn_int_from_identifier
, (DWORD
)identifier
);
583 int32_t rv
= NPNFuncs
.intfromidentifier(identifier
);
586 logger
->logReturn(action_npn_int_from_identifier
, rv
);
591 NPUTF8
*NPN_UTF8FromIdentifier(NPIdentifier identifier
)
594 logger
->logCall(action_npn_utf8_from_identifier
, (DWORD
)identifier
);
596 NPUTF8
*rv
= NPNFuncs
.utf8fromidentifier(identifier
);
599 logger
->logReturn(action_npn_utf8_from_identifier
, 1234567890);
604 bool NPN_IdentifierIsString(NPIdentifier identifier
)
607 logger
->logCall(action_npn_identifier_is_string
, (DWORD
)identifier
);
609 bool rv
= NPNFuncs
.identifierisstring(identifier
);
612 logger
->logReturn(action_npn_identifier_is_string
, rv
);
617 NPIdentifier
NPN_GetIntIdentifier(int32_t value
)
620 logger
->logCall(action_npn_get_int_identifer
, (DWORD
)value
);
622 NPIdentifier rv
= NPNFuncs
.getintidentifier(value
);
625 logger
->logReturn(action_npn_get_int_identifer
, (DWORD
)rv
);
630 void NPN_GetStringIdentifiers(const NPUTF8
**names
, int32_t count
, NPIdentifier
*identifiers
)
633 logger
->logCall(action_npn_get_string_identifiers
);
635 NPNFuncs
.getstringidentifiers(names
, count
, identifiers
);