-/* Finds entry for client by the client's ID. Returns the entry or NULL
- if the entry was not found. */
-
-SilcClientEntry silc_client_get_client_by_id(SilcClient client,
- SilcClientConnection conn,
- SilcClientID *client_id)
-{
- SilcIDCacheEntry id_cache;
-
- assert(client && conn);
- if (!client_id)
- return NULL;
-
- SILC_LOG_DEBUG(("Finding client by ID (%s)",
- silc_id_render(client_id, SILC_ID_CLIENT)));
-
- /* Find ID from cache */
- if (!silc_idcache_find_by_id_one_ext(conn->internal->client_cache,
- (void *)client_id, NULL, NULL,
- silc_hash_client_id_compare, NULL,
- &id_cache))
- return NULL;
-
- SILC_LOG_DEBUG(("Found"));
-
- return (SilcClientEntry)id_cache->context;
-}
-
-typedef struct {
- SilcClient client;
- SilcClientConnection conn;
- SilcClientID *client_id;
- SilcGetClientCallback completion;
- void *context;
-} *GetClientByIDInternal;
-
-SILC_CLIENT_CMD_FUNC(get_client_by_id_callback)
-{
- GetClientByIDInternal i = (GetClientByIDInternal)context;
- SilcClientEntry entry;
-
- /* Get the client */
- entry = silc_client_get_client_by_id(i->client, i->conn, i->client_id);
- if (entry) {
- if (i->completion)
- i->completion(i->client, i->conn, &entry, 1, i->context);
- } else {
- if (i->completion)
- i->completion(i->client, i->conn, NULL, 0, i->context);
- }
-
- silc_free(i->client_id);
- silc_free(i);
-}
-
-/* Same as above but will always resolve the information from the server.
- Use this only if you know that you don't have the entry and the only
- thing you know about the client is its ID. */
-
-void silc_client_get_client_by_id_resolve(SilcClient client,
- SilcClientConnection conn,
- SilcClientID *client_id,
- SilcBuffer attributes,
- SilcGetClientCallback completion,
- void *context)
-{
- SilcBuffer idp;
- GetClientByIDInternal i = silc_calloc(1, sizeof(*i));
-
- assert(client && conn && client_id);
-
- SILC_LOG_DEBUG(("Start"));
-
- i->client = client;
- i->conn = conn;
- i->client_id = silc_id_dup(client_id, SILC_ID_CLIENT);
- i->completion = completion;
- i->context = context;
-
- /* Register our own command reply for this command */
- silc_client_command_register(client, SILC_COMMAND_WHOIS, NULL, NULL,
- silc_client_command_reply_whois_i, 0,
- ++conn->cmd_ident);
-
- /* Send the command */
- idp = silc_id_payload_encode(client_id, SILC_ID_CLIENT);
- silc_client_command_send(client, conn, SILC_COMMAND_WHOIS, conn->cmd_ident,
- 2, 3, attributes ? attributes->data : NULL,
- attributes ? attributes->len : 0,
- 4, idp->data, idp->len);
- silc_buffer_free(idp);
-
- /* Add pending callback */
- silc_client_command_pending(conn, SILC_COMMAND_WHOIS, conn->cmd_ident,
- silc_client_command_get_client_by_id_callback,
- (void *)i);
-}
-
-
-/******************************************************************************
-
- Client, Channel and Server entry manipulation
-
-******************************************************************************/