updates.
[silc.git] / lib / silcclient / client.c
index b931b51c7a2b89474d47c60c1ee6a9a66dda4ac1..4dd828f89bce4d088871d93af1755568c0b59c2b 100644 (file)
@@ -54,6 +54,9 @@ SilcClient silc_client_alloc(SilcClientOperations *ops, void *application)
 void silc_client_free(SilcClient client)
 {
   if (client) {
+    if (client->rng)
+      silc_rng_free(client->rng);
+
     silc_free(client);
   }
 }
@@ -76,7 +79,7 @@ int silc_client_init(SilcClient client)
   /* Initialize random number generator */
   client->rng = silc_rng_alloc();
   silc_rng_init(client->rng);
-  silc_math_primegen_init(); /* XXX */
+  silc_rng_global_init(client->rng);
 
   /* Register protocols */
   silc_client_protocols_register();
@@ -271,6 +274,7 @@ int silc_client_start_key_exchange(SilcClient client,
 
   conn->nickname = strdup(client->username);
   conn->sock->hostname = conn->remote_host;
+  conn->sock->ip = strdup(conn->remote_host);
   conn->sock->port = conn->remote_port;
 
   /* Allocate internal Key Exchange context. This is sent to the
@@ -412,7 +416,7 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_second)
                                    &proto_ctx->auth_data_len))
     {
       /* XXX do AUTH_REQUEST resolcing with server */
-      proto_ctx->auth_meth = SILC_PROTOCOL_CONN_AUTH_NONE;
+      proto_ctx->auth_meth = SILC_AUTH_NONE;
     }
 
   /* Free old protocol as it is finished now */
@@ -599,8 +603,7 @@ SILC_TASK_CALLBACK(silc_client_packet_process)
        return;
       }
       
-      client->ops->say(client, conn, "Connection closed: premature EOF");
-      SILC_LOG_DEBUG(("Premature EOF from connection %d", sock->sock));
+      SILC_LOG_DEBUG(("EOF from connection %d", sock->sock));
       client->ops->disconnect(client, conn);
       silc_client_close_connection(client, sock);
       return;
@@ -1180,8 +1183,7 @@ void silc_client_close_connection(SilcClient client,
   silc_net_close_connection(sock->sock);
 
   client->ops->say(client, sock->user_data,
-                  "Closed connection to host %s", sock->hostname ?
-                  sock->hostname : sock->ip);
+                  "Closed connection to host %s", sock->hostname);
 
   /* Free everything */
   if (sock->user_data) {
@@ -1423,11 +1425,16 @@ void silc_client_notify_by_server(SilcClient client,
       goto out;
     }
 
-    /* Get channel entry */
-    channel_id = silc_id_str2id(packet->dst_id, packet->dst_id_len,
-                               SILC_ID_CHANNEL);
+    /* Get Channel ID */
+    tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
+    if (!tmp)
+      goto out;
+
+    channel_id = silc_id_payload_parse_id(tmp, tmp_len);
     if (!channel_id)
       goto out;
+
+    /* Get channel entry */
     if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)channel_id,
                                     SILC_ID_CHANNEL, &id_cache))
       break;
@@ -1523,8 +1530,13 @@ void silc_client_notify_by_server(SilcClient client,
     silc_idcache_del_by_id(conn->client_cache, SILC_ID_CLIENT, 
                           client_entry->id);
 
+    /* Get signoff message */
+    tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
+    if (tmp_len > 128)
+      tmp = NULL;
+
     /* Notify application */
-    client->ops->notify(client, conn, type, client_entry);
+    client->ops->notify(client, conn, type, client_entry, tmp);
 
     /* Free data */
     if (client_entry->nickname)