Annotation of libwww/Library/src/HTAlert.html, revision 2.35

2.6       timbl       1: <HTML>
                      2: <HEAD>
2.32      frystyk     3: <TITLE>Library Interface for Displaying and Promting Messages</TITLE>
2.34      frystyk     4: <!-- Changed by: Henrik Frystyk Nielsen,  6-Feb-1996 -->
2.6       timbl       5: <NEXTID N="z3">
                      6: </HEAD>
                      7: <BODY>
2.12      frystyk     8: 
2.32      frystyk     9: <H1>Library Interface for Displaying and Promting Messages</H1>
2.10      frystyk    10: 
2.12      frystyk    11: <PRE>
                     12: /*
2.18      frystyk    13: **     (c) COPYRIGHT MIT 1995.
2.12      frystyk    14: **     Please first read the full copyright statement in the file COPYRIGH.
                     15: */
                     16: </PRE>
                     17: 
2.32      frystyk    18: This module is a platform independent and language independent
                     19: interface to User messages and prompting. The Library does not provide
                     20: any messages on its own as they must be language independent. These
                     21: can be provided by the application in a language that suits the
                     22: user. The module is a registration of call back functions to the
                     23: application.<P>
2.12      frystyk    24: 
                     25: This module is implemented by <A HREF="HTAlert.c">HTAlert.c</A>, and
2.30      frystyk    26: it is a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C
                     27: Reference Library</A>.
2.12      frystyk    28: 
2.11      frystyk    29: <PRE>
2.12      frystyk    30: #ifndef HTALERT_H
                     31: #define HTALERT_H
2.17      frystyk    32: 
2.27      frystyk    33: #include "HTReq.h"
2.11      frystyk    34: </PRE>
                     35: 
2.32      frystyk    36: <H2>Declaration of Callback Function</H2>
2.15      frystyk    37: 
2.32      frystyk    38: The callback functions are defined as a generic callback where the
                     39: caller can pass a set of input parameters and the callee can return a
                     40: set of outptu parameters. Also note that all the <CODE>*_PROG_*</CODE>
                     41: opcodes are a subset of <CODE>HT_A_PROGRESS</CODE>. This means that
                     42: you easily can register a callback for <EM>all</EM> progress reports.
2.15      frystyk    43: 
2.32      frystyk    44: <PRE>
                     45: typedef enum _HTAlertOpcode {
                     46:     HT_PROG_DNS                = 0x1,          /* Doing DNS resolution */
                     47:     HT_PROG_CONNECT    = 0x2,          /* Connecting Active */
                     48:     HT_PROG_ACCEPT     = 0x4,          /* Connecting Passive */
                     49:     HT_PROG_READ       = 0x8,          /* Read data */
                     50:     HT_PROG_WRITE      = 0x10,         /* Write data */
                     51:     HT_PROG_DONE       = 0x20,         /* Request finished */
                     52:     HT_PROG_WAIT       = 0x40,         /* Wait for socket */
                     53:     HT_A_PROGRESS      = 0xFF,         /* Send a progress report - no reply */
                     54: 
                     55:     /* First word are reserved for progresss notifications */
                     56: 
                     57:     HT_A_MESSAGE       = 0x1&lt;&lt;8, /* Send a message - no reply */
                     58:     HT_A_CONFIRM       = 0x2&lt;&lt;8, /* Want YES or NO back */
                     59:     HT_A_PROMPT                = 0x4&lt;&lt;8, /* Want full dialog */
                     60:     HT_A_SECRET                = 0x8&lt;&lt;8, /* Secret dialog (e.g. password) */
                     61:     HT_A_USER_PW       = 0x10&lt;&lt;8 /* Atomic userid and password */
                     62: } HTAlertOpcode;
2.15      frystyk    63: 
2.32      frystyk    64: typedef struct _HTAlertPar HTAlertPar;
2.8       luotonen   65: 
2.32      frystyk    66: typedef BOOL HTAlertCallback   (HTRequest * request, HTAlertOpcode op,
2.35    ! frystyk    67:                                int msgnum, const char * dfault, void * input,
2.32      frystyk    68:                                HTAlertPar * reply);
2.6       timbl      69: </PRE>
2.11      frystyk    70: 
2.32      frystyk    71: If you don't expect any return values then <CODE>reply</CODE> can be
                     72: NULL. The return value of the callback function can be used to
                     73: indicate confirmation on a prompt (Yes or No).
                     74: 
                     75: <H2>String Messages</H2>
2.11      frystyk    76: 
2.32      frystyk    77: This is an enumerated list of messages that can be converted into a
                     78: string table etc.
2.11      frystyk    79: 
2.15      frystyk    80: <PRE>
2.32      frystyk    81: typedef enum _HTAlertMsg {
                     82:     HT_MSG_NULL = -1,
                     83:     HT_MSG_UID = 0,
                     84:     HT_MSG_PW,
                     85:     HT_MSG_FILENAME,
                     86:     HT_MSG_ACCOUNT,
                     87:     HT_MSG_METHOD,
                     88:     HT_MSG_MOVED,
                     89:     HT_MSG_RULES,
                     90:     HT_MSG_ELEMENTS                        /* This MUST be the last element */
                     91: } HTAlertMsg;
2.15      frystyk    92: </PRE>
                     93: 
2.32      frystyk    94: <H2>Public Methods</H3>
2.15      frystyk    95: 
2.32      frystyk    96: <H3>Enable or Disable Messages</H3>
2.6       timbl      97: 
2.32      frystyk    98: If you really don't want the library to prompt for anything at all
                     99: then enable this constant. The default value is <EM>Interactive</EM>.
                    100: 
                    101: <PRE>
                    102: extern void HTAlert_setInteractive     (BOOL interative);
                    103: extern BOOL HTAlert_interactive                (void);
2.15      frystyk   104: </PRE>
                    105: 
2.32      frystyk   106: <H3>Add a Callback Function to a list</H3>
2.15      frystyk   107: 
2.32      frystyk   108: Register a call back function that is to be called when generating
                    109: messages, dialog, prompts, progress reports etc.
2.15      frystyk   110: 
2.32      frystyk   111: The opcode signifies which call back function to call depending of the
                    112: type of the message. Opcode can be any combination of the bitflags
                    113: defined by <CODE>HTAlertOpcode</CODE>. If you register one callback
                    114: for <CODE>HT_A_PROGRESS</CODE> then this will get called on all
                    115: progress notifications.
2.15      frystyk   116: 
                    117: <PRE>
2.32      frystyk   118: extern BOOL HTAlertCall_add (HTList * list, HTAlertCallback * cbf,
                    119:                             HTAlertOpcode opcode);
2.15      frystyk   120: </PRE>
                    121: 
2.32      frystyk   122: <H3>Delete a Callback function from a list</H3>
2.15      frystyk   123: 
2.32      frystyk   124: Unregister a call back function from a list
1.1       timbl     125: 
2.8       luotonen  126: <PRE>
2.32      frystyk   127: extern BOOL HTAlertCall_delete (HTList * list, HTAlertCallback * cbf);
2.15      frystyk   128: </PRE>
1.1       timbl     129: 
2.32      frystyk   130: <H3>Delete a list of Callback Functions</H3>
2.15      frystyk   131: 
2.32      frystyk   132: Unregisters all call back functions
                    133: 
                    134: <PRE>
                    135: extern BOOL HTAlertCall_deleteAll (HTList * list);
                    136: </PRE>
2.15      frystyk   137: 
2.32      frystyk   138: <H3>Find a Callback Function from a List</H3>
2.15      frystyk   139: 
2.32      frystyk   140: Finds a callback function corresponding to the opcode. If none has
                    141: been registered then NULL is returned.
2.6       timbl     142: 
                    143: <PRE>
2.32      frystyk   144: extern HTAlertCallback * HTAlertCall_find(HTList * list, HTAlertOpcode opcode);
2.6       timbl     145: </PRE>
                    146: 
2.32      frystyk   147: <H2>Handle the Reply Structure</H2>
2.6       timbl     148: 
2.32      frystyk   149: Create and delete...
2.24      frystyk   150: 
                    151: <PRE>
2.32      frystyk   152: extern HTAlertPar * HTAlert_newReply   (void);
                    153: extern void HTAlert_deleteReply                (HTAlertPar * old);
                    154: </PRE>
                    155: 
2.34      frystyk   156: <H3>Handle the Reply Message</H3>
                    157: 
                    158: These methods provide the API for handling the reply message. There
                    159: are two ways of assigning a message to the reply message - either by
                    160: copying the buffer or by reusing the same buffer. In the latter case,
                    161: the caller must make sure <B>not</B> to free the reply message before
                    162: it has been used.
                    163: 
                    164: <PRE>
2.35    ! frystyk   165: extern BOOL HTAlert_setReplyMessage    (HTAlertPar * me, const char *message);
2.34      frystyk   166: extern BOOL HTAlert_assignReplyMessage (HTAlertPar * me, char * message);
                    167: </PRE>
                    168: 
                    169: You can get the data back again by using this method:
2.32      frystyk   170: 
                    171: <PRE>
                    172: extern char * HTAlert_replyMessage     (HTAlertPar * me);
2.34      frystyk   173: </PRE>
2.32      frystyk   174: 
2.34      frystyk   175: <PRE>
2.32      frystyk   176: extern char * HTAlert_replySecret      (HTAlertPar * me);
2.35    ! frystyk   177: extern BOOL HTAlert_setReplySecret     (HTAlertPar * me, const char * secret);
2.6       timbl     178: 
2.32      frystyk   179: extern void * HTAlert_replyOutput      (HTAlertPar * me);
                    180: extern BOOL HTAlert_setReplyOutput     (HTAlertPar * me, void * output);
2.17      frystyk   181: </PRE>
                    182: 
2.32      frystyk   183: <H2>Global set of Callback Functions</H2>
                    184: 
                    185: A list can be assigned as being global for all messages.
2.17      frystyk   186: 
2.32      frystyk   187: <PRE>
                    188: extern void HTAlert_setGlobal  (HTList * list);
                    189: extern HTList * HTAlert_global (void);
                    190: </PRE>
                    191: 
                    192: You can also assign a callback directly to the global list. In this
                    193: case you do not need to worry about creating the list - it will be
                    194: created automatically.
2.17      frystyk   195: 
                    196: <PRE>
2.33      frystyk   197: extern BOOL HTAlert_add                (HTAlertCallback * cbf, HTAlertOpcode opcode);
                    198: extern BOOL HTAlert_delete     (HTAlertCallback * cbf);
2.32      frystyk   199: extern HTAlertCallback * HTAlert_find (HTAlertOpcode opcode);
                    200: </PRE>
2.6       timbl     201: 
2.32      frystyk   202: <PRE>
2.12      frystyk   203: #endif
                    204: </PRE>
2.32      frystyk   205: 
                    206: End of declaration
2.6       timbl     207: 
2.12      frystyk   208: </BODY>
2.6       timbl     209: </HTML>

Webmaster