/*
 * ArcWeb
 *
 * Copyright (C) Stewart Brodie, 1994, 1995, 1996, 1997
 *
 * This product is supplied under the terms laid down in the `Terms' file.
 *
 * This file may be distributed freely with any ArcWeb related software,
 * provided it meets with the definition of 'free' in the 'Terms' file.
 *
 * This file: requester.h
 *
 *   A WIMP-library-independent interface definition.  All structures are
 *   defined in terms of basic types.
 *
 * Last changes: for ArcWeb 1.77 - new flags.
 *
 */
#ifndef _requester_h_included
#define _requester_h_included
#ifdef __cplusplus
extern "C" {
#endif

#define arcweb_MAXURL           (200)


#define msg_Arcweb__base        (0x4A240)
#define msg_Arcweb__last	(msg_Arcweb__base + 0x3f)
#define swi_Arcweb__base        (msg_Arcweb__base)
#define err_Arcweb__base        (0x80D200)

typedef enum {

        Message_ArcwebFetchRequest    = (msg_Arcweb__base +  0),
        Message_ArcwebFetchDone       = (msg_Arcweb__base +  1),
        Message_ArcwebRenderRequest   = (msg_Arcweb__base +  2),
        Message_ArcwebRenderDone      = (msg_Arcweb__base +  3),
        Message_ArcwebPostRequest     = (msg_Arcweb__base +  4),
        Message_ArcwebPostDone        = (msg_Arcweb__base +  5),
        Message_ArcwebEMailRequest    = (msg_Arcweb__base +  6),
        Message_ArcwebEMailDone       = (msg_Arcweb__base +  7),

        Message_ArcwebImageSize       = (msg_Arcweb__base + 16),
        Message_ArcwebImageComplete   = (msg_Arcweb__base + 17),
        Message_ArcwebXferControl     = (msg_Arcweb__base + 18),
        Message_ArcwebXferControlAck  = (msg_Arcweb__base + 19),

        Message_ArcwebQuit            = (msg_Arcweb__base + 32),
        Message_ArcwebExpire          = (msg_Arcweb__base + 33),
        Message_ArcwebAbortRequest    = (msg_Arcweb__base + 34),
        Message_ArcwebTransferStatus  = (msg_Arcweb__base + 35),
        Message_ArcwebConfigure       = (msg_Arcweb__base + 36),
        Message_ArcwebExternalLaunch  = (msg_Arcweb__base + 37),
        Message_ArcwebLaunchDone      = (msg_Arcweb__base + 38),
        Message_ArcwebWebBrowser      = (msg_Arcweb__base + 39),
        Message_ArcwebColourSelected  = (msg_Arcweb__base + 40),
        Message_ArcwebPermanentMove   = (msg_Arcweb__base + 41),

        Message_IntertalkRequest      = (0x4AF80)

} arcweb_msgid;


/* Use these constants in the flag words in the messages below */

#define arcweb_FLAGS_error              0x80000000
#define arcweb_FLAGS_typeknown          0x40000000
#define arcweb_FLAGS_inhibit_render     0x20000000
#define arcweb_FLAGS_want_symlink       0x10000000
#define arcweb_FLAGS_url_changed        0x08000000
#define arcweb_FLAGS_close_previous     0x04000000
#define arcweb_FLAGS_image_fetch        0x02000000
#define arcweb_FLAGS_error_handled      0x01000000
#define arcweb_FLAGS_inhibit_display    0x00800000
#define arcweb_FLAGS_extended_url       0x00400000
#define arcweb_FLAGS_email_complete     0x00200000
#define arcweb_FLAGS_reload		0x00100000
#define arcweb_FLAGS_load_to_disc	0x00080000
#define arcweb_FLAGS_forcing_reload	0x00040000
#define arcweb_FLAGS_reserved_mask      0x00020000
#define arcweb_FLAGS_extended_type      0x00010000
#define arcweb_FLAGS_typemask           0x0001ffff
#define arcweb_FLAGS_stream		0x00004000
#define arcweb_FLAGS_rnfr		0x00002000
#define arcweb_FLAGS_dele		0x00001000
#define arcweb_FLAGS_rmdir		0x00000800
#define arcweb_FLAGS_mkdir		0x00000400
#define arcweb_FLAGS_put		0x00000200
#define arcweb_FLAGS_forcing_images	0x00000100
#define arcweb_FLAGS_referer_available	0x00000080
#define arcweb_FLAGS_xfer_control       0x00000020
#define arcweb_FLAGS_images_disabled    0x00000010
#define arcweb_FLAGS_post_was_put       0x00000008
#define arcweb_FLAGS_fast_images	0x00000004
#define arcweb_FLAGS_local_launch	0x00000002
#define arcweb_FLAGS_document_fetch	0x00000000


#define arcweb_XFER_xmit_running        0x00000001
#define arcweb_XFER_recv_running        0x00000002
#define arcweb_XFER_xmit_complete       0x00000004
#define arcweb_XFER_recv_complete       0x00000008
#define arcweb_XFER_misc_running        0x00000010
#define arcweb_XFER_reserved            0xffffffe0


/* Flag bit meanings:
 *
 *  Responses only:
 *      bits 0 to 15    : RISC OS/ArcWeb filetype indicator
 *      bit 16          : if set, type is arcweb_TYPES_*, else RISC OS type
 *
 *  Requests only:
 *      bit  1          : the previous page was a local: URL
 *      bit  2          : if set, 'fast images' are being used - not implemented yet
 *      bit  3          : if set, the POST request should be sent as a PUT instead
 *      bit  4          : if set, user has disabled image fetching
 *      bit  5          : if set, control transfer protocol is available
 *	bit  6		Reserved - must be zero
 *	bit  7		Internal use only - must be zero for non-ArcWeb tasks
 *	bit  8		If set, user has forced image fetching for this fetch
 *	bit  9		If set, user requested a PUT operation
 *	bit  10		If set, user requested the URI be created as a directory
 *	bit  11		If set, user requested the directory URI be deleted
 *	bit  12		If set, user requested deletion of URI
 *	bit  13		If set, user requested rename of URI
 *      bit  14		Reserved - must be zero (or you'll be sorry)
 *
 *  Both:
 *
 *      bits 17 and 18  : reserved (must be preserved in replies)
 *      bit 19          : if set, user has requested a 'load to disc'
 *      bit 20          : if set, this is a reload, so flush any cache
 *      bit 21          : if set, the e-mail message is complete
 *      bit 22          : if set, this is an extended URL
 *      bit 23          : if set, ArcWeb will not display the results of the render
 *      bit 24          : if set, ArcWeb wont raise any error to user
 *      bit 25          : if set, this is an inline image fetch, not a page fetch
 *      bit 26          : if set, the previous ArcWeb window should be closed
 *      bit 27          : if set, URL has been changed (+ is in URL file)
 *      bit 28          : if set, request use of symbolic link in host filesystem
 *      bit 29          : if set, (in FetchDone), ArcWeb will not render it
 *      bit 30          : if set, bits 0-16 are valid, else they are invalid
 *      bit 31          : if set, the buffer contains an error message
 *
 */

typedef struct {
        struct arcweb_msghdr {    /* message block header. */
          int size;               /* 20<=size<=256, multiple of 4 */
          int task;               /* task handle of sender (filled in by wimp) */
          int my_ref;             /* unique ref number (filled in by wimp) */
          int your_ref;           /* (0==>none) if non-zero, acknowledge */
          arcweb_msgid action;    /* message action code */
        } hdr;
        void           *handle;         /* MUST be preserved */
        int             flags;          /* See above */
        union {
                int  _arcweb_words[57]; /* Ensure the right size */
                char _arcweb_data[228]; /* a char version        */

                struct {
                        int     localfile;  /* *RISC OS* file handle */
                        union {
                                int     url_file;            /* if bit 22 set */
                                char    URL[arcweb_MAXURL];  /* if bit 22 clr */
                        } url;
                } fetch_request;

                union {
                        struct {
                                int     use_given_expiry;
                                int     use_default_expiry;
                                char    date[8]; /* to stop Cv5 warnings */
                                int	response_code;
                                char	mime_type[208]; /* MUST start "MIME:" */
                        } expiry;
                        char    error[228];
                } fetch_done;

               struct {
                        int     localfile;
                        int     formfile;
                        union {
                                int     url_file;            /* if bit 22 set */
                                char    URL[arcweb_MAXURL];  /* if bit 22 clr */
                        } url;
                } post_request;

                struct {
                        int     localsrc;
                        int     localtmp;
                        int     localdiag;
                        int     locallink;
                        int     size_in_msg;
                        char    fileheader[228-5*sizeof(int)];
                } render_request;

                union {
                        struct {
                                int x_pix;
                                int y_pix;
                        } size;
                        char    error[228];
                } render_done;

                struct {
                        int     formfile;
                } email_request;

                struct {
                        char    error[228]; /* Do I want this? */
                } email_done;

                struct {
                        union {
                                int  url_file;           /* if bit 22 set   */
                                char URL[arcweb_MAXURL]; /* if bit 22 clear */
                        } url;
                } expire;

                 union {
                        struct {
                                int     use_given_expiry;
                                int     use_default_expiry;
                                char    date[8]; /* to stop Cv5 warnings */
                                int	response_code;
                                char	mime_type[208]; /* MUST start "MIME:" */
                        } expiry;
                        char    error[228];
                } post_done;

                struct {
                        int     flags;
                        int     transmit_total;
                        int     transmit_sofar;
                        int     receive_total;
                        int     receive_sofar;
                        char    message[208];
                } status_report;

                struct {
                        char    reason[228];
                } abort_request;

                struct {
                        int     renderer_handle;
                        int     x_os_units;
                        int     y_os_units;
                } image_size;

                struct {
                        int     renderer_handle;
                } image_complete;

                struct {
                	char	application[228];
                } configure;

                struct {
                        union {
                                int  url_file;           /* if bit 22 set   */
                                char URL[arcweb_MAXURL]; /* if bit 22 clear */
                        } url;
                } launch_request;

                struct {
                        char    error[228];
                } launch_done;

                struct {
                        int     localfile;  /* *RISC OS* file handle */
                        union {
                                int     url_file;            /* if bit 22 set */
                                char    URL[arcweb_MAXURL];  /* if bit 22 clr */
                        } url;
                } xfer_request;

                struct {
                        char    error[228];
                } xfer_request_ack;
                
                struct {
                        char 	browser[228];
                } web_browser;

		struct {
		        int	background;
		        int	normal;
		        int	link;
		        int	vlink;
		        int	alink;
		        int	no_images;
		} colour_selection;
		
		struct {
		        /* NOTE: These pointers are possibly in app w/s */
		        /* Must use Wimp_TransferBlock to get them */
		        const char 	*from;
		        int		fromsize;
		        const char	*to;
		        int		tosize;
		} permanent_move;

        } data;
} arcweb_msg; /* use as a wimp_msgstr */

#ifdef __cplusplus
}
#endif
#endif
