summaryrefslogtreecommitdiff
path: root/plugins/Toaster/src/services.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-09-15 12:28:41 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-09-15 12:28:41 +0000
commit7d17df97bb5dc0c604a8ed1722f8dba9ea8c56fd (patch)
tree907986661bd629f9e1fdc236e07e8912f4483471 /plugins/Toaster/src/services.cpp
parentb4e932fe7025e034972ae3adbb04c61ed78f0120 (diff)
Toaster: code optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@15358 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Toaster/src/services.cpp')
-rw-r--r--plugins/Toaster/src/services.cpp47
1 files changed, 31 insertions, 16 deletions
diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp
index 91e2e4aaa3..fca3a833e8 100644
--- a/plugins/Toaster/src/services.cpp
+++ b/plugins/Toaster/src/services.cpp
@@ -19,8 +19,7 @@ void __stdcall ShowToastNotification(void* p)
if (ProtoServiceExists(szProto, PS_GETAVATARINFO))
{
- PROTO_AVATAR_INFORMATION pai = { 0 };
- pai.hContact = td->hContact;
+ PROTO_AVATAR_INFORMATION pai = { td->hContact };
if (CallProtoService(szProto, PS_GETAVATARINFO, 0, (LPARAM)&pai) == GAIR_SUCCESS)
{
imagePath = mir_tstrdup(pai.filename);
@@ -29,17 +28,20 @@ void __stdcall ShowToastNotification(void* p)
if (imagePath == NULL)
{
- if (td->iType == 1 && td->hBitmap && !szProto)
+ if (szProto)
{
- imagePath = ToasterImage(td->hBitmap);
- }
- else if (td->iType == 2 && td->hIcon && !szProto)
- {
- imagePath = ToasterImage(td->hIcon);
+ imagePath = ToasterImage(szProto);
}
- else if (szProto)
+ else
{
- imagePath = ToasterImage(szProto);
+ if (td->iType == 1 && td->hBitmap)
+ {
+ imagePath = ToasterImage(td->hBitmap);
+ }
+ else if (td->iType == 2 && td->hIcon)
+ {
+ imagePath = ToasterImage(td->hIcon);
+ }
}
}
}
@@ -57,7 +59,7 @@ void __stdcall ShowToastNotification(void* p)
if (SUCCEEDED(hr))
{
ToastHandlerData *thd = new ToastHandlerData();
- thd->hContact = td->hContact;
+ thd->hContact = td->hContact;
thd->vPopupData = td->vPopupData;
thd->pPopupProc = td->pPopupProc;
thd->tstNotification = notification;
@@ -148,7 +150,7 @@ static INT_PTR RegisterClass(WPARAM, LPARAM lParam)
mp_Classes[pc->pszName] = cd;
- return (INT_PTR)cd->handle;
+ return (INT_PTR)cd;
}
static INT_PTR CreateClassPopup(WPARAM, LPARAM lParam)
@@ -180,11 +182,10 @@ static INT_PTR CreateClassPopup(WPARAM, LPARAM lParam)
static INT_PTR UnRegisterClass(WPARAM, LPARAM lParam)
{
- HANDLE h = (HANDLE)lParam;
for (auto it = mp_Classes.begin(); it != mp_Classes.end(); it++)
{
- if (it->second->handle == h)
+ if (it->second == (void*)lParam)
{
delete it->second;
mp_Classes.erase(it);
@@ -230,10 +231,24 @@ static INT_PTR PopupQuery(WPARAM wParam, LPARAM)
}
}
-static INT_PTR ShowMessage(WPARAM wParam, LPARAM)
+static INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam)
{
+ HICON hIcon = NULL;
+ switch (lParam)
+ {
+ case SM_WARNING:
+ hIcon = Skin_LoadIcon(SKINICON_WARNING);
+ break;
+ case SM_ERROR:
+ hIcon = Skin_LoadIcon(SKINICON_ERROR);
+ break;
+ case SM_NOTIFY:
+ hIcon = Skin_LoadIcon(SKINICON_INFORMATION);
+ break;
+ }
+
ptrT tszText(mir_utf8decodeT((char*)wParam));
- ToastData *td = new ToastData(NULL, NULL, tszText, HICON(0));
+ ToastData *td = new ToastData(NULL, NULL, tszText, hIcon);
CallFunctionAsync(&ShowToastNotification, td);