// C++/WinRT v2.0.250303.1 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #ifndef WINRT_Windows_UI_Notifications_Management_H #define WINRT_Windows_UI_Notifications_Management_H #include "winrt/base.h" static_assert(winrt::check_version(CPPWINRT_VERSION, "2.0.250303.1"), "Mismatched C++/WinRT headers."); #define CPPWINRT_VERSION "2.0.250303.1" #include "winrt/Windows.UI.Notifications.h" #include "winrt/impl/Windows.Foundation.2.h" #include "winrt/impl/Windows.Foundation.Collections.2.h" #include "winrt/impl/Windows.UI.Notifications.2.h" #include "winrt/impl/Windows.UI.Notifications.Management.2.h" namespace winrt::impl { template auto consume_Windows_UI_Notifications_Management_IUserNotificationListener::RequestAccessAsync() const { void* operation{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->RequestAccessAsync(&operation)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->RequestAccessAsync(&operation)); } return winrt::Windows::Foundation::IAsyncOperation{ operation, take_ownership_from_abi }; } template auto consume_Windows_UI_Notifications_Management_IUserNotificationListener::GetAccessStatus() const { winrt::Windows::UI::Notifications::Management::UserNotificationListenerAccessStatus result{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->GetAccessStatus(reinterpret_cast(&result))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->GetAccessStatus(reinterpret_cast(&result))); } return result; } template auto consume_Windows_UI_Notifications_Management_IUserNotificationListener::NotificationChanged(winrt::Windows::Foundation::TypedEventHandler const& handler) const { winrt::event_token token{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->add_NotificationChanged(*(void**)(&handler), put_abi(token))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->add_NotificationChanged(*(void**)(&handler), put_abi(token))); } return token; } template auto consume_Windows_UI_Notifications_Management_IUserNotificationListener::NotificationChanged(auto_revoke_t, winrt::Windows::Foundation::TypedEventHandler const& handler) const { return impl::make_event_revoker(this, NotificationChanged(handler)); } template auto consume_Windows_UI_Notifications_Management_IUserNotificationListener::NotificationChanged(winrt::event_token const& token) const noexcept { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; _winrt_abi_type->remove_NotificationChanged(impl::bind_in(token)); } else { auto const _winrt_abi_type = *(abi_t**)this; _winrt_abi_type->remove_NotificationChanged(impl::bind_in(token)); } } template auto consume_Windows_UI_Notifications_Management_IUserNotificationListener::GetNotificationsAsync(winrt::Windows::UI::Notifications::NotificationKinds const& kinds) const { void* operation{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->GetNotificationsAsync(static_cast(kinds), &operation)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->GetNotificationsAsync(static_cast(kinds), &operation)); } return winrt::Windows::Foundation::IAsyncOperation>{ operation, take_ownership_from_abi }; } template auto consume_Windows_UI_Notifications_Management_IUserNotificationListener::GetNotification(uint32_t notificationId) const { void* result{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->GetNotification(notificationId, &result)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->GetNotification(notificationId, &result)); } return winrt::Windows::UI::Notifications::UserNotification{ result, take_ownership_from_abi }; } template auto consume_Windows_UI_Notifications_Management_IUserNotificationListener::ClearNotifications() const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->ClearNotifications()); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->ClearNotifications()); } } template auto consume_Windows_UI_Notifications_Management_IUserNotificationListener::RemoveNotification(uint32_t notificationId) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->RemoveNotification(notificationId)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->RemoveNotification(notificationId)); } } template auto consume_Windows_UI_Notifications_Management_IUserNotificationListenerStatics::Current() const { void* value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_Current(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_Current(&value)); } return winrt::Windows::UI::Notifications::Management::UserNotificationListener{ value, take_ownership_from_abi }; } #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall RequestAccessAsync(void** operation) noexcept final try { clear_abi(operation); typename D::abi_guard guard(this->shim()); *operation = detach_from>(this->shim().RequestAccessAsync()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall GetAccessStatus(int32_t* result) noexcept final try { typename D::abi_guard guard(this->shim()); *result = detach_from(this->shim().GetAccessStatus()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall add_NotificationChanged(void* handler, winrt::event_token* token) noexcept final try { zero_abi(token); typename D::abi_guard guard(this->shim()); *token = detach_from(this->shim().NotificationChanged(*reinterpret_cast const*>(&handler))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall remove_NotificationChanged(winrt::event_token token) noexcept final { typename D::abi_guard guard(this->shim()); this->shim().NotificationChanged(*reinterpret_cast(&token)); return 0; } int32_t __stdcall GetNotificationsAsync(uint32_t kinds, void** operation) noexcept final try { clear_abi(operation); typename D::abi_guard guard(this->shim()); *operation = detach_from>>(this->shim().GetNotificationsAsync(*reinterpret_cast(&kinds))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall GetNotification(uint32_t notificationId, void** result) noexcept final try { clear_abi(result); typename D::abi_guard guard(this->shim()); *result = detach_from(this->shim().GetNotification(notificationId)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall ClearNotifications() noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().ClearNotifications(); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall RemoveNotification(uint32_t notificationId) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().RemoveNotification(notificationId); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall get_Current(void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().Current()); return 0; } catch (...) { return to_hresult(); } }; #endif } WINRT_EXPORT namespace winrt::Windows::UI::Notifications::Management { inline auto UserNotificationListener::Current() { return impl::call_factory_cast([](IUserNotificationListenerStatics const& f) { return f.Current(); }); } } namespace std { #ifndef WINRT_LEAN_AND_MEAN template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; #endif #ifdef __cpp_lib_format #endif } #endif