home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / plugin / nsplugin.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  31.1 KB  |  935 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. // INTERFACE TO NETSCAPE COMMUNICATOR PLUGINS (NEW C++ API).
  21. //
  22. // This superscedes the old plugin API (npapi.h, npupp.h), and 
  23. // eliminates the need for glue files: npunix.c, npwin.cpp and npmac.cpp. 
  24. // Correspondences to the old API are shown throughout the file.
  25. ////////////////////////////////////////////////////////////////////////////////
  26.  
  27. // XXX THIS HEADER IS A BETA VERSION OF THE NEW PLUGIN INTERFACE.
  28. // USE ONLY FOR EXPERIMENTAL PURPOSES!
  29.  
  30. #ifndef nsplugin_h___
  31. #define nsplugin_h___
  32.  
  33. #ifdef __OS2__
  34. #pragma pack(1)
  35. #endif
  36.  
  37. // XXX Move this XP_ defining stuff to xpcom or nspr... 
  38.  
  39. #if defined (__OS2__ ) || defined (OS2)
  40. #    ifndef XP_OS2
  41. #        define XP_OS2 1
  42. #    endif /* XP_OS2 */
  43. #endif /* __OS2__ */
  44.  
  45. #ifdef _WINDOWS
  46. #    ifndef XP_WIN
  47. #        define XP_WIN 1
  48. #    endif /* XP_WIN */
  49. #endif /* _WINDOWS */
  50.  
  51. #ifdef __MWERKS__
  52. #    define _declspec __declspec
  53. #    ifdef macintosh
  54. #        ifndef XP_MAC
  55. #            define XP_MAC 1
  56. #        endif /* XP_MAC */
  57. #    endif /* macintosh */
  58. #    ifdef __INTEL__
  59. #        undef NULL
  60. #        ifndef XP_WIN
  61. #            define XP_WIN 1
  62. #        endif /* __INTEL__ */
  63. #    endif /* XP_PC */
  64. #endif /* __MWERKS__ */
  65.  
  66. #ifdef XP_MAC
  67.     #include <Quickdraw.h>
  68.     #include <Events.h>
  69. #endif
  70.  
  71. #ifdef XP_UNIX
  72.     #include <X11/Xlib.h>
  73.     #include <X11/Xutil.h>
  74. #endif
  75.  
  76. #include "jri.h"                // XXX change to jni.h
  77. #include "nsISupports.h"
  78.  
  79. ////////////////////////////////////////////////////////////////////////////////
  80.  
  81. /* The OS/2 version of Netscape uses RC_DATA to define the
  82.    mime types, file extentions, etc that are required.
  83.    Use a vertical bar to seperate types, end types with \0.
  84.    FileVersion and ProductVersion are 32bit ints, all other
  85.    entries are strings the MUST be terminated wwith a \0.
  86.  
  87. AN EXAMPLE:
  88.  
  89. RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
  90.  
  91. RCDATA NP_INFO_MIMEType    { "video/x-video|",
  92.                              "video/x-flick\0" }
  93. RCDATA NP_INFO_FileExtents { "avi|",
  94.                              "flc\0" }
  95. RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
  96.                              "MMOS2 Flc/Fli player(*.flc)\0" }
  97.  
  98. RCDATA NP_INFO_FileVersion       { 1,0,0,1 }
  99. RCDATA NP_INFO_CompanyName       { "Netscape Communications\0" }
  100. RCDATA NP_INFO_FileDescription   { "NPAVI32 Extension DLL\0"
  101. RCDATA NP_INFO_InternalName      { "NPAVI32\0" )
  102. RCDATA NP_INFO_LegalCopyright    { "Copyright Netscape Communications \251 1996\0"
  103. RCDATA NP_INFO_OriginalFilename  { "NVAPI32.DLL" }
  104. RCDATA NP_INFO_ProductName       { "NPAVI32 Dynamic Link Library\0" }
  105.  
  106. */
  107.  
  108.  
  109. /* RC_DATA types for version info - required */
  110. #define NP_INFO_ProductVersion      1
  111. #define NP_INFO_MIMEType            2
  112. #define NP_INFO_FileOpenName        3
  113. #define NP_INFO_FileExtents         4
  114.  
  115. /* RC_DATA types for version info - used if found */
  116. #define NP_INFO_FileDescription     5
  117. #define NP_INFO_ProductName         6
  118.  
  119. /* RC_DATA types for version info - optional */
  120. #define NP_INFO_CompanyName         7
  121. #define NP_INFO_FileVersion         8
  122. #define NP_INFO_InternalName        9
  123. #define NP_INFO_LegalCopyright      10
  124. #define NP_INFO_OriginalFilename    11
  125.  
  126. #ifndef RC_INVOKED
  127.  
  128. ////////////////////////////////////////////////////////////////////////////////
  129. // Structures and definitions
  130.  
  131. #ifdef XP_MAC
  132. #pragma options align=mac68k
  133. #endif
  134.  
  135. typedef const char*     nsMIMEType;
  136.  
  137. struct nsByteRange {
  138.     PRInt32             offset;     /* negative offset means from the end */
  139.     PRUint32            length;
  140.     struct nsByteRange* next;
  141. };
  142.  
  143. struct nsRect {
  144.     PRUint16            top;
  145.     PRUint16            left;
  146.     PRUint16            bottom;
  147.     PRUint16            right;
  148. };
  149.  
  150. ////////////////////////////////////////////////////////////////////////////////
  151. // Unix specific structures and definitions
  152.  
  153. #ifdef XP_UNIX
  154.  
  155. /*
  156.  * Callback Structures.
  157.  *
  158.  * These are used to pass additional platform specific information.
  159.  */
  160. enum NPPluginCallbackType {
  161.     NPPluginCallbackType_SetWindow = 1,
  162.     NPPluginCallbackType_Print
  163. };
  164.  
  165. struct NPPluginAnyCallbackStruct {
  166.     PRInt32     type;
  167. };
  168.  
  169. struct NPPluginSetWindowCallbackStruct {
  170.     PRInt32     type;
  171.     Display*    display;
  172.     Visual*     visual;
  173.     Colormap    colormap;
  174.     PRUint32    depth;
  175. };
  176.  
  177. struct NPPluginPrintCallbackStruct {
  178.     PRInt32     type;
  179.     FILE*       fp;
  180. };
  181.  
  182. #endif /* XP_UNIX */
  183.  
  184. ////////////////////////////////////////////////////////////////////////////////
  185.  
  186. // List of variable names for which NPP_GetValue shall be implemented
  187. enum NPPluginVariable {
  188.     NPPluginVariable_NameString = 1,
  189.     NPPluginVariable_DescriptionString,
  190.     NPPluginVariable_WindowBool,        // XXX go away
  191.     NPPluginVariable_TransparentBool,   // XXX go away?
  192.     NPPluginVariable_JavaClass,         // XXX go away
  193.     NPPluginVariable_WindowSize
  194.     // XXX add MIMEDescription (for unix) (but GetValue is on the instance, not the class)
  195. };
  196.  
  197. // List of variable names for which NPN_GetValue is implemented by Mozilla
  198. enum NPPluginManagerVariable {
  199.     NPPluginManagerVariable_XDisplay = 1,
  200.     NPPluginManagerVariable_XtAppContext,
  201.     NPPluginManagerVariable_NetscapeWindow,
  202.     NPPluginManagerVariable_JavascriptEnabledBool,      // XXX prefs accessor api
  203.     NPPluginManagerVariable_ASDEnabledBool,             // XXX prefs accessor api
  204.     NPPluginManagerVariable_IsOfflineBool               // XXX prefs accessor api
  205. };
  206.  
  207. ////////////////////////////////////////////////////////////////////////////////
  208.  
  209. enum NPPluginType {
  210.     NPPluginType_Embedded = 1,
  211.     NPPluginType_Full
  212. };
  213.  
  214. // XXX this can go away now
  215. enum NPStreamType {
  216.     NPStreamType_Normal = 1,
  217.     NPStreamType_Seek,
  218.     NPStreamType_AsFile,
  219.     NPStreamType_AsFileOnly
  220. };
  221.  
  222. #define NP_STREAM_MAXREADY    (((unsigned)(~0)<<1)>>1)
  223.  
  224. /*
  225.  * The type of a NPWindow - it specifies the type of the data structure
  226.  * returned in the window field.
  227.  */
  228. enum NPPluginWindowType {
  229.     NPPluginWindowType_Window = 1,
  230.     NPPluginWindowType_Drawable
  231. };
  232.  
  233. struct NPPluginWindow {
  234.     void*       window;         /* Platform specific window handle */
  235.                                 /* OS/2: x - Position of bottom left corner  */
  236.                                 /* OS/2: y - relative to visible netscape window */
  237.     PRUint32    x;              /* Position of top left corner relative */
  238.     PRUint32    y;              /*    to a netscape page.                    */
  239.     PRUint32    width;          /* Maximum window size */
  240.     PRUint32    height;
  241.     nsRect      clipRect;       /* Clipping rectangle in port coordinates */
  242.                                 /* Used by MAC only.              */
  243. #ifdef XP_UNIX
  244.     void*       ws_info;        /* Platform-dependent additonal data */
  245. #endif /* XP_UNIX */
  246.     NPPluginWindowType type;    /* Is this a window or a drawable? */
  247. };
  248.  
  249. struct NPPluginFullPrint {
  250.     PRBool      pluginPrinted;    /* Set TRUE if plugin handled fullscreen */
  251.                                 /*    printing                             */
  252.     PRBool      printOne;       /* TRUE if plugin should print one copy  */
  253.                                 /*    to default printer                     */
  254.     void*       platformPrint;  /* Platform-specific printing info */
  255. };
  256.  
  257. struct NPPluginEmbedPrint {
  258.     NPPluginWindow    window;
  259.     void*       platformPrint;    /* Platform-specific printing info */
  260. };
  261.  
  262. struct NPPluginPrint {
  263.     NPPluginType      mode;     /* NP_FULL or NPPluginType_Embedded */
  264.     union
  265.     {
  266.         NPPluginFullPrint     fullPrint;    /* if mode is NP_FULL */
  267.         NPPluginEmbedPrint    embedPrint;    /* if mode is NPPluginType_Embedded */
  268.     } print;
  269. };
  270.  
  271. struct NPPluginEvent {
  272.  
  273. #if defined(XP_MAC)
  274.     EventRecord* event;
  275.     void*       window;
  276.  
  277. #elif defined(XP_WIN)
  278.     uint16      event;
  279.     uint32      wParam;
  280.     uint32      lParam;
  281.  
  282. #elif defined(XP_OS2)
  283.     uint32      event;
  284.     uint32      wParam;
  285.     uint32      lParam;
  286.  
  287. #elif defined(XP_UNIX)
  288.     XEvent      event;
  289.  
  290. #endif
  291. };
  292.  
  293. #ifdef XP_MAC
  294. typedef RgnHandle nsRegion;
  295. #elif defined(XP_WIN)
  296. typedef HRGN nsRegion;
  297. #elif defined(XP_UNIX)
  298. typedef Region nsRegion;
  299. #else
  300. typedef void *nsRegion;
  301. #endif /* XP_MAC */
  302.  
  303. ////////////////////////////////////////////////////////////////////////////////
  304. // Mac-specific structures and definitions.
  305.  
  306. #ifdef XP_MAC
  307.  
  308. struct NPPort {
  309.     CGrafPtr    port;   /* Grafport */
  310.     PRInt32     portx;  /* position inside the topmost window */
  311.     PRInt32     porty;
  312. };
  313.  
  314. /*
  315.  *  Non-standard event types that can be passed to HandleEvent
  316.  */
  317. #define getFocusEvent           (osEvt + 16)
  318. #define loseFocusEvent          (osEvt + 17)
  319. #define adjustCursorEvent       (osEvt + 18)
  320.  
  321. #endif /* XP_MAC */
  322.  
  323. ////////////////////////////////////////////////////////////////////////////////
  324. // Error and Reason Code definitions
  325.  
  326. enum NPPluginError {
  327.     NPPluginError_Base = 0,
  328.     NPPluginError_NoError = 0,
  329.     NPPluginError_GenericError,
  330.     NPPluginError_InvalidInstanceError,
  331.     NPPluginError_InvalidFunctableError,
  332.     NPPluginError_ModuleLoadFailedError,
  333.     NPPluginError_OutOfMemoryError,
  334.     NPPluginError_InvalidPluginError,
  335.     NPPluginError_InvalidPluginDirError,
  336.     NPPluginError_IncompatibleVersionError,
  337.     NPPluginError_InvalidParam,
  338.     NPPluginError_InvalidUrl,
  339.     NPPluginError_FileNotFound,
  340.     NPPluginError_NoData,
  341.     NPPluginError_StreamNotSeekable
  342. };
  343.  
  344. enum NPPluginReason {
  345.     NPPluginReason_Base = 0,
  346.     NPPluginReason_Done = 0,
  347.     NPPluginReason_NetworkErr,
  348.     NPPluginReason_UserBreak,
  349.     NPPluginReason_NoReason
  350. };
  351.  
  352. ////////////////////////////////////////////////////////////////////////////////
  353. // Classes
  354. ////////////////////////////////////////////////////////////////////////////////
  355.  
  356. class NPIStream;                        // base class for all streams
  357.  
  358. // Classes that must be implemented by the plugin DLL:
  359. class NPIPlugin;                        // plugin class (MIME-type handler)
  360. class NPILiveConnectPlugin;             // subclass of NPIPlugin
  361. class NPIPluginInstance;                // plugin instance
  362. class NPIPluginStream;                  // stream to receive data from the browser
  363.  
  364. // Classes that are implemented by the browser:
  365. class NPIPluginManager;                 // minimum browser requirements
  366. class NPIPluginManagerStream;           // stream to send data to the browser
  367. class NPIPluginInstancePeer;            // parts of NPIPluginInstance implemented by the browser
  368. class NPILiveConnectPluginInstancePeer; // subclass of NPIPluginInstancePeer
  369. class NPIPluginStreamPeer;              // parts of NPIPluginStream implemented by the browser
  370. class NPISeekablePluginStreamPeer;      // seekable subclass of NPIPluginStreamPeer
  371.  
  372. //       Plugin DLL Side                Browser Side
  373. //
  374. //         
  375. //       +-----------+                 +-----------------------+
  376. //       | Plugin /  |                 | Plugin Manager        |
  377. //       | LC Plugin |                 |                       |
  378. //       +-----------+                 +-----------------------+
  379. //            ^                               ^
  380. //            |                               |
  381. //            |                        +-----------------------+
  382. //            |                        | Plugin Manager Stream |
  383. //            |                        +-----------------------+
  384. //            |
  385. //            |
  386. //       +-----------------+   peer    +-----------------------+
  387. //       | Plugin Instance |---------->| Plugin Instance Peer  |
  388. //       |                 |           | / LC Plugin Inst Peer |
  389. //       +-----------------+           +-----------------------+
  390. //
  391. //       +-----------------+   peer    +-----------------------+
  392. //       | Plugin Stream   |---------->| Plugin Stream Peer /  |
  393. //       |                 |           | Seekable P Stream Peer|
  394. //       +-----------------+           +-----------------------+
  395.  
  396. ////////////////////////////////////////////////////////////////////////////////
  397. // This is the main entry point to the plugin's DLL. The plugin manager finds
  398. // this symbol and calls it to create the plugin class. Once the plugin object
  399. // is returned to the plugin manager, instances on the page are created by 
  400. // calling NPIPlugin::NewInstance.
  401.  
  402. // (Corresponds to NPP_Initialize.)
  403. extern "C" NS_EXPORT NPPluginError
  404. NP_CreatePlugin(NPIPluginManager* mgr, NPIPlugin* *result);
  405.  
  406. ////////////////////////////////////////////////////////////////////////////////
  407. // Plugin Stream Interface
  408. // This base class is shared by both the plugin and the plugin manager.
  409.  
  410. class NPIStream : public nsISupports {
  411. public:
  412.  
  413.     // The Release method on NPIPlugin corresponds to NPP_DestroyStream.
  414.     
  415.     // (Corresponds to NPP_WriteReady.)
  416.     NS_IMETHOD_(PRInt32)
  417.     WriteReady(void) = 0;
  418.  
  419.     // (Corresponds to NPP_Write and NPN_Write.)
  420.     NS_IMETHOD_(PRInt32)
  421.     Write(PRInt32 len, void* buffer) = 0;
  422.  
  423. };
  424.  
  425. #define NP_ISTREAM_IID                               \
  426. { /* 5d852ef0-a1bc-11d1-85b1-00805f0e4dfe */         \
  427.     0x5d852ef0,                                      \
  428.     0xa1bc,                                          \
  429.     0x11d1,                                          \
  430.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  431. }
  432.  
  433. ////////////////////////////////////////////////////////////////////////////////
  434. // THINGS THAT MUST BE IMPLEMENTED BY THE PLUGIN...
  435. ////////////////////////////////////////////////////////////////////////////////
  436.  
  437. ////////////////////////////////////////////////////////////////////////////////
  438. // Plugin Interface
  439. // This is the minimum interface plugin developers need to support in order to
  440. // implement a plugin. The plugin manager may QueryInterface for more specific 
  441. // plugin types, e.g. NPILiveConnectPlugin.
  442.  
  443. class NPIPlugin : public nsISupports {
  444. public:
  445.  
  446.     // The Release method on NPIPlugin corresponds to NPP_Shutdown.
  447.  
  448.     // The old NPP_New call has been factored into two plugin instance methods:
  449.     //
  450.     // NewInstance -- called once, after the plugin instance is created. This 
  451.     // method is used to initialize the new plugin instance (although the actual
  452.     // plugin instance object will be created by the plugin manager).
  453.     //
  454.     // NPIPluginInstance::Start -- called when the plugin instance is to be
  455.     // started. This happens in two circumstances: (1) after the plugin instance
  456.     // is first initialized, and (2) after a plugin instance is returned to
  457.     // (e.g. by going back in the window history) after previously being stopped
  458.     // by the Stop method. 
  459.  
  460.     NS_IMETHOD_(NPPluginError)
  461.     NewInstance(NPIPluginInstancePeer* peer, NPIPluginInstance* *result) = 0;
  462.  
  463. #ifdef XP_UNIX  // XXX why can't this be XP?
  464.  
  465.     // (Corresponds to NPP_GetMIMEDescription.)
  466.     NS_IMETHOD_(const char*)
  467.     GetMIMEDescription(void) = 0;
  468.  
  469. #endif /* XP_UNIX */
  470.  
  471. };
  472.  
  473. #define NP_IPLUGIN_IID                               \
  474. { /* 8a623430-a1bc-11d1-85b1-00805f0e4dfe */         \
  475.     0x8a623430,                                      \
  476.     0xa1bc,                                          \
  477.     0x11d1,                                          \
  478.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  479. }
  480.  
  481. ////////////////////////////////////////////////////////////////////////////////
  482. // LiveConnect Plugin Interface
  483. // This interface defines additional entry points that a plugin developer needs
  484. // to implement in order for the plugin to support LiveConnect, i.e. be 
  485. // scriptable by Java or JavaScript.
  486.  
  487. class NPILiveConnectPlugin : public NPIPlugin {
  488. public:
  489.  
  490.     // (Corresponds to NPP_GetJavaClass.)
  491.     NS_IMETHOD_(jclass)
  492.     GetJavaClass(void) = 0;
  493.  
  494. };
  495.  
  496. #define NP_ILIVECONNECTPLUGIN_IID                    \
  497. { /* cf134df0-a1bc-11d1-85b1-00805f0e4dfe */         \
  498.     0xcf134df0,                                      \
  499.     0xa1bc,                                          \
  500.     0x11d1,                                          \
  501.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  502. }
  503.  
  504. ////////////////////////////////////////////////////////////////////////////////
  505. // Plugin Instance Interface
  506.  
  507. // (Corresponds to NPP object.)
  508. class NPIPluginInstance : public nsISupports {
  509. public:
  510.  
  511.     // The Release method on NPIPluginInstance corresponds to NPP_Destroy.
  512.  
  513.     // See comment for NPIPlugin::NewInstance, above.
  514.     NS_IMETHOD_(NPPluginError)
  515.     Start(void) = 0;
  516.  
  517.     // The old NPP_Destroy call has been factored into two plugin instance 
  518.     // methods:
  519.     //
  520.     // Stop -- called when the plugin instance is to be stopped (e.g. by 
  521.     // displaying another plugin manager window, causing the page containing 
  522.     // the plugin to become removed from the display).
  523.     //
  524.     // Release -- called once, before the plugin instance peer is to be 
  525.     // destroyed. This method is used to destroy the plugin instance.
  526.  
  527.     NS_IMETHOD_(NPPluginError)
  528.     Stop(void) = 0;
  529.  
  530.     // (Corresponds to NPP_SetWindow.)
  531.     NS_IMETHOD_(NPPluginError)
  532.     SetWindow(NPPluginWindow* window) = 0;
  533.  
  534.     // (Corresponds to NPP_NewStream.)
  535.     NS_IMETHOD_(NPPluginError)
  536.     NewStream(NPIPluginStreamPeer* peer, NPIPluginStream* *result) = 0;
  537.  
  538.     // (Corresponds to NPP_Print.)
  539.     NS_IMETHOD_(void)
  540.     Print(NPPluginPrint* platformPrint) = 0;
  541.  
  542.     // (Corresponds to NPP_HandleEvent.)
  543.     // Note that for Unix and Mac the NPPluginEvent structure is different
  544.     // from the old NPEvent structure -- it's no longer the native event
  545.     // record, but is instead a struct. This was done for future extensibility,
  546.     // and so that the Mac could receive the window argument too. For Windows
  547.     // and OS2, it's always been a struct, so there's no change for them.
  548.     NS_IMETHOD_(PRInt16)
  549.     HandleEvent(NPPluginEvent* event) = 0;
  550.  
  551.     // (Corresponds to NPP_URLNotify.)
  552.     NS_IMETHOD_(void)
  553.     URLNotify(const char* url, const char* target,
  554.               NPPluginReason reason, void* notifyData) = 0;
  555.  
  556.     // (Corresponds to NPP_GetValue.)
  557.     NS_IMETHOD_(NPPluginError)
  558.     GetValue(NPPluginVariable variable, void *value) = 0;
  559.  
  560.     // (Corresponds to NPP_SetValue.)
  561.     NS_IMETHOD_(NPPluginError)
  562.     SetValue(NPPluginManagerVariable variable, void *value) = 0;
  563.  
  564. };
  565.  
  566. #define NP_IPLUGININSTANCE_IID                       \
  567. { /* b62f3a10-a1bc-11d1-85b1-00805f0e4dfe */         \
  568.     0xb62f3a10,                                      \
  569.     0xa1bc,                                          \
  570.     0x11d1,                                          \
  571.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  572. }
  573.  
  574. ////////////////////////////////////////////////////////////////////////////////
  575. // Plugin Stream Interface
  576.  
  577. class NPIPluginStream : public NPIStream {
  578. public:
  579.  
  580.     // (Corresponds to NPP_NewStream's stype return parameter.)
  581.     NS_IMETHOD_(NPStreamType)
  582.     GetStreamType(void) = 0;
  583.  
  584.     // (Corresponds to NPP_StreamAsFile.)
  585.     NS_IMETHOD_(void)
  586.     AsFile(const char* fname) = 0;
  587.  
  588. };
  589.  
  590. #define NP_IPLUGINSTREAM_IID                         \
  591. { /* e7a97340-a1bc-11d1-85b1-00805f0e4dfe */         \
  592.     0xe7a97340,                                      \
  593.     0xa1bc,                                          \
  594.     0x11d1,                                          \
  595.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  596. }
  597.  
  598. ////////////////////////////////////////////////////////////////////////////////
  599. // THINGS IMPLEMENTED BY THE BROWSER...
  600. ////////////////////////////////////////////////////////////////////////////////
  601.  
  602. ////////////////////////////////////////////////////////////////////////////////
  603. // Plugin Manager Interface
  604. // This interface defines the minimum set of functionality that a plugin
  605. // manager will support if it implements plugins. Plugin implementations can
  606. // QueryInterface to determine if a plugin manager implements more specific 
  607. // APIs for the plugin to use.
  608.  
  609. class NPIPluginManager : public nsISupports {
  610. public:
  611.  
  612.     // QueryInterface may be used to obtain a JRIEnv or JNIEnv
  613.     // from an NPIPluginManager.
  614.     // (Corresponds to NPN_GetJavaEnv.)
  615.  
  616.     // (Corresponds to NPN_ReloadPlugins.)
  617.     NS_IMETHOD_(void)
  618.     ReloadPlugins(PRBool reloadPages) = 0;
  619.  
  620.     // (Corresponds to NPN_MemAlloc.)
  621.     NS_IMETHOD_(void*)
  622.     MemAlloc(PRUint32 size) = 0;
  623.  
  624.     // (Corresponds to NPN_MemFree.)
  625.     NS_IMETHOD_(void)
  626.     MemFree(void* ptr) = 0;
  627.  
  628.     // (Corresponds to NPN_MemFlush.)
  629.     NS_IMETHOD_(PRUint32)
  630.     MemFlush(PRUint32 size) = 0;
  631.  
  632. };
  633.  
  634. #define NP_IPLUGINMANAGER_IID                        \
  635. { /* f10b9600-a1bc-11d1-85b1-00805f0e4dfe */         \
  636.     0xf10b9600,                                      \
  637.     0xa1bc,                                          \
  638.     0x11d1,                                          \
  639.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  640. }
  641.  
  642. #define NP_IJRIENV_IID                               \
  643. { /* f9d4ea00-a1bc-11d1-85b1-00805f0e4dfe */         \
  644.     0xf9d4ea00,                                      \
  645.     0xa1bc,                                          \
  646.     0x11d1,                                          \
  647.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  648. }
  649.  
  650. #define NP_IJNIENV_IID                               \
  651. { /* 04610650-a1bd-11d1-85b1-00805f0e4dfe */         \
  652.     0x04610650,                                      \
  653.     0xa1bd,                                          \
  654.     0x11d1,                                          \
  655.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  656. }
  657.  
  658. ////////////////////////////////////////////////////////////////////////////////
  659. // Plugin Instance Peer Interface
  660.  
  661. class NPIPluginInstancePeer : public nsISupports {
  662. public:
  663.  
  664.     NS_IMETHOD_(NPIPlugin*)
  665.     GetClass(void) = 0;
  666.  
  667.     // (Corresponds to NPP_New's MIMEType argument.)
  668.     NS_IMETHOD_(nsMIMEType)
  669.     GetMIMEType(void) = 0;
  670.  
  671.     // (Corresponds to NPP_New's mode argument.)
  672.     NS_IMETHOD_(NPPluginType)
  673.     GetMode(void) = 0;
  674.  
  675.     // (Corresponds to NPP_New's argc argument.)
  676.     NS_IMETHOD_(PRUint16)
  677.     GetArgCount(void) = 0;
  678.  
  679.     // (Corresponds to NPP_New's argn argument.)
  680.     NS_IMETHOD_(const char**)
  681.     GetArgNames(void) = 0;
  682.  
  683.     // (Corresponds to NPP_New's argv argument.)
  684.     NS_IMETHOD_(const char**)
  685.     GetArgValues(void) = 0;
  686.  
  687.     NS_IMETHOD_(NPIPluginManager*)
  688.     GetPluginManager(void) = 0;
  689.  
  690.     // (Corresponds to NPN_GetURL and NPN_GetURLNotify.)
  691.     //   notifyData: When present, URLNotify is called passing the notifyData back
  692.     //          to the client. When NULL, this call behaves like NPN_GetURL.
  693.     // New arguments:
  694.     //   altHost: An IP-address string that will be used instead of the host
  695.     //          specified in the URL. This is used to prevent DNS-spoofing attacks.
  696.     //          Can be defaulted to NULL meaning use the host in the URL.
  697.     //   referrer: 
  698.     //   forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs,
  699.     //          even if the user currently has JavaScript disabled. 
  700.     NS_IMETHOD_(NPPluginError)
  701.     GetURL(const char* url, const char* target, void* notifyData = NULL,
  702.            const char* altHost = NULL, const char* referrer = NULL,
  703.            PRBool forceJSEnabled = PR_FALSE) = 0;
  704.  
  705.     // (Corresponds to NPN_PostURL and NPN_PostURLNotify.)
  706.     //   notifyData: When present, URLNotify is called passing the notifyData back
  707.     //          to the client. When NULL, this call behaves like NPN_GetURL.
  708.     // New arguments:
  709.     //   altHost: An IP-address string that will be used instead of the host
  710.     //          specified in the URL. This is used to prevent DNS-spoofing attacks.
  711.     //          Can be defaulted to NULL meaning use the host in the URL.
  712.     //   referrer: 
  713.     //   forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs,
  714.     //          even if the user currently has JavaScript disabled. 
  715.     //   postHeaders: A string containing post headers.
  716.     //   postHeadersLength: The length of the post headers string.
  717.     NS_IMETHOD_(NPPluginError)
  718.     PostURL(const char* url, const char* target, PRUint32 bufLen, 
  719.             const char* buf, PRBool file, void* notifyData = NULL,
  720.             const char* altHost = NULL, const char* referrer = NULL,
  721.             PRBool forceJSEnabled = PR_FALSE,
  722.             PRUint32 postHeadersLength = 0, const char* postHeaders = NULL) = 0;
  723.  
  724.     // (Corresponds to NPN_NewStream.)
  725.     NS_IMETHOD_(NPPluginError)
  726.     NewStream(nsMIMEType type, const char* target,
  727.               NPIPluginManagerStream* *result) = 0;
  728.  
  729.     // (Corresponds to NPN_Status.)
  730.     NS_IMETHOD_(void)
  731.     ShowStatus(const char* message) = 0;
  732.  
  733.     // (Corresponds to NPN_UserAgent.)
  734.     NS_IMETHOD_(const char*)
  735.     UserAgent(void) = 0;
  736.  
  737.     // (Corresponds to NPN_GetValue.)
  738.     NS_IMETHOD_(NPPluginError)
  739.     GetValue(NPPluginManagerVariable variable, void *value) = 0;
  740.  
  741.     // (Corresponds to NPN_SetValue.)
  742.     NS_IMETHOD_(NPPluginError)
  743.     SetValue(NPPluginVariable variable, void *value) = 0;
  744.  
  745.     ////////////////////////////////////////////////////////////////////////////
  746.     // XXX Only used by windowless plugin instances?...
  747.  
  748.     // (Corresponds to NPN_InvalidateRect.)
  749.     NS_IMETHOD_(void)
  750.     InvalidateRect(nsRect *invalidRect) = 0;
  751.  
  752.     // (Corresponds to NPN_InvalidateRegion.)
  753.     NS_IMETHOD_(void)
  754.     InvalidateRegion(nsRegion invalidRegion) = 0;
  755.  
  756.     // (Corresponds to NPN_ForceRedraw.)
  757.     NS_IMETHOD_(void)
  758.     ForceRedraw(void) = 0;
  759.     
  760.     // New top-level window handling calls for Mac:
  761.     
  762.     NS_IMETHOD_(void)
  763.     RegisterWindow(void* window) = 0;
  764.     
  765.     NS_IMETHOD_(void)
  766.     UnregisterWindow(void* window) = 0;
  767.  
  768. };
  769.  
  770. #define NP_IPLUGININSTANCEPEER_IID                   \
  771. { /* 15c75de0-a1bd-11d1-85b1-00805f0e4dfe */         \
  772.     0x15c75de0,                                      \
  773.     0xa1bd,                                          \
  774.     0x11d1,                                          \
  775.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  776. }
  777.  
  778. ////////////////////////////////////////////////////////////////////////////////
  779. // LiveConnect Plugin Instance Peer Interface
  780. // Browsers that support LiveConnect implement this subclass of plugin instance
  781. // peer. 
  782.  
  783. // XXX Should this really be a separate subclass?
  784.  
  785. class NPILiveConnectPluginInstancePeer : public NPIPluginInstancePeer {
  786. public:
  787.  
  788.     // (Corresponds to NPN_GetJavaPeer.)
  789.     NS_IMETHOD_(jobject)
  790.     GetJavaPeer(void) = 0;
  791.  
  792. };
  793.  
  794. #define NP_ILIVECONNECTPLUGININSTANCEPEER_IID        \
  795. { /* 1e3502a0-a1bd-11d1-85b1-00805f0e4dfe */         \
  796.     0x1e3502a0,                                      \
  797.     0xa1bd,                                          \
  798.     0x11d1,                                          \
  799.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  800. }
  801.  
  802. ////////////////////////////////////////////////////////////////////////////////
  803. // Plugin Manager Stream Interface
  804.  
  805. class NPIPluginManagerStream : public NPIStream {
  806. public:
  807.  
  808.     // (Corresponds to NPStream's url field.)
  809.     NS_IMETHOD_(const char*)
  810.     GetURL(void) = 0;
  811.  
  812.     // (Corresponds to NPStream's end field.)
  813.     NS_IMETHOD_(PRUint32)
  814.     GetEnd(void) = 0;
  815.  
  816.     // (Corresponds to NPStream's lastmodified field.)
  817.     NS_IMETHOD_(PRUint32)
  818.     GetLastModified(void) = 0;
  819.  
  820.     // (Corresponds to NPStream's notifyData field.)
  821.     NS_IMETHOD_(void*)
  822.     GetNotifyData(void) = 0;
  823.  
  824. };
  825.  
  826. #define NP_IPLUGINMANAGERSTREAM_IID                  \
  827. { /* 30c24560-a1bd-11d1-85b1-00805f0e4dfe */         \
  828.     0x30c24560,                                      \
  829.     0xa1bd,                                          \
  830.     0x11d1,                                          \
  831.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  832. }
  833.  
  834. ////////////////////////////////////////////////////////////////////////////////
  835. // Plugin Stream Peer Interface
  836. // A plugin stream peer is passed to a plugin instance's NewStream call in 
  837. // order to indicate that a new stream is to be created and be read by the
  838. // plugin instance.
  839.  
  840. class NPIPluginStreamPeer : public nsISupports {
  841. public:
  842.  
  843.     // (Corresponds to NPP_DestroyStream's reason argument.)
  844.     NS_IMETHOD_(NPPluginReason)
  845.     GetReason(void) = 0;
  846.  
  847.     // (Corresponds to NPP_NewStream's MIMEType argument.)
  848.     NS_IMETHOD_(nsMIMEType)
  849.     GetMIMEType(void) = 0;
  850.  
  851.     NS_IMETHOD_(PRUint32)
  852.     GetContentLength(void) = 0;
  853. #if 0
  854.     NS_IMETHOD_(const char*)
  855.     GetContentEncoding(void) = 0;
  856.  
  857.     NS_IMETHOD_(const char*)
  858.     GetCharSet(void) = 0;
  859.  
  860.     NS_IMETHOD_(const char*)
  861.     GetBoundary(void) = 0;
  862.  
  863.     NS_IMETHOD_(const char*)
  864.     GetContentName(void) = 0;
  865.  
  866.     NS_IMETHOD_(time_t)
  867.     GetExpires(void) = 0;
  868.  
  869.     NS_IMETHOD_(time_t)
  870.     GetLastModified(void) = 0;
  871.  
  872.     NS_IMETHOD_(time_t)
  873.     GetServerDate(void) = 0;
  874.  
  875.     NS_IMETHOD_(NPServerStatus)
  876.     GetServerStatus(void) = 0;
  877. #endif
  878.     NS_IMETHOD_(PRUint32)
  879.     GetHeaderFieldCount(void) = 0;
  880.  
  881.     NS_IMETHOD_(const char*)
  882.     GetHeaderFieldKey(PRUint32 index) = 0;
  883.  
  884.     NS_IMETHOD_(const char*)
  885.     GetHeaderField(PRUint32 index) = 0;
  886.  
  887. };
  888.  
  889. #define NP_IPLUGINSTREAMPEER_IID                     \
  890. { /* 38278eb0-a1bd-11d1-85b1-00805f0e4dfe */         \
  891.     0x38278eb0,                                      \
  892.     0xa1bd,                                          \
  893.     0x11d1,                                          \
  894.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  895. }
  896.  
  897. ////////////////////////////////////////////////////////////////////////////////
  898. // Seekable Plugin Stream Peer Interface
  899. // The browser implements this subclass of plugin stream peer if a stream
  900. // is seekable. Plugins can query interface for this type, and call the 
  901. // RequestRead method to seek to a particular position in the stream.
  902.  
  903. class NPISeekablePluginStreamPeer : public NPIPluginStreamPeer {
  904. public:
  905.  
  906.     // QueryInterface for this class corresponds to NPP_NewStream's 
  907.     // seekable argument.
  908.  
  909.     // (Corresponds to NPN_RequestRead.)
  910.     NS_IMETHOD_(NPPluginError)
  911.     RequestRead(nsByteRange* rangeList) = 0;
  912.  
  913. };
  914.  
  915. #define NP_ISEEKABLEPLUGINSTREAMPEER_IID             \
  916. { /* f55c8250-a73e-11d1-85b1-00805f0e4dfe */         \
  917.     0xf55c8250,                                      \
  918.     0xa73e,                                          \
  919.     0x11d1,                                          \
  920.     {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
  921. }                                                    \
  922.  
  923. ////////////////////////////////////////////////////////////////////////////////
  924.  
  925. #ifdef XP_MAC
  926. #pragma options align=reset
  927. #endif
  928.  
  929. #endif /* RC_INVOKED */
  930. #ifdef __OS2__
  931. #pragma pack()
  932. #endif
  933.  
  934. #endif /* nsplugin_h___ */
  935.