home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / ftp.vapor.com / voyager / voyager-sdk.lzx / v_plugin.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-16  |  9.1 KB  |  368 lines

  1. /*
  2. **
  3. ** $Id: v_plugin.h,v 1.24 2000/04/13 22:30:10 zapek 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-2000 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. ** Revision 6 (23-01-00)
  39. ** ---------------------
  40. ** - added VPLUG_Query_RegisterMIMEExtension
  41. ** - added VPLUG_GetInfo()
  42. ** - fixed for newer GCC and vbcc (Emmanuel Lesueur)
  43. **
  44. ** Revision 7 (04-03-00)
  45. ** ---------------------
  46. ** - added VPLUG_Query_HasURLMethodGetSize
  47. **   and the related plugin entry point
  48. */
  49.  
  50. #ifndef __reg
  51. #ifdef _DCC
  52. #define __reg(x,y) __ ## x y
  53. #elif defined __GNUC__
  54. #define __reg(x,y) y __asm__(#x)
  55. #else
  56. #define __reg(x,y) register __ ## x y
  57. #endif
  58. #endif
  59.  
  60. #ifndef PLFUNC
  61. #if defined __MAXON__ || defined __STORM__ || defined _DCC || defined __GNUC__
  62. #define PLFUNC
  63. #else
  64. #define PLFUNC __asm
  65. #endif
  66. #endif
  67.  
  68. #ifndef SAVEDS
  69. #if defined __MAXON__ || defined __GNUC__
  70. #define SAVEDS
  71. #endif
  72. #if defined __STORM__ || defined __SASC
  73. #define SAVEDS __saveds
  74. #endif
  75. #ifdef _DCC
  76. #define SAVEDS __geta4
  77. #endif
  78. #endif
  79.  
  80. #include <exec/types.h>
  81. #ifdef __STORM__
  82. #include <exec/libraries.h>
  83. #endif
  84. /* ^ needed for the #pragma libbase below  */
  85.  
  86. #include <exec/types.h>
  87. #include <utility/tagitem.h>
  88. #include <utility/hooks.h>
  89.  
  90. #define VPLUG_TAGBASE (TAG_USER+0x87112)
  91.  
  92. /*
  93. ** VPLUG_Query() is supposed to return a static TagList
  94. ** which describes the ability and requirements of
  95. ** a plugin.
  96. **
  97. ** Everything is described in the autodocs
  98. ** 
  99. */
  100.  
  101. /*
  102. ** V1 = Voyager 2.95 and before
  103. ** V2 = Voyager 3.0
  104. ** V3 = Voyager 3.1
  105. */
  106. #define VPLUG_API_VERSION 3
  107.  
  108. #define VPLUG_QUERYBASE (VPLUG_TAGBASE+100)
  109.  
  110. #define VPLUG_Query_Version (VPLUG_QUERYBASE+0)                  /* ULONG */
  111. #define VPLUG_Query_Revision (VPLUG_QUERYBASE+1)                  /* ULONG  */
  112. #define VPLUG_Query_Copyright (VPLUG_QUERYBASE+2)                 /* STRPTR */
  113. #define VPLUG_Query_Infostring (VPLUG_QUERYBASE+3)                /* STRPTR */
  114. #define VPLUG_Query_APIVersion (VPLUG_QUERYBASE+6)                  /* ULONG */
  115. #define VPLUG_Query_HasPrefs (VPLUG_QUERYBASE+7)                 /* LONG */
  116. #define VPLUG_Query_PluginID (VPLUG_QUERYBASE+8)                  /* STRPTR */
  117. #define VPLUG_Query_RegisterURLMethod (VPLUG_QUERYBASE+4)       /* STRPTR */
  118. #define VPLUG_Query_HasURLMethodGetSize (VPLUG_QUERYBASE+10)    /* BOOL */
  119. #define VPLUG_Query_RegisterMIMEType (VPLUG_QUERYBASE+5)           /* STRPTR */
  120. #define VPLUG_Query_RegisterMIMEExtension (VPLUG_QUERYBASE+9)    /* STRPTR */
  121.  
  122. /*
  123. ** Arguments passed to <EMBED>
  124. ** ArgNames is an array of STRPTR with the names,
  125. ** ArgValues is an array of STRPTR with the values, or ""
  126. ** ArgCnt is the number of arguments
  127. */
  128. #define VPLUG_EmbedInfo_ArgNames (VPLUG_QUERYBASE+4002)
  129. #define VPLUG_EmbedInfo_ArgValues (VPLUG_QUERYBASE+4004)
  130. #define VPLUG_EmbedInfo_ArgCnt (VPLUG_QUERYBASE+4005)
  131. #define VPLUG_EmbedInfo_ParentURL (VPLUG_QUERYBASE+4006)
  132. #define VPLUG_EmbedInfo_Baseref (VPLUG_QUERYBASE+4007)
  133.  
  134. /*
  135. ** The complete URL of the SRC (<EMBED SRC="...">)
  136. */
  137. #define VPLUG_EmbedInfo_URL (VPLUG_QUERYBASE+4000)                /* STRPTR */
  138.  
  139. /*
  140. ** The complete URL of the page containing the <EMBED>
  141. */
  142. #define VPLUG_EmbedInfo_Container (VPLUG_QUERYBASE+4001)        /* STRPTR */
  143.  
  144.  
  145. /* APTR handle to network stream, already opened. Do NOT vplug_nets_close()
  146. ** it! The plugin can call vplug_settofile() or vplug_settomem() to
  147. ** get the file to whereever it wants the data. The network handler
  148. ** then does send VPLUG_NetStream_GotData and VPLUG_NetStream_GotDone
  149. ** methods to the embedded objects, informing of download progress.
  150. */
  151. #define VPLUG_EmbedInfo_NetStream (VPLUG_QUERYBASE+4003)
  152.  
  153. /*
  154. ** Those are methods sent to the plugin.
  155. ** GotInfo is sent when V got all the header of the stream,
  156. ** GotData is sent everytime V gets one chunk of data and
  157. ** GotDone is sent when V is done with the loading of the
  158. ** stream
  159. */
  160. #define VPLUG_NetStream_GotInfo 0x851ba045
  161. #define VPLUG_NetStream_GotData 0x851ba046
  162. #define VPLUG_NetStream_GotDone 0x851ba047
  163.  
  164.  
  165. /****************************************************************************/
  166.  
  167. /*
  168. ** Callback table
  169. ** If a plugin implements API spec >= 2, V will call
  170. ** VPLUG_Setup() with a pointer to this
  171. ** object. The plugin can call functions in that
  172. ** table anytime.
  173. */
  174. #define VPLUG_FUNCTABVERSION 6
  175.  
  176. struct vplug_functable 
  177. {
  178.     int vplug_functabversion;
  179.  
  180.     APTR context; /* ***PRIVATE!!! DO NOT TOUCH!!!*** */
  181.  
  182.     APTR (PLFUNC * vplug_net_openurl)(
  183.             __reg(a0, STRPTR url),
  184.             __reg(a1, STRPTR referer),
  185.             __reg(a2, APTR informobj),
  186.             __reg(d0, int reload)
  187.     );
  188.  
  189.     int (PLFUNC * vplug_net_state)(
  190.             __reg(a0, APTR nethandle)
  191.     );
  192.  
  193.     void (PLFUNC * vplug_net_close)(
  194.             __reg(a0, APTR nethandle)
  195.     );
  196.  
  197.     STRPTR (PLFUNC * vplug_net_mimetype)(
  198.             __reg(a0, APTR nethandle)
  199.     );
  200.  
  201.     APTR (PLFUNC * vplug_net_getdocmem)(
  202.             __reg(a0, APTR nethandle)
  203.     );
  204.  
  205.     int (PLFUNC * vplug_net_getdocptr)(
  206.             __reg(a0, APTR nethandle)
  207.     );
  208.     
  209.     int (PLFUNC * vplug_net_getdoclen)(
  210.             __reg(a0, APTR nethandle)
  211.     );
  212.  
  213.     void (PLFUNC * vplug_net_settomem)(
  214.             __reg(a0, APTR nethandle)
  215.     );
  216.  
  217.     void (PLFUNC * vplug_net_settofile)(
  218.             __reg(a0, APTR nethandle),
  219.             __reg(a1, STRPTR filename),
  220.             __reg(d0, int resume)
  221.     );
  222.  
  223.     STRPTR (PLFUNC * vplug_net_redirecturl)(
  224.             __reg(a0, APTR nethandle)
  225.     );
  226.     
  227.     STRPTR (PLFUNC * vplug_net_url)(
  228.             __reg(a0, APTR nethandle)
  229.     );
  230.  
  231.     void (PLFUNC * vplug_net_lockdocmem)(void);
  232.     
  233.     void (PLFUNC * vplug_net_unlockdocmem)(void);
  234.  
  235.     void (PLFUNC * vplug_net_abort)(
  236.             __reg(a0, APTR nethandle)
  237.     );
  238.  
  239.     STRPTR (PLFUNC * vplug_net_errorstring)(            
  240.             __reg(a0, APTR nethandle)
  241.     );
  242.  
  243.     int (PLFUNC * vplug_domethoda)(
  244.         __reg(a0, APTR obj),
  245.         __reg(a1, APTR Msg)
  246.     );
  247.  
  248.     void (PLFUNC * vplug_seturl)(
  249.         __reg(a0, STRPTR url),
  250.         __reg(a1, STRPTR target),
  251.         __reg(d0, int reload)
  252.     );
  253.  
  254.     void (PLFUNC * vplug_mergeurl)(
  255.         __reg(a0, STRPTR url),
  256.         __reg(a1, STRPTR partial),
  257.         __reg(a2, STRPTR dest)
  258.     );
  259.     
  260.     void (PLFUNC * vplug_colorspec2rgb)(
  261.         __reg(a0, STRPTR colorspec),
  262.         __reg(d0, ULONG *red),
  263.         __reg(d1, ULONG *green),
  264.         __reg(d2, ULONG *blue)
  265.     );
  266. };
  267.  
  268. /*
  269.  * Network handle states
  270.  */
  271.     /* states */
  272. #define    VNS_FAILED       -1
  273. #define VNS_INPROGRESS 0
  274. #define VNS_DONE       1
  275.  
  276.  
  277. /****************************************************************************/
  278.  
  279. /*
  280. ** holds your plugin's custom preference page information
  281. ** A pointer to this structure, which is already allocated for you 
  282. ** by Voyager, is passed to the VPLUG_Hook_Prefs() function.
  283. */
  284. struct vplug_prefs {
  285.     char *label;            /* list item label, defaults to plugin name */
  286.     struct BitMap *bitmap;    /* 24x14 list icon bitmap, defaults to plugin image */
  287.     APTR colormap;            /* bitmap's colormap, defaults to MWB palette (8 col.) */
  288.     APTR object;            /* preferences object */
  289. };
  290.  
  291. /* 
  292. ** These are the methods you are expected to handle in _Hook_Prefs()
  293. ** whenever Voyager wants to know or do stuff with your prefs.
  294. ** The description of the method id is what Voyager expects you to
  295. ** do or what to return when it is requested. Check the autodocs for more infos
  296. */
  297. enum {
  298.     VPLUGPREFS_first = 16384,
  299.     VPLUGPREFS_Setup,
  300.     VPLUGPREFS_Cleanup,
  301.     VPLUGPREFS_Create,
  302.     VPLUGPREFS_Dispose,
  303.     VPLUGPREFS_Use,
  304.     VPLUGPREFS_Load,
  305.     VPLUGPREFS_Save,
  306. };
  307.  
  308. /* where to store the settings */
  309. #define VPLUGPREFSPATH "PROGDIR:Plugins/Data"
  310.  
  311.  
  312. /****************************************************************************/
  313.  
  314. /*
  315. ** Plugin library calls
  316. */
  317.  
  318. #ifndef BUILDPLUGIN
  319.  
  320. #ifndef NO_PRAGMAS
  321. #pragma libcall classlib VPLUG_Query 1e 0
  322. #pragma libcall classlib VPLUG_ProcessURLMethod 24 801
  323. #pragma libcall classlib VPLUG_GetURLData 2a 801
  324. #pragma libcall classlib VPLUG_GetURLMIMEType 30 801
  325. #pragma libcall classlib VPLUG_FreeURLData 36 801
  326. /* V2 API additions */
  327. #pragma libcall classlib VPLUG_GetClass 3c 801
  328. #pragma libcall classlib VPLUG_Setup 42 801
  329. #pragma libcall classlib VPLUG_Cleanup 48 0
  330. #pragma libcall classlib VPLUG_FinalSetup 4e 0
  331. #pragma libcall classlib VPLUG_Hook_Prefs 54 8002
  332. /* V3 API additions */
  333. #pragma libcall classlib VPLUG_GetInfo 5a 9802
  334. #pragma libcall classlib VPLUG_GetURLDataSize 60 801
  335. #endif
  336.  
  337. #ifndef NO_PROTO
  338.  
  339. struct TagItem *VPLUG_Query( void );
  340. APTR VPLUG_ProcessURLMethod( STRPTR url );
  341. APTR VPLUG_GetURLData( APTR handle );
  342. STRPTR VPLUG_GetURLMIMEType( APTR handle ); 
  343. void VPLUG_FreeURLData( APTR handle );
  344. APTR VPLUG_GetClass( STRPTR mimetype );
  345.  
  346. /*
  347.  * Embedding objects, asking for size. This structure might extend in the future.
  348.  * Just modify the fields of VPlugInfo if you need to.
  349.  */
  350. struct VPlugInfo {
  351.     ULONG x;            /* horizontal size */
  352.     ULONG y;               /* vertical size */
  353.     STRPTR wintitle;    /* title of the window */
  354. };
  355.  
  356. BOOL VPLUG_GetInfo( struct VPlugInfo *, APTR nethandle );
  357. BOOL VPLUG_Setup( struct vplug_functable *table );
  358. void VPLUG_FinalSetup( void );
  359. void VPLUG_Cleanup( void );
  360. void VPLUG_Hook_Prefs( ULONG methodid, struct vplug_prefs *prefs );
  361. int VPLUG_GetURLDataSize( APTR handle );
  362.  
  363. #endif /* NO_PROTO */
  364.  
  365. #endif /* BUILDPLUGIN */
  366.  
  367. #endif /* V_PLUGIN_H */
  368.