about summary refs log tree commit diff stats
path: root/src/otr/otr.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-06-21 18:00:57 +0100
committerJames Booth <boothj5@gmail.com>2015-06-21 18:00:57 +0100
commit8d2d92360370747a34c25319a63d91a2775ffb85 (patch)
treebbe3a6fa3a59d9973d9b374e1bc4f22d11e14329 /src/otr/otr.c
parent9b991ae0586444af094c9e044715a7ceb63b6171 (diff)
downloadprofani-tty-8d2d92360370747a34c25319a63d91a2775ffb85.tar.gz
Moved message display logic to sv_ev_incoming_message
Diffstat (limited to 'src/otr/otr.c')
-rw-r--r--src/otr/otr.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/otr/otr.c b/src/otr/otr.c
index f2f5833f..e61a0e47 100644
--- a/src/otr/otr.c
+++ b/src/otr/otr.c
@@ -272,12 +272,9 @@ otr_on_connect(ProfAccount *account)
     return;
 }
 
-void
-otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message)
+char*
+otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message, gboolean *was_decrypted)
 {
-    gboolean was_decrypted = FALSE;
-    char *decrypted;
-
     prof_otrpolicy_t policy = otr_get_policy(barejid);
     char *whitespace_base = strstr(message, OTRL_MESSAGE_TAG_BASE);
 
@@ -298,22 +295,19 @@ otr_on_message_recv(const char * const barejid, const char * const resource, con
             }
         }
     }
-    decrypted = otr_decrypt_message(barejid, message, &was_decrypted);
 
-    // internal OTR message
-    if (decrypted == NULL) {
-        return;
+    char *decrypted = otr_decrypt_message(barejid, message, was_decrypted);
+    if (!decrypted) { // internal OTR message
+        return NULL;
     }
 
-    if (policy == PROF_OTRPOLICY_ALWAYS && !was_decrypted && !whitespace_base) {
+    if (policy == PROF_OTRPOLICY_ALWAYS && *was_decrypted == FALSE && !whitespace_base) {
         char *otr_query_message = otr_start_query();
         cons_show("Attempting to start OTR session...");
         message_send_chat_otr(barejid, otr_query_message);
     }
 
-    ui_incoming_msg(barejid, resource, decrypted, NULL);
-    chat_log_otr_msg_in(barejid, decrypted, was_decrypted);
-    otr_free_message(decrypted);
+    return decrypted;
 }
 
 gboolean