Moved the SilcClient and SilcClientConnection to the public
[silc.git] / lib / silcclient / client_notify.c
index bd3edd3ff3f9638411756962e20637c7058c1cfc..4517aab10517b67e5332bdecc675a3195ad89637 100644 (file)
@@ -428,7 +428,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_context(conn->client_cache, client_entry);
+    silc_idcache_del_by_context(conn->internal->client_cache, client_entry);
 
     /* Get signoff message */
     tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
@@ -615,10 +615,11 @@ void silc_client_notify_by_server(SilcClient client,
 
       if (tmp_nick && !strcmp(tmp, tmp_nick)) {
        /* Nickname didn't change. Update only the ID */
-       silc_idcache_del_by_context(conn->client_cache, client_entry);
+       silc_idcache_del_by_context(conn->internal->client_cache,
+                                   client_entry);
        silc_free(client_entry->id);
        client_entry->id = silc_id_dup(client_id, SILC_ID_CLIENT);
-       silc_idcache_add(conn->client_cache, strdup(tmp),
+       silc_idcache_add(conn->internal->client_cache, strdup(tmp),
                         client_entry->id, client_entry, 0, NULL);
 
        /* Notify application */
@@ -673,7 +674,7 @@ void silc_client_notify_by_server(SilcClient client,
     }
 
     /* Remove the old from cache */
-    silc_idcache_del_by_context(conn->client_cache, client_entry);
+    silc_idcache_del_by_context(conn->internal->client_cache, client_entry);
     
     /* Replace old ID entry with new one on all channels. */
     silc_client_replace_from_channels(client, conn, client_entry,
@@ -724,6 +725,28 @@ void silc_client_notify_by_server(SilcClient client,
                                             SILC_ID_CLIENT, client_id);
        goto out;
       }
+
+      if (!client_entry->nickname) {
+       if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING) {
+         /* Attach to existing resolving */
+         SilcClientNotifyResolve res = silc_calloc(1, sizeof(*res));
+         res->packet = silc_packet_context_dup(packet);
+         res->context = client;
+         res->sock = silc_socket_dup(conn->sock);
+         silc_client_command_pending(conn, SILC_COMMAND_NONE, 
+                                     client_entry->resolve_cmd_ident,
+                                     silc_client_notify_by_server_pending,
+                                     res);
+         goto out;
+       }
+
+       /* Do new resolving */
+       silc_client_channel_set_wait(client, conn, channel,
+                                    conn->cmd_ident + 1);
+       silc_client_notify_by_server_resolve(client, conn, packet, 
+                                            SILC_ID_CLIENT, client_id);
+       goto out;
+      }
     } else if (id_type == SILC_ID_SERVER) {
       /* Find Server entry */
       server_id = id;
@@ -848,6 +871,28 @@ void silc_client_notify_by_server(SilcClient client,
                                             SILC_ID_CLIENT, client_id);
        goto out;
       }
+
+      if (!client_entry->nickname) {
+       if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING) {
+         /* Attach to existing resolving */
+         SilcClientNotifyResolve res = silc_calloc(1, sizeof(*res));
+         res->packet = silc_packet_context_dup(packet);
+         res->context = client;
+         res->sock = silc_socket_dup(conn->sock);
+         silc_client_command_pending(conn, SILC_COMMAND_NONE, 
+                                     client_entry->resolve_cmd_ident,
+                                     silc_client_notify_by_server_pending,
+                                     res);
+         goto out;
+       }
+
+       /* Do new resolving */
+       silc_client_channel_set_wait(client, conn, channel,
+                                    conn->cmd_ident + 1);
+       silc_client_notify_by_server_resolve(client, conn, packet, 
+                                            SILC_ID_CLIENT, client_id);
+       goto out;
+      }
     } else if (id_type == SILC_ID_SERVER) {
       /* Find Server entry */
       server_id = id;