7685978ec8836ad83e0e072442369259da20dec0
[silc.git] / lib / silcclient / silcclient_entry.h
1 /*
2
3   silcclient_entry.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2006 - 2007 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 /****h* silcclient/Client Library Interface
21  *
22  * DESCRIPTION
23  *
24  * This header file includes the SilcClientEntry, SilcChannelEntry and
25  * SilcServer entry structures and various routines to search, resolve and
26  * handle these structures.
27  *
28  * All entries (SilcClientEntry, SilcChannelEntry and SilcServerEntry) are
29  * reference counted.  If application wishes to save an entry pointer it must
30  * always first acquire a reference.  The reference must be released once the
31  * entry is not needed anymore.  If application wants to read any data from
32  * the entry structure it must first lock the entry.  This protects access to
33  * the entries in multithreaded environment.  If threads are not used, locking
34  * the entries is not needed.  They however still must be referenced even
35  * when threads are not used.
36  *
37  ***/
38
39 #ifndef SILCCLIENT_ENTRY_H
40 #define SILCCLIENT_ENTRY_H
41
42 #ifndef SILCCLIENT_H
43 #error "Do not include this header directly, include silcclient.h instead"
44 #endif
45
46 /****s* silcclient/SilcClientAPI/SilcClientEntry
47  *
48  * NAME
49  *
50  *    typedef struct SilcClientEntryStruct { ... } *SilcClientEntry;
51  *
52  * DESCRIPTION
53  *
54  *    This structure represents a client or a user in the SILC network.
55  *    The local user has this structure also and it can be accessed from
56  *    SilcClientConnection structure.  All other users in the SILC network
57  *    that are accessed using the Client Library routines will have their
58  *    own SilcClientEntry structure.  For example, when finding users by
59  *    their nickname the Client Library returns this structure back to
60  *    the application.  All strings in the structure are UTF-8 encoded.
61  *
62  *    Application may store its own pointer into the context pointer in
63  *    this structure.
64  *
65  * NOTES
66  *
67  *    If application wants to store nickname or any of the other strings
68  *    it should always duplicated them.
69  *
70  *    None of the string arrays are set if the first character is '\0'.
71  *    All string arrays are always zero ('\0') terminated.
72  *
73  *    If application stores the SilcClientEntry it must always take
74  *    a reference of it by calling silc_client_ref_client function.  The
75  *    reference must be released after it is not needed anymore by calling
76  *    silc_client_unref_client function.
77  *
78  * SOURCE
79  */
80 struct SilcClientEntryStruct {
81   char nickname[128 + 1];            /* Nickname */
82   char username[128 + 1];            /* Username */
83   char hostname[256 + 1];            /* Hostname */
84   char server  [256 + 1];            /* SILC server name */
85   char *realname;                    /* Realname (userinfo) */
86   char *nickname_normalized;         /* Normalized nickname */
87
88   SilcClientID id;                   /* The Client ID */
89   SilcUInt32 mode;                   /* User mode in SILC, see SilcUserMode */
90   SilcPublicKey public_key;          /* User's public key, may be NULL */
91   SilcHashTable channels;            /* Channels client has joined */
92   SilcDList attrs;                   /* Requested Attributes (maybe NULL) */
93   unsigned char fingerprint[20];     /* SHA-1 fingerprint of the public key */
94
95   void *context;                     /* Application specific context */
96   SilcClientEntryInternal internal;
97 };
98 /***/
99
100 /****s* silcclient/SilcClientAPI/SilcChannelEntry
101  *
102  * NAME
103  *
104  *    typedef struct SilcChannelEntryStruct { ... } *SilcChannelEntry;
105  *
106  * DESCRIPTION
107  *
108  *    This structure represents a channel in the SILC network.  All
109  *    channels that the client are aware of or have joined in will be
110  *    represented as SilcChannelEntry.  The structure includes information
111  *    about the channel.  All strings in the structure are UTF-8 encoded.
112  *
113  *    Application may store its own pointer into the context pointer in
114  *    this structure.
115  *
116  * NOTES
117  *
118  *    If application stores the SilcChannelEntry it must always take
119  *    a reference of it by calling silc_client_ref_channel function.  The
120  *    reference must be released after it is not needed anymore by calling
121  *    silc_client_unref_channel function.
122  *
123  * SOURCE
124  */
125 struct SilcChannelEntryStruct {
126   char *channel_name;                /* Channel name */
127   char *topic;                       /* Current topic, may be NULL */
128   SilcPublicKey founder_key;         /* Founder key, may be NULL */
129   SilcDList channel_pubkeys;         /* Channel public keys, may be NULL */
130   SilcChannelID id;                  /* Channel ID */
131   SilcUInt32 mode;                   /* Channel mode, ChannelModes. */
132   SilcUInt32 user_limit;             /* User limit on channel */
133   SilcHashTable user_list;           /* Joined users.  Key to hash table is
134                                         SilcClientEntry, context is
135                                         SilcChannelUser. */
136   const char *cipher;                /* Current channel cipher algorithm*/
137   const char *hmac;                  /* Current channel HMAC algorithm */
138
139   void *context;                     /* Application specific context */
140   SilcChannelEntryInternal internal;
141 };
142 /***/
143
144 /****s* silcclient/SilcClientAPI/SilcServerEntry
145  *
146  * NAME
147  *
148  *    typedef struct SilcServerEntryStruct { ... } *SilcServerEntry;
149  *
150  * DESCRIPTION
151  *
152  *    This structure represents a server in the SILC network.  All servers
153  *    that the client is aware of and have for example resolved with
154  *    SILC_COMMAND_INFO command have their on SilcServerEntry structure.
155  *    Server's public key is present only if it has been retrieved using
156  *    SILC_COMMAND_GETKEY command.  All strings in the structure are UTF-8
157  *    encoded.
158  *
159  *    Application may store its own pointer into the context pointer in
160  *    this structure.
161  *
162  * NOTES
163  *
164  *    If application stores the SilcServerEntry it must always take
165  *    a reference of it by calling silc_client_ref_server function.  The
166  *    reference must be released after it is not needed anymore by calling
167  *    silc_client_unref_server function.
168  *
169  * SOURCE
170  */
171 struct SilcServerEntryStruct {
172   /* General information */
173   char *server_name;                 /* Server name */
174   char *server_info;                 /* Server info */
175   SilcServerID id;                   /* Server ID */
176   SilcPublicKey public_key;          /* Server public key, may be NULL */
177
178   void *context;                     /* Application specific context */
179   SilcServerEntryInternal internal;
180 };
181 /***/
182
183 /* SilcClientEntry routines */
184
185 /****f* silcclient/SilcClientAPI/SilcGetClientCallback
186  *
187  * SYNOPSIS
188  *
189  *    typedef void (*SilcGetClientCallback)(SilcClient client,
190  *                                          SilcClientConnection conn,
191  *                                          SilcStatus status,
192  *                                          SilcDList clients,
193  *                                          void *context);
194  *
195  * DESCRIPTION
196  *
197  *    Callback function given to various client search functions.  The
198  *    found entries are allocated into the `clients' list.  The list must
199  *    not be freed by the receiver, the library will free it later.  If the
200  *    `clients' is NULL, no such clients exist in the SILC network, and
201  *    the `status' will include the error.  Each entry in the `clients'
202  *    is SilcClientEntry.
203  *
204  * NOTES
205  *
206  *    If the application stores any of the SilcClientEntry pointers from
207  *    the `clients' list it must reference it with silc_client_ref_client
208  *    function.
209  *
210  *    Application must not free the returned `clients' list.
211  *
212  ***/
213 typedef void (*SilcGetClientCallback)(SilcClient client,
214                                       SilcClientConnection conn,
215                                       SilcStatus status,
216                                       SilcDList clients,
217                                       void *context);
218
219 /****f* silcclient/SilcClientAPI/silc_client_lock_client
220  *
221  * SYNOPSIS
222  *
223  *    void silc_client_lock_client(SilcClientEntry client_entry);
224  *
225  * DESCRIPTION
226  *
227  *    Acquires lock for the client entry indicate by `client_entry'.  When
228  *    application wants to access `client_entry' it must lock the entry
229  *    before reading any data from the `client_entry'.  The lock must be
230  *    unlocked with silc_client_unlock_client.
231  *
232  * NOTES
233  *
234  *    The entry must be unlocked before calling any Client Library API
235  *    functions where the entry is given as argument, unless otherwise stated.
236  *
237  *    The entry should not be locked for long periods of time.  For example,
238  *    it is not appropriate to hold the lock while waiting user interface to
239  *    be drawn.  The appropriate way is to read the data and duplicate it if
240  *    necessary, unlock the entry, then draw on the user interface.
241  *
242  *    This function is not needed if application is not multithreaded.
243  *
244  ***/
245 void silc_client_lock_client(SilcClientEntry client_entry);
246
247 /****f* silcclient/SilcClientAPI/silc_client_unlock_client
248  *
249  * SYNOPSIS
250  *
251  *    void silc_client_unlock_client(SilcClientEntry client_entry);
252  *
253  * DESCRIPTION
254  *
255  *    Releases the lock acquired with silc_client_lock_client.
256  *
257  ***/
258 void silc_client_unlock_client(SilcClientEntry client_entry);
259
260 /****f* silcclient/SilcClientAPI/silc_client_ref_client
261  *
262  * SYNOPSIS
263  *
264  *    SilcClientEntry
265  *    silc_client_ref_client(SilcClient client,
266  *                           SilcClientConnection conn,
267  *                           SilcClientEntry client_entry);
268  *
269  * DESCRIPTION
270  *
271  *    Takes a reference of the client entry indicated by `client_entry'
272  *    The reference must be released by calling silc_client_unref_client
273  *    after it is not needed anymore.  Returns `client_entry'.
274  *
275  ***/
276 SilcClientEntry silc_client_ref_client(SilcClient client,
277                                        SilcClientConnection conn,
278                                        SilcClientEntry client_entry);
279
280 /****f* silcclient/SilcClientAPI/silc_client_unref_client
281  *
282  * SYNOPSIS
283  *
284  *    void silc_client_unref_client(SilcClient client,
285  *                                  SilcClientConnection conn,
286  *                                  SilcClientEntry client_entry);
287  *
288  * DESCRIPTION
289  *
290  *    Releases the client entry reference indicated by `client_entry'.
291  *
292  ***/
293 void silc_client_unref_client(SilcClient client, SilcClientConnection conn,
294                               SilcClientEntry client_entry);
295
296 /****f* silcclient/SilcClientAPI/silc_client_list_free
297  *
298  * SYNOPSIS
299  *
300  *    void silc_client_list_free(SilcClient client,
301  *                               SilcClientConnection conn,
302  *                               SilcDList client_list);
303  *
304  * DESCRIPTION
305  *
306  *    Free's client entry list that has been returned by various library
307  *    routines.
308  *
309  ***/
310 void silc_client_list_free(SilcClient client, SilcClientConnection conn,
311                            SilcDList client_list);
312
313 /****f* silcclient/SilcClientAPI/silc_client_get_clients
314  *
315  * SYNOPSIS
316  *
317  *    SilcUInt16 silc_client_get_clients(SilcClient client,
318  *                                       SilcClientConnection conn,
319  *                                       const char *nickname,
320  *                                       const char *server,
321  *                                       SilcGetClientCallback completion,
322  *                                       void *context);
323  *
324  * DESCRIPTION
325  *
326  *    Finds client entry or entries by the `nickname' and `server'. The
327  *    completion callback will be called when the client entries has been
328  *    found.  After the server returns the client information it is cached
329  *    and can be accesses locally at a later time.  The resolving is done
330  *    with IDENTIFY command.  The `server' may be NULL.  The server
331  *    associated with the nickname may be in the `nickname' (nick@server).
332  *    The `nickname' may also be a formatted nickname in which case the
333  *    formatting is ignored and the base nickname is used.  If the nickname
334  *    is formatted it must be formatted as defined in SilcClientParams.
335  *    Returns 0 on error and the command identifier used with the command
336  *    otherwise.
337  *
338  * NOTES
339  *
340  *    This function is always asynchronous and resolves the client
341  *    information from the server.  Thus, if you already know the client
342  *    information then use the silc_client_get_client_by_id function to
343  *    get the client entry since this function may be very slow and should
344  *    be used only to initially get the client entries.
345  *
346  *    This function resolves only the relevant information (user's nickname
347  *    and username).  It does not resolve for example user's real name,
348  *    joined channel list or other information.  To resolve all the details
349  *    use silc_client_get_clients_whois instead.
350  *
351  ***/
352 SilcUInt16 silc_client_get_clients(SilcClient client,
353                                    SilcClientConnection conn,
354                                    const char *nickname,
355                                    const char *server,
356                                    SilcGetClientCallback completion,
357                                    void *context);
358
359 /****f* silcclient/SilcClientAPI/silc_client_get_clients_whois
360  *
361  * SYNOPSIS
362  *
363  *    SilcUInt16
364  *    silc_client_get_clients_whois(SilcClient client,
365  *                                  SilcClientConnection conn,
366  *                                  const char *nickname,
367  *                                  const char *server,
368  *                                  SilcBuffer attributes,
369  *                                  SilcGetClientCallback completion,
370  *                                  void *context);
371  *
372  * DESCRIPTION
373  *
374  *    Finds client entry or entries by the `nickname' and `server'. The
375  *    completion callback will be called when the client entries has been
376  *    found.  After the server returns the client information it is cached
377  *    and can be accesses locally at a later time.  The resolving is done
378  *    with WHOIS command.  The `server' may be NULL.  The server
379  *    associated with the nickname may be in the `nickname' (nick@server).
380  *    The `nickname' may also be a formatted nickname in which case the
381  *    formatting is ignored and the base nickname is used.  If the nickname
382  *    is formatted it must be formatted as defined in SilcClientParams.
383  *    Returns 0 on error and the command identifier used with the command
384  *    otherwise.
385  *
386  *    If the `attributes' is non-NULL then the buffer includes Requested
387  *    Attributes which can be used to fetch very detailed information
388  *    about the user. If it is NULL then only normal WHOIS query is
389  *    made (for more information about attributes see SilcAttribute).
390  *    Caller may create the `attributes' with silc_client_attributes_request
391  *    function.
392  *
393  * NOTES
394  *
395  *    The resolving is done with WHOIS command.  For this reason this
396  *    command may take a long time because it resolves detailed user
397  *    information.
398  *
399  ***/
400 SilcUInt16 silc_client_get_clients_whois(SilcClient client,
401                                          SilcClientConnection conn,
402                                          const char *nickname,
403                                          const char *server,
404                                          SilcBuffer attributes,
405                                          SilcGetClientCallback completion,
406                                          void *context);
407
408 /****f* silcclient/SilcClientAPI/silc_client_get_clients_local
409  *
410  * SYNOPSIS
411  *
412  *    SilcDList silc_client_get_clients_local(SilcClient client,
413  *                                            SilcClientConnection conn,
414  *                                            const char *nickname,
415  *                                            SilcBool return_all);
416  *
417  * DESCRIPTION
418  *
419  *    Same as silc_client_get_clients function but does not resolve anything
420  *    from the server.  This checks local cache and returns matching clients
421  *    from the local cache.  If none was found this returns NULL.  The
422  *    `nickname' is the nickname to find and it may be a formatted nickname
423  *    or a base nickname.  If the `return_all' is TRUE this call will return
424  *    all clients matching the `nickname' base.  If it is FALSE this will
425  *    return the exact match if `nickname' is a formatted nickname or the
426  *    first matching nickname if it is not formatted.  The formatted nickname
427  *    must of the format specified in SilcClientParams.  The caller must free
428  *    the returned list by calling silc_client_list_free function.
429  *
430  * NOTES
431  *
432  *    If the application stores any of the SilcClientEntry pointers from
433  *    the returned list it must reference it with silc_client_ref_client
434  *    function.
435  *
436  *    Application must free the returned list with silc_client_list_free
437  *    function.
438  *
439  ***/
440 SilcDList silc_client_get_clients_local(SilcClient client,
441                                         SilcClientConnection conn,
442                                         const char *nickname,
443                                         SilcBool return_all);
444
445 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id
446  *
447  * SYNOPSIS
448  *
449  *    SilcClientEntry silc_client_get_client_by_id(SilcClient client,
450  *                                                 SilcClientConnection conn,
451  *                                                 SilcClientID *client_id);
452  *
453  * DESCRIPTION
454  *
455  *    Find client entry by the client's ID.  Returns the entry or NULL
456  *    if the entry was not found.  This checks the local cache and does
457  *    not resolve anything from server.
458  *
459  * NOTES
460  *
461  *    The returned SilcClientEntry has been referenced by the library and
462  *    the caller must call silc_client_unref_client after the entry is not
463  *    needed anymore.
464  *
465  ***/
466 SilcClientEntry silc_client_get_client_by_id(SilcClient client,
467                                              SilcClientConnection conn,
468                                              SilcClientID *client_id);
469
470 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id_resolve
471  *
472  * SYNOPSIS
473  *
474  *    SilcUInt16
475  *    silc_client_get_client_by_id_resolve(SilcClient client,
476  *                                         SilcClientConnection conn,
477  *                                         SilcClientID *client_id,
478  *                                         SilcBuffer attributes,
479  *                                         SilcGetClientCallback completion,
480  *                                         void *context);
481  *
482  * DESCRIPTION
483  *
484  *    Same as silc_client_get_client_by_id but will always resolve the
485  *    information from the server. Use this only if you know that you
486  *    do not have the entry and the only thing you know about the client
487  *    is its ID. When server returns the client information it will be
488  *    cache and can be accessed locally at a later time. The resolving
489  *    is done by sending WHOIS command.
490  *
491  *    Returns command identifier for the resolving.  It can be used to attach
492  *    a pending command to it, if needed.  Returns 0 on error.
493  *
494  *    If the `attributes' is non-NULL then the buffer includes Requested
495  *    Attributes which can be used to fetch very detailed information
496  *    about the user. If it is NULL then only normal WHOIS query is
497  *    made (for more information about attributes see SilcAttribute).
498  *    Caller may create the `attributes' with silc_client_attributes_request
499  *    function.
500  *
501  ***/
502 SilcUInt16
503 silc_client_get_client_by_id_resolve(SilcClient client,
504                                      SilcClientConnection conn,
505                                      SilcClientID *client_id,
506                                      SilcBuffer attributes,
507                                      SilcGetClientCallback completion,
508                                      void *context);
509
510 /* SilcChannelEntry routines */
511
512 /****f* silcclient/SilcClientAPI/SilcGetChannelCallback
513  *
514  * SYNOPSIS
515  *
516  *    typedef void (*SilcGetChannelCallback)(SilcClient client,
517  *                                           SilcClientConnection conn,
518  *                                           SilcStatus status,
519  *                                           SilcDList channels,
520  *                                           void *context);
521  *
522  * DESCRIPTION
523  *
524  *    Callback function given to various channel resolving functions.
525  *    The found entries are included in the `channels' list and each entry
526  *    in the list is SilcChannelEntry.  If `channels' is NULL then no such
527  *    channel exist in the network and the `status' will indicate the error.
528  *
529  * NOTES
530  *
531  *    If the application stores any of the SilcChannelEntry pointers from
532  *    the `channels' list it must reference it with silc_client_ref_channel
533  *    function.
534  *
535  *    Application must not free the returned `channels' list.
536  *
537  ***/
538 typedef void (*SilcGetChannelCallback)(SilcClient client,
539                                        SilcClientConnection conn,
540                                        SilcStatus status,
541                                        SilcDList channels,
542                                        void *context);
543
544 /****f* silcclient/SilcClientAPI/silc_client_lock_channel
545  *
546  * SYNOPSIS
547  *
548  *    void silc_client_lock_channel(SilcChannelEntry channel_entry);
549  *
550  * DESCRIPTION
551  *
552  *    Acquires lock for the channel entry indicate by `channel_entry'.  When
553  *    application wants to access `channel_entry' it must lock the entry
554  *    before reading any data from the `channel_entry'.  The lock must be
555  *    unlocked with silc_client_unlock_channel.
556  *
557  * NOTES
558  *
559  *    The entry must be unlocked before calling any Client Library API
560  *    functions where the entry is given as argument, unless otherwise stated.
561  *
562  *    The entry should not be locked for long periods of time.  For example,
563  *    it is not appropriate to hold the lock while waiting user interface to
564  *    be drawn.  The appropriate way is to read the data and duplicate it if
565  *    necessary, unlock the entry, then draw on the user interface.
566  *
567  *    This function is not needed if application is not multithreaded.
568  *
569  ***/
570 void silc_client_lock_channel(SilcChannelEntry channel_entry);
571
572 /****f* silcclient/SilcClientAPI/silc_client_unlock_channel
573  *
574  * SYNOPSIS
575  *
576  *    void silc_client_unlock_channel(SilcChannelEntry channel_entry);
577  *
578  * DESCRIPTION
579  *
580  *    Releases the lock acquired with silc_client_lock_channel.
581  *
582  ***/
583 void silc_client_unlock_channel(SilcChannelEntry channel_entry);
584
585 /****f* silcclient/SilcClientAPI/silc_client_ref_channel
586  *
587  * SYNOPSIS
588  *
589  *    SilcChannelEntry
590  *    silc_client_ref_channel(SilcClient client,
591  *                            SilcClientConnection conn,
592  *                            SilcChannelEntry channel_entry);
593  *
594  * DESCRIPTION
595  *
596  *    Takes a reference of the channel entry indicated by `channel_entry'
597  *    The reference must be released by calling silc_client_unref_channel
598  *    after it is not needed anymore.  Returns `channel_entry'.
599  *
600  ***/
601 SilcChannelEntry silc_client_ref_channel(SilcClient client,
602                                          SilcClientConnection conn,
603                                          SilcChannelEntry channel_entry);
604
605 /****f* silcclient/SilcClientAPI/silc_client_unref_channel
606  *
607  * SYNOPSIS
608  *
609  *    void silc_client_unref_channel(SilcClient client,
610  *                                   SilcClientConnection conn,
611  *                                   SilcChannelEntry channel_entry);
612  *
613  * DESCRIPTION
614  *
615  *    Releases the channel entry reference indicated by `channel_entry'.
616  *
617  ***/
618 void silc_client_unref_channel(SilcClient client, SilcClientConnection conn,
619                                SilcChannelEntry channel_entry);
620
621 /****f* silcclient/SilcClientAPI/silc_client_list_free_channel
622  *
623  * SYNOPSIS
624  *
625  *    void silc_client_list_free_channel(SilcClient client,
626  *                                       SilcClientConnection conn,
627  *                                       SilcDList channel_list);
628  *
629  * DESCRIPTION
630  *
631  *    Free's channel entry list that has been returned by various library
632  *    routines.
633  *
634  ***/
635 void silc_client_list_free_channels(SilcClient client,
636                                     SilcClientConnection conn,
637                                     SilcDList channel_list);
638
639 /****f* silcclient/SilcClientAPI/silc_client_get_channel
640  *
641  * SYNOPSIS
642  *
643  *    SilcChannelEntry silc_client_get_channel(SilcClient client,
644  *                                             SilcClientConnection conn,
645  *                                             char *channel_name);
646  *
647  * DESCRIPTION
648  *
649  *    Finds entry for channel by the channel name. Returns the entry or NULL
650  *    if the entry was not found. It is found only if the client is joined
651  *    to the channel.  Use silc_client_get_channel_resolve or
652  *    silc_client_get_channel_by_id_resolve to resolve channel that client
653  *    is not joined.
654  *
655  * NOTES
656  *
657  *    The returned SilcChannelEntry has been referenced by the library and
658  *    the caller must call silc_client_unref_channel after the entry is not
659  *    needed anymore.
660  *
661  ***/
662 SilcChannelEntry silc_client_get_channel(SilcClient client,
663                                          SilcClientConnection conn,
664                                          char *channel_name);
665
666 /****f* silcclient/SilcClientAPI/silc_client_get_channel_resolve
667  *
668  * SYNOPSIS
669  *
670  *    void silc_client_get_channel_resolve(SilcClient client,
671  *                                         SilcClientConnection conn,
672  *                                         char *channel_name,
673  *                                         SilcGetChannelCallback completion,
674  *                                         void *context);
675  *
676  * DESCRIPTION
677  *
678  *    Resolves entry for channel by the channel name from the server.
679  *    The resolving is done with IDENTIFY command. Note that users on
680  *    the channel are not resolved at the same time. Use for example
681  *    USERS command to resolve all users on a channel.
682  *
683  ***/
684 void silc_client_get_channel_resolve(SilcClient client,
685                                      SilcClientConnection conn,
686                                      char *channel_name,
687                                      SilcGetChannelCallback completion,
688                                      void *context);
689
690 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id
691  *
692  * SYNOPSIS
693  *
694  *    SilcChannelEntry
695  *    silc_client_get_channel_by_id(SilcClient client,
696  *                                  SilcClientConnection conn,
697  *                                  SilcChannelID *channel_id);
698  *
699  * DESCRIPTION
700  *
701  *    Finds channel entry by the channel ID. Returns the entry or NULL
702  *    if the entry was not found.  This checks the local cache and does
703  *    not resolve anything from server.
704  *
705  * NOTES
706  *
707  *    The returned SilcChannelEntry has been referenced by the library and
708  *    the caller must call silc_client_unref_channel after the entry is not
709  *    needed anymore.
710  *
711  ***/
712 SilcChannelEntry silc_client_get_channel_by_id(SilcClient client,
713                                                SilcClientConnection conn,
714                                                SilcChannelID *channel_id);
715
716 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id_resolve
717  *
718  * SYNOPSIS
719  *
720  *    SilcUInt16
721  *    silc_client_get_channel_by_id_resolve(SilcClient client,
722  *                                          SilcClientConnection conn,
723  *                                          SilcChannelID *channel_id,
724  *                                          SilcGetClientCallback completion,
725  *                                          void *context);
726  *
727  * DESCRIPTION
728  *
729  *    Resolves the channel information (its name mainly) from the server
730  *    by the `channel_id'. Use this only if you know that you do not have
731  *    the entry cached locally. The resolving is done with IDENTIFY command.
732  *
733  *    Returns command identifier for the resolving.  It can be used to attach
734  *    a pending command to it, if needed.  Returns 0 on error.
735  *
736  *    Note that users on the channel are not resolved at the same time.
737  *    Use for example USERS command to resolve all users on a channel.
738  *
739  ***/
740 SilcUInt16
741 silc_client_get_channel_by_id_resolve(SilcClient client,
742                                       SilcClientConnection conn,
743                                       SilcChannelID *channel_id,
744                                       SilcGetChannelCallback completion,
745                                       void *context);
746
747 /* SilcServerEntry routines */
748
749 /****f* silcclient/SilcClientAPI/SilcGetServerCallback
750  *
751  * SYNOPSIS
752  *
753  *    typedef void (*SilcGetServerCallback)(SilcClient client,
754  *                                          SilcClientConnection conn,
755  *                                          SilcStatus status,
756  *                                          SilcDList servers,
757  *                                          void *context);
758  *
759  * DESCRIPTION
760  *
761  *    Callback function given to various server resolving functions.
762  *    The found entries are included in the `servers' list and each entry
763  *    in the list is SilcServerEntry.  If `server' is NULL then no such
764  *    server exist in the network and the `status' will indicate the error.
765  *
766  * NOTES
767  *
768  *    If the application stores any of the SilcServerEntry pointers from
769  *    the `server' list it must reference it with silc_client_ref_server
770  *    function.
771  *
772  *    Application must not free the returned `server' list.
773  *
774  ***/
775 typedef void (*SilcGetServerCallback)(SilcClient client,
776                                       SilcClientConnection conn,
777                                       SilcStatus status,
778                                       SilcDList servers,
779                                       void *context);
780
781 /****f* silcclient/SilcClientAPI/silc_client_lock_server
782  *
783  * SYNOPSIS
784  *
785  *    void silc_client_lock_server(SilcServerEntry server_entry);
786  *
787  * DESCRIPTION
788  *
789  *    Acquires lock for the server entry indicate by `server_entry'.  When
790  *    application wants to access `server_entry' it must lock the entry
791  *    before reading any data from the `server_entry'.  The lock must be
792  *    unlocked with silc_client_unlock_server.
793  *
794  * NOTES
795  *
796  *    The entry must be unlocked before calling any Client Library API
797  *    functions where the entry is given as argument, unless otherwise stated.
798  *
799  *    The entry should not be locked for long periods of time.  For example,
800  *    it is not appropriate to hold the lock while waiting user interface to
801  *    be drawn.  The appropriate way is to read the data and duplicate it if
802  *    necessary, unlock the entry, then draw on the user interface.
803  *
804  *    This function is not needed if application is not multithreaded.
805  *
806  ***/
807 void silc_client_lock_server(SilcServerEntry server_entry);
808
809 /****f* silcclient/SilcClientAPI/silc_client_unlock_server
810  *
811  * SYNOPSIS
812  *
813  *    void silc_client_unlock_server(SilcServerEntry server_entry);
814  *
815  * DESCRIPTION
816  *
817  *    Releases the lock acquired with silc_client_lock_server.
818  *
819  ***/
820 void silc_client_unlock_server(SilcServerEntry server_entry);
821
822 /****f* silcclient/SilcClientAPI/silc_client_ref_server
823  *
824  * SYNOPSIS
825  *
826  *    SilcServerEntry
827  *    silc_client_ref_server(SilcClient client,
828  *                           SilcClientConnection conn,
829  *                           SilcServerEntry server_entry);
830  *
831  * DESCRIPTION
832  *
833  *    Takes a reference of the server entry indicated by `server_entry'
834  *    The reference must be released by calling silc_client_unref_server
835  *    after it is not needed anymore.  Returns `server_entry'.
836  *
837  ***/
838 SilcServerEntry silc_client_ref_server(SilcClient client,
839                                        SilcClientConnection conn,
840                                        SilcServerEntry server_entry);
841
842 /****f* silcclient/SilcClientAPI/silc_client_unref_server
843  *
844  * SYNOPSIS
845  *
846  *    void silc_client_unref_server(SilcClient client,
847  *                                  SilcClientConnection conn,
848  *                                  SilcServerEntry server_entry);
849  *
850  * DESCRIPTION
851  *
852  *    Releases the server entry reference indicated by `server_entry'.
853  *
854  ***/
855 void silc_client_unref_server(SilcClient client, SilcClientConnection conn,
856                               SilcServerEntry server_entry);
857
858 /****f* silcclient/SilcClientAPI/silc_client_list_free_server
859  *
860  * SYNOPSIS
861  *
862  *    void silc_client_list_free_server(SilcClient client,
863  *                                      SilcClientConnection conn,
864  *                                      SilcDList server_list);
865  *
866  * DESCRIPTION
867  *
868  *    Free's server entry list that has been returned by various library
869  *    routines.
870  *
871  ***/
872 void silc_client_list_free_servers(SilcClient client,
873                                    SilcClientConnection conn,
874                                    SilcDList server_list);
875
876 /****f* silcclient/SilcClientAPI/silc_client_get_server
877  *
878  * SYNOPSIS
879  *
880  *    SilcServerEntry silc_client_get_server(SilcClient client,
881  *                                           SilcClientConnection conn,
882  *                                           char *server_name)
883  *
884  * DESCRIPTION
885  *
886  *    Finds entry for server by the server name. Returns the entry or NULL
887  *    if the entry was not found.
888  *
889  ***/
890 SilcServerEntry silc_client_get_server(SilcClient client,
891                                        SilcClientConnection conn,
892                                        char *server_name);
893
894 /****f* silcclient/SilcClientAPI/silc_client_get_server_by_id
895  *
896  * SYNOPSIS
897  *
898  *    SilcServerEntry silc_client_get_server_by_id(SilcClient client,
899  *                                                 SilcClientConnection conn,
900  *                                                 SilcServerID *server_id);
901  *
902  * DESCRIPTION
903  *
904  *    Finds entry for server by the server ID. Returns the entry or NULL
905  *    if the entry was not found.
906  *
907  ***/
908 SilcServerEntry silc_client_get_server_by_id(SilcClient client,
909                                              SilcClientConnection conn,
910                                              SilcServerID *server_id);
911
912 /****f* silcclient/SilcClientAPI/silc_client_get_server_by_id_resolve
913  *
914  * SYNOPSIS
915  *
916  *    SilcUInt16
917  *    silc_client_get_server_by_id_resolve(SilcClient client,
918  *                                         SilcClientConnection conn,
919  *                                         SilcServerID *server_id,
920  *                                         SilcGetServerCallback completion,
921  *                                         void *context);
922  *
923  * DESCRIPTION
924  *
925  *    Resolves the server information by the `server_id'.  The resolved
926  *    server is returned into the `completion' callback.
927  *
928  *    Returns command identifier for the resolving.  It can be used to attach
929  *    a pending command to it, if needed.  Returns 0 on error.
930  *
931  ***/
932 SilcUInt16
933 silc_client_get_server_by_id_resolve(SilcClient client,
934                                      SilcClientConnection conn,
935                                      SilcServerID *server_id,
936                                      SilcGetServerCallback completion,
937                                      void *context);
938
939 #endif /* SILCCLIENT_ENTRY_H */