47 lines
1.3 KiB
Vala
47 lines
1.3 KiB
Vala
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() { }
|
|
}
|
|
|
|
}
|