1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
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
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.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
40 * npapi.h $Revision: 3.46 $
41 * Netscape client plug-in API spec
52 /* Copied from xp_core.h */
53 /* removed #ifdef for hpux defined in /usr/include/model.h */
68 * NO_NSPR_10_SUPPORT disables the inclusion
69 * of obsolete/protypes.h, whose int16, uint16,
70 * int32, and uint32 typedefs conflict with those
73 #ifndef NO_NSPR_10_SUPPORT
74 #define NO_NSPR_10_SUPPORT
77 #include "jri.h" /* Java Runtime Interface */
80 #if defined (__OS2__ ) || defined (OS2)
94 # define _declspec __declspec
100 # endif /* __INTEL__ */
101 #endif /* __MWERKS__ */
104 #include <Carbon/Carbon.h>
106 #define NP_NO_QUICKDRAW
112 # if defined(MOZ_X11)
113 # include <X11/Xlib.h>
114 # include <X11/Xutil.h>
118 /*----------------------------------------------------------------------*/
119 /* Plugin Version Constants */
120 /*----------------------------------------------------------------------*/
122 #define NP_VERSION_MAJOR 0
123 #define NP_VERSION_MINOR 19
126 /* The OS/2 version of Netscape uses RC_DATA to define the
127 mime types, file extensions, etc that are required.
128 Use a vertical bar to separate types, end types with \0.
129 FileVersion and ProductVersion are 32bit ints, all other
130 entries are strings the MUST be terminated wwith a \0.
134 RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
136 RCDATA NP_INFO_MIMEType { "video/x-video|",
138 RCDATA NP_INFO_FileExtents { "avi|",
140 RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
141 "MMOS2 Flc/Fli player(*.flc)\0" }
143 RCDATA NP_INFO_FileVersion { 1,0,0,1 }
144 RCDATA NP_INFO_CompanyName { "Netscape Communications\0" }
145 RCDATA NP_INFO_FileDescription { "NPAVI32 Extension DLL\0"
146 RCDATA NP_INFO_InternalName { "NPAVI32\0" )
147 RCDATA NP_INFO_LegalCopyright { "Copyright Netscape Communications \251 1996\0"
148 RCDATA NP_INFO_OriginalFilename { "NVAPI32.DLL" }
149 RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" }
154 /* RC_DATA types for version info - required */
155 #define NP_INFO_ProductVersion 1
156 #define NP_INFO_MIMEType 2
157 #define NP_INFO_FileOpenName 3
158 #define NP_INFO_FileExtents 4
160 /* RC_DATA types for version info - used if found */
161 #define NP_INFO_FileDescription 5
162 #define NP_INFO_ProductName 6
164 /* RC_DATA types for version info - optional */
165 #define NP_INFO_CompanyName 7
166 #define NP_INFO_FileVersion 8
167 #define NP_INFO_InternalName 9
168 #define NP_INFO_LegalCopyright 10
169 #define NP_INFO_OriginalFilename 11
175 /*----------------------------------------------------------------------*/
176 /* Definition of Basic Types */
177 /*----------------------------------------------------------------------*/
180 typedef unsigned short uint16;
184 # if defined(__alpha) || defined(__amd64__) || defined(__x86_64__)
185 typedef unsigned int uint32;
187 typedef unsigned long uint32;
188 # endif /* __alpha */
192 * AIX defines these in sys/inttypes.h included from sys/types.h
200 # if defined(__alpha) || defined(__amd64__) || defined(__x86_64__)
204 # endif /* __alpha */
220 #ifndef NP_NO_QUICKDRAW
221 NPDrawingModelQuickDraw = 0,
223 NPDrawingModelCoreGraphics = 1
227 typedef unsigned char NPBool;
228 typedef int16 NPError;
229 typedef int16 NPReason;
230 typedef char* NPMIMEType;
234 /*----------------------------------------------------------------------*/
235 /* Structures and definitions */
236 /*----------------------------------------------------------------------*/
239 * NPP is a plug-in's opaque instance handle
243 void* pdata; /* plug-in private data */
244 void* ndata; /* netscape private data */
250 typedef struct _NPStream
252 void* pdata; /* plug-in private data */
253 void* ndata; /* netscape private data */
258 const char* headers; /* Response headers from host.
259 * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS.
260 * Used for HTTP only; NULL for non-HTTP.
261 * Available from NPP_NewStream onwards.
262 * Plugin should copy this data before storing it.
263 * Includes HTTP status line and all headers,
264 * preferably verbatim as received from server,
265 * headers formatted as in HTTP ("Header: Value"),
266 * and newlines (\n, NOT \r\n) separating lines.
267 * Terminated by \n\0 (NOT \n\n\0). */
271 typedef struct _NPByteRange
273 int32 offset; /* negative offset means from the end */
275 struct _NPByteRange* next;
279 typedef struct _NPSavedData
286 typedef struct _NPRect
294 typedef struct _NPSize
302 * Unix specific structures and definitions
306 * Callback Structures.
308 * These are used to pass additional platform specific information.
318 } NPAnyCallbackStruct;
329 } NPSetWindowCallbackStruct;
335 } NPPrintCallbackStruct;
341 * The following masks are applied on certain platforms to NPNV and
342 * NPPV selectors that pass around pointers to COM interfaces. Newer
343 * compilers on some platforms may generate vtables that are not
344 * compatible with older compilers. To prevent older plugins from
345 * not understanding a new browser's ABI, these masks change the
346 * values of those selectors on those platforms. To remain backwards
347 * compatible with differenet versions of the browser, plugins can
348 * use these masks to dynamically determine and use the correct C++
349 * ABI that the browser is expecting. This does not apply to Windows
350 * as Microsoft's COM ABI will likely not change.
353 #define NP_ABI_GCC3_MASK 0x10000000
355 * gcc 3.x generated vtables on UNIX and OSX are incompatible with
356 * previous compilers.
358 #if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3))
359 #define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK
361 #define _NP_ABI_MIXIN_FOR_GCC3 0
365 #define NP_ABI_MACHO_MASK 0x01000000
367 * On OSX, the Mach-O executable format is significantly
368 * different than CFM. In addition to having a different
369 * C++ ABI, it also has has different C calling convention.
370 * You must use glue code when calling between CFM and
371 * Mach-O C functions.
373 #if (defined(TARGET_RT_MAC_MACHO))
374 #define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK
376 #define _NP_ABI_MIXIN_FOR_MACHO 0
380 #define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO)
383 * List of variable names for which NPP_GetValue shall be implemented
386 NPPVpluginNameString = 1,
387 NPPVpluginDescriptionString,
388 NPPVpluginWindowBool,
389 NPPVpluginTransparentBool,
390 NPPVjavaClass, /* Not implemented in Mozilla 1.0 */
391 NPPVpluginWindowSize,
392 NPPVpluginTimerInterval,
394 NPPVpluginScriptableInstance = (10 | NP_ABI_MASK),
395 NPPVpluginScriptableIID = 11,
397 /* Introduced in Mozilla 0.9.9 */
398 NPPVjavascriptPushCallerBool = 12,
400 /* Introduced in Mozilla 1.0 */
401 NPPVpluginKeepLibraryInMemory = 13,
402 NPPVpluginNeedsXEmbed = 14,
404 /* Get the NPObject for scripting the plugin. Introduced in Firefox
405 * 1.0 (NPAPI minor version 14).
407 NPPVpluginScriptableNPObject = 15,
409 /* Get the plugin value (as \0-terminated UTF-8 string data) for
410 * form submission if the plugin is part of a form. Use
411 * NPN_MemAlloc() to allocate memory for the string data. Introduced
412 * in Mozilla 1.8b2 (NPAPI minor version 15).
418 * List of variable names for which NPN_GetValue is implemented by Mozilla
424 NPNVjavascriptEnabledBool,
428 /* 10 and over are available on Mozilla builds starting with 0.9.4 */
429 NPNVserviceManager = (10 | NP_ABI_MASK),
430 NPNVDOMElement = (11 | NP_ABI_MASK), /* available in Mozilla 1.2 */
431 NPNVDOMWindow = (12 | NP_ABI_MASK),
432 NPNVToolkit = (13 | NP_ABI_MASK),
433 NPNVSupportsXEmbedBool = 14,
435 /* Get the NPObject wrapper for the browser window. */
436 NPNVWindowNPObject = 15,
438 /* Get the NPObject wrapper for the plugins DOM element. */
439 NPNVPluginElementNPObject = 16
442 /* Used for negotiating drawing models */
443 , NPNVpluginDrawingModel = 1000
444 #ifndef NP_NO_QUICKDRAW
445 , NPNVsupportsQuickDrawBool = 2000
447 , NPNVsupportsCoreGraphicsBool = 2001
452 * The type of Tookkit the widgets use
460 * The type of a NPWindow - it specifies the type of the data structure
461 * returned in the window field.
464 NPWindowTypeWindow = 1,
468 typedef struct _NPWindow
470 void* window; /* Platform specific window handle */
471 /* OS/2: x - Position of bottom left corner */
472 /* OS/2: y - relative to visible netscape window */
473 int32 x; /* Position of top left corner relative */
474 int32 y; /* to a netscape page. */
475 uint32 width; /* Maximum window size */
477 NPRect clipRect; /* Clipping rectangle in port coordinates */
478 /* Used by MAC only. */
479 #if defined(XP_UNIX) && !defined(XP_MACOSX)
480 void * ws_info; /* Platform-dependent additonal data */
482 NPWindowType type; /* Is this a window or a drawable? */
486 typedef struct _NPFullPrint
488 NPBool pluginPrinted;/* Set TRUE if plugin handled fullscreen printing */
489 NPBool printOne; /* TRUE if plugin should print one copy to default printer */
490 void* platformPrint; /* Platform-specific printing info */
493 typedef struct _NPEmbedPrint
496 void* platformPrint; /* Platform-specific printing info */
499 typedef struct _NPPrint
501 uint16 mode; /* NP_FULL or NP_EMBED */
504 NPFullPrint fullPrint; /* if mode is NP_FULL */
505 NPEmbedPrint embedPrint; /* if mode is NP_EMBED */
510 typedef EventRecord NPEvent;
511 #elif defined(XP_WIN)
512 typedef struct _NPEvent
518 #elif defined(XP_OS2)
519 typedef struct _NPEvent
525 #elif defined (XP_UNIX) && defined(MOZ_X11)
526 typedef XEvent NPEvent;
528 typedef void* NPEvent;
529 #endif /* XP_MACOSX */
532 typedef void* NPRegion;
533 #ifndef NP_NO_QUICKDRAW
534 typedef RgnHandle NPQDRegion;
536 typedef CGPathRef NPCGRegion;
537 #elif defined(XP_WIN)
538 typedef HRGN NPRegion;
539 #elif defined(XP_UNIX) && defined(MOZ_X11)
540 typedef Region NPRegion;
542 typedef void *NPRegion;
543 #endif /* XP_MACOSX */
547 * Mac-specific structures and definitions.
550 typedef struct NP_Port
552 CGrafPtr port; /* Grafport */
553 int32 portx; /* position inside the topmost window */
557 typedef struct NP_CGContext
559 CGContextRef context;
564 * Non-standard event types that can be passed to HandleEvent
568 NPEventType_GetFocusEvent = (osEvt + 16),
569 NPEventType_LoseFocusEvent,
570 NPEventType_AdjustCursorEvent,
571 NPEventType_MenuCommandEvent,
572 NPEventType_ClippingChangedEvent,
573 NPEventType_ScrollingBeginsEvent = 1000,
574 NPEventType_ScrollingEndsEvent
578 #define getFocusEvent (osEvt + 16)
579 #define loseFocusEvent (osEvt + 17)
580 #define adjustCursorEvent (osEvt + 18)
582 #endif /* XP_MACOSX */
585 * Values for mode passed to NPP_New:
591 * Values for stream type passed to NPP_NewStream:
596 #define NP_ASFILEONLY 4
598 #define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
601 /*----------------------------------------------------------------------*/
602 /* Error and Reason Code definitions */
603 /*----------------------------------------------------------------------*/
606 * Values of type NPError:
609 #define NPERR_NO_ERROR (NPERR_BASE + 0)
610 #define NPERR_GENERIC_ERROR (NPERR_BASE + 1)
611 #define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2)
612 #define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3)
613 #define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4)
614 #define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5)
615 #define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6)
616 #define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7)
617 #define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
618 #define NPERR_INVALID_PARAM (NPERR_BASE + 9)
619 #define NPERR_INVALID_URL (NPERR_BASE + 10)
620 #define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11)
621 #define NPERR_NO_DATA (NPERR_BASE + 12)
622 #define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13)
625 * Values of type NPReason:
628 #define NPRES_DONE (NPRES_BASE + 0)
629 #define NPRES_NETWORK_ERR (NPRES_BASE + 1)
630 #define NPRES_USER_BREAK (NPRES_BASE + 2)
633 * Don't use these obsolete error codes any more.
635 #define NP_NOERR NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
636 #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
637 #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
640 * Version feature information
642 #define NPVERS_HAS_STREAMOUTPUT 8
643 #define NPVERS_HAS_NOTIFICATION 9
644 #define NPVERS_HAS_LIVECONNECT 9
645 #define NPVERS_WIN16_HAS_LIVECONNECT 9
646 #define NPVERS_68K_HAS_LIVECONNECT 11
647 #define NPVERS_HAS_WINDOWLESS 11
648 #define NPVERS_HAS_XPCONNECT_SCRIPTING 13
649 #define NPVERS_HAS_NPRUNTIME_SCRIPTING 14
650 #define NPVERS_HAS_FORM_VALUES 15
651 #define NPVERS_HAS_POPUPS_ENABLED_STATE 16
652 #define NPVERS_HAS_RESPONSE_HEADERS 17
653 #define NPVERS_HAS_NPOBJECT_ENUM 18
654 #define NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL 19
656 /*----------------------------------------------------------------------*/
657 /* Function Prototypes */
658 /*----------------------------------------------------------------------*/
660 #if defined(_WINDOWS) && !defined(WIN32)
661 #define NP_LOADDS _loadds
664 #define NP_LOADDS _System
675 * NPP_* functions are provided by the plugin and called by the navigator.
679 char* NPP_GetMIMEDescription(void);
682 NPError NP_LOADDS NPP_Initialize(void);
683 void NP_LOADDS NPP_Shutdown(void);
684 NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
685 uint16 mode, int16 argc, char* argn[],
686 char* argv[], NPSavedData* saved);
687 NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
688 NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
689 NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
690 NPStream* stream, NPBool seekable,
692 NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream,
694 int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
695 int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset,
696 int32 len, void* buffer);
697 void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
699 void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
700 int16 NP_LOADDS NPP_HandleEvent(NPP instance, void* event);
701 void NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
702 NPReason reason, void* notifyData);
704 jref NP_LOADDS NPP_GetJavaClass(void);
706 NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, void *value);
707 NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value);
710 * NPN_* functions are provided by the navigator and called by the plugin.
712 void NP_LOADDS NPN_Version(int* plugin_major, int* plugin_minor,
713 int* netscape_major, int* netscape_minor);
714 NPError NP_LOADDS NPN_GetURLNotify(NPP instance, const char* url,
715 const char* target, void* notifyData);
716 NPError NP_LOADDS NPN_GetURL(NPP instance, const char* url,
718 NPError NP_LOADDS NPN_PostURLNotify(NPP instance, const char* url,
719 const char* target, uint32 len,
720 const char* buf, NPBool file,
722 NPError NP_LOADDS NPN_PostURL(NPP instance, const char* url,
723 const char* target, uint32 len,
724 const char* buf, NPBool file);
725 NPError NP_LOADDS NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
726 NPError NP_LOADDS NPN_NewStream(NPP instance, NPMIMEType type,
727 const char* target, NPStream** stream);
728 int32 NP_LOADDS NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer);
729 NPError NP_LOADDS NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
730 void NP_LOADDS NPN_Status(NPP instance, const char* message);
731 const char* NP_LOADDS NPN_UserAgent(NPP instance);
732 void* NP_LOADDS NPN_MemAlloc(uint32 size);
733 void NP_LOADDS NPN_MemFree(void* ptr);
734 uint32 NP_LOADDS NPN_MemFlush(uint32 size);
735 void NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages);
737 JRIEnv* NP_LOADDS NPN_GetJavaEnv(void);
738 jref NP_LOADDS NPN_GetJavaPeer(NPP instance);
740 NPError NP_LOADDS NPN_GetValue(NPP instance, NPNVariable variable, void *value);
741 NPError NP_LOADDS NPN_SetValue(NPP instance, NPPVariable variable, void *value);
742 void NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
743 void NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
744 void NP_LOADDS NPN_ForceRedraw(NPP instance);
745 //jam changed two functions below to return bool
746 bool NP_LOADDS NPN_PushPopupsEnabledState(NPP instance, NPBool enabled);
747 bool NP_LOADDS NPN_PopPopupsEnabledState(NPP instance);
748 void NP_LOADDS NPN_PluginThreadAsyncCall(NPP instance,
749 void (*func) (void *),
753 } /* end extern "C" */
756 #endif /* RC_INVOKED */
761 #endif /* _NPAPI_H_ */