From 130965f322ea58d3d2bbce5ee6ac31dae2d3a659 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 22 Aug 2019 16:05:28 +0200 Subject: Add incoming mediated invitation support (#162) Co-authored-by: Emmanuel Gil Peyrot --- main/src/ui/application.vala | 49 +++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 17 deletions(-) (limited to 'main/src/ui/application.vala') diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index 57ebe11a..d5ec0170 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -44,23 +44,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { public void handle_uri(string jid, string query, Gee.Map options) { switch (query) { case "join": - Dialog dialog = new Dialog.with_buttons(_("Join Conference"), window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.USE_HEADER_BAR, _("Join"), ResponseType.OK, _("Cancel"), ResponseType.CANCEL); - dialog.modal = true; - Button ok_button = dialog.get_widget_for_response(ResponseType.OK) as Button; - ok_button.get_style_context().add_class("suggested-action"); - ConferenceDetailsFragment conference_fragment = new ConferenceDetailsFragment(stream_interactor) { ok_button=ok_button }; - conference_fragment.jid = jid; - Box content_area = dialog.get_content_area(); - content_area.add(conference_fragment); - dialog.response.connect((response_id) => { - if (response_id == ResponseType.OK) { - stream_interactor.get_module(MucManager.IDENTITY).join(conference_fragment.account, new Jid(conference_fragment.jid), conference_fragment.nick, conference_fragment.password); - dialog.destroy(); - } else if (response_id == ResponseType.CANCEL) { - dialog.destroy(); - } - }); - dialog.present(); + show_join_muc_dialog(null, new Jid(jid)); break; case "message": Gee.List accounts = stream_interactor.get_accounts(); @@ -133,6 +117,14 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { add_action(conference_action); set_accels_for_action("app.add_conference", new string[]{"G"}); + SimpleAction accept_muc_invite_action = new SimpleAction("open-muc-join", VariantType.INT32); + accept_muc_invite_action.activate.connect((variant) => { + Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation_by_id(variant.get_int32()); + if (conversation == null) return; + show_join_muc_dialog(conversation.account, conversation.counterpart); + }); + add_action(accept_muc_invite_action); + SimpleAction loop_conversations_action = new SimpleAction("loop_conversations", null); loop_conversations_action.activate.connect(() => { window.loop_conversations(false); }); add_action(loop_conversations_action); @@ -161,5 +153,28 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { dialog.set_transient_for(get_active_window()); dialog.present(); } + + private void show_join_muc_dialog(Account? account, Jid jid) { + Dialog dialog = new Dialog.with_buttons(_("Join Conference"), window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.USE_HEADER_BAR, _("Join"), ResponseType.OK, _("Cancel"), ResponseType.CANCEL); + dialog.modal = true; + Button ok_button = dialog.get_widget_for_response(ResponseType.OK) as Button; + ok_button.get_style_context().add_class("suggested-action"); + ConferenceDetailsFragment conference_fragment = new ConferenceDetailsFragment(stream_interactor) { ok_button=ok_button }; + conference_fragment.jid = jid.to_string(); + if (account != null) { + conference_fragment.account = account; + } + Box content_area = dialog.get_content_area(); + content_area.add(conference_fragment); + dialog.response.connect((response_id) => { + if (response_id == ResponseType.OK) { + stream_interactor.get_module(MucManager.IDENTITY).join(conference_fragment.account, new Jid(conference_fragment.jid), conference_fragment.nick, conference_fragment.password); + dialog.destroy(); + } else if (response_id == ResponseType.CANCEL) { + dialog.destroy(); + } + }); + dialog.present(); + } } -- cgit v1.2.3-54-g00ecf