1 /* -*- Mode: C; tab-width: 4; -*- */
2 /*
3  *  npapi.h $Revision: 1.3 $
4  *  Netscape client plug-in API spec
5  */
6 
7 #ifndef _NPAPI_H_
8 #define _NPAPI_H_
9 
10 #include "jri.h"		/* Java Runtime Interface */
11 
12 
13 /* XXX this needs to get out of here */
14 #if defined(__MWERKS__)
15 #ifndef XP_MAC
16 #define XP_MAC
17 #endif
18 #endif
19 
20 
21 
22 /*----------------------------------------------------------------------*/
23 /*                   Plugin Version Constants                           */
24 /*----------------------------------------------------------------------*/
25 
26 #define NP_VERSION_MAJOR 0
27 #define NP_VERSION_MINOR 9
28 
29 
30 
31 /*----------------------------------------------------------------------*/
32 /*                   Definition of Basic Types                          */
33 /*----------------------------------------------------------------------*/
34 
35 #ifndef _UINT16
36 typedef unsigned short uint16;
37 #endif
38 #ifndef _UINT32
39 #if defined(__alpha)
40 typedef unsigned int uint32;
41 #else /* __alpha */
42 typedef unsigned long uint32;
43 #endif /* __alpha */
44 #endif
45 #ifndef _INT16
46 typedef short int16;
47 #endif
48 #ifndef _INT32
49 #if defined(__alpha)
50 typedef int int32;
51 #else /* __alpha */
52 typedef long int32;
53 #endif /* __alpha */
54 #endif
55 
56 #ifndef FALSE
57 #define FALSE (0)
58 #endif
59 #ifndef TRUE
60 #define TRUE (1)
61 #endif
62 #ifndef NULL
63 #define NULL (0L)
64 #endif
65 
66 typedef unsigned char	NPBool;
67 typedef void*			NPEvent;
68 typedef int16			NPError;
69 typedef int16			NPReason;
70 typedef char*			NPMIMEType;
71 
72 
73 
74 /*----------------------------------------------------------------------*/
75 /*                   Structures and definitions                         */
76 /*----------------------------------------------------------------------*/
77 
78 /*
79  *  NPP is a plug-in's opaque instance handle
80  */
81 typedef struct _NPP
82 {
83     void*	pdata;			/* plug-in private data */
84     void*	ndata;			/* netscape private data */
85 } NPP_t;
86 
87 typedef NPP_t*  NPP;
88 
89 
90 typedef struct _NPStream
91 {
92     void*		pdata;		/* plug-in private data */
93     void*		ndata;		/* netscape private data */
94     const char*		url;
95     uint32		end;
96     uint32		lastmodified;
97     void*		notifyData;
98 } NPStream;
99 
100 
101 typedef struct _NPByteRange
102 {
103     int32	offset;			/* negative offset means from the end */
104     uint32	length;
105     struct _NPByteRange* next;
106 } NPByteRange;
107 
108 
109 typedef struct _NPSavedData
110 {
111     int32	len;
112     void*	buf;
113 } NPSavedData;
114 
115 
116 typedef struct _NPRect
117 {
118     uint16	top;
119     uint16	left;
120     uint16	bottom;
121     uint16	right;
122 } NPRect;
123 
124 
125 #ifdef XP_UNIX
126 /*
127  * Unix specific structures and definitions
128  */
129 #include <X11/Xlib.h>
130 
131 /*
132  * Callback Structures.
133  *
134  * These are used to pass additional platform specific information.
135  */
136 enum {
137 	NP_SETWINDOW = 1
138 };
139 
140 typedef struct
141 {
142     int32		type;
143 } NPAnyCallbackStruct;
144 
145 typedef struct
146 {
147     int32			type;
148     Display*		display;
149     Visual*			visual;
150     Colormap		colormap;
151     unsigned int	depth;
152 } NPSetWindowCallbackStruct;
153 
154 /*
155  * List of variable names for which NPP_GetValue shall be implemented
156  */
157 typedef enum {
158 	NPPVpluginNameString = 1,
159 	NPPVpluginDescriptionString
160 } NPPVariable;
161 
162 /*
163  * List of variable names for which NPN_GetValue is implemented by Mozilla
164  */
165 typedef enum {
166 	NPNVxDisplay = 1,
167 	NPNVxtAppContext
168 } NPNVariable;
169 
170 #endif /* XP_UNIX */
171 
172 
173 typedef struct _NPWindow
174 {
175     void*	window;		/* Platform specific window handle */
176     uint32	x;			/* Position of top left corner relative */
177     uint32	y; 			/*	to a netscape page.					*/
178     uint32	width;		/* Maximum window size */
179     uint32	height;
180     NPRect	clipRect;	/* Clipping rectangle in port coordinates */
181 						/* Used by MAC only.                      */
182 #ifdef XP_UNIX
183     void *	ws_info;	/* Platform-dependent additonal data */
184 #endif /* XP_UNIX */
185 } NPWindow;
186 
187 
188 typedef struct _NPFullPrint
189 {
190     NPBool	pluginPrinted;	/* Set TRUE if plugin handled fullscreen */
191 							/*	printing							 */
192     NPBool	printOne;		/* TRUE if plugin should print one copy  */
193 							/*	to default printer					 */
194     void*	platformPrint;	/* Platform-specific printing info */
195 } NPFullPrint;
196 
197 typedef struct _NPEmbedPrint
198 {
199     NPWindow	window;
200     void*	platformPrint;	/* Platform-specific printing info */
201 } NPEmbedPrint;
202 
203 typedef struct _NPPrint
204 {
205     uint16	mode;						/* NP_FULL or NP_EMBED */
206     union
207     {
208 		NPFullPrint		fullPrint;		/* if mode is NP_FULL */
209 		NPEmbedPrint	embedPrint;		/* if mode is NP_EMBED */
210     } print;
211 } NPPrint;
212 
213 
214 #ifdef XP_MAC
215 /*
216  *  Mac-specific structures and definitions.
217  */
218 
219 #include <Quickdraw.h>
220 #include <Events.h>
221 
222 typedef struct NP_Port
223 {
224     CGrafPtr	port;		/* Grafport */
225     int32		portx;		/* position inside the topmost window */
226     int32		porty;
227 } NP_Port;
228 
229 /*
230  *  Non-standard event types that can be passed to HandleEvent
231  */
232 #define getFocusEvent       (osEvt + 16)
233 #define loseFocusEvent      (osEvt + 17)
234 #define adjustCursorEvent   (osEvt + 18)
235 
236 #endif /* XP_MAC */
237 
238 
239 /*
240  * Values for mode passed to NPP_New:
241  */
242 #define NP_EMBED		1
243 #define NP_FULL			2
244 
245 /*
246  * Values for stream type passed to NPP_NewStream:
247  */
248 #define NP_NORMAL		1
249 #define NP_SEEK			2
250 #define NP_ASFILE		3
251 #define NP_ASFILEONLY		4
252 
253 #define NP_MAXREADY	(((unsigned)(~0)<<1)>>1)
254 
255 
256 
257 /*----------------------------------------------------------------------*/
258 /*                   Error and Reason Code definitions                  */
259 /*----------------------------------------------------------------------*/
260 
261 /*
262  *	Values of type NPError:
263  */
264 #define NPERR_BASE							0
265 #define NPERR_NO_ERROR						(NPERR_BASE + 0)
266 #define NPERR_GENERIC_ERROR					(NPERR_BASE + 1)
267 #define NPERR_INVALID_INSTANCE_ERROR		(NPERR_BASE + 2)
268 #define NPERR_INVALID_FUNCTABLE_ERROR		(NPERR_BASE + 3)
269 #define NPERR_MODULE_LOAD_FAILED_ERROR		(NPERR_BASE + 4)
270 #define NPERR_OUT_OF_MEMORY_ERROR			(NPERR_BASE + 5)
271 #define NPERR_INVALID_PLUGIN_ERROR			(NPERR_BASE + 6)
272 #define NPERR_INVALID_PLUGIN_DIR_ERROR		(NPERR_BASE + 7)
273 #define NPERR_INCOMPATIBLE_VERSION_ERROR	(NPERR_BASE + 8)
274 #define NPERR_INVALID_PARAM 				(NPERR_BASE + 9)
275 #define NPERR_INVALID_URL 					(NPERR_BASE + 10)
276 #define NPERR_FILE_NOT_FOUND 				(NPERR_BASE + 11)
277 #define NPERR_NO_DATA		 				(NPERR_BASE + 12)
278 #define NPERR_STREAM_NOT_SEEKABLE			(NPERR_BASE + 13)
279 
280 /*
281  *	Values of type NPReason:
282  */
283 #define NPRES_BASE                      	0
284 #define NPRES_DONE			               	(NPRES_BASE + 0)
285 #define NPRES_NETWORK_ERR               	(NPRES_BASE + 1)
286 #define NPRES_USER_BREAK                	(NPRES_BASE + 2)
287 
288 /*
289  *	Don't use these obsolete error codes any more.
290  */
291 #define NP_NOERR  NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
292 #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
293 #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
294 
295 /*
296  * Version feature information
297  */
298 #define NPVERS_HAS_STREAMOUTPUT		8
299 #define NPVERS_HAS_NOTIFICATION		9
300 #define NPVERS_HAS_LIVECONNECT		9
301 
302 
303 /*----------------------------------------------------------------------*/
304 /*                   Function Prototypes                                */
305 /*----------------------------------------------------------------------*/
306 
307 #if defined(_WINDOWS) && !defined(WIN32)
308 #define NP_LOADDS  _loadds
309 #else
310 #define NP_LOADDS
311 #endif
312 
313 #ifdef __cplusplus
314 extern "C" {
315 #endif
316 
317 /*
318  * NPP_* functions are provided by the plugin and called by the navigator.
319  */
320 
321 #ifdef XP_UNIX
322 char*					NPP_GetMIMEDescription(void);
323 NPError					NPP_GetValue(void *instance, NPPVariable variable,
324 									 void *value);
325 #endif /* XP_UNIX */
326 NPError               	NPP_Initialize(void);
327 void                  	NPP_Shutdown(void);
328 NPError     NP_LOADDS	NPP_New(NPMIMEType pluginType, NPP instance,
329 								uint16 mode, int16 argc, char* argn[],
330 								char* argv[], NPSavedData* saved);
331 NPError     NP_LOADDS	NPP_Destroy(NPP instance, NPSavedData** save);
332 NPError     NP_LOADDS	NPP_SetWindow(NPP instance, NPWindow* window);
333 NPError     NP_LOADDS	NPP_NewStream(NPP instance, NPMIMEType type,
334 									  NPStream* stream, NPBool seekable,
335 									  uint16* stype);
336 NPError     NP_LOADDS	NPP_DestroyStream(NPP instance, NPStream* stream,
337 										  NPReason reason);
338 int32       NP_LOADDS	NPP_WriteReady(NPP instance, NPStream* stream);
339 int32       NP_LOADDS	NPP_Write(NPP instance, NPStream* stream, int32 offset,
340 								  int32 len, void* buffer);
341 void        NP_LOADDS	NPP_StreamAsFile(NPP instance, NPStream* stream,
342 										 const char* fname);
343 void        NP_LOADDS	NPP_Print(NPP instance, NPPrint* platformPrint);
344 int16                 	NPP_HandleEvent(NPP instance, void* event);
345 void                 	NPP_URLNotify(NPP instance, const char* url,
346 									  NPReason reason, void* notifyData);
347 jref					NPP_GetJavaClass(void);
348 
349 
350 /*
351  * NPN_* functions are provided by the navigator and called by the plugin.
352  */
353 
354 #ifdef XP_UNIX
355 NPError			NPN_GetValue(NPP instance, NPNVariable variable,
356 							 void *value);
357 #endif /* XP_UNIX */
358 void        	NPN_Version(int* plugin_major, int* plugin_minor,
359 							int* netscape_major, int* netscape_minor);
360 NPError     	NPN_GetURLNotify(NPP instance, const char* url,
361 								 const char* target, void* notifyData);
362 NPError     	NPN_GetURL(NPP instance, const char* url,
363 						   const char* target);
364 NPError     	NPN_PostURLNotify(NPP instance, const char* url,
365 								  const char* target, uint32 len,
366 								  const char* buf, NPBool file,
367 								  void* notifyData);
368 NPError     	NPN_PostURL(NPP instance, const char* url,
369 							const char* target, uint32 len,
370 							const char* buf, NPBool file);
371 NPError     	NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
372 NPError     	NPN_NewStream(NPP instance, NPMIMEType type,
373 							  const char* target, NPStream** stream);
374 int32       	NPN_Write(NPP instance, NPStream* stream, int32 len,
375 						  void* buffer);
376 NPError    		NPN_DestroyStream(NPP instance, NPStream* stream,
377 								  NPReason reason);
378 void        	NPN_Status(NPP instance, const char* message);
379 const char* 	NPN_UserAgent(NPP instance);
380 void*       	NPN_MemAlloc(uint32 size);
381 void        	NPN_MemFree(void* ptr);
382 uint32      	NPN_MemFlush(uint32 size);
383 void			NPN_ReloadPlugins(NPBool reloadPages);
384 JRIEnv*			NPN_GetJavaEnv(void);
385 jref			NPN_GetJavaPeer(NPP instance);
386 
387 
388 #ifdef __cplusplus
389 }  /* end extern "C" */
390 #endif
391 
392 #endif /* _NPAPI_H_ */
393