From 2c94ee5a88f64332a3f41f41a4d314fc52200e31 Mon Sep 17 00:00:00 2001 From: DebXWoody Date: Sun, 21 Jun 2020 09:43:42 +0200 Subject: 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 --- src/event/client_events.c | 9 +++++++++ src/event/server_events.c | 24 ++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'src/event') 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 @@ -138,6 +138,15 @@ cl_ev_send_msg_correct(ProfChatWin *chatwin, const char *const msg, const char * log_database_add_outgoing_chat(id, chatwin->barejid, plugin_msg, replace_id, PROF_MSG_ENC_OMEMO); 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 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 @@ -516,6 +516,22 @@ _sv_ev_incoming_pgp(ProfChatWin *chatwin, gboolean new_win, ProfMessage *message #endif } +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) { @@ -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); -- cgit 1.4.1-2-gfad0