updates.
[silc.git] / lib / silcclient / client_prvmsg.c
index d9f2e65d4d02e8bc5ad09b91e92833e382ce00a8..331e1d6990cba16b376e7c500f3b4b8a5f187042 100644 (file)
@@ -147,7 +147,7 @@ void silc_client_private_message(SilcClient client,
 {
   SilcClientConnection conn = (SilcClientConnection)sock->user_data;
   SilcPrivateMessagePayload payload = NULL;
-  SilcIDCacheEntry id_cache;
+  SilcIDCacheEntry id_cache = NULL;
   SilcClientID *remote_id = NULL;
   SilcClientEntry remote_client;
   SilcMessageFlags flags;
@@ -164,7 +164,18 @@ void silc_client_private_message(SilcClient client,
   if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)remote_id, 
                                       NULL, NULL, 
                                       silc_hash_client_id_compare, NULL,
-                                      &id_cache)) {
+                                      &id_cache) || 
+      ((SilcClientEntry)id_cache->context)->nickname == NULL) {
+
+    if (id_cache && id_cache->context) {
+      remote_client = (SilcClientEntry)id_cache->context;
+      if (remote_client->status & SILC_CLIENT_STATUS_RESOLVING) {
+       remote_client->status &= ~SILC_CLIENT_STATUS_RESOLVING;
+       goto out;
+      }
+      remote_client->status |= SILC_CLIENT_STATUS_RESOLVING;
+    }
+
     /* Resolve the client info */
     silc_client_get_client_by_id_resolve(client, conn, remote_id,
                                         silc_client_private_message_cb,
@@ -175,7 +186,8 @@ void silc_client_private_message(SilcClient client,
   remote_client = (SilcClientEntry)id_cache->context;
 
   /* Parse the payload and decrypt it also if private message key is set */
-  payload = silc_private_message_payload_parse(packet->buffer,
+  payload = silc_private_message_payload_parse(packet->buffer->data,
+                                              packet->buffer->len,
                                               remote_client->receive_key);
   if (!payload) {
     silc_free(remote_id);
@@ -207,8 +219,7 @@ void silc_client_private_message(SilcClient client,
  out:
   if (payload)
     silc_private_message_payload_free(payload);
-  if (remote_id)
-    silc_free(remote_id);
+  silc_free(remote_id);
 }
 
 /* Function that actually employes the received private message key */