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