From 8fe95399a1c2f530b9a64f2dd864d55712fa4f6a Mon Sep 17 00:00:00 2001 From: DebXWoody Date: Sat, 5 Jun 2021 19:12:42 +0200 Subject: OMEMO: Separate handling of device list In profanity are two handlers for device list: * _handle_own_device_list * _handle_device_list_start_session I seems both handler will start a session via omemo_start_device_session_handle_bundle _handle_own_device_list will also make sure, that the own device is withing the omemo device list. If we add the _handle_device_list_start_session into the hashmap, we are not going the republish ourself, in case we clean-up the device list from another client. This will maybe fix #1552 99 Little Bugs in my Code. Take one down. Patch it around. 113 Bugs in my Code --- src/omemo/omemo.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index 9b2b35f5..efc3dbfe 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -367,6 +367,8 @@ omemo_generate_crypto_materials(ProfAccount* account) void omemo_publish_crypto_materials(void) { + log_debug("[OMEMO] publish crypto materials"); + if (loaded != TRUE) { cons_show("OMEMO: cannot publish crypto materials before they are generated"); log_error("[OMEMO] cannot publish crypto materials before they are generated"); @@ -408,8 +410,14 @@ omemo_start_session(const char* const barejid) GList* device_list = g_hash_table_lookup(omemo_ctx.device_list, barejid); if (!device_list) { log_debug("[OMEMO] missing device list for %s", barejid); + // Own devices are handled by _handle_own_device_list + // We won't add _handle_device_list_start_session for ourself + char* mybarejid = connection_get_barejid(); + if( g_strcmp0(mybarejid, barejid ) != 0 ) { + g_hash_table_insert(omemo_ctx.device_list_handler, strdup(barejid), _handle_device_list_start_session); + } + free(mybarejid); omemo_devicelist_request(barejid); - g_hash_table_insert(omemo_ctx.device_list_handler, strdup(barejid), _handle_device_list_start_session); return; } @@ -525,6 +533,7 @@ omemo_prekeys(GList** prekeys, GList** ids, GList** lengths) void omemo_set_device_list(const char* const from, GList* device_list) { + log_debug("[OMEMO] Setting device list for %s", from); Jid* jid; if (from) { jid = jid_create(from); @@ -540,6 +549,8 @@ omemo_set_device_list(const char* const from, GList* device_list) if (!keep) { g_hash_table_remove(omemo_ctx.device_list_handler, jid->barejid); } + } else { + log_debug("[OMEMO] No Device List Handler for %s", from); } // OMEMO trustmode ToFu -- cgit 1.4.1-2-gfad0