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