Home | History | Annotate | Download | only in bindings
      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
      4  *
      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/
      9  *
     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.
     14  *
     15  * The Original Code is mozilla.org code.
     16  *
     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.
     21  *
     22  * Contributor(s):
     23  *
     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.
     35  *
     36  * ***** END LICENSE BLOCK ***** */
     37 
     38 #ifndef npapi_h_
     39 #define npapi_h_
     40 
     41 #if defined(__OS2__)
     42 #pragma pack(1)
     43 #endif
     44 
     45 /* BEGIN GOOGLE MODIFICATIONS */
     46 
     47 #ifndef __native_client__
     48 #include "nptypes.h"
     49 #endif
     50 
     51 #ifdef __native_client__
     52 #include <stdint.h>
     53 #include <sys/types.h>
     54 #else
     55 #include "base/basictypes.h"
     56 #endif  /* __native_client__ */
     57 
     58 /* END GOOGLE MODIFICATIONS */
     59 
     60 #if defined(__OS2__) || defined(OS2)
     61 #ifndef XP_OS2
     62 #define XP_OS2 1
     63 #endif
     64 #endif
     65 
     66 #if defined(_WIN32) && !defined(__SYMBIAN32__)
     67 #include <windows.h>
     68 #ifndef XP_WIN
     69 #define XP_WIN 1
     70 #endif
     71 #endif
     72 
     73 /* BEGIN GOOGLE MODIFICATIONS */
     74 /* On Linux and Mac, be sure to set Mozilla-specific macros. */
     75 #if defined(USE_X11)
     76 #if !defined(XP_UNIX)
     77 #define XP_UNIX 1
     78 #endif
     79 #if !defined(MOZ_X11)
     80 #define MOZ_X11 1
     81 #endif
     82 #endif
     83 /* END GOOGLE MODIFICATIONS */
     84 
     85 #if defined(__SYMBIAN32__)
     86 #ifndef XP_SYMBIAN
     87 #define XP_SYMBIAN 1
     88 #undef XP_WIN
     89 #endif
     90 #endif
     91 
     92 #if defined(__APPLE_CC__) && !defined(XP_UNIX)
     93 #ifndef XP_MACOSX
     94 #define XP_MACOSX 1
     95 #endif
     96 #endif
     97 
     98 #if defined(XP_MACOSX) && defined(__LP64__)
     99 #define NP_NO_QUICKDRAW
    100 #define NP_NO_CARBON
    101 #endif
    102 
    103 #if defined(XP_MACOSX)
    104 #include <ApplicationServices/ApplicationServices.h>
    105 #include <OpenGL/OpenGL.h>
    106 #ifndef NP_NO_CARBON
    107 #include <Carbon/Carbon.h>
    108 #endif
    109 #endif
    110 
    111 #if defined(XP_UNIX)
    112 #include <stdio.h>
    113 /* BEGIN GOOGLE MODIFICATIONS */
    114 #if 0
    115 /* END GOOGLE MODIFICATIONS */
    116 #if defined(MOZ_X11)
    117 #include <X11/Xlib.h>
    118 #include <X11/Xutil.h>
    119 #endif
    120 /* BEGIN GOOGLE MODIFICATIONS */
    121 #endif
    122 /* END GOOGLE MODIFICATIONS */
    123 #endif
    124 
    125 #if defined(XP_SYMBIAN)
    126 #include <QEvent>
    127 #include <QRegion>
    128 #endif
    129 
    130 /*----------------------------------------------------------------------*/
    131 /*                        Plugin Version Constants                      */
    132 /*----------------------------------------------------------------------*/
    133 
    134 #define NP_VERSION_MAJOR 0
    135 #define NP_VERSION_MINOR 27
    136 
    137 
    138 /* The OS/2 version of Netscape uses RC_DATA to define the
    139    mime types, file extensions, etc that are required.
    140    Use a vertical bar to separate types, end types with \0.
    141    FileVersion and ProductVersion are 32bit ints, all other
    142    entries are strings that MUST be terminated with a \0.
    143 
    144 AN EXAMPLE:
    145 
    146 RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
    147 
    148 RCDATA NP_INFO_MIMEType    { "video/x-video|",
    149                              "video/x-flick\0" }
    150 RCDATA NP_INFO_FileExtents { "avi|",
    151                              "flc\0" }
    152 RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
    153                              "MMOS2 Flc/Fli player(*.flc)\0" }
    154 
    155 RCDATA NP_INFO_FileVersion       { 1,0,0,1 }
    156 RCDATA NP_INFO_CompanyName       { "Netscape Communications\0" }
    157 RCDATA NP_INFO_FileDescription   { "NPAVI32 Extension DLL\0"
    158 RCDATA NP_INFO_InternalName      { "NPAVI32\0" )
    159 RCDATA NP_INFO_LegalCopyright    { "Copyright Netscape Communications \251 1996\0"
    160 RCDATA NP_INFO_OriginalFilename  { "NVAPI32.DLL" }
    161 RCDATA NP_INFO_ProductName       { "NPAVI32 Dynamic Link Library\0" }
    162 */
    163 /* RC_DATA types for version info - required */
    164 #define NP_INFO_ProductVersion      1
    165 #define NP_INFO_MIMEType            2
    166 #define NP_INFO_FileOpenName        3
    167 #define NP_INFO_FileExtents         4
    168 /* RC_DATA types for version info - used if found */
    169 #define NP_INFO_FileDescription     5
    170 #define NP_INFO_ProductName         6
    171 /* RC_DATA types for version info - optional */
    172 #define NP_INFO_CompanyName         7
    173 #define NP_INFO_FileVersion         8
    174 #define NP_INFO_InternalName        9
    175 #define NP_INFO_LegalCopyright      10
    176 #define NP_INFO_OriginalFilename    11
    177 
    178 #ifndef RC_INVOKED
    179 
    180 /*----------------------------------------------------------------------*/
    181 /*                       Definition of Basic Types                      */
    182 /*----------------------------------------------------------------------*/
    183 
    184 typedef unsigned char NPBool;
    185 typedef int16_t       NPError;
    186 typedef int16_t       NPReason;
    187 typedef char*         NPMIMEType;
    188 
    189 /*----------------------------------------------------------------------*/
    190 /*                       Structures and definitions                     */
    191 /*----------------------------------------------------------------------*/
    192 
    193 #if !defined(__LP64__)
    194 #if defined(XP_MACOSX)
    195 #pragma options align=mac68k
    196 #endif
    197 #endif /* __LP64__ */
    198 
    199 /*
    200  *  NPP is a plug-in's opaque instance handle
    201  */
    202 typedef struct _NPP
    203 {
    204   void* pdata;      /* plug-in private data */
    205   void* ndata;      /* netscape private data */
    206 } NPP_t;
    207 
    208 typedef NPP_t*  NPP;
    209 
    210 typedef struct _NPStream
    211 {
    212   void*    pdata; /* plug-in private data */
    213   void*    ndata; /* netscape private data */
    214   const    char* url;
    215   uint32_t end;
    216   uint32_t lastmodified;
    217   void*    notifyData;
    218   const    char* headers; /* Response headers from host.
    219                            * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS.
    220                            * Used for HTTP only; NULL for non-HTTP.
    221                            * Available from NPP_NewStream onwards.
    222                            * Plugin should copy this data before storing it.
    223                            * Includes HTTP status line and all headers,
    224                            * preferably verbatim as received from server,
    225                            * headers formatted as in HTTP ("Header: Value"),
    226                            * and newlines (\n, NOT \r\n) separating lines.
    227                            * Terminated by \n\0 (NOT \n\n\0). */
    228 } NPStream;
    229 
    230 typedef struct _NPByteRange
    231 {
    232   int32_t  offset; /* negative offset means from the end */
    233   uint32_t length;
    234   struct _NPByteRange* next;
    235 } NPByteRange;
    236 
    237 typedef struct _NPSavedData
    238 {
    239   int32_t len;
    240   void*   buf;
    241 } NPSavedData;
    242 
    243 typedef struct _NPRect
    244 {
    245   uint16_t top;
    246   uint16_t left;
    247   uint16_t bottom;
    248   uint16_t right;
    249 } NPRect;
    250 
    251 typedef struct _NPSize
    252 {
    253   int32_t width;
    254   int32_t height;
    255 } NPSize;
    256 
    257 typedef enum {
    258   NPFocusNext = 0,
    259   NPFocusPrevious = 1
    260 } NPFocusDirection;
    261 
    262 /* Return values for NPP_HandleEvent */
    263 #define kNPEventNotHandled 0
    264 #define kNPEventHandled 1
    265 /* Exact meaning must be spec'd in event model. */
    266 #define kNPEventStartIME 2
    267 
    268 #if defined(XP_UNIX)
    269 /*
    270  * Unix specific structures and definitions
    271  */
    272 
    273 /*
    274  * Callback Structures.
    275  *
    276  * These are used to pass additional platform specific information.
    277  */
    278 enum {
    279   NP_SETWINDOW = 1,
    280   NP_PRINT
    281 };
    282 
    283 typedef struct
    284 {
    285   int32_t type;
    286 } NPAnyCallbackStruct;
    287 
    288 /* BEGIN GOOGLE MODIFICATIONS */
    289 typedef struct _NPSetWindowCallbackStruct NPSetWindowCallbackStruct;
    290 /* END GOOGLE MODIFICATIONS */
    291 
    292 typedef struct
    293 {
    294   int32_t type;
    295   FILE* fp;
    296 } NPPrintCallbackStruct;
    297 
    298 #endif /* XP_UNIX */
    299 
    300 #if defined(XP_MACOSX)
    301 typedef enum {
    302 #ifndef NP_NO_QUICKDRAW
    303   NPDrawingModelQuickDraw = 0,
    304 #endif
    305   NPDrawingModelCoreGraphics = 1,
    306   NPDrawingModelOpenGL = 2,
    307   NPDrawingModelCoreAnimation = 3,
    308   NPDrawingModelInvalidatingCoreAnimation = 4
    309 } NPDrawingModel;
    310 
    311 typedef enum {
    312 #ifndef NP_NO_CARBON
    313   NPEventModelCarbon = 0,
    314 #endif
    315   NPEventModelCocoa = 1
    316 } NPEventModel;
    317 #endif
    318 
    319 /*
    320  *   The following masks are applied on certain platforms to NPNV and
    321  *   NPPV selectors that pass around pointers to COM interfaces. Newer
    322  *   compilers on some platforms may generate vtables that are not
    323  *   compatible with older compilers. To prevent older plugins from
    324  *   not understanding a new browser's ABI, these masks change the
    325  *   values of those selectors on those platforms. To remain backwards
    326  *   compatible with different versions of the browser, plugins can
    327  *   use these masks to dynamically determine and use the correct C++
    328  *   ABI that the browser is expecting. This does not apply to Windows
    329  *   as Microsoft's COM ABI will likely not change.
    330  */
    331 
    332 #define NP_ABI_GCC3_MASK  0x10000000
    333 /*
    334  *   gcc 3.x generated vtables on UNIX and OSX are incompatible with
    335  *   previous compilers.
    336  */
    337 #if (defined(XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3))
    338 #define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK
    339 #else
    340 #define _NP_ABI_MIXIN_FOR_GCC3 0
    341 #endif
    342 
    343 #if defined(XP_MACOSX)
    344 #define NP_ABI_MACHO_MASK 0x01000000
    345 #define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK
    346 #else
    347 #define _NP_ABI_MIXIN_FOR_MACHO 0
    348 #endif
    349 
    350 #define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO)
    351 
    352 /*
    353  * List of variable names for which NPP_GetValue shall be implemented
    354  */
    355 typedef enum {
    356   NPPVpluginNameString = 1,
    357   NPPVpluginDescriptionString,
    358   NPPVpluginWindowBool,
    359   NPPVpluginTransparentBool,
    360   NPPVjavaClass,
    361   NPPVpluginWindowSize,
    362   NPPVpluginTimerInterval,
    363   NPPVpluginScriptableInstance = (10 | NP_ABI_MASK),
    364   NPPVpluginScriptableIID = 11,
    365   NPPVjavascriptPushCallerBool = 12,
    366   NPPVpluginKeepLibraryInMemory = 13,
    367   NPPVpluginNeedsXEmbed         = 14,
    368 
    369   /* Get the NPObject for scripting the plugin. Introduced in NPAPI minor version 14.
    370    */
    371   NPPVpluginScriptableNPObject  = 15,
    372 
    373   /* Get the plugin value (as \0-terminated UTF-8 string data) for
    374    * form submission if the plugin is part of a form. Use
    375    * NPN_MemAlloc() to allocate memory for the string data. Introduced
    376    * in NPAPI minor version 15.
    377    */
    378   NPPVformValue = 16,
    379 
    380   NPPVpluginUrlRequestsDisplayedBool = 17,
    381 
    382   /* Checks if the plugin is interested in receiving the http body of
    383    * all http requests (including failed ones, http status != 200).
    384    */
    385   NPPVpluginWantsAllNetworkStreams = 18,
    386 
    387   /* Browsers can retrieve a native ATK accessibility plug ID via this variable. */
    388   NPPVpluginNativeAccessibleAtkPlugId = 19,
    389 
    390   /* Checks to see if the plug-in would like the browser to load the "src" attribute. */
    391   NPPVpluginCancelSrcStream = 20,
    392 
    393   NPPVsupportsAdvancedKeyHandling = 21,
    394 
    395   NPPVpluginUsesDOMForCursorBool = 22
    396 
    397 #if defined(XP_MACOSX)
    398   /* Used for negotiating drawing models */
    399   , NPPVpluginDrawingModel = 1000
    400   /* Used for negotiating event models */
    401   , NPPVpluginEventModel = 1001
    402   /* In the NPDrawingModelCoreAnimation drawing model, the browser asks the plug-in for a Core Animation layer. */
    403   , NPPVpluginCoreAnimationLayer = 1003
    404 #endif
    405 
    406 #if defined(MOZ_PLATFORM_MAEMO) && ((MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6))
    407   , NPPVpluginWindowlessLocalBool = 2002
    408 #endif
    409 } NPPVariable;
    410 
    411 /*
    412  * List of variable names for which NPN_GetValue should be implemented.
    413  */
    414 typedef enum {
    415   NPNVxDisplay = 1,
    416   NPNVxtAppContext,
    417   NPNVnetscapeWindow,
    418   NPNVjavascriptEnabledBool,
    419   NPNVasdEnabledBool,
    420   NPNVisOfflineBool,
    421 
    422   NPNVserviceManager = (10 | NP_ABI_MASK),
    423   NPNVDOMElement     = (11 | NP_ABI_MASK),
    424   NPNVDOMWindow      = (12 | NP_ABI_MASK),
    425   NPNVToolkit        = (13 | NP_ABI_MASK),
    426   NPNVSupportsXEmbedBool = 14,
    427 
    428   /* Get the NPObject wrapper for the browser window. */
    429   NPNVWindowNPObject = 15,
    430 
    431   /* Get the NPObject wrapper for the plugins DOM element. */
    432   NPNVPluginElementNPObject = 16,
    433 
    434   NPNVSupportsWindowless = 17,
    435 
    436   NPNVprivateModeBool = 18,
    437 
    438   NPNVsupportsAdvancedKeyHandling = 21,
    439 
    440   NPNVdocumentOrigin = 22
    441 
    442 #if defined(XP_MACOSX)
    443   /* Used for negotiating drawing models */
    444   , NPNVpluginDrawingModel = 1000
    445 #ifndef NP_NO_QUICKDRAW
    446   , NPNVsupportsQuickDrawBool = 2000
    447 #endif
    448   , NPNVsupportsCoreGraphicsBool = 2001
    449   , NPNVsupportsOpenGLBool = 2002
    450   , NPNVsupportsCoreAnimationBool = 2003
    451   , NPNVsupportsInvalidatingCoreAnimationBool = 2004
    452 #ifndef NP_NO_CARBON
    453   , NPNVsupportsCarbonBool = 3000 /* TRUE if the browser supports the Carbon event model */
    454 #endif
    455   , NPNVsupportsCocoaBool = 3001 /* TRUE if the browser supports the Cocoa event model */
    456   , NPNVsupportsUpdatedCocoaTextInputBool = 3002 /* TRUE if the browser supports the updated
    457                                                     Cocoa text input specification. */
    458   , NPNVsupportsCompositingCoreAnimationPluginsBool = 74656 /* TRUE if the browser supports
    459                                                                CA model compositing */
    460 #endif
    461 #if defined(MOZ_PLATFORM_MAEMO) && ((MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6))
    462   , NPNVSupportsWindowlessLocal = 2002
    463 #endif
    464 } NPNVariable;
    465 
    466 typedef enum {
    467   NPNURLVCookie = 501,
    468   NPNURLVProxy
    469 } NPNURLVariable;
    470 
    471 /*
    472  * The type of Toolkit the widgets use
    473  */
    474 typedef enum {
    475   NPNVGtk12 = 1,
    476   NPNVGtk2
    477 } NPNToolkitType;
    478 
    479 /*
    480  * The type of a NPWindow - it specifies the type of the data structure
    481  * returned in the window field.
    482  */
    483 typedef enum {
    484   NPWindowTypeWindow = 1,
    485   NPWindowTypeDrawable
    486 } NPWindowType;
    487 
    488 typedef struct _NPWindow
    489 {
    490   void* window;  /* Platform specific window handle */
    491                  /* OS/2: x - Position of bottom left corner */
    492                  /* OS/2: y - relative to visible netscape window */
    493   int32_t  x;      /* Position of top left corner relative */
    494   int32_t  y;      /* to a netscape page. */
    495   uint32_t width;  /* Maximum window size */
    496   uint32_t height;
    497   NPRect   clipRect; /* Clipping rectangle in port coordinates */
    498 #if (defined(XP_UNIX) || defined(XP_SYMBIAN)) && !defined(XP_MACOSX)
    499   void * ws_info; /* Platform-dependent additional data */
    500 #endif /* XP_UNIX */
    501   NPWindowType type; /* Is this a window or a drawable? */
    502 } NPWindow;
    503 
    504 typedef struct _NPImageExpose
    505 {
    506   char*    data;       /* image pointer */
    507   int32_t  stride;     /* Stride of data image pointer */
    508   int32_t  depth;      /* Depth of image pointer */
    509   int32_t  x;          /* Expose x */
    510   int32_t  y;          /* Expose y */
    511   uint32_t width;      /* Expose width */
    512   uint32_t height;     /* Expose height */
    513   NPSize   dataSize;   /* Data buffer size */
    514   float    translateX; /* translate X matrix value */
    515   float    translateY; /* translate Y matrix value */
    516   float    scaleX;     /* scale X matrix value */
    517   float    scaleY;     /* scale Y matrix value */
    518 } NPImageExpose;
    519 
    520 typedef struct _NPFullPrint
    521 {
    522   NPBool pluginPrinted;/* Set TRUE if plugin handled fullscreen printing */
    523   NPBool printOne;     /* TRUE if plugin should print one copy to default
    524                           printer */
    525   void* platformPrint; /* Platform-specific printing info */
    526 } NPFullPrint;
    527 
    528 typedef struct _NPEmbedPrint
    529 {
    530   NPWindow window;
    531   void* platformPrint; /* Platform-specific printing info */
    532 } NPEmbedPrint;
    533 
    534 typedef struct _NPPrint
    535 {
    536   uint16_t mode;               /* NP_FULL or NP_EMBED */
    537   union
    538   {
    539     NPFullPrint fullPrint;   /* if mode is NP_FULL */
    540     NPEmbedPrint embedPrint; /* if mode is NP_EMBED */
    541   } print;
    542 } NPPrint;
    543 
    544 #if defined(XP_MACOSX)
    545 #ifndef NP_NO_CARBON
    546 typedef EventRecord NPEvent;
    547 #endif
    548 #elif defined(XP_SYMBIAN)
    549 typedef QEvent NPEvent;
    550 #elif defined(XP_WIN)
    551 typedef struct _NPEvent
    552 {
    553   uint16_t event;
    554   uintptr_t wParam;
    555   uintptr_t lParam;
    556 } NPEvent;
    557 #elif defined(XP_OS2)
    558 typedef struct _NPEvent
    559 {
    560   uint32_t event;
    561   uint32_t wParam;
    562   uint32_t lParam;
    563 } NPEvent;
    564 #elif defined(XP_UNIX) && defined(MOZ_X11)
    565 /* BEGIN GOOGLE MODIFICATIONS */
    566 typedef union _XEvent XEvent;
    567 /* END GOOGLE MODIFICATIONS */
    568 typedef XEvent NPEvent;
    569 #else
    570 typedef void*  NPEvent;
    571 #endif
    572 
    573 #if defined(XP_MACOSX)
    574 typedef void* NPRegion;
    575 #ifndef NP_NO_QUICKDRAW
    576 typedef RgnHandle NPQDRegion;
    577 #endif
    578 typedef CGPathRef NPCGRegion;
    579 #elif defined(XP_WIN)
    580 typedef HRGN NPRegion;
    581 #elif defined(XP_UNIX) && defined(MOZ_X11)
    582 /* BEGIN GOOGLE MODIFICATIONS */
    583 typedef struct _XRegion *Region;
    584 /* END GOOGLE MODIFICATIONS */
    585 typedef Region NPRegion;
    586 #elif defined(XP_SYMBIAN)
    587 typedef QRegion* NPRegion;
    588 #else
    589 typedef void *NPRegion;
    590 #endif
    591 
    592 typedef struct _NPNSString NPNSString;
    593 typedef struct _NPNSWindow NPNSWindow;
    594 typedef struct _NPNSMenu   NPNSMenu;
    595 
    596 #if defined(XP_MACOSX)
    597 typedef NPNSMenu NPMenu;
    598 #else
    599 typedef void *NPMenu;
    600 #endif
    601 
    602 typedef enum {
    603   NPCoordinateSpacePlugin = 1,
    604   NPCoordinateSpaceWindow,
    605   NPCoordinateSpaceFlippedWindow,
    606   NPCoordinateSpaceScreen,
    607   NPCoordinateSpaceFlippedScreen
    608 } NPCoordinateSpace;
    609 
    610 #if defined(XP_MACOSX)
    611 
    612 #ifndef NP_NO_QUICKDRAW
    613 typedef struct NP_Port
    614 {
    615   CGrafPtr port;
    616   int32_t portx; /* position inside the topmost window */
    617   int32_t porty;
    618 } NP_Port;
    619 #endif /* NP_NO_QUICKDRAW */
    620 
    621 /*
    622  * NP_CGContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelCoreGraphics
    623  * as its drawing model.
    624  */
    625 
    626 typedef struct NP_CGContext
    627 {
    628   CGContextRef context;
    629   void *window; /* A WindowRef under the Carbon event model. */
    630 } NP_CGContext;
    631 
    632 /*
    633  * NP_GLContext is the type of the NPWindow's 'window' when the plugin specifies NPDrawingModelOpenGL as its
    634  * drawing model.
    635  */
    636 
    637 typedef struct NP_GLContext
    638 {
    639   CGLContextObj context;
    640 #ifdef NP_NO_CARBON
    641   NPNSWindow *window;
    642 #else
    643   void *window; /* Can be either an NSWindow or a WindowRef depending on the event model */
    644 #endif
    645 } NP_GLContext;
    646 
    647 typedef enum {
    648   NPCocoaEventDrawRect = 1,
    649   NPCocoaEventMouseDown,
    650   NPCocoaEventMouseUp,
    651   NPCocoaEventMouseMoved,
    652   NPCocoaEventMouseEntered,
    653   NPCocoaEventMouseExited,
    654   NPCocoaEventMouseDragged,
    655   NPCocoaEventKeyDown,
    656   NPCocoaEventKeyUp,
    657   NPCocoaEventFlagsChanged,
    658   NPCocoaEventFocusChanged,
    659   NPCocoaEventWindowFocusChanged,
    660   NPCocoaEventScrollWheel,
    661   NPCocoaEventTextInput
    662 } NPCocoaEventType;
    663 
    664 typedef struct _NPCocoaEvent {
    665   NPCocoaEventType type;
    666   uint32_t version;
    667   union {
    668     struct {
    669       uint32_t modifierFlags;
    670       double   pluginX;
    671       double   pluginY;
    672       int32_t  buttonNumber;
    673       int32_t  clickCount;
    674       double   deltaX;
    675       double   deltaY;
    676       double   deltaZ;
    677     } mouse;
    678     struct {
    679       uint32_t    modifierFlags;
    680       NPNSString *characters;
    681       NPNSString *charactersIgnoringModifiers;
    682       NPBool      isARepeat;
    683       uint16_t    keyCode;
    684     } key;
    685     struct {
    686       CGContextRef context;
    687       double x;
    688       double y;
    689       double width;
    690       double height;
    691     } draw;
    692     struct {
    693       NPBool hasFocus;
    694     } focus;
    695     struct {
    696       NPNSString *text;
    697     } text;
    698   } data;
    699 } NPCocoaEvent;
    700 
    701 #ifndef NP_NO_CARBON
    702 /* Non-standard event types that can be passed to HandleEvent */
    703 enum NPEventType {
    704   NPEventType_GetFocusEvent = (osEvt + 16),
    705   NPEventType_LoseFocusEvent,
    706   NPEventType_AdjustCursorEvent,
    707   NPEventType_MenuCommandEvent,
    708   NPEventType_ClippingChangedEvent,
    709   NPEventType_ScrollingBeginsEvent = 1000,
    710   NPEventType_ScrollingEndsEvent
    711 };
    712 #endif /* NP_NO_CARBON */
    713 
    714 #endif /* XP_MACOSX */
    715 
    716 /*
    717  * Values for mode passed to NPP_New:
    718  */
    719 #define NP_EMBED 1
    720 #define NP_FULL  2
    721 
    722 /*
    723  * Values for stream type passed to NPP_NewStream:
    724  */
    725 #define NP_NORMAL     1
    726 #define NP_SEEK       2
    727 #define NP_ASFILE     3
    728 #define NP_ASFILEONLY 4
    729 
    730 #define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
    731 
    732 /*
    733  * Flags for NPP_ClearSiteData.
    734  */
    735 #define NP_CLEAR_ALL   0
    736 #define NP_CLEAR_CACHE (1 << 0)
    737 
    738 #if !defined(__LP64__)
    739 #if defined(XP_MACOSX)
    740 #pragma options align=reset
    741 #endif
    742 #endif /* __LP64__ */
    743 
    744 /*----------------------------------------------------------------------*/
    745 /*       Error and Reason Code definitions                              */
    746 /*----------------------------------------------------------------------*/
    747 
    748 /*
    749  * Values of type NPError:
    750  */
    751 #define NPERR_BASE                         0
    752 #define NPERR_NO_ERROR                    (NPERR_BASE + 0)
    753 #define NPERR_GENERIC_ERROR               (NPERR_BASE + 1)
    754 #define NPERR_INVALID_INSTANCE_ERROR      (NPERR_BASE + 2)
    755 #define NPERR_INVALID_FUNCTABLE_ERROR     (NPERR_BASE + 3)
    756 #define NPERR_MODULE_LOAD_FAILED_ERROR    (NPERR_BASE + 4)
    757 #define NPERR_OUT_OF_MEMORY_ERROR         (NPERR_BASE + 5)
    758 #define NPERR_INVALID_PLUGIN_ERROR        (NPERR_BASE + 6)
    759 #define NPERR_INVALID_PLUGIN_DIR_ERROR    (NPERR_BASE + 7)
    760 #define NPERR_INCOMPATIBLE_VERSION_ERROR  (NPERR_BASE + 8)
    761 #define NPERR_INVALID_PARAM               (NPERR_BASE + 9)
    762 #define NPERR_INVALID_URL                 (NPERR_BASE + 10)
    763 #define NPERR_FILE_NOT_FOUND              (NPERR_BASE + 11)
    764 #define NPERR_NO_DATA                     (NPERR_BASE + 12)
    765 #define NPERR_STREAM_NOT_SEEKABLE         (NPERR_BASE + 13)
    766 #define NPERR_TIME_RANGE_NOT_SUPPORTED    (NPERR_BASE + 14)
    767 #define NPERR_MALFORMED_SITE              (NPERR_BASE + 15)
    768 
    769 /*
    770  * Values of type NPReason:
    771  */
    772 #define NPRES_BASE          0
    773 #define NPRES_DONE         (NPRES_BASE + 0)
    774 #define NPRES_NETWORK_ERR  (NPRES_BASE + 1)
    775 #define NPRES_USER_BREAK   (NPRES_BASE + 2)
    776 
    777 /*
    778  * Don't use these obsolete error codes any more.
    779  */
    780 #define NP_NOERR  NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
    781 #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
    782 #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
    783 
    784 /*
    785  * Version feature information
    786  */
    787 #define NPVERS_HAS_STREAMOUTPUT             8
    788 #define NPVERS_HAS_NOTIFICATION             9
    789 #define NPVERS_HAS_LIVECONNECT              9
    790 #define NPVERS_68K_HAS_LIVECONNECT          11
    791 #define NPVERS_HAS_WINDOWLESS               11
    792 #define NPVERS_HAS_XPCONNECT_SCRIPTING      13
    793 #define NPVERS_HAS_NPRUNTIME_SCRIPTING      14
    794 #define NPVERS_HAS_FORM_VALUES              15
    795 #define NPVERS_HAS_POPUPS_ENABLED_STATE     16
    796 #define NPVERS_HAS_RESPONSE_HEADERS         17
    797 #define NPVERS_HAS_NPOBJECT_ENUM            18
    798 #define NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL 19
    799 #define NPVERS_HAS_ALL_NETWORK_STREAMS      20
    800 #define NPVERS_HAS_URL_AND_AUTH_INFO        21
    801 #define NPVERS_HAS_PRIVATE_MODE             22
    802 #define NPVERS_MACOSX_HAS_COCOA_EVENTS      23
    803 #define NPVERS_HAS_ADVANCED_KEY_HANDLING    25
    804 #define NPVERS_HAS_URL_REDIRECT_HANDLING    26
    805 #define NPVERS_HAS_CLEAR_SITE_DATA          27
    806 
    807 /*----------------------------------------------------------------------*/
    808 /*                        Function Prototypes                           */
    809 /*----------------------------------------------------------------------*/
    810 
    811 #if defined(__OS2__)
    812 #define NP_LOADDS _System
    813 #else
    814 #define NP_LOADDS
    815 #endif
    816 
    817 #ifdef __cplusplus
    818 extern "C" {
    819 #endif
    820 
    821 /* NPP_* functions are provided by the plugin and called by the navigator. */
    822 
    823 #if defined(XP_UNIX)
    824 const char* NPP_GetMIMEDescription(void);
    825 #endif
    826 
    827 NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
    828                           uint16_t mode, int16_t argc, char* argn[],
    829                           char* argv[], NPSavedData* saved);
    830 NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
    831 NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
    832 NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
    833                                 NPStream* stream, NPBool seekable,
    834                                 uint16_t* stype);
    835 NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream,
    836                                     NPReason reason);
    837 int32_t NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
    838 int32_t NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32_t offset,
    839                             int32_t len, void* buffer);
    840 void    NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
    841                                    const char* fname);
    842 void    NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
    843 int16_t NP_LOADDS NPP_HandleEvent(NPP instance, void* event);
    844 void    NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
    845                                 NPReason reason, void* notifyData);
    846 NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, void *value);
    847 NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value);
    848 NPBool  NP_LOADDS NPP_GotFocus(NPP instance, NPFocusDirection direction);
    849 void    NP_LOADDS NPP_LostFocus(NPP instance);
    850 void    NP_LOADDS NPP_URLRedirectNotify(NPP instance, const char* url, int32_t status, void* notifyData);
    851 NPError NP_LOADDS NPP_ClearSiteData(const char* site, uint64_t flags, uint64_t maxAge);
    852 char**  NP_LOADDS NPP_GetSitesWithData(void);
    853 
    854 /* NPN_* functions are provided by the navigator and called by the plugin. */
    855 void        NP_LOADDS NPN_Version(int* plugin_major, int* plugin_minor,
    856                                   int* netscape_major, int* netscape_minor);
    857 NPError     NP_LOADDS NPN_GetURLNotify(NPP instance, const char* url,
    858                                        const char* target, void* notifyData);
    859 NPError     NP_LOADDS NPN_GetURL(NPP instance, const char* url,
    860                                  const char* target);
    861 NPError     NP_LOADDS NPN_PostURLNotify(NPP instance, const char* url,
    862                                         const char* target, uint32_t len,
    863                                         const char* buf, NPBool file,
    864                                         void* notifyData);
    865 NPError     NP_LOADDS NPN_PostURL(NPP instance, const char* url,
    866                                   const char* target, uint32_t len,
    867                                   const char* buf, NPBool file);
    868 NPError     NP_LOADDS NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
    869 NPError     NP_LOADDS NPN_NewStream(NPP instance, NPMIMEType type,
    870                                     const char* target, NPStream** stream);
    871 int32_t     NP_LOADDS NPN_Write(NPP instance, NPStream* stream, int32_t len,
    872                                 void* buffer);
    873 NPError     NP_LOADDS NPN_DestroyStream(NPP instance, NPStream* stream,
    874                                         NPReason reason);
    875 void        NP_LOADDS NPN_Status(NPP instance, const char* message);
    876 const char* NP_LOADDS NPN_UserAgent(NPP instance);
    877 void*       NP_LOADDS NPN_MemAlloc(uint32_t size);
    878 void        NP_LOADDS NPN_MemFree(void* ptr);
    879 uint32_t    NP_LOADDS NPN_MemFlush(uint32_t size);
    880 void        NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages);
    881 NPError     NP_LOADDS NPN_GetValue(NPP instance, NPNVariable variable,
    882                                    void *value);
    883 NPError     NP_LOADDS NPN_SetValue(NPP instance, NPPVariable variable,
    884                                    void *value);
    885 void        NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
    886 void        NP_LOADDS NPN_InvalidateRegion(NPP instance,
    887                                            NPRegion invalidRegion);
    888 void        NP_LOADDS NPN_ForceRedraw(NPP instance);
    889 void        NP_LOADDS NPN_PushPopupsEnabledState(NPP instance, NPBool enabled);
    890 void        NP_LOADDS NPN_PopPopupsEnabledState(NPP instance);
    891 void        NP_LOADDS NPN_PluginThreadAsyncCall(NPP instance,
    892                                                 void (*func) (void *),
    893                                                 void *userData);
    894 NPError     NP_LOADDS NPN_GetValueForURL(NPP instance, NPNURLVariable variable,
    895                                          const char *url, char **value,
    896                                          uint32_t *len);
    897 NPError     NP_LOADDS NPN_SetValueForURL(NPP instance, NPNURLVariable variable,
    898                                          const char *url, const char *value,
    899                                          uint32_t len);
    900 NPError     NP_LOADDS NPN_GetAuthenticationInfo(NPP instance,
    901                                                 const char *protocol,
    902                                                 const char *host, int32_t port,
    903                                                 const char *scheme,
    904                                                 const char *realm,
    905                                                 char **username, uint32_t *ulen,
    906                                                 char **password,
    907                                                 uint32_t *plen);
    908 uint32_t    NP_LOADDS NPN_ScheduleTimer(NPP instance, uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID));
    909 void        NP_LOADDS NPN_UnscheduleTimer(NPP instance, uint32_t timerID);
    910 NPError     NP_LOADDS NPN_PopUpContextMenu(NPP instance, NPMenu* menu);
    911 NPBool      NP_LOADDS NPN_ConvertPoint(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace);
    912 NPBool      NP_LOADDS NPN_HandleEvent(NPP instance, void *event, NPBool handled);
    913 NPBool      NP_LOADDS NPN_UnfocusInstance(NPP instance, NPFocusDirection direction);
    914 void        NP_LOADDS NPN_URLRedirectResponse(NPP instance, void* notifyData, NPBool allow);
    915 
    916 #ifdef __cplusplus
    917 }  /* end extern "C" */
    918 #endif
    919 
    920 #endif /* RC_INVOKED */
    921 #if defined(__OS2__)
    922 #pragma pack()
    923 #endif
    924 
    925 #endif /* npapi_h_ */
    926