From be0e1841b89d11ecbea93d227c1ec21be6dd6169 Mon Sep 17 00:00:00 2001 From: LAGonauta Date: Sat, 27 Feb 2021 12:52:03 -0300 Subject: [PATCH] Anitial builder --- plugins/windows-notification/CMakeLists.txt | 1 + .../api/src/converter.cpp | 2 +- .../src/toast_notification_builder.vala | 166 ++++++++++++++++++ .../src/windows_notifications_plugin.vala | 100 ++--------- 4 files changed, 182 insertions(+), 87 deletions(-) create mode 100644 plugins/windows-notification/src/toast_notification_builder.vala diff --git a/plugins/windows-notification/CMakeLists.txt b/plugins/windows-notification/CMakeLists.txt index 9cef5965..915fd121 100644 --- a/plugins/windows-notification/CMakeLists.txt +++ b/plugins/windows-notification/CMakeLists.txt @@ -12,6 +12,7 @@ vala_precompile(WINDOWS_NOTIFICATION_VALA_C SOURCES src/windows_notifications_plugin.vala src/windows_notifications_register_plugin.vala + src/toast_notification_builder.vala # src/win_notification_provider.vala CUSTOM_VAPIS ${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi diff --git a/plugins/windows-notification/api/src/converter.cpp b/plugins/windows-notification/api/src/converter.cpp index b6ab3c7b..67a52071 100644 --- a/plugins/windows-notification/api/src/converter.cpp +++ b/plugins/windows-notification/api/src/converter.cpp @@ -10,7 +10,7 @@ char* wsview_to_char(const std::wstring_view wstr) return nullptr; } int final_size = WideCharToMultiByte(CP_UTF8, 0, wstr.data(), (int)wstr.size(), nullptr, 0, nullptr, nullptr); - char* strTo = new char[final_size]; + char* strTo = new char[final_size + 1]{ 0 }; WideCharToMultiByte(CP_UTF8, 0, wstr.data(), (int)wstr.size(), strTo, final_size, nullptr, nullptr); return strTo; } diff --git a/plugins/windows-notification/src/toast_notification_builder.vala b/plugins/windows-notification/src/toast_notification_builder.vala new file mode 100644 index 00000000..6abf3f65 --- /dev/null +++ b/plugins/windows-notification/src/toast_notification_builder.vala @@ -0,0 +1,166 @@ +using Dino.Entities; +using Dino.Plugins.WindowsNotification.Vapi; +using winrt.Windows.UI.Notifications; +using Dino.Plugins.WindowsNotification.Vapi.Win32Api; +using Xmpp; + +namespace Dino.Plugins.WindowsNotification { + private delegate void NodeFunction(StanzaNode node); + private class Button { + public string title; + public string arguments; + } + + public class ToastNotificationBuilder { + private static bool _supportsModernFeatures = SupportsModernNotifications(); + private Gee.List