summaryrefslogtreecommitdiff
path: root/plugins/Toaster/src
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-09-29 13:33:25 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-09-29 13:33:25 +0000
commit98f090a525e33973738e4105b6e8257ab34ff6eb (patch)
tree6aecfaef0cc0d24eab8134fb690f92df10d8668b /plugins/Toaster/src
parent8235db586d12c56b18ebf4d1279c873b4fe7cac7 (diff)
Toaster: code optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@15471 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Toaster/src')
-rw-r--r--plugins/Toaster/src/services.cpp4
-rw-r--r--plugins/Toaster/src/toast_event_handler.cpp20
-rw-r--r--plugins/Toaster/src/toast_event_handler.h2
-rw-r--r--plugins/Toaster/src/toast_notification.cpp14
-rw-r--r--plugins/Toaster/src/toast_notification.h2
5 files changed, 19 insertions, 23 deletions
diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp
index ebfb13b3a5..8cc9beaaae 100644
--- a/plugins/Toaster/src/services.cpp
+++ b/plugins/Toaster/src/services.cpp
@@ -64,7 +64,7 @@ void __stdcall ShowToastNotification(void* p)
thd->pPopupProc = td->pPopupProc;
thd->tstNotification = notification;
- notification->Show(new ToastEventHandler(thd));
+ notification->Show(thd);
lstNotifications.insert(notification);
}
else
@@ -255,7 +255,7 @@ static INT_PTR ShowMessageW(WPARAM wParam, LPARAM lParam)
static INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam)
{
- ptrT tszText(mir_utf8decodeW((char*)wParam));
+ ptrW tszText(mir_utf8decodeW((char*)wParam));
return ShowMessageW(tszText, lParam);
}
diff --git a/plugins/Toaster/src/toast_event_handler.cpp b/plugins/Toaster/src/toast_event_handler.cpp
index 5b1bdaf1f5..e312f7a8e1 100644
--- a/plugins/Toaster/src/toast_event_handler.cpp
+++ b/plugins/Toaster/src/toast_event_handler.cpp
@@ -5,14 +5,12 @@ using namespace Microsoft::WRL;
ToastEventHandler::ToastEventHandler(_In_ ToastHandlerData *pData) : _ref(0), _thd(pData)
{
- if (_thd->pPopupProc)
- _thd->pPopupProc((HWND)this, UM_INITPOPUP, (WPARAM)this, 0);
+ CallPopupProc(UM_INITPOPUP);
}
ToastEventHandler::~ToastEventHandler()
{
- if (_thd->pPopupProc)
- _thd->pPopupProc((HWND)this, UM_FREEPLUGINDATA, 0, 0);
+ CallPopupProc(UM_FREEPLUGINDATA);
}
IFACEMETHODIMP_(ULONG) ToastEventHandler::AddRef()
@@ -46,11 +44,8 @@ IFACEMETHODIMP ToastEventHandler::QueryInterface(_In_ REFIID riid, _COM_Outptr_
IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification*, _In_ IInspectable*)
{
- if (_thd->pPopupProc)
- _thd->pPopupProc((HWND)this, WM_COMMAND, 0, 0);
-
+ CallPopupProc(WM_COMMAND);
DestroyNotification();
-
return S_OK;
}
@@ -63,8 +58,7 @@ IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification*, _In_ IToastDi
{
case ToastDismissalReason_UserCanceled:
{
- if (_thd->pPopupProc)
- _thd->pPopupProc((HWND)this, WM_CONTEXTMENU, 0, 0);
+ CallPopupProc(WM_CONTEXTMENU);
_thd->tstNotification->Hide();
break;
}
@@ -89,6 +83,12 @@ void ToastEventHandler::DestroyNotification()
lstNotifications.remove(_thd->tstNotification);
}
+void ToastEventHandler::CallPopupProc(UINT uMsg)
+{
+ if (_thd->pPopupProc)
+ _thd->pPopupProc((HWND)this, uMsg, 0, 0);
+}
+
void* ToastEventHandler::GetPluginData()
{
return _thd->vPopupData;
diff --git a/plugins/Toaster/src/toast_event_handler.h b/plugins/Toaster/src/toast_event_handler.h
index f4a74534fb..bdad152a4e 100644
--- a/plugins/Toaster/src/toast_event_handler.h
+++ b/plugins/Toaster/src/toast_event_handler.h
@@ -30,6 +30,8 @@ private:
std::unique_ptr<ToastHandlerData> _thd;
void DestroyNotification();
+
+ void CallPopupProc(UINT uMsg);
};
#endif //_TOAST_EVENT_HANDLER_H_ \ No newline at end of file
diff --git a/plugins/Toaster/src/toast_notification.cpp b/plugins/Toaster/src/toast_notification.cpp
index 0275920c64..1db63634ec 100644
--- a/plugins/Toaster/src/toast_notification.cpp
+++ b/plugins/Toaster/src/toast_notification.cpp
@@ -8,9 +8,6 @@ ToastNotification::ToastNotification(_In_ wchar_t* text, _In_ wchar_t* caption,
ToastNotification::~ToastNotification()
{
- notification->remove_Activated(_ertActivated);
- notification->remove_Dismissed(_ertDismissed);
- notification->remove_Failed(_ertFailed);
}
HRESULT ToastNotification::Initialize()
@@ -26,6 +23,7 @@ HRESULT ToastNotification::CreateXml(_Outptr_ ABI::Windows::Data::Xml::Dom::IXml
CHECKHR(Windows::Foundation::ActivateInstance(StringReferenceWrapper(RuntimeClass_Windows_Data_Xml_Dom_XmlDocument).Get(), &xmlDocument));
HXML xmlToast = xmlCreateNode(L"toast", NULL, 0);
+ xmlAddAttr(xmlToast, L"activationType", L"foreground");
HXML xmlAudioNode = xmlAddChild(xmlToast, L"audio", NULL);
xmlAddAttr(xmlAudioNode, L"silent", L"true");
@@ -33,14 +31,10 @@ HRESULT ToastNotification::CreateXml(_Outptr_ ABI::Windows::Data::Xml::Dom::IXml
HXML xmlVisualNode = xmlAddChild(xmlToast, L"visual", NULL);
HXML xmlBindingNode = xmlAddChild(xmlVisualNode, L"binding", NULL);
- xmlAddAttr(xmlBindingNode, L"template", IsWinVer10Plus() ? L"ToastGeneric" : L"ToastImageAndText02");
+ xmlAddAttr(xmlBindingNode, L"template", L"ToastImageAndText02");
if (_imagePath)
{
HXML xmlImageNode = xmlAddChild(xmlBindingNode, L"image", NULL);
-
- if (IsWinVer10Plus())
- xmlAddAttr(xmlImageNode, L"placement", L"appLogoOverride");
-
xmlAddAttr(xmlImageNode, L"id", L"1");
xmlAddAttr(xmlImageNode, L"src", CMString(FORMAT, L"file:///%s", _imagePath));
}
@@ -73,9 +67,9 @@ HRESULT ToastNotification::Create(_Outptr_ ABI::Windows::UI::Notifications::IToa
return factory->CreateToastNotification(xml.Get(), _notification);
}
-HRESULT ToastNotification::Show(_In_ ToastEventHandler* handler)
+HRESULT ToastNotification::Show(_In_ ToastHandlerData* thd)
{
- ComPtr<ToastEventHandler> eventHandler(handler);
+ ComPtr<ToastEventHandler> eventHandler(new ToastEventHandler(thd));
CHECKHR(notification->add_Activated(eventHandler.Get(), &_ertActivated));
CHECKHR(notification->add_Dismissed(eventHandler.Get(), &_ertDismissed));
diff --git a/plugins/Toaster/src/toast_notification.h b/plugins/Toaster/src/toast_notification.h
index cf86271e64..30bb591f3d 100644
--- a/plugins/Toaster/src/toast_notification.h
+++ b/plugins/Toaster/src/toast_notification.h
@@ -24,7 +24,7 @@ public:
~ToastNotification();
HRESULT Initialize();
- HRESULT Show(_In_ ToastEventHandler* handler);
+ HRESULT Show(_In_ ToastHandlerData*);
HRESULT Hide();
};