diff options
-rw-r--r-- | src/command/cmd_funcs.c | 12 | ||||
-rw-r--r-- | src/xmpp/muc.c | 20 | ||||
-rw-r--r-- | src/xmpp/muc.h | 7 |
3 files changed, 33 insertions, 6 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index fe289f0b..3c55fedb 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -8031,14 +8031,14 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args) ProfMucWin *mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - /* TODO: Check room is configured correctly, no anonymous and access to - * full jid */ - omemo_start_muc_sessions(mucwin->roomjid); - - mucwin->is_omemo = TRUE; + if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS) { + omemo_start_muc_sessions(mucwin->roomjid); + mucwin->is_omemo = TRUE; + } else { + win_println(window, THEME_DEFAULT, '!', "MUC must be non-anonymous (i.e. be configured to present real jid to anyone) in order to support OMEMO."); + } } else { win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to start an OMEMO session."); - return TRUE; } } diff --git a/src/xmpp/muc.c b/src/xmpp/muc.c index 62a589d7..89e707a1 100644 --- a/src/xmpp/muc.c +++ b/src/xmpp/muc.c @@ -64,6 +64,7 @@ typedef struct _muc_room_t { GHashTable *nick_changes; gboolean roster_received; muc_member_type_t member_type; + muc_anonymity_type_t anonymity_type; } ChatRoom; GHashTable *rooms = NULL; @@ -223,6 +224,7 @@ muc_join(const char *const room, const char *const nick, const char *const passw new_room->pending_nick_change = FALSE; new_room->autojoin = autojoin; new_room->member_type = MUC_MEMBER_TYPE_UNKNOWN; + new_room->anonymity_type = MUC_ANONYMITY_TYPE_UNKNOWN; g_hash_table_insert(rooms, strdup(room), new_room); } @@ -264,6 +266,13 @@ muc_set_features(const char *const room, GSList *features) } else { chat_room->member_type = MUC_MEMBER_TYPE_PUBLIC; } + if (g_slist_find_custom(features, "muc_nonanonymous", (GCompareFunc)g_strcmp0)) { + chat_room->anonymity_type = MUC_ANONYMITY_TYPE_NONANONYMOUS; + } else if (g_slist_find_custom(features, "muc_semianonymous", (GCompareFunc)g_strcmp0)) { + chat_room->anonymity_type = MUC_ANONYMITY_TYPE_SEMIANONYMOUS; + } else { + chat_room->anonymity_type = MUC_ANONYMITY_TYPE_UNKNOWN; + } } } @@ -835,6 +844,17 @@ muc_member_type(const char *const room) } } +muc_anonymity_type_t +muc_anonymity_type(const char *const room) +{ + ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + if (chat_room) { + return chat_room->anonymity_type; + } else { + return MUC_ANONYMITY_TYPE_UNKNOWN; + } +} + static void _free_room(ChatRoom *room) diff --git a/src/xmpp/muc.h b/src/xmpp/muc.h index e0b035f2..4b49a954 100644 --- a/src/xmpp/muc.h +++ b/src/xmpp/muc.h @@ -63,6 +63,12 @@ typedef enum { MUC_MEMBER_TYPE_MEMBERS_ONLY } muc_member_type_t; +typedef enum { + MUC_ANONYMITY_TYPE_UNKNOWN, + MUC_ANONYMITY_TYPE_NONANONYMOUS, + MUC_ANONYMITY_TYPE_SEMIANONYMOUS +} muc_anonymity_type_t; + typedef struct _muc_occupant_t { char *nick; gchar *nick_collate_key; @@ -150,5 +156,6 @@ char* muc_role_str(const char *const room); char* muc_affiliation_str(const char *const room); muc_member_type_t muc_member_type(const char *const room); +muc_anonymity_type_t muc_anonymity_type(const char *const room); #endif |