1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * Safari/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
21 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
25 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
31 #include <Processes.h>
33 #include <CodeFragments.h>
35 #include <Resources.h>
36 #include <ToolUtils.h>
39 #undef TARGET_RT_MAC_CFM
42 // A4Stuff.h contains the definition of EnterCodeResource and
43 // EnterCodeResource, used for setting up the code resource’s
44 // globals for 68K (analagous to the function SetCurrentA5
45 // defined by the toolbox).
47 // A4Stuff does not exist as of CW 7. Define them to nothing.
50 #if (defined(__MWERKS__) && (__MWERKS__ >= 0x2400)) || defined(__GNUC__)
51 #define EnterCodeResource()
52 #define ExitCodeResource()
60 // The Mixed Mode procInfos defined in npupp.h assume Think C-
61 // style calling conventions. These conventions are used by
62 // Metrowerks with the exception of pointer return types, which
63 // in Metrowerks 68K are returned in A0, instead of the standard
64 // D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers,
65 // Mixed Mode will return the values to a 68K plugin in D0, but
66 // a 68K plugin compiled by Metrowerks will expect the result in
67 // A0. The following pragma forces Metrowerks to use D0 instead.
71 #pragma pointers_in_D0
79 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
81 // e.g. CALL_NPN(CallNPN_GetURLNotify, x, y, z) -> CallNPN_GetURLNotify(x, y, z);
82 #define CALL_NPN(__CallNPNFunc__, ...) (__CallNPNFunc__(__VA_ARGS__))
84 #include "npfunctions.h"
85 #define CALL_NPN(unused, FN, ...) ((*FN)(__VA_ARGS__))
88 #include "../vlcshell.h"
92 #pragma pointers_in_A0
96 // The following fix for static initializers (which fixes a previous
97 // incompatibility with some parts of PowerPlant, was submitted by
104 extern void __InitCode__(void);
106 extern void __sinit(void);
107 #define __InitCode__ __sinit
109 extern void __destroy_global_chain(void);
112 #endif // __cplusplus
116 // Define PLUGIN_TRACE to 1 to have the wrapper functions emit
117 // DebugStr messages whenever they are called.
119 #define PLUGIN_TRACE 0
122 #define PLUGINDEBUGSTR(msg) ::DebugStr(msg)
124 #define PLUGINDEBUGSTR(msg) {}
127 #if defined(XP_MACOSX) && defined(__POWERPC__) && (!defined(TARGET_RT_MAC_CFM))
129 // glue for mapping outgoing Macho function pointers to TVectors
137 TFPtoTVGlue setwindow
;
138 TFPtoTVGlue newstream
;
139 TFPtoTVGlue destroystream
;
141 TFPtoTVGlue writeready
;
145 TFPtoTVGlue urlnotify
;
146 TFPtoTVGlue getvalue
;
147 TFPtoTVGlue setvalue
;
149 TFPtoTVGlue shutdown
;
150 } gPluginFuncsGlueTable
;
152 static inline void* SetupFPtoTVGlue(TFPtoTVGlue
* functionGlue
, void* fp
)
154 functionGlue
->glue
[0] = fp
;
155 functionGlue
->glue
[1] = 0;
159 #define PLUGIN_TO_HOST_GLUE(name, fp) (SetupFPtoTVGlue(&gPluginFuncsGlueTable.name, (void*)fp))
161 // glue for mapping netscape TVectors to Macho function pointers
169 TTVtoFPGlue requestread
;
170 TTVtoFPGlue newstream
;
172 TTVtoFPGlue destroystream
;
175 TTVtoFPGlue memalloc
;
177 TTVtoFPGlue memflush
;
178 TTVtoFPGlue reloadplugins
;
179 TTVtoFPGlue getJavaEnv
;
180 TTVtoFPGlue getJavaPeer
;
181 TTVtoFPGlue geturlnotify
;
182 TTVtoFPGlue posturlnotify
;
183 TTVtoFPGlue getvalue
;
184 TTVtoFPGlue setvalue
;
185 TTVtoFPGlue invalidaterect
;
186 TTVtoFPGlue invalidateregion
;
187 TTVtoFPGlue forceredraw
;
189 TTVtoFPGlue getstringidentifier
;
190 TTVtoFPGlue getstringidentifiers
;
191 TTVtoFPGlue getintidentifier
;
192 TTVtoFPGlue identifierisstring
;
193 TTVtoFPGlue utf8fromidentifier
;
194 TTVtoFPGlue intfromidentifier
;
195 TTVtoFPGlue createobject
;
196 TTVtoFPGlue retainobject
;
197 TTVtoFPGlue releaseobject
;
199 TTVtoFPGlue invokeDefault
;
200 TTVtoFPGlue evaluate
;
201 TTVtoFPGlue getproperty
;
202 TTVtoFPGlue setproperty
;
203 TTVtoFPGlue removeproperty
;
204 TTVtoFPGlue hasproperty
;
205 TTVtoFPGlue hasmethod
;
206 TTVtoFPGlue releasevariantvalue
;
207 TTVtoFPGlue setexception
;
208 } gNetscapeFuncsGlueTable
;
210 static void* SetupTVtoFPGlue(TTVtoFPGlue
* functionGlue
, void* tvp
)
212 static const TTVtoFPGlue glueTemplate
= { 0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420 };
214 memcpy(functionGlue
, &glueTemplate
, sizeof(TTVtoFPGlue
));
215 functionGlue
->glue
[0] |= ((UInt32
)tvp
>> 16);
216 functionGlue
->glue
[1] |= ((UInt32
)tvp
& 0xFFFF);
217 ::MakeDataExecutable(functionGlue
, sizeof(TTVtoFPGlue
));
221 #define HOST_TO_PLUGIN_GLUE(name, fp) ((UniversalProcPtr)(SetupTVtoFPGlue(&gNetscapeFuncsGlueTable.name, (void*)fp)))
225 #define PLUGIN_TO_HOST_GLUE(name, fp) (fp)
226 #define HOST_TO_PLUGIN_GLUE(name, fp) (fp)
228 #endif /* XP_MACOSX */
232 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
236 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
238 #if !TARGET_API_MAC_CARBON
239 QDGlobals
* gQDPtr
; // Pointer to Netscape’s QuickDraw globals
241 short gResFile
; // Refnum of the plugin’s resource file
242 NPNetscapeFuncs gNetscapeFuncs
; // Function table for procs in Netscape called by plugin
244 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
246 // Wrapper functions for all calls from the plugin to Netscape.
247 // These functions let the plugin developer just call the APIs
248 // as documented and defined in npapi.h, without needing to know
249 // about the function table and call macros in npupp.h.
251 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
253 void NPN_Version(int* plugin_major
, int* plugin_minor
, int* netscape_major
, int* netscape_minor
)
255 *plugin_major
= NP_VERSION_MAJOR
;
256 *plugin_minor
= NP_VERSION_MINOR
;
257 *netscape_major
= gNetscapeFuncs
.version
>> 8; // Major version is in high byte
258 *netscape_minor
= gNetscapeFuncs
.version
& 0xFF; // Minor version is in low byte
261 NPError
NPN_GetURLNotify(NPP instance
, const char* url
, const char* window
, void* notifyData
)
263 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
266 if( navMinorVers
>= NPVERS_HAS_NOTIFICATION
)
268 err
= CALL_NPN(CallNPN_GetURLNotifyProc
, gNetscapeFuncs
.geturlnotify
, instance
, url
, window
, notifyData
);
272 err
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
277 NPError
NPN_GetURL(NPP instance
, const char* url
, const char* window
)
279 return CALL_NPN(CallNPN_GetURLProc
, gNetscapeFuncs
.geturl
, instance
, url
, window
);
282 NPError
NPN_PostURLNotify(NPP instance
, const char* url
, const char* window
, uint32_t len
, const char* buf
, NPBool file
, void* notifyData
)
284 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
287 if( navMinorVers
>= NPVERS_HAS_NOTIFICATION
)
289 err
= CALL_NPN(CallNPN_PostURLNotifyProc
, gNetscapeFuncs
.posturlnotify
, instance
, url
,
290 window
, len
, buf
, file
, notifyData
);
294 err
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
299 NPError
NPN_PostURL(NPP instance
, const char* url
, const char* window
, uint32_t len
, const char* buf
, NPBool file
)
301 return CALL_NPN(CallNPN_PostURLProc
, gNetscapeFuncs
.posturl
, instance
, url
, window
, len
, buf
, file
);
304 NPError
NPN_RequestRead(NPStream
* stream
, NPByteRange
* rangeList
)
306 return CALL_NPN(CallNPN_RequestReadProc
, gNetscapeFuncs
.requestread
, stream
, rangeList
);
309 NPError
NPN_NewStream(NPP instance
, NPMIMEType type
, const char* window
, NPStream
** stream
)
311 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
314 if( navMinorVers
>= NPVERS_HAS_STREAMOUTPUT
)
316 err
= CALL_NPN(CallNPN_NewStreamProc
, gNetscapeFuncs
.newstream
, instance
, type
, window
, stream
);
320 err
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
325 int32_t NPN_Write(NPP instance
, NPStream
* stream
, int32_t len
, void* buffer
)
327 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
330 if( navMinorVers
>= NPVERS_HAS_STREAMOUTPUT
)
332 err
= CALL_NPN(CallNPN_WriteProc
, gNetscapeFuncs
.write
, instance
, stream
, len
, buffer
);
336 err
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
341 NPError
NPN_DestroyStream(NPP instance
, NPStream
* stream
, NPError reason
)
343 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
346 if( navMinorVers
>= NPVERS_HAS_STREAMOUTPUT
)
348 err
= CALL_NPN(CallNPN_DestroyStreamProc
, gNetscapeFuncs
.destroystream
, instance
, stream
, reason
);
352 err
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
357 void NPN_Status(NPP instance
, const char* message
)
359 CALL_NPN(CallNPN_StatusProc
, gNetscapeFuncs
.status
, instance
, message
);
362 const char* NPN_UserAgent(NPP instance
)
364 return CALL_NPN(CallNPN_UserAgentProc
, gNetscapeFuncs
.uagent
, instance
);
367 void* NPN_MemAlloc(uint32_t size
)
369 return CALL_NPN(CallNPN_MemAllocProc
, gNetscapeFuncs
.memalloc
, size
);
372 void NPN_MemFree(void* ptr
)
374 CALL_NPN(CallNPN_MemFreeProc
, gNetscapeFuncs
.memfree
, ptr
);
377 uint32_t NPN_MemFlush(uint32_t size
)
379 return CALL_NPN(CallNPN_MemFlushProc
, gNetscapeFuncs
.memflush
, size
);
382 void NPN_ReloadPlugins(NPBool reloadPages
)
384 CALL_NPN(CallNPN_ReloadPluginsProc
, gNetscapeFuncs
.reloadplugins
, reloadPages
);
388 JRIEnv
* NPN_GetJavaEnv(void)
390 return CallNPN_GetJavaEnvProc( gNetscapeFuncs
.getJavaEnv
);
393 jobject
NPN_GetJavaPeer(NPP instance
)
395 return CallNPN_GetJavaPeerProc( gNetscapeFuncs
.getJavaPeer
, instance
);
399 NPError
NPN_GetValue(NPP instance
, NPNVariable variable
, void *value
)
401 return CALL_NPN(CallNPN_GetValueProc
, gNetscapeFuncs
.getvalue
, instance
, variable
, value
);
404 NPError
NPN_SetValue(NPP instance
, NPPVariable variable
, void *value
)
406 return CALL_NPN(CallNPN_SetValueProc
, gNetscapeFuncs
.setvalue
, instance
, variable
, value
);
409 void NPN_InvalidateRect(NPP instance
, NPRect
*rect
)
411 CALL_NPN(CallNPN_InvalidateRectProc
, gNetscapeFuncs
.invalidaterect
, instance
, rect
);
414 void NPN_InvalidateRegion(NPP instance
, NPRegion region
)
416 CALL_NPN(CallNPN_InvalidateRegionProc
, gNetscapeFuncs
.invalidateregion
, instance
, region
);
419 void NPN_ForceRedraw(NPP instance
)
421 CALL_NPN(CallNPN_ForceRedrawProc
, gNetscapeFuncs
.forceredraw
, instance
);
424 NPIdentifier
NPN_GetStringIdentifier(const NPUTF8
*name
)
426 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
427 if( navMinorVers
>= 14 )
429 return CALL_NPN(CallNPN_GetStringIdentifierProc
, gNetscapeFuncs
.getstringidentifier
, name
);
434 void NPN_GetStringIdentifiers(const NPUTF8
**names
, int32_t nameCount
, NPIdentifier
*identifiers
)
436 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
437 if( navMinorVers
>= 14 )
439 CALL_NPN(CallNPN_GetStringIdentifiersProc
, gNetscapeFuncs
.getstringidentifiers
, names
, nameCount
, identifiers
);
443 NPIdentifier
NPN_GetIntIdentifier(int32_t intid
)
445 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
446 if( navMinorVers
>= 14 )
448 return CALL_NPN(CallNPN_GetIntIdentifierProc
, gNetscapeFuncs
.getintidentifier
, intid
);
453 bool NPN_IdentifierIsString(NPIdentifier identifier
)
455 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
456 if( navMinorVers
>= 14 )
458 return CALL_NPN(CallNPN_IdentifierIsStringProc
, gNetscapeFuncs
.identifierisstring
, identifier
);
463 NPUTF8
*NPN_UTF8FromIdentifier(NPIdentifier identifier
)
465 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
466 if( navMinorVers
>= 14 )
468 return CALL_NPN(CallNPN_UTF8FromIdentifierProc
, gNetscapeFuncs
.utf8fromidentifier
, identifier
);
473 int32_t NPN_IntFromIdentifier(NPIdentifier identifier
)
475 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
476 if( navMinorVers
>= 14 )
478 return CALL_NPN(CallNPN_IntFromIdentifierProc
, gNetscapeFuncs
.intfromidentifier
, identifier
);
483 NPObject
*NPN_CreateObject(NPP instance
, NPClass
*aClass
)
485 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
486 if( navMinorVers
>= 14 )
488 return CALL_NPN(CallNPN_CreateObjectProc
, gNetscapeFuncs
.createobject
, instance
, aClass
);
493 NPObject
*NPN_RetainObject(NPObject
*npobj
)
495 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
496 if( navMinorVers
>= 14 )
498 return CALL_NPN(CallNPN_RetainObjectProc
, gNetscapeFuncs
.retainobject
, npobj
);
503 void NPN_ReleaseObject(NPObject
*npobj
)
505 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
506 if( navMinorVers
>= 14 )
508 CALL_NPN(CallNPN_ReleaseObjectProc
, gNetscapeFuncs
.releaseobject
, npobj
);
512 bool NPN_Invoke(NPP instance
, NPObject
*npobj
, NPIdentifier methodName
, const NPVariant
*args
, uint32_t argCount
, NPVariant
*result
)
514 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
515 if( navMinorVers
>= 14 )
517 return CALL_NPN(CallNPN_InvokeProc
, gNetscapeFuncs
.invoke
, instance
, npobj
, methodName
, args
, argCount
, result
);
522 bool NPN_InvokeDefault(NPP instance
, NPObject
*npobj
, const NPVariant
*args
, uint32_t argCount
, NPVariant
*result
)
524 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
525 if( navMinorVers
>= 14 )
527 return CALL_NPN(CallNPN_InvokeDefaultProc
, gNetscapeFuncs
.invokeDefault
, instance
, npobj
, args
, argCount
, result
);
532 bool NPN_Evaluate(NPP instance
, NPObject
*npobj
, NPString
*script
, NPVariant
*result
)
534 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
535 if( navMinorVers
>= 14 )
537 return CALL_NPN(CallNPN_EvaluateProc
, gNetscapeFuncs
.evaluate
, instance
, npobj
, script
, result
);
542 bool NPN_GetProperty(NPP instance
, NPObject
*npobj
, NPIdentifier propertyName
, NPVariant
*result
)
544 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
545 if( navMinorVers
>= 14 )
547 return CALL_NPN(CallNPN_GetPropertyProc
, gNetscapeFuncs
.getproperty
, instance
, npobj
, propertyName
, result
);
552 bool NPN_SetProperty(NPP instance
, NPObject
*npobj
, NPIdentifier propertyName
, const NPVariant
*value
)
554 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
555 if( navMinorVers
>= 14 )
557 return CALL_NPN(CallNPN_SetPropertyProc
, gNetscapeFuncs
.setproperty
, instance
, npobj
, propertyName
, value
);
562 bool NPN_RemoveProperty(NPP instance
, NPObject
*npobj
, NPIdentifier propertyName
)
564 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
565 if( navMinorVers
>= 14 )
567 return CALL_NPN(CallNPN_RemovePropertyProc
, gNetscapeFuncs
.removeproperty
, instance
, npobj
, propertyName
);
572 bool NPN_HasProperty(NPP instance
, NPObject
*npobj
, NPIdentifier propertyName
)
574 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
575 if( navMinorVers
>= 14 )
577 return CALL_NPN(CallNPN_HasPropertyProc
, gNetscapeFuncs
.hasproperty
, instance
, npobj
, propertyName
);
582 bool NPN_HasMethod(NPP instance
, NPObject
*npobj
, NPIdentifier methodName
)
584 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
585 if( navMinorVers
>= 14 )
587 return CALL_NPN(CallNPN_HasMethodProc
, gNetscapeFuncs
.hasmethod
, instance
, npobj
, methodName
);
592 void NPN_ReleaseVariantValue(NPVariant
*variant
)
594 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
595 if( navMinorVers
>= 14 )
597 CALL_NPN(CallNPN_ReleaseVariantValueProc
, gNetscapeFuncs
.releasevariantvalue
, variant
);
601 void NPN_SetException(NPObject
*npobj
, const NPUTF8
*message
)
603 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
604 if( navMinorVers
>= 14 )
606 CALL_NPN(CallNPN_SetExceptionProc
, gNetscapeFuncs
.setexception
, npobj
, message
);
612 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
614 // Wrapper functions for all calls from Netscape to the 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 NPError
Private_Initialize(void);
623 void Private_Shutdown(void);
624 NPError
Private_New(NPMIMEType pluginType
, NPP instance
, uint16_t mode
, 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_GetValue( NPP instance
, NPPVariable variable
, void *value
);
628 NPError
Private_SetValue( NPP instance
, NPPVariable variable
, void *value
);
629 NPError
Private_NewStream(NPP instance
, NPMIMEType type
, NPStream
* stream
, NPBool seekable
, uint16_t* stype
);
630 NPError
Private_DestroyStream(NPP instance
, NPStream
* stream
, NPError reason
);
631 int32_t Private_WriteReady(NPP instance
, NPStream
* stream
);
632 int32_t Private_Write(NPP instance
, NPStream
* stream
, int32_t offset
, int32_t len
, void* buffer
);
633 void Private_StreamAsFile(NPP instance
, NPStream
* stream
, const char* fname
);
634 void Private_Print(NPP instance
, NPPrint
* platformPrint
);
635 int16_t Private_HandleEvent(NPP instance
, void* event
);
636 void Private_URLNotify(NPP instance
, const char* url
, NPReason reason
, void* notifyData
);
638 jobject
Private_GetJavaClass(void);
642 NPError
Private_Initialize(void)
646 PLUGINDEBUGSTR("\pInitialize;g;");
647 err
= NPP_Initialize();
652 void Private_Shutdown(void)
655 PLUGINDEBUGSTR("\pShutdown;g;");
659 __destroy_global_chain();
665 NPError
Private_New(NPMIMEType pluginType
, NPP instance
, uint16_t mode
, int16_t argc
, char* argn
[], char* argv
[], NPSavedData
* saved
)
668 NPError ret
= NPP_New(pluginType
, instance
, mode
, argc
, argn
, argv
, saved
);
669 PLUGINDEBUGSTR("\pNew;g;");
674 NPError
Private_Destroy(NPP instance
, NPSavedData
** save
)
678 PLUGINDEBUGSTR("\pDestroy;g;");
679 err
= NPP_Destroy(instance
, save
);
684 NPError
Private_SetWindow(NPP instance
, NPWindow
* window
)
688 PLUGINDEBUGSTR("\pSetWindow;g;");
689 err
= NPP_SetWindow(instance
, window
);
694 NPError
Private_GetValue( NPP instance
, NPPVariable variable
, void *value
)
698 PLUGINDEBUGSTR("\pGetValue;g;");
699 err
= NPP_GetValue(instance
, variable
, value
);
704 NPError
Private_SetValue( NPP instance
, NPNVariable variable
, void *value
)
708 PLUGINDEBUGSTR("\pSetValue;g;");
709 err
= NPP_SetValue(instance
, variable
, value
);
714 NPError
Private_NewStream(NPP instance
, NPMIMEType type
, NPStream
* stream
, NPBool seekable
, uint16_t* stype
)
718 PLUGINDEBUGSTR("\pNewStream;g;");
719 err
= NPP_NewStream(instance
, type
, stream
, seekable
, stype
);
724 int32_t Private_WriteReady(NPP instance
, NPStream
* stream
)
728 PLUGINDEBUGSTR("\pWriteReady;g;");
729 result
= NPP_WriteReady(instance
, stream
);
734 int32_t Private_Write(NPP instance
, NPStream
* stream
, int32_t offset
, int32_t len
, void* buffer
)
738 PLUGINDEBUGSTR("\pWrite;g;");
739 result
= NPP_Write(instance
, stream
, offset
, len
, buffer
);
744 void Private_StreamAsFile(NPP instance
, NPStream
* stream
, const char* fname
)
747 PLUGINDEBUGSTR("\pStreamAsFile;g;");
748 NPP_StreamAsFile(instance
, stream
, fname
);
752 NPError
Private_DestroyStream(NPP instance
, NPStream
* stream
, NPError reason
)
756 PLUGINDEBUGSTR("\pDestroyStream;g;");
757 err
= NPP_DestroyStream(instance
, stream
, reason
);
762 int16_t Private_HandleEvent(NPP instance
, void* event
)
766 PLUGINDEBUGSTR("\pHandleEvent;g;");
767 result
= NPP_HandleEvent(instance
, event
);
772 void Private_Print(NPP instance
, NPPrint
* platformPrint
)
775 PLUGINDEBUGSTR("\pPrint;g;");
776 NPP_Print(instance
, platformPrint
);
780 void Private_URLNotify(NPP instance
, const char* url
, NPReason reason
, void* notifyData
)
783 PLUGINDEBUGSTR("\pURLNotify;g;");
784 NPP_URLNotify(instance
, url
, reason
, notifyData
);
789 jobject
Private_GetJavaClass(void)
792 PLUGINDEBUGSTR("\pGetJavaClass;g;");
794 jobject clazz
= NPP_GetJavaClass();
798 JRIEnv
* env
= NPN_GetJavaEnv();
799 return (jobject
)JRI_NewGlobalRef(env
, clazz
);
808 #if !TARGET_API_MAC_CARBON
809 ProcessSerialNumber PSN
;
812 ProcessInfoRec infoRec
;
813 OSErr result
= noErr
;
814 CFragConnectionID connID
;
819 // Memorize the plugin’s resource file
820 // refnum for later use.
822 gResFile
= CurResFile();
824 #if !TARGET_API_MAC_CARBON
826 // Ask the system if CFM is available.
829 OSErr err
= Gestalt(gestaltCFMAttr
, &response
);
830 Boolean hasCFM
= BitTst(&response
, 31-gestaltCFMPresent
);
832 ProcessInfoRec infoRec
;
836 // GetProcessInformation takes a process serial number and
837 // will give us back the name and FSSpec of the application.
838 // See the Process Manager in IM.
842 infoRec
.processInfoLength
= sizeof(ProcessInfoRec
);
843 infoRec
.processName
= name
;
844 infoRec
.processAppSpec
= &myFSSpec
;
846 ProcessSerialNumber PSN
;
847 PSN
.highLongOfPSN
= 0;
848 PSN
.lowLongOfPSN
= kCurrentProcess
;
850 result
= GetProcessInformation(&PSN
, &infoRec
);
852 PLUGINDEBUGSTR("\pFailed in GetProcessInformation");
856 // If no CFM installed, assume it must be a 68K app.
860 CFragConnectionID connID
;
864 // Now that we know the app name and FSSpec, we can call GetDiskFragment
865 // to get a connID to use in a subsequent call to FindSymbol (it will also
866 // return the address of “main” in app, which we ignore). If GetDiskFragment
867 // returns an error, we assume the app must be 68K.
871 result
= GetDiskFragment(infoRec
.processAppSpec
, 0L, 0L, infoRec
.processName
,
872 kLoadCFrag
, &connID
, (Ptr
*)&mainAddr
, errName
);
878 // The app is a PPC code fragment, so call FindSymbol
879 // to get the exported “qd” symbol so we can access its
880 // QuickDraw globals.
882 CFragSymbolClass symClass
;
883 result
= FindSymbol(connID
, "\pqd", (Ptr
*)&gQDPtr
, &symClass
);
884 if (result
!= noErr
) { // this fails if we are in NS 6
885 gQDPtr
= &qd
; // so we default to the standard QD globals
891 // The app is 68K, so use its A5 to compute the address
892 // of its QuickDraw globals.
894 gQDPtr
= (QDGlobals
*)(*((long*)SetCurrentA5()) - (sizeof(QDGlobals
) - sizeof(GrafPtr
)));
900 // gcc requires that main have an 'int' return type
901 typedef int main_return_t
;
903 typedef NPError mainReturnType
;
906 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
907 typedef NPP_ShutdownUPP unloadupp_t
;
909 typedef NPP_ShutdownProcPtr unloadupp_t
;
913 main_return_t
main(NPNetscapeFuncs
* nsTable
, NPPluginFuncs
* pluginFuncs
, unloadupp_t
* unloadUpp
);
915 #if !TARGET_API_MAC_CARBON
918 #if TARGET_RT_MAC_CFM
920 RoutineDescriptor mainRD
= BUILD_ROUTINE_DESCRIPTOR(uppNPP_MainEntryProcInfo
, main
);
925 #endif /* !TARGET_API_MAC_CARBON */
927 DEFINE_API_C(main_return_t
) main(NPNetscapeFuncs
* nsTable
, NPPluginFuncs
* pluginFuncs
, unloadupp_t
* unloadUpp
)
930 PLUGINDEBUGSTR("\pmain");
936 NPError err
= NPERR_NO_ERROR
;
939 // Ensure that everything Netscape passed us is valid!
941 if ((nsTable
== NULL
) || (pluginFuncs
== NULL
) || (unloadUpp
== NULL
))
942 err
= NPERR_INVALID_FUNCTABLE_ERROR
;
945 // Check the “major” version passed in Netscape’s function table.
946 // We won’t load if the major version is newer than what we expect.
947 // Also check that the function tables passed in are big enough for
948 // all the functions we need (they could be bigger, if Netscape added
949 // new APIs, but that’s OK with us -- we’ll just ignore them).
951 if (err
== NPERR_NO_ERROR
)
953 if ((nsTable
->version
>> 8) > NP_VERSION_MAJOR
) // Major version is in high byte
954 err
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
957 if (err
== NPERR_NO_ERROR
)
960 // Copy all the fields of Netscape’s function table into our
961 // copy so we can call back into Netscape later. Note that
962 // we need to copy the fields one by one, rather than assigning
963 // the whole structure, because the Netscape function table
964 // could actually be bigger than what we expect.
967 int navMinorVers
= nsTable
->version
& 0xFF;
969 gNetscapeFuncs
.version
= nsTable
->version
;
970 gNetscapeFuncs
.size
= nsTable
->size
;
971 gNetscapeFuncs
.posturl
= HOST_TO_PLUGIN_GLUE(posturl
, nsTable
->posturl
);
972 gNetscapeFuncs
.geturl
= HOST_TO_PLUGIN_GLUE(geturl
, nsTable
->geturl
);
973 gNetscapeFuncs
.requestread
= HOST_TO_PLUGIN_GLUE(requestread
, nsTable
->requestread
);
974 gNetscapeFuncs
.newstream
= HOST_TO_PLUGIN_GLUE(newstream
, nsTable
->newstream
);
975 gNetscapeFuncs
.write
= HOST_TO_PLUGIN_GLUE(write
, nsTable
->write
);
976 gNetscapeFuncs
.destroystream
= HOST_TO_PLUGIN_GLUE(destroystream
, nsTable
->destroystream
);
977 gNetscapeFuncs
.status
= HOST_TO_PLUGIN_GLUE(status
, nsTable
->status
);
978 gNetscapeFuncs
.uagent
= HOST_TO_PLUGIN_GLUE(uagent
, nsTable
->uagent
);
979 gNetscapeFuncs
.memalloc
= HOST_TO_PLUGIN_GLUE(memalloc
, nsTable
->memalloc
);
980 gNetscapeFuncs
.memfree
= HOST_TO_PLUGIN_GLUE(memfree
, nsTable
->memfree
);
981 gNetscapeFuncs
.memflush
= HOST_TO_PLUGIN_GLUE(memflush
, nsTable
->memflush
);
982 gNetscapeFuncs
.reloadplugins
= HOST_TO_PLUGIN_GLUE(reloadplugins
, nsTable
->reloadplugins
);
983 if( navMinorVers
>= NPVERS_HAS_LIVECONNECT
)
985 gNetscapeFuncs
.getJavaEnv
= HOST_TO_PLUGIN_GLUE(getJavaEnv
, nsTable
->getJavaEnv
);
986 gNetscapeFuncs
.getJavaPeer
= HOST_TO_PLUGIN_GLUE(getJavaPeer
, nsTable
->getJavaPeer
);
988 if( navMinorVers
>= NPVERS_HAS_NOTIFICATION
)
990 gNetscapeFuncs
.geturlnotify
= HOST_TO_PLUGIN_GLUE(geturlnotify
, nsTable
->geturlnotify
);
991 gNetscapeFuncs
.posturlnotify
= HOST_TO_PLUGIN_GLUE(posturlnotify
, nsTable
->posturlnotify
);
993 gNetscapeFuncs
.getvalue
= HOST_TO_PLUGIN_GLUE(getvalue
, nsTable
->getvalue
);
994 gNetscapeFuncs
.setvalue
= HOST_TO_PLUGIN_GLUE(setvalue
, nsTable
->setvalue
);
995 gNetscapeFuncs
.invalidaterect
= HOST_TO_PLUGIN_GLUE(invalidaterect
, nsTable
->invalidaterect
);
996 gNetscapeFuncs
.invalidateregion
= HOST_TO_PLUGIN_GLUE(invalidateregion
, nsTable
->invalidateregion
);
997 gNetscapeFuncs
.forceredraw
= HOST_TO_PLUGIN_GLUE(forceredraw
, nsTable
->forceredraw
);
998 if( navMinorVers
>= 14 )
1000 // NPRuntime support
1001 gNetscapeFuncs
.getstringidentifier
= HOST_TO_PLUGIN_GLUE(getstringidentifier
, nsTable
->getstringidentifier
);
1002 gNetscapeFuncs
.getstringidentifiers
= HOST_TO_PLUGIN_GLUE(getstringidentifiers
, nsTable
->getstringidentifiers
);
1003 gNetscapeFuncs
.getintidentifier
= HOST_TO_PLUGIN_GLUE(getintidentifier
, nsTable
->getintidentifier
);
1004 gNetscapeFuncs
.identifierisstring
= HOST_TO_PLUGIN_GLUE(identifierisstring
, nsTable
->identifierisstring
);
1005 gNetscapeFuncs
.utf8fromidentifier
= HOST_TO_PLUGIN_GLUE(utf8fromidentifier
, nsTable
->utf8fromidentifier
);
1006 gNetscapeFuncs
.intfromidentifier
= HOST_TO_PLUGIN_GLUE(intfromidentifier
, nsTable
->intfromidentifier
);
1007 gNetscapeFuncs
.createobject
= HOST_TO_PLUGIN_GLUE(createobject
, nsTable
->createobject
);
1008 gNetscapeFuncs
.retainobject
= HOST_TO_PLUGIN_GLUE(retainobject
, nsTable
->retainobject
);
1009 gNetscapeFuncs
.releaseobject
= HOST_TO_PLUGIN_GLUE(releaseobject
, nsTable
->releaseobject
);
1010 gNetscapeFuncs
.invoke
= HOST_TO_PLUGIN_GLUE(invoke
, nsTable
->invoke
);
1011 gNetscapeFuncs
.invokeDefault
= HOST_TO_PLUGIN_GLUE(invokeDefault
, nsTable
->invokeDefault
);
1012 gNetscapeFuncs
.evaluate
= HOST_TO_PLUGIN_GLUE(evaluate
, nsTable
->evaluate
);
1013 gNetscapeFuncs
.getproperty
= HOST_TO_PLUGIN_GLUE(getproperty
, nsTable
->getproperty
);
1014 gNetscapeFuncs
.setproperty
= HOST_TO_PLUGIN_GLUE(setproperty
, nsTable
->setproperty
);
1015 gNetscapeFuncs
.removeproperty
= HOST_TO_PLUGIN_GLUE(removeproperty
, nsTable
->removeproperty
);
1016 gNetscapeFuncs
.hasproperty
= HOST_TO_PLUGIN_GLUE(hasproperty
, nsTable
->hasproperty
);
1017 gNetscapeFuncs
.hasmethod
= HOST_TO_PLUGIN_GLUE(hasmethod
, nsTable
->hasmethod
);
1018 gNetscapeFuncs
.releasevariantvalue
= HOST_TO_PLUGIN_GLUE(releasevariantvalue
, nsTable
->releasevariantvalue
);
1019 gNetscapeFuncs
.setexception
= HOST_TO_PLUGIN_GLUE(setexception
, nsTable
->setexception
);
1023 // Set up the plugin function table that Netscape will use to
1024 // call us. Netscape needs to know about our version and size
1025 // and have a UniversalProcPointer for every function we implement.
1027 pluginFuncs
->version
= (NP_VERSION_MAJOR
<< 8) + NP_VERSION_MINOR
;
1028 pluginFuncs
->size
= sizeof(NPPluginFuncs
);
1029 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
1030 pluginFuncs
->newp
= NewNPP_NewProc(PLUGIN_TO_HOST_GLUE(newp
, Private_New
));
1031 pluginFuncs
->destroy
= NewNPP_DestroyProc(PLUGIN_TO_HOST_GLUE(destroy
, Private_Destroy
));
1032 pluginFuncs
->setwindow
= NewNPP_SetWindowProc(PLUGIN_TO_HOST_GLUE(setwindow
, Private_SetWindow
));
1033 pluginFuncs
->newstream
= NewNPP_NewStreamProc(PLUGIN_TO_HOST_GLUE(newstream
, Private_NewStream
));
1034 pluginFuncs
->destroystream
= NewNPP_DestroyStreamProc(PLUGIN_TO_HOST_GLUE(destroystream
, Private_DestroyStream
));
1035 pluginFuncs
->asfile
= NewNPP_StreamAsFileProc(PLUGIN_TO_HOST_GLUE(asfile
, Private_StreamAsFile
));
1036 pluginFuncs
->writeready
= NewNPP_WriteReadyProc(PLUGIN_TO_HOST_GLUE(writeready
, Private_WriteReady
));
1037 pluginFuncs
->write
= NewNPP_WriteProc(PLUGIN_TO_HOST_GLUE(write
, Private_Write
));
1038 pluginFuncs
->print
= NewNPP_PrintProc(PLUGIN_TO_HOST_GLUE(print
, Private_Print
));
1039 pluginFuncs
->event
= NewNPP_HandleEventProc(PLUGIN_TO_HOST_GLUE(event
, Private_HandleEvent
));
1040 pluginFuncs
->getvalue
= NewNPP_GetValueProc(PLUGIN_TO_HOST_GLUE(getvalue
, Private_GetValue
));
1042 pluginFuncs
->newp
= (NPP_NewProcPtr
)(PLUGIN_TO_HOST_GLUE(newp
, Private_New
));
1043 pluginFuncs
->destroy
= (NPP_DestroyProcPtr
)(PLUGIN_TO_HOST_GLUE(destroy
, Private_Destroy
));
1044 pluginFuncs
->setwindow
= (NPP_SetWindowProcPtr
)(PLUGIN_TO_HOST_GLUE(setwindow
, Private_SetWindow
));
1045 pluginFuncs
->newstream
= (NPP_NewStreamProcPtr
)(PLUGIN_TO_HOST_GLUE(newstream
, Private_NewStream
));
1046 pluginFuncs
->destroystream
= (NPP_DestroyStreamProcPtr
)(PLUGIN_TO_HOST_GLUE(destroystream
, Private_DestroyStream
));
1047 pluginFuncs
->asfile
= (NPP_StreamAsFileProcPtr
)(PLUGIN_TO_HOST_GLUE(asfile
, Private_StreamAsFile
));
1048 pluginFuncs
->writeready
= (NPP_WriteReadyProcPtr
)(PLUGIN_TO_HOST_GLUE(writeready
, Private_WriteReady
));
1049 pluginFuncs
->write
= (NPP_WriteProcPtr
)(PLUGIN_TO_HOST_GLUE(write
, Private_Write
));
1050 pluginFuncs
->print
= (NPP_PrintProcPtr
)(PLUGIN_TO_HOST_GLUE(print
, Private_Print
));
1051 pluginFuncs
->event
= (NPP_HandleEventProcPtr
)(PLUGIN_TO_HOST_GLUE(event
, Private_HandleEvent
));
1052 pluginFuncs
->getvalue
= (NPP_GetValueProcPtr
)(PLUGIN_TO_HOST_GLUE(getvalue
, Private_GetValue
));
1054 if( navMinorVers
>= NPVERS_HAS_NOTIFICATION
)
1056 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
1057 pluginFuncs
->urlnotify
= NewNPP_URLNotifyProc(PLUGIN_TO_HOST_GLUE(urlnotify
, Private_URLNotify
));
1059 pluginFuncs
->urlnotify
= (NPP_URLNotifyProcPtr
)(PLUGIN_TO_HOST_GLUE(urlnotify
, Private_URLNotify
));
1063 if( navMinorVers
>= NPVERS_HAS_LIVECONNECT
)
1065 pluginFuncs
->javaClass
= (JRIGlobalRef
) Private_GetJavaClass();
1068 pluginFuncs
->javaClass
= NULL
;
1070 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
1071 *unloadUpp
= NewNPP_ShutdownProc(PLUGIN_TO_HOST_GLUE(shutdown
, Private_Shutdown
));
1073 *unloadUpp
= (NPP_ShutdownProcPtr
)(PLUGIN_TO_HOST_GLUE(shutdown
, Private_Shutdown
));
1076 err
= Private_Initialize();
1086 ** netscape plugins functions when building Mach-O binary
1090 NPError
NP_Initialize(NPNetscapeFuncs
* nsTable
);
1091 NPError
NP_GetEntryPoints(NPPluginFuncs
* pluginFuncs
);
1092 NPError
NP_Shutdown(void);
1096 ** netscape plugins functions when using Mach-O binary
1099 NPError
NP_Initialize(NPNetscapeFuncs
* nsTable
)
1101 PLUGINDEBUGSTR("\pNP_Initialize");
1103 /* validate input parameters */
1105 if( NULL
== nsTable
)
1106 return NPERR_INVALID_FUNCTABLE_ERROR
;
1109 * Check the major version passed in Netscape's function table.
1110 * We won't load if the major version is newer than what we expect.
1111 * Also check that the function tables passed in are big enough for
1112 * all the functions we need (they could be bigger, if Netscape added
1113 * new APIs, but that's OK with us -- we'll just ignore them).
1117 if ((nsTable
->version
>> 8) > NP_VERSION_MAJOR
)
1118 return NPERR_INCOMPATIBLE_VERSION_ERROR
;
1120 if (nsTable
->size
< sizeof(NPNetscapeFuncs
))
1121 return NPERR_INVALID_FUNCTABLE_ERROR
;
1123 int navMinorVers
= nsTable
->version
& 0xFF;
1126 * Copy all the fields of Netscape function table into our
1127 * copy so we can call back into Netscape later. Note that
1128 * we need to copy the fields one by one, rather than assigning
1129 * the whole structure, because the Netscape function table
1130 * could actually be bigger than what we expect.
1132 gNetscapeFuncs
.version
= nsTable
->version
;
1133 gNetscapeFuncs
.size
= nsTable
->size
;
1134 gNetscapeFuncs
.posturl
= nsTable
->posturl
;
1135 gNetscapeFuncs
.geturl
= nsTable
->geturl
;
1136 gNetscapeFuncs
.requestread
= nsTable
->requestread
;
1137 gNetscapeFuncs
.newstream
= nsTable
->newstream
;
1138 gNetscapeFuncs
.write
= nsTable
->write
;
1139 gNetscapeFuncs
.destroystream
= nsTable
->destroystream
;
1140 gNetscapeFuncs
.status
= nsTable
->status
;
1141 gNetscapeFuncs
.uagent
= nsTable
->uagent
;
1142 gNetscapeFuncs
.memalloc
= nsTable
->memalloc
;
1143 gNetscapeFuncs
.memfree
= nsTable
->memfree
;
1144 gNetscapeFuncs
.memflush
= nsTable
->memflush
;
1145 gNetscapeFuncs
.reloadplugins
= nsTable
->reloadplugins
;
1146 if( navMinorVers
>= NPVERS_HAS_LIVECONNECT
)
1148 gNetscapeFuncs
.getJavaEnv
= nsTable
->getJavaEnv
;
1149 gNetscapeFuncs
.getJavaPeer
= nsTable
->getJavaPeer
;
1151 if( navMinorVers
>= NPVERS_HAS_NOTIFICATION
)
1153 gNetscapeFuncs
.geturlnotify
= nsTable
->geturlnotify
;
1154 gNetscapeFuncs
.posturlnotify
= nsTable
->posturlnotify
;
1157 gNetscapeFuncs
.getvalue
= nsTable
->getvalue
;
1158 gNetscapeFuncs
.setvalue
= nsTable
->setvalue
;
1159 gNetscapeFuncs
.invalidaterect
= nsTable
->invalidaterect
;
1160 gNetscapeFuncs
.invalidateregion
= nsTable
->invalidateregion
;
1161 gNetscapeFuncs
.forceredraw
= nsTable
->forceredraw
;
1162 if( navMinorVers
>= 14 )
1164 // NPRuntime support
1165 gNetscapeFuncs
.getstringidentifier
= nsTable
->getstringidentifier
;
1166 gNetscapeFuncs
.getstringidentifiers
= nsTable
->getstringidentifiers
;
1167 gNetscapeFuncs
.getintidentifier
= nsTable
->getintidentifier
;
1168 gNetscapeFuncs
.identifierisstring
= nsTable
->identifierisstring
;
1169 gNetscapeFuncs
.utf8fromidentifier
= nsTable
->utf8fromidentifier
;
1170 gNetscapeFuncs
.intfromidentifier
= nsTable
->intfromidentifier
;
1171 gNetscapeFuncs
.createobject
= nsTable
->createobject
;
1172 gNetscapeFuncs
.retainobject
= nsTable
->retainobject
;
1173 gNetscapeFuncs
.releaseobject
= nsTable
->releaseobject
;
1174 gNetscapeFuncs
.invoke
= nsTable
->invoke
;
1175 gNetscapeFuncs
.invokeDefault
= nsTable
->invokeDefault
;
1176 gNetscapeFuncs
.evaluate
= nsTable
->evaluate
;
1177 gNetscapeFuncs
.getproperty
= nsTable
->getproperty
;
1178 gNetscapeFuncs
.setproperty
= nsTable
->setproperty
;
1179 gNetscapeFuncs
.removeproperty
= nsTable
->removeproperty
;
1180 gNetscapeFuncs
.hasproperty
= nsTable
->hasproperty
;
1181 gNetscapeFuncs
.hasmethod
= nsTable
->hasmethod
;
1182 gNetscapeFuncs
.releasevariantvalue
= nsTable
->releasevariantvalue
;
1183 gNetscapeFuncs
.setexception
= nsTable
->setexception
;
1185 return NPP_Initialize();
1188 NPError
NP_GetEntryPoints(NPPluginFuncs
* pluginFuncs
)
1190 int navMinorVers
= gNetscapeFuncs
.version
& 0xFF;
1192 PLUGINDEBUGSTR("\pNP_GetEntryPoints");
1194 if( pluginFuncs
== NULL
)
1195 return NPERR_INVALID_FUNCTABLE_ERROR
;
1197 /*if (pluginFuncs->size < sizeof(NPPluginFuncs))
1198 return NPERR_INVALID_FUNCTABLE_ERROR;*/
1201 * Set up the plugin function table that Netscape will use to
1202 * call us. Netscape needs to know about our version and size
1203 * and have a UniversalProcPointer for every function we
1207 pluginFuncs
->version
= (NP_VERSION_MAJOR
<< 8) + NP_VERSION_MINOR
;
1208 pluginFuncs
->size
= sizeof(NPPluginFuncs
);
1209 #if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
1210 pluginFuncs
->newp
= NewNPP_NewProc(Private_New
);
1211 pluginFuncs
->destroy
= NewNPP_DestroyProc(Private_Destroy
);
1212 pluginFuncs
->setwindow
= NewNPP_SetWindowProc(Private_SetWindow
);
1213 pluginFuncs
->newstream
= NewNPP_NewStreamProc(Private_NewStream
);
1214 pluginFuncs
->destroystream
= NewNPP_DestroyStreamProc(Private_DestroyStream
);
1215 pluginFuncs
->asfile
= NewNPP_StreamAsFileProc(Private_StreamAsFile
);
1216 pluginFuncs
->writeready
= NewNPP_WriteReadyProc(Private_WriteReady
);
1217 pluginFuncs
->write
= NewNPP_WriteProc(Private_Write
);
1218 pluginFuncs
->print
= NewNPP_PrintProc(Private_Print
);
1219 pluginFuncs
->event
= NewNPP_HandleEventProc(Private_HandleEvent
);
1220 pluginFuncs
->getvalue
= NewNPP_GetValueProc(Private_GetValue
);
1221 pluginFuncs
->setvalue
= NewNPP_SetValueProc(Private_SetValue
);
1223 pluginFuncs
->newp
= (NPP_NewProcPtr
)(Private_New
);
1224 pluginFuncs
->destroy
= (NPP_DestroyProcPtr
)(Private_Destroy
);
1225 pluginFuncs
->setwindow
= (NPP_SetWindowProcPtr
)(Private_SetWindow
);
1226 pluginFuncs
->newstream
= (NPP_NewStreamProcPtr
)(Private_NewStream
);
1227 pluginFuncs
->destroystream
= (NPP_DestroyStreamProcPtr
)(Private_DestroyStream
);
1228 pluginFuncs
->asfile
= (NPP_StreamAsFileProcPtr
)(Private_StreamAsFile
);
1229 pluginFuncs
->writeready
= (NPP_WriteReadyProcPtr
)(Private_WriteReady
);
1230 pluginFuncs
->write
= (NPP_WriteProcPtr
)(Private_Write
);
1231 pluginFuncs
->print
= (NPP_PrintProcPtr
)(Private_Print
);
1232 pluginFuncs
->event
= (NPP_HandleEventProcPtr
)(Private_HandleEvent
);
1233 pluginFuncs
->getvalue
= (NPP_GetValueProcPtr
)(Private_GetValue
);
1234 pluginFuncs
->setvalue
= (NPP_SetValueProcPtr
)(Private_SetValue
);
1236 if( navMinorVers
>= NPVERS_HAS_NOTIFICATION
)
1238 pluginFuncs
->urlnotify
= Private_URLNotify
;
1241 if( navMinorVers
>= NPVERS_HAS_LIVECONNECT
)
1243 pluginFuncs
->javaClass
= (JRIGlobalRef
) Private_GetJavaClass();
1246 pluginFuncs
->javaClass
= NULL
;
1249 return NPERR_NO_ERROR
;
1252 NPError
NP_Shutdown(void)
1254 PLUGINDEBUGSTR("\pNP_Shutdown");
1256 return NPERR_NO_ERROR
;