From 62384056910fc8fef88e1d99c62b3fe7ac313ac2 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sat, 12 Sep 2015 10:36:30 +0000 Subject: Toaster: removed crutches, normal event handler git-svn-id: http://svn.miranda-ng.org/main/trunk@15330 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Toaster/src/toast_event_handler.cpp | 32 +++++++++++++---------------- 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'plugins/Toaster/src/toast_event_handler.cpp') diff --git a/plugins/Toaster/src/toast_event_handler.cpp b/plugins/Toaster/src/toast_event_handler.cpp index 05e9a60601..fa97240d6f 100644 --- a/plugins/Toaster/src/toast_event_handler.cpp +++ b/plugins/Toaster/src/toast_event_handler.cpp @@ -3,17 +3,20 @@ using namespace ABI::Windows::UI::Notifications; using namespace Microsoft::WRL; -ToastEventHandler::ToastEventHandler() : _ref(1), _callback(nullptr), _arg(nullptr) +ToastEventHandler::ToastEventHandler() : _ref(1) { } -ToastEventHandler::ToastEventHandler(_In_ pEventHandler callback, _In_ void* arg) : _ref(1), _callback(callback), _arg(arg) +ToastEventHandler::ToastEventHandler(_In_ ToastHandlerData *pData) : _ref(1), _thd(pData) { } ToastEventHandler::~ToastEventHandler() { - mir_free(_arg); + _thd->pPopupProc((HWND)this, UM_FREEPLUGINDATA, 0, 0); + + mir_cslock lck(csNotifications); + lstNotifications.remove(_thd->tstNotification); } IFACEMETHODIMP_(ULONG) ToastEventHandler::AddRef() @@ -31,17 +34,17 @@ IFACEMETHODIMP_(ULONG) ToastEventHandler::Release() IFACEMETHODIMP ToastEventHandler::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void **ppv) { if (IsEqualIID(riid, IID_IUnknown)) - *ppv = static_cast(static_cast(this)); + *ppv = (IUnknown*)(DesktopToastActivatedEventHandler*)(this); else if (IsEqualIID(riid, __uuidof(DesktopToastActivatedEventHandler))) - *ppv = static_cast(this); + *ppv = (DesktopToastActivatedEventHandler*)(this); else if (IsEqualIID(riid, __uuidof(DesktopToastDismissedEventHandler))) - *ppv = static_cast(this); + *ppv = (DesktopToastDismissedEventHandler*)(this); else if (IsEqualIID(riid, __uuidof(DesktopToastFailedEventHandler))) - *ppv = static_cast(this); + *ppv = (DesktopToastFailedEventHandler*)(this); else *ppv = nullptr; if (*ppv) { - reinterpret_cast(*ppv)->AddRef(); + ((IUnknown*)*ppv)->AddRef(); return S_OK; } @@ -50,25 +53,18 @@ IFACEMETHODIMP ToastEventHandler::QueryInterface(_In_ REFIID riid, _COM_Outptr_ IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification * /*sender*/, _In_ IInspectable* /*args*/) { - if (_callback != nullptr) - _callback(_arg); - - mir_cslock lck(csNotifications); - lstNotifications.remove(((callbackArg*)_arg)->notification); + _thd->pPopupProc((HWND)this, WM_COMMAND, 0, 0); return S_OK; } IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification* /* sender */, _In_ IToastDismissedEventArgs* /*e*/) { - ((callbackArg*)_arg)->notification->Hide(); - mir_cslock lck(csNotifications); - lstNotifications.remove(((callbackArg*)_arg)->notification); + _thd->pPopupProc((HWND)this, WM_CONTEXTMENU, 0, 0); return S_OK; } IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification* /* sender */, _In_ IToastFailedEventArgs* /*e*/ ) { - mir_cslock lck(csNotifications); - lstNotifications.remove(((callbackArg*)_arg)->notification); + delete this; return S_OK; } \ No newline at end of file -- cgit v1.2.3