mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Moved pgp signature verification to sv_ev_contact_online
This commit is contained in:
parent
8673488368
commit
8ebc1d4ac1
@ -47,6 +47,9 @@
|
||||
#ifdef HAVE_LIBOTR
|
||||
#include "otr/otr.h"
|
||||
#endif
|
||||
#ifdef HAVE_LIBGPGME
|
||||
#include "pgp/gpg.h"
|
||||
#endif
|
||||
|
||||
#include "ui/ui.h"
|
||||
|
||||
@ -280,7 +283,7 @@ sv_ev_contact_offline(char *barejid, char *resource, char *status)
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_contact_online(char *barejid, Resource *resource, GDateTime *last_activity)
|
||||
sv_ev_contact_online(char *barejid, Resource *resource, GDateTime *last_activity, char *pgpsig)
|
||||
{
|
||||
gboolean updated = roster_update_presence(barejid, resource, last_activity);
|
||||
|
||||
@ -288,6 +291,12 @@ sv_ev_contact_online(char *barejid, Resource *resource, GDateTime *last_activity
|
||||
ui_contact_online(barejid, resource, last_activity);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBGPGME
|
||||
if (pgpsig) {
|
||||
p_gpg_verify(barejid, pgpsig);
|
||||
}
|
||||
#endif
|
||||
|
||||
rosterwin_roster();
|
||||
chat_session_remove(barejid);
|
||||
}
|
||||
|
@ -62,8 +62,7 @@ void sv_ev_gone(const char * const barejid, const char * const resource);
|
||||
void sv_ev_subscription(const char *from, jabber_subscr_t type);
|
||||
void sv_ev_message_receipt(char *barejid, char *id);
|
||||
void sv_ev_contact_offline(char *contact, char *resource, char *status);
|
||||
void sv_ev_contact_online(char *contact, Resource *resource,
|
||||
GDateTime *last_activity);
|
||||
void sv_ev_contact_online(char *contact, Resource *resource, GDateTime *last_activity, char *pgpkey);
|
||||
void sv_ev_leave_room(const char * const room);
|
||||
void sv_ev_room_destroy(const char * const room);
|
||||
void sv_ev_room_occupant_offline(const char * const room, const char * const nick,
|
||||
|
@ -619,16 +619,6 @@ _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);
|
||||
|
||||
@ -645,7 +635,14 @@ _available_handler(xmpp_conn_t * const conn,
|
||||
if (g_strcmp0(xmpp_presence->jid->barejid, my_jid->barejid) == 0) {
|
||||
connection_add_available_resource(resource);
|
||||
} else {
|
||||
sv_ev_contact_online(xmpp_presence->jid->barejid, resource, xmpp_presence->last_activity);
|
||||
char *pgpsig = NULL;
|
||||
xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_SIGNED);
|
||||
if (x) {
|
||||
pgpsig = xmpp_stanza_get_text(x);
|
||||
}
|
||||
sv_ev_contact_online(xmpp_presence->jid->barejid, resource, xmpp_presence->last_activity, pgpsig);
|
||||
xmpp_ctx_t *ctx = connection_get_ctx();
|
||||
xmpp_free(ctx, pgpsig);
|
||||
}
|
||||
|
||||
jid_destroy(my_jid);
|
||||
|
@ -23,3 +23,4 @@ const char* p_gpg_libver(void)
|
||||
|
||||
void p_gpg_free_key(ProfPGPKey *key) {}
|
||||
|
||||
void p_gpg_verify(const char * const barejid, const char *const sign) {}
|
||||
|
@ -26,7 +26,7 @@ void console_shows_online_presence_when_set_online(void **state)
|
||||
expect_memory(ui_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(ui_contact_online, last_activity, NULL);
|
||||
|
||||
sv_ev_contact_online(barejid, resource, NULL);
|
||||
sv_ev_contact_online(barejid, resource, NULL, NULL);
|
||||
|
||||
roster_clear();
|
||||
}
|
||||
@ -43,7 +43,7 @@ void console_shows_online_presence_when_set_all(void **state)
|
||||
expect_memory(ui_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(ui_contact_online, last_activity, NULL);
|
||||
|
||||
sv_ev_contact_online(barejid, resource, NULL);
|
||||
sv_ev_contact_online(barejid, resource, NULL, NULL);
|
||||
|
||||
roster_clear();
|
||||
}
|
||||
@ -60,7 +60,7 @@ void console_shows_dnd_presence_when_set_all(void **state)
|
||||
expect_memory(ui_contact_online, resource, resource, sizeof(resource));
|
||||
expect_value(ui_contact_online, last_activity, NULL);
|
||||
|
||||
sv_ev_contact_online(barejid, resource, NULL);
|
||||
sv_ev_contact_online(barejid, resource, NULL, NULL);
|
||||
|
||||
roster_clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user