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
Wrap
C/C++ Source or Header
|
1985-05-15
|
12KB
|
426 lines
/*
**
** $Id: v_plugin.h,v 1.10 1999/07/18 17:57:58 owagner Exp $
**
*/
#ifndef V_PLUGIN_H
#define V_PLUGIN_H
/*
** Voyager Plugin definitions
** ==========================
**
** (C) 1997-99 Oliver Wagner <owagner@vapor.com>
** All Rights Reserved
**
** Revision 2 (12-10-97)
** ---------------------
** - extended comments a bit
**
** Revision 3 (04-07-99)
** ---------------------
** - added VPLUG_Query_APIVersion
** - added VPLUG_Query_RegisterMIMEType
** - added function table
**
** Revision 4 (09-07-99)
** ---------------------
** - added vplug_domethoda()
**
** Revision 5 (18-07-99)
** ---------------------
** - added vplug_seturl()
** - added vplug_mergeurl()
** - added VPLUG_EmbedInfo_ParentURL
** - added VPLUG_EmbedInfo_Baseref
**
*/
#ifndef _reg
#ifdef _DCC
#define _reg(x) __ ## x
#else
#define _reg(x) register __ ## x
#endif
#endif
#ifndef PLFUNC
#if defined __MAXON__ || defined __STORM__ || defined _DCC
#define PLFUNC
#else
#define PLFUNC __asm
#endif
#endif
#ifndef SAVEDS
#ifdef __MAXON__
#define SAVEDS
#endif
#if defined __STORM__ || defined __SASC
#define SAVEDS __saveds
#endif
#if defined _GCC || defined _DCC
#define SAVEDS __geta4
#endif
#endif
#include <exec/types.h>
#ifdef __STORM__
#include <exec/libraries.h>
#endif
/* ^ needed for the #pragma libbase below */
#include <exec/types.h>
#include <utility/tagitem.h>
#include <utility/hooks.h>
#define VPLUG_TAGBASE (TAG_USER+0x87112)
/*
** VPLUG_Query() is supposed to return a static TagList
** which describes the ability and requirements of
** a plugin.
**
** Upon startup, V will scan PROGDIR:Plugins/#?.VPlug,
** OpenLibrary() anything it finds and call upon VPLUG_Query()
** to get information.
**
*/
/*
** V1 = Voyager 2.95 and before
** V2 = Voyager 3.0
*/
#define VPLUG_API_VERSION 2
#define VPLUG_QUERYBASE (VPLUG_TAGBASE+100)
#define VPLUG_Query_Version (VPLUG_QUERYBASE+0) /* ULONG version */
#define VPLUG_Query_Revision (VPLUG_QUERYBASE+1) /* ULONG revision */
#define VPLUG_Query_Copyright (VPLUG_QUERYBASE+2) /* STRPTR copyright information */
#define VPLUG_Query_Infostring (VPLUG_QUERYBASE+3) /* STRPTR generic info string */
#define VPLUG_Query_APIVersion (VPLUG_QUERYBASE+6) /* ULONG which version of the
Plugin API is implemented
by the plugin. Assumed to be 1
when missing */
#define VPLUG_Query_HasPrefs (VPLUG_QUERYBASE+7) /* flag - has VPLUG_Hook_Prefs() func */
#define VPLUG_Query_PluginID (VPLUG_QUERYBASE+8) /* STRPTR - plugin ID as it appears in the navigator.plugins array */
/*
** If a Plugin wants to handle a certain
** URL method (for example, "mailto"), it
** must specify the following tag. V will
** then call upon VPLUG_ProcessURLMethod()
** for the plugin to return a data stream.
** V will call upon VPLUG_FreeURLData()
** later on to free any data allocated
** in the data stream
**
*/
#define VPLUG_Query_RegisterURLMethod (VPLUG_QUERYBASE+4) /* STRPTR register URL method */
/*
** If a Plugin wants to handle a certain
** MIME type within HTML <embed>, it can
** register a MIME type here.
** When layouting, V will call VPLUG_GetClass()
** and expects the plugin to return a pointer
** to a MUI custom class (subclassed from Area.mui).
** V will NewObject() an instance of that class and
** embed that object into the page. Then, the plugin
** can do anything what a MUI object can do --
** getting input, rendering and all.
** Together with the OM_NEW, V will pass additional
** tags to inform the object of the environment,
** source URL and other stuff. The plugin class
** can make use of this as it likes.
**
*/
#define VPLUG_Query_RegisterMIMEType (VPLUG_QUERYBASE+5) /* STRPTR mime type */
#define VPLUG_EmbedInfo_URL (VPLUG_QUERYBASE+4000)
/* STRPTR the complete URL of the <EMBED SRC> */
#define VPLUG_EmbedInfo_Container (VPLUG_QUERYBASE+4001)
/* STRPTR the complete URL of the page containing the <EMBED> */
#define VPLUG_EmbedInfo_ArgNames (VPLUG_QUERYBASE+4002)
#define VPLUG_EmbedInfo_ArgValues (VPLUG_QUERYBASE+4004)
#define VPLUG_EmbedInfo_ArgCnt (VPLUG_QUERYBASE+4005)
#define VPLUG_EmbedInfo_ParentURL (VPLUG_QUERYBASE+4006)
#define VPLUG_EmbedInfo_Baseref (VPLUG_QUERYBASE+4007)
/*
Arguments passed to <EMBED>
ArgNames is an array of STRPTR with the names,
ArgValues is an array of STRPTR with the values, or ""
ArgCnt is the number of arguments
*/
#define VPLUG_EmbedInfo_NetStream (VPLUG_QUERYBASE+4003)
/* APTR handle to network stream, already opened. Do NOT nets_close() it.
The plugin can call vplug_settofile() or vplug_settomem() to
get the file to whereever it wants the data. The network handler
then does send VPLUG_NetStream_GotData and VPLUG_NetStream_GotDone
methods to the embedded objects, informing of download progress */
#define VPLUG_NetStream_GotInfo 0x851ba045
#define VPLUG_NetStream_GotData 0x851ba046
#define VPLUG_NetStream_GotDone 0x851ba047
/****************************************************************************/
/*
** Callback table
** If a plugin implements API spec >= 2, V will call
** VPLUG_Setup() with a pointer to this
** object. The plugin can call functions in that
** table anytime.
*/
#define VPLUG_FUNCTABVERSION 5
struct vplug_functable
{
int vplug_functabversion;
APTR context; /* ***PRIVATE!!! DO NOT TOUCH!!!*** */
/* Open an URL data stream. Returns a private handle, or NULL */
APTR (PLFUNC * vplug_net_openurl)(
_reg(a0) STRPTR url,
_reg(a1) STRPTR referer,
_reg(a2) APTR informobj,
_reg(d0) int reload
);
/* returns state of a network handle. -1 = failed, 0 = in progress, 1 = done */
int (PLFUNC * vplug_net_state)(
_reg(a0) APTR nethandle
);
/* close a network handle */
void (PLFUNC * vplug_net_close)(
_reg(a0) APTR nethandle
);
/* return the mime type of the object */
STRPTR (PLFUNC * vplug_net_mimetype)(
_reg(a0) APTR nethandle
);
/* Return pointer to in-memory data buffer.
You *MUST* call vplug_net_lockdocmem()/unlockdocmem()!
*/
APTR (PLFUNC * vplug_net_getdocmem)(
_reg(a0) APTR nethandle
);
/* Size of data read so far */
int (PLFUNC * vplug_net_getdocptr)(
_reg(a0) APTR nethandle
);
/* Return advertised length of document. Will be -1
if the length is unknown (no Content-Length: given
by server, for example) */
int (PLFUNC * vplug_net_getdoclen)(
_reg(a0) APTR nethandle
);
/* Tell a netstream to load itself into memory */
void (PLFUNC * vplug_net_settomem)(
_reg(a0) APTR nethandle
);
/* Tell a netstream to save itself into a file */
void (PLFUNC * vplug_net_settofile)(
_reg(a0) APTR nethandle,
_reg(a1) STRPTR filename,
_reg(d0) int resume
);
/* Return the redirect URL (if any), and the object's URL */
STRPTR (PLFUNC * vplug_net_redirecturl)(
_reg(a0) APTR nethandle
);
STRPTR (PLFUNC * vplug_net_url)(
_reg(a0) APTR nethandle
);
/* Lock doc memory semaphore. Must be called before accessing docmem */
void (PLFUNC * vplug_net_lockdocmem)(void);
void (PLFUNC * vplug_net_unlockdocmem)(void);
/* abort loading of data */
void (PLFUNC * vplug_net_abort)(
_reg(a0) APTR nethandle
);
/* error string in case URL loading failed */
STRPTR (PLFUNC * vplug_net_errorstring)(
_reg(a0) APTR nethandle
);
/* execute a MUI method synchronously (!)
can be called from other tasks, will (ab)use
yourself->pr_MsgPort
*/
int (PLFUNC * vplug_domethoda)(
_reg(a0) APTR obj,
_reg(a1) APTR Msg
);
/*
set URL. Note that this method is asynchronous,
which means that it *WILL* return to the caller,
even if the embedded object which called it should
go away due to the URL change.
*/
void (PLFUNC * vplug_seturl)(
_reg(a0) STRPTR url,
_reg(a1) STRPTR target,
_reg(d0) int flags
);
void (PLFUNC * vplug_mergeurl)(
_reg(a0) STRPTR url,
_reg(a1) STRPTR partial,
_reg(a2) STRPTR dest
);
};
/****************************************************************************/
/*
** holds your plugin's custom preference page information
** A pointer to this structure, which is already allocated for you
** by Voyager, is passed to the VPLUG_Hook_Prefs() function.
*/
struct vplug_prefs {
char *label; /* list item label, defaults to plugin name */
struct BitMap *bitmap; /* 24x14 list icon bitmap, defaults to plugin image */
APTR colormap; /* bitmap's colormap, defaults to MWB palette (8 col.) */
APTR object; /* preferences object */
};
/*
** These are the methods you are expected to handle in _Hook_Prefs()
** whenever Voyager wants to know or do stuff with your prefs.
** The description of the method id is what Voyager expects you to
** do or what to return when it is requested.
*/
enum {
VPLUGPREFS_first = 16384,
/* Setup stuff
Do whatever setup you need to do during this method. This can be eg.
setting default prefs, filling the prefs structure with the prefs
label, bitmap and colormap, etc. This method is called only once,
directly after VPLUG_Setup() (or VPLUG_FinalSetup() if you have
one).
*/
VPLUGPREFS_Setup,
/* Cleanup stuff
This method is performed only once, just before VPLUG_Cleanup().
*/
VPLUGPREFS_Cleanup,
/* Create prefsobject.
You should create your prefs object here and put that in prefs->object.
Don't check for success, Voyager will do that for you and perform an
VPLUGPREFS_Dispose if anything went wrong. If you specify NULL as
bitmap pointer, Voyager will use the default (plugin) image and colormap
for the list entry. Note: Make sure your prefs object is sizable in all
directions or you'll annoy your user!
Note: You could also set up the label, bitmap, etc, here instead of
_Setup, as they only need to be valid between _Create and _Dispose.
*/
VPLUGPREFS_Create,
/* You should dispose of the prefsobject during this method.
You don't NEED to dispose, ie. you can let your object linger around
if you wish, but it's better to dispose it though. If you don't dispose
your stuff, then don't forget to get rid of it during the _Cleanup
method!
*/
VPLUGPREFS_Dispose,
/* Take settings from prefsobject and make those the new current
settings. This method is performed when the user wants to let his/her
changes take effect.
*/
VPLUGPREFS_Use,
/* Load preferences, and make those the new current settings.
Beware: Do NOT use the prefs object for this! Don't update or check
its status, just LOAD the prefs and let THOSE prefs take effect.
This method is (also) performed after VPLUGPREFS_Setup method!
*/
VPLUGPREFS_Load,
/* Save preferences. You should save the current settings during
this method. Again, don't use the settings in the prefs object,
just save the currently used settings.
*/
VPLUGPREFS_Save,
};
/****************************************************************************/
/*
** Plugin library calls
*/
#ifndef BUILDPLUGIN
#ifndef NO_PROTO
#pragma libcall classlib VPLUG_Query 1e 0
#pragma libcall classlib VPLUG_ProcessURLMethod 24 801
#pragma libcall classlib VPLUG_GetURLData 2a 801
#pragma libcall classlib VPLUG_GetURLMIMEType 30 801
#pragma libcall classlib VPLUG_FreeURLData 36 801
/* V2 API additions*/
#pragma libcall classlib VPLUG_GetClass 3c 801
#pragma libcall classlib VPLUG_Setup 42 801
#pragma libcall classlib VPLUG_Cleanup 48 0
#pragma libcall classlib VPLUG_FinalSetup 4e 0
#pragma libcall classlib VPLUG_Hook_Prefs 54 8002
#endif
#ifndef NO_PRAGMAS
/* Get information */
struct TagItem *VPLUG_Query( void );
/* URL processing */
APTR VPLUG_ProcessURLMethod( STRPTR url );
APTR VPLUG_GetURLData( APTR handle );
STRPTR VPLUG_GetURLMIMEType( APTR handle );
void VPLUG_FreeURLData( APTR handle );
/* Embedding objects */
APTR VPLUG_GetClass( STRPTR mimetype );
/* Called after plugin is loaded */
BOOL VPLUG_Setup( struct vplug_functable *table );
/* Called after all plugins are loaded and _Setup()ed */
void VPLUG_FinalSetup( void );
/* Called before plugin is unloaded */
void VPLUG_Cleanup( void );
/* Prefs callback hook */
void VPLUG_Hook_Prefs( ULONG methodid, struct vplug_prefs *prefs );
#endif
#endif
#endif