1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * Mozilla/Firefox plugin for VLC
4 * Copyright (C) 2009, Jean-Paul Saman <jpsaman@videolan.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * The Original Code is mozilla.org code.
22 * The Initial Developer of the Original Code is
23 * Netscape Communications Corporation.
24 * Portions created by the Initial Developer are Copyright (C) 1998
25 * the Initial Developer. All Rights Reserved.
28 * Stephen Mak <smak@sun.com>
35 * Netscape Client Plugin API
36 * - Wrapper function to interface with the Netscape Navigator
38 * dp Suresh <dp@netscape.com>
40 *----------------------------------------------------------------------
42 * YOU WILL NOT NEED TO EDIT THIS FILE.
43 *----------------------------------------------------------------------
51 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
54 #include "npfunctions.h"
57 #include "../vlcshell.h"
60 * Define PLUGIN_TRACE to have the wrapper functions print
61 * messages to stderr whenever they are called.
66 #define PLUGINDEBUGSTR(msg) fprintf(stderr, "%s\n", msg)
68 #define PLUGINDEBUGSTR(msg)
71 /***********************************************************************
75 ***********************************************************************/
77 static NPNetscapeFuncs gNetscapeFuncs
; /* Netscape Function table */
79 /***********************************************************************
81 * Wrapper functions : plugin calling Netscape Navigator
83 * These functions let the plugin developer just call the APIs
84 * as documented and defined in npapi.h, without needing to know
85 * about the function table and call macros in npupp.h.
87 ***********************************************************************/
90 NPN_Version(int* plugin_major
, int* plugin_minor
,
91 int* netscape_major
, int* netscape_minor
)
93 *plugin_major
= NP_VERSION_MAJOR
;
94 *plugin_minor
= NP_VERSION_MINOR
;
96 /* Major version is in high byte */
97 *netscape_major
= gNetscapeFuncs
.version
>> 8;
98 /* Minor version is in low byte */
99 *netscape_minor
= gNetscapeFuncs
.version
& 0xFF;
103 NPN_PluginThreadAsyncCall(NPP plugin
,
104 void (*func
)(void *),
107 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) >= 20)
108 return (*gNetscapeFuncs
.pluginthreadasynccall
)(plugin
, func
, userData
);
113 NPN_GetValue(NPP instance
, NPNVariable variable
, void *r_value
)
115 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
116 return CallNPN_GetValueProc(gNetscapeFuncs
.getvalue
,
117 instance
, variable
, r_value
);
119 return (*gNetscapeFuncs
.getvalue
)(instance
, variable
, r_value
);
124 NPN_SetValue(NPP instance
, NPPVariable variable
, void *value
)
126 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
127 return CallNPN_SetValueProc(gNetscapeFuncs
.setvalue
,
128 instance
, variable
, value
);
130 return (*gNetscapeFuncs
.setvalue
)(instance
, variable
, value
);
135 NPN_GetURL(NPP instance
, const char* url
, const char* window
)
137 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
138 return CallNPN_GetURLProc(gNetscapeFuncs
.geturl
, instance
, url
, window
);
140 return (*gNetscapeFuncs
.geturl
)(instance
, url
, window
);
145 NPN_GetURLNotify(NPP instance
, const char* url
, const char* window
, void* notifyData
)
147 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
148 return CallNPN_GetURLNotifyProc(gNetscapeFuncs
.geturlnotify
, instance
, url
, window
, notifyData
);
150 return (*gNetscapeFuncs
.geturlnotify
)(instance
, url
, window
, notifyData
);
155 NPN_PostURL(NPP instance
, const char* url
, const char* window
,
156 uint32_t len
, const char* buf
, NPBool file
)
158 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
159 return CallNPN_PostURLProc(gNetscapeFuncs
.posturl
, instance
,
160 url
, window
, len
, buf
, file
);
162 return (*gNetscapeFuncs
.posturl
)(instance
, url
, window
, len
, buf
, file
);
167 NPN_PostURLNotify(NPP instance
, const char* url
, const char* window
, uint32_t len
,
168 const char* buf
, NPBool file
, void* notifyData
)
170 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
171 return CallNPN_PostURLNotifyProc(gNetscapeFuncs
.posturlnotify
,
172 instance
, url
, window
, len
, buf
, file
, notifyData
);
174 return (*gNetscapeFuncs
.posturlnotify
)(instance
, url
, window
, len
, buf
, file
, notifyData
);
180 NPN_RequestRead(NPStream
* stream
, NPByteRange
* rangeList
)
182 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
183 return CallNPN_RequestReadProc(gNetscapeFuncs
.requestread
,
186 return (*gNetscapeFuncs
.requestread
)(stream
, rangeList
);
191 NPN_NewStream(NPP instance
, NPMIMEType type
, const char *window
,
192 NPStream
** stream_ptr
)
194 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
195 return CallNPN_NewStreamProc(gNetscapeFuncs
.newstream
, instance
,
196 type
, window
, stream_ptr
);
198 return (*gNetscapeFuncs
.newstream
)(instance
, type
, window
, stream_ptr
);
203 NPN_Write(NPP instance
, NPStream
* stream
, int32_t len
, void* buffer
)
205 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
206 return CallNPN_WriteProc(gNetscapeFuncs
.write
, instance
,
207 stream
, len
, buffer
);
209 return (*gNetscapeFuncs
.write
)(instance
, stream
, len
, buffer
);
214 NPN_DestroyStream(NPP instance
, NPStream
* stream
, NPError reason
)
216 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
217 return CallNPN_DestroyStreamProc(gNetscapeFuncs
.destroystream
,
218 instance
, stream
, reason
);
220 return (*gNetscapeFuncs
.destroystream
)(instance
, stream
, reason
);
225 NPN_Status(NPP instance
, const char* message
)
227 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
228 CallNPN_StatusProc(gNetscapeFuncs
.status
, instance
, message
);
230 (*gNetscapeFuncs
.status
)(instance
, message
);
235 NPN_UserAgent(NPP instance
)
237 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
238 return CallNPN_UserAgentProc(gNetscapeFuncs
.uagent
, instance
);
240 return (*gNetscapeFuncs
.uagent
)(instance
);
244 void *NPN_MemAlloc(uint32_t size
)
246 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
247 return CallNPN_MemAllocProc(gNetscapeFuncs
.memalloc
, size
);
249 return (*gNetscapeFuncs
.memalloc
)(size
);
253 void NPN_MemFree(void* ptr
)
255 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
256 CallNPN_MemFreeProc(gNetscapeFuncs
.memfree
, ptr
);
258 (*gNetscapeFuncs
.memfree
)(ptr
);
262 uint32_t NPN_MemFlush(uint32_t size
)
264 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
265 return CallNPN_MemFlushProc(gNetscapeFuncs
.memflush
, size
);
267 return (*gNetscapeFuncs
.memflush
)(size
);
271 void NPN_ReloadPlugins(NPBool reloadPages
)
273 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
274 CallNPN_ReloadPluginsProc(gNetscapeFuncs
.reloadplugins
, reloadPages
);
276 (*gNetscapeFuncs
.reloadplugins
)(reloadPages
);
281 JRIEnv
* NPN_GetJavaEnv()
283 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
284 return CallNPN_GetJavaEnvProc(gNetscapeFuncs
.getJavaEnv
);
286 return (*gNetscapeFuncs
.getJavaEnv
);
290 jref
NPN_GetJavaPeer(NPP instance
)
292 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
293 return CallNPN_GetJavaPeerProc(gNetscapeFuncs
.getJavaPeer
,
296 return (*gNetscapeFuncs
.getJavaPeer
)(instance
);
302 NPN_InvalidateRect(NPP instance
, NPRect
*invalidRect
)
304 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
305 CallNPN_InvalidateRectProc(gNetscapeFuncs
.invalidaterect
, instance
,
308 (*gNetscapeFuncs
.invalidaterect
)(instance
, invalidRect
);
313 NPN_InvalidateRegion(NPP instance
, NPRegion invalidRegion
)
315 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
316 CallNPN_InvalidateRegionProc(gNetscapeFuncs
.invalidateregion
, instance
,
319 (*gNetscapeFuncs
.invalidateregion
)(instance
, invalidRegion
);
324 NPN_ForceRedraw(NPP instance
)
326 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
327 CallNPN_ForceRedrawProc(gNetscapeFuncs
.forceredraw
, instance
);
329 (*gNetscapeFuncs
.forceredraw
)(instance
);
333 void NPN_PushPopupsEnabledState(NPP instance
, NPBool enabled
)
335 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
336 CallNPN_PushPopupsEnabledStateProc(gNetscapeFuncs
.pushpopupsenabledstate
,
339 (*gNetscapeFuncs
.pushpopupsenabledstate
)(instance
, enabled
);
343 void NPN_PopPopupsEnabledState(NPP instance
)
345 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
346 CallNPN_PopPopupsEnabledStateProc(gNetscapeFuncs
.poppopupsenabledstate
,
349 (*gNetscapeFuncs
.poppopupsenabledstate
)(instance
);
353 NPIdentifier
NPN_GetStringIdentifier(const NPUTF8
*name
)
355 int minor
= gNetscapeFuncs
.version
& 0xFF;
358 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
359 return CallNPN_GetStringIdentifierProc(
360 gNetscapeFuncs
.getstringidentifier
, name
);
362 return (*gNetscapeFuncs
.getstringidentifier
)(name
);
368 void NPN_GetStringIdentifiers(const NPUTF8
**names
, int32_t nameCount
,
369 NPIdentifier
*identifiers
)
371 int minor
= gNetscapeFuncs
.version
& 0xFF;
374 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
375 CallNPN_GetStringIdentifiersProc(gNetscapeFuncs
.getstringidentifiers
,
376 names
, nameCount
, identifiers
);
378 (*gNetscapeFuncs
.getstringidentifiers
)(names
, nameCount
, identifiers
);
383 NPIdentifier
NPN_GetIntIdentifier(int32_t intid
)
385 int minor
= gNetscapeFuncs
.version
& 0xFF;
388 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
389 return CallNPN_GetIntIdentifierProc(gNetscapeFuncs
.getintidentifier
, intid
);
391 return (*gNetscapeFuncs
.getintidentifier
)(intid
);
397 bool NPN_IdentifierIsString(NPIdentifier identifier
)
399 int minor
= gNetscapeFuncs
.version
& 0xFF;
402 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
403 return CallNPN_IdentifierIsStringProc(
404 gNetscapeFuncs
.identifierisstring
,
407 return (*gNetscapeFuncs
.identifierisstring
)(identifier
);
413 NPUTF8
*NPN_UTF8FromIdentifier(NPIdentifier identifier
)
415 int minor
= gNetscapeFuncs
.version
& 0xFF;
418 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
419 return CallNPN_UTF8FromIdentifierProc(
420 gNetscapeFuncs
.utf8fromidentifier
,
423 return (*gNetscapeFuncs
.utf8fromidentifier
)(identifier
);
429 int32_t NPN_IntFromIdentifier(NPIdentifier identifier
)
431 int minor
= gNetscapeFuncs
.version
& 0xFF;
434 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
435 return CallNPN_IntFromIdentifierProc(
436 gNetscapeFuncs
.intfromidentifier
,
439 return (*gNetscapeFuncs
.intfromidentifier
)(identifier
);
445 NPObject
*NPN_CreateObject(NPP npp
, NPClass
*aClass
)
447 int minor
= gNetscapeFuncs
.version
& 0xFF;
449 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
450 return CallNPN_CreateObjectProc(gNetscapeFuncs
.createobject
, npp
, aClass
);
452 return (*gNetscapeFuncs
.createobject
)(npp
, aClass
);
457 NPObject
*NPN_RetainObject(NPObject
*obj
)
459 int minor
= gNetscapeFuncs
.version
& 0xFF;
461 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
462 return CallNPN_RetainObjectProc(gNetscapeFuncs
.retainobject
, obj
);
464 return (*gNetscapeFuncs
.retainobject
)(obj
);
469 void NPN_ReleaseObject(NPObject
*obj
)
471 int minor
= gNetscapeFuncs
.version
& 0xFF;
473 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
474 CallNPN_ReleaseObjectProc(gNetscapeFuncs
.releaseobject
, obj
);
476 (*gNetscapeFuncs
.releaseobject
)(obj
);
480 bool NPN_Invoke(NPP npp
, NPObject
* obj
, NPIdentifier methodName
,
481 const NPVariant
*args
, uint32_t argCount
, NPVariant
*result
)
483 int minor
= gNetscapeFuncs
.version
& 0xFF;
485 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
486 return CallNPN_InvokeProc(gNetscapeFuncs
.invoke
, npp
, obj
, methodName
,
487 args
, argCount
, result
);
489 return (*gNetscapeFuncs
.invoke
)(npp
, obj
, methodName
, args
, argCount
, result
);
494 bool NPN_InvokeDefault(NPP npp
, NPObject
* obj
, const NPVariant
*args
,
495 uint32_t argCount
, NPVariant
*result
)
497 int minor
= gNetscapeFuncs
.version
& 0xFF;
499 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
500 return CallNPN_InvokeDefaultProc(gNetscapeFuncs
.invokeDefault
, npp
, obj
,
501 args
, argCount
, result
);
503 return (*gNetscapeFuncs
.invokeDefault
)(npp
, obj
, args
, argCount
, result
);
508 bool NPN_Evaluate(NPP npp
, NPObject
* obj
, NPString
*script
,
511 int minor
= gNetscapeFuncs
.version
& 0xFF;
513 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
514 return CallNPN_EvaluateProc(gNetscapeFuncs
.evaluate
, npp
, obj
,
517 return (*gNetscapeFuncs
.evaluate
)(npp
, obj
, script
, result
);
522 bool NPN_GetProperty(NPP npp
, NPObject
* obj
, NPIdentifier propertyName
,
525 int minor
= gNetscapeFuncs
.version
& 0xFF;
527 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
528 return CallNPN_GetPropertyProc(gNetscapeFuncs
.getproperty
, npp
, obj
,
529 propertyName
, result
);
531 return (*gNetscapeFuncs
.getproperty
)(npp
, obj
, propertyName
, result
);
536 bool NPN_SetProperty(NPP npp
, NPObject
* obj
, NPIdentifier propertyName
,
537 const NPVariant
*value
)
539 int minor
= gNetscapeFuncs
.version
& 0xFF;
541 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
542 return CallNPN_SetPropertyProc(gNetscapeFuncs
.setproperty
, npp
, obj
,
543 propertyName
, value
);
545 return (*gNetscapeFuncs
.setproperty
)(npp
, obj
, propertyName
, value
);
550 bool NPN_RemoveProperty(NPP npp
, NPObject
* obj
, NPIdentifier propertyName
)
552 int minor
= gNetscapeFuncs
.version
& 0xFF;
554 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
555 return CallNPN_RemovePropertyProc(gNetscapeFuncs
.removeproperty
, npp
, obj
,
558 return (*gNetscapeFuncs
.removeproperty
)(npp
, obj
, propertyName
);
563 bool NPN_HasProperty(NPP npp
, NPObject
* obj
, NPIdentifier propertyName
)
565 int minor
= gNetscapeFuncs
.version
& 0xFF;
567 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
568 return CallNPN_HasPropertyProc(gNetscapeFuncs
.hasproperty
, npp
, obj
,
571 return (*gNetscapeFuncs
.hasproperty
)(npp
, obj
, propertyName
);
576 bool NPN_HasMethod(NPP npp
, NPObject
* obj
, NPIdentifier methodName
)
578 int minor
= gNetscapeFuncs
.version
& 0xFF;
580 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
581 return CallNPN_HasMethodProc(gNetscapeFuncs
.hasmethod
, npp
,
584 return (*gNetscapeFuncs
.hasmethod
)(npp
, obj
, methodName
);
589 void NPN_ReleaseVariantValue(NPVariant
*variant
)
591 int minor
= gNetscapeFuncs
.version
& 0xFF;
593 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
594 CallNPN_ReleaseVariantValueProc(gNetscapeFuncs
.releasevariantvalue
, variant
);
596 (*gNetscapeFuncs
.releasevariantvalue
)(variant
);
600 void NPN_SetException(NPObject
* obj
, const NPUTF8
*message
)
602 int minor
= gNetscapeFuncs
.version
& 0xFF;
604 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
605 CallNPN_SetExceptionProc(gNetscapeFuncs
.setexception
, obj
, message
);
607 (*gNetscapeFuncs
.setexception
)(obj
, message
);
611 /***********************************************************************
613 * Wrapper functions : Netscape Navigator -> plugin
615 * These functions let the plugin developer just create the APIs
616 * as documented and defined in npapi.h, without needing to
617 * install those functions in the function table or worry about
618 * setting up globals for 68K plugins.
620 ***********************************************************************/
622 /* Function prototypes */
623 NPError
Private_New(NPMIMEType pluginType
, NPP instance
, uint16_t mode
,
624 int16_t argc
, char* argn
[], char* argv
[], NPSavedData
* saved
);
625 NPError
Private_Destroy(NPP instance
, NPSavedData
** save
);
626 NPError
Private_SetWindow(NPP instance
, NPWindow
* window
);
627 NPError
Private_NewStream(NPP instance
, NPMIMEType type
, NPStream
* stream
,
628 NPBool seekable
, uint16_t* stype
);
629 int32_t Private_WriteReady(NPP instance
, NPStream
* stream
);
630 int32_t Private_Write(NPP instance
, NPStream
* stream
, int32_t offset
,
631 int32_t len
, void* buffer
);
632 void Private_StreamAsFile(NPP instance
, NPStream
* stream
, const char* fname
);
633 NPError
Private_DestroyStream(NPP instance
, NPStream
* stream
, NPError reason
);
634 void Private_URLNotify(NPP instance
, const char* url
,
635 NPReason reason
, void* notifyData
);
636 void Private_Print(NPP instance
, NPPrint
* platformPrint
);
637 NPError
Private_GetValue(NPP instance
, NPPVariable variable
, void *r_value
);
638 NPError
Private_SetValue(NPP instance
, NPPVariable variable
, void *r_value
);
640 JRIGlobalRef
Private_GetJavaClass(void);
643 /* function implementations */
645 Private_New(NPMIMEType pluginType
, NPP instance
, uint16_t mode
,
646 int16_t argc
, char* argn
[], char* argv
[], NPSavedData
* saved
)
649 PLUGINDEBUGSTR("New");
650 ret
= NPP_New(pluginType
, instance
, mode
, argc
, argn
, argv
, saved
);
655 Private_Destroy(NPP instance
, NPSavedData
** save
)
657 PLUGINDEBUGSTR("Destroy");
658 return NPP_Destroy(instance
, save
);
662 Private_SetWindow(NPP instance
, NPWindow
* window
)
665 PLUGINDEBUGSTR("SetWindow");
666 err
= NPP_SetWindow(instance
, window
);
671 Private_NewStream(NPP instance
, NPMIMEType type
, NPStream
* stream
,
672 NPBool seekable
, uint16_t* stype
)
675 PLUGINDEBUGSTR("NewStream");
676 err
= NPP_NewStream(instance
, type
, stream
, seekable
, stype
);
681 Private_WriteReady(NPP instance
, NPStream
* stream
)
684 PLUGINDEBUGSTR("WriteReady");
685 result
= NPP_WriteReady(instance
, stream
);
690 Private_Write(NPP instance
, NPStream
* stream
, int32_t offset
, int32_t len
,
694 PLUGINDEBUGSTR("Write");
695 result
= NPP_Write(instance
, stream
, offset
, len
, buffer
);
700 Private_StreamAsFile(NPP instance
, NPStream
* stream
, const char* fname
)
702 PLUGINDEBUGSTR("StreamAsFile");
703 NPP_StreamAsFile(instance
, stream
, fname
);
708 Private_DestroyStream(NPP instance
, NPStream
* stream
, NPError reason
)
711 PLUGINDEBUGSTR("DestroyStream");
712 err
= NPP_DestroyStream(instance
, stream
, reason
);
717 Private_URLNotify(NPP instance
, const char* url
,
718 NPReason reason
, void* notifyData
)
720 PLUGINDEBUGSTR("URLNotify");
721 NPP_URLNotify(instance
, url
, reason
, notifyData
);
725 Private_Print(NPP instance
, NPPrint
* platformPrint
)
727 PLUGINDEBUGSTR("Print");
728 NPP_Print(instance
, platformPrint
);
732 Private_GetValue(NPP instance
, NPPVariable variable
, void *r_value
)
734 PLUGINDEBUGSTR("GetValue");
735 return NPP_GetValue(instance
, variable
, r_value
);
739 Private_SetValue(NPP instance
, NPPVariable variable
, void *r_value
)
741 PLUGINDEBUGSTR("SetValue");
742 return NPP_SetValue(instance
, variable
, r_value
);
747 Private_GetJavaClass(void)
749 jref clazz
= NPP_GetJavaClass();
751 JRIEnv
* env
= NPN_GetJavaEnv();
752 return JRI_NewGlobalRef(env
, clazz
);
758 /***********************************************************************
760 * These functions are located automagically by netscape.
762 ***********************************************************************/
765 * NP_GetMIMEDescription
766 * - Netscape needs to know about this symbol
767 * - Netscape uses the return value to identify when an object instance
768 * of this plugin should be created.
771 NP_GetMIMEDescription(void)
773 return NPP_GetMIMEDescription();
777 * NP_GetValue [optional]
778 * - Netscape needs to know about this symbol.
779 * - Interfaces with plugin to get values for predefined variables
780 * that the navigator needs.
783 NP_GetValue(void* future
, NPPVariable variable
, void *value
)
785 return NPP_GetValue(future
, variable
, value
);
790 * - Netscape needs to know about this symbol.
791 * - It calls this function after looking up its symbol before it
792 * is about to create the first ever object of this kind.
795 * nsTable - The netscape function table. If developers just use these
796 * wrappers, they don't need to worry about all these function
800 * - This functions needs to fill the plugin function table
801 * pluginFuncs and return it. Netscape Navigator plugin
802 * library will use this function table to call the plugin.
806 NP_Initialize(NPNetscapeFuncs
* nsTable
, NPPluginFuncs
* pluginFuncs
)
808 NPError err
= NPERR_NO_ERROR
;
810 PLUGINDEBUGSTR("NP_Initialize");
812 /* validate input parameters */
813 if ((nsTable
== NULL
) || (pluginFuncs
== NULL
))
814 err
= NPERR_INVALID_FUNCTABLE_ERROR
;
817 * Check the major version passed in Netscape's function table.
818 * We won't load if the major version is newer than what we expect.
819 * Also check that the function tables passed in are big enough for
820 * all the functions we need (they could be bigger, if Netscape added
821 * new APIs, but that's OK with us -- we'll just ignore them).
824 if (err
== NPERR_NO_ERROR
) {
825 if ((nsTable
->version
>> 8) > NP_VERSION_MAJOR
)
826 err
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
827 if (nsTable
->size
< ((char *)&nsTable
->posturlnotify
- (char *)nsTable
))
828 err
= NPERR_INVALID_FUNCTABLE_ERROR
;
829 if (pluginFuncs
->size
< sizeof(NPPluginFuncs
))
830 err
= NPERR_INVALID_FUNCTABLE_ERROR
;
833 if (err
== NPERR_NO_ERROR
)
836 * Copy all the fields of Netscape function table into our
837 * copy so we can call back into Netscape later. Note that
838 * we need to copy the fields one by one, rather than assigning
839 * the whole structure, because the Netscape function table
840 * could actually be bigger than what we expect.
842 int minor
= nsTable
->version
& 0xFF;
844 gNetscapeFuncs
.version
= nsTable
->version
;
845 gNetscapeFuncs
.size
= nsTable
->size
;
846 gNetscapeFuncs
.posturl
= nsTable
->posturl
;
847 gNetscapeFuncs
.geturl
= nsTable
->geturl
;
848 gNetscapeFuncs
.requestread
= nsTable
->requestread
;
849 gNetscapeFuncs
.newstream
= nsTable
->newstream
;
850 gNetscapeFuncs
.write
= nsTable
->write
;
851 gNetscapeFuncs
.destroystream
= nsTable
->destroystream
;
852 gNetscapeFuncs
.status
= nsTable
->status
;
853 gNetscapeFuncs
.uagent
= nsTable
->uagent
;
854 gNetscapeFuncs
.memalloc
= nsTable
->memalloc
;
855 gNetscapeFuncs
.memfree
= nsTable
->memfree
;
856 gNetscapeFuncs
.memflush
= nsTable
->memflush
;
857 gNetscapeFuncs
.reloadplugins
= nsTable
->reloadplugins
;
858 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) >= 20)
859 gNetscapeFuncs
.pluginthreadasynccall
=
860 nsTable
->pluginthreadasynccall
;
863 if( minor
>= NPVERS_HAS_LIVECONNECT
)
865 gNetscapeFuncs
.getJavaEnv
= nsTable
->getJavaEnv
;
866 gNetscapeFuncs
.getJavaPeer
= nsTable
->getJavaPeer
;
869 gNetscapeFuncs
.getvalue
= nsTable
->getvalue
;
870 gNetscapeFuncs
.setvalue
= nsTable
->setvalue
;
872 if( minor
>= NPVERS_HAS_NOTIFICATION
)
874 gNetscapeFuncs
.geturlnotify
= nsTable
->geturlnotify
;
875 gNetscapeFuncs
.posturlnotify
= nsTable
->posturlnotify
;
878 if (nsTable
->size
>= ((char *)&nsTable
->setexception
- (char *)nsTable
))
880 gNetscapeFuncs
.invalidaterect
= nsTable
->invalidaterect
;
881 gNetscapeFuncs
.invalidateregion
= nsTable
->invalidateregion
;
882 gNetscapeFuncs
.forceredraw
= nsTable
->forceredraw
;
883 /* npruntime support */
886 gNetscapeFuncs
.getstringidentifier
= nsTable
->getstringidentifier
;
887 gNetscapeFuncs
.getstringidentifiers
= nsTable
->getstringidentifiers
;
888 gNetscapeFuncs
.getintidentifier
= nsTable
->getintidentifier
;
889 gNetscapeFuncs
.identifierisstring
= nsTable
->identifierisstring
;
890 gNetscapeFuncs
.utf8fromidentifier
= nsTable
->utf8fromidentifier
;
891 gNetscapeFuncs
.intfromidentifier
= nsTable
->intfromidentifier
;
892 gNetscapeFuncs
.createobject
= nsTable
->createobject
;
893 gNetscapeFuncs
.retainobject
= nsTable
->retainobject
;
894 gNetscapeFuncs
.releaseobject
= nsTable
->releaseobject
;
895 gNetscapeFuncs
.invoke
= nsTable
->invoke
;
896 gNetscapeFuncs
.invokeDefault
= nsTable
->invokeDefault
;
897 gNetscapeFuncs
.evaluate
= nsTable
->evaluate
;
898 gNetscapeFuncs
.getproperty
= nsTable
->getproperty
;
899 gNetscapeFuncs
.setproperty
= nsTable
->setproperty
;
900 gNetscapeFuncs
.removeproperty
= nsTable
->removeproperty
;
901 gNetscapeFuncs
.hasproperty
= nsTable
->hasproperty
;
902 gNetscapeFuncs
.hasmethod
= nsTable
->hasmethod
;
903 gNetscapeFuncs
.releasevariantvalue
= nsTable
->releasevariantvalue
;
904 gNetscapeFuncs
.setexception
= nsTable
->setexception
;
909 gNetscapeFuncs
.invalidaterect
= NULL
;
910 gNetscapeFuncs
.invalidateregion
= NULL
;
911 gNetscapeFuncs
.forceredraw
= NULL
;
912 gNetscapeFuncs
.getstringidentifier
= NULL
;
913 gNetscapeFuncs
.getstringidentifiers
= NULL
;
914 gNetscapeFuncs
.getintidentifier
= NULL
;
915 gNetscapeFuncs
.identifierisstring
= NULL
;
916 gNetscapeFuncs
.utf8fromidentifier
= NULL
;
917 gNetscapeFuncs
.intfromidentifier
= NULL
;
918 gNetscapeFuncs
.createobject
= NULL
;
919 gNetscapeFuncs
.retainobject
= NULL
;
920 gNetscapeFuncs
.releaseobject
= NULL
;
921 gNetscapeFuncs
.invoke
= NULL
;
922 gNetscapeFuncs
.invokeDefault
= NULL
;
923 gNetscapeFuncs
.evaluate
= NULL
;
924 gNetscapeFuncs
.getproperty
= NULL
;
925 gNetscapeFuncs
.setproperty
= NULL
;
926 gNetscapeFuncs
.removeproperty
= NULL
;
927 gNetscapeFuncs
.hasproperty
= NULL
;
928 gNetscapeFuncs
.releasevariantvalue
= NULL
;
929 gNetscapeFuncs
.setexception
= NULL
;
932 ((char *)&nsTable
->poppopupsenabledstate
- (char *)nsTable
))
934 gNetscapeFuncs
.pushpopupsenabledstate
= nsTable
->pushpopupsenabledstate
;
935 gNetscapeFuncs
.poppopupsenabledstate
= nsTable
->poppopupsenabledstate
;
939 gNetscapeFuncs
.pushpopupsenabledstate
= NULL
;
940 gNetscapeFuncs
.poppopupsenabledstate
= NULL
;
944 * Set up the plugin function table that Netscape will use to
945 * call us. Netscape needs to know about our version and size
946 * and have a UniversalProcPointer for every function we
949 pluginFuncs
->version
= (NP_VERSION_MAJOR
<< 8) + NP_VERSION_MINOR
;
950 pluginFuncs
->size
= sizeof(NPPluginFuncs
);
951 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
952 pluginFuncs
->newp
= NewNPP_NewProc(Private_New
);
953 pluginFuncs
->destroy
= NewNPP_DestroyProc(Private_Destroy
);
954 pluginFuncs
->setwindow
= NewNPP_SetWindowProc(Private_SetWindow
);
955 pluginFuncs
->newstream
= NewNPP_NewStreamProc(Private_NewStream
);
956 pluginFuncs
->destroystream
= NewNPP_DestroyStreamProc(Private_DestroyStream
);
957 pluginFuncs
->asfile
= NewNPP_StreamAsFileProc(Private_StreamAsFile
);
958 pluginFuncs
->writeready
= NewNPP_WriteReadyProc(Private_WriteReady
);
959 pluginFuncs
->write
= NewNPP_WriteProc(Private_Write
);
960 pluginFuncs
->print
= NewNPP_PrintProc(Private_Print
);
961 pluginFuncs
->getvalue
= NewNPP_GetValueProc(Private_GetValue
);
962 pluginFuncs
->setvalue
= NewNPP_SetValueProc(Private_SetValue
);
964 pluginFuncs
->newp
= (NPP_NewProcPtr
)(Private_New
);
965 pluginFuncs
->destroy
= (NPP_DestroyProcPtr
)(Private_Destroy
);
966 pluginFuncs
->setwindow
= (NPP_SetWindowProcPtr
)(Private_SetWindow
);
967 pluginFuncs
->newstream
= (NPP_NewStreamProcPtr
)(Private_NewStream
);
968 pluginFuncs
->destroystream
= (NPP_DestroyStreamProcPtr
)(Private_DestroyStream
);
969 pluginFuncs
->asfile
= (NPP_StreamAsFileProcPtr
)(Private_StreamAsFile
);
970 pluginFuncs
->writeready
= (NPP_WriteReadyProcPtr
)(Private_WriteReady
);
971 pluginFuncs
->write
= (NPP_WriteProcPtr
)(Private_Write
);
972 pluginFuncs
->print
= (NPP_PrintProcPtr
)(Private_Print
);
973 pluginFuncs
->getvalue
= (NPP_GetValueProcPtr
)(Private_GetValue
);
974 pluginFuncs
->setvalue
= (NPP_SetValueProcPtr
)(Private_SetValue
);
976 pluginFuncs
->event
= NULL
;
977 if( minor
>= NPVERS_HAS_NOTIFICATION
)
979 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
980 pluginFuncs
->urlnotify
= NewNPP_URLNotifyProc(Private_URLNotify
);
982 pluginFuncs
->urlnotify
= (NPP_URLNotifyProcPtr
)(Private_URLNotify
);
986 if( minor
>= NPVERS_HAS_LIVECONNECT
)
987 pluginFuncs
->javaClass
= Private_GetJavaClass();
989 pluginFuncs
->javaClass
= NULL
;
991 pluginFuncs
->javaClass
= NULL
;
994 err
= NPP_Initialize();
1001 * NP_Shutdown [optional]
1002 * - Netscape needs to know about this symbol.
1003 * - It calls this function after looking up its symbol after
1004 * the last object of this kind has been destroyed.
1010 PLUGINDEBUGSTR("NP_Shutdown");
1012 return NPERR_NO_ERROR
;