about summary refs log tree commit diff stats
path: root/src/event/client_events.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-08-30 01:32:13 +0100
committerJames Booth <boothj5@gmail.com>2015-08-30 01:32:13 +0100
commitb4722632b6fa447386b7d786efc8dafd22a3671c (patch)
tree6a6d3e243415ef982a13412503890b4e6ae19565 /src/event/client_events.c
parent1484e94b355dc8f41d7285206b114a3e8251a1d9 (diff)
downloadprofani-tty-b4722632b6fa447386b7d786efc8dafd22a3671c.tar.gz
Split PGP incoming and outgoing message handling
Diffstat (limited to 'src/event/client_events.c')
-rw-r--r--src/event/client_events.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/event/client_events.c b/src/event/client_events.c
index 56723f40..761452df 100644
--- a/src/event/client_events.c
+++ b/src/event/client_events.c
@@ -91,20 +91,19 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
 // OTR suported, PGP supported
 #ifdef HAVE_LIBOTR
 #ifdef HAVE_LIBGPGME
-    prof_enc_t enc_mode = chatwin->enc_mode;
-    if (enc_mode == PROF_ENC_NONE || enc_mode == PROF_ENC_OTR) {
+    if (chatwin->pgp_send) {
+        char *id = message_send_chat_pgp(chatwin->barejid, msg);
+        chat_log_pgp_msg_out(chatwin->barejid, msg);
+        ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PGP);
+        free(id);
+    } else {
         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, PROF_ENC_NONE);
+            ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PLAIN);
             free(id);
         }
-    } else { // enc_mode = PROF_ENC_PGP
-        char *id = message_send_chat_pgp(chatwin->barejid, msg);
-        chat_log_pgp_msg_out(chatwin->barejid, msg);
-        ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_PGP);
-        free(id);
     }
     return;
 #endif
@@ -117,7 +116,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const 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, PROF_ENC_NONE);
+        ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PLAIN);
         free(id);
     }
     return;
@@ -127,16 +126,15 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
 // OTR unsupported, PGP supported
 #ifndef HAVE_LIBOTR
 #ifdef HAVE_LIBGPGME
-    prof_enc_t enc_mode = chatwin->enc_mode;
-    if (enc_mode == PROF_ENC_NONE) {
-        char *id = message_send_chat(chatwin->barejid, msg);
-        chat_log_msg_out(chatwin->barejid, msg);
-        ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE);
-        free(id);
-    } else if (enc_mode == PROF_ENC_PGP) {
+    if (chatwin->pgp_send) {
         char *id = message_send_chat_pgp(chatwin->barejid, msg);
         chat_log_pgp_msg_out(chatwin->barejid, msg);
-        ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_PGP);
+        ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PGP);
+        free(id);
+    } else {
+        char *id = message_send_chat(chatwin->barejid, msg);
+        chat_log_msg_out(chatwin->barejid, msg);
+        ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PLAIN);
         free(id);
     }
     return;
@@ -148,7 +146,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg)
 #ifndef HAVE_LIBGPGME
     char *id = message_send_chat(chatwin->barejid, msg);
     chat_log_msg_out(chatwin->barejid, msg);
-    ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE);
+    ui_outgoing_chat_msg(chatwin, msg, id, PROF_MSG_PLAIN);
     free(id);
     return;
 #endif