diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-08-31 07:45:19 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-08-31 07:45:19 +0000 |
commit | 291d2b6a67bf9501c5427758092805b66aa44dcf (patch) | |
tree | 079076be3a220a78fdc5e2b63077adcb407d0ef9 /plugins/Toaster/src/services.cpp | |
parent | 081f1880ea898bba1bfd2ba2ff79b5e4de929b86 (diff) |
Toaster: more fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@15124 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Toaster/src/services.cpp')
-rw-r--r-- | plugins/Toaster/src/services.cpp | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp index 689dabae4a..c5eaf84f6a 100644 --- a/plugins/Toaster/src/services.cpp +++ b/plugins/Toaster/src/services.cpp @@ -63,22 +63,24 @@ static void __cdecl OnToastNotificationClicked(void* arg) }
}
-static void ShowToastNotification(TCHAR* text, TCHAR* title, MCONTACT hContact)
+void __stdcall ShowToastNotification(void* p)
{
+ std::unique_ptr<ToastData> td((ToastData*)p);
+
if (!db_get_b(0, "Popup", "ModuleIsEnabled", 1))
return;
ptrT imagePath;
callbackArg *arg = (callbackArg*)mir_calloc(sizeof(callbackArg));
- if (hContact)
+ if (td->hContact)
{
- arg->hContact = hContact;
- const char* szProto = GetContactProto(hContact);
+ arg->hContact = td->hContact;
+ const char* szProto = GetContactProto(td->hContact);
if (ProtoServiceExists(szProto, PS_GETAVATARINFO))
{
PROTO_AVATAR_INFORMATION pai = { 0 };
- pai.hContact = hContact;
+ pai.hContact = td->hContact;
if (CallProtoService(szProto, PS_GETAVATARINFO, 0, (LPARAM)&pai) == GAIR_SUCCESS)
{
imagePath = mir_tstrdup(pai.filename);
@@ -94,7 +96,7 @@ static void ShowToastNotification(TCHAR* text, TCHAR* title, MCONTACT hContact) }
}
- arg->notification = new ToastNotification(text, title, imagePath);
+ arg->notification = new ToastNotification(td->tszText, td->tszTitle, imagePath);
HRESULT hr = arg->notification->Initialize();
if (SUCCEEDED(hr))
@@ -104,12 +106,6 @@ static void ShowToastNotification(TCHAR* text, TCHAR* title, MCONTACT hContact) }
else
{
- OutputDebugStringA(CMStringA(FORMAT, "Toaster error: HRESULT = %lld", hr));
-#ifdef _DEBUG
- DebugBreak();
-#else
- Netlib_Logf(NULL, "Toaster: " __FUNCTION__ " failed: HRESULT = %lld", hr);
-#endif
delete arg->notification;
}
}
@@ -120,7 +116,7 @@ static INT_PTR CreatePopup(WPARAM wParam, LPARAM) ptrW text(mir_a2u(ppd->lpzText));
ptrW contactName(mir_a2u(ppd->lpzContactName));
- ShowToastNotification(text, contactName, ppd->lchContact);
+ CallFunctionAsync(&ShowToastNotification, new ToastData(ppd->lchContact, contactName, text));
return 0;
}
@@ -128,9 +124,7 @@ static INT_PTR CreatePopup(WPARAM wParam, LPARAM) static INT_PTR CreatePopupW(WPARAM wParam, LPARAM)
{
POPUPDATAW *ppd = (POPUPDATAW*)wParam;
-
- ShowToastNotification(ppd->lpwzText, ppd->lpwzContactName, ppd->lchContact);
-
+ CallFunctionAsync(&ShowToastNotification, new ToastData(ppd->lchContact, ppd->lpwzContactName, ppd->lpwzText));
return 0;
}
@@ -150,7 +144,7 @@ static INT_PTR CreatePopup2(WPARAM wParam, LPARAM) title = mir_a2u(ppd->lpzTitle);
}
- ShowToastNotification(text, title, ppd->lchContact);
+ CallFunctionAsync(&ShowToastNotification, new ToastData(ppd->lchContact, title, text));
return 0;
}
@@ -169,7 +163,7 @@ static INT_PTR PopupQuery(WPARAM wParam, LPARAM) {
bool enabled = db_get_b(0, "Popup", "ModuleIsEnabled", 1) != 0;
if (enabled) db_set_b(0, "Popup", "ModuleIsEnabled", 0);
- HideAllToasts();
+ CallFunctionAsync(&HideAllToasts, NULL);
return enabled;
}
break;
@@ -182,7 +176,7 @@ static INT_PTR PopupQuery(WPARAM wParam, LPARAM) }
}
-void HideAllToasts()
+void __stdcall HideAllToasts(void*)
{
mir_cslock lck(csNotifications);
while (lstNotifications.getCount())
@@ -198,4 +192,4 @@ void InitServices() CreateServiceFunction(MS_POPUP_ADDPOPUPW, CreatePopupW);
CreateServiceFunction(MS_POPUP_ADDPOPUP2, CreatePopup2);
CreateServiceFunction(MS_POPUP_QUERY, PopupQuery);
-}
+}
\ No newline at end of file |