/* ** (c) COPYRIGHT MIT 1995. ** Please first read the full copyright statement in the file COPYRIGH. */This module is a platform independent and language independent interface to User messages and prompting. The Library does not provide any messages on its own as they must be language independent. These can be provided by the application in a language that suits the user. The module is a registration of call back functions to the application.
This module is implemented by HTAlert.c, and it is a part of the W3C Reference Library.
#ifndef HTALERT_H #define HTALERT_H #include "HTReq.h"
*_PROG_*
opcodes are a subset of HT_A_PROGRESS
. This means that
you easily can register a callback for all progress reports.
typedef enum _HTAlertOpcode { HT_PROG_DNS = 0x1, /* Doing DNS resolution */ HT_PROG_CONNECT = 0x2, /* Connecting Active */ HT_PROG_ACCEPT = 0x4, /* Connecting Passive */ HT_PROG_READ = 0x8, /* Read data */ HT_PROG_WRITE = 0x10, /* Write data */ HT_PROG_DONE = 0x20, /* Request finished */ HT_PROG_WAIT = 0x40, /* Wait for socket */ HT_A_PROGRESS = 0xFF, /* Send a progress report - no reply */ /* First word are reserved for progresss notifications */ HT_A_MESSAGE = 0x1<<8, /* Send a message - no reply */ HT_A_CONFIRM = 0x2<<8, /* Want YES or NO back */ HT_A_PROMPT = 0x4<<8, /* Want full dialog */ HT_A_SECRET = 0x8<<8, /* Secret dialog (e.g. password) */ HT_A_USER_PW = 0x10<<8 /* Atomic userid and password */ } HTAlertOpcode; typedef struct _HTAlertPar HTAlertPar; typedef BOOL HTAlertCallback (HTRequest * request, HTAlertOpcode op, int msgnum, CONST char * dfault, void * input, HTAlertPar * reply);If you don't expect any return values then
reply
can be
NULL. The return value of the callback function can be used to
indicate confirmation on a prompt (Yes or No).
typedef enum _HTAlertMsg { HT_MSG_NULL = -1, HT_MSG_UID = 0, HT_MSG_PW, HT_MSG_FILENAME, HT_MSG_ACCOUNT, HT_MSG_METHOD, HT_MSG_MOVED, HT_MSG_RULES, HT_MSG_ELEMENTS /* This MUST be the last element */ } HTAlertMsg;
extern void HTAlert_setInteractive (BOOL interative); extern BOOL HTAlert_interactive (void);
HTAlertOpcode
. If you register one callback
for HT_A_PROGRESS
then this will get called on all
progress notifications.
extern BOOL HTAlertCall_add (HTList * list, HTAlertCallback * cbf, HTAlertOpcode opcode);
extern BOOL HTAlertCall_delete (HTList * list, HTAlertCallback * cbf);
extern BOOL HTAlertCall_deleteAll (HTList * list);
extern HTAlertCallback * HTAlertCall_find(HTList * list, HTAlertOpcode opcode);
extern HTAlertPar * HTAlert_newReply (void); extern void HTAlert_deleteReply (HTAlertPar * old);
extern BOOL HTAlert_setReplyMessage (HTAlertPar * me, CONST char *message); extern BOOL HTAlert_assignReplyMessage (HTAlertPar * me, char * message);You can get the data back again by using this method:
extern char * HTAlert_replyMessage (HTAlertPar * me);
extern char * HTAlert_replySecret (HTAlertPar * me); extern BOOL HTAlert_setReplySecret (HTAlertPar * me, CONST char * secret); extern void * HTAlert_replyOutput (HTAlertPar * me); extern BOOL HTAlert_setReplyOutput (HTAlertPar * me, void * output);
extern void HTAlert_setGlobal (HTList * list); extern HTList * HTAlert_global (void);You can also assign a callback directly to the global list. In this case you do not need to worry about creating the list - it will be created automatically.
extern BOOL HTAlert_add (HTAlertCallback * cbf, HTAlertOpcode opcode); extern BOOL HTAlert_delete (HTAlertCallback * cbf); extern HTAlertCallback * HTAlert_find (HTAlertOpcode opcode);
#endifEnd of declaration