diff options
author | fiaxh <git@lightrise.org> | 2019-08-22 16:05:28 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2019-08-22 16:05:28 +0200 |
commit | 130965f322ea58d3d2bbce5ee6ac31dae2d3a659 (patch) | |
tree | 1ece66670d82eac674ee82ebe84a7ca487047d69 /main/src/ui/application.vala | |
parent | 0521afa3d828ea0dfc79e6c5c76697e2a3a270c0 (diff) | |
download | dino-130965f322ea58d3d2bbce5ee6ac31dae2d3a659.tar.gz dino-130965f322ea58d3d2bbce5ee6ac31dae2d3a659.zip |
Add incoming mediated invitation support (#162)
Co-authored-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Diffstat (limited to 'main/src/ui/application.vala')
-rw-r--r-- | main/src/ui/application.vala | 49 |
1 files changed, 32 insertions, 17 deletions
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<string, string> 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<Account> 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[]{"<Ctrl>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(); + } } |