Added new SILC_STATUS_ERR_TIMEDOUT status type.
[silc.git] / lib / silcclient / client.c
index f44aefbdd5ce2c9717683b03b03ec8e8d8947246..f54fd256815f69a781a7e50cff38f44d00399ee8 100644 (file)
@@ -120,7 +120,7 @@ int silc_client_init(SilcClient client)
   /* Initialize the scheduler */
   client->schedule = 
     silc_schedule_init(client->internal->params->task_max ?
-                      client->internal->params->task_max : 200);
+                      client->internal->params->task_max : 200, client);
   if (!client->schedule)
     return FALSE;
 
@@ -248,7 +248,8 @@ void silc_client_del_connection(SilcClient client, SilcClientConnection conn)
       if (conn->pending_commands)
        silc_dlist_uninit(conn->pending_commands);
       silc_free(conn->remote_host);
-      silc_dlist_uninit(conn->ftp_sessions);
+      if (conn->ftp_sessions)
+        silc_dlist_uninit(conn->ftp_sessions);
       silc_free(conn);
 
       client->internal->conns[i] = NULL;
@@ -1618,8 +1619,6 @@ void silc_client_receive_new_id(SilcClient client,
   conn->local_entry->nickname = conn->nickname;
   if (!conn->local_entry->username)
     conn->local_entry->username = strdup(client->username);
-  if (!conn->local_entry->hostname)
-    conn->local_entry->hostname = strdup(client->hostname);
   if (!conn->local_entry->server)
     conn->local_entry->server = strdup(conn->remote_host);
   conn->local_entry->id = conn->local_id;
@@ -1635,9 +1634,19 @@ void silc_client_receive_new_id(SilcClient client,
                   (void *)conn->local_entry, 0, NULL);
 
   if (connecting) {
-    if (!conn->params.detach_data) {
-      SilcBuffer sidp;
+    SilcBuffer sidp;
 
+    /* Issue IDENTIFY command for itself to get resolved hostname
+       correctly from server. */
+    silc_client_command_register(client, SILC_COMMAND_IDENTIFY, NULL, NULL,
+                                silc_client_command_reply_identify_i, 0, 
+                                ++conn->cmd_ident);
+    sidp = silc_id_payload_encode(conn->local_entry->id, SILC_ID_CLIENT);
+    silc_client_command_send(client, conn, SILC_COMMAND_IDENTIFY,
+                            conn->cmd_ident, 1, 5, sidp->data, sidp->len);
+    silc_buffer_free(sidp);
+
+    if (!conn->params.detach_data) {
       /* Send NICK command if the nickname was set by the application (and is
         not same as the username). Send this with little timeout. */
       if (client->nickname && strcmp(client->nickname, client->username))