Moved the SilcClient and SilcClientConnection to the public
[silc.git] / lib / silcclient / client_prvmsg.c
index 647790b552505ce485d55613ed299197870be9d5..4a4fc6b43f018944ca27a70dcaea82b4525d8379 100644 (file)
@@ -71,8 +71,8 @@ void silc_client_send_private_message(SilcClient client,
   /* We have private message specific key */
 
   /* Get data used in the encryption */
-  cipher = conn->send_key;
-  hmac = conn->hmac_send;
+  cipher = conn->internal->send_key;
+  hmac = conn->internal->hmac_send;
   block_len = silc_cipher_get_block_len(cipher);
 
   /* Set the packet context pointers. */
@@ -103,7 +103,7 @@ void silc_client_send_private_message(SilcClient client,
   }
 
   /* Encrypt the header and padding of the packet. */
-  silc_packet_encrypt(cipher, hmac, conn->psn_send++,
+  silc_packet_encrypt(cipher, hmac, conn->internal->psn_send++,
                      (SilcBuffer)&packet, SILC_PACKET_HEADER_LEN + 
                      packetdata.src_id_len + packetdata.dst_id_len +
                      packetdata.padlen);
@@ -173,7 +173,7 @@ void silc_client_private_message(SilcClient client,
     }
 
     /* 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;
@@ -202,7 +202,8 @@ void silc_client_private_message(SilcClient client,
 
   /* See if we are away (gone). If we are away we will reply to the
      sender with the set away message. */
-  if (conn->away && conn->away->away && !(flags & SILC_MESSAGE_FLAG_NOREPLY)) {
+  if (conn->internal->away && conn->internal->away->away &&
+      !(flags & SILC_MESSAGE_FLAG_NOREPLY)) {
     /* If it's me, ignore */
     if (SILC_ID_CLIENT_COMPARE(remote_id, conn->local_id))
       goto out;
@@ -211,8 +212,8 @@ void silc_client_private_message(SilcClient client,
     silc_client_send_private_message(client, conn, remote_client,
                                     SILC_MESSAGE_FLAG_AUTOREPLY |
                                     SILC_MESSAGE_FLAG_NOREPLY,
-                                    conn->away->away,
-                                    strlen(conn->away->away), TRUE);
+                                    conn->internal->away->away,
+                                    strlen(conn->internal->away->away), TRUE);
   }
 
  out:
@@ -287,6 +288,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);
@@ -356,7 +358,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->internal->md5hash, keymat) 
+                                        client->md5hash, keymat) 
       != SILC_SKE_STATUS_OK)
     return FALSE;
 
@@ -455,13 +457,15 @@ int silc_client_send_private_message_key(SilcClient client,
   SilcSocketConnection sock = conn->sock;
   SilcBuffer buffer;
   int cipher_len;
+  const char *cipher;
 
   if (!client_entry->send_key || !client_entry->key)
     return FALSE;
 
   SILC_LOG_DEBUG(("Sending private message key"));
 
-  cipher_len = strlen(client_entry->send_key->cipher->name);
+  cipher = silc_cipher_get_name(client_entry->send_key);
+  cipher_len = strlen(cipher);
 
   /* Create private message key payload */
   buffer = silc_buffer_alloc(2 + client_entry->key_len);
@@ -471,7 +475,7 @@ int silc_client_send_private_message_key(SilcClient client,
                     SILC_STR_UI_XNSTRING(client_entry->key, 
                                          client_entry->key_len),
                     SILC_STR_UI_SHORT(cipher_len),
-                    SILC_STR_UI_XNSTRING(client_entry->send_key->cipher->name,
+                    SILC_STR_UI_XNSTRING(cipher,
                                          cipher_len),
                     SILC_STR_END);
 
@@ -531,7 +535,7 @@ silc_client_list_private_message_keys(SilcClient client,
   SilcIDCacheList list;
   SilcClientEntry entry;
 
-  if (!silc_idcache_get_all(conn->client_cache, &list))
+  if (!silc_idcache_get_all(conn->internal->client_cache, &list))
     return NULL;
 
   if (!silc_idcache_list_count(list)) {
@@ -547,7 +551,7 @@ silc_client_list_private_message_keys(SilcClient client,
 
     if (entry->send_key) {
       keys[count].client_entry = entry;
-      keys[count].cipher = entry->send_key->cipher->name;
+      keys[count].cipher = (char *)silc_cipher_get_name(entry->send_key);
       keys[count].key = entry->generated == FALSE ? entry->key : NULL;
       keys[count].key_len = entry->generated == FALSE ? entry->key_len : 0;
       count++;
@@ -584,17 +588,17 @@ void silc_client_set_away_message(SilcClient client,
                                  SilcClientConnection conn,
                                  char *message)
 {
-  if (!message && conn->away) {
-    silc_free(conn->away->away);
-    silc_free(conn->away);
-    conn->away = NULL;
+  if (!message && conn->internal->away) {
+    silc_free(conn->internal->away->away);
+    silc_free(conn->internal->away);
+    conn->internal->away = NULL;
   }
 
   if (message) {
-    if (!conn->away)
-      conn->away = silc_calloc(1, sizeof(*conn->away));
-    if (conn->away->away)
-      silc_free(conn->away->away);
-    conn->away->away = strdup(message);
+    if (!conn->internal->away)
+      conn->internal->away = silc_calloc(1, sizeof(*conn->internal->away));
+    if (conn->internal->away->away)
+      silc_free(conn->internal->away->away);
+    conn->internal->away->away = strdup(message);
   }
 }