home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / npapi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  15.2 KB  |  570 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19.  
  20. /*
  21.  *  npapi.h $Revision: 3.1 $
  22.  *  Netscape client plug-in API spec
  23.  */
  24.  
  25. #ifndef _NPAPI_H_
  26. #define _NPAPI_H_
  27.  
  28. #ifdef __OS2__
  29. #pragma pack(1)
  30. #endif
  31.  
  32. #include "jri.h"                /* Java Runtime Interface */
  33.  
  34. #if defined (__OS2__ ) || defined (OS2)
  35. #    ifndef XP_OS2
  36. #        define XP_OS2 1
  37. #    endif /* XP_OS2 */
  38. #endif /* __OS2__ */
  39.  
  40. #ifdef _WINDOWS
  41. #    ifndef XP_WIN
  42. #        define XP_WIN 1
  43. #    endif /* XP_WIN */
  44. #endif /* _WINDOWS */
  45.  
  46. #ifdef __MWERKS__
  47. #    define _declspec __declspec
  48. #    ifdef macintosh
  49. #        ifndef XP_MAC
  50. #            define XP_MAC 1
  51. #        endif /* XP_MAC */
  52. #    endif /* macintosh */
  53. #    ifdef __INTEL__
  54. #        undef NULL
  55. #        ifndef XP_WIN
  56. #            define XP_WIN 1
  57. #        endif /* __INTEL__ */
  58. #    endif /* XP_PC */
  59. #endif /* __MWERKS__ */
  60.  
  61. #ifdef XP_MAC
  62.     #include <Quickdraw.h>
  63.     #include <Events.h>
  64. #endif
  65.  
  66. #ifdef XP_UNIX
  67.     #include <X11/Xlib.h>
  68.     #include <X11/Xutil.h>
  69. #endif
  70.  
  71.  
  72. /*----------------------------------------------------------------------*/
  73. /*             Plugin Version Constants                */
  74. /*----------------------------------------------------------------------*/
  75.  
  76. #define NP_VERSION_MAJOR 0
  77. #define NP_VERSION_MINOR 12
  78.  
  79.  
  80. /* The OS/2 version of Netscape uses RC_DATA to define the
  81.    mime types, file extentions, etc that are required.
  82.    Use a vertical bar to seperate types, end types with \0.
  83.    FileVersion and ProductVersion are 32bit ints, all other
  84.    entries are strings the MUST be terminated wwith a \0.
  85.  
  86. AN EXAMPLE:
  87.  
  88. RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
  89.  
  90. RCDATA NP_INFO_MIMEType    { "video/x-video|",
  91.                              "video/x-flick\0" }
  92. RCDATA NP_INFO_FileExtents { "avi|",
  93.                              "flc\0" }
  94. RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
  95.                              "MMOS2 Flc/Fli player(*.flc)\0" }
  96.  
  97. RCDATA NP_INFO_FileVersion       { 1,0,0,1 }
  98. RCDATA NP_INFO_CompanyName       { "Netscape Communications\0" }
  99. RCDATA NP_INFO_FileDescription   { "NPAVI32 Extension DLL\0"
  100. RCDATA NP_INFO_InternalName      { "NPAVI32\0" )
  101. RCDATA NP_INFO_LegalCopyright    { "Copyright Netscape Communications \251 1996\0"
  102. RCDATA NP_INFO_OriginalFilename  { "NVAPI32.DLL" }
  103. RCDATA NP_INFO_ProductName       { "NPAVI32 Dynamic Link Library\0" }
  104.  
  105. */
  106.  
  107.  
  108. /* RC_DATA types for version info - required */
  109. #define NP_INFO_ProductVersion      1
  110. #define NP_INFO_MIMEType            2
  111. #define NP_INFO_FileOpenName        3
  112. #define NP_INFO_FileExtents         4
  113.  
  114. /* RC_DATA types for version info - used if found */
  115. #define NP_INFO_FileDescription     5
  116. #define NP_INFO_ProductName         6
  117.  
  118. /* RC_DATA types for version info - optional */
  119. #define NP_INFO_CompanyName         7
  120. #define NP_INFO_FileVersion         8
  121. #define NP_INFO_InternalName        9
  122. #define NP_INFO_LegalCopyright      10
  123. #define NP_INFO_OriginalFilename    11
  124.  
  125. #ifndef RC_INVOKED
  126.  
  127.  
  128.  
  129. /*----------------------------------------------------------------------*/
  130. /*             Definition of Basic Types                */
  131. /*----------------------------------------------------------------------*/
  132.  
  133. #ifndef _UINT16
  134. typedef unsigned short uint16;
  135. #endif
  136. #ifndef _UINT32
  137. #if defined(__alpha)
  138. typedef unsigned int uint32;
  139. #else /* __alpha */
  140. typedef unsigned long uint32;
  141. #endif /* __alpha */
  142. #endif
  143. #ifndef _INT16
  144. typedef short int16;
  145. #endif
  146. #ifndef _INT32
  147. #if defined(__alpha)
  148. typedef int int32;
  149. #else /* __alpha */
  150. typedef long int32;
  151. #endif /* __alpha */
  152. #endif
  153.  
  154. #ifndef FALSE
  155. #define FALSE (0)
  156. #endif
  157. #ifndef TRUE
  158. #define TRUE (1)
  159. #endif
  160. #ifndef NULL
  161. #define NULL (0L)
  162. #endif
  163.  
  164. typedef unsigned char    NPBool;
  165. typedef int16            NPError;
  166. typedef int16            NPReason;
  167. typedef char*            NPMIMEType;
  168.  
  169.  
  170.  
  171. /*----------------------------------------------------------------------*/
  172. /*             Structures and definitions             */
  173. /*----------------------------------------------------------------------*/
  174.  
  175. #ifdef XP_MAC
  176. #pragma options align=mac68k
  177. #endif
  178.  
  179. /*
  180.  *  NPP is a plug-in's opaque instance handle
  181.  */
  182. typedef struct _NPP
  183. {
  184.     void*    pdata;            /* plug-in private data */
  185.     void*    ndata;            /* netscape private data */
  186. } NPP_t;
  187.  
  188. typedef NPP_t*    NPP;
  189.  
  190.  
  191. typedef struct _NPStream
  192. {
  193.     void*        pdata;        /* plug-in private data */
  194.     void*        ndata;        /* netscape private data */
  195.     const char*     url;
  196.     uint32        end;
  197.     uint32        lastmodified;
  198.     void*        notifyData;
  199. } NPStream;
  200.  
  201.  
  202. typedef struct _NPByteRange
  203. {
  204.     int32    offset;         /* negative offset means from the end */
  205.     uint32    length;
  206.     struct _NPByteRange* next;
  207. } NPByteRange;
  208.  
  209.  
  210. typedef struct _NPSavedData
  211. {
  212.     int32    len;
  213.     void*    buf;
  214. } NPSavedData;
  215.  
  216.  
  217. typedef struct _NPRect
  218. {
  219.     uint16    top;
  220.     uint16    left;
  221.     uint16    bottom;
  222.     uint16    right;
  223. } NPRect;
  224.  
  225. typedef struct _NPSize 
  226.   int32 width; 
  227.   int32 height; 
  228. } NPSize; 
  229.  
  230. #ifdef XP_UNIX
  231. /*
  232.  * Unix specific structures and definitions
  233.  */
  234.  
  235. /*
  236.  * Callback Structures.
  237.  *
  238.  * These are used to pass additional platform specific information.
  239.  */
  240. enum {
  241.     NP_SETWINDOW = 1,
  242.     NP_PRINT
  243. };
  244.  
  245. typedef struct
  246. {
  247.     int32        type;
  248. } NPAnyCallbackStruct;
  249.  
  250. typedef struct
  251. {
  252.     int32            type;
  253.     Display*        display;
  254.     Visual*            visual;
  255.     Colormap        colormap;
  256.     unsigned int    depth;
  257. } NPSetWindowCallbackStruct;
  258.  
  259. typedef struct
  260. {
  261.     int32            type;
  262.     FILE*            fp;
  263. } NPPrintCallbackStruct;
  264.  
  265. #endif /* XP_UNIX */
  266.  
  267. /*
  268.  * List of variable names for which NPP_GetValue shall be implemented
  269.  */
  270. typedef enum {
  271.     NPPVpluginNameString = 1,
  272.     NPPVpluginDescriptionString,
  273.     NPPVpluginWindowBool,
  274.     NPPVpluginTransparentBool,
  275.   NPPVjavaClass,
  276.   NPPVpluginWindowSize
  277. } NPPVariable;
  278.  
  279. /*
  280.  * List of variable names for which NPN_GetValue is implemented by Mozilla
  281.  */
  282. typedef enum {
  283.     NPNVxDisplay = 1,
  284.     NPNVxtAppContext,
  285.     NPNVnetscapeWindow,
  286.     NPNVjavascriptEnabledBool,
  287.     NPNVasdEnabledBool,
  288.     NPNVisOfflineBool
  289. } NPNVariable;
  290.  
  291. /*
  292.  * The type of a NPWindow - it specifies the type of the data structure
  293.  * returned in the window field.
  294.  */
  295. typedef enum {
  296.     NPWindowTypeWindow = 1,
  297.     NPWindowTypeDrawable
  298. } NPWindowType;
  299.  
  300. typedef struct _NPWindow
  301. {
  302.     void*    window;        /* Platform specific window handle */
  303.                                         /* OS/2: x - Position of bottom left corner  */
  304.                                         /* OS/2: y - relative to visible netscape window */
  305.     uint32    x;            /* Position of top left corner relative */
  306.     uint32    y;             /*    to a netscape page.                    */
  307.     uint32    width;        /* Maximum window size */
  308.     uint32    height;
  309.     NPRect    clipRect;    /* Clipping rectangle in port coordinates */
  310.                         /* Used by MAC only.              */
  311. #ifdef XP_UNIX
  312.     void *    ws_info;    /* Platform-dependent additonal data */
  313. #endif /* XP_UNIX */
  314.     NPWindowType type;    /* Is this a window or a drawable? */
  315. } NPWindow;
  316.  
  317.  
  318. typedef struct _NPFullPrint
  319. {
  320.     NPBool    pluginPrinted;    /* Set TRUE if plugin handled fullscreen */
  321.                             /*    printing                             */
  322.     NPBool    printOne;        /* TRUE if plugin should print one copy  */
  323.                             /*    to default printer                     */
  324.     void*    platformPrint;    /* Platform-specific printing info */
  325. } NPFullPrint;
  326.  
  327. typedef struct _NPEmbedPrint
  328. {
  329.     NPWindow    window;
  330.     void*    platformPrint;    /* Platform-specific printing info */
  331. } NPEmbedPrint;
  332.  
  333. typedef struct _NPPrint
  334. {
  335.     uint16    mode;                        /* NP_FULL or NP_EMBED */
  336.     union
  337.     {
  338.         NPFullPrint        fullPrint;        /* if mode is NP_FULL */
  339.         NPEmbedPrint    embedPrint;        /* if mode is NP_EMBED */
  340.     } print;
  341. } NPPrint;
  342.  
  343. #ifdef XP_MAC
  344. typedef EventRecord    NPEvent;
  345. #elif defined(XP_WIN)
  346. typedef struct _NPEvent
  347. {
  348.     uint16   event;
  349.     uint32   wParam;
  350.     uint32   lParam;
  351. } NPEvent;
  352. #elif defined(XP_OS2)
  353. typedef struct _NPEvent
  354. {
  355.     uint32   event;
  356.     uint32   wParam;
  357.     uint32   lParam;
  358. } NPEvent;
  359. #elif defined (XP_UNIX)
  360. typedef XEvent NPEvent;
  361. #else
  362. typedef void*            NPEvent;
  363. #endif /* XP_MAC */
  364.  
  365. #ifdef XP_MAC
  366. typedef RgnHandle NPRegion;
  367. #elif defined(XP_WIN)
  368. typedef HRGN NPRegion;
  369. #elif defined(XP_UNIX)
  370. typedef Region NPRegion;
  371. #else
  372. typedef void *NPRegion;
  373. #endif /* XP_MAC */
  374.  
  375. #ifdef XP_MAC
  376. /*
  377.  *  Mac-specific structures and definitions.
  378.  */
  379.  
  380. typedef struct NP_Port
  381. {
  382.     CGrafPtr    port;        /* Grafport */
  383.     int32        portx;        /* position inside the topmost window */
  384.     int32        porty;
  385. } NP_Port;
  386.  
  387. /*
  388.  *  Non-standard event types that can be passed to HandleEvent
  389.  */
  390. #define getFocusEvent        (osEvt + 16)
  391. #define loseFocusEvent        (osEvt + 17)
  392. #define adjustCursorEvent   (osEvt + 18)
  393.  
  394. #endif /* XP_MAC */
  395.  
  396.  
  397. /*
  398.  * Values for mode passed to NPP_New:
  399.  */
  400. #define NP_EMBED        1
  401. #define NP_FULL         2
  402.  
  403. /*
  404.  * Values for stream type passed to NPP_NewStream:
  405.  */
  406. #define NP_NORMAL        1
  407. #define NP_SEEK         2
  408. #define NP_ASFILE        3
  409. #define NP_ASFILEONLY        4
  410.  
  411. #define NP_MAXREADY    (((unsigned)(~0)<<1)>>1)
  412.  
  413. #ifdef XP_MAC
  414. #pragma options align=reset
  415. #endif
  416.  
  417.  
  418. /*----------------------------------------------------------------------*/
  419. /*             Error and Reason Code definitions            */
  420. /*----------------------------------------------------------------------*/
  421.  
  422. /*
  423.  *    Values of type NPError:
  424.  */
  425. #define NPERR_BASE                            0
  426. #define NPERR_NO_ERROR                        (NPERR_BASE + 0)
  427. #define NPERR_GENERIC_ERROR                    (NPERR_BASE + 1)
  428. #define NPERR_INVALID_INSTANCE_ERROR        (NPERR_BASE + 2)
  429. #define NPERR_INVALID_FUNCTABLE_ERROR        (NPERR_BASE + 3)
  430. #define NPERR_MODULE_LOAD_FAILED_ERROR        (NPERR_BASE + 4)
  431. #define NPERR_OUT_OF_MEMORY_ERROR            (NPERR_BASE + 5)
  432. #define NPERR_INVALID_PLUGIN_ERROR            (NPERR_BASE + 6)
  433. #define NPERR_INVALID_PLUGIN_DIR_ERROR        (NPERR_BASE + 7)
  434. #define NPERR_INCOMPATIBLE_VERSION_ERROR    (NPERR_BASE + 8)
  435. #define NPERR_INVALID_PARAM                (NPERR_BASE + 9)
  436. #define NPERR_INVALID_URL                    (NPERR_BASE + 10)
  437. #define NPERR_FILE_NOT_FOUND                (NPERR_BASE + 11)
  438. #define NPERR_NO_DATA                        (NPERR_BASE + 12)
  439. #define NPERR_STREAM_NOT_SEEKABLE            (NPERR_BASE + 13)
  440.  
  441. /*
  442.  *    Values of type NPReason:
  443.  */
  444. #define NPRES_BASE                0
  445. #define NPRES_DONE                    (NPRES_BASE + 0)
  446. #define NPRES_NETWORK_ERR            (NPRES_BASE + 1)
  447. #define NPRES_USER_BREAK            (NPRES_BASE + 2)
  448.  
  449. /*
  450.  *      Don't use these obsolete error codes any more.
  451.  */
  452. #define NP_NOERR  NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
  453. #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
  454. #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
  455.  
  456. /*
  457.  * Version feature information
  458.  */
  459. #define NPVERS_HAS_STREAMOUTPUT     8
  460. #define NPVERS_HAS_NOTIFICATION     9
  461. #define NPVERS_HAS_LIVECONNECT        9
  462. #define NPVERS_WIN16_HAS_LIVECONNECT    9
  463. #define NPVERS_68K_HAS_LIVECONNECT    11
  464. #define NPVERS_HAS_WINDOWLESS       11
  465.  
  466.  
  467. /*----------------------------------------------------------------------*/
  468. /*             Function Prototypes                */
  469. /*----------------------------------------------------------------------*/
  470.  
  471. #if defined(_WINDOWS) && !defined(WIN32)
  472. #define NP_LOADDS  _loadds
  473. #else
  474. #if defined(__OS2__)
  475. #define NP_LOADDS _System
  476. #else
  477. #define NP_LOADDS
  478. #endif
  479. #endif
  480.  
  481. #ifdef __cplusplus
  482. extern "C" {
  483. #endif
  484.  
  485. /*
  486.  * NPP_* functions are provided by the plugin and called by the navigator.
  487.  */
  488.  
  489. #ifdef XP_UNIX
  490. char*                    NPP_GetMIMEDescription(void);
  491. #endif /* XP_UNIX */
  492.  
  493. NPError     NP_LOADDS    NPP_Initialize(void);
  494. void        NP_LOADDS    NPP_Shutdown(void);
  495. NPError     NP_LOADDS    NPP_New(NPMIMEType pluginType, NPP instance,
  496.                                 uint16 mode, int16 argc, char* argn[],
  497.                                 char* argv[], NPSavedData* saved);
  498. NPError     NP_LOADDS    NPP_Destroy(NPP instance, NPSavedData** save);
  499. NPError     NP_LOADDS    NPP_SetWindow(NPP instance, NPWindow* window);
  500. NPError     NP_LOADDS    NPP_NewStream(NPP instance, NPMIMEType type,
  501.                                       NPStream* stream, NPBool seekable,
  502.                                       uint16* stype);
  503. NPError     NP_LOADDS    NPP_DestroyStream(NPP instance, NPStream* stream,
  504.                                           NPReason reason);
  505. int32        NP_LOADDS    NPP_WriteReady(NPP instance, NPStream* stream);
  506. int32        NP_LOADDS    NPP_Write(NPP instance, NPStream* stream, int32 offset,
  507.                                   int32 len, void* buffer);
  508. void        NP_LOADDS    NPP_StreamAsFile(NPP instance, NPStream* stream,
  509.                                          const char* fname);
  510. void        NP_LOADDS    NPP_Print(NPP instance, NPPrint* platformPrint);
  511. int16       NP_LOADDS    NPP_HandleEvent(NPP instance, void* event);
  512. void        NP_LOADDS    NPP_URLNotify(NPP instance, const char* url,
  513.                                       NPReason reason, void* notifyData);
  514. jref        NP_LOADDS            NPP_GetJavaClass(void);
  515. NPError            NP_LOADDS    NPP_GetValue(void *instance, NPPVariable variable,
  516.                                      void *value);
  517. NPError            NP_LOADDS    NPP_SetValue(void *instance, NPNVariable variable,
  518.                                      void *value);
  519.  
  520. /*
  521.  * NPN_* functions are provided by the navigator and called by the plugin.
  522.  */
  523. void       NP_LOADDS    NPN_Version(int* plugin_major, int* plugin_minor,
  524.                             int* netscape_major, int* netscape_minor);
  525. NPError    NP_LOADDS    NPN_GetURLNotify(NPP instance, const char* url,
  526.                                  const char* target, void* notifyData);
  527. NPError    NP_LOADDS    NPN_GetURL(NPP instance, const char* url,
  528.                            const char* target);
  529. NPError    NP_LOADDS    NPN_PostURLNotify(NPP instance, const char* url,
  530.                                   const char* target, uint32 len,
  531.                                   const char* buf, NPBool file,
  532.                                   void* notifyData);
  533. NPError    NP_LOADDS    NPN_PostURL(NPP instance, const char* url,
  534.                             const char* target, uint32 len,
  535.                             const char* buf, NPBool file);
  536. NPError    NP_LOADDS    NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
  537. NPError    NP_LOADDS    NPN_NewStream(NPP instance, NPMIMEType type,
  538.                               const char* target, NPStream** stream);
  539. int32      NP_LOADDS    NPN_Write(NPP instance, NPStream* stream, int32 len,
  540.                           void* buffer);
  541. NPError    NP_LOADDS    NPN_DestroyStream(NPP instance, NPStream* stream,
  542.                                   NPReason reason);
  543. void       NP_LOADDS    NPN_Status(NPP instance, const char* message);
  544. const char* NP_LOADDS    NPN_UserAgent(NPP instance);
  545. void*      NP_LOADDS    NPN_MemAlloc(uint32 size);
  546. void       NP_LOADDS    NPN_MemFree(void* ptr);
  547. uint32     NP_LOADDS    NPN_MemFlush(uint32 size);
  548. void       NP_LOADDS    NPN_ReloadPlugins(NPBool reloadPages);
  549. JRIEnv*       NP_LOADDS    NPN_GetJavaEnv(void);
  550. jref       NP_LOADDS    NPN_GetJavaPeer(NPP instance);
  551. NPError       NP_LOADDS    NPN_GetValue(NPP instance, NPNVariable variable,
  552.                              void *value);
  553. NPError       NP_LOADDS    NPN_SetValue(NPP instance, NPPVariable variable,
  554.                              void *value);
  555. void        NP_LOADDS    NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
  556. void        NP_LOADDS    NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
  557. void       NP_LOADDS    NPN_ForceRedraw(NPP instance);
  558.  
  559. #ifdef __cplusplus
  560. }  /* end extern "C" */
  561. #endif
  562.  
  563. #endif                  /* RC_INVOKED */
  564. #ifdef __OS2__
  565. #pragma pack()
  566. #endif
  567.  
  568. #endif /* _NPAPI_H_ */
  569.