Back to index

lightning-sunbird  0.9+nobinonly
npapi.h
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; -*- */
00002 /*
00003  *  npapi.h $Revision: 1.2 $
00004  *  Netscape client plug-in API spec
00005  */
00006 
00007 #ifndef _NPAPI_H_
00008 #define _NPAPI_H_
00009 
00010 #include "jri.h"                /* Java Runtime Interface */
00011 
00012 #ifdef _WINDOWS
00013 # ifndef XP_WIN
00014 #   define XP_WIN 1
00015 # endif /* XP_WIN */
00016 #endif /* _WINDOWS */
00017 
00018 #ifdef __MWERKS__
00019 # define _declspec __declspec
00020 # ifdef macintosh
00021 #   ifndef XP_MAC
00022 #     define XP_MAC 1
00023 #   endif /* XP_MAC */
00024 # endif /* macintosh */
00025 # ifdef __INTEL__
00026 #   undef NULL
00027 #   ifndef XP_WIN
00028 #     define XP_WIN 1
00029 #   endif /* XP_WIN */
00030 # endif /* __INTELL__ */
00031 #endif /* __MWERKS__ */
00032 
00033 #ifdef XP_MAC
00034   #include <Quickdraw.h>
00035   #include <Events.h>
00036 #endif
00037               
00038 #ifdef XP_UNIX
00039   #include <X11/Xlib.h>
00040   #include <X11/Xutil.h>
00041 #endif          
00042 
00043 
00044 /*----------------------------------------------------------------------*/
00045 /*         Plugin Version Constants       */
00046 /*----------------------------------------------------------------------*/
00047 
00048 #define NP_VERSION_MAJOR 0
00049 #define NP_VERSION_MINOR 11
00050 
00051 
00052 
00053 /*----------------------------------------------------------------------*/
00054 /*         Definition of Basic Types        */
00055 /*----------------------------------------------------------------------*/
00056 
00057 #ifndef _UINT16
00058 typedef unsigned short uint16;
00059 #endif
00060 #ifndef _UINT32
00061 #if defined(__alpha)
00062 typedef unsigned int uint32;
00063 #else /* __alpha */
00064 typedef unsigned long uint32;
00065 #endif /* __alpha */
00066 #endif
00067 #ifndef _INT16
00068 typedef short int16;
00069 #endif
00070 #ifndef _INT32
00071 #if defined(__alpha)
00072 typedef int int32;
00073 #else /* __alpha */
00074 typedef long int32;
00075 #endif /* __alpha */
00076 #endif
00077 
00078 #ifndef FALSE
00079 #define FALSE (0)
00080 #endif
00081 #ifndef TRUE
00082 #define TRUE (1)
00083 #endif
00084 #ifndef NULL
00085 #define NULL (0L)
00086 #endif
00087 
00088 typedef unsigned char NPBool;
00089 typedef int16     NPError;
00090 typedef int16     NPReason;
00091 typedef char*     NPMIMEType;
00092 
00093 
00094 
00095 /*----------------------------------------------------------------------*/
00096 /*         Structures and definitions       */
00097 /*----------------------------------------------------------------------*/
00098 
00099 #ifdef XP_MAC
00100 #pragma options align=mac68k
00101 #endif
00102 
00103 /*
00104  *  NPP is a plug-in's opaque instance handle
00105  */
00106 typedef struct _NPP
00107 {
00108     void* pdata;      /* plug-in private data */
00109     void* ndata;      /* netscape private data */
00110 } NPP_t;
00111 
00112 typedef NPP_t*  NPP;
00113 
00114 
00115 typedef struct _NPStream
00116 {
00117     void*   pdata;    /* plug-in private data */
00118     void*   ndata;    /* netscape private data */
00119     const char*   url;
00120     uint32    end;
00121     uint32    lastmodified;
00122     void*   notifyData;
00123 } NPStream;
00124 
00125 
00126 typedef struct _NPByteRange
00127 {
00128     int32 offset;     /* negative offset means from the end */
00129     uint32  length;
00130     struct _NPByteRange* next;
00131 } NPByteRange;
00132 
00133 
00134 typedef struct _NPSavedData
00135 {
00136     int32 len;
00137     void* buf;
00138 } NPSavedData;
00139 
00140 
00141 typedef struct _NPRect
00142 {
00143     uint16  top;
00144     uint16  left;
00145     uint16  bottom;
00146     uint16  right;
00147 } NPRect;
00148 
00149 
00150 #ifdef XP_UNIX
00151 /*
00152  * Unix specific structures and definitions
00153  */
00154 
00155 /*
00156  * Callback Structures.
00157  *
00158  * These are used to pass additional platform specific information.
00159  */
00160 enum {
00161   NP_SETWINDOW = 1,
00162   NP_PRINT
00163 };
00164 
00165 typedef struct
00166 {
00167     int32   type;
00168 } NPAnyCallbackStruct;
00169 
00170 typedef struct
00171 {
00172     int32     type;
00173     Display*    display;
00174     Visual*     visual;
00175     Colormap    colormap;
00176     unsigned int  depth;
00177 } NPSetWindowCallbackStruct;
00178 
00179 typedef struct
00180 {
00181     int32     type;
00182     FILE*     fp;
00183 } NPPrintCallbackStruct;
00184 
00185 #endif /* XP_UNIX */
00186 
00187 /*
00188  * List of variable names for which NPP_GetValue shall be implemented
00189  */
00190 typedef enum {
00191   NPPVpluginNameString = 1,
00192   NPPVpluginDescriptionString,
00193   NPPVpluginWindowBool,
00194   NPPVpluginTransparentBool
00195 } NPPVariable;
00196 
00197 /*
00198  * List of variable names for which NPN_GetValue is implemented by Mozilla
00199  */
00200 typedef enum {
00201   NPNVxDisplay = 1,
00202   NPNVxtAppContext,
00203     NPNVnetscapeWindow,
00204   NPNVjavascriptEnabledBool,
00205   NPNVasdEnabledBool,
00206   NPNVisOfflineBool
00207 } NPNVariable;
00208 
00209 /*
00210  * The type of a NPWindow - it specifies the type of the data structure
00211  * returned in the window field.
00212  */
00213 typedef enum {
00214     NPWindowTypeWindow = 1,
00215     NPWindowTypeDrawable
00216 } NPWindowType;
00217 
00218 typedef struct _NPWindow
00219 {
00220     void* window;   /* Platform specific window handle */
00221     int32 x;      /* Position of top left corner relative */
00222     int32 y;      /*  to a netscape page.         */
00223     uint32  width;    /* Maximum window size */
00224     uint32  height;
00225     NPRect  clipRect; /* Clipping rectangle in port coordinates */
00226             /* Used by MAC only.        */
00227 #ifdef XP_UNIX
00228     void *  ws_info;  /* Platform-dependent additonal data */
00229 #endif /* XP_UNIX */
00230     NPWindowType type;  /* Is this a window or a drawable? */
00231 } NPWindow;
00232 
00233 
00234 typedef struct _NPFullPrint
00235 {
00236     NPBool  pluginPrinted;  /* Set TRUE if plugin handled fullscreen */
00237               /*  printing               */
00238     NPBool  printOne;   /* TRUE if plugin should print one copy  */
00239               /*  to default printer           */
00240     void* platformPrint;  /* Platform-specific printing info */
00241 } NPFullPrint;
00242 
00243 typedef struct _NPEmbedPrint
00244 {
00245     NPWindow  window;
00246     void* platformPrint;  /* Platform-specific printing info */
00247 } NPEmbedPrint;
00248 
00249 typedef struct _NPPrint
00250 {
00251     uint16  mode;           /* NP_FULL or NP_EMBED */
00252     union
00253     {
00254     NPFullPrint   fullPrint;    /* if mode is NP_FULL */
00255     NPEmbedPrint  embedPrint;   /* if mode is NP_EMBED */
00256     } print;
00257 } NPPrint;
00258 
00259 #ifdef XP_MAC
00260 typedef EventRecord NPEvent;
00261 #elif defined(XP_WIN)
00262 typedef struct _NPEvent
00263 {
00264     uint16   event;
00265     uint32   wParam;
00266     uint32   lParam;
00267 } NPEvent;
00268 #elif defined (XP_UNIX)
00269 typedef XEvent NPEvent;
00270 #else
00271 typedef void*     NPEvent;
00272 #endif /* XP_MAC */
00273 
00274 #ifdef XP_MAC
00275 typedef RgnHandle NPRegion;
00276 #elif defined(XP_WIN)
00277 typedef HRGN NPRegion;
00278 #elif defined(XP_UNIX)
00279 typedef Region NPRegion;
00280 #else
00281 typedef void *NPRegion;
00282 #endif /* XP_MAC */
00283 
00284 #ifdef XP_MAC
00285 /*
00286  *  Mac-specific structures and definitions.
00287  */
00288 
00289 typedef struct NP_Port
00290 {
00291     CGrafPtr  port;   /* Grafport */
00292     int32   portx;    /* position inside the topmost window */
00293     int32   porty;
00294 } NP_Port;
00295 
00296 /*
00297  *  Non-standard event types that can be passed to HandleEvent
00298  */
00299 #define getFocusEvent     (osEvt + 16)
00300 #define loseFocusEvent      (osEvt + 17)
00301 #define adjustCursorEvent   (osEvt + 18)
00302 
00303 #endif /* XP_MAC */
00304 
00305 
00306 /*
00307  * Values for mode passed to NPP_New:
00308  */
00309 #define NP_EMBED    1
00310 #define NP_FULL     2
00311 
00312 /*
00313  * Values for stream type passed to NPP_NewStream:
00314  */
00315 #define NP_NORMAL   1
00316 #define NP_SEEK     2
00317 #define NP_ASFILE   3
00318 #define NP_ASFILEONLY   4
00319 
00320 #define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
00321 
00322 #ifdef XP_MAC
00323 #pragma options align=reset
00324 #endif
00325 
00326 
00327 /*----------------------------------------------------------------------*/
00328 /*         Error and Reason Code definitions      */
00329 /*----------------------------------------------------------------------*/
00330 
00331 /*
00332  *  Values of type NPError:
00333  */
00334 #define NPERR_BASE              0
00335 #define NPERR_NO_ERROR            (NPERR_BASE + 0)
00336 #define NPERR_GENERIC_ERROR         (NPERR_BASE + 1)
00337 #define NPERR_INVALID_INSTANCE_ERROR    (NPERR_BASE + 2)
00338 #define NPERR_INVALID_FUNCTABLE_ERROR   (NPERR_BASE + 3)
00339 #define NPERR_MODULE_LOAD_FAILED_ERROR    (NPERR_BASE + 4)
00340 #define NPERR_OUT_OF_MEMORY_ERROR     (NPERR_BASE + 5)
00341 #define NPERR_INVALID_PLUGIN_ERROR      (NPERR_BASE + 6)
00342 #define NPERR_INVALID_PLUGIN_DIR_ERROR    (NPERR_BASE + 7)
00343 #define NPERR_INCOMPATIBLE_VERSION_ERROR  (NPERR_BASE + 8)
00344 #define NPERR_INVALID_PARAM       (NPERR_BASE + 9)
00345 #define NPERR_INVALID_URL         (NPERR_BASE + 10)
00346 #define NPERR_FILE_NOT_FOUND        (NPERR_BASE + 11)
00347 #define NPERR_NO_DATA           (NPERR_BASE + 12)
00348 #define NPERR_STREAM_NOT_SEEKABLE     (NPERR_BASE + 13)
00349 
00350 /*
00351  *  Values of type NPReason:
00352  */
00353 #define NPRES_BASE        0
00354 #define NPRES_DONE          (NPRES_BASE + 0)
00355 #define NPRES_NETWORK_ERR     (NPRES_BASE + 1)
00356 #define NPRES_USER_BREAK      (NPRES_BASE + 2)
00357 
00358 /*
00359  *      Don't use these obsolete error codes any more.
00360  */
00361 #define NP_NOERR  NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
00362 #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
00363 #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
00364 
00365 /*
00366  * Version feature information
00367  */
00368 #define NPVERS_HAS_STREAMOUTPUT   8
00369 #define NPVERS_HAS_NOTIFICATION   9
00370 #define NPVERS_HAS_LIVECONNECT    9
00371 #define NPVERS_WIN16_HAS_LIVECONNECT  9
00372 #define NPVERS_68K_HAS_LIVECONNECT  11
00373 #define NPVERS_HAS_WINDOWLESS       11
00374 
00375 
00376 /*----------------------------------------------------------------------*/
00377 /*         Function Prototypes        */
00378 /*----------------------------------------------------------------------*/
00379 
00380 #if defined(_WINDOWS) && !defined(WIN32)
00381 #define NP_LOADDS  _loadds
00382 #else
00383 #define NP_LOADDS
00384 #endif
00385 
00386 #ifdef __cplusplus
00387 extern "C" {
00388 #endif
00389 
00390 /*
00391  * NPP_* functions are provided by the plugin and called by the navigator.
00392  */
00393 
00394 #ifdef XP_UNIX
00395 char*         NPP_GetMIMEDescription(void);
00396 #endif /* XP_UNIX */
00397 
00398 NPError    NPP_Initialize(void);
00399 void       NPP_Shutdown(void);
00400 NPError     NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
00401                 uint16 mode, int16 argc, char* argn[],
00402                 char* argv[], NPSavedData* saved);
00403 NPError     NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
00404 NPError     NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
00405 NPError     NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
00406                     NPStream* stream, NPBool seekable,
00407                     uint16* stype);
00408 NPError     NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream,
00409                       NPReason reason);
00410 int32     NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
00411 int32     NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset,
00412                   int32 len, void* buffer);
00413 void      NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
00414                      const char* fname);
00415 void      NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
00416 int16     NPP_HandleEvent(NPP instance, void* event);
00417 void      NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
00418                     NPReason reason, void* notifyData);
00419 jref      NP_LOADDS     NPP_GetJavaClass(void);
00420 NPError         NPP_GetValue(void *instance, NPPVariable variable,
00421                    void *value);
00422 NPError         NPP_SetValue(void *instance, NPNVariable variable,
00423                    void *value);
00424 
00425 /*
00426  * NPN_* functions are provided by the navigator and called by the plugin.
00427  */
00428 
00429 void    NPN_Version(int* plugin_major, int* plugin_minor,
00430               int* netscape_major, int* netscape_minor);
00431 NPError   NPN_GetURLNotify(NPP instance, const char* url,
00432                  const char* target, void* notifyData);
00433 NPError   NPN_GetURL(NPP instance, const char* url,
00434                const char* target);
00435 NPError   NPN_PostURLNotify(NPP instance, const char* url,
00436                   const char* target, uint32 len,
00437                   const char* buf, NPBool file,
00438                   void* notifyData);
00439 NPError   NPN_PostURL(NPP instance, const char* url,
00440               const char* target, uint32 len,
00441               const char* buf, NPBool file);
00442 NPError   NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
00443 NPError   NPN_NewStream(NPP instance, NPMIMEType type,
00444                 const char* target, NPStream** stream);
00445 int32   NPN_Write(NPP instance, NPStream* stream, int32 len,
00446               void* buffer);
00447 NPError     NPN_DestroyStream(NPP instance, NPStream* stream,
00448                   NPReason reason);
00449 void    NPN_Status(NPP instance, const char* message);
00450 const char* NPN_UserAgent(NPP instance);
00451 void*   NPN_MemAlloc(uint32 size);
00452 void    NPN_MemFree(void* ptr);
00453 uint32    NPN_MemFlush(uint32 size);
00454 void      NPN_ReloadPlugins(NPBool reloadPages);
00455 JRIEnv*     NPN_GetJavaEnv(void);
00456 jref      NPN_GetJavaPeer(NPP instance);
00457 NPError     NPN_GetValue(NPP instance, NPNVariable variable,
00458                void *value);
00459 NPError     NPN_SetValue(NPP instance, NPPVariable variable,
00460                void *value);
00461 void    NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
00462 void    NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
00463 void    NPN_ForceRedraw(NPP instance);
00464 
00465 #ifdef __cplusplus
00466 }  /* end extern "C" */
00467 #endif
00468 
00469 #endif /* _NPAPI_H_ */