22 #define NP_EXPORT _export
26 NPNetscapeFuncs
* g_pNavigatorFuncs
= 0;
27 JRIGlobalRef
Private_GetJavaClass(void);
29 //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
30 ////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
31 // Private_GetJavaClass (global function)
33 // Given a Java class reference (thru NPP_GetJavaClass) inform JRT
34 // of this class existence
37 Private_GetJavaClass(void)
39 jref clazz
= NPP_GetJavaClass();
41 JRIEnv
* env
= NPN_GetJavaEnv();
42 return JRI_NewGlobalRef(env
, clazz
);
47 //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
48 ////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
49 // PLUGIN DLL entry points
51 // These are the Windows specific DLL entry points. They must be exoprted
54 // we need these to be global since we have to fill one of its field
55 // with a data (class) which requires knowlwdge of the navigator
56 // jump-table. This jump table is known at Initialize time (NP_Initialize)
57 // which is called after NP_GetEntryPoint
58 static NPPluginFuncs
* g_pluginFuncs
;
60 //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
61 ////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
64 // fills in the func table used by Navigator to call entry points in
65 // plugin DLL. Note that these entry points ensure that DS is loaded
66 // by using the NP_LOADDS macro, when compiling for Win16
68 NPError WINAPI NP_EXPORT
69 NP_GetEntryPoints(NPPluginFuncs
* pFuncs
)
73 return NPERR_INVALID_FUNCTABLE_ERROR
;
75 // if the plugin's function table is smaller than the plugin expects,
76 // then they are incompatible, and should return an error
78 pFuncs
->version
= (NP_VERSION_MAJOR
<< 8) | NP_VERSION_MINOR
;
79 pFuncs
->newp
= NPP_New
;
80 pFuncs
->destroy
= NPP_Destroy
;
81 pFuncs
->setwindow
= NPP_SetWindow
;
82 pFuncs
->newstream
= NPP_NewStream
;
83 pFuncs
->destroystream
= NPP_DestroyStream
;
84 pFuncs
->asfile
= NPP_StreamAsFile
;
85 pFuncs
->writeready
= NPP_WriteReady
;
86 pFuncs
->write
= NPP_Write
;
87 pFuncs
->print
= NPP_Print
;
88 pFuncs
->event
= 0; /// reserved
90 g_pluginFuncs
= pFuncs
;
92 return NPERR_NO_ERROR
;
95 //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
96 ////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
99 // called immediately after the plugin DLL is loaded
101 NPError WINAPI NP_EXPORT
102 NP_Initialize(NPNetscapeFuncs
* pFuncs
)
106 return NPERR_INVALID_FUNCTABLE_ERROR
;
108 g_pNavigatorFuncs
= pFuncs
; // save it for future reference
110 // if the plugin's major ver level is lower than the Navigator's,
111 // then they are incompatible, and should return an error
112 if(HIBYTE(pFuncs
->version
) > NP_VERSION_MAJOR
)
113 return NPERR_INCOMPATIBLE_VERSION_ERROR
;
115 // We have to defer these assignments until g_pNavigatorFuncs is set
116 int navMinorVers
= g_pNavigatorFuncs
->version
& 0xFF;
118 if( navMinorVers
>= NPVERS_HAS_NOTIFICATION
) {
119 g_pluginFuncs
->urlnotify
= NPP_URLNotify
;
122 #ifdef WIN32 // An ugly hack, because Win16 lags behind in Java
123 if( navMinorVers
>= NPVERS_HAS_LIVECONNECT
) {
125 if( navMinorVers
>= NPVERS_WIN16_HAS_LIVECONNECT
) {
127 g_pluginFuncs
->javaClass
= Private_GetJavaClass();
130 // NPP_Initialize is a standard (cross-platform) initialize function.
131 return NPP_Initialize();
134 //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
135 ////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
138 // called immediately before the plugin DLL is unloaded.
139 // This functio shuold check for some ref count on the dll to see if it is
140 // unloadable or it needs to stay in memory.
142 NPError WINAPI NP_EXPORT
146 g_pNavigatorFuncs
= NULL
;
147 return NPERR_NO_ERROR
;
150 // END - PLUGIN DLL entry points
151 ////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
152 //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
154 /* NAVIGATOR Entry points */
156 /* These entry points expect to be called from within the plugin. The
157 noteworthy assumption is that DS has already been set to point to the
158 plugin's DLL data segment. Don't call these functions from outside
159 the plugin without ensuring DS is set to the DLLs data segment first,
160 typically using the NP_LOADDS macro
164 void NPN_InvalidateRect(NPP instance
, NPRect
*rect
)
166 return g_pNavigatorFuncs
->invalidaterect(instance
, rect
);
169 /* returns the major/minor version numbers of the Plugin API for the plugin
172 void NPN_Version(int* plugin_major
, int* plugin_minor
, int* netscape_major
, int* netscape_minor
)
174 *plugin_major
= NP_VERSION_MAJOR
;
175 *plugin_minor
= NP_VERSION_MINOR
;
176 *netscape_major
= HIBYTE(g_pNavigatorFuncs
->version
);
177 *netscape_minor
= LOBYTE(g_pNavigatorFuncs
->version
);
180 /* causes the specified URL to be fetched and streamed in
182 NPError
NPN_GetURLNotify(NPP instance
, const char *url
, const char *target
, void* notifyData
)
184 int navMinorVers
= g_pNavigatorFuncs
->version
& 0xFF;
186 if( navMinorVers
>= NPVERS_HAS_NOTIFICATION
) {
187 err
= g_pNavigatorFuncs
->geturlnotify(instance
, url
, target
, notifyData
);
190 err
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
196 NPError
NPN_GetURL(NPP instance
, const char *url
, const char *target
)
198 return g_pNavigatorFuncs
->geturl(instance
, url
, target
);
201 NPError
NPN_PostURLNotify(NPP instance
, const char* url
, const char* window
, uint32 len
, const char* buf
, NPBool file
, void* notifyData
)
203 int navMinorVers
= g_pNavigatorFuncs
->version
& 0xFF;
205 if( navMinorVers
>= NPVERS_HAS_NOTIFICATION
) {
206 err
= g_pNavigatorFuncs
->posturlnotify(instance
, url
, window
, len
, buf
, file
, notifyData
);
209 err
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
215 NPError
NPN_PostURL(NPP instance
, const char* url
, const char* window
, uint32 len
, const char* buf
, NPBool file
)
217 return g_pNavigatorFuncs
->posturl(instance
, url
, window
, len
, buf
, file
);
220 /* Requests that a number of bytes be provided on a stream. Typically
221 this would be used if a stream was in "pull" mode. An optional
222 position can be provided for streams which are seekable.
224 NPError
NPN_RequestRead(NPStream
* stream
, NPByteRange
* rangeList
)
226 return g_pNavigatorFuncs
->requestread(stream
, rangeList
);
229 /* Creates a new stream of data from the plug-in to be interpreted
230 by Netscape in the current window.
232 NPError
NPN_NewStream(NPP instance
, NPMIMEType type
,
233 const char* target
, NPStream
** stream
)
235 int navMinorVersion
= g_pNavigatorFuncs
->version
& 0xFF;
238 if( navMinorVersion
>= NPVERS_HAS_STREAMOUTPUT
) {
239 err
= g_pNavigatorFuncs
->newstream(instance
, type
, target
, stream
);
242 err
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
247 /* Provides len bytes of data.
249 int32
NPN_Write(NPP instance
, NPStream
*stream
, int32 len
, void *buffer
)
251 int navMinorVersion
= g_pNavigatorFuncs
->version
& 0xFF;
254 if( navMinorVersion
>= NPVERS_HAS_STREAMOUTPUT
) {
255 result
= g_pNavigatorFuncs
->write(instance
, stream
, len
, buffer
);
263 /* Closes a stream object.
264 reason indicates why the stream was closed.
266 NPError
NPN_DestroyStream(NPP instance
, NPStream
* stream
, NPError reason
)
268 int navMinorVersion
= g_pNavigatorFuncs
->version
& 0xFF;
271 if( navMinorVersion
>= NPVERS_HAS_STREAMOUTPUT
) {
272 err
= g_pNavigatorFuncs
->destroystream(instance
, stream
, reason
);
275 err
= NPERR_INCOMPATIBLE_VERSION_ERROR
;
280 /* Provides a text status message in the Netscape client user interface
282 void NPN_Status(NPP instance
, const char *message
)
284 g_pNavigatorFuncs
->status(instance
, message
);
287 /* returns the user agent string of Navigator, which contains version info
289 const char* NPN_UserAgent(NPP instance
)
291 return g_pNavigatorFuncs
->uagent(instance
);
294 /* allocates memory from the Navigator's memory space. Necessary so that
295 saved instance data may be freed by Navigator when exiting.
299 void* NPN_MemAlloc(uint32 size
)
301 return g_pNavigatorFuncs
->memalloc(size
);
304 /* reciprocal of MemAlloc() above
306 void NPN_MemFree(void* ptr
)
308 g_pNavigatorFuncs
->memfree(ptr
);
311 /* private function to Netscape. do not use!
313 void NPN_ReloadPlugins(NPBool reloadPages
)
315 g_pNavigatorFuncs
->reloadplugins(reloadPages
);
318 JRIEnv
* NPN_GetJavaEnv(void)
320 return g_pNavigatorFuncs
->getJavaEnv();
323 jref
NPN_GetJavaPeer(NPP instance
)
325 return g_pNavigatorFuncs
->getJavaPeer(instance
);