summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-08-30 07:11:11 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-08-30 07:11:11 +0000
commita46baf1a0315e63a3e08b2272622831194cf7b11 (patch)
treeac11c05e1dffcb5bd77e8ea16097d6ae6f91c677
parenta3441bbbcdef9558827f3223511871a1695cee8f (diff)
Toaster: code cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@15111 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Toaster/src/services.cpp14
-rw-r--r--plugins/Toaster/src/toast_event_handler.cpp5
-rw-r--r--plugins/Toaster/src/toast_notification.cpp3
3 files changed, 12 insertions, 10 deletions
diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp
index 03475b5f38..a2747758e8 100644
--- a/plugins/Toaster/src/services.cpp
+++ b/plugins/Toaster/src/services.cpp
@@ -26,7 +26,6 @@ static void __cdecl OnToastNotificationClicked(void* arg)
CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce);
}
}
- lstNotifications.remove(cb->notification);
}
static void ShowToastNotification(TCHAR* text, TCHAR* title, MCONTACT hContact)
@@ -45,15 +44,16 @@ static void ShowToastNotification(TCHAR* text, TCHAR* title, MCONTACT hContact)
{
PROTO_AVATAR_INFORMATION pai = { 0 };
pai.hContact = hContact;
- CallProtoService(szProto, PS_GETAVATARINFO, (WPARAM)0, (LPARAM)&pai);
- imagePath = pai.filename[0] ? mir_tstrdup(pai.filename) : nullptr;
+ if (CallProtoService(szProto, PS_GETAVATARINFO, 0, (LPARAM)&pai) == GAIR_SUCCESS)
+ {
+ imagePath = mir_tstrdup(pai.filename);
+ }
}
}
- ToastNotification* notification = new ToastNotification (text, title, imagePath);
- arg->notification = notification;
- notification->Show(new ToastEventHandler(OnToastNotificationClicked, arg));
- lstNotifications.insert(notification);
+ arg->notification = new ToastNotification(text, title, imagePath);
+ arg->notification->Show(new ToastEventHandler(OnToastNotificationClicked, arg));
+ lstNotifications.insert(arg->notification);
}
static INT_PTR CreatePopup(WPARAM wParam, LPARAM)
diff --git a/plugins/Toaster/src/toast_event_handler.cpp b/plugins/Toaster/src/toast_event_handler.cpp
index 47ceb8d561..51689bab3e 100644
--- a/plugins/Toaster/src/toast_event_handler.cpp
+++ b/plugins/Toaster/src/toast_event_handler.cpp
@@ -52,12 +52,16 @@ IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification* /* sender */,
if (_callback != nullptr)
_callback(_arg);
+ callbackArg *cb = (callbackArg*)_arg;
+ mir_cslock lck(csNotifications);
+ lstNotifications.remove(cb->notification);
return S_OK;
}
IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification* /* sender */, _In_ IToastDismissedEventArgs* /* e */)
{
callbackArg *cb = (callbackArg*)_arg;
+ mir_cslock lck(csNotifications);
lstNotifications.remove(cb->notification);
return S_OK;
}
@@ -65,6 +69,7 @@ IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification* /* sender */,
IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification* /* sender */, _In_ IToastFailedEventArgs* /* e */)
{
callbackArg *cb = (callbackArg*)_arg;
+ mir_cslock lck(csNotifications);
lstNotifications.remove(cb->notification);
return S_OK;
} \ No newline at end of file
diff --git a/plugins/Toaster/src/toast_notification.cpp b/plugins/Toaster/src/toast_notification.cpp
index c3c4b506f4..47f98dbf28 100644
--- a/plugins/Toaster/src/toast_notification.cpp
+++ b/plugins/Toaster/src/toast_notification.cpp
@@ -223,9 +223,6 @@ HRESULT ToastNotification::Show(_In_ ToastEventHandler* handler)
EventRegistrationToken activatedToken, dismissedToken, failedToken;
Microsoft::WRL::ComPtr<ToastEventHandler> eventHandler(handler);
- hr = notification->add_Activated(eventHandler.Get(), &activatedToken);
- if (FAILED(hr))
- return hr;
notification->add_Activated(eventHandler.Get(), &activatedToken);
notification->add_Dismissed(eventHandler.Get(), &dismissedToken);