summaryrefslogtreecommitdiff
path: root/plugins/Toaster
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-09-02 13:15:26 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-09-02 13:15:26 +0000
commite97507aef71bc2bfa51b08e598f21ffe7600880a (patch)
tree7d3e1ddb43c7c3fe016bfa271703edc5919ca256 /plugins/Toaster
parentb85839f935aec299520441b3a04864e9808d193b (diff)
Toaster: support popup classes
git-svn-id: http://svn.miranda-ng.org/main/trunk@15150 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Toaster')
-rw-r--r--plugins/Toaster/src/services.cpp33
-rw-r--r--plugins/Toaster/src/stdafx.h4
2 files changed, 35 insertions, 2 deletions
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<ToastNotification> lstNotifications(1);
+std::map<std::string, int> 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 <ShObjIdl.h>
#include <propvarutil.h>
#include <memory>
-
+#include <map>
#include <newpluginapi.h>
#include <m_system_cpp.h>
#include <m_langpack.h>
@@ -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);