about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-10 21:57:38 +0000
committerJames Booth <boothj5@gmail.com>2014-01-10 21:57:38 +0000
commitdf8c7dedc12b05d29d759e54637c0cbeb37f54fd (patch)
tree558510c6cd0d693dbbc8896cc2626c10803ce42b
parente294a6db92b23956be777844d3796393147f5f30 (diff)
downloadprofani-tty-df8c7dedc12b05d29d759e54637c0cbeb37f54fd.tar.gz
Implemented message encryption, session started with whitspace tags on first message
-rw-r--r--src/otr.c26
-rw-r--r--src/otr.h2
2 files changed, 8 insertions, 20 deletions
diff --git a/src/otr.c b/src/otr.c
index b6b19252..cb72b777 100644
--- a/src/otr.c
+++ b/src/otr.c
@@ -37,7 +37,7 @@ static OtrlPolicy
 cb_policy(void *opdata, ConnContext *context)
 {
 //    cons_debug("cb_policy");
-    return OTRL_POLICY_DEFAULT;
+    return OTRL_POLICY_DEFAULT ;
 }
 
 static void
@@ -45,20 +45,6 @@ cb_create_privkey(void *opdata, const char *accountname,
     const char *protocol)
 {
 //    cons_debug("cb_create_privkey accountname: %s, protocol: %s", accountname, protocol);
-//    GString *key_filename = g_string_new("./");
-//    g_string_append(key_filename, accountname);
-//    g_string_append(key_filename, "_key.txt");
-
-//    gcry_error_t err = 0;
-
-//    err = otrl_privkey_generate(user_state, key_filename->str, accountname, protocol);
-//    if (!err == GPG_ERR_NO_ERROR) {
-//        cons_debug("Failed to generate private key");
-//        g_string_free(key_filename, TRUE);
-//        return;
-//    }
-//    otrl_privkey_read(user_state, key_filename->str);
-//    cons_debug("Generated private key");
 }
 
 static int
@@ -76,8 +62,7 @@ cb_inject_message(void *opdata, const char *accountname,
 {
 //    cons_debug("cb_inject_message: account: %s, protocol, %s, recipient: %s, message: %s",
 //        accountname, protocol, recipient, message);
-  char *msg_decrypt = NULL;
-  otrl_message_receiving(user_state, &ops, NULL, recipient, protocol, accountname, message, &msg_decrypt, 0, NULL, NULL);
+    message_send(message, recipient);
 }
 
 static void
@@ -272,7 +257,7 @@ otr_get_fingerprint(void)
 char *
 otr_encrypt_message(const char * const to, const char * const message)
 {
-//    cons_debug("otr_encrypt_message, account: %s, recipient: %s, message: %s", jid, to, message);
+    cons_debug("Encrypting message: %s", message);
     gcry_error_t err;
     char *newmessage = NULL;
 
@@ -292,7 +277,7 @@ otr_encrypt_message(const char * const to, const char * const message)
 //        cons_debug("Error encrypting, result: %s", newmessage);
         return NULL;
     } else {
-        cons_debug("Encrypted, result: %s", newmessage);
+        cons_debug("Encrypted message: %s", newmessage);
         return newmessage;
     }
 }
@@ -300,10 +285,11 @@ otr_encrypt_message(const char * const to, const char * const message)
 char *
 otr_decrypt_message(const char * const from, const char * const message)
 {
-//    cons_debug("otr_decrypt_message, account: %s, from: %s, message: %s", jid, from, message);
+    cons_debug("Decrypting message: %s", message);
     char *decrypted = NULL;
     int ignore_mesage = otrl_message_receiving(user_state, &ops, NULL, jid, "xmpp", from, message, &decrypted, 0, NULL, NULL);
     if (!ignore_mesage) {
+        cons_debug("Decrypted message: %s", decrypted);
         return decrypted;
     } else {
         return NULL;
diff --git a/src/otr.h b/src/otr.h
index cb964908..c96290c2 100644
--- a/src/otr.h
+++ b/src/otr.h
@@ -28,8 +28,10 @@
 void otr_init(void);
 void otr_account_load(ProfAccount *account);
 char * otr_get_fingerprint(void);
+
 char * otr_encrypt_message(const char * const to, const char * const message);
 char * otr_decrypt_message(const char * const from, const char * const message);
+
 void otr_free_message(char *message);
 
 #endif