diff options
author | codedust <codedust@users.noreply.github.com> | 2018-08-20 02:59:58 +0200 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2018-11-02 15:14:35 +0100 |
commit | 1e54a442ba78cd117c0262b9b5e83ef4438e5858 (patch) | |
tree | 025be91fe62a1284ac911a7919792afe2bce1ea2 | |
parent | 4ad07fea47e9e3463e864673b9c601b304b05270 (diff) | |
download | dino-1e54a442ba78cd117c0262b9b5e83ef4438e5858.tar.gz dino-1e54a442ba78cd117c0262b9b5e83ef4438e5858.zip |
Display room name in conversation selector and conversation titlebar
-rw-r--r-- | libdino/src/service/muc_manager.vala | 6 | ||||
-rw-r--r-- | main/src/ui/conversation_selector/conversation_row.vala | 2 | ||||
-rw-r--r-- | main/src/ui/conversation_selector/groupchat_row.vala | 6 | ||||
-rw-r--r-- | main/src/ui/conversation_titlebar/view.vala | 23 | ||||
-rw-r--r-- | main/src/ui/util/helper.vala | 8 | ||||
-rw-r--r-- | xmpp-vala/src/module/xep/0045_muc/module.vala | 13 |
6 files changed, 42 insertions, 16 deletions
diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala index a0f7fe70..98700c60 100644 --- a/libdino/src/service/muc_manager.vala +++ b/libdino/src/service/muc_manager.vala @@ -12,6 +12,7 @@ public class MucManager : StreamInteractionModule, Object { public signal void enter_error(Account account, Jid jid, Xep.Muc.MucEnterError error); 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 bookmarks_updated(Account account, Gee.List<Xep.Bookmarks.Conference> conferences); private StreamInteractor stream_interactor; @@ -42,7 +43,7 @@ public class MucManager : StreamInteractionModule, Object { Entities.Message? last_message = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(conversation); if (last_message != null) history_since = last_message.time; } - + stream.get_module(Xep.Muc.Module.IDENTITY).enter(stream, jid.bare_jid, nick_, password, history_since); } @@ -242,6 +243,9 @@ public class MucManager : StreamInteractionModule, Object { stream_interactor.module_manager.get_module(account, Xep.Muc.Module.IDENTITY).subject_set.connect( (stream, subject, jid) => { subject_set(account, jid, subject); }); + 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.Bookmarks.Module.IDENTITY).received_conferences.connect( (stream, conferences) => { sync_autojoin_active(account, conferences); bookmarks_updated(account, conferences); diff --git a/main/src/ui/conversation_selector/conversation_row.vala b/main/src/ui/conversation_selector/conversation_row.vala index d79b840b..ea0aeeb4 100644 --- a/main/src/ui/conversation_selector/conversation_row.vala +++ b/main/src/ui/conversation_selector/conversation_row.vala @@ -61,7 +61,7 @@ public abstract class ConversationRow : ListBoxRow { update_read(); } - protected void update_name_label(string? new_name = null) { + protected void update_name_label() { name_label.label = Util.get_conversation_display_name(stream_interactor, conversation); } diff --git a/main/src/ui/conversation_selector/groupchat_row.vala b/main/src/ui/conversation_selector/groupchat_row.vala index fdbfa40b..70b24dfd 100644 --- a/main/src/ui/conversation_selector/groupchat_row.vala +++ b/main/src/ui/conversation_selector/groupchat_row.vala @@ -12,6 +12,12 @@ public class GroupchatRow : ConversationRow { closed.connect(() => { stream_interactor.get_module(MucManager.IDENTITY).part(conversation.account, conversation.counterpart); }); + + stream_interactor.get_module(MucManager.IDENTITY).room_name_set.connect((account, jid, room_name) => { + if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) { + update_name_label(); + } + }); } protected override void update_message_label() { diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala index 4ca57e1c..924ca15e 100644 --- a/main/src/ui/conversation_titlebar/view.vala +++ b/main/src/ui/conversation_titlebar/view.vala @@ -36,9 +36,15 @@ public class ConversationTitlebar : Gtk.HeaderBar { } + stream_interactor.get_module(MucManager.IDENTITY).room_name_set.connect((account, jid, room_name) => { + if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) { + update_title(); + } + }); + stream_interactor.get_module(MucManager.IDENTITY).subject_set.connect((account, jid, subject) => { if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) { - update_subtitle(subject); + update_subtitle(); } }); } @@ -57,17 +63,10 @@ public class ConversationTitlebar : Gtk.HeaderBar { set_title(Util.get_conversation_display_name(stream_interactor, conversation)); } - private void update_subtitle(string? subtitle = null) { - if (subtitle != null) { - set_subtitle(subtitle); - } else if (conversation.type_ == Conversation.Type.GROUPCHAT) { - string? subject = stream_interactor.get_module(MucManager.IDENTITY).get_groupchat_subject(conversation.counterpart, conversation.account); - if (subject != null) { - subject = (new Regex("\\s+")).replace_literal(subject, -1, 0, " "); - } - set_subtitle(subject != "" ? subject : null); - } else { - set_subtitle(null); + private void update_subtitle() { + if (conversation.type_ == Conversation.Type.GROUPCHAT) { + string groupchat_subject = stream_interactor.get_module(MucManager.IDENTITY).get_groupchat_subject(conversation.counterpart, conversation.account); + set_subtitle(groupchat_subject); } } } diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index 9472c965..e2c8840f 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -59,7 +59,13 @@ public static string get_conversation_display_name(StreamInteractor stream_inter } public static string get_display_name(StreamInteractor stream_interactor, Jid jid, Account account) { - if (stream_interactor.get_module(MucManager.IDENTITY).is_groupchat_occupant(jid, account)) { + if (stream_interactor.get_module(MucManager.IDENTITY).is_groupchat(jid, account)) { + string room_name = stream_interactor.get_module(MucManager.IDENTITY).get_room_name(account, jid); + if (room_name != null) { + return room_name; + } + return jid.bare_jid.to_string(); + } else if (stream_interactor.get_module(MucManager.IDENTITY).is_groupchat_occupant(jid, account)) { return jid.resourcepart; } else { if (jid.equals_bare(account.bare_jid)) { diff --git a/xmpp-vala/src/module/xep/0045_muc/module.vala b/xmpp-vala/src/module/xep/0045_muc/module.vala index b0a22d6b..955ea89b 100644 --- a/xmpp-vala/src/module/xep/0045_muc/module.vala +++ b/xmpp-vala/src/module/xep/0045_muc/module.vala @@ -60,7 +60,7 @@ public class Module : XmppStreamModule { public signal void received_occupant_jid(XmppStream stream, Jid jid, Jid? real_jid); public signal void received_occupant_role(XmppStream stream, Jid jid, Role? role); public signal void subject_set(XmppStream stream, string? subject, Jid jid); - public signal void room_configuration_changed(XmppStream stream, Jid jid, StatusCode code); + public signal void room_name_set(XmppStream stream, Jid jid, string? room_name); public signal void room_entered(XmppStream stream, Jid jid, string nick); public signal void room_enter_error(XmppStream stream, Jid jid, MucEnterError? error); // TODO "?" shoudln't be necessary (vala bug), remove someday @@ -207,6 +207,16 @@ public class Module : XmppStreamModule { stream.get_flag(Flag.IDENTITY).set_muc_subject(message.from, subject); subject_set(stream, subject, message.from); } + + StanzaNode? x_node = message.stanza.get_subnode("x", NS_URI_USER); + if (x_node != null) { + StanzaNode? status_node = x_node.get_subnode("status", NS_URI_USER); + if (status_node != null && status_node.get_attribute_int("code") == 104) { + // room configuration has changed (e.g. room name) + // https://xmpp.org/extensions/xep-0045.html#roomconfig-notify + query_room_info(stream, message.from.bare_jid); + } + } } } @@ -320,6 +330,7 @@ public class Module : XmppStreamModule { foreach (ServiceDiscovery.Identity identity in query_result.identities) { if (identity.category == "conference") { stream.get_flag(Flag.IDENTITY).set_room_name(jid, identity.name); + room_name_set(stream, jid, identity.name); } } |