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/notifications.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/notifications.vala')
-rw-r--r-- | main/src/ui/notifications.vala | 18 |
1 files changed, 18 insertions, 0 deletions
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; |