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 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'plugins/Toaster/src/services.cpp') 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 -- cgit v1.2.3