2020-10-24 22:05:35 +00:00
|
|
|
using Dino.Entities;
|
2021-02-18 09:24:53 +00:00
|
|
|
using Dino.Plugins.WindowsNotification.Vapi;
|
2021-02-24 01:05:02 +00:00
|
|
|
using winrt.Windows.UI.Notifications;
|
2021-02-26 11:31:07 +00:00
|
|
|
using Xmpp;
|
2020-10-24 22:05:35 +00:00
|
|
|
|
|
|
|
namespace Dino.Plugins.WindowsNotification {
|
|
|
|
public class Plugin : RootInterface, Object {
|
|
|
|
|
2021-02-18 09:24:53 +00:00
|
|
|
private static string AUMID = "org.dino.Dino";
|
2021-02-24 01:05:02 +00:00
|
|
|
private ToastNotifier notifier;
|
2021-02-27 15:52:03 +00:00
|
|
|
private ToastNotification notification; // Notifications remove their actions when they go out of scope
|
2021-02-26 11:31:07 +00:00
|
|
|
|
2020-10-24 22:05:35 +00:00
|
|
|
public void registered(Dino.Application app) {
|
2021-02-21 20:03:24 +00:00
|
|
|
if (!winrt.InitApartment())
|
2021-03-26 11:22:55 +00:00
|
|
|
{
|
2021-02-18 09:24:53 +00:00
|
|
|
// log error, return
|
2020-10-24 22:30:57 +00:00
|
|
|
}
|
2021-03-26 11:22:55 +00:00
|
|
|
|
2021-02-18 09:24:53 +00:00
|
|
|
if (!Win32Api.SetAppModelID(AUMID))
|
|
|
|
{
|
|
|
|
// log error, return
|
|
|
|
}
|
2021-03-26 11:22:55 +00:00
|
|
|
|
2021-02-18 09:24:53 +00:00
|
|
|
if (!ShortcutCreator.TryCreateShortcut(AUMID))
|
2021-03-26 11:22:55 +00:00
|
|
|
{
|
2021-02-18 09:24:53 +00:00
|
|
|
// log error, return
|
2021-03-26 11:22:55 +00:00
|
|
|
}
|
|
|
|
|
2021-02-18 09:24:53 +00:00
|
|
|
{
|
2021-02-27 15:52:03 +00:00
|
|
|
//var notificationBuilder = new ToastNotificationBuilder.from_string(template);
|
|
|
|
this.notification = new ToastNotificationBuilder()
|
|
|
|
.SetHeader("Hello")
|
|
|
|
.SetBody("World")
|
|
|
|
.SetImage("C:\\Users\\lfsaf\\Pictures\\14236067.png")
|
|
|
|
.AddButton("Clique aqui", "argumento")
|
|
|
|
.Build();
|
2021-02-26 11:31:07 +00:00
|
|
|
|
2021-02-24 01:05:02 +00:00
|
|
|
this.notifier = new ToastNotifier(AUMID);
|
2021-02-27 15:52:03 +00:00
|
|
|
var token = this.notification.Activated((c, d) => {
|
2021-02-26 11:31:07 +00:00
|
|
|
stdout.printf("\nYay! Activated!\n");
|
2021-02-27 15:52:03 +00:00
|
|
|
var tr = false;
|
|
|
|
if (c != null && c == "argumento") {
|
|
|
|
tr = true;
|
|
|
|
}
|
|
|
|
|
2021-02-26 11:31:07 +00:00
|
|
|
stdout.flush();
|
2021-02-24 23:26:31 +00:00
|
|
|
});
|
|
|
|
|
2021-02-24 01:05:02 +00:00
|
|
|
notifier.Show(notification);
|
2021-02-21 20:03:24 +00:00
|
|
|
}
|
2021-02-18 09:24:53 +00:00
|
|
|
|
|
|
|
// var provider = new WindowsNotificationProvider(app, Win32Api.SupportsModernNotifications());
|
|
|
|
// app.stream_interactor.get_module(NotificationEvents.IDENTITY).register_notification_provider(provider);
|
2020-10-24 22:05:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void shutdown() {
|
2020-10-25 11:07:31 +00:00
|
|
|
}
|
2020-10-24 22:05:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|