From e97507aef71bc2bfa51b08e598f21ffe7600880a Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Wed, 2 Sep 2015 13:15:26 +0000 Subject: Toaster: support popup classes git-svn-id: http://svn.miranda-ng.org/main/trunk@15150 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Toaster/src/services.cpp | 33 +++++++++++++++++++++++++++++++++ plugins/Toaster/src/stdafx.h | 4 ++-- 2 files changed, 35 insertions(+), 2 deletions(-) (limited to 'plugins/Toaster') diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp index 501d6a8253..36edadc576 100644 --- a/plugins/Toaster/src/services.cpp +++ b/plugins/Toaster/src/services.cpp @@ -2,6 +2,7 @@ mir_cs csNotifications; OBJLIST lstNotifications(1); +std::map mp_Classes; wchar_t wszTempDir[MAX_PATH]; __forceinline bool isChatRoom(MCONTACT hContact) @@ -161,6 +162,36 @@ static INT_PTR CreatePopup2(WPARAM wParam, LPARAM) return 0; } +static INT_PTR RegisterClass(WPARAM, LPARAM lParam) +{ + POPUPCLASS *pc = (POPUPCLASS*)lParam; + mp_Classes[pc->pszName] = pc->flags; + + HANDLE h; + Utils_GetRandom(&h, sizeof(h)); + return (INT_PTR)h; +} + +static INT_PTR CreateClassPopup(WPARAM, LPARAM lParam) +{ + POPUPDATACLASS *ppc = (POPUPDATACLASS*)lParam; + + auto it = mp_Classes.find(ppc->pszClassName); + if (it != mp_Classes.end()) + { + if (it->second & PCF_TCHAR) + { + CallFunctionAsync(&ShowToastNotification, new ToastData(ppc->hContact, ppc->ptszTitle, ppc->ptszText)); + } + else + { + CallFunctionAsync(&ShowToastNotification, new ToastData(ppc->hContact, mir_utf8decodeT(ppc->pszTitle), mir_utf8decodeT(ppc->pszText))); + } + } + + return 0; +} + static INT_PTR PopupQuery(WPARAM wParam, LPARAM) { switch (wParam) { @@ -204,4 +235,6 @@ void InitServices() CreateServiceFunction(MS_POPUP_ADDPOPUPW, CreatePopupW); CreateServiceFunction(MS_POPUP_ADDPOPUP2, CreatePopup2); CreateServiceFunction(MS_POPUP_QUERY, PopupQuery); + CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, CreateClassPopup); + CreateServiceFunction(MS_POPUP_REGISTERCLASS, RegisterClass); } \ No newline at end of file diff --git a/plugins/Toaster/src/stdafx.h b/plugins/Toaster/src/stdafx.h index 86bf5bb66c..5d8fa45407 100644 --- a/plugins/Toaster/src/stdafx.h +++ b/plugins/Toaster/src/stdafx.h @@ -8,7 +8,7 @@ #include #include #include - +#include #include #include #include @@ -56,7 +56,7 @@ struct ToastData TCHAR *tszText; HICON hIcon; - ToastData(MCONTACT _hContact, TCHAR *_tszTitle, TCHAR *_tszText, HICON _hIcon = NULL) : hContact(_hContact), tszTitle(mir_tstrdup(_tszTitle)), tszText(mir_tstrdup(_tszText)), hIcon(_hIcon) {} + ToastData(MCONTACT _hContact, const TCHAR *_tszTitle, const TCHAR *_tszText, HICON _hIcon = NULL) : hContact(_hContact), tszTitle(mir_tstrdup(_tszTitle)), tszText(mir_tstrdup(_tszText)), hIcon(_hIcon) {} ~ToastData() { mir_free(tszTitle); -- cgit v1.2.3