home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / plugins / ImAlive / npapi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  11.0 KB  |  410 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.  *  npapi.h $Revision: 3.1 $
  21.  *  Netscape client plug-in API spec
  22.  */
  23.  
  24. #ifndef _NPAPI_H_
  25. #define _NPAPI_H_
  26.  
  27. #include "jri.h"        /* Java Runtime Interface */
  28.  
  29.  
  30. /* XXX this needs to get out of here */
  31. #if defined(__MWERKS__)
  32. #ifndef XP_MAC
  33. #define XP_MAC
  34. #endif
  35. #endif
  36.  
  37.  
  38.  
  39. /*----------------------------------------------------------------------*/
  40. /*                   Plugin Version Constants                           */
  41. /*----------------------------------------------------------------------*/
  42.  
  43. #define NP_VERSION_MAJOR 0
  44. #define NP_VERSION_MINOR 9
  45.  
  46.  
  47.  
  48. /*----------------------------------------------------------------------*/
  49. /*                   Definition of Basic Types                          */
  50. /*----------------------------------------------------------------------*/
  51.  
  52. #ifndef _UINT16
  53. typedef unsigned short uint16;
  54. #endif
  55. #ifndef _UINT32
  56. #if defined(__alpha)
  57. typedef unsigned int uint32;
  58. #else /* __alpha */
  59. typedef unsigned long uint32;
  60. #endif /* __alpha */
  61. #endif
  62. #ifndef _INT16
  63. typedef short int16;
  64. #endif
  65. #ifndef _INT32
  66. #if defined(__alpha)
  67. typedef int int32;
  68. #else /* __alpha */
  69. typedef long int32;
  70. #endif /* __alpha */
  71. #endif
  72.  
  73. #ifndef FALSE
  74. #define FALSE (0)
  75. #endif
  76. #ifndef TRUE
  77. #define TRUE (1)
  78. #endif
  79. #ifndef NULL
  80. #define NULL (0L)
  81. #endif
  82.  
  83. typedef unsigned char    NPBool;
  84. typedef void*            NPEvent;
  85. typedef int16            NPError;
  86. typedef int16            NPReason;
  87. typedef char*            NPMIMEType;
  88.  
  89.  
  90.  
  91. /*----------------------------------------------------------------------*/
  92. /*                   Structures and definitions                         */
  93. /*----------------------------------------------------------------------*/
  94.  
  95. /*
  96.  *  NPP is a plug-in's opaque instance handle
  97.  */
  98. typedef struct _NPP
  99. {
  100.     void*    pdata;            /* plug-in private data */
  101.     void*    ndata;            /* netscape private data */
  102. } NPP_t;
  103.  
  104. typedef NPP_t*  NPP;
  105.  
  106.  
  107. typedef struct _NPStream
  108. {
  109.     void*        pdata;        /* plug-in private data */
  110.     void*        ndata;        /* netscape private data */
  111.     const char*        url;
  112.     uint32        end;
  113.     uint32        lastmodified;
  114.     void*        notifyData;
  115. } NPStream;
  116.  
  117.  
  118. typedef struct _NPByteRange
  119. {
  120.     int32    offset;            /* negative offset means from the end */
  121.     uint32    length;
  122.     struct _NPByteRange* next;
  123. } NPByteRange;
  124.  
  125.  
  126. typedef struct _NPSavedData
  127. {
  128.     int32    len;
  129.     void*    buf;
  130. } NPSavedData;
  131.  
  132.  
  133. typedef struct _NPRect
  134. {
  135.     uint16    top;
  136.     uint16    left;
  137.     uint16    bottom;
  138.     uint16    right;
  139. } NPRect;
  140.  
  141.  
  142. #ifdef XP_UNIX
  143. /*
  144.  * Unix specific structures and definitions
  145.  */
  146. #include <X11/Xlib.h>
  147.  
  148. /*
  149.  * Callback Structures.
  150.  *
  151.  * These are used to pass additional platform specific information.
  152.  */
  153. enum {
  154.     NP_SETWINDOW = 1
  155. };
  156.  
  157. typedef struct
  158. {
  159.     int32        type;
  160. } NPAnyCallbackStruct;
  161.  
  162. typedef struct
  163. {
  164.     int32            type;
  165.     Display*        display;
  166.     Visual*            visual;
  167.     Colormap        colormap;
  168.     unsigned int    depth;
  169. } NPSetWindowCallbackStruct;
  170.  
  171. /*
  172.  * List of variable names for which NPP_GetValue shall be implemented
  173.  */
  174. typedef enum {
  175.     NPPVpluginNameString = 1,
  176.     NPPVpluginDescriptionString
  177. } NPPVariable;
  178.  
  179. /*
  180.  * List of variable names for which NPN_GetValue is implemented by Mozilla
  181.  */
  182. typedef enum {
  183.     NPNVxDisplay = 1,
  184.     NPNVxtAppContext
  185. } NPNVariable;
  186.  
  187. #endif /* XP_UNIX */
  188.  
  189.  
  190. typedef struct _NPWindow 
  191. {
  192.     void*    window;        /* Platform specific window handle */
  193.     uint32    x;            /* Position of top left corner relative */
  194.     uint32    y;             /*    to a netscape page.                    */
  195.     uint32    width;        /* Maximum window size */
  196.     uint32    height;
  197.     NPRect    clipRect;    /* Clipping rectangle in port coordinates */
  198.                         /* Used by MAC only.                      */
  199. #ifdef XP_UNIX
  200.     void *    ws_info;    /* Platform-dependent additonal data */
  201. #endif /* XP_UNIX */
  202. } NPWindow;
  203.  
  204.  
  205. typedef struct _NPFullPrint
  206. {
  207.     NPBool    pluginPrinted;    /* Set TRUE if plugin handled fullscreen */
  208.                             /*    printing                             */
  209.     NPBool    printOne;        /* TRUE if plugin should print one copy  */
  210.                             /*    to default printer                     */
  211.     void*    platformPrint;    /* Platform-specific printing info */
  212. } NPFullPrint;
  213.  
  214. typedef struct _NPEmbedPrint
  215. {
  216.     NPWindow    window;
  217.     void*    platformPrint;    /* Platform-specific printing info */
  218. } NPEmbedPrint;
  219.  
  220. typedef struct _NPPrint
  221. {
  222.     uint16    mode;                        /* NP_FULL or NP_EMBED */
  223.     union
  224.     {
  225.         NPFullPrint        fullPrint;        /* if mode is NP_FULL */
  226.         NPEmbedPrint    embedPrint;        /* if mode is NP_EMBED */
  227.     } print;
  228. } NPPrint;
  229.  
  230.  
  231. #ifdef XP_MAC
  232. /*
  233.  *  Mac-specific structures and definitions.
  234.  */
  235.  
  236. #include <Quickdraw.h>
  237. #include <Events.h>
  238.  
  239. typedef struct NP_Port
  240. {
  241.     CGrafPtr    port;        /* Grafport */
  242.     int32        portx;        /* position inside the topmost window */
  243.     int32        porty;
  244. } NP_Port;
  245.  
  246. /*
  247.  *  Non-standard event types that can be passed to HandleEvent
  248.  */
  249. #define getFocusEvent       (osEvt + 16)
  250. #define loseFocusEvent      (osEvt + 17)
  251. #define adjustCursorEvent   (osEvt + 18)
  252.  
  253. #endif /* XP_MAC */
  254.  
  255.  
  256. /*
  257.  * Values for mode passed to NPP_New:
  258.  */
  259. #define NP_EMBED        1
  260. #define NP_FULL            2
  261.  
  262. /*
  263.  * Values for stream type passed to NPP_NewStream:
  264.  */
  265. #define NP_NORMAL        1
  266. #define NP_SEEK            2
  267. #define NP_ASFILE        3
  268. #define NP_ASFILEONLY        4
  269.  
  270. #define NP_MAXREADY    (((unsigned)(~0)<<1)>>1)
  271.  
  272.  
  273.  
  274. /*----------------------------------------------------------------------*/
  275. /*                   Error and Reason Code definitions                  */
  276. /*----------------------------------------------------------------------*/
  277.  
  278. /*
  279.  *    Values of type NPError:
  280.  */
  281. #define NPERR_BASE                            0
  282. #define NPERR_NO_ERROR                        (NPERR_BASE + 0)
  283. #define NPERR_GENERIC_ERROR                    (NPERR_BASE + 1)
  284. #define NPERR_INVALID_INSTANCE_ERROR        (NPERR_BASE + 2)
  285. #define NPERR_INVALID_FUNCTABLE_ERROR        (NPERR_BASE + 3)
  286. #define NPERR_MODULE_LOAD_FAILED_ERROR        (NPERR_BASE + 4)
  287. #define NPERR_OUT_OF_MEMORY_ERROR            (NPERR_BASE + 5)
  288. #define NPERR_INVALID_PLUGIN_ERROR            (NPERR_BASE + 6)
  289. #define NPERR_INVALID_PLUGIN_DIR_ERROR        (NPERR_BASE + 7)
  290. #define NPERR_INCOMPATIBLE_VERSION_ERROR    (NPERR_BASE + 8)
  291. #define NPERR_INVALID_PARAM                 (NPERR_BASE + 9)
  292. #define NPERR_INVALID_URL                     (NPERR_BASE + 10)
  293. #define NPERR_FILE_NOT_FOUND                 (NPERR_BASE + 11)
  294. #define NPERR_NO_DATA                         (NPERR_BASE + 12)
  295. #define NPERR_STREAM_NOT_SEEKABLE            (NPERR_BASE + 13)
  296.  
  297. /*
  298.  *    Values of type NPReason:
  299.  */
  300. #define NPRES_BASE                          0
  301. #define NPRES_DONE                               (NPRES_BASE + 0)
  302. #define NPRES_NETWORK_ERR                   (NPRES_BASE + 1)
  303. #define NPRES_USER_BREAK                    (NPRES_BASE + 2)
  304.  
  305. /*
  306.  *    Don't use these obsolete error codes any more.
  307.  */
  308. #define NP_NOERR  NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
  309. #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
  310. #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
  311.  
  312. /*
  313.  * Version feature information
  314.  */
  315. #define NPVERS_HAS_STREAMOUTPUT        8
  316. #define NPVERS_HAS_NOTIFICATION        9
  317. #define NPVERS_HAS_LIVECONNECT        9
  318.  
  319.  
  320. /*----------------------------------------------------------------------*/
  321. /*                   Function Prototypes                                */
  322. /*----------------------------------------------------------------------*/
  323.  
  324. #if defined(_WINDOWS) && !defined(WIN32)
  325. #define NP_LOADDS  _loadds
  326. #else
  327. #define NP_LOADDS
  328. #endif
  329.  
  330. #ifdef __cplusplus
  331. extern "C" {
  332. #endif
  333.  
  334. /*
  335.  * NPP_* functions are provided by the plugin and called by the navigator.
  336.  */
  337.  
  338. #ifdef XP_UNIX
  339. char*                    NPP_GetMIMEDescription(void);
  340. NPError                    NPP_GetValue(void *instance, NPPVariable variable,
  341.                                      void *value);
  342. #endif /* XP_UNIX */
  343. NPError                   NPP_Initialize(void);
  344. void                      NPP_Shutdown(void);
  345. NPError     NP_LOADDS    NPP_New(NPMIMEType pluginType, NPP instance,
  346.                                 uint16 mode, int16 argc, char* argn[],
  347.                                 char* argv[], NPSavedData* saved);
  348. NPError     NP_LOADDS    NPP_Destroy(NPP instance, NPSavedData** save);
  349. NPError     NP_LOADDS    NPP_SetWindow(NPP instance, NPWindow* window);
  350. NPError     NP_LOADDS    NPP_NewStream(NPP instance, NPMIMEType type,
  351.                                       NPStream* stream, NPBool seekable,
  352.                                       uint16* stype);
  353. NPError     NP_LOADDS    NPP_DestroyStream(NPP instance, NPStream* stream,
  354.                                           NPReason reason);
  355. int32       NP_LOADDS    NPP_WriteReady(NPP instance, NPStream* stream);
  356. int32       NP_LOADDS    NPP_Write(NPP instance, NPStream* stream, int32 offset,
  357.                                   int32 len, void* buffer);
  358. void        NP_LOADDS    NPP_StreamAsFile(NPP instance, NPStream* stream,
  359.                                          const char* fname);
  360. void        NP_LOADDS    NPP_Print(NPP instance, NPPrint* platformPrint);
  361. int16                     NPP_HandleEvent(NPP instance, void* event);
  362. void                     NPP_URLNotify(NPP instance, const char* url,
  363.                                       NPReason reason, void* notifyData);
  364. jref                    NPP_GetJavaClass(void);
  365.  
  366.  
  367. /*
  368.  * NPN_* functions are provided by the navigator and called by the plugin.
  369.  */
  370.  
  371. #ifdef XP_UNIX
  372. NPError            NPN_GetValue(NPP instance, NPNVariable variable,
  373.                              void *value);
  374. #endif /* XP_UNIX */
  375. void            NPN_Version(int* plugin_major, int* plugin_minor,
  376.                             int* netscape_major, int* netscape_minor);
  377. NPError         NPN_GetURLNotify(NPP instance, const char* url,
  378.                                  const char* target, void* notifyData);
  379. NPError         NPN_GetURL(NPP instance, const char* url,
  380.                            const char* target);
  381. NPError         NPN_PostURLNotify(NPP instance, const char* url,
  382.                                   const char* target, uint32 len,
  383.                                   const char* buf, NPBool file,
  384.                                   void* notifyData);
  385. NPError         NPN_PostURL(NPP instance, const char* url,
  386.                             const char* target, uint32 len,
  387.                             const char* buf, NPBool file);
  388. NPError         NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
  389. NPError         NPN_NewStream(NPP instance, NPMIMEType type,
  390.                               const char* target, NPStream** stream);
  391. int32           NPN_Write(NPP instance, NPStream* stream, int32 len,
  392.                           void* buffer);
  393. NPError            NPN_DestroyStream(NPP instance, NPStream* stream,
  394.                                   NPReason reason);
  395. void            NPN_Status(NPP instance, const char* message);
  396. const char*     NPN_UserAgent(NPP instance);
  397. void*           NPN_MemAlloc(uint32 size);
  398. void            NPN_MemFree(void* ptr);
  399. uint32          NPN_MemFlush(uint32 size);
  400. void            NPN_ReloadPlugins(NPBool reloadPages);
  401. JRIEnv*            NPN_GetJavaEnv(void);
  402. jref            NPN_GetJavaPeer(NPP instance);
  403.  
  404.  
  405. #ifdef __cplusplus
  406. }  /* end extern "C" */
  407. #endif
  408.  
  409. #endif /* _NPAPI_H_ */
  410.