diff options
author | Paul Fariello <paul@fariello.eu> | 2019-02-25 06:04:03 +0140 |
---|---|---|
committer | Paul Fariello <paul@fariello.eu> | 2019-04-10 16:03:50 +0200 |
commit | 95da03ac28c283e59588bebf698b12aea2333c1f (patch) | |
tree | fd6cdbae6cc8b1e6f48c7b083a9b2a17501076d8 /src | |
parent | 756fefb09aa9cb22d1f882c51984ca6047dc236d (diff) | |
download | profani-tty-95da03ac28c283e59588bebf698b12aea2333c1f.tar.gz |
Ensure received devicelist contains our own device id
Diffstat (limited to 'src')
-rw-r--r-- | src/omemo/omemo.c | 13 | ||||
-rw-r--r-- | src/omemo/omemo.h | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index 9300c6b8..3ab044ee 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -173,9 +173,18 @@ omemo_prekeys(GList ** const prekeys, GList ** const ids, GList ** const lengths } void -omemo_set_device_list(const char *const jid, GList * const device_list) +omemo_set_device_list(const char *const jid, GList * device_list) { - /* TODO handle self device_list to ensure we still are on the list */ + xmpp_ctx_t * const ctx = connection_get_ctx(); + char *barejid = xmpp_jid_bare(ctx, session_get_account_name()); + + if (g_strcmp0(jid, barejid) == 0) { + if (!g_list_find(device_list, GINT_TO_POINTER(omemo_ctx.device_id))) { + device_list = g_list_append(device_list, GINT_TO_POINTER(omemo_ctx.device_id)); + omemo_devicelist_publish(device_list); + } + } + g_hash_table_insert(omemo_ctx.device_list, strdup(jid), device_list); } diff --git a/src/omemo/omemo.h b/src/omemo/omemo.h index ca9f7208..31d942b8 100644 --- a/src/omemo/omemo.h +++ b/src/omemo/omemo.h @@ -12,7 +12,7 @@ void omemo_identity_key(unsigned char **output, size_t *length); void omemo_signed_prekey(unsigned char **output, size_t *length); void omemo_signed_prekey_signature(unsigned char **output, size_t *length); void omemo_prekeys(GList ** const prekeys, GList ** const ids, GList ** const lengths); -void omemo_set_device_list(const char *const jid, GList * const device_list); +void omemo_set_device_list(const char *const jid, GList * device_list); void omemo_start_session(ProfAccount *account, char *barejid); gboolean omemo_loaded(void); |