Annotation of libwww/Library/src/HTAlert.html, revision 2.56
2.6 timbl 1: <HTML>
2: <HEAD>
2.51 frystyk 3: <!-- Changed by: Henrik Frystyk Nielsen, 13-Jul-1996 -->
2.46 frystyk 4: <TITLE>W3C Sample Code Library libwww Library Alert Class</TITLE>
2.6 timbl 5: </HEAD>
6: <BODY>
2.38 frystyk 7: <H1>
8: The Alert Class
9: </H1>
2.12 frystyk 10: <PRE>
11: /*
2.18 frystyk 12: ** (c) COPYRIGHT MIT 1995.
2.12 frystyk 13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
2.38 frystyk 16: <P>
2.56 ! frystyk 17: The Alert class defines a set of methods to be used by libwww for passing
! 18: prompts and message to the application. In order to maintain libwww application
! 19: independent and natural language independent, it does not know how to communicate
! 20: with a <I>user</I>. Note here that a <I>user</I> is a somewhat abstract notion
! 21: for something that can receive a message or prompt from libwww. A
! 22: <EM>user</EM> can for example be a person, but is may also be handled
! 23: automatically by a robot or a client receiving a response from a HTTP server.
2.38 frystyk 24: <P>
25: Libwww has a set of <B>opcodes</B> that classifies the nature of the message,
26: for example that it is a question that must be confirmed in order to continue
27: a request or simply a progress notification. The application can register
2.56 ! frystyk 28: a callback for any number of the defined opcodes - in case libwww has a message
! 29: for an opcode that does not have a method associated, the message is ignored.
! 30: You can also globally disable any message send from libwww.
2.38 frystyk 31: <P>
32: <B>Note</B>: The library <B>core</B> does not define any message or dialog
2.56 ! frystyk 33: methods - they are all considered part of the application. However, it comes
2.38 frystyk 34: with a <A HREF="HTDialog.html">default set of methods</A> which can be initiated
35: using the function <CODE>HTAlertInit()</CODE> in <A HREF="HTInit.html">HTInit
36: module</A>
37: <P>
38: This module is implemented by <A HREF="HTAlert.c">HTAlert.c</A>, and it is
2.50 frystyk 39: a part of the <A HREF="http://www.w3.org/Library/"> W3C Sample Code
2.38 frystyk 40: Library</A>.
2.11 frystyk 41: <PRE>
2.12 frystyk 42: #ifndef HTALERT_H
43: #define HTALERT_H
2.17 frystyk 44:
2.27 frystyk 45: #include "HTReq.h"
2.11 frystyk 46: </PRE>
2.38 frystyk 47: <H2>
2.55 frystyk 48: <A NAME="Message">Message Opcodes and Messages</A>
2.38 frystyk 49: </H2>
50: <P>
51: The callback functions are defined as a generic callback where the caller
52: can pass a set of input parameters and the callee can return a set of outptu
53: parameters. Also note that all the <CODE>*_PROG_*</CODE> opcodes are a subset
54: of <CODE>HT_A_PROGRESS</CODE>. This means that you easily can register a
2.56 ! frystyk 55: callback for <EM>all</EM> progress reports.
! 56: <P>
! 57: The callback handler for progress notifications <EM>SHOULD NOT</EM> be used
! 58: to interrupt the ongoing message as it is not guaranteed to be in a state
! 59: to do so. Instead you should use the <A HREF="HTEvent.html">event handlers</A>
! 60: or the <A HREF="HTTimer.html">timers</A> for this.
2.32 frystyk 61: <PRE>
62: typedef enum _HTAlertOpcode {
63: HT_PROG_DNS = 0x1, /* Doing DNS resolution */
64: HT_PROG_CONNECT = 0x2, /* Connecting Active */
65: HT_PROG_ACCEPT = 0x4, /* Connecting Passive */
66: HT_PROG_READ = 0x8, /* Read data */
67: HT_PROG_WRITE = 0x10, /* Write data */
68: HT_PROG_DONE = 0x20, /* Request finished */
2.53 frystyk 69: HT_PROG_INTERRUPT = 0x40, /* Request interrupted */
70: HT_PROG_OTHER = 0x80, /* Other progress notes */
71: HT_PROG_TIMEOUT = 0x100, /* Request timed out */
2.54 frystyk 72: HT_PROG_LOGIN = 0x200, /* Automatic login notifications */
2.53 frystyk 73: HT_A_PROGRESS = 0xFFFF, /* Get all progress reports - no reply */
2.32 frystyk 74:
75: /* First word are reserved for progresss notifications */
76:
2.53 frystyk 77: HT_A_MESSAGE = 0x1<<16, /* Send a message - no reply */
78: HT_A_CONFIRM = 0x2<<16, /* Want YES or NO back */
79: HT_A_PROMPT = 0x4<<16, /* Want full dialog */
80: HT_A_SECRET = 0x8<<16, /* Secret dialog (e.g. password) */
81: HT_A_USER_PW = 0x10<<16 /* Atomic userid and password */
2.32 frystyk 82: } HTAlertOpcode;
2.15 frystyk 83:
2.32 frystyk 84: typedef struct _HTAlertPar HTAlertPar;
2.8 luotonen 85:
2.32 frystyk 86: typedef BOOL HTAlertCallback (HTRequest * request, HTAlertOpcode op,
2.35 frystyk 87: int msgnum, const char * dfault, void * input,
2.32 frystyk 88: HTAlertPar * reply);
2.6 timbl 89: </PRE>
2.38 frystyk 90: <P>
91: If you don't expect any return values then <CODE>reply</CODE> can be NULL.
92: The return value of the callback function can be used to indicate confirmation
93: on a prompt (Yes or No).
2.55 frystyk 94: <H2>
95: <A NAME="String">User Prompts and Questions</A>
96: </H2>
2.38 frystyk 97: <P>
98: This is an enumerated list of messages that can be converted into a string
2.55 frystyk 99: table etc. See the <A HREF="HTDialog.html#Prompt">HTDialog module</A> for
100: default initialization of these strings.
2.15 frystyk 101: <PRE>
2.32 frystyk 102: typedef enum _HTAlertMsg {
103: HT_MSG_NULL = -1,
104: HT_MSG_UID = 0,
2.43 frystyk 105: HT_MSG_PROXY_UID,
106: HT_MSG_FTP_UID,
2.32 frystyk 107: HT_MSG_PW,
108: HT_MSG_FILENAME,
109: HT_MSG_ACCOUNT,
110: HT_MSG_METHOD,
111: HT_MSG_MOVED,
112: HT_MSG_RULES,
2.39 frystyk 113: HT_MSG_FILE_REPLACE,
114: HT_MSG_RETRY_AUTHENTICATION,
2.41 frystyk 115: HT_MSG_RETRY_PROXY_AUTH,
2.40 frystyk 116: HT_MSG_REDO,
117: HT_MSG_BIG_PUT,
118: HT_MSG_SOURCE_MOVED,
119: HT_MSG_DESTINATION_MOVED,
2.41 frystyk 120: HT_MSG_REDIRECTION,
2.47 frystyk 121: HT_MSG_PROXY,
2.48 frystyk 122: HT_MSG_CACHE_LOCK,
2.55 frystyk 123: HT_MSG_ACCEPT_COOKIE,
2.32 frystyk 124: HT_MSG_ELEMENTS /* This MUST be the last element */
125: } HTAlertMsg;
2.15 frystyk 126: </PRE>
2.38 frystyk 127: <H2>
2.55 frystyk 128: <A NAME="Enable">Enable or Disable Messages</A>
2.38 frystyk 129: </H2>
130: <P>
131: If you really don't want the library to prompt for anything at all then enable
132: this constant. The default value is <EM>Interactive</EM>.
2.32 frystyk 133: <PRE>
134: extern void HTAlert_setInteractive (BOOL interative);
135: extern BOOL HTAlert_interactive (void);
2.15 frystyk 136: </PRE>
2.38 frystyk 137: <H2>
2.55 frystyk 138: <A NAME="Creation">Creation and Deletion Methods</A>
2.38 frystyk 139: </H2>
140: <P>
141: Message methods are registered in lists. By default a list is not enabled
142: before you assign it as being <I><A HREF="#active">active</A></I>. This allows
143: the application to maintain multiple lists of message handlers which can
144: be swapped in and out as neeeded.
145: <H3>
146: Add a Callback Function
147: </H3>
148: <P>
149: Register a call back function that is to be called when generating messages,
150: dialog, prompts, progress reports etc. The opcode signifies which call back
151: function to call depending of the type of the message. Opcode can be any
152: combination of the bitflags defined by <CODE>HTAlertOpcode</CODE>. If you
153: register one callback for <CODE>HT_A_PROGRESS </CODE>then this will get called
154: on all progress notifications.
2.15 frystyk 155: <PRE>
2.32 frystyk 156: extern BOOL HTAlertCall_add (HTList * list, HTAlertCallback * cbf,
157: HTAlertOpcode opcode);
2.15 frystyk 158: </PRE>
2.38 frystyk 159: <H3>
160: Delete a Callback function
161: </H3>
162: <P>
2.32 frystyk 163: Unregister a call back function from a list
2.8 luotonen 164: <PRE>
2.32 frystyk 165: extern BOOL HTAlertCall_delete (HTList * list, HTAlertCallback * cbf);
2.15 frystyk 166: </PRE>
2.38 frystyk 167: <H3>
2.51 frystyk 168: Delete all Callbacks With this Opcode
169: </H3>
170: <P>
171: Unregister all handlers registered for a given opcode.
172: <PRE>
173: extern BOOL HTAlertCall_deleteOpcode (HTList * list, HTAlertOpcode opcode);
174: </PRE>
175: <H3>
2.38 frystyk 176: Delete a list of Callback Functions
177: </H3>
178: <P>
2.32 frystyk 179: Unregisters all call back functions
180: <PRE>
181: extern BOOL HTAlertCall_deleteAll (HTList * list);
182: </PRE>
2.38 frystyk 183: <H3>
184: Find a Callback Function
185: </H3>
186: <P>
187: Finds a callback function corresponding to the opcode. If none has been
188: registered then NULL is returned.
2.6 timbl 189: <PRE>
2.32 frystyk 190: extern HTAlertCallback * HTAlertCall_find(HTList * list, HTAlertOpcode opcode);
2.6 timbl 191: </PRE>
2.38 frystyk 192: <H2>
2.56 ! frystyk 193: <A NAME="Reply">The Reply Object</A>
2.38 frystyk 194: </H2>
195: <P>
196: The reply object is used for communicating input from the <I>user</I> back
197: to the Library. This is only required to use when for example the user is
198: prompted for a file name etc. You can find several examples on how to use
199: this in the <A HREF="HTDialog.html">default message and dialog module</A>
200: provided together with the Library.
201: <PRE>extern HTAlertPar * HTAlert_newReply (void);
2.32 frystyk 202: extern void HTAlert_deleteReply (HTAlertPar * old);
203: </PRE>
2.38 frystyk 204: <H3>
205: Handle the Reply Message
206: </H3>
207: <P>
208: These methods provide the API for handling the reply message. There are two
209: ways of assigning a message to the reply message - either by copying the
210: buffer or by reusing the same buffer. In the latter case, the caller must
211: make sure <B>not</B> to free the reply message before it has been used.
2.34 frystyk 212: <PRE>
2.35 frystyk 213: extern BOOL HTAlert_setReplyMessage (HTAlertPar * me, const char *message);
2.34 frystyk 214: extern BOOL HTAlert_assignReplyMessage (HTAlertPar * me, char * message);
215: </PRE>
2.38 frystyk 216: <P>
2.34 frystyk 217: You can get the data back again by using this method:
2.32 frystyk 218: <PRE>
219: extern char * HTAlert_replyMessage (HTAlertPar * me);
2.34 frystyk 220: </PRE>
221: <PRE>
2.32 frystyk 222: extern char * HTAlert_replySecret (HTAlertPar * me);
2.35 frystyk 223: extern BOOL HTAlert_setReplySecret (HTAlertPar * me, const char * secret);
2.6 timbl 224:
2.32 frystyk 225: extern void * HTAlert_replyOutput (HTAlertPar * me);
226: extern BOOL HTAlert_setReplyOutput (HTAlertPar * me, void * output);
2.17 frystyk 227: </PRE>
2.38 frystyk 228: <H2>
229: <A NAME="active">Active set of Callback Functions</A>
230: </H2>
231: <P>
232: A list can be assigned as being active in which case it is <I>visible</I>
2.51 frystyk 233: for libwww by assigning the list as the <I>global alert list</I>. Libwww
234: does not know about inactive lists of alert handlers.
2.32 frystyk 235: <PRE>
236: extern void HTAlert_setGlobal (HTList * list);
237: extern HTList * HTAlert_global (void);
238: </PRE>
2.51 frystyk 239: <H3>
240: Global Alert List Methods
241: </H3>
2.38 frystyk 242: <P>
2.51 frystyk 243: You can assign a callback directly to the global list in which case it becomes
244: immediately available to libwww. In this case you do not need to worry about
245: creating the list - it will be created as well as deleted automatically.
246: <H4>
247: Add an Alert Handler
248: </H4>
249: <PRE>
250: extern BOOL HTAlert_add (HTAlertCallback * cbf, HTAlertOpcode opcode);
251: </PRE>
252: <H4>
253: Delete an Alert Handler
254: </H4>
255: <P>
256: You can either delete a handler by referring to its address or to the opcode
257: that it has been registered for.
258: <PRE>
259: extern BOOL HTAlert_delete (HTAlertCallback * cbf);
260: extern BOOL HTAlert_deleteOpcode (HTAlertOpcode opcode);
261: </PRE>
262: <H4>
263: Delete all Alert Handlers
264: </H4>
2.17 frystyk 265: <PRE>
2.49 frystyk 266: extern BOOL HTAlert_deleteAll (void);
2.51 frystyk 267: </PRE>
268: <H4>
269: Find an Alert Handler
270: </H4>
271: <PRE>
2.32 frystyk 272: extern HTAlertCallback * HTAlert_find (HTAlertOpcode opcode);
273: </PRE>
274: <PRE>
2.12 frystyk 275: #endif
276: </PRE>
2.38 frystyk 277: <P>
278: <HR>
2.37 frystyk 279: <ADDRESS>
2.56 ! frystyk 280: @(#) $Id: HTAlert.html,v 2.55 1999/04/01 19:35:39 frystyk Exp $
2.37 frystyk 281: </ADDRESS>
2.38 frystyk 282: </BODY></HTML>
Webmaster