diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-09-16 12:35:57 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-09-16 12:35:57 +0000 |
commit | d0a1040e019092c29d8d2a2c2a29bc1e7644a5e5 (patch) | |
tree | 9297e79ab09653aa870c5ef83c163673fbce8e6c | |
parent | 87208846a0e7fd82e246dd1e6a9cddfc0ca159e4 (diff) |
Toaster: more optimizations
git-svn-id: http://svn.miranda-ng.org/main/trunk@15361 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Toaster/src/services.cpp | 20 | ||||
-rw-r--r-- | plugins/Toaster/src/structs.h | 2 | ||||
-rw-r--r-- | plugins/Toaster/src/toast_event_handler.cpp | 15 | ||||
-rw-r--r-- | plugins/Toaster/src/toast_event_handler.h | 8 | ||||
-rw-r--r-- | plugins/Toaster/src/toast_notification.cpp | 11 | ||||
-rw-r--r-- | plugins/Toaster/src/toast_notification.h | 4 |
6 files changed, 37 insertions, 23 deletions
diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp index 79e7acca08..08641fa15e 100644 --- a/plugins/Toaster/src/services.cpp +++ b/plugins/Toaster/src/services.cpp @@ -75,12 +75,12 @@ void __stdcall ShowToastNotification(void* p) static INT_PTR GetPopupData(WPARAM wParam, LPARAM)
{
- return (INT_PTR)((ToastEventHandler*)wParam)->_thd->vPopupData;
+ return (INT_PTR)((ToastEventHandler*)wParam)->GetPluginData();
}
static INT_PTR GetPopupContact(WPARAM wParam, LPARAM)
{
- return (INT_PTR)((ToastEventHandler*)wParam)->_thd->hContact;
+ return (INT_PTR)((ToastEventHandler*)wParam)->GetContact();
}
static INT_PTR CreatePopup(WPARAM wParam, LPARAM)
@@ -231,7 +231,7 @@ static INT_PTR PopupQuery(WPARAM wParam, LPARAM) }
}
-static INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam)
+static INT_PTR ShowMessageW(WPARAM wParam, LPARAM lParam)
{
HICON hIcon = NULL;
switch (lParam)
@@ -247,19 +247,16 @@ static INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam) break;
}
- ptrT tszText(mir_utf8decodeT((char*)wParam));
- ToastData *td = new ToastData(NULL, NULL, tszText, hIcon);
-
+ ToastData *td = new ToastData(NULL, NULL, (wchar_t*)wParam, hIcon);
CallFunctionAsync(&ShowToastNotification, td);
return 0;
}
-static INT_PTR ShowMessageW(WPARAM wParam, LPARAM)
-{
- ToastData *td = new ToastData(NULL, NULL, (wchar_t*)wParam, HICON(0));
- CallFunctionAsync(&ShowToastNotification, td);
- return 0;
+static INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam)
+{
+ ptrT tszText(mir_utf8decodeW((char*)wParam));
+ return ShowMessageW(tszText, lParam);
}
void __stdcall HideAllToasts(void*)
@@ -280,6 +277,7 @@ void InitServices() CreateServiceFunction(MS_POPUP_ADDPOPUP, CreatePopup);
CreateServiceFunction(MS_POPUP_ADDPOPUPW, CreatePopupW);
CreateServiceFunction(MS_POPUP_ADDPOPUP2, CreatePopup2);
+
CreateServiceFunction(MS_POPUP_QUERY, PopupQuery);
CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, CreateClassPopup);
diff --git a/plugins/Toaster/src/structs.h b/plugins/Toaster/src/structs.h index e74eb14bf1..0aa4f59ae8 100644 --- a/plugins/Toaster/src/structs.h +++ b/plugins/Toaster/src/structs.h @@ -56,4 +56,4 @@ struct ToastHandlerData : public MZeroedObject void *vPopupData;
ToastNotification *tstNotification;
-};
+};
\ No newline at end of file diff --git a/plugins/Toaster/src/toast_event_handler.cpp b/plugins/Toaster/src/toast_event_handler.cpp index c6682da954..abb24ece06 100644 --- a/plugins/Toaster/src/toast_event_handler.cpp +++ b/plugins/Toaster/src/toast_event_handler.cpp @@ -3,7 +3,7 @@ using namespace ABI::Windows::UI::Notifications;
using namespace Microsoft::WRL;
-ToastEventHandler::ToastEventHandler(_In_ ToastHandlerData *pData) : _ref(1), _thd(pData)
+ToastEventHandler::ToastEventHandler(_In_ ToastHandlerData *pData) : _ref(0), _thd(pData)
{
if (_thd->pPopupProc)
_thd->pPopupProc((HWND)this, UM_INITPOPUP, (WPARAM)this, 0);
@@ -68,7 +68,6 @@ IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification* /* sender */, {
if (_thd->pPopupProc)
_thd->pPopupProc((HWND)this, WM_CONTEXTMENU, 0, 0);
- //delete this;
break;
}
case ToastDismissalReason_UserCanceled:
@@ -76,11 +75,9 @@ IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification* /* sender */, if (_thd->pPopupProc)
_thd->pPopupProc((HWND)this, WM_CONTEXTMENU, 0, 0);
_thd->tstNotification->Hide();
- //delete this;
break;
}
case ToastDismissalReason_TimedOut:
- //delete this; // should be rewritten
break;
}
@@ -95,4 +92,14 @@ IFACEMETHODIMP ToastEventHandler::Invoke(_In_ IToastNotification* /* sender */, mir_cslock lck(csNotifications);
lstNotifications.remove(_thd->tstNotification);
return S_OK;
+}
+
+void* ToastEventHandler::GetPluginData()
+{
+ return _thd->vPopupData;
+}
+
+MCONTACT ToastEventHandler::GetContact()
+{
+ return _thd->hContact;
}
\ No newline at end of file diff --git a/plugins/Toaster/src/toast_event_handler.h b/plugins/Toaster/src/toast_event_handler.h index 4405272f54..4d7a13c2f5 100644 --- a/plugins/Toaster/src/toast_event_handler.h +++ b/plugins/Toaster/src/toast_event_handler.h @@ -10,8 +10,6 @@ struct ToastHandlerData; class ToastEventHandler : public Microsoft::WRL::Implements<DesktopToastActivatedEventHandler, DesktopToastDismissedEventHandler, DesktopToastFailedEventHandler>
{
public:
- std::unique_ptr<ToastHandlerData> _thd;
-
ToastEventHandler::ToastEventHandler(_In_ ToastHandlerData *pData);
~ToastEventHandler();
@@ -23,9 +21,13 @@ public: IFACEMETHODIMP Invoke(_In_ ABI::Windows::UI::Notifications::IToastNotification* sender, _In_ IInspectable* args);
IFACEMETHODIMP Invoke(_In_ ABI::Windows::UI::Notifications::IToastNotification* /* sender */, _In_ ABI::Windows::UI::Notifications::IToastDismissedEventArgs* e);
IFACEMETHODIMP Invoke(_In_ ABI::Windows::UI::Notifications::IToastNotification* /* sender */, _In_ ABI::Windows::UI::Notifications::IToastFailedEventArgs* /* e */);
+
+ void* GetPluginData();
+ MCONTACT GetContact();
+
private:
ULONG _ref;
-
+ std::unique_ptr<ToastHandlerData> _thd;
};
#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 4eb83adca4..02b190a80e 100644 --- a/plugins/Toaster/src/toast_notification.cpp +++ b/plugins/Toaster/src/toast_notification.cpp @@ -9,6 +9,9 @@ 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()
@@ -79,12 +82,12 @@ HRESULT ToastNotification::Show() HRESULT ToastNotification::Show(_In_ ToastEventHandler* handler)
{
- EventRegistrationToken activatedToken, dismissedToken, failedToken;
+
ComPtr<ToastEventHandler> eventHandler(handler);
- notification->add_Activated(eventHandler.Get(), &activatedToken);
- notification->add_Dismissed(eventHandler.Get(), &dismissedToken);
- notification->add_Failed(eventHandler.Get(), &failedToken);
+ notification->add_Activated(eventHandler.Get(), &ertActivated);
+ notification->add_Dismissed(eventHandler.Get(), &ertDismissed);
+ notification->add_Failed(eventHandler.Get(), &ertFailed);
return notifier->Show(notification.Get());
}
diff --git a/plugins/Toaster/src/toast_notification.h b/plugins/Toaster/src/toast_notification.h index 6a83da5da4..e56a08c418 100644 --- a/plugins/Toaster/src/toast_notification.h +++ b/plugins/Toaster/src/toast_notification.h @@ -8,6 +8,10 @@ private: wchar_t* _caption;
wchar_t* _imagePath;
+ EventRegistrationToken ertActivated;
+ EventRegistrationToken ertDismissed;
+ EventRegistrationToken ertFailed;
+
Microsoft::WRL::ComPtr<ABI::Windows::UI::Notifications::IToastNotificationManagerStatics> notificationManager;
Microsoft::WRL::ComPtr<ABI::Windows::UI::Notifications::IToastNotifier> notifier;
Microsoft::WRL::ComPtr<ABI::Windows::UI::Notifications::IToastNotification> notification;
|