merge the formfield patch from ooo-build
[ooovba.git] / np_sdk / mozsrc / npapi.h
blobaf64042804ccb9864cb375b60998e2ac1a09ea12
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Netscape Public License
6 * Version 1.1 (the "License"); you may not use this file except in
7 * compliance with the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/NPL/
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
13 * License.
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.
22 * Contributor(s):
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the NPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the NPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
41 * npapi.h $Revision: 1.2 $
42 * Netscape client plug-in API spec
45 #ifndef _NPAPI_H_
46 #define _NPAPI_H_
48 #ifdef __OS2__
49 #pragma pack(1)
50 #endif
52 #include "jri.h" /* Java Runtime Interface */
54 #if defined (__OS2__ ) || defined (OS2)
55 # ifndef XP_OS2
56 # define XP_OS2 1
57 # endif /* XP_OS2 */
58 #endif /* __OS2__ */
60 #ifdef _WINDOWS
61 # ifndef XP_WIN
62 # define XP_WIN 1
63 # endif /* XP_WIN */
64 #endif /* _WINDOWS */
66 #ifdef __MWERKS__
67 # define _declspec __declspec
68 # ifdef macintosh
69 # ifndef XP_MAC
70 # define XP_MAC 1
71 # endif /* XP_MAC */
72 # endif /* macintosh */
73 # ifdef __INTEL__
74 # undef NULL
75 # ifndef XP_WIN
76 # define XP_WIN 1
77 # endif /* __INTEL__ */
78 # endif /* XP_PC */
79 #endif /* __MWERKS__ */
81 #ifdef XP_MAC
82 #include <Quickdraw.h>
83 #include <Events.h>
84 #endif
86 #if defined(XP_UNIX) && !defined(NO_X11)
87 #include <X11/Xlib.h>
88 #include <X11/Xutil.h>
89 #endif
91 /*----------------------------------------------------------------------*/
92 /* Plugin Version Constants */
93 /*----------------------------------------------------------------------*/
95 #define NP_VERSION_MAJOR 0
96 #define NP_VERSION_MINOR 13
99 /* The OS/2 version of Netscape uses RC_DATA to define the
100 mime types, file extentions, etc that are required.
101 Use a vertical bar to seperate types, end types with \0.
102 FileVersion and ProductVersion are 32bit ints, all other
103 entries are strings the MUST be terminated wwith a \0.
105 AN EXAMPLE:
107 RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
109 RCDATA NP_INFO_MIMEType { "video/x-video|",
110 "video/x-flick\0" }
111 RCDATA NP_INFO_FileExtents { "avi|",
112 "flc\0" }
113 RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
114 "MMOS2 Flc/Fli player(*.flc)\0" }
116 RCDATA NP_INFO_FileVersion { 1,0,0,1 }
117 RCDATA NP_INFO_CompanyName { "Netscape Communications\0" }
118 RCDATA NP_INFO_FileDescription { "NPAVI32 Extension DLL\0"
119 RCDATA NP_INFO_InternalName { "NPAVI32\0" )
120 RCDATA NP_INFO_LegalCopyright { "Copyright Netscape Communications \251 1996\0"
121 RCDATA NP_INFO_OriginalFilename { "NVAPI32.DLL" }
122 RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" }
127 /* RC_DATA types for version info - required */
128 #define NP_INFO_ProductVersion 1
129 #define NP_INFO_MIMEType 2
130 #define NP_INFO_FileOpenName 3
131 #define NP_INFO_FileExtents 4
133 /* RC_DATA types for version info - used if found */
134 #define NP_INFO_FileDescription 5
135 #define NP_INFO_ProductName 6
137 /* RC_DATA types for version info - optional */
138 #define NP_INFO_CompanyName 7
139 #define NP_INFO_FileVersion 8
140 #define NP_INFO_InternalName 9
141 #define NP_INFO_LegalCopyright 10
142 #define NP_INFO_OriginalFilename 11
144 #ifndef RC_INVOKED
148 /*----------------------------------------------------------------------*/
149 /* Definition of Basic Types */
150 /*----------------------------------------------------------------------*/
152 #ifndef _UINT16
153 typedef unsigned short uint16;
154 #endif
156 #ifndef _UINT32
157 # if defined(__alpha)
158 typedef unsigned int uint32;
159 # else /* __alpha */
160 typedef unsigned long uint32;
161 # endif /* __alpha */
162 #endif
165 * AIX defines these in sys/inttypes.h included from sys/types.h
167 #ifndef AIX
168 #ifndef _INT16
169 typedef short int16;
170 #endif
172 #ifndef _INT32
173 # if defined(__alpha)
174 typedef int int32;
175 # else /* __alpha */
176 typedef long int32;
177 # endif /* __alpha */
178 #endif
179 #endif
181 #ifndef FALSE
182 #define FALSE (0)
183 #endif
184 #ifndef TRUE
185 #define TRUE (1)
186 #endif
187 #ifndef NULL
188 #define NULL (0L)
189 #endif
191 typedef unsigned char NPBool;
192 typedef int16 NPError;
193 typedef int16 NPReason;
194 typedef char* NPMIMEType;
198 /*----------------------------------------------------------------------*/
199 /* Structures and definitions */
200 /*----------------------------------------------------------------------*/
202 #ifdef XP_MAC
203 #pragma options align=mac68k
204 #endif
207 * NPP is a plug-in's opaque instance handle
209 typedef struct _NPP
211 void* pdata; /* plug-in private data */
212 void* ndata; /* netscape private data */
213 } NPP_t;
215 typedef NPP_t* NPP;
218 typedef struct _NPStream
220 void* pdata; /* plug-in private data */
221 void* ndata; /* netscape private data */
222 const char* url;
223 uint32 end;
224 uint32 lastmodified;
225 void* notifyData;
226 } NPStream;
229 typedef struct _NPByteRange
231 int32 offset; /* negative offset means from the end */
232 uint32 length;
233 struct _NPByteRange* next;
234 } NPByteRange;
237 typedef struct _NPSavedData
239 int32 len;
240 void* buf;
241 } NPSavedData;
244 typedef struct _NPRect
246 uint16 top;
247 uint16 left;
248 uint16 bottom;
249 uint16 right;
250 } NPRect;
252 typedef struct _NPSize
254 int32 width;
255 int32 height;
256 } NPSize;
258 #ifdef XP_UNIX
260 * Unix specific structures and definitions
264 * Callback Structures.
266 * These are used to pass additional platform specific information.
268 enum {
269 NP_SETWINDOW = 1,
270 NP_PRINT
273 typedef struct
275 int32 type;
276 } NPAnyCallbackStruct;
278 typedef struct
280 int32 type;
281 #ifndef NO_X11
282 Display* display;
283 Visual* visual;
284 Colormap colormap;
285 unsigned int depth;
286 #endif
287 } NPSetWindowCallbackStruct;
289 typedef struct
291 int32 type;
292 FILE* fp;
293 } NPPrintCallbackStruct;
295 #endif /* XP_UNIX */
298 * List of variable names for which NPP_GetValue shall be implemented
300 typedef enum {
301 NPPVpluginNameString = 1,
302 NPPVpluginDescriptionString,
303 NPPVpluginWindowBool,
304 NPPVpluginTransparentBool,
305 NPPVjavaClass, /* Not implemented in Mozilla 1.0 */
306 NPPVpluginWindowSize,
307 NPPVpluginTimerInterval,
309 NPPVpluginScriptableInstance = 10,
310 NPPVpluginScriptableIID = 11,
312 /* 12 and over are available on Mozilla builds starting with 0.9.9 */
313 NPPVjavascriptPushCallerBool = 12,
314 NPPVpluginKeepLibraryInMemory = 13 /* available in Mozilla 1.0 */
315 } NPPVariable;
318 * List of variable names for which NPN_GetValue is implemented by Mozilla
320 typedef enum {
321 NPNVxDisplay = 1,
322 NPNVxtAppContext,
323 NPNVnetscapeWindow,
324 NPNVjavascriptEnabledBool,
325 NPNVasdEnabledBool,
326 NPNVisOfflineBool,
328 /* 10 and over are available on Mozilla builds starting with 0.9.4 */
329 NPNVserviceManager = 10
330 } NPNVariable;
333 * The type of a NPWindow - it specifies the type of the data structure
334 * returned in the window field.
336 typedef enum {
337 NPWindowTypeWindow = 1,
338 NPWindowTypeDrawable
339 } NPWindowType;
341 typedef struct _NPWindow
343 void* window; /* Platform specific window handle */
344 /* OS/2: x - Position of bottom left corner */
345 /* OS/2: y - relative to visible netscape window */
346 int32 x; /* Position of top left corner relative */
347 int32 y; /* to a netscape page. */
348 uint32 width; /* Maximum window size */
349 uint32 height;
350 NPRect clipRect; /* Clipping rectangle in port coordinates */
351 /* Used by MAC only. */
352 #ifdef XP_UNIX
353 void * ws_info; /* Platform-dependent additonal data */
354 #endif /* XP_UNIX */
355 NPWindowType type; /* Is this a window or a drawable? */
356 } NPWindow;
359 typedef struct _NPFullPrint
361 NPBool pluginPrinted;/* Set TRUE if plugin handled fullscreen printing */
362 NPBool printOne; /* TRUE if plugin should print one copy to default printer */
363 void* platformPrint; /* Platform-specific printing info */
364 } NPFullPrint;
366 typedef struct _NPEmbedPrint
368 NPWindow window;
369 void* platformPrint; /* Platform-specific printing info */
370 } NPEmbedPrint;
372 typedef struct _NPPrint
374 uint16 mode; /* NP_FULL or NP_EMBED */
375 union
377 NPFullPrint fullPrint; /* if mode is NP_FULL */
378 NPEmbedPrint embedPrint; /* if mode is NP_EMBED */
379 } print;
380 } NPPrint;
382 #ifdef XP_MAC
383 typedef EventRecord NPEvent;
384 #elif defined(XP_WIN)
385 typedef struct _NPEvent
387 uint16 event;
388 uint32 wParam;
389 uint32 lParam;
390 } NPEvent;
391 #elif defined(XP_OS2)
392 typedef struct _NPEvent
394 uint32 event;
395 uint32 wParam;
396 uint32 lParam;
397 } NPEvent;
398 #elif defined (XP_UNIX) && !defined(NO_X11)
399 typedef XEvent NPEvent;
400 #else
401 typedef void* NPEvent;
402 #endif /* XP_MAC */
404 #ifdef XP_MAC
405 typedef RgnHandle NPRegion;
406 #elif defined(XP_WIN)
407 typedef HRGN NPRegion;
408 #elif defined(XP_UNIX) && !defined(NO_X11)
409 typedef Region NPRegion;
410 #else
411 typedef void *NPRegion;
412 #endif /* XP_MAC */
414 #ifdef XP_MAC
416 * Mac-specific structures and definitions.
419 typedef struct NP_Port
421 CGrafPtr port; /* Grafport */
422 int32 portx; /* position inside the topmost window */
423 int32 porty;
424 } NP_Port;
427 * Non-standard event types that can be passed to HandleEvent
430 enum NPEventType {
431 NPEventType_GetFocusEvent = (osEvt + 16),
432 NPEventType_LoseFocusEvent,
433 NPEventType_AdjustCursorEvent,
434 NPEventType_MenuCommandEvent,
435 NPEventType_ClippingChangedEvent,
436 NPEventType_ScrollingBeginsEvent = 1000,
437 NPEventType_ScrollingEndsEvent
440 #ifdef OBSOLETE
441 #define getFocusEvent (osEvt + 16)
442 #define loseFocusEvent (osEvt + 17)
443 #define adjustCursorEvent (osEvt + 18)
444 #endif
445 #endif /* XP_MAC */
448 * Values for mode passed to NPP_New:
450 #define NP_EMBED 1
451 #define NP_FULL 2
454 * Values for stream type passed to NPP_NewStream:
456 #define NP_NORMAL 1
457 #define NP_SEEK 2
458 #define NP_ASFILE 3
459 #define NP_ASFILEONLY 4
461 #define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
463 #ifdef XP_MAC
464 #pragma options align=reset
465 #endif
468 /*----------------------------------------------------------------------*/
469 /* Error and Reason Code definitions */
470 /*----------------------------------------------------------------------*/
473 * Values of type NPError:
475 #define NPERR_BASE 0
476 #define NPERR_NO_ERROR (NPERR_BASE + 0)
477 #define NPERR_GENERIC_ERROR (NPERR_BASE + 1)
478 #define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2)
479 #define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3)
480 #define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4)
481 #define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5)
482 #define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6)
483 #define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7)
484 #define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
485 #define NPERR_INVALID_PARAM (NPERR_BASE + 9)
486 #define NPERR_INVALID_URL (NPERR_BASE + 10)
487 #define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11)
488 #define NPERR_NO_DATA (NPERR_BASE + 12)
489 #define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13)
492 * Values of type NPReason:
494 #define NPRES_BASE 0
495 #define NPRES_DONE (NPRES_BASE + 0)
496 #define NPRES_NETWORK_ERR (NPRES_BASE + 1)
497 #define NPRES_USER_BREAK (NPRES_BASE + 2)
500 * Don't use these obsolete error codes any more.
502 #define NP_NOERR NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
503 #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
504 #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
507 * Version feature information
509 #define NPVERS_HAS_STREAMOUTPUT 8
510 #define NPVERS_HAS_NOTIFICATION 9
511 #define NPVERS_HAS_LIVECONNECT 9
512 #define NPVERS_WIN16_HAS_LIVECONNECT 9
513 #define NPVERS_68K_HAS_LIVECONNECT 11
514 #define NPVERS_HAS_WINDOWLESS 11
515 #define NPVERS_HAS_XPCONNECT_SCRIPTING 13
517 /*----------------------------------------------------------------------*/
518 /* Function Prototypes */
519 /*----------------------------------------------------------------------*/
521 #if defined(_WINDOWS) && !defined(WIN32)
522 #define NP_LOADDS _loadds
523 #else
524 #if defined(__OS2__)
525 #define NP_LOADDS _System
526 #else
527 #define NP_LOADDS
528 #endif
529 #endif
531 #ifdef __cplusplus
532 extern "C" {
533 #endif
536 * NPP_* functions are provided by the plugin and called by the navigator.
539 char* NPP_GetMIMEDescription(void);
541 NPError NP_LOADDS NPP_Initialize(void);
542 void NP_LOADDS NPP_Shutdown(void);
543 NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
544 uint16 mode, int16 argc, char* argn[],
545 char* argv[], NPSavedData* saved);
546 NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
547 NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
548 NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
549 NPStream* stream, NPBool seekable,
550 uint16* stype);
551 NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream,
552 NPReason reason);
553 int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
554 int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset,
555 int32 len, void* buffer);
556 void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
557 const char* fname);
558 void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
559 int16 NP_LOADDS NPP_HandleEvent(NPP instance, void* event);
560 void NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
561 NPReason reason, void* notifyData);
562 jref NP_LOADDS NPP_GetJavaClass(void);
563 NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, void *value);
564 NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value);
567 * NPN_* functions are provided by the navigator and called by the plugin.
569 void NP_LOADDS NPN_Version(int* plugin_major, int* plugin_minor,
570 int* netscape_major, int* netscape_minor);
571 NPError NP_LOADDS NPN_GetURLNotify(NPP instance, const char* url,
572 const char* target, void* notifyData);
573 NPError NP_LOADDS NPN_GetURL(NPP instance, const char* url,
574 const char* target);
575 NPError NP_LOADDS NPN_PostURLNotify(NPP instance, const char* url,
576 const char* target, uint32 len,
577 const char* buf, NPBool file,
578 void* notifyData);
579 NPError NP_LOADDS NPN_PostURL(NPP instance, const char* url,
580 const char* target, uint32 len,
581 const char* buf, NPBool file);
582 NPError NP_LOADDS NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
583 NPError NP_LOADDS NPN_NewStream(NPP instance, NPMIMEType type,
584 const char* target, NPStream** stream);
585 int32 NP_LOADDS NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer);
586 NPError NP_LOADDS NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
587 void NP_LOADDS NPN_Status(NPP instance, const char* message);
588 const char* NP_LOADDS NPN_UserAgent(NPP instance);
589 void* NP_LOADDS NPN_MemAlloc(uint32 size);
590 void NP_LOADDS NPN_MemFree(void* ptr);
591 uint32 NP_LOADDS NPN_MemFlush(uint32 size);
592 void NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages);
593 JRIEnv* NP_LOADDS NPN_GetJavaEnv(void);
594 jref NP_LOADDS NPN_GetJavaPeer(NPP instance);
595 NPError NP_LOADDS NPN_GetValue(NPP instance, NPNVariable variable, void *value);
596 NPError NP_LOADDS NPN_SetValue(NPP instance, NPPVariable variable, void *value);
597 void NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
598 void NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
599 void NP_LOADDS NPN_ForceRedraw(NPP instance);
601 #ifdef __cplusplus
602 } /* end extern "C" */
603 #endif
605 #endif /* RC_INVOKED */
606 #ifdef __OS2__
607 #pragma pack()
608 #endif
610 #endif /* _NPAPI_H_ */