Integer type name change.
[silc.git] / lib / silcclient / client_ops_example.c
1 /* Predefined stub functions for the SilcClientOperation callbacks.
2    You can freely use this template in your application. These are
3    the functions that you as an application programmer need to implement
4    for the library.  The library may call these functions at any time.
5
6    At the end of this file SilcClientOperation structure is defined, and
7    it is the one the you will give as an argument to the silc_client_alloc
8    function. See also lib/silcclient/README file, and silcclient.h. */
9
10
11 /* Message sent to the application by library. `conn' associates the
12    message to a specific connection.  `conn', however, may be NULL. 
13    The `type' indicates the type of the message sent by the library.
14    The applicationi can for example filter the message according the
15    type. */
16
17 static void 
18 silc_say(SilcClient client, SilcClientConnection conn, 
19          SilcClientMessageType type, char *msg, ...)
20 {
21
22 }
23
24
25 /* Message for a channel. The `sender' is the sender of the message
26    The `channel' is the channel. The `msg' is the message.  Note that  
27    `msg' maybe NULL. */
28
29 static void 
30 silc_channel_message(SilcClient client, SilcClientConnection conn, 
31                      SilcClientEntry sender, SilcChannelEntry channel, 
32                      SilcMessageFlags flags, char *msg)
33 {
34
35 }
36
37
38 /* Private message to the client. The `sender' is the sender of the
39    message. */
40
41 static void 
42 silc_private_message(SilcClient client, SilcClientConnection conn, 
43                      SilcClientEntry sender, SilcMessageFlags flags, char *msg)
44 {
45
46 }
47
48
49 /* Notify message to the client. The notify arguments are sent in the
50    same order as servers sends them. The arguments are same as received
51    from the server except for ID's.  If ID is received application receives
52    the corresponding entry to the ID. For example, if Client ID is received
53    application receives SilcClientEntry.  Also, if the notify type is
54    for channel the channel entry is sent to application (even if server
55    does not send it because client library gets the channel entry from
56    the Channel ID in the packet's header). */
57
58 static void 
59 silc_notify(SilcClient client, SilcClientConnection conn, 
60             SilcNotifyType type, ...)
61 {
62
63 }
64
65
66 /* Command handler. This function is called always in the command function.
67    If error occurs it will be called as well. `conn' is the associated
68    client connection. `cmd_context' is the command context that was
69    originally sent to the command. `success' is FALSE if error occurred
70    during command. `command' is the command being processed. It must be
71    noted that this is not reply from server. This is merely called just
72    after application has called the command. Just to tell application
73    that the command really was processed. */
74
75 static void 
76 silc_command(SilcClient client, SilcClientConnection conn, 
77              SilcClientCommandContext cmd_context, int success, 
78              SilcCommand command)
79 {
80
81 }
82
83
84 /* Command reply handler. This function is called always in the command reply
85    function. If error occurs it will be called as well. Normal scenario
86    is that it will be called after the received command data has been parsed
87    and processed. The function is used to pass the received command data to
88    the application. 
89    
90    `conn' is the associated client connection. `cmd_payload' is the command
91    payload data received from server and it can be ignored. It is provided
92    if the application would like to re-parse the received command data,
93    however, it must be noted that the data is parsed already by the library
94    thus the payload can be ignored. `success' is FALSE if error occurred.
95    In this case arguments are not sent to the application. The `status' is
96    the command reply status server returned. The `command' is the command
97    reply being processed. The function has variable argument list and each
98    command defines the number and type of arguments it passes to the
99    application (on error they are not sent). */
100
101 static void 
102 silc_command_reply(SilcClient client, SilcClientConnection conn, 
103                    SilcCommandPayload cmd_payload, int success, 
104                    SilcCommand command, SilcCommandStatus status, ...)
105 {
106
107 }
108
109
110 /* Called to indicate that connection was either successfully established
111    or connecting failed.  This is also the first time application receives
112    the SilcClientConnection objecet which it should save somewhere.
113    If the `success' is FALSE the application must always call the function
114    silc_client_close_connection. */
115
116 static void 
117 silc_connect(SilcClient client, SilcClientConnection conn, int success)
118 {
119
120 }
121
122
123 /* Called to indicate that connection was disconnected to the server. */
124
125 static void 
126 silc_disconnect(SilcClient client, SilcClientConnection conn)
127 {
128
129 }
130
131
132 /* Find authentication method and authentication data by hostname and
133    port. The hostname may be IP address as well. When the authentication
134    method has been resolved the `completion' callback with the found
135    authentication method and authentication data is called. The `conn'
136    may be NULL. */
137
138 static void 
139 silc_get_auth_method(SilcClient client, SilcClientConnection conn, 
140                      char *hostname, SilcUInt16 port, SilcGetAuthMeth completion, 
141                      void *context)
142 {
143
144 }
145
146
147 /* Verifies received public key. The `conn_type' indicates which entity
148    (server, client etc.) has sent the public key. If user decides to trust
149    the key may be saved as trusted public key for later use. The 
150    `completion' must be called after the public key has been verified. */
151
152 static void 
153 silc_verify_public_key(SilcClient client, SilcClientConnection conn, 
154                        SilcSocketType conn_type, unsigned char *pk, 
155                        SilcUInt32 pk_len, SilcSKEPKType pk_type, 
156                        SilcVerifyPublicKey completion, void *context)
157 {
158
159 }
160
161
162 /* Ask (interact, that is) a passphrase from user. The passphrase is
163    returned to the library by calling the `completion' callback with
164    the `context'. */
165
166 static void 
167 silc_ask_passphrase(SilcClient client, SilcClientConnection conn, 
168                     SilcAskPassphrase completion, void *context)
169 {
170
171 }
172
173
174 /* Notifies application that failure packet was received.  This is called
175    if there is some protocol active in the client.  The `protocol' is the
176    protocol context.  The `failure' is opaque pointer to the failure
177    indication.  Note, that the `failure' is protocol dependant and
178    application must explicitly cast it to correct type.  Usually `failure'
179    is 32 bit failure type (see protocol specs for all protocol failure
180    types). */
181
182 static void 
183 silc_failure(SilcClient client, SilcClientConnection conn, 
184              SilcProtocol protocol, void *failure)
185 {
186
187 }
188
189
190 /* Asks whether the user would like to perform the key agreement protocol.
191    This is called after we have received an key agreement packet or an
192    reply to our key agreement packet. This returns TRUE if the user wants
193    the library to perform the key agreement protocol and FALSE if it is not
194    desired (application may start it later by calling the function
195    silc_client_perform_key_agreement). If TRUE is returned also the
196    `completion' and `context' arguments must be set by the application. */
197
198 static int 
199 silc_key_agreement(SilcClient client, SilcClientConnection conn, 
200                    SilcClientEntry client_entry, const char *hostname, 
201                    SilcUInt16 port, SilcKeyAgreementCallback *completion, 
202                    void **context)
203 {
204
205 }
206
207
208 /* Notifies application that file transfer protocol session is being
209    requested by the remote client indicated by the `client_entry' from
210    the `hostname' and `port'. The `session_id' is the file transfer
211    session and it can be used to either accept or reject the file
212    transfer request, by calling the silc_client_file_receive or
213    silc_client_file_close, respectively. */
214
215 static void 
216 silc_ftp(SilcClient client, SilcClientConnection conn, 
217          SilcClientEntry client_entry, SilcUInt32 session_id, 
218          const char *hostname, SilcUInt16 port)
219 {
220
221 }
222
223
224 /* The SilcClientOperation structure containing the operation functions.
225    You will give this as an argument to silc_client_alloc function. */
226 SilcClientOperations ops = {
227   silc_say,
228   silc_channel_message,
229   silc_private_message,
230   silc_notify,
231   silc_command,
232   silc_command_reply,
233   silc_connect,
234   silc_disconnect,
235   silc_get_auth_method,
236   silc_verify_public_key,
237   silc_ask_passphrase,
238   silc_failure,
239   silc_key_agreement,
240   silc_ftp
241 };