mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge pull request #1066 from paulfariello/hotfix/OMEMO-ensure-muc-is-nonanonymous
Ensure MUC is Non-Anonymous before starting OMEMO
This commit is contained in:
commit
9574127177
@ -8032,14 +8032,14 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args)
|
|||||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||||
|
|
||||||
/* TODO: Check room is configured correctly, no anonymous and access to
|
if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS) {
|
||||||
* full jid */
|
|
||||||
omemo_start_muc_sessions(mucwin->roomjid);
|
omemo_start_muc_sessions(mucwin->roomjid);
|
||||||
|
|
||||||
mucwin->is_omemo = TRUE;
|
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 {
|
} else {
|
||||||
win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to start an OMEMO session.");
|
win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to start an OMEMO session.");
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ typedef struct _muc_room_t {
|
|||||||
GHashTable *nick_changes;
|
GHashTable *nick_changes;
|
||||||
gboolean roster_received;
|
gboolean roster_received;
|
||||||
muc_member_type_t member_type;
|
muc_member_type_t member_type;
|
||||||
|
muc_anonymity_type_t anonymity_type;
|
||||||
} ChatRoom;
|
} ChatRoom;
|
||||||
|
|
||||||
GHashTable *rooms = NULL;
|
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->pending_nick_change = FALSE;
|
||||||
new_room->autojoin = autojoin;
|
new_room->autojoin = autojoin;
|
||||||
new_room->member_type = MUC_MEMBER_TYPE_UNKNOWN;
|
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);
|
g_hash_table_insert(rooms, strdup(room), new_room);
|
||||||
}
|
}
|
||||||
@ -264,6 +266,13 @@ muc_set_features(const char *const room, GSList *features)
|
|||||||
} else {
|
} else {
|
||||||
chat_room->member_type = MUC_MEMBER_TYPE_PUBLIC;
|
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
|
static void
|
||||||
_free_room(ChatRoom *room)
|
_free_room(ChatRoom *room)
|
||||||
|
@ -63,6 +63,12 @@ typedef enum {
|
|||||||
MUC_MEMBER_TYPE_MEMBERS_ONLY
|
MUC_MEMBER_TYPE_MEMBERS_ONLY
|
||||||
} muc_member_type_t;
|
} 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 {
|
typedef struct _muc_occupant_t {
|
||||||
char *nick;
|
char *nick;
|
||||||
gchar *nick_collate_key;
|
gchar *nick_collate_key;
|
||||||
@ -150,5 +156,6 @@ char* muc_role_str(const char *const room);
|
|||||||
char* muc_affiliation_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_member_type_t muc_member_type(const char *const room);
|
||||||
|
muc_anonymity_type_t muc_anonymity_type(const char *const room);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user