From 6f537c38186b3cdc4c63e11a327f367723ecffbd Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 22 Mar 2016 00:20:29 +0000 Subject: Add PGP decryption for incoming/outgoing carbons --- src/xmpp/message.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/message.c b/src/xmpp/message.c index ccd4d624..6e3e7721 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -191,8 +191,6 @@ message_send_chat_pgp(const char *const barejid, const char *const msg) stanza_attach_state(ctx, message, state); } - stanza_attach_carbons_private(ctx, message); - if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) { stanza_attach_receipt_request(ctx, message); } @@ -714,17 +712,25 @@ _handle_carbons(xmpp_stanza_t *const stanza) // check for and deal with message xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(message, STANZA_NAME_BODY); if (body) { - char *message = xmpp_stanza_get_text(body); - if (message) { + char *message_txt = xmpp_stanza_get_text(body); + if (message_txt) { + // check for pgp encrypted message + char *enc_message = NULL; + xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(message, STANZA_NS_ENCRYPTED); + if (x) { + enc_message = xmpp_stanza_get_text(x); + } + // if we are the recipient, treat as standard incoming message if(g_strcmp0(my_jid->barejid, jid_to->barejid) == 0){ - sv_ev_incoming_carbon(jid_from->barejid, jid_from->resourcepart, message); - } + sv_ev_incoming_carbon(jid_from->barejid, jid_from->resourcepart, message_txt, enc_message); + // else treat as a sent message - else{ - sv_ev_outgoing_carbon(jid_to->barejid, message); + } else { + sv_ev_outgoing_carbon(jid_to->barejid, message_txt, enc_message); } - xmpp_free(ctx, message); + xmpp_free(ctx, message_txt); + xmpp_free(ctx, enc_message); } } -- cgit 1.4.1-2-gfad0