1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Netscape Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/NPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is mozilla.org code.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1998
19 * the Initial Developer. All Rights Reserved.
22 * Portions Copyright (c) 2004-2006, Nokia Corporation
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 ***** */
40 * Nokia modified this file, by changing certain variables for the purpose of
41 * porting the file to the Symbian platform on May 1st, 2004.
45 * Netscape client plug-in API spec
52 #include "jri.h" /* Java Runtime Interface */
67 # define _declspec __declspec
72 # endif /* macintosh */
77 # endif /* __INTEL__ */
79 #endif /* __MWERKS__ */
85 #if defined(__APPLE_CC__) && !defined(__MACOS_CLASSIC__)
90 #include <Quickdraw.h>
95 #include <Carbon/Carbon.h>
96 #include <ApplicationServices/ApplicationServices.h>
97 #include <OpenGL/OpenGL.h>
101 #include <X11/Xlib.h>
102 #include <X11/Xutil.h>
110 #include <np_defines.h>
112 #if defined(XP_MACOSX) && defined(__LP64__)
113 #error 64-bit Netscape plug-ins are not supported on Mac OS X
116 /*----------------------------------------------------------------------*/
117 /* Plugin Version Constants */
118 /*----------------------------------------------------------------------*/
120 #define NP_VERSION_MAJOR 0
121 #define NP_VERSION_MINOR 18
125 /*----------------------------------------------------------------------*/
126 /* Definition of Basic Types */
127 /*----------------------------------------------------------------------*/
131 typedef unsigned short uint16;
137 typedef unsigned int uint32;
139 typedef unsigned long uint32;
140 #endif /* __LP64__ */
154 #endif /* __LP64__ */
167 typedef unsigned char NPBool;
168 typedef int16 NPError;
169 typedef int16 NPReason;
170 #ifndef __SYMBIAN32__
171 typedef char* NPMIMEType;
172 #else/* __SYMBIAN32__ */
173 typedef const TDesC8& NPMIMEType;
176 /*----------------------------------------------------------------------*/
177 /* Structures and definitions */
178 /*----------------------------------------------------------------------*/
180 #if !defined(__LP64__)
181 #if defined(XP_MAC) || defined(XP_MACOSX)
182 #pragma options align=mac68k
184 #endif /* __LP64__ */
187 * NPP is a plug-in's opaque instance handle
190 #ifndef _NP_RUNTIME_H_NPP
191 #define _NP_RUNTIME_H_NPP
194 void* pdata; /* plug-in private data */
195 void* ndata; /* netscape private data */
199 #endif // _NP_RUNTIME_H_NPP
203 void* pdata; /* plug-in private data */
204 void* ndata; /* netscape private data */
210 typedef struct _NPStream
212 void* pdata; /* plug-in private data */
213 void* ndata; /* netscape private data */
214 #ifndef __SYMBIAN32__
216 #else /*__SYMBIAN32__*/
222 const char* headers; /* Response headers from host.
223 * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS.
224 * Used for HTTP only; NULL for non-HTTP.
225 * Available from NPP_NewStream onwards.
226 * Plugin should copy this data before storing it.
227 * Includes HTTP status line and all headers,
228 * preferably verbatim as received from server,
229 * headers formatted as in HTTP ("Header: Value"),
230 * and newlines (\n, NOT \r\n) separating lines.
231 * Terminated by \n\0 (NOT \n\n\0). */
235 typedef struct _NPByteRange
237 int32 offset; /* negative offset means from the end */
239 struct _NPByteRange* next;
243 typedef struct _NPSavedData
250 typedef struct _NPRect
261 * Unix specific structures and definitions
265 * Callback Structures.
267 * These are used to pass additional platform specific information.
277 } NPAnyCallbackStruct;
286 } NPSetWindowCallbackStruct;
292 } NPPrintCallbackStruct;
297 * The following masks are applied on certain platforms to NPNV and
298 * NPPV selectors that pass around pointers to COM interfaces. Newer
299 * compilers on some platforms may generate vtables that are not
300 * compatible with older compilers. To prevent older plugins from
301 * not understanding a new browser's ABI, these masks change the
302 * values of those selectors on those platforms. To remain backwards
303 * compatible with differenet versions of the browser, plugins can
304 * use these masks to dynamically determine and use the correct C++
305 * ABI that the browser is expecting. This does not apply to Windows
306 * as Microsoft's COM ABI will likely not change.
309 #define NP_ABI_GCC3_MASK 0x10000000
311 * gcc 3.x generated vtables on UNIX and OSX are incompatible with
312 * previous compilers.
314 #if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3))
315 #define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK
317 #define _NP_ABI_MIXIN_FOR_GCC3 0
320 #define NP_ABI_MACHO_MASK 0x01000000
322 * On OSX, the Mach-O executable format is significantly
323 * different than CFM. In addition to having a different
324 * C++ ABI, it also has has different C calling convention.
325 * You must use glue code when calling between CFM and
326 * Mach-O C functions.
328 #if (defined(TARGET_RT_MAC_MACHO))
329 #define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK
331 #define _NP_ABI_MIXIN_FOR_MACHO 0
335 #define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO)
338 * List of variable names for which NPP_GetValue shall be implemented
341 NPPVpluginNameString = 1,
342 NPPVpluginDescriptionString,
343 NPPVpluginWindowBool,
344 NPPVpluginTransparentBool,
346 NPPVjavaClass, /* Not implemented in WebKit */
347 NPPVpluginWindowSize, /* Not implemented in WebKit */
348 NPPVpluginTimerInterval, /* Not implemented in WebKit */
350 NPPVpluginScriptableInstance = (10 | NP_ABI_MASK), /* Not implemented in WebKit */
351 NPPVpluginScriptableIID = 11, /* Not implemented in WebKit */
353 /* 12 and over are available on Mozilla builds starting with 0.9.9 */
354 NPPVjavascriptPushCallerBool = 12, /* Not implemented in WebKit */
355 NPPVpluginKeepLibraryInMemory = 13, /* Not implemented in WebKit */
356 NPPVpluginNeedsXEmbed = 14, /* Not implemented in WebKit */
358 /* Get the NPObject for scripting the plugin. */
359 NPPVpluginScriptableNPObject = 15,
362 // Custom NPP variables, starting from 100 till 1000
363 NPPVPluginFocusPosition = 100,
364 NPPVPluginDeactivate = 101,
365 NPPVPluginZoom = 102,
366 NPPVPluginPointerEvent = 103,
367 NPPVpluginInteractiveBool = 1000,
370 /* Get the plugin value (as \0-terminated UTF-8 string data) for
371 * form submission if the plugin is part of a form. Use
372 * NPN_MemAlloc() to allocate memory for the string data.
374 NPPVformValue = 16, /* Not implemented in WebKit */
375 NPPVpluginFullScreenBool = 17 /* Not implemented in WebKit */
379 * List of variable names for which NPN_GetValue is implemented by Mozilla
385 NPNVjavascriptEnabledBool,
389 /* 10 and over are available on Mozilla builds starting with 0.9.4 */
390 NPNVserviceManager = (10 | NP_ABI_MASK), /* Not implemented in WebKit */
391 NPNVDOMElement = (11 | NP_ABI_MASK), /* Not implemented in WebKit */
392 NPNVDOMWindow = (12 | NP_ABI_MASK), /* Not implemented in WebKit */
393 NPNVToolkit = (13 | NP_ABI_MASK), /* Not implemented in WebKit */
394 NPNVSupportsXEmbedBool = 14, /* Not implemented in WebKit */
396 /* Get the NPObject wrapper for the browser window. */
397 NPNVWindowNPObject = 15,
399 /* Get the NPObject wrapper for the plugins DOM element. */
400 NPNVPluginElementNPObject,
403 , NPNVpluginDrawingModel = 1000 /* The NPDrawingModel specified by the plugin */
405 #ifndef NP_NO_QUICKDRAW
406 , NPNVsupportsQuickDrawBool = 2000 /* TRUE if the browser supports the QuickDraw drawing model */
408 , NPNVsupportsCoreGraphicsBool = 2001 /* TRUE if the browser supports the CoreGraphics drawing model */
409 , NPNVsupportsOpenGLBool = 2002 /* TRUE if the browser supports the OpenGL drawing model (CGL on Mac) */
410 #endif /* XP_MACOSX */
412 /* Get the id of the currently connected access point */
417 * The type of a NPWindow - it specifies the type of the data structure
418 * returned in the window field.
421 NPWindowTypeWindow = 1,
428 * The drawing model for a Mac OS X plugin. These are the possible values for the NPNVpluginDrawingModel variable.
432 #ifndef NP_NO_QUICKDRAW
433 NPDrawingModelQuickDraw = 0,
435 NPDrawingModelCoreGraphics = 1,
436 NPDrawingModelOpenGL = 2
441 typedef struct _NPWindow
443 void* window; /* Platform specific window handle */
444 int32 x; /* Position of top left corner relative */
445 int32 y; /* to a netscape page. */
446 uint32 width; /* Maximum window size */
448 NPRect clipRect; /* Clipping rectangle in port coordinates */
449 /* Used by MAC only. */
451 void * ws_info; /* Platform-dependent additonal data */
453 NPWindowType type; /* Is this a window or a drawable? */
457 typedef struct _NPFullPrint
459 NPBool pluginPrinted; /* Set TRUE if plugin handled fullscreen */
461 NPBool printOne; /* TRUE if plugin should print one copy */
462 /* to default printer */
463 void* platformPrint; /* Platform-specific printing info */
466 typedef struct _NPEmbedPrint
469 void* platformPrint; /* Platform-specific printing info */
472 typedef struct _NPPrint
474 uint16 mode; /* NP_FULL or NP_EMBED */
477 NPFullPrint fullPrint; /* if mode is NP_FULL */
478 NPEmbedPrint embedPrint; /* if mode is NP_EMBED */
482 #if defined(XP_MAC) || defined(XP_MACOSX)
483 typedef EventRecord NPEvent;
484 #elif defined(XP_WIN)
485 typedef struct _NPEvent
491 #elif defined (XP_UNIX)
492 typedef XEvent NPEvent;
493 #elif defined (__SYMBIAN32__)
494 typedef struct _NPEvent
500 typedef void* NPEvent;
504 typedef RgnHandle NPRegion;
505 #elif defined(XP_MACOSX)
507 * NPRegion's type depends on the drawing model specified by the plugin (see NPNVpluginDrawingModel).
508 * NPQDRegion represents a QuickDraw RgnHandle and is used with the QuickDraw drawing model.
509 * NPCGRegion repesents a graphical region when using any other drawing model.
511 typedef void *NPRegion;
512 #ifndef NP_NO_QUICKDRAW
513 typedef RgnHandle NPQDRegion;
515 typedef CGPathRef NPCGRegion;
516 #elif defined(XP_WIN)
517 typedef HRGN NPRegion;
518 #elif defined(XP_UNIX)
519 typedef Region NPRegion;
521 typedef void *NPRegion;
527 * NP_CGContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelCoreGraphics
528 * as its drawing model.
531 typedef struct NP_CGContext
533 CGContextRef context;
538 * NP_GLContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelOpenGL as its
542 typedef struct NP_GLContext
544 CGLContextObj context;
548 #endif /* XP_MACOSX */
550 #if defined(XP_MAC) || defined(XP_MACOSX)
553 * Mac-specific structures and definitions.
556 #ifndef NP_NO_QUICKDRAW
559 * NP_Port is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelQuickDraw as its
560 * drawing model, or the plugin does not specify a drawing model.
562 * It is not recommended that new plugins use NPDrawingModelQuickDraw or NP_Port, as QuickDraw has been
563 * deprecated in Mac OS X 10.5. CoreGraphics is the preferred drawing API.
565 * NP_Port is not available in 64-bit.
568 typedef struct NP_Port
570 CGrafPtr port; /* Grafport */
571 int32 portx; /* position inside the topmost window */
575 #endif /* NP_NO_QUICKDRAW */
578 * Non-standard event types that can be passed to HandleEvent
580 #define getFocusEvent (osEvt + 16)
581 #define loseFocusEvent (osEvt + 17)
582 #define adjustCursorEvent (osEvt + 18)
588 * Values for mode passed to NPP_New:
594 * Values for stream type passed to NPP_NewStream:
599 #define NP_ASFILEONLY 4
601 #define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
603 #if !defined(__LP64__)
604 #if defined(XP_MAC) || defined(XP_MACOSX)
605 #pragma options align=reset
607 #endif /* __LP64__ */
610 /*----------------------------------------------------------------------*/
611 /* Error and Reason Code definitions */
612 /*----------------------------------------------------------------------*/
615 * Values of type NPError:
618 #define NPERR_NO_ERROR (NPERR_BASE + 0)
619 #define NPERR_GENERIC_ERROR (NPERR_BASE + 1)
620 #define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2)
621 #define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3)
622 #define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4)
623 #define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5)
624 #define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6)
625 #define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7)
626 #define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
627 #define NPERR_INVALID_PARAM (NPERR_BASE + 9)
628 #define NPERR_INVALID_URL (NPERR_BASE + 10)
629 #define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11)
630 #define NPERR_NO_DATA (NPERR_BASE + 12)
631 #define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13)
634 * Values of type NPReason:
637 #define NPRES_DONE (NPRES_BASE + 0)
638 #define NPRES_NETWORK_ERR (NPRES_BASE + 1)
639 #define NPRES_USER_BREAK (NPRES_BASE + 2)
642 * Don't use these obsolete error codes any more.
644 #define NP_NOERR NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
645 #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
646 #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
649 * Version feature information
651 #define NPVERS_HAS_STREAMOUTPUT 8
652 #define NPVERS_HAS_NOTIFICATION 9
653 #define NPVERS_HAS_LIVECONNECT 9
654 #define NPVERS_WIN16_HAS_LIVECONNECT 9
655 #define NPVERS_68K_HAS_LIVECONNECT 11
656 #define NPVERS_HAS_WINDOWLESS 11
657 #define NPVERS_HAS_XPCONNECT_SCRIPTING 13 /* Not implemented in WebKit */
658 #define NPVERS_HAS_NPRUNTIME_SCRIPTING 14
659 #define NPVERS_HAS_FORM_VALUES 15 /* Not implemented in WebKit; see bug 13061 */
660 #define NPVERS_HAS_POPUPS_ENABLED_STATE 16 /* Not implemented in WebKit */
661 #define NPVERS_HAS_RESPONSE_HEADERS 17
662 #define NPVERS_HAS_NPOBJECT_ENUM 18
665 /*----------------------------------------------------------------------*/
666 /* Function Prototypes */
667 /*----------------------------------------------------------------------*/
669 #if defined(_WINDOWS) && !defined(WIN32)
670 #define NP_LOADDS _loadds
675 #ifndef __SYMBIAN32__
682 * NPP_* functions are provided by the plugin and called by the navigator.
686 char* NPP_GetMIMEDescription(void);
691 IMPORT_C const TDesC* NPP_GetMIMEDescription(void);
692 #endif /* __SYMBIAN32__ */
694 NPError NPP_Initialize(void);
697 #endif /* __SYMBIAN32__ */
698 void NPP_Shutdown(void);
700 #ifndef __SYMBIAN32__
701 NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
702 uint16 mode, int16 argc, char* argn[],
703 char* argv[], NPSavedData* saved);
705 NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
706 uint16 mode, CDesCArray* argn,
707 CDesCArray* argv, NPSavedData* saved);
708 #endif /* __SYMBIAN32__ */
710 NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
711 NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
712 NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
713 NPStream* stream, NPBool seekable,
715 NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream,
717 int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
718 int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset,
719 int32 len, void* buffer);
721 #ifndef __SYMBIAN32__
722 void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
724 #else/* __SYMBIAN32__ */
725 void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
727 #endif /* __SYMBIAN32__ */
729 void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
730 int16 NPP_HandleEvent(NPP instance, void* event);
732 #ifndef __SYMBIAN32__
733 void NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
734 NPReason reason, void* notifyData);
735 jref NP_LOADDS NPP_GetJavaClass(void);
736 #else/* __SYMBIAN32__ */
737 void NP_LOADDS NPP_URLNotify(NPP instance, const TDesC& url,
738 NPReason reason, void* notifyData);
739 #endif /* __SYMBIAN32__ */
744 #endif /* __SYMBIAN32__ */
745 NPError NPP_GetValue(NPP instance, NPPVariable variable,
747 NPError NPP_SetValue(NPP instance, NPNVariable variable,
751 * NPN_* functions are provided by the navigator and called by the plugin.
754 void NPN_Version(int* plugin_major, int* plugin_minor,
755 int* netscape_major, int* netscape_minor);
757 #ifndef __SYMBIAN32__
758 NPError NPN_GetURLNotify(NPP instance, const char* url,
759 const char* target, void* notifyData);
760 NPError NPN_GetURL(NPP instance, const char* url,
762 NPError NPN_PostURLNotify(NPP instance, const char* url,
763 const char* target, uint32 len,
764 const char* buf, NPBool file,
766 NPError NPN_PostURL(NPP instance, const char* url,
767 const char* target, uint32 len,
768 const char* buf, NPBool file);
769 #else/* __SYMBIAN32__ */
770 NPError NP_LOADDS NPN_GetURLNotify(NPP instance, const TDesC& url,
771 const TDesC* target, void* notifyData);
772 NPError NP_LOADDS NPN_GetURL(NPP instance, const TDesC& url,
773 const TDesC* target);
774 NPError NP_LOADDS NPN_PostURLNotify(NPP instance, const TDesC& url,
776 const TDesC& buf, NPBool file,
778 NPError NP_LOADDS NPN_PostURL(NPP instance, const TDesC& url,
780 const TDesC& buf, NPBool file);
781 #endif /* __SYMBIAN32__ */
783 NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
785 #ifndef __SYMBIAN32__
786 NPError NPN_NewStream(NPP instance, NPMIMEType type,
787 const char* target, NPStream** stream);
788 #else/* __SYMBIAN32__ */
789 NPError NP_LOADDS NPN_NewStream(NPP instance, NPMIMEType type,
790 const TDesC* target, NPStream** stream);
791 #endif /* __SYMBIAN32__ */
793 int32 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer);
794 NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
796 #ifndef __SYMBIAN32__
797 void NPN_Status(NPP instance, const char* message);
798 #else/* __SYMBIAN32__ */
799 void NP_LOADDS NPN_Status(NPP instance, const TDesC& message);
800 #endif /* __SYMBIAN32__ */
802 #ifndef __SYMBIAN32__
803 const char* NPN_UserAgent(NPP instance);
804 #else/* __SYMBIAN32__ */
805 const TDesC* NP_LOADDS NPN_UserAgent(NPP instance);
806 #endif /* __SYMBIAN32__ */
809 void* NPN_MemAlloc(uint32 size);
810 void NPN_MemFree(void* ptr);
811 uint32 NPN_MemFlush(uint32 size);
812 void NPN_ReloadPlugins(NPBool reloadPages);
813 #ifndef __SYMBIAN32__
814 JRIEnv* NPN_GetJavaEnv(void);
815 jref NPN_GetJavaPeer(NPP instance);
817 NPError NPN_GetValue(NPP instance, NPNVariable variable,
819 NPError NPN_SetValue(NPP instance, NPPVariable variable,
821 void NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
822 void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
823 void NPN_ForceRedraw(NPP instance);
824 void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled);
825 void NPN_PopPopupsEnabledState(NPP instance);
827 #ifndef __SYMBIAN32__
829 } /* end extern "C" */
833 #endif /* _NPAPI_H_ */