aboutsummaryrefslogtreecommitdiff
path: root/plugins/notification-sound/src/plugin.vala
blob: e014d1061e93b709425233f3248fc67885920573 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
namespace Dino.Plugins.NotificationSound {

public class Plugin : RootInterface, Object {

    public Dino.Application app;
    private Canberra.Context sound_context;

    public void registered(Dino.Application app) {
        this.app = app;
        Canberra.Context.create(out sound_context);
        string sound_id = "",
            description = "Unknown notification";

        var? module = app.stream_interactor.get_module(NotificationEvents.IDENTITY);

        if (module == null)
            return;

        module.notify_content_item.connect((item, conversation) => {
            switch (item.type_) {
                case MessageItem.TYPE:
                    description = "New Dino message";
                    sound_id = "message-new-instant";
                    break;
                case CallItem.TYPE:
                    description = "Incoming call";
                    sound_id = "phone-incoming-call";
                    break;
                case FileItem.TYPE:
                    description = "Incoming file";
                    sound_id = "message-new-instant";
                    break;
            }

            sound_context.play(0,
                Canberra.PROP_EVENT_ID,
                sound_id,
                Canberra.PROP_EVENT_DESCRIPTION,
                description);
        });
    }

    public void shutdown() { }
}

}