updates.
[silc.git] / lib / silcclient / client.c
index 2619df2671b66c5d6e6b82c61bb2948f21dbcd41..7b0f1ca70531de22b38d2b7add43fda0508c9b6e 100644 (file)
@@ -1479,16 +1479,28 @@ SILC_TASK_CALLBACK(silc_client_disconnected_by_server_later)
 
 void silc_client_disconnected_by_server(SilcClient client,
                                        SilcSocketConnection sock,
-                                       SilcBuffer message)
+                                       SilcBuffer packet)
 {
-  char *msg;
+  SilcStatus status;
+  char *message = NULL;
 
   SILC_LOG_DEBUG(("Server disconnected us, sock %d", sock->sock));
 
-  msg = silc_memdup(message->data, message->len);
+  if (packet->len < 1)
+    return;
+
+  status = (SilcStatus)packet->data[0];
+
+  if (packet->len > 1 &&
+      silc_utf8_valid(packet->data + 1, packet->len - 1))
+    message = silc_memdup(packet->data, packet->len);
+
   client->internal->ops->say(client, sock->user_data, 
-                            SILC_CLIENT_MESSAGE_AUDIT, msg);
-  silc_free(msg);
+                            SILC_CLIENT_MESSAGE_AUDIT, 
+                            "Server closed connection: %s (%d) %s",
+                            silc_get_status_message(status), status,
+                            message ? message : "");
+  silc_free(message);
 
   SILC_SET_DISCONNECTED(sock);
 
@@ -1543,15 +1555,17 @@ static void silc_client_resume_session_cb(SilcClient client,
                                 SILC_CLIENT_CONN_SUCCESS_RESUME :
                                 SILC_CLIENT_CONN_ERROR);
 
-  /* Issue INFO command to fetch the real server name and server
-     information and other stuff. */
-  silc_client_command_register(client, SILC_COMMAND_INFO, NULL, NULL,
-                              silc_client_command_reply_info_i, 0, 
-                              ++conn->cmd_ident);
-  sidp = silc_id_payload_encode(conn->remote_id, SILC_ID_SERVER);
-  silc_client_command_send(client, conn, SILC_COMMAND_INFO,
-                          conn->cmd_ident, 1, 2, sidp->data, sidp->len);
-  silc_buffer_free(sidp);
+  if (success) {
+    /* Issue INFO command to fetch the real server name and server
+       information and other stuff. */
+    silc_client_command_register(client, SILC_COMMAND_INFO, NULL, NULL,
+                                silc_client_command_reply_info_i, 0, 
+                                ++conn->cmd_ident);
+    sidp = silc_id_payload_encode(conn->remote_id, SILC_ID_SERVER);
+    silc_client_command_send(client, conn, SILC_COMMAND_INFO,
+                            conn->cmd_ident, 1, 2, sidp->data, sidp->len);
+    silc_buffer_free(sidp);
+  }
 }
 
 /* Processes the received new Client ID from server. Old Client ID is