From 21ae946896d5c1489f3b8d4341dc90bf33ace984 Mon Sep 17 00:00:00 2001 From: Paul Fariello Date: Wed, 17 Apr 2019 12:41:19 +0200 Subject: [PATCH] Handle MUC anonymous state when auto starting OMEMO When auto joining a MUC we don't have access to required information so we just don't start OMEMO at this time. Once we receive disco info we then try to start OMEMO. --- src/ui/mucwin.c | 2 +- src/xmpp/iq.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index fc485b3d..b56cd994 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -55,7 +55,7 @@ mucwin_new(const char *const barejid) ProfMucWin *mucwin = (ProfMucWin *)window; #ifdef HAVE_OMEMO - if (omemo_automatic_start(barejid)) { + if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS && omemo_automatic_start(barejid)) { omemo_start_muc_sessions(barejid); mucwin->is_omemo = TRUE; } diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index d6e4c153..7800ef3c 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -72,6 +72,10 @@ #include "xmpp/roster.h" #include "xmpp/muc.h" +#ifdef HAVE_OMEMO +#include "omemo/omemo.h" +#endif + typedef struct p_room_info_data_t { char *room; gboolean display; @@ -2100,8 +2104,16 @@ _room_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata muc_set_features(cb_data->room, features); ProfMucWin *mucwin = wins_get_muc(cb_data->room); - if (mucwin && cb_data->display) { - mucwin_room_disco_info(mucwin, identities, features); + if (mucwin) { +#ifdef HAVE_OMEMO + if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS && omemo_automatic_start(cb_data->room)) { + omemo_start_muc_sessions(cb_data->room); + mucwin->is_omemo = TRUE; + } +#endif + if (cb_data->display) { + mucwin_room_disco_info(mucwin, identities, features); + } } g_slist_free_full(features, free);