diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2018-12-04 10:21:24 +0100 |
---|---|---|
committer | fiaxh <fiaxh@users.noreply.github.com> | 2018-12-28 13:42:58 +0100 |
commit | d8e0ab406cdad73edf79123e84d0013b96a3963a (patch) | |
tree | 4de13499d19113f96b5720a0554f95a3feb707b7 /libdino/src | |
parent | 965f4da75ae5a5b308191bd61890b4277504f5b1 (diff) | |
download | dino-d8e0ab406cdad73edf79123e84d0013b96a3963a.tar.gz dino-d8e0ab406cdad73edf79123e84d0013b96a3963a.zip |
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.)
Diffstat (limited to 'libdino/src')
-rw-r--r-- | libdino/src/service/muc_manager.vala | 27 |
1 files changed, 27 insertions, 0 deletions
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<Xep.Bookmarks.Conference> 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<Jid>? get_occupants(Jid jid, Account account) { if (is_groupchat(jid, account)) { Gee.List<Jid> ret = new ArrayList<Jid>(Jid.equals_func); @@ -203,6 +217,14 @@ public class MucManager : StreamInteractionModule, Object { return null; } + public Gee.List<Jid>? get_other_offline_members(Jid jid, Account account) { + Gee.List<Jid>? 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); |