about summary refs log tree commit diff stats
path: root/src/event
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-06-21 01:48:25 +0100
committerJames Booth <boothj5@gmail.com>2015-06-21 01:48:25 +0100
commite45afd5c09a5a4bea9cbf8f16eb6af3908344dba (patch)
tree5832dce58ec4eea210ba2c2adffcf38715296e24 /src/event
parent6617bb5a2b432d9c4178984386855f30be76ecf3 (diff)
downloadprofani-tty-e45afd5c09a5a4bea9cbf8f16eb6af3908344dba.tar.gz
Added pgp checks for message sending
Diffstat (limited to 'src/event')
-rw-r--r--src/event/client_events.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/event/client_events.c b/src/event/client_events.c
index e9a42d32..f1af8331 100644
--- a/src/event/client_events.c
+++ b/src/event/client_events.c
@@ -88,13 +88,52 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
     chat_state_active(chatwin->state);
 
 #ifdef HAVE_LIBOTR
-    otr_on_message_send(chatwin, msg);
-#else
+    if (chatwin->enc_mode == PROF_ENC_NONE || chatwin->enc_mode == PROF_ENC_OTR) {
+        gboolean handled = otr_on_message_send(chatwin, msg);
+        if (!handled) {
+            char *id = message_send_chat(chatwin->barejid, msg);
+            chat_log_msg_out(chatwin->barejid, msg);
+            ui_outgoing_chat_msg(chatwin, msg, id);
+            free(id);
+        }
+        return;
+    }
+#ifdef HAVE_LIBGPGME
+    if (chatwin->enc_mode == PROF_ENC_PGP) {
+        char *id = message_send_chat_pgp(chatwin->barejid, msg);
+        // TODO pgp message logger
+        chat_log_msg_out(chatwin->barejid, msg);
+        ui_outgoing_chat_msg(chatwin, msg, id);
+        free(id);
+        return;
+    }
+#endif // HAVE_LIBGPGME
+
+#else // HAVE_LIBOTR
+
+#ifdef HAVE_LIBGPGME
+    if (chatwin->enc_mode == PROF_ENC_PGP) {
+        char *id = message_send_chat_pgp(chatwin->barejid, msg);
+        chat_log_msg_out(chatwin->barejid, msg);
+        ui_outgoing_chat_msg(chatwin, msg, id);
+        free(id);
+        return;
+    }
+
     char *id = message_send_chat(chatwin->barejid, msg);
     chat_log_msg_out(chatwin->barejid, msg);
     ui_outgoing_chat_msg(chatwin, msg, id);
     free(id);
-#endif
+    return;
+#else // HAVE_LIBGPGME
+    char *id = message_send_chat(chatwin->barejid, msg);
+    chat_log_msg_out(chatwin->barejid, msg);
+    ui_outgoing_chat_msg(chatwin, msg, id);
+    free(id);
+    return;
+#endif // HAVE_LIBGPGME
+
+#endif // HAVE_LIBOTR
 }
 
 void