From 79cd4ccc87c8a4f380bd29139c71c0995e565913 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Tue, 29 Dec 2015 17:40:24 +0000 Subject: Toaster: big refactoring git-svn-id: http://svn.miranda-ng.org/main/trunk@15964 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Toaster/src/services.cpp | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) (limited to 'plugins/Toaster/src/services.cpp') diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp index 3f701b86f9..16c89edcb1 100644 --- a/plugins/Toaster/src/services.cpp +++ b/plugins/Toaster/src/services.cpp @@ -53,34 +53,17 @@ void __stdcall ShowToastNotification(void* p) } } - ToastNotification *notification = new ToastNotification(td->tszText, td->tszTitle, imagePath); - - HRESULT hr = notification->Initialize(); - if (SUCCEEDED(hr)) - { - ToastHandlerData *thd = new ToastHandlerData(); - thd->hContact = td->hContact; - thd->vPopupData = td->vPopupData; - thd->pPopupProc = td->pPopupProc; - thd->tstNotification = notification; - - notification->Show(thd); - lstNotifications.insert(notification); - } - else - { - delete notification; - } + new ToastNotification(td->tszText, td->tszTitle, imagePath, td->hContact, td->pPopupProc, td->vPopupData); } static INT_PTR GetPopupData(WPARAM wParam, LPARAM) { - return (INT_PTR)((ToastEventHandler*)wParam)->GetPluginData(); + return (INT_PTR)((ToastNotification*)wParam)->GetPluginData(); } static INT_PTR GetPopupContact(WPARAM wParam, LPARAM) { - return (INT_PTR)((ToastEventHandler*)wParam)->GetContact(); + return (INT_PTR)((ToastNotification*)wParam)->GetContact(); } static INT_PTR CreatePopup(WPARAM wParam, LPARAM) @@ -261,23 +244,18 @@ static INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam) static INT_PTR HideToast(WPARAM, LPARAM lParam) { - extern LIST lstHandlers; - ToastEventHandler* handler = reinterpret_cast(lParam); - if (lstHandlers.getIndex(handler) != -1) + ToastNotification* pNotification = reinterpret_cast(lParam); + if (lstNotifications.getIndex(pNotification) != -1) { - ToastNotification* notification = static_cast(handler->GetToastNotification()); - if (lstNotifications.getIndex(notification) != -1) - { - notification->Hide(); - } + lstNotifications.remove(pNotification); } return 0; } void __stdcall HideAllToasts(void*) { mir_cslock lck(csNotifications); - for (int i = 0; i < lstNotifications.getCount(); i++) - lstNotifications[i].Hide(); + while(lstNotifications.getCount()) + lstNotifications.remove(0); } void InitServices() -- cgit v1.2.3