home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 1 / CD_Magazyn_EXEC_nr_1.iso / eXec / Voyager3 / Programy / v3_plugin_def.lzx / v_plugin.h < prev   
C/C++ Source or Header  |  1985-05-15  |  12KB  |  426 lines

  1. /*
  2. **
  3. ** $Id: v_plugin.h,v 1.10 1999/07/18 17:57:58 owagner Exp $
  4. **
  5. */
  6.  
  7. #ifndef V_PLUGIN_H
  8. #define V_PLUGIN_H
  9.  
  10. /*
  11. ** Voyager Plugin definitions
  12. ** ==========================
  13. **
  14. ** (C) 1997-99 Oliver Wagner <owagner@vapor.com>
  15. ** All Rights Reserved
  16. **
  17. ** Revision 2 (12-10-97)
  18. ** ---------------------
  19. ** - extended comments a bit
  20. **
  21. ** Revision 3 (04-07-99)
  22. ** ---------------------
  23. ** - added VPLUG_Query_APIVersion
  24. ** - added VPLUG_Query_RegisterMIMEType
  25. ** - added function table
  26. **
  27. ** Revision 4 (09-07-99)
  28. ** ---------------------
  29. ** - added vplug_domethoda()
  30. **
  31. ** Revision 5 (18-07-99)
  32. ** ---------------------
  33. ** - added vplug_seturl()
  34. ** - added vplug_mergeurl()
  35. ** - added VPLUG_EmbedInfo_ParentURL
  36. ** - added VPLUG_EmbedInfo_Baseref
  37. **
  38. */
  39.  
  40. #ifndef _reg
  41. #ifdef _DCC
  42. #define _reg(x) __ ## x
  43. #else
  44. #define _reg(x) register __ ## x
  45. #endif
  46. #endif
  47.  
  48. #ifndef PLFUNC
  49. #if defined __MAXON__ || defined __STORM__ || defined _DCC
  50. #define PLFUNC
  51. #else
  52. #define PLFUNC __asm
  53. #endif
  54. #endif
  55.  
  56. #ifndef SAVEDS
  57. #ifdef __MAXON__
  58. #define SAVEDS
  59. #endif
  60. #if defined __STORM__ || defined __SASC
  61. #define SAVEDS __saveds
  62. #endif
  63. #if defined _GCC || defined _DCC
  64. #define SAVEDS __geta4
  65. #endif
  66. #endif
  67.  
  68. #include <exec/types.h>
  69. #ifdef __STORM__
  70. #include <exec/libraries.h>
  71. #endif
  72. /* ^ needed for the #pragma libbase below  */
  73.  
  74. #include <exec/types.h>
  75. #include <utility/tagitem.h>
  76. #include <utility/hooks.h>
  77.  
  78. #define VPLUG_TAGBASE (TAG_USER+0x87112)
  79.  
  80. /*
  81. ** VPLUG_Query() is supposed to return a static TagList
  82. ** which describes the ability and requirements of
  83. ** a plugin.
  84. **
  85. ** Upon startup, V will scan PROGDIR:Plugins/#?.VPlug,
  86. ** OpenLibrary() anything it finds and call upon VPLUG_Query()
  87. ** to get information.
  88. ** 
  89. */
  90.  
  91. /*
  92. ** V1 = Voyager 2.95 and before
  93. ** V2 = Voyager 3.0
  94. */
  95. #define VPLUG_API_VERSION 2
  96.  
  97. #define VPLUG_QUERYBASE (VPLUG_TAGBASE+100)
  98.  
  99. #define VPLUG_Query_Version (VPLUG_QUERYBASE+0)       /* ULONG version */
  100. #define VPLUG_Query_Revision (VPLUG_QUERYBASE+1)      /* ULONG revision */
  101. #define VPLUG_Query_Copyright (VPLUG_QUERYBASE+2)     /* STRPTR copyright information */
  102. #define VPLUG_Query_Infostring (VPLUG_QUERYBASE+3)    /* STRPTR generic info string */
  103.  
  104. #define VPLUG_Query_APIVersion (VPLUG_QUERYBASE+6)      /* ULONG which version of the
  105.                                                          Plugin API is implemented
  106.                                                          by the plugin. Assumed to be 1 
  107.                                                          when missing */
  108.  
  109. #define VPLUG_Query_HasPrefs (VPLUG_QUERYBASE+7)      /* flag - has VPLUG_Hook_Prefs() func */
  110.  
  111. #define VPLUG_Query_PluginID (VPLUG_QUERYBASE+8)      /* STRPTR - plugin ID as it appears in the navigator.plugins array */
  112.  
  113. /*
  114. ** If a Plugin wants to handle a certain
  115. ** URL method (for example, "mailto"), it
  116. ** must specify the following tag. V will
  117. ** then call upon VPLUG_ProcessURLMethod()
  118. ** for the plugin to return a data stream.
  119. ** V will call upon VPLUG_FreeURLData()
  120. ** later on to free any data allocated
  121. ** in the data stream
  122. **
  123. */
  124. #define VPLUG_Query_RegisterURLMethod (VPLUG_QUERYBASE+4)   /* STRPTR register URL method */
  125.  
  126. /*
  127. ** If a Plugin wants to handle a certain
  128. ** MIME type within HTML <embed>, it can
  129. ** register a MIME type here.
  130. ** When layouting, V will call VPLUG_GetClass()
  131. ** and expects the plugin to return a pointer
  132. ** to a MUI custom class (subclassed from Area.mui). 
  133. ** V will NewObject() an instance of that class and 
  134. ** embed that object into the page. Then, the plugin 
  135. ** can do anything what a MUI object can do -- 
  136. ** getting input, rendering and all.
  137. ** Together with the OM_NEW, V will pass additional
  138. ** tags to inform the object of the environment,
  139. ** source URL and other stuff. The plugin class
  140. ** can make use of this as it likes.
  141. **
  142. */
  143. #define VPLUG_Query_RegisterMIMEType (VPLUG_QUERYBASE+5)   /* STRPTR mime type */
  144.  
  145. #define VPLUG_EmbedInfo_URL (VPLUG_QUERYBASE+4000)
  146. /* STRPTR the complete URL of the <EMBED SRC> */
  147.  
  148. #define VPLUG_EmbedInfo_Container (VPLUG_QUERYBASE+4001)
  149. /* STRPTR the complete URL of the page containing the <EMBED> */
  150.  
  151. #define VPLUG_EmbedInfo_ArgNames (VPLUG_QUERYBASE+4002)
  152. #define VPLUG_EmbedInfo_ArgValues (VPLUG_QUERYBASE+4004)
  153. #define VPLUG_EmbedInfo_ArgCnt (VPLUG_QUERYBASE+4005)
  154. #define VPLUG_EmbedInfo_ParentURL (VPLUG_QUERYBASE+4006)
  155. #define VPLUG_EmbedInfo_Baseref (VPLUG_QUERYBASE+4007)
  156.  
  157. /*
  158.  Arguments passed to <EMBED>
  159.  ArgNames is an array of STRPTR with the names,
  160.  ArgValues is an array of STRPTR with the values, or ""
  161.  ArgCnt is the number of arguments
  162. */
  163.  
  164. #define VPLUG_EmbedInfo_NetStream (VPLUG_QUERYBASE+4003)
  165. /* APTR handle to network stream, already opened. Do NOT nets_close() it.
  166.    The plugin can call vplug_settofile() or vplug_settomem() to
  167.    get the file to whereever it wants the data. The network handler
  168.    then does send VPLUG_NetStream_GotData and VPLUG_NetStream_GotDone
  169.    methods to the embedded objects, informing of download progress */
  170. #define VPLUG_NetStream_GotInfo 0x851ba045
  171. #define VPLUG_NetStream_GotData 0x851ba046
  172. #define VPLUG_NetStream_GotDone 0x851ba047
  173.  
  174. /****************************************************************************/
  175.  
  176. /*
  177. ** Callback table
  178. ** If a plugin implements API spec >= 2, V will call
  179. ** VPLUG_Setup() with a pointer to this
  180. ** object. The plugin can call functions in that
  181. ** table anytime.
  182. */
  183. #define VPLUG_FUNCTABVERSION 5
  184.  
  185. struct vplug_functable 
  186. {
  187.     int vplug_functabversion;
  188.  
  189.     APTR context; /* ***PRIVATE!!! DO NOT TOUCH!!!*** */
  190.  
  191.     /* Open an URL data stream. Returns a private handle, or NULL */
  192.     APTR (PLFUNC * vplug_net_openurl)(
  193.             _reg(a0) STRPTR url,
  194.             _reg(a1) STRPTR referer,
  195.             _reg(a2) APTR informobj,
  196.             _reg(d0) int reload
  197.     );
  198.  
  199.     /* returns state of a network handle. -1 = failed, 0 = in progress, 1 = done */
  200.     int (PLFUNC * vplug_net_state)(
  201.             _reg(a0) APTR nethandle
  202.     );
  203.  
  204.     /* close a network handle */
  205.     void (PLFUNC * vplug_net_close)(
  206.             _reg(a0) APTR nethandle
  207.     );
  208.  
  209.     /* return the mime type of the object */
  210.     STRPTR (PLFUNC * vplug_net_mimetype)(
  211.             _reg(a0) APTR nethandle
  212.     );
  213.  
  214.     /* Return pointer to in-memory data buffer.
  215.        You *MUST* call vplug_net_lockdocmem()/unlockdocmem()!
  216.     */
  217.     APTR (PLFUNC * vplug_net_getdocmem)(
  218.             _reg(a0) APTR nethandle
  219.     );
  220.  
  221.     /* Size of data read so far */
  222.     int (PLFUNC * vplug_net_getdocptr)(
  223.             _reg(a0) APTR nethandle
  224.     );
  225.  
  226.     /* Return advertised length of document. Will be -1
  227.        if the length is unknown (no Content-Length: given
  228.        by server, for example) */
  229.     int (PLFUNC * vplug_net_getdoclen)(
  230.             _reg(a0) APTR nethandle
  231.     );
  232.  
  233.     /* Tell a netstream to load itself into memory */
  234.     void (PLFUNC * vplug_net_settomem)(
  235.             _reg(a0) APTR nethandle
  236.     );
  237.  
  238.     /* Tell a netstream to save itself into a file */
  239.     void (PLFUNC * vplug_net_settofile)(
  240.             _reg(a0) APTR nethandle,
  241.             _reg(a1) STRPTR filename,
  242.             _reg(d0) int resume
  243.     );
  244.  
  245.     /* Return the redirect URL (if any), and the object's URL */
  246.     STRPTR (PLFUNC * vplug_net_redirecturl)(
  247.             _reg(a0) APTR nethandle
  248.     );
  249.     STRPTR (PLFUNC * vplug_net_url)(
  250.             _reg(a0) APTR nethandle
  251.     );
  252.  
  253.     /* Lock doc memory semaphore. Must be called before accessing docmem */
  254.     void (PLFUNC * vplug_net_lockdocmem)(void);
  255.     void (PLFUNC * vplug_net_unlockdocmem)(void);
  256.  
  257.     /* abort loading of data */
  258.     void (PLFUNC * vplug_net_abort)(
  259.             _reg(a0) APTR nethandle
  260.     );
  261.  
  262.     /* error string in case URL loading failed */
  263.     STRPTR (PLFUNC * vplug_net_errorstring)(            
  264.             _reg(a0) APTR nethandle
  265.     );
  266.  
  267.     /* execute a MUI method synchronously (!) 
  268.        can be called from other tasks, will (ab)use
  269.        yourself->pr_MsgPort
  270.     */
  271.     int (PLFUNC * vplug_domethoda)(
  272.         _reg(a0) APTR obj,
  273.         _reg(a1) APTR Msg
  274.     );
  275.  
  276.     /* 
  277.        set URL. Note that this method is asynchronous,
  278.        which means that it *WILL* return to the caller,
  279.        even if the embedded object which called it should
  280.        go away due to the URL change.
  281.     */
  282.     void (PLFUNC * vplug_seturl)(
  283.         _reg(a0) STRPTR url,
  284.         _reg(a1) STRPTR target,
  285.         _reg(d0) int flags
  286.     );
  287.  
  288.     void (PLFUNC * vplug_mergeurl)(
  289.         _reg(a0) STRPTR url,
  290.         _reg(a1) STRPTR partial,
  291.         _reg(a2) STRPTR dest
  292.     );
  293. };
  294.  
  295. /****************************************************************************/
  296.  
  297. /*
  298. ** holds your plugin's custom preference page information
  299. ** A pointer to this structure, which is already allocated for you 
  300. ** by Voyager, is passed to the VPLUG_Hook_Prefs() function.
  301. */
  302. struct vplug_prefs {
  303.     char *label;            /* list item label, defaults to plugin name */
  304.     struct BitMap *bitmap;    /* 24x14 list icon bitmap, defaults to plugin image */
  305.     APTR colormap;            /* bitmap's colormap, defaults to MWB palette (8 col.) */
  306.     APTR object;            /* preferences object */
  307. };
  308.  
  309. /* 
  310. ** These are the methods you are expected to handle in _Hook_Prefs()
  311. ** whenever Voyager wants to know or do stuff with your prefs.
  312. ** The description of the method id is what Voyager expects you to
  313. ** do or what to return when it is requested.
  314. */
  315. enum {
  316.     VPLUGPREFS_first = 16384,
  317.  
  318.     /* Setup stuff
  319.        Do whatever setup you need to do during this method. This can be eg.
  320.        setting default prefs, filling the prefs structure with the prefs
  321.        label, bitmap and colormap, etc. This method is called only once,
  322.        directly after VPLUG_Setup() (or VPLUG_FinalSetup() if you have
  323.        one).
  324.     */
  325.     VPLUGPREFS_Setup,
  326.  
  327.  
  328.     /* Cleanup stuff
  329.        This method is performed only once, just before VPLUG_Cleanup().
  330.     */
  331.     VPLUGPREFS_Cleanup,
  332.  
  333.     /* Create prefsobject.
  334.        You should create your prefs object here and put that in prefs->object.
  335.        Don't check for success, Voyager will do that for you and perform an
  336.        VPLUGPREFS_Dispose if anything went wrong. If you specify NULL as
  337.        bitmap pointer, Voyager will use the default (plugin) image and colormap
  338.        for the list entry. Note: Make sure your prefs object is sizable in all
  339.        directions or you'll annoy your user!
  340.        Note: You could also set up the label, bitmap, etc, here instead of
  341.        _Setup, as they only need to be valid between _Create and _Dispose.
  342.     */
  343.     VPLUGPREFS_Create,
  344.  
  345.     /* You should dispose of the prefsobject during this method.
  346.        You don't NEED to dispose, ie. you can let your object linger around
  347.        if you wish, but it's better to dispose it though. If you don't dispose
  348.        your stuff, then don't forget to get rid of it during the _Cleanup
  349.        method!
  350.     */
  351.     VPLUGPREFS_Dispose,
  352.  
  353.     /* Take settings from prefsobject and make those the new current
  354.        settings. This method is performed when the user wants to let his/her
  355.        changes take effect.
  356.     */
  357.     VPLUGPREFS_Use,
  358.  
  359.     /* Load preferences, and make those the new current settings.
  360.        Beware: Do NOT use the prefs object for this! Don't update or check
  361.        its status, just LOAD the prefs and let THOSE prefs take effect.
  362.        This method is (also) performed after VPLUGPREFS_Setup method!
  363.     */
  364.     VPLUGPREFS_Load,
  365.  
  366.     /* Save preferences. You should save the current settings during
  367.        this method. Again, don't use the settings in the prefs object,
  368.        just save the currently used settings.
  369.     */
  370.     VPLUGPREFS_Save,
  371. };
  372.  
  373.  
  374. /****************************************************************************/
  375.  
  376. /*
  377. ** Plugin library calls
  378. */
  379.  
  380. #ifndef BUILDPLUGIN
  381.  
  382. #ifndef NO_PROTO
  383. #pragma libcall classlib VPLUG_Query 1e 0
  384. #pragma libcall classlib VPLUG_ProcessURLMethod 24 801
  385. #pragma libcall classlib VPLUG_GetURLData 2a 801
  386. #pragma libcall classlib VPLUG_GetURLMIMEType 30 801
  387. #pragma libcall classlib VPLUG_FreeURLData 36 801
  388. /* V2 API additions*/
  389. #pragma libcall classlib VPLUG_GetClass 3c 801
  390. #pragma libcall classlib VPLUG_Setup 42 801
  391. #pragma libcall classlib VPLUG_Cleanup 48 0
  392. #pragma libcall classlib VPLUG_FinalSetup 4e 0
  393. #pragma libcall classlib VPLUG_Hook_Prefs 54 8002
  394. #endif
  395.  
  396. #ifndef NO_PRAGMAS
  397.  
  398. /* Get information */
  399. struct TagItem *VPLUG_Query( void );
  400.  
  401. /* URL processing */
  402. APTR VPLUG_ProcessURLMethod( STRPTR url );
  403. APTR VPLUG_GetURLData( APTR handle );
  404. STRPTR VPLUG_GetURLMIMEType( APTR handle ); 
  405. void VPLUG_FreeURLData( APTR handle );
  406.  
  407. /* Embedding objects */
  408. APTR VPLUG_GetClass( STRPTR mimetype );
  409.  
  410. /* Called after plugin is loaded */
  411. BOOL VPLUG_Setup( struct vplug_functable *table );
  412. /* Called after all plugins are loaded and _Setup()ed */
  413. void VPLUG_FinalSetup( void );
  414. /* Called before plugin is unloaded */
  415. void VPLUG_Cleanup( void );
  416.  
  417. /* Prefs callback hook */
  418. void  VPLUG_Hook_Prefs( ULONG methodid, struct vplug_prefs *prefs );
  419.  
  420.  
  421. #endif
  422.  
  423. #endif
  424.  
  425. #endif
  426.