aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/src/ui/application.vala49
-rw-r--r--main/src/ui/notifications.vala18
2 files changed, 50 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();
+ }
}
diff --git a/main/src/ui/notifications.vala b/main/src/ui/notifications.vala
index 78e8f47e..b8792bee 100644
--- a/main/src/ui/notifications.vala
+++ b/main/src/ui/notifications.vala
@@ -44,6 +44,7 @@ public class Notifications : Object {
stream_interactor.get_module(NotificationEvents.IDENTITY).notify_content_item.connect((content_item, conversation) => notify_content_item.begin(content_item, conversation));
stream_interactor.get_module(NotificationEvents.IDENTITY).notify_subscription_request.connect(notify_subscription_request);
stream_interactor.get_module(NotificationEvents.IDENTITY).notify_connection_error.connect(notify_connection_error);
+ stream_interactor.get_module(NotificationEvents.IDENTITY).notify_muc_invite.connect(on_invite_received);
}
private async void notify_content_item(ContentItem content_item, Conversation conversation) {
@@ -117,6 +118,23 @@ public class Notifications : Object {
window.get_application().send_notification(account.id.to_string() + "-connection-error", notification);
}
+ private async void on_invite_received(Account account, Jid room_jid, Jid from_jid, string? password, string? reason) {
+ string display_name = Util.get_display_name(stream_interactor, from_jid, account);
+ string display_room = room_jid.bare_jid.to_string();
+ Notification notification = new Notification(_("Invitation to %s").printf(display_room));
+ string body = _("%s invited you to %s").printf(display_name, display_room);
+ notification.set_body(body);
+
+ Cairo.ImageSurface jid_avatar = yield (new AvatarGenerator(40, 40)).draw_jid(stream_interactor, from_jid, account);
+ notification.set_icon(get_pixbuf_icon(jid_avatar));
+
+ Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(room_jid, account, Conversation.Type.GROUPCHAT);
+ notification.set_default_action_and_target_value("app.open-muc-join", new Variant.int32(conversation.id));
+ notification.add_button_with_target_value(_("Deny"), "app.deny-invite", conversation.id);
+ notification.add_button_with_target_value(_("Accept"), "app.open-muc-join", conversation.id);
+ window.get_application().send_notification(null, notification);
+ }
+
private Icon get_pixbuf_icon(Cairo.ImageSurface surface) throws Error {
Gdk.Pixbuf avatar = Gdk.pixbuf_get_from_surface(surface, 0, 0, surface.get_width(), surface.get_height());
uint8[] buffer;