about summary refs log tree commit diff stats
path: root/src/xmpp/presence.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp/presence.c')
-rw-r--r--src/xmpp/presence.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index a8418673..241932e6 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -232,20 +232,21 @@ presence_update(const resource_presence_t presence_type, const char * const msg,
     char *account_name = jabber_get_account_name();
     ProfAccount *account = accounts_get_account(account_name);
     if (account->pgp_keyid) {
-        xmpp_stanza_t *x = xmpp_stanza_new(ctx);
-        xmpp_stanza_set_name(x, STANZA_NAME_X);
-        xmpp_stanza_set_ns(x, STANZA_NS_SIGNED);
-        xmpp_stanza_t *signed_text = xmpp_stanza_new(ctx);
-
         char *signed_status = p_gpg_sign_str(msg, account->pgp_keyid);
 
-        xmpp_stanza_set_text(signed_text, signed_status);
-        xmpp_stanza_add_child(x, signed_text);
-        xmpp_stanza_release(signed_text);
-        xmpp_stanza_add_child(presence, x);
-        xmpp_stanza_release(x);
-
-        free(signed_status);
+        if (signed_status) {
+            xmpp_stanza_t *x = xmpp_stanza_new(ctx);
+            xmpp_stanza_set_name(x, STANZA_NAME_X);
+            xmpp_stanza_set_ns(x, STANZA_NS_SIGNED);
+            xmpp_stanza_t *signed_text = xmpp_stanza_new(ctx);
+            xmpp_stanza_set_text(signed_text, signed_status);
+            xmpp_stanza_add_child(x, signed_text);
+            xmpp_stanza_release(signed_text);
+            xmpp_stanza_add_child(presence, x);
+            xmpp_stanza_release(x);
+
+            free(signed_status);
+        }
     }
 #endif
 
@@ -606,6 +607,16 @@ _available_handler(xmpp_conn_t * const conn,
         log_debug("Presence available handler fired for: %s", jid);
     }
 
+#ifdef HAVE_LIBGPGME
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_SIGNED);
+    if (x) {
+        char *sign = xmpp_stanza_get_text(x);
+        if (sign) {
+            p_gpg_verify(xmpp_presence->jid->barejid, sign);
+        }
+    }
+#endif
+
     const char *my_jid_str = xmpp_conn_get_jid(conn);
     Jid *my_jid = jid_create(my_jid_str);