diff options
author | fiaxh <git@mx.ax.lt> | 2017-03-10 19:53:24 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-03-10 19:53:24 +0100 |
commit | 24b55d83a1f9e21b028c8d5ac9778e75565f417d (patch) | |
tree | 195b0f332e32d08e1a18fc3d8a5a6725c5ed11d7 /client/src/ui/notifications.vala | |
parent | 4c48c5c16d5f5b010c2e5dfb1affcb59f937510c (diff) | |
parent | 29ca70a6d534e1cd79963718c793ae740318cff1 (diff) | |
download | dino-24b55d83a1f9e21b028c8d5ac9778e75565f417d.tar.gz dino-24b55d83a1f9e21b028c8d5ac9778e75565f417d.zip |
Merge branch 'master' of github.com:dino/dino
Diffstat (limited to 'client/src/ui/notifications.vala')
-rw-r--r-- | client/src/ui/notifications.vala | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/client/src/ui/notifications.vala b/client/src/ui/notifications.vala deleted file mode 100644 index 17636995..00000000 --- a/client/src/ui/notifications.vala +++ /dev/null @@ -1,57 +0,0 @@ -using Dino.Entities; -using Xmpp; - -namespace Dino.Ui { - -public class Notifications : GLib.Object { - - private StreamInteractor stream_interactor; - private Notify.Notification notification = new Notify.Notification("", null, null); - - public Notifications(StreamInteractor stream_interactor) { - this.stream_interactor = stream_interactor; - } - - public void start() { - MessageManager.get_instance(stream_interactor).message_received.connect(on_message_received); - PresenceManager.get_instance(stream_interactor).received_subscription_request.connect(on_received_subscription_request); - } - - private void on_message_received(Entities.Message message, Conversation conversation) { - if (!ChatInteraction.get_instance(stream_interactor).is_active_focus()) { - string display_name = Util.get_conversation_display_name(stream_interactor, conversation); - if (MucManager.get_instance(stream_interactor).is_groupchat(conversation.counterpart, conversation.account)) { - string muc_occupant = Util.get_display_name(stream_interactor, message.from, conversation.account); - display_name = muc_occupant + " in " + display_name; - } - notification.update(display_name, message.body, null); - notification.set_image_from_pixbuf((new AvatarGenerator(40, 40)).draw_conversation(stream_interactor, conversation)); - notification.set_timeout(3); - try { - notification.show(); - } catch (Error error) { } - } - } - - private void on_received_subscription_request(Jid jid, Account account) { - Notify.Notification notification = new Notify.Notification("Subscription request", jid.bare_jid.to_string(), null); - notification.set_image_from_pixbuf((new AvatarGenerator(40, 40)).draw_jid(stream_interactor, jid, account)); - notification.add_action("accept", "Accept", () => { - PresenceManager.get_instance(stream_interactor).approve_subscription(account, jid); - try { - notification.close(); - } catch (Error error) { } - }); - notification.add_action("deny", "Deny", () => { - PresenceManager.get_instance(stream_interactor).deny_subscription(account, jid); - try { - notification.close(); - } catch (Error error) { } - }); - try { - notification.show(); - } catch (Error error) { } - } -} - -}
\ No newline at end of file |