updates.
[silc.git] / lib / silcclient / client_notify.c
index 14b3b591f053c83c7a190fcf3155b3f84fb399a9..ce8204e2b6065f8beff0ef2837de7bec64b35706 100644 (file)
@@ -33,6 +33,7 @@ static void silc_client_notify_by_server_pending(void *context)
 {
   SilcPacketContext *p = (SilcPacketContext *)context;
   silc_client_notify_by_server(p->context, p->sock, p);
+  silc_socket_free(p->sock);
 }
 
 /* Destructor for the pending command callback */
@@ -53,7 +54,7 @@ static void silc_client_notify_by_server_resolve(SilcClient client,
   SilcBuffer idp = silc_id_payload_encode(client_id, SILC_ID_CLIENT);
 
   p->context = (void *)client;
-  p->sock = conn->sock;
+  p->sock = silc_socket_dup(conn->sock);
 
   silc_client_send_command(client, conn, SILC_COMMAND_WHOIS, ++conn->cmd_ident,
                           1, 3, idp->data, idp->len);
@@ -84,7 +85,7 @@ void silc_client_notify_by_server(SilcClient client,
   SilcChannelUser chu;
   SilcIDCacheEntry id_cache = NULL;
   unsigned char *tmp;
-  unsigned int tmp_len, mode;
+  uint32 tmp_len, mode;
 
   payload = silc_notify_payload_parse(buffer);
   if (!payload)
@@ -120,7 +121,7 @@ void silc_client_notify_by_server(SilcClient client,
     /* Get the channel entry */
     channel = NULL;
     if (silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
-                                    SILC_ID_CHANNEL, &id_cache))
+                               &id_cache))
       channel = (SilcChannelEntry)id_cache->context;
 
     /* Get sender Client ID */
@@ -187,7 +188,7 @@ void silc_client_notify_by_server(SilcClient client,
 
     /* Get channel entry */
     if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
-                                    SILC_ID_CHANNEL, &id_cache))
+                                &id_cache))
       break;
 
     channel = (SilcChannelEntry)id_cache->context;
@@ -235,7 +236,7 @@ void silc_client_notify_by_server(SilcClient client,
     if (!channel_id)
       goto out;
     if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
-                                    SILC_ID_CHANNEL, &id_cache))
+                                &id_cache))
       break;
 
     channel = (SilcChannelEntry)id_cache->context;
@@ -280,8 +281,7 @@ void silc_client_notify_by_server(SilcClient client,
     silc_client_remove_from_channels(client, conn, client_entry);
 
     /* Remove from cache */
-    silc_idcache_del_by_id(conn->client_cache, SILC_ID_CLIENT, 
-                          client_entry->id);
+    silc_idcache_del_by_context(conn->client_cache, client_entry);
 
     /* Get signoff message */
     tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
@@ -335,7 +335,7 @@ void silc_client_notify_by_server(SilcClient client,
     if (!channel_id)
       goto out;
     if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
-                                    SILC_ID_CHANNEL, &id_cache))
+                                &id_cache))
       break;
 
     channel = (SilcChannelEntry)id_cache->context;
@@ -364,7 +364,7 @@ void silc_client_notify_by_server(SilcClient client,
       goto out;
 
     /* Ignore my ID */
-    if (!SILC_ID_CLIENT_COMPARE(client_id, conn->local_id))
+    if (SILC_ID_CLIENT_COMPARE(client_id, conn->local_id))
       break;
 
     /* Find old Client entry */
@@ -390,8 +390,7 @@ void silc_client_notify_by_server(SilcClient client,
     }
 
     /* Remove the old from cache */
-    silc_idcache_del_by_id(conn->client_cache, SILC_ID_CLIENT, 
-                          client_entry->id);
+    silc_idcache_del_by_context(conn->client_cache, client_entry);
 
     /* Replace old ID entry with new one on all channels. */
     silc_client_replace_from_channels(client, conn, client_entry,
@@ -460,7 +459,7 @@ void silc_client_notify_by_server(SilcClient client,
     if (!channel_id)
       goto out;
     if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
-                                    SILC_ID_CHANNEL, &id_cache))
+                                &id_cache))
       break;
 
     channel = (SilcChannelEntry)id_cache->context;
@@ -541,7 +540,7 @@ void silc_client_notify_by_server(SilcClient client,
     if (!channel_id)
       goto out;
     if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
-                                    SILC_ID_CHANNEL, &id_cache))
+                                &id_cache))
       break;
 
     channel = (SilcChannelEntry)id_cache->context;
@@ -592,7 +591,7 @@ void silc_client_notify_by_server(SilcClient client,
     
     /* Get the channel entry */
     if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
-                                    SILC_ID_CHANNEL, &id_cache))
+                                &id_cache))
       break;
 
     channel = (SilcChannelEntry)id_cache->context;
@@ -639,7 +638,7 @@ void silc_client_notify_by_server(SilcClient client,
     if (!channel_id)
       goto out;
     if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
-                                    SILC_ID_CHANNEL, &id_cache))
+                                &id_cache))
       break;
 
     channel = (SilcChannelEntry)id_cache->context;
@@ -656,8 +655,7 @@ void silc_client_notify_by_server(SilcClient client,
     if (client_entry == conn->local_entry) {
       if (conn->current_channel == channel)
        conn->current_channel = NULL;
-      silc_idcache_del_by_id(conn->channel_cache, 
-                            SILC_ID_CHANNEL, channel->id);
+      silc_idcache_del_by_id(conn->channel_cache, channel->id);
       silc_free(channel->channel_name);
       silc_free(channel->id);
       silc_free(channel->key);
@@ -694,8 +692,7 @@ void silc_client_notify_by_server(SilcClient client,
     if (client_entry != conn->local_entry) {
       /* Remove client from all channels */
       silc_client_remove_from_channels(client, conn, client_entry);
-      silc_idcache_del_by_id(conn->client_cache, SILC_ID_CLIENT, 
-                            client_entry->id);
+      silc_idcache_del_by_context(conn->client_cache, client_entry);
       if (client_entry->nickname)
        silc_free(client_entry->nickname);
       if (client_entry->server)
@@ -718,7 +715,7 @@ void silc_client_notify_by_server(SilcClient client,
        * from channels as they quit as well.
        */
       SilcClientEntry *clients = NULL;
-      unsigned int clients_count = 0;
+      uint32 clients_count = 0;
       int i;
 
       for (i = 1; i < silc_argument_get_arg_num(args); i++) {
@@ -754,8 +751,7 @@ void silc_client_notify_by_server(SilcClient client,
          continue;
 
        silc_client_remove_from_channels(client, conn, client_entry);
-       silc_idcache_del_by_id(conn->client_cache, SILC_ID_CLIENT, 
-                              client_entry->id);
+       silc_idcache_del_by_context(conn->client_cache, client_entry);
        if (client_entry->nickname)
          silc_free(client_entry->nickname);
        if (client_entry->server)