about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2019-03-27 13:37:09 +0100
committerPaul Fariello <paul@fariello.eu>2019-04-10 17:23:45 +0200
commit2015ba201d446a181c240f4cc957b99af4d9ba1d (patch)
tree256035d6ff50553240ddbb284206be8870c83305
parentdaf84ced0cbead11c930017df1bd713b02776ee3 (diff)
downloadprofani-tty-2015ba201d446a181c240f4cc957b99af4d9ba1d.tar.gz
Ensure encrypted carbon of own message are marked as encrypted
-rw-r--r--src/event/server_events.c40
-rw-r--r--src/event/server_events.h2
-rw-r--r--src/ui/chatwin.c2
-rw-r--r--src/xmpp/message.c2
4 files changed, 42 insertions, 4 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index fd719cc1..023e8a13 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -387,7 +387,7 @@ sv_ev_delayed_private_message(const char *const fulljid, char *message, GDateTim
 }
 
 void
-sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message)
+sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message, gboolean omemo)
 {
     ProfChatWin *chatwin = wins_get_chat(barejid);
     if (!chatwin) {
@@ -397,6 +397,7 @@ sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message)
     chat_state_active(chatwin->state);
 
 #ifdef HAVE_LIBGPGME
+#ifndef HAVE_OMEMO
     if (pgp_message) {
         char *decrypted = p_gpg_decrypt(pgp_message);
         if (decrypted) {
@@ -407,9 +408,44 @@ sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message)
     } else {
         chatwin_outgoing_carbon(chatwin, message, PROF_MSG_PLAIN);
     }
-#else
+    return;
+#endif
+#endif
+
+#ifndef HAVE_LIBGPGME
+#ifdef HAVE_OMEMO
+    if (omemo) {
+        chatwin_outgoing_carbon(chatwin, message, PROF_MSG_OMEMO);
+    } else {
+        chatwin_outgoing_carbon(chatwin, message, PROF_MSG_PLAIN);
+    }
+    return;
+#endif
+#endif
+
+#ifdef HAVE_LIBGPGME
+#ifdef HAVE_OMEMO
+    if (omemo) {
+        chatwin_outgoing_carbon(chatwin, message, PROF_MSG_OMEMO);
+    } else if (pgp_message) {
+        char *decrypted = p_gpg_decrypt(pgp_message);
+        if (decrypted) {
+            chatwin_outgoing_carbon(chatwin, decrypted, PROF_MSG_PGP);
+        } else {
+            chatwin_outgoing_carbon(chatwin, message, PROF_MSG_PLAIN);
+        }
+    } else {
+        chatwin_outgoing_carbon(chatwin, message, PROF_MSG_PLAIN);
+    }
+    return;
+#endif
+#endif
+
+#ifndef HAVE_LIBGPGME
+#ifndef HAVE_OMEMO
     chatwin_outgoing_carbon(chatwin, message, PROF_MSG_PLAIN);
 #endif
+#endif
 }
 
 #ifdef HAVE_LIBGPGME
diff --git a/src/event/server_events.h b/src/event/server_events.h
index 0fa9989f..cf437f9a 100644
--- a/src/event/server_events.h
+++ b/src/event/server_events.h
@@ -73,7 +73,7 @@ void sv_ev_room_occupent_kicked(const char *const room, const char *const nick,
 void sv_ev_room_banned(const char *const room, const char *const actor, const char *const reason);
 void sv_ev_room_occupent_banned(const char *const room, const char *const nick, const char *const actor,
     const char *const reason);
-void sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message);
+void sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message, gboolean omemo);
 void sv_ev_incoming_carbon(char *barejid, char *resource, char *message, char *pgp_message, gboolean omemo);
 void sv_ev_xmpp_stanza(const char *const msg);
 void sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean config_required,
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index c7acce52..5064b194 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -324,6 +324,8 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_en
     char enc_char = '-';
     if (enc_mode == PROF_MSG_PGP) {
         enc_char = prefs_get_pgp_char();
+    } else if (enc_mode == PROF_MSG_OMEMO) {
+        enc_char = prefs_get_omemo_char();
     }
 
     ProfWin *window = (ProfWin*)chatwin;
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index bc166111..bc91ef3b 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -932,7 +932,7 @@ _handle_carbons(xmpp_stanza_t *const stanza)
 
     // else treat as a sent message
     } else {
-        sv_ev_outgoing_carbon(jid_to->barejid, message_txt, enc_message);
+        sv_ev_outgoing_carbon(jid_to->barejid, message_txt, enc_message, omemo);
     }
 
     xmpp_ctx_t *ctx = connection_get_ctx();