about summary refs log tree commit diff stats
path: root/src/event
diff options
context:
space:
mode:
authorDebXWoody <stefan@debxwoody.de>2020-06-21 09:43:42 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-06-29 19:05:41 +0200
commit2c94ee5a88f64332a3f41f41a4d314fc52200e31 (patch)
tree6209fd4796609a7706f950b18a9bb652c6c137fb /src/event
parent3afd854dc862696c4842b2ed93efcad44d617910 (diff)
downloadprofani-tty-2c94ee5a88f64332a3f41f41a4d314fc52200e31.tar.gz
Feature request - XEP-0373: OpenPGP for XMPP (OX)
Basic implementation of XEP-0373: OpenPGP for XMPP.
https://xmpp.org/extensions/xep-0373.html

Command /ox

Issue: #1331
Diffstat (limited to 'src/event')
-rw-r--r--src/event/client_events.c9
-rw-r--r--src/event/server_events.c24
2 files changed, 31 insertions, 2 deletions
diff --git a/src/event/client_events.c b/src/event/client_events.c
index 177a6559..15261760 100644
--- a/src/event/client_events.c
+++ b/src/event/client_events.c
@@ -139,6 +139,15 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char *
         chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt, replace_id);
         free(id);
 #endif
+    } else if (chatwin->is_ox) {
+#ifdef HAVE_LIBGPGME
+        // XEP-0373: OpenPGP for XMPP
+        char *id = message_send_chat_ox(chatwin->barejid, plugin_msg, request_receipt, replace_id);
+        chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL);
+        log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_OX);
+        chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OX, request_receipt, replace_id);
+        free(id);
+#endif
     } else if (chatwin->pgp_send) {
 #ifdef HAVE_LIBGPGME
         char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt, replace_id);
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 1684a7d2..22ac9d10 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -517,6 +517,22 @@ _sv_ev_incoming_pgp(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message
 }
 
 static void
+_sv_ev_incoming_ox(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message, gboolean logit)
+{
+#ifdef HAVE_LIBGPGME
+        //_clean_incoming_message(message);
+        chatwin_incoming_msg(chatwin, message, new_win);
+        log_database_add_incoming(message);
+        if (logit) {
+            chat_log_pgp_msg_in(message);
+        }
+        chatwin->pgp_recv = TRUE;
+        //p_gpg_free_decrypted(message->plain);
+        message->plain = NULL;
+}
+#endif
+
+static void
 _sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message)
 {
 #ifdef HAVE_LIBOTR
@@ -604,7 +620,9 @@ sv_ev_incoming_message(ProfMessage *message)
 #endif
     }
 
-    if (message->encrypted) {
+    if( message->enc == PROF_MSG_ENC_OX) {
+	 _sv_ev_incoming_ox(chatwin, new_win, message, TRUE);
+    } else if (message->encrypted) {
         if (chatwin->is_otr) {
             win_println((ProfWin*)chatwin, THEME_DEFAULT, "-", "PGP encrypted message received whilst in OTR session.");
         } else {
@@ -638,7 +656,9 @@ sv_ev_incoming_carbon(ProfMessage *message)
 #endif
     }
 
-    if (message->encrypted) {
+    if (message->enc == PROF_MSG_ENC_OX) {
+        _sv_ev_incoming_ox(chatwin, new_win, message, FALSE);
+    } else if (message->encrypted) {
         _sv_ev_incoming_pgp(chatwin, new_win, message, FALSE);
     } else if (message->enc == PROF_MSG_ENC_OMEMO) {
         _sv_ev_incoming_omemo(chatwin, new_win, message, FALSE);