Added Requested Attributes sending and receiving support to
[silc.git] / lib / silcclient / client_prvmsg.c
index a6e09917b0853f1f4e2183fb2c713a10f59e2645..dca5d000d1e93eb7843686fa18b5681a173806ef 100644 (file)
@@ -150,6 +150,7 @@ void silc_client_private_message(SilcClient client,
   SilcMessageFlags flags;
   unsigned char *message;
   SilcUInt32 message_len;
+  SilcCipher cipher = NULL;
 
   if (packet->src_id_type != SILC_ID_CLIENT)
     goto out;
@@ -168,19 +169,25 @@ void silc_client_private_message(SilcClient client,
        goto out;
       }
       remote_client->status |= SILC_CLIENT_STATUS_RESOLVING;
+      remote_client->resolve_cmd_ident = conn->cmd_ident + 1;
     }
 
     /* Resolve the client info */
-    silc_client_get_client_by_id_resolve(client, conn, remote_id,
+    silc_client_get_client_by_id_resolve(client, conn, remote_id, NULL,
                                         silc_client_private_message_cb,
                                         silc_packet_context_dup(packet));
     return;
   }
 
+  cipher = remote_client->receive_key;
+  if (packet->flags & SILC_PACKET_FLAG_PRIVMSG_KEY && !cipher) {
+    silc_free(remote_id);
+    return;
+  }
+
   /* Parse the payload and decrypt it also if private message key is set */
   payload = silc_private_message_payload_parse(packet->buffer->data,
-                                              packet->buffer->len,
-                                              remote_client->receive_key);
+                                              packet->buffer->len, cipher);
   if (!payload) {
     silc_free(remote_id);
     return;
@@ -280,6 +287,7 @@ void silc_client_private_message_key(SilcClient client,
     return;
 
   silc_client_get_client_by_id_resolve(client, sock->user_data, remote_id,
+                                      NULL,
                                       silc_client_private_message_key_cb,
                                       silc_packet_context_dup(packet));
   silc_free(remote_id);