56cbaf7d6fe5c1c2b82eb0e97e15d257301310ec
[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_lock_client
199  *
200  * SYNOPSIS
201  *
202  *    void silc_client_lock_client(SilcClientEntry client_entry);
203  *
204  * DESCRIPTION
205  *
206  *    Acquires lock for the client entry indicate by `client_entry'.  When
207  *    application wants to access `client_entry' it must lock the entry
208  *    before reading any data from the `client_entry'.  The lock must be
209  *    unlocked with silc_client_unlock_client.
210  *
211  *    The entry must be unlocked before calling any Client Library API
212  *    functions where the entry is given as argument.
213  *
214  *    This function is not needed if application is not multithreaded
215  *
216  ***/
217 void silc_client_lock_client(SilcClientEntry client_entry);
218
219 /****f* silcclient/SilcClientAPI/silc_client_unlock_client
220  *
221  * SYNOPSIS
222  *
223  *    void silc_client_unlock_client(SilcClientEntry client_entry);
224  *
225  * DESCRIPTION
226  *
227  *    Releases the lock acquired with silc_client_lock_client.
228  *
229  ***/
230 void silc_client_unlock_client(SilcClientEntry client_entry);
231
232 /****f* silcclient/SilcClientAPI/silc_client_ref_client
233  *
234  * SYNOPSIS
235  *
236  *    SilcClientEntry
237  *    silc_client_ref_client(SilcClient client,
238  *                           SilcClientConnection conn,
239  *                           SilcClientEntry client_entry);
240  *
241  * DESCRIPTION
242  *
243  *    Takes a reference of the client entry indicated by `client_entry'
244  *    The reference must be released by calling silc_client_unref_client
245  *    after it is not needed anymore.  Returns `client_entry'.
246  *
247  ***/
248 SilcClientEntry silc_client_ref_client(SilcClient client, 
249                                        SilcClientConnection conn,
250                                        SilcClientEntry client_entry);
251
252 /****f* silcclient/SilcClientAPI/silc_client_unref_client
253  *
254  * SYNOPSIS
255  *
256  *    void silc_client_unref_client(SilcClient client,
257  *                                  SilcClientConnection conn,
258  *                                  SilcClientEntry client_entry);
259  *
260  * DESCRIPTION
261  *
262  *    Releases the client entry reference indicated by `client_entry'.
263  *
264  ***/
265 void silc_client_unref_client(SilcClient client, SilcClientConnection conn,
266                               SilcClientEntry client_entry);
267
268 /****f* silcclient/SilcClientAPI/silc_client_list_free
269  *
270  * SYNOPSIS
271  *
272  *    void silc_client_list_free(SilcClient client,
273  *                               SilcClientConnection conn,
274  *                               SilcDList client_list);
275  *
276  * DESCRIPTION
277  *
278  *    Free's client entry list that has been returned by various library
279  *    routines.
280  *
281  ***/
282 void silc_client_list_free(SilcClient client, SilcClientConnection conn,
283                            SilcDList client_list);
284
285 /****f* silcclient/SilcClientAPI/silc_client_get_clients
286  *
287  * SYNOPSIS
288  *
289  *    SilcUInt16 silc_client_get_clients(SilcClient client,
290  *                                       SilcClientConnection conn,
291  *                                       const char *nickname,
292  *                                       const char *server,
293  *                                       SilcGetClientCallback completion,
294  *                                       void *context);
295  *
296  * DESCRIPTION
297  *
298  *    Finds client entry or entries by the `nickname' and `server'. The
299  *    completion callback will be called when the client entries has been
300  *    found.  After the server returns the client information it is cached
301  *    and can be accesses locally at a later time.  The resolving is done
302  *    with IDENTIFY command.  The `server' may be NULL.  Returns 0 on
303  *    error and the command identifier used with the command otherwise.
304  *
305  * NOTES
306  *
307  *    This function is always asynchronous and resolves the client
308  *    information from the server.  Thus, if you already know the client
309  *    information then use the silc_client_get_client_by_id function to
310  *    get the client entry since this function may be very slow and should
311  *    be used only to initially get the client entries.
312  *
313  *    This function resolves only the relevant information (user's nickname
314  *    and username).  It does not resolve for example user's real name,
315  *    joined channel list or other information.  To resolve all the details
316  *    use silc_client_get_clients_whois instead.
317  *
318  ***/
319 SilcUInt16 silc_client_get_clients(SilcClient client,
320                                    SilcClientConnection conn,
321                                    const char *nickname,
322                                    const char *server,
323                                    SilcGetClientCallback completion,
324                                    void *context);
325
326 /****f* silcclient/SilcClientAPI/silc_client_get_clients_whois
327  *
328  * SYNOPSIS
329  *
330  *    SilcUInt16
331  *    silc_client_get_clients_whois(SilcClient client,
332  *                                  SilcClientConnection conn,
333  *                                  const char *nickname,
334  *                                  const char *server,
335  *                                  SilcBuffer attributes,
336  *                                  SilcGetClientCallback completion,
337  *                                  void *context);
338  *
339  * DESCRIPTION
340  *
341  *    Finds client entry or entries by the `nickname' and `server'. The
342  *    completion callback will be called when the client entries has been
343  *    found.  After the server returns the client information it is cached
344  *    and can be accesses locally at a later time.  The resolving is done
345  *    with WHOIS command.  The `server' may be NULL.  Returns 0 on error,
346  *    and the command identifier used with the command otherwise.
347  *
348  *    If the `attributes' is non-NULL then the buffer includes Requested
349  *    Attributes which can be used to fetch very detailed information
350  *    about the user. If it is NULL then only normal WHOIS query is
351  *    made (for more information about attributes see SilcAttribute).
352  *    Caller may create the `attributes' with silc_client_attributes_request
353  *    function.
354  *
355  * NOTES
356  *
357  *    The resolving is done with WHOIS command.  For this reason this
358  *    command may take a long time because it resolves detailed user
359  *    information.
360  *
361  ***/
362 SilcUInt16 silc_client_get_clients_whois(SilcClient client,
363                                          SilcClientConnection conn,
364                                          const char *nickname,
365                                          const char *server,
366                                          SilcBuffer attributes,
367                                          SilcGetClientCallback completion,
368                                          void *context);
369
370 /****f* silcclient/SilcClientAPI/silc_client_get_clients_local
371  *
372  * SYNOPSIS
373  *
374  *    SilcDList silc_client_get_clients_local(SilcClient client,
375  *                                            SilcClientConnection conn,
376  *                                            const char *nickname,
377  *                                            const char *format);
378  *
379  * DESCRIPTION
380  *
381  *    Same as silc_client_get_clients function but does not resolve anything
382  *    from the server.  This checks local cache and returns all matching
383  *    clients from the local cache.  If none was found this returns NULL.
384  *    The `nickname' is the real nickname of the client, and the `format'
385  *    is the formatted nickname to find exact match from multiple found
386  *    entries.  The format must be same as given in the SilcClientParams
387  *    structure to the client library.  If the `format' is NULL all found
388  *    clients by `nickname' are returned.  The caller must free the
389  *    returned list by silc_client_list_free function.
390  *
391  * NOTES
392  *
393  *    If the application stores any of the SilcClientEntry pointers from
394  *    the returned list it must reference it with silc_client_ref_client
395  *    function.
396  *
397  *    Application must free the returned list with silc_client_list_free
398  *    function.
399  *
400  ***/
401 SilcDList silc_client_get_clients_local(SilcClient client,
402                                         SilcClientConnection conn,
403                                         const char *nickname,
404                                         const char *format);
405
406 /****f* silcclient/SilcClientAPI/silc_client_get_clients_by_channel
407  *
408  * SYNOPSIS
409  *
410  *    void silc_client_get_clients_by_channel(SilcClient client,
411  *                                            SilcClientConnection conn,
412  *                                            SilcChannelEntry channel,
413  *                                            SilcGetClientCallback completion,
414  *                                            void *context);
415  *
416  * DESCRIPTION
417  *
418  *    Gets client entries by the channel indicated by `channel'. Thus,
419  *    it resovles the users currently on that channel. If all users are
420  *    already resolved this returns the users from the channel. If the
421  *    users are resolved only partially this resolves the complete user
422  *    information. If no users are resolved on this channel at all, this
423  *    calls USERS command to resolve all users on the channel. The `completion'
424  *    will be called after the entries are available. When server returns
425  *    the client information it will be cached and can be accessed locally
426  *    at a later time.
427  *
428  *    This function can be used for example in SILC_COMMAND_JOIN command
429  *    reply handling in application to resolve users on that channel.  It
430  *    also can be used after calling silc_client_get_channel_resolve to
431  *    resolve users on that channel.
432  *
433  * NOTES
434  *
435  *    The resolving is done with WHOIS command.  For this reason this
436  *    command may take a long time because it resolves detailed user
437  *    information.
438  *
439  ***/
440 void silc_client_get_clients_by_channel(SilcClient client,
441                                         SilcClientConnection conn,
442                                         SilcChannelEntry channel,
443                                         SilcGetClientCallback completion,
444                                         void *context);
445
446 /****f* silcclient/SilcClientAPI/silc_client_get_clients_by_list
447  *
448  * SYNOPSIS
449  *
450  *    SilcUInt16
451  *    silc_client_get_clients_by_list(SilcClient client,
452  *                                    SilcClientConnection conn,
453  *                                    SilcUInt32 list_count,
454  *                                    SilcBuffer client_id_list,
455  *                                    SilcGetClientCallback completion,
456  *                                    void *context);
457  *
458  * DESCRIPTION
459  *
460  *    Gets client entries by the list of client ID's `client_id_list'. This
461  *    always resolves those client ID's it doesn't know about from the server.
462  *    The `client_id_list' is a list of ID Payloads added one after other.
463  *    JOIN command reply and USERS command reply for example returns this sort
464  *    of list. The `completion' will be called after the entries are available.
465  *    When server returns the client information it will be cached and can be
466  *    accessed locally at a later time.  The resolving is done with WHOIS
467  *    command.
468  *
469  *    Returns command identifier for the resolving.  It can be used to attach
470  *    a pending command to it, if needed.  Returns 0 when no resolving was
471  *    done or wasn't needed (completion is called before this returns).
472  *
473  * NOTES
474  *
475  *    If even after resolving some Client ID in the `client_id_list' is
476  *    unknown it will be ignored and error is not returned.
477  *
478  ***/
479 SilcUInt16 silc_client_get_clients_by_list(SilcClient client,
480                                            SilcClientConnection conn,
481                                            SilcUInt32 list_count,
482                                            SilcBuffer client_id_list,
483                                            SilcGetClientCallback completion,
484                                            void *context);
485
486 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id
487  *
488  * SYNOPSIS
489  *
490  *    SilcClientEntry silc_client_get_client_by_id(SilcClient client,
491  *                                                 SilcClientConnection conn,
492  *                                                 SilcClientID *client_id);
493  *
494  * DESCRIPTION
495  *
496  *    Find client entry by the client's ID.  Returns the entry or NULL
497  *    if the entry was not found.  This checks the local cache and does
498  *    not resolve anything from server.
499  *
500  * NOTES
501  *
502  *    The returned SilcClientEntry has been referenced by the library and
503  *    the caller must call silc_client_unref_client after the entry is not
504  *    needed anymore.
505  *
506  ***/
507 SilcClientEntry silc_client_get_client_by_id(SilcClient client,
508                                              SilcClientConnection conn,
509                                              SilcClientID *client_id);
510
511 /****f* silcclient/SilcClientAPI/silc_client_get_client_by_id_resolve
512  *
513  * SYNOPSIS
514  *
515  *    SilcUInt16
516  *    silc_client_get_client_by_id_resolve(SilcClient client,
517  *                                         SilcClientConnection conn,
518  *                                         SilcClientID *client_id,
519  *                                         SilcBuffer attributes,
520  *                                         SilcGetClientCallback completion,
521  *                                         void *context);
522  *
523  * DESCRIPTION
524  *
525  *    Same as silc_client_get_client_by_id but will always resolve the
526  *    information from the server. Use this only if you know that you
527  *    do not have the entry and the only thing you know about the client
528  *    is its ID. When server returns the client information it will be
529  *    cache and can be accessed locally at a later time. The resolving
530  *    is done by sending WHOIS command.
531  *
532  *    Returns command identifier for the resolving.  It can be used to attach
533  *    a pending command to it, if needed.  Returns 0 on error.
534  *
535  *    If the `attributes' is non-NULL then the buffer includes Requested
536  *    Attributes which can be used to fetch very detailed information
537  *    about the user. If it is NULL then only normal WHOIS query is
538  *    made (for more information about attributes see SilcAttribute).
539  *    Caller may create the `attributes' with silc_client_attributes_request
540  *    function.
541  *
542  ***/
543 SilcUInt16
544 silc_client_get_client_by_id_resolve(SilcClient client,
545                                      SilcClientConnection conn,
546                                      SilcClientID *client_id,
547                                      SilcBuffer attributes,
548                                      SilcGetClientCallback completion,
549                                      void *context);
550
551 /* SilcChannelEntry routines */
552
553 /****f* silcclient/SilcClientAPI/SilcGetChannelCallback
554  *
555  * SYNOPSIS
556  *
557  *    typedef void (*SilcGetChannelCallback)(SilcClient client,
558  *                                           SilcClientConnection conn,
559  *                                           SilcStatus status,
560  *                                           SilcDList channels,
561  *                                           void *context);
562  *
563  * DESCRIPTION
564  *
565  *    Callback function given to various channel resolving functions.
566  *    The found entries are included in the `channels' list and each entry
567  *    in the list is SilcChannelEntry.  If `channels' is NULL then no such
568  *    channel exist in the network and the `status' will indicate the error.
569  *
570  * NOTES
571  *
572  *    If the application stores any of the SilcChannelEntry pointers from
573  *    the `channels' list it must reference it with silc_client_ref_channel
574  *    function.
575  *
576  *    Application must not free the returned `channels' list.
577  *
578  ***/
579 typedef void (*SilcGetChannelCallback)(SilcClient client,
580                                        SilcClientConnection conn,
581                                        SilcStatus status,
582                                        SilcDList channels,
583                                        void *context);
584
585 /****f* silcclient/SilcClientAPI/silc_client_lock_channel
586  *
587  * SYNOPSIS
588  *
589  *    void silc_client_lock_channel(SilcChannelEntry channel_entry);
590  *
591  * DESCRIPTION
592  *
593  *    Acquires lock for the channel entry indicate by `channel_entry'.  When
594  *    application wants to access `channel_entry' it must lock the entry
595  *    before reading any data from the `channel_entry'.  The lock must be
596  *    unlocked with silc_client_unlock_channel.
597  *
598  *    The entry must be unlocked before calling any Client Library API
599  *    functions where the entry is given as argument.
600  *
601  *    This function is not needed if application is not multithreaded
602  *
603  ***/
604 void silc_client_lock_channel(SilcChannelEntry channel_entry);
605
606 /****f* silcclient/SilcClientAPI/silc_client_unlock_channel
607  *
608  * SYNOPSIS
609  *
610  *    void silc_client_unlock_channel(SilcChannelEntry channel_entry);
611  *
612  * DESCRIPTION
613  *
614  *    Releases the lock acquired with silc_client_lock_channel.
615  *
616  ***/
617 void silc_client_unlock_channel(SilcChannelEntry channel_entry);
618
619 /****f* silcclient/SilcClientAPI/silc_client_ref_channel
620  *
621  * SYNOPSIS
622  *
623  *    SilcChannelEntry
624  *    silc_client_ref_channel(SilcClient client,
625  *                            SilcClientConnection conn,
626  *                            SilcChannelEntry channel_entry);
627  *
628  * DESCRIPTION
629  *
630  *    Takes a reference of the channel entry indicated by `channel_entry'
631  *    The reference must be released by calling silc_client_unref_channel
632  *    after it is not needed anymore.  Returns `channel_entry'.
633  *
634  ***/
635 SilcChannelEntry silc_client_ref_channel(SilcClient client, 
636                                          SilcClientConnection conn,
637                                          SilcChannelEntry channel_entry);
638
639 /****f* silcclient/SilcClientAPI/silc_client_unref_channel
640  *
641  * SYNOPSIS
642  *
643  *    void silc_client_unref_channel(SilcClient client,
644  *                                   SilcClientConnection conn,
645  *                                   SilcChannelEntry channel_entry);
646  *
647  * DESCRIPTION
648  *
649  *    Releases the channel entry reference indicated by `channel_entry'.
650  *
651  ***/
652 void silc_client_unref_channel(SilcClient client, SilcClientConnection conn,
653                                SilcChannelEntry channel_entry);
654
655 /****f* silcclient/SilcClientAPI/silc_client_list_free_channel
656  *
657  * SYNOPSIS
658  *
659  *    void silc_client_list_free_channel(SilcClient client,
660  *                                       SilcClientConnection conn,
661  *                                       SilcDList channel_list);
662  *
663  * DESCRIPTION
664  *
665  *    Free's channel entry list that has been returned by various library
666  *    routines.
667  *
668  ***/
669 void silc_client_list_free_channels(SilcClient client,
670                                     SilcClientConnection conn,
671                                     SilcDList channel_list);
672
673 /****f* silcclient/SilcClientAPI/silc_client_get_channel
674  *
675  * SYNOPSIS
676  *
677  *    SilcChannelEntry silc_client_get_channel(SilcClient client,
678  *                                             SilcClientConnection conn,
679  *                                             char *channel_name);
680  *
681  * DESCRIPTION
682  *
683  *    Finds entry for channel by the channel name. Returns the entry or NULL
684  *    if the entry was not found. It is found only if the client is joined
685  *    to the channel.  Use silc_client_get_channel_resolve or
686  *    silc_client_get_channel_by_id_resolve to resolve channel that client
687  *    is not joined.
688  *
689  * NOTES
690  *
691  *    The returned SilcChannelEntry has been referenced by the library and
692  *    the caller must call silc_client_unref_channel after the entry is not
693  *    needed anymore.
694  *
695  ***/
696 SilcChannelEntry silc_client_get_channel(SilcClient client,
697                                          SilcClientConnection conn,
698                                          char *channel_name);
699
700 /****f* silcclient/SilcClientAPI/silc_client_get_channel_resolve
701  *
702  * SYNOPSIS
703  *
704  *    void silc_client_get_channel_resolve(SilcClient client,
705  *                                         SilcClientConnection conn,
706  *                                         char *channel_name,
707  *                                         SilcGetChannelCallback completion,
708  *                                         void *context);
709  *
710  * DESCRIPTION
711  *
712  *    Resolves entry for channel by the channel name from the server.
713  *    The resolving is done with IDENTIFY command. Note that users on
714  *    the channel are not resolved at the same time. Use for example
715  *    silc_client_get_clients_by_channel to resolve all users on a channel.
716  *
717  ***/
718 void silc_client_get_channel_resolve(SilcClient client,
719                                      SilcClientConnection conn,
720                                      char *channel_name,
721                                      SilcGetChannelCallback completion,
722                                      void *context);
723
724 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id
725  *
726  * SYNOPSIS
727  *
728  *    SilcChannelEntry
729  *    silc_client_get_channel_by_id(SilcClient client,
730  *                                  SilcClientConnection conn,
731  *                                  SilcChannelID *channel_id);
732  *
733  * DESCRIPTION
734  *
735  *    Finds channel entry by the channel ID. Returns the entry or NULL
736  *    if the entry was not found.  This checks the local cache and does
737  *    not resolve anything from server.
738  *
739  * NOTES
740  *
741  *    The returned SilcChannelEntry has been referenced by the library and
742  *    the caller must call silc_client_unref_channel after the entry is not
743  *    needed anymore.
744  *
745  ***/
746 SilcChannelEntry silc_client_get_channel_by_id(SilcClient client,
747                                                SilcClientConnection conn,
748                                                SilcChannelID *channel_id);
749
750 /****f* silcclient/SilcClientAPI/silc_client_get_channel_by_id_resolve
751  *
752  * SYNOPSIS
753  *
754  *    SilcUInt16
755  *    silc_client_get_channel_by_id_resolve(SilcClient client,
756  *                                          SilcClientConnection conn,
757  *                                          SilcChannelID *channel_id,
758  *                                          SilcGetClientCallback completion,
759  *                                          void *context);
760  *
761  * DESCRIPTION
762  *
763  *    Resolves the channel information (its name mainly) from the server
764  *    by the `channel_id'. Use this only if you know that you do not have
765  *    the entry cached locally. The resolving is done with IDENTIFY command.
766  *
767  *    Returns command identifier for the resolving.  It can be used to attach
768  *    a pending command to it, if needed.  Returns 0 on error.
769  *
770  *    Note that users on the channel are not resolved at the same time.
771  *    Use for example silc_client_get_clients_by_channel to resolve all
772  *    users on a channel.
773  *
774  ***/
775 SilcUInt16
776 silc_client_get_channel_by_id_resolve(SilcClient client,
777                                       SilcClientConnection conn,
778                                       SilcChannelID *channel_id,
779                                       SilcGetChannelCallback completion,
780                                       void *context);
781
782 /* SilcServerEntry routines */
783
784 /****f* silcclient/SilcClientAPI/SilcGetServerCallback
785  *
786  * SYNOPSIS
787  *
788  *    typedef void (*SilcGetServerCallback)(SilcClient client,
789  *                                          SilcClientConnection conn,
790  *                                          SilcStatus status,
791  *                                          SilcDList servers,
792  *                                          void *context);
793  *
794  * DESCRIPTION
795  *
796  *    Callback function given to various server resolving functions.
797  *    The found entries are included in the `servers' list and each entry
798  *    in the list is SilcServerEntry.  If `server' is NULL then no such
799  *    server exist in the network and the `status' will indicate the error.
800  *
801  * NOTES
802  *
803  *    If the application stores any of the SilcServerEntry pointers from
804  *    the `server' list it must reference it with silc_client_ref_server
805  *    function.
806  *
807  *    Application must not free the returned `server' list.
808  *
809  ***/
810 typedef void (*SilcGetServerCallback)(SilcClient client,
811                                       SilcClientConnection conn,
812                                       SilcStatus status,
813                                       SilcDList servers,
814                                       void *context);
815
816 /****f* silcclient/SilcClientAPI/silc_client_lock_server
817  *
818  * SYNOPSIS
819  *
820  *    void silc_client_lock_server(SilcServerEntry server_entry);
821  *
822  * DESCRIPTION
823  *
824  *    Acquires lock for the server entry indicate by `server_entry'.  When
825  *    application wants to access `server_entry' it must lock the entry
826  *    before reading any data from the `server_entry'.  The lock must be
827  *    unlocked with silc_client_unlock_server.
828  *
829  *    The entry must be unlocked before calling any Client Library API
830  *    functions where the entry is given as argument.
831  *
832  *    This function is not needed if application is not multithreaded
833  *
834  ***/
835 void silc_client_lock_server(SilcServerEntry server_entry);
836
837 /****f* silcclient/SilcClientAPI/silc_client_unlock_server
838  *
839  * SYNOPSIS
840  *
841  *    void silc_client_unlock_server(SilcServerEntry server_entry);
842  *
843  * DESCRIPTION
844  *
845  *    Releases the lock acquired with silc_client_lock_server.
846  *
847  ***/
848 void silc_client_unlock_server(SilcServerEntry server_entry);
849
850 /****f* silcclient/SilcClientAPI/silc_client_ref_server
851  *
852  * SYNOPSIS
853  *
854  *    SilcServerEntry
855  *    silc_client_ref_server(SilcClient client,
856  *                           SilcClientConnection conn,
857  *                           SilcServerEntry server_entry);
858  *
859  * DESCRIPTION
860  *
861  *    Takes a reference of the server entry indicated by `server_entry'
862  *    The reference must be released by calling silc_client_unref_server
863  *    after it is not needed anymore.  Returns `server_entry'.
864  *
865  ***/
866 SilcServerEntry silc_client_ref_server(SilcClient client, 
867                                        SilcClientConnection conn,
868                                        SilcServerEntry server_entry);
869
870 /****f* silcclient/SilcClientAPI/silc_client_unref_server
871  *
872  * SYNOPSIS
873  *
874  *    void silc_client_unref_server(SilcClient client,
875  *                                  SilcClientConnection conn,
876  *                                  SilcServerEntry server_entry);
877  *
878  * DESCRIPTION
879  *
880  *    Releases the server entry reference indicated by `server_entry'.
881  *
882  ***/
883 void silc_client_unref_server(SilcClient client, SilcClientConnection conn,
884                               SilcServerEntry server_entry);
885
886 /****f* silcclient/SilcClientAPI/silc_client_list_free_server
887  *
888  * SYNOPSIS
889  *
890  *    void silc_client_list_free_server(SilcClient client,
891  *                                      SilcClientConnection conn,
892  *                                      SilcDList server_list);
893  *
894  * DESCRIPTION
895  *
896  *    Free's server entry list that has been returned by various library
897  *    routines.
898  *
899  ***/
900 void silc_client_list_free_servers(SilcClient client,
901                                    SilcClientConnection conn,
902                                    SilcDList server_list);
903
904 /****f* silcclient/SilcClientAPI/silc_client_get_server
905  *
906  * SYNOPSIS
907  *
908  *    SilcServerEntry silc_client_get_server(SilcClient client,
909  *                                           SilcClientConnection conn,
910  *                                           char *server_name)
911  *
912  * DESCRIPTION
913  *
914  *    Finds entry for server by the server name. Returns the entry or NULL
915  *    if the entry was not found.
916  *
917  ***/
918 SilcServerEntry silc_client_get_server(SilcClient client,
919                                        SilcClientConnection conn,
920                                        char *server_name);
921
922 /****f* silcclient/SilcClientAPI/silc_client_get_server_by_id
923  *
924  * SYNOPSIS
925  *
926  *    SilcServerEntry silc_client_get_server_by_id(SilcClient client,
927  *                                                 SilcClientConnection conn,
928  *                                                 SilcServerID *server_id);
929  *
930  * DESCRIPTION
931  *
932  *    Finds entry for server by the server ID. Returns the entry or NULL
933  *    if the entry was not found.
934  *
935  ***/
936 SilcServerEntry silc_client_get_server_by_id(SilcClient client,
937                                              SilcClientConnection conn,
938                                              SilcServerID *server_id);
939
940 /****f* silcclient/SilcClientAPI/silc_client_get_server_by_id_resolve
941  *
942  * SYNOPSIS
943  *
944  *    SilcUInt16
945  *    silc_client_get_server_by_id_resolve(SilcClient client,
946  *                                         SilcClientConnection conn,
947  *                                         SilcServerID *server_id,
948  *                                         SilcGetServerCallback completion,
949  *                                         void *context);
950  *
951  * DESCRIPTION
952  *
953  *    Resolves the server information by the `server_id'.  The resolved
954  *    server is returned into the `completion' callback.
955  *
956  *    Returns command identifier for the resolving.  It can be used to attach
957  *    a pending command to it, if needed.  Returns 0 on error.
958  *
959  ***/
960 SilcUInt16
961 silc_client_get_server_by_id_resolve(SilcClient client,
962                                      SilcClientConnection conn,
963                                      SilcServerID *server_id,
964                                      SilcGetServerCallback completion,
965                                      void *context);
966
967 #endif /* SILCCLIENT_ENTRY_H */