diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-09-19 16:46:00 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-09-19 16:46:00 +0000 |
commit | 22fd8863b0175f11937c43441904852eda5f9c4a (patch) | |
tree | 537e26262f9f7c08d37d2ad5020925bbffc8c344 /plugins/Toaster/src/toast_notification.cpp | |
parent | 3e31902e8049fdd12bad86353617badead391917 (diff) |
Toaster: code optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@15397 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Toaster/src/toast_notification.cpp')
-rw-r--r-- | plugins/Toaster/src/toast_notification.cpp | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/plugins/Toaster/src/toast_notification.cpp b/plugins/Toaster/src/toast_notification.cpp index 02b190a80e..acbb5d627c 100644 --- a/plugins/Toaster/src/toast_notification.cpp +++ b/plugins/Toaster/src/toast_notification.cpp @@ -4,14 +4,13 @@ using namespace Microsoft::WRL; ToastNotification::ToastNotification(_In_ wchar_t* text, _In_ wchar_t* caption, _In_ wchar_t* imagePath)
: _text(text), _caption(caption), _imagePath(imagePath)
-{
-}
+{}
ToastNotification::~ToastNotification()
{
- notification->remove_Activated(ertActivated);
- notification->remove_Dismissed(ertDismissed);
- notification->remove_Failed(ertFailed);
+ notification->remove_Activated(_ertActivated);
+ notification->remove_Dismissed(_ertDismissed);
+ notification->remove_Failed(_ertFailed);
}
HRESULT ToastNotification::Initialize()
@@ -53,13 +52,12 @@ HRESULT ToastNotification::CreateXml(_Outptr_ ABI::Windows::Data::Xml::Dom::IXml HXML xmlTextNode = xmlAddChild(xmlBindingNode, L"text", _text);
xmlAddAttr(xmlTextNode, L"id", L"2");
}
-
- TCHAR *xtmp = xmlToString(xmlToast, NULL);
- size_t xlen = mir_tstrlen(xtmp);
+ int nLength;
+ TCHAR *xtmp = xmlToString(xmlToast, &nLength);
xmlDestroyNode(xmlToast);
- CHECKHR(xmlDocument->LoadXml(StringReferenceWrapper(xtmp, (UINT32)xlen).Get()));
+ CHECKHR(xmlDocument->LoadXml(StringReferenceWrapper(xtmp, nLength).Get()));
return xmlDocument.CopyTo(xml);
}
@@ -75,19 +73,14 @@ HRESULT ToastNotification::Create(_Outptr_ ABI::Windows::UI::Notifications::IToa return factory->CreateToastNotification(xml.Get(), _notification);
}
-HRESULT ToastNotification::Show()
-{
- return Show(new ToastEventHandler(nullptr));
-}
-
HRESULT ToastNotification::Show(_In_ ToastEventHandler* handler)
{
-
ComPtr<ToastEventHandler> eventHandler(handler);
- notification->add_Activated(eventHandler.Get(), &ertActivated);
- notification->add_Dismissed(eventHandler.Get(), &ertDismissed);
- notification->add_Failed(eventHandler.Get(), &ertFailed);
+ notification->add_Activated(eventHandler.Get(), &_ertActivated);
+ notification->add_Dismissed(eventHandler.Get(), &_ertDismissed);
+ notification->add_Failed(eventHandler.Get(), &_ertFailed);
+
return notifier->Show(notification.Get());
}
|