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