📄 htalert.h
字号:
/* W3C Sample Code Library libwww Library Alert Class! The Alert Class!*//*** (c) COPYRIGHT MIT 1995.** Please first read the full copyright statement in the file COPYRIGH.*//*The Alert class defines a set of methods to be used by libwww for passingprompts and message to the application. In order to maintain libwww applicationindependent and natural language independent, it does not know how to communicatewith a user. Note here that a user is a somewhat abstract notionfor something that can receive a message or prompt from libwww. Auser can for example be a person, but is may also be handledautomatically by a robot or a client receiving a response from a HTTP server.Libwww has a set of opcodes that classifies the nature of the message,for example that it is a question that must be confirmed in order to continuea request or simply a progress notification. The application can registera callback for any number of the defined opcodes - in case libwww has a messagefor an opcode that does not have a method associated, the message is ignored.You can also globally disable any message send from libwww.Note: The library core does not define any message or dialogmethods - they are all considered part of the application. However, it comeswith a default set of methods which can be initiatedusing the function HTAlertInit() in HTInitmoduleThis module is implemented by HTAlert.c, and it isa part of the W3C Sample CodeLibrary.*/#ifndef HTALERT_H#define HTALERT_H#include "HTReq.h"/*. Message Opcodes and Messages.The callback functions are defined as a generic callback where the callercan pass a set of input parameters and the callee can return a set of outptuparameters. Also note that all the *_PROG_* opcodes are a subsetof HT_A_PROGRESS. This means that you easily can register acallback for all progress reports. The callback handler for progress notifications SHOULD NOT be usedto interrupt the ongoing message as it is not guaranteed to be in a stateto do so. Instead you should use the event handlersor the timers for this.*/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_INTERRUPT = 0x40, /* Request interrupted */ HT_PROG_OTHER = 0x80, /* Other progress notes */ HT_PROG_TIMEOUT = 0x100, /* Request timed out */ HT_PROG_LOGIN = 0x200, /* Automatic login notifications */ HT_A_PROGRESS = 0xFFFF, /* Get all progress reports - no reply */ /* First word are reserved for progresss notifications */ HT_A_MESSAGE = 0x1<<16, /* Send a message - no reply */ HT_A_CONFIRM = 0x2<<16, /* Want YES or NO back */ HT_A_PROMPT = 0x4<<16, /* Want full dialog */ HT_A_SECRET = 0x8<<16, /* Secret dialog (e.g. password) */ HT_A_USER_PW = 0x10<<16 /* 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 confirmationon a prompt (Yes or No).. User Prompts and Questions.This is an enumerated list of messages that can be converted into a stringtable etc. See the HTDialog module fordefault initialization of these strings.*/typedef enum _HTAlertMsg { HT_MSG_NULL = -1, HT_MSG_UID = 0, HT_MSG_PROXY_UID, HT_MSG_FTP_UID, HT_MSG_PW, HT_MSG_FILENAME, HT_MSG_ACCOUNT, HT_MSG_METHOD, HT_MSG_MOVED, HT_MSG_RULES, HT_MSG_FILE_REPLACE, HT_MSG_RETRY_AUTHENTICATION, HT_MSG_RETRY_PROXY_AUTH, HT_MSG_REDO, HT_MSG_BIG_PUT, HT_MSG_SOURCE_MOVED, HT_MSG_DESTINATION_MOVED, HT_MSG_REDIRECTION, HT_MSG_PROXY, HT_MSG_CACHE_LOCK, HT_MSG_ACCEPT_COOKIE, HT_MSG_ELEMENTS /* This MUST be the last element */} HTAlertMsg;/*. Enable or Disable Messages.If you really don't want the library to prompt for anything at all then enablethis constant. The default value is Interactive.*/extern void HTAlert_setInteractive (BOOL interative);extern BOOL HTAlert_interactive (void);/*. Creation and Deletion Methods.Message methods are registered in lists. By default a list is not enabledbefore you assign it as being active. This allowsthe application to maintain multiple lists of message handlers which canbe swapped in and out as neeeded.( Add a Callback Function)Register a call back function that is to be called when generating messages,dialog, prompts, progress reports etc. The opcode signifies which call backfunction to call depending of the type of the message. Opcode can be anycombination of the bitflags defined by HTAlertOpcode. If youregister one callback for HT_A_PROGRESS then this will get calledon all progress notifications.*/extern BOOL HTAlertCall_add (HTList * list, HTAlertCallback * cbf, HTAlertOpcode opcode);/*( Delete a Callback function)Unregister a call back function from a list*/extern BOOL HTAlertCall_delete (HTList * list, HTAlertCallback * cbf);/*( Delete all Callbacks With this Opcode)Unregister all handlers registered for a given opcode.*/extern BOOL HTAlertCall_deleteOpcode (HTList * list, HTAlertOpcode opcode);/*( Delete a list of Callback Functions)Unregisters all call back functions*/extern BOOL HTAlertCall_deleteAll (HTList * list);/*( Find a Callback Function)Finds a callback function corresponding to the opcode. If none has beenregistered then NULL is returned.*/extern HTAlertCallback * HTAlertCall_find(HTList * list, HTAlertOpcode opcode);/*. The Reply Object.The reply object is used for communicating input from the user backto the Library. This is only required to use when for example the user isprompted for a file name etc. You can find several examples on how to usethis in the default message and dialog moduleprovided together with the Library.*/extern HTAlertPar * HTAlert_newReply (void);extern void HTAlert_deleteReply (HTAlertPar * old);/*( Handle the Reply Message)These methods provide the API for handling the reply message. There are twoways of assigning a message to the reply message - either by copying thebuffer or by reusing the same buffer. In the latter case, the caller mustmake sure not to free the reply message before it has been used.*/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);/*. Active set of Callback Functions.A list can be assigned as being active in which case it is visiblefor libwww by assigning the list as the global alert list. Libwwwdoes not know about inactive lists of alert handlers.*/extern void HTAlert_setGlobal (HTList * list);extern HTList * HTAlert_global (void);/*( Global Alert List Methods)You can assign a callback directly to the global list in which case it becomesimmediately available to libwww. In this case you do not need to worry aboutcreating the list - it will be created as well as deleted automatically. Add an Alert Handler*/extern BOOL HTAlert_add (HTAlertCallback * cbf, HTAlertOpcode opcode);/* Delete an Alert HandlerYou can either delete a handler by referring to its address or to the opcodethat it has been registered for.*/extern BOOL HTAlert_delete (HTAlertCallback * cbf);extern BOOL HTAlert_deleteOpcode (HTAlertOpcode opcode);/* Delete all Alert Handlers*/extern BOOL HTAlert_deleteAll (void);/* Find an Alert Handler*/extern HTAlertCallback * HTAlert_find (HTAlertOpcode opcode);/**/#endif/* @(#) $Id: HTAlert.html,v 2.56 1999/06/30 20:15:03 frystyk Exp $*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -