diff --git a/src/pgp/gpg.c b/src/pgp/gpg.c index bb701c3f..8aac50ff 100644 --- a/src/pgp/gpg.c +++ b/src/pgp/gpg.c @@ -1141,6 +1141,11 @@ _ox_key_is_usable(gpgme_key_t key, const char* const barejid, gboolean secret) char* p_ox_gpg_decrypt(char* base64) { + // if there is no private key avaibale, + // we don't try do decrypt + if(!ox_is_private_key_available(connection_get_barejid())) { + return NULL; + } setlocale(LC_ALL, ""); gpgme_check_version(NULL); gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 33e15e78..aad7107d 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -1463,28 +1463,29 @@ _handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_m xmpp_stanza_t *p = xmpp_stanza_get_child_by_name(x, "payload"); if ( !p ) { log_warning("OX Stanza - no Payload"); + message->plain = "OX error: No payload found"; return; } xmpp_stanza_t *b = xmpp_stanza_get_child_by_name(p, "body"); if ( !b ) { log_warning("OX Stanza - no body"); + message->plain = "OX error: No paylod body found"; return; } message->plain = xmpp_stanza_get_text(b); + message->encrypted = xmpp_stanza_get_text(ox); if(message->plain == NULL ) { message->plain = xmpp_stanza_get_text(stanza); } - message->encrypted = xmpp_stanza_get_text(ox); - - if (message->plain == NULL) { - message->plain = xmpp_stanza_get_text(stanza); - } - message->encrypted = xmpp_stanza_get_text(ox); } else { + message->plain = "Unable to decrypt OX message (XEP-0373: OpenPGP for XMPP)"; log_warning("OX Stanza text to stanza failed"); } + } else { + message->plain = "Unable to decrypt OX message (XEP-0373: OpenPGP for XMPP)"; } } else { + message->plain = "OX stanza without openpgp name"; log_warning("OX Stanza without openpgp stanza"); } #endif // HAVE_LIBGPGME