updates.
[silc.git] / lib / silcclient / idlist.c
index 487b739c55b5e426bff79d328cb6aa3da5611b0e..ea45f108a4582cf3a9a0d394cb5eecb43c5bacce 100644 (file)
@@ -93,17 +93,19 @@ void silc_client_get_clients(SilcClient client,
   snprintf(ident, sizeof(ident), "IDENTIFY %s", nickname);
   silc_parse_command_line(ident, &ctx->argv, &ctx->argv_lens, 
                          &ctx->argv_types, &ctx->argc, 2);
-  ctx->command->cb(ctx);
-      
-  i->cmd = ctx;
+
+  i->cmd = silc_client_command_dup(ctx);
   i->nickname = nickname ? strdup(nickname) : NULL;
   i->server = server ? strdup(server) : NULL;
   i->completion = completion;
   i->context = context;
 
+  /* Call the command */
+  ctx->command->cb(ctx);
+
   /* Add pending callback */
   silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY, 
-                             ++conn->cmd_ident, 
+                             conn->cmd_ident, 
                              silc_client_get_client_destructor,
                              silc_client_command_get_client_callback, 
                              (void *)i);
@@ -124,8 +126,7 @@ SilcClientEntry *silc_client_get_clients_local(SilcClient client,
   int i = 0;
 
   /* Find ID from cache */
-  if (!silc_idcache_find_by_name(conn->client_cache, nickname, 
-                                &list))
+  if (!silc_idcache_find_by_name(conn->client_cache, nickname, &list))
     return NULL;
 
   if (!silc_idcache_list_count(list)) {
@@ -357,8 +358,7 @@ SilcClientEntry silc_idlist_get_client(SilcClient client,
   SilcClientEntry entry = NULL;
 
   /* Find ID from cache */
-  if (!silc_idcache_find_by_name(conn->client_cache, nickname, 
-                                &list)) {
+  if (!silc_idcache_find_by_name(conn->client_cache, nickname, &list)) {
   identify:
 
     if (query) {
@@ -517,6 +517,25 @@ void silc_client_get_client_by_id_resolve(SilcClient client,
                              (void *)i);
 }
 
+/* Removes client from the cache by the client entry. */
+
+bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
+                           SilcClientEntry client_entry)
+{
+  return silc_idcache_del_by_context(conn->client_cache, client_entry);
+}
+
+/* Removes client from the cache by the client ID. */
+
+bool silc_client_del_client_by_id(SilcClient client, 
+                                 SilcClientConnection conn,
+                                 SilcClientID *client_id)
+{
+  return silc_idcache_del_by_id_ext(conn->client_cache, (void *)client_id, 
+                                   NULL, NULL, 
+                                   silc_hash_client_id_compare, NULL);
+}
+
 /* Finds entry for channel by the channel name. Returns the entry or NULL
    if the entry was not found. It is found only if the client is joined
    to the channel. */