summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Toaster/src/main.cpp5
-rw-r--r--plugins/Toaster/src/services.cpp29
-rw-r--r--plugins/Toaster/src/stdafx.h2
-rw-r--r--plugins/Toaster/src/toast_notification.cpp25
-rw-r--r--plugins/Toaster/src/utils.cpp12
5 files changed, 32 insertions, 41 deletions
diff --git a/plugins/Toaster/src/main.cpp b/plugins/Toaster/src/main.cpp
index 10dea8e278..4fd340fb81 100644
--- a/plugins/Toaster/src/main.cpp
+++ b/plugins/Toaster/src/main.cpp
@@ -28,9 +28,10 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_POPUP,
/////////////////////////////////////////////////////////////////////////////////////////
-static int OnPreShutdown(WPARAM, LPARAM)
+static int OnShutdown(WPARAM, LPARAM)
{
CleanupClasses();
+ HideAllToasts();
DeleteDirectoryTreeW(wszTempDir);
return 0;
}
@@ -43,7 +44,7 @@ int CMPlugin::Load()
}
HookEvent(ME_OPT_INITIALISE, OnOptionsInitialized);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, &OnPreShutdown);
+ HookEvent(ME_SYSTEM_SHUTDOWN, &OnShutdown);
InitServices();
diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp
index ed318ac5fb..b75719acb3 100644
--- a/plugins/Toaster/src/services.cpp
+++ b/plugins/Toaster/src/services.cpp
@@ -5,7 +5,7 @@ OBJLIST<ToastNotification> lstNotifications(2, PtrKeySortT);
std::map<std::string, ClassData*> mp_Classes;
wchar_t wszTempDir[MAX_PATH];
-void __stdcall ShowToastNotification(void* p)
+void __stdcall ShowToastNotification(void *p)
{
std::unique_ptr<ToastData> td((ToastData*)p);
@@ -78,13 +78,11 @@ static INT_PTR CreatePopup2(WPARAM wParam, LPARAM)
POPUPDATA2 *ppd = (POPUPDATA2*)wParam;
ptrW text, title;
- if (ppd->flags & PU2_UNICODE)
- {
+ if (ppd->flags & PU2_UNICODE) {
text = mir_wstrdup(ppd->szText.w);
title = mir_wstrdup(ppd->szTitle.w);
}
- else
- {
+ else {
text = mir_a2u(ppd->szText.a);
title = mir_a2u(ppd->szTitle.a);
}
@@ -120,8 +118,7 @@ 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 != mp_Classes.end()) {
ToastData *td;
if (it->second->iFlags & PCF_UNICODE)
td = new ToastData(ppc->hContact, ppc->szTitle.w, ppc->szText.w, it->second->hIcon);
@@ -139,10 +136,8 @@ static INT_PTR CreateClassPopup(WPARAM, LPARAM lParam)
static INT_PTR UnRegisterPopupClass(WPARAM, LPARAM lParam)
{
- for (auto it = mp_Classes.begin(); it != mp_Classes.end(); it++)
- {
- if (it->second == (void*)lParam)
- {
+ for (auto it = mp_Classes.begin(); it != mp_Classes.end(); it++) {
+ if (it->second == (void *)lParam) {
delete it->second;
mp_Classes.erase(it);
break;
@@ -161,8 +156,7 @@ void CleanupClasses()
static INT_PTR ShowMessageW(WPARAM wParam, LPARAM lParam)
{
HICON hIcon = nullptr;
- switch (lParam)
- {
+ switch (lParam) {
case SM_WARNING:
hIcon = Skin_LoadIcon(SKINICON_WARNING, 1);
break;
@@ -174,7 +168,7 @@ static INT_PTR ShowMessageW(WPARAM wParam, LPARAM lParam)
break;
}
- ToastData *td = new ToastData(NULL, nullptr, (wchar_t*)wParam, hIcon);
+ ToastData *td = new ToastData(NULL, nullptr, (wchar_t *)wParam, hIcon);
CallFunctionAsync(ShowToastNotification, td);
return 0;
@@ -182,19 +176,20 @@ static INT_PTR ShowMessageW(WPARAM wParam, LPARAM lParam)
static INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam)
{
- ptrW tszText(mir_utf8decodeW((char*)wParam));
+ ptrW tszText(mir_utf8decodeW((char *)wParam));
return ShowMessageW(tszText, lParam);
}
static INT_PTR HideToast(WPARAM, LPARAM lParam)
{
- ToastNotification* pNotification = reinterpret_cast<ToastNotification*>(lParam);
+ ToastNotification *pNotification = reinterpret_cast<ToastNotification *>(lParam);
mir_cslock lck(csNotifications);
if (lstNotifications.getIndex(pNotification) != -1)
lstNotifications.remove(pNotification);
return 0;
}
-void __stdcall HideAllToasts(void*)
+
+void HideAllToasts()
{
mir_cslock lck(csNotifications);
while (lstNotifications.getCount())
diff --git a/plugins/Toaster/src/stdafx.h b/plugins/Toaster/src/stdafx.h
index 48baec164f..4d61dfc837 100644
--- a/plugins/Toaster/src/stdafx.h
+++ b/plugins/Toaster/src/stdafx.h
@@ -54,7 +54,7 @@ extern OBJLIST<ToastNotification> lstNotifications;
void CleanupClasses();
void InitServices();
-void __stdcall HideAllToasts(void*);
+void HideAllToasts();
int OnOptionsInitialized(WPARAM wParam, LPARAM);
diff --git a/plugins/Toaster/src/toast_notification.cpp b/plugins/Toaster/src/toast_notification.cpp
index 38c04f0066..3e11ec9a51 100644
--- a/plugins/Toaster/src/toast_notification.cpp
+++ b/plugins/Toaster/src/toast_notification.cpp
@@ -3,12 +3,12 @@
using namespace Microsoft::WRL;
ToastNotification::ToastNotification(
- _In_ wchar_t* text,
- _In_ wchar_t* caption,
- _In_ wchar_t* imagePath,
+ _In_ wchar_t *text,
+ _In_ wchar_t *caption,
+ _In_ wchar_t *imagePath,
MCONTACT hContact,
WNDPROC pWndProc,
- void *pData )
+ void *pData)
: _text(text), _caption(caption), _imagePath(imagePath), _hContact(hContact), _pfnPopupProc(pWndProc), _pvPopupData(pData)
{
{
@@ -34,8 +34,7 @@ ToastNotification::~ToastNotification()
notifier->Hide(notification.Get());
}
-
-HRESULT ToastNotification::CreateXml(_Outptr_ ABI::Windows::Data::Xml::Dom::IXmlDocument** xml)
+HRESULT ToastNotification::CreateXml(_Outptr_ ABI::Windows::Data::Xml::Dom::IXmlDocument **xml)
{
ComPtr<ABI::Windows::Data::Xml::Dom::IXmlDocumentIO> xmlDocument;
CHECKHR(Windows::Foundation::ActivateInstance(StringReferenceWrapper(RuntimeClass_Windows_Data_Xml_Dom_XmlDocument).Get(), &xmlDocument));
@@ -50,7 +49,7 @@ HRESULT ToastNotification::CreateXml(_Outptr_ ABI::Windows::Data::Xml::Dom::IXml
TiXmlElement *xmlBindingNode = doc.NewElement("binding"); xmlVisualNode->InsertEndChild(xmlBindingNode);
xmlBindingNode->SetAttribute("template", "ToastImageAndText02");
-
+
if (_imagePath) {
TiXmlElement *xmlImageNode = doc.NewElement("image"); xmlBindingNode->InsertEndChild(xmlImageNode);
xmlImageNode->SetAttribute("id", 1);
@@ -59,7 +58,7 @@ HRESULT ToastNotification::CreateXml(_Outptr_ ABI::Windows::Data::Xml::Dom::IXml
TiXmlElement *xmlTitleNode = doc.NewElement("text"); xmlBindingNode->InsertEndChild(xmlTitleNode);
xmlTitleNode->SetAttribute("id", 1); xmlTitleNode->SetText(_caption != nullptr ? _caption : L"Miranda NG");
-
+
if (_text) {
TiXmlElement *xmlTextNode = doc.NewElement("text"); xmlBindingNode->InsertEndChild(xmlTextNode);
xmlTextNode->SetAttribute("id", 2); xmlTextNode->SetText(_text);
@@ -73,7 +72,7 @@ HRESULT ToastNotification::CreateXml(_Outptr_ ABI::Windows::Data::Xml::Dom::IXml
return xmlDocument.CopyTo(xml);
}
-HRESULT ToastNotification::Create(_Outptr_ ABI::Windows::UI::Notifications::IToastNotification** _notification)
+HRESULT ToastNotification::Create(_Outptr_ ABI::Windows::UI::Notifications::IToastNotification **_notification)
{
ComPtr<ABI::Windows::Data::Xml::Dom::IXmlDocument> xml;
CHECKHR(CreateXml(&xml));
@@ -84,14 +83,14 @@ HRESULT ToastNotification::Create(_Outptr_ ABI::Windows::UI::Notifications::IToa
return factory->CreateToastNotification(xml.Get(), _notification);
}
-HRESULT ToastNotification::OnActivate(_In_ ABI::Windows::UI::Notifications::IToastNotification*, IInspectable*)
+HRESULT ToastNotification::OnActivate(_In_ ABI::Windows::UI::Notifications::IToastNotification *, IInspectable *)
{
CallPopupProc(WM_COMMAND);
Destroy();
return S_OK;
}
-HRESULT ToastNotification::OnDismiss(_In_ ABI::Windows::UI::Notifications::IToastNotification*, _In_ ABI::Windows::UI::Notifications::IToastDismissedEventArgs *e)
+HRESULT ToastNotification::OnDismiss(_In_ ABI::Windows::UI::Notifications::IToastNotification *, _In_ ABI::Windows::UI::Notifications::IToastDismissedEventArgs *e)
{
if (_signature == TOAST_SIGNATURE) {
ABI::Windows::UI::Notifications::ToastDismissalReason tdr;
@@ -103,7 +102,7 @@ HRESULT ToastNotification::OnDismiss(_In_ ABI::Windows::UI::Notifications::IToas
return S_OK;
}
-HRESULT ToastNotification::OnFail(_In_ ABI::Windows::UI::Notifications::IToastNotification*, _In_ ABI::Windows::UI::Notifications::IToastFailedEventArgs*)
+HRESULT ToastNotification::OnFail(_In_ ABI::Windows::UI::Notifications::IToastNotification *, _In_ ABI::Windows::UI::Notifications::IToastFailedEventArgs *)
{
if (_signature == TOAST_SIGNATURE)
Destroy();
@@ -114,4 +113,4 @@ void ToastNotification::Destroy()
{
mir_cslock lck(csNotifications);
lstNotifications.remove(this);
-} \ No newline at end of file
+}
diff --git a/plugins/Toaster/src/utils.cpp b/plugins/Toaster/src/utils.cpp
index 9751dcb13f..96cc61527a 100644
--- a/plugins/Toaster/src/utils.cpp
+++ b/plugins/Toaster/src/utils.cpp
@@ -27,18 +27,14 @@ HRESULT InstallShortcut(_In_z_ wchar_t *shortcutPath)
PROPVARIANT appIdPropVar;
HRESULT hr = InitPropVariantFromString(AppUserModelID, &appIdPropVar);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = propertyStore->Commit();
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
ComPtr<IPersistFile> persistFile;
hr = shellLink.As(&persistFile);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = persistFile->Save(shortcutPath, TRUE);
}
}