X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcclient%2Fclient_prvmsg.c;h=45b785e211b495e111670542467775917a80b081;hb=6394d86063413bc1c473723f3ef971840195bcd3;hp=d9f2e65d4d02e8bc5ad09b91e92833e382ce00a8;hpb=1e4e7d57f414a337e084df4072a2690f0c9b71c6;p=silc.git diff --git a/lib/silcclient/client_prvmsg.c b/lib/silcclient/client_prvmsg.c index d9f2e65d..45b785e2 100644 --- a/lib/silcclient/client_prvmsg.c +++ b/lib/silcclient/client_prvmsg.c @@ -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); @@ -185,9 +197,10 @@ void silc_client_private_message(SilcClient client, flags = silc_private_message_get_flags(payload); /* Pass the private message to application */ - client->ops->private_message(client, conn, remote_client, flags, - silc_private_message_get_message(payload, - NULL)); + client->internal->ops->private_message( + client, conn, remote_client, flags, + silc_private_message_get_message(payload, + NULL)); /* See if we are away (gone). If we are away we will reply to the sender with the set away message. */ @@ -207,8 +220,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 */ @@ -245,14 +257,15 @@ static void silc_client_private_message_key_cb(SilcClient client, goto out; /* Print some info for application */ - client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT, - "Received private message key from %s%s%s %s%s%s", - clients[0]->nickname, - clients[0]->server ? "@" : "", - clients[0]->server ? clients[0]->server : "", - clients[0]->username ? "(" : "", - clients[0]->username ? clients[0]->username : "", - clients[0]->username ? ")" : ""); + client->internal->ops->say( + client, conn, SILC_CLIENT_MESSAGE_AUDIT, + "Received private message key from %s%s%s %s%s%s", + clients[0]->nickname, + clients[0]->server ? "@" : "", + clients[0]->server ? clients[0]->server : "", + clients[0]->username ? "(" : "", + clients[0]->username ? clients[0]->username : "", + clients[0]->username ? ")" : ""); out: silc_packet_context_free(packet); @@ -346,7 +359,7 @@ int silc_client_add_private_message_key(SilcClient client, /* Produce the key material as the protocol defines */ keymat = silc_calloc(1, sizeof(*keymat)); if (silc_ske_process_key_material_data(key, key_len, 16, 256, 16, - client->md5hash, keymat) + client->internal->md5hash, keymat) != SILC_SKE_STATUS_OK) return FALSE;