From b4722632b6fa447386b7d786efc8dafd22a3671c Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 30 Aug 2015 01:32:13 +0100 Subject: Split PGP incoming and outgoing message handling --- src/event/client_events.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'src/event/client_events.c') 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 -- cgit 1.4.1-2-gfad0