updates.
[silc.git] / apps / silcd / command_reply.c
index eec802895db6798bc068583f0ec960f86613af60..4717e3b77a440fa071f208cd6882a4fd84dc432d 100644 (file)
@@ -115,7 +115,7 @@ void silc_server_command_reply_process(SilcServer server,
 void silc_server_command_reply_free(SilcServerCommandReplyContext cmd)
 {
   if (cmd) {
-    silc_command_free_payload(cmd->payload);
+    silc_command_payload_free(cmd->payload);
     if (cmd->sock)
       silc_socket_free(cmd->sock); /* Decrease the reference counter */
     silc_free(cmd);
@@ -132,7 +132,6 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
   char *nickname, *username, *realname, *servername = NULL;
   SilcClientID *client_id;
   SilcClientEntry client;
-  SilcIDCacheEntry cache = NULL;
   char global = FALSE;
   char *nick;
   uint32 mode = 0, len, id_len;
@@ -159,11 +158,10 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
 
   /* Check if we have this client cached already. */
 
-  client = silc_idlist_find_client_by_id(server->local_list, client_id,
-                                        &cache);
+  client = silc_idlist_find_client_by_id(server->local_list, client_id, NULL);
   if (!client) {
-    client = silc_idlist_find_client_by_id(server->global_list, 
-                                          client_id, &cache);
+    client = silc_idlist_find_client_by_id(server->global_list, client_id, 
+                                          NULL);
     global = TRUE;
   }
 
@@ -187,7 +185,7 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
     /* We don't have that client anywhere, add it. The client is added
        to global list since server didn't have it in the lists so it must be 
        global. */
-    client = silc_idlist_add_client(server->global_list, nick, strlen(nick),
+    client = silc_idlist_add_client(server->global_list, nick, 
                                    strdup(username), 
                                    strdup(realname), client_id, 
                                    cmd->sock->user_data, NULL);
@@ -226,13 +224,12 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
     client->mode = mode;
     client->servername = servername;
 
-    if (cache) {
-      cache->data = nick;
-      cache->data_len = strlen(nick);
-      silc_idcache_sort_by_data(global ? server->global_list->clients : 
-                               server->local_list->clients);
-    }
-
+    /* Remove the old cache entry and create a new one */
+    silc_idcache_del_by_context(global ? server->global_list->clients :
+                               server->local_list->clients, client);
+    silc_idcache_add(global ? server->global_list->clients :
+                    server->local_list->clients, nick, client->id, 
+                    client, FALSE);
     silc_free(client_id);
   }
 
@@ -325,7 +322,7 @@ silc_server_command_reply_whowas_save(SilcServerCommandReplyContext cmd)
     /* We don't have that client anywhere, add it. The client is added
        to global list since server didn't have it in the lists so it must be 
        global. */
-    client = silc_idlist_add_client(server->global_list, nick, strlen(nick),
+    client = silc_idlist_add_client(server->global_list, nick,
                                    strdup(username), strdup(realname), 
                                    silc_id_dup(client_id, SILC_ID_CLIENT), 
                                    cmd->sock->user_data, NULL);
@@ -360,12 +357,12 @@ silc_server_command_reply_whowas_save(SilcServerCommandReplyContext cmd)
     client->username = strdup(username);
     client->servername = servername;
 
-    if (cache) {
-      cache->data = nick;
-      cache->data_len = strlen(nick);
-      silc_idcache_sort_by_data(global ? server->global_list->clients : 
-                               server->local_list->clients);
-    }
+    /* Remove the old cache entry and create a new one */
+    silc_idcache_del_by_context(global ? server->global_list->clients :
+                               server->local_list->clients, client);
+    silc_idcache_add(global ? server->global_list->clients :
+                    server->local_list->clients, nick, client->id, 
+                    client, FALSE);
   }
 
   silc_free(client_id);
@@ -410,7 +407,6 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
   char *nickname, *username;
   SilcClientID *client_id;
   SilcClientEntry client;
-  SilcIDCacheEntry cache = NULL;
   char global = FALSE;
   char *nick = NULL;
 
@@ -426,11 +422,10 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
 
   /* Check if we have this client cached already. */
 
-  client = silc_idlist_find_client_by_id(server->local_list, client_id,
-                                        &cache);
+  client = silc_idlist_find_client_by_id(server->local_list, client_id, NULL);
   if (!client) {
-    client = silc_idlist_find_client_by_id(server->global_list, 
-                                          client_id, &cache);
+    client = silc_idlist_find_client_by_id(server->global_list, client_id,
+                                          NULL);
     global = TRUE;
   }
 
@@ -454,7 +449,7 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
     /* We don't have that client anywhere, add it. The client is added
        to global list since server didn't have it in the lists so it must be 
        global. */
-    client = silc_idlist_add_client(server->global_list, nick, strlen(nick),
+    client = silc_idlist_add_client(server->global_list, nick, 
                                    username ? strdup(username) : NULL, NULL,
                                    client_id, cmd->sock->user_data, NULL);
     client->data.registered = TRUE;
@@ -485,13 +480,14 @@ silc_server_command_reply_identify_save(SilcServerCommandReplyContext cmd)
       client->username = strdup(username);
     }
 
-    if (nickname && cache) {
-      cache->data = nick;
-      cache->data_len = strlen(nick);
-      silc_idcache_sort_by_data(global ? server->global_list->clients : 
-                               server->local_list->clients);
+    /* Remove the old cache entry and create a new one */
+    if (nickname) {
+      silc_idcache_del_by_context(global ? server->global_list->clients :
+                                 server->local_list->clients, client);
+      silc_idcache_add(global ? server->global_list->clients :
+                      server->local_list->clients, nick, client->id, 
+                      client, FALSE);
     }
-
     silc_free(client_id);
   }