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