void silc_client_send_private_message(SilcClient client,
SilcClientConnection conn,
SilcClientEntry client_entry,
+ SilcMessageFlags flags,
unsigned char *data,
- unsigned int data_len,
+ uint32 data_len,
int force_send)
{
SilcSocketConnection sock = conn->sock;
SILC_LOG_DEBUG(("Sending private message"));
/* Encode private message payload */
- buffer = silc_private_message_payload_encode(strlen(conn->nickname),
- conn->nickname, 0,
+ buffer = silc_private_message_payload_encode(flags,
data_len, data,
client_entry->send_key);
/* Get data used in the encryption */
cipher = client_entry->send_key;
- hmac = conn->hmac;
+ hmac = conn->hmac_send;
/* Set the packet context pointers. */
packetdata.flags = SILC_PACKET_FLAG_PRIVMSG_KEY;
packetdata.type = SILC_PACKET_PRIVATE_MESSAGE;
packetdata.src_id = conn->local_id_data;
- packetdata.src_id_len = SILC_ID_CLIENT_LEN;
+ packetdata.src_id_len = silc_id_get_len(conn->local_id, SILC_ID_CLIENT);
packetdata.src_id_type = SILC_ID_CLIENT;
packetdata.dst_id = silc_id_id2str(client_entry->id, SILC_ID_CLIENT);
- packetdata.dst_id_len = SILC_ID_CLIENT_LEN;
+ packetdata.dst_id_len = silc_id_get_len(client_entry->id, SILC_ID_CLIENT);
packetdata.dst_id_type = SILC_ID_CLIENT;
packetdata.truelen = buffer->len + SILC_PACKET_HEADER_LEN +
packetdata.src_id_len + packetdata.dst_id_len;
sock->outbuf->data, sock->outbuf->len);
/* Now actually send the packet */
- silc_client_packet_send_real(client, sock, force_send);
+ silc_client_packet_send_real(client, sock, force_send, FALSE);
silc_free(packetdata.dst_id);
out:
static void silc_client_private_message_cb(SilcClient client,
SilcClientConnection conn,
SilcClientEntry *clients,
- unsigned int clients_count,
+ uint32 clients_count,
void *context)
{
SilcPacketContext *packet = (SilcPacketContext *)context;
goto out;
/* Check whether we know this client already */
- if (!silc_idcache_find_by_id_one(conn->client_cache, remote_id,
- SILC_ID_CLIENT, &id_cache)) {
+ if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)remote_id,
+ NULL, NULL,
+ silc_hash_client_id_compare, NULL,
+ &id_cache)) {
/* Resolve the client info */
silc_client_get_client_by_id_resolve(client, conn, remote_id,
silc_client_private_message_cb,
}
/* Pass the private message to application */
- client->ops->private_message(client, conn, remote_client,
+ client->ops->private_message(client, conn, remote_client,
+ silc_private_message_get_flags(payload),
silc_private_message_get_message(payload,
NULL));
sender with the set away message. */
if (conn->away && conn->away->away) {
/* If it's me, ignore */
- if (!SILC_ID_CLIENT_COMPARE(remote_id, conn->local_id))
+ if (SILC_ID_CLIENT_COMPARE(remote_id, conn->local_id))
goto out;
/* Send the away message */
silc_client_send_private_message(client, conn, remote_client,
+ SILC_MESSAGE_FLAG_AUTOREPLY,
conn->away->away,
strlen(conn->away->away), TRUE);
}
static void silc_client_private_message_key_cb(SilcClient client,
SilcClientConnection conn,
SilcClientEntry *clients,
- unsigned int clients_count,
+ uint32 clients_count,
void *context)
{
SilcPacketContext *packet = (SilcPacketContext *)context;
unsigned char *key;
- unsigned short key_len;
+ uint16 key_len;
unsigned char *cipher;
int ret;
SilcClientEntry client_entry,
char *cipher,
unsigned char *key,
- unsigned int key_len,
+ uint32 key_len,
int generate_key)
{
unsigned char private_key[32];
- unsigned int len;
+ uint32 len;
int i;
SilcSKEKeyMaterial *keymat;
SilcPrivateMessageKeys
silc_client_list_private_message_keys(SilcClient client,
SilcClientConnection conn,
- unsigned int *key_count)
+ uint32 *key_count)
{
SilcPrivateMessageKeys keys;
- unsigned int count = 0;
+ uint32 count = 0;
SilcIDCacheEntry id_cache;
SilcIDCacheList list;
SilcClientEntry entry;
- if (!silc_idcache_find_by_id(conn->client_cache, SILC_ID_CACHE_ANY,
- SILC_ID_CLIENT, &list))
+ if (!silc_idcache_get_all(conn->client_cache, &list))
return NULL;
if (!silc_idcache_list_count(list)) {
silc_client_list_private_message_keys. */
void silc_client_free_private_message_keys(SilcPrivateMessageKeys keys,
- unsigned int key_count)
+ uint32 key_count)
{
silc_free(keys);
}