diff --git a/plugins/windows-notification/api/include/gobject/winrt.h b/plugins/windows-notification/api/include/gobject/winrt.h index 82d72e67..10c4feef 100644 --- a/plugins/windows-notification/api/include/gobject/winrt.h +++ b/plugins/windows-notification/api/include/gobject/winrt.h @@ -8,15 +8,17 @@ #include "winrt-enums.h" #ifdef __cplusplus -extern "C" -{ +#define EXTERN extern "C" +#define NOEXCEPT noexcept +#else +#define EXTERN +#define NOEXCEPT #endif -gboolean winrt_InitApartment(); -char* winrt_windows_ui_notifications_toast_notification_manager_GetTemplateContent(winrtWindowsUINotificationsToastTemplateType type); +EXTERN gboolean winrt_InitApartment(); +EXTERN char* winrt_windows_ui_notifications_toast_notification_manager_GetTemplateContent(winrtWindowsUINotificationsToastTemplateType type) NOEXCEPT; -#ifdef __cplusplus -} -#endif +#undef EXTERN +#undef NOEXCEPT -#endif // __WINRT_GLIB_2_H__ \ No newline at end of file +#endif // __WINRT_GLIB_2_H__ diff --git a/plugins/windows-notification/api/src/gobject/winrt.cpp b/plugins/windows-notification/api/src/gobject/winrt.cpp index 1b9965aa..d3d1e302 100644 --- a/plugins/windows-notification/api/src/gobject/winrt.cpp +++ b/plugins/windows-notification/api/src/gobject/winrt.cpp @@ -2,6 +2,7 @@ #include "gobject/winrt-private.h" #include "converter.hpp" +#include "ginvoke.hpp" gboolean winrt_InitApartment() { @@ -24,8 +25,13 @@ gboolean winrt_InitApartment() return false; } -char* winrt_windows_ui_notifications_toast_notification_manager_GetTemplateContent(winrtWindowsUINotificationsToastTemplateType type) +static char* ImplGetTemplateContent(winrtWindowsUINotificationsToastTemplateType type) { using namespace winrt::Windows::UI::Notifications; return wsview_to_char(ToastNotificationManager::GetTemplateContent(static_cast(type)).GetXml()); -} \ No newline at end of file +} + +char* winrt_windows_ui_notifications_toast_notification_manager_GetTemplateContent(winrtWindowsUINotificationsToastTemplateType type) noexcept +{ + return g_try_invoke(ImplGetTemplateContent, type).value_or(nullptr); +}