From d8e0ab406cdad73edf79123e84d0013b96a3963a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 4 Dec 2018 10:21:24 +0100 Subject: display groups w/o name by list of members For members-only, non-anonymous groups that do not have a name set we now show an automatically generated name that is generated from the list of members (offline, and online). Only the first name (before the first space) is used to keep the generated name short. The term *private room* is coined as a short hand for members only&non-anon group chats. This commit also uses the offline members list instead of the online member list to generate avatar tiles (also only in members-only, non-anon groups.) --- libdino/src/service/muc_manager.vala | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'libdino/src') diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala index 9856e229..243aeb1c 100644 --- a/libdino/src/service/muc_manager.vala +++ b/libdino/src/service/muc_manager.vala @@ -13,6 +13,7 @@ public class MucManager : StreamInteractionModule, Object { public signal void left(Account account, Jid jid); public signal void subject_set(Account account, Jid jid, string? subject); public signal void room_name_set(Account account, Jid jid, string? room_name); + public signal void private_room_occupant_updated(Account account, Jid room, Jid occupant); public signal void bookmarks_updated(Account account, Gee.List conferences); private StreamInteractor stream_interactor; @@ -97,6 +98,19 @@ public class MucManager : StreamInteractionModule, Object { return false; } + //the term `private room` is a short hand for members-only+non-anonymous rooms + public bool is_private_room(Account account, Jid jid) { + XmppStream? stream = stream_interactor.get_stream(account); + if (stream == null) { + return false; + } + Xep.Muc.Flag? flag = stream.get_flag(Xep.Muc.Flag.IDENTITY); + if (flag == null) { + return false; + } + return flag.has_room_feature(jid, Xep.Muc.Feature.NON_ANONYMOUS) && flag.has_room_feature(jid, Xep.Muc.Feature.MEMBERS_ONLY); + } + public Gee.List? get_occupants(Jid jid, Account account) { if (is_groupchat(jid, account)) { Gee.List ret = new ArrayList(Jid.equals_func); @@ -203,6 +217,14 @@ public class MucManager : StreamInteractionModule, Object { return null; } + public Gee.List? get_other_offline_members(Jid jid, Account account) { + Gee.List? occupants = get_offline_members(jid, account); + if (occupants != null) { + occupants.remove(account.bare_jid); + } + return occupants; + } + public Jid? get_own_jid(Jid muc_jid, Account account) { Xep.Muc.Flag? flag = get_muc_flag(account); if (flag != null) { @@ -241,6 +263,11 @@ public class MucManager : StreamInteractionModule, Object { stream_interactor.module_manager.get_module(account, Xep.Muc.Module.IDENTITY).room_name_set.connect( (stream, jid, room_name) => { room_name_set(account, jid, room_name); }); + stream_interactor.module_manager.get_module(account, Xep.Muc.Module.IDENTITY).received_occupant_jid.connect( (stream, room, occupant) => { + if (is_private_room(account, room.bare_jid)) { + private_room_occupant_updated(account, room, occupant); + } + }); stream_interactor.module_manager.get_module(account, Xep.Bookmarks.Module.IDENTITY).received_conferences.connect( (stream, conferences) => { sync_autojoin_active(account, conferences); bookmarks_updated(account, conferences); -- cgit v1.2.3-70-g09d2