From 4c4735a232c680e60a85d0f85e2cb392e012c6e0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 17 May 2018 17:49:56 +0300 Subject: Toaster, TooltipNotify, TrafficCounter, UInfoEx, UserGuide, Variables -> CMPlugin --- plugins/Toaster/src/main.cpp | 64 +++++++++++++++++++---------------------- plugins/Toaster/src/options.cpp | 2 +- plugins/Toaster/src/stdafx.h | 10 +++++-- 3 files changed, 37 insertions(+), 39 deletions(-) (limited to 'plugins/Toaster/src') diff --git a/plugins/Toaster/src/main.cpp b/plugins/Toaster/src/main.cpp index f48c47ea20..406bd52180 100644 --- a/plugins/Toaster/src/main.cpp +++ b/plugins/Toaster/src/main.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" int hLangpack; +CMPlugin g_plugin; -HINSTANCE g_hInstance; +///////////////////////////////////////////////////////////////////////////////////////// PLUGININFOEX pluginInfo = { @@ -18,67 +19,60 @@ PLUGININFOEX pluginInfo = { 0x1fdbd8f0, 0x3929, 0x41bc, { 0x92, 0xd1, 0x2, 0x7, 0x79, 0x46, 0x7, 0x69 } } }; -DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID) -{ - g_hInstance = hInstance; - return TRUE; -} - extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { - if (!IsWinVer8Plus()) - { + if (!IsWinVer8Plus()) { MessageBox(nullptr, TranslateT("This plugin requires Windows 8 or higher"), _T(MODULE), MB_OK | MB_ICONERROR); return nullptr; } return &pluginInfo; } +///////////////////////////////////////////////////////////////////////////////////////// + +static int OnPreShutdown(WPARAM, LPARAM) +{ + CleanupClasses(); + + SHFILEOPSTRUCT file_op = { + nullptr, + FO_DELETE, + wszTempDir, + L"", + FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION, + false, + nullptr, + L"" + }; + SHFileOperation(&file_op); + + return 0; +} + extern "C" int __declspec(dllexport) Load(void) { mir_getLP(&pluginInfo); HookEvent(ME_OPT_INITIALISE, OnOptionsInitialized); HookEvent(ME_SYSTEM_PRESHUTDOWN, &OnPreShutdown); - + InitServices(); - if (GetEnvironmentVariableW(L"TEMP", wszTempDir, MAX_PATH) != 0) - { + if (GetEnvironmentVariableW(L"TEMP", wszTempDir, MAX_PATH) != 0) { wcscat_s(wszTempDir, L"\\Miranda.Toaster"); DWORD dwAttributes = GetFileAttributes(wszTempDir); if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) CreateDirectoryTreeW(wszTempDir); } - else - { - MessageBox(nullptr, TranslateT("Failed to create temporary directory"), _T(MODULE), MB_OK | MB_ICONERROR); - } + else MessageBox(nullptr, TranslateT("Failed to create temporary directory"), _T(MODULE), MB_OK | MB_ICONERROR); return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" int __declspec(dllexport) Unload(void) { return 0; } - -int OnPreShutdown(WPARAM, LPARAM) -{ - CleanupClasses(); - - SHFILEOPSTRUCT file_op = { - nullptr, - FO_DELETE, - wszTempDir, - L"", - FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION, - false, - nullptr, - L"" - }; - SHFileOperation(&file_op); - - return 0; -} \ No newline at end of file diff --git a/plugins/Toaster/src/options.cpp b/plugins/Toaster/src/options.cpp index 9d0c0d4034..7b0f3b5995 100644 --- a/plugins/Toaster/src/options.cpp +++ b/plugins/Toaster/src/options.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" COptions::COptions() - : CDlgBase(g_hInstance, IDD_OPTIONS_MAIN), + : CDlgBase(g_plugin.getInst(), IDD_OPTIONS_MAIN), m_shortcut(this, IDC_SHORTCUT), m_preview(this, IDC_PREVIEW), m_enabled(this, IDC_CHECK_ENABLED) diff --git a/plugins/Toaster/src/stdafx.h b/plugins/Toaster/src/stdafx.h index 925a04f86d..1d337c7cf8 100644 --- a/plugins/Toaster/src/stdafx.h +++ b/plugins/Toaster/src/stdafx.h @@ -10,7 +10,6 @@ #include #include -#define __NO_CMPLUGIN_NEEDED #include #include #include @@ -33,8 +32,14 @@ const wchar_t AppUserModelID[] = L"MirandaNG"; #define MODULE "Toaster" #define CHECKHR(x) if (FAILED(x)) return x; +struct CMPlugin : public PLUGIN +{ + CMPlugin() : + PLUGIN(MODULE) + {} +}; + class ToastNotification; -extern HINSTANCE g_hInstance; extern mir_cs csNotifications; extern wchar_t wszTempDir[MAX_PATH]; extern OBJLIST lstNotifications; @@ -47,7 +52,6 @@ extern OBJLIST lstNotifications; void CleanupClasses(); void InitServices(); -int OnPreShutdown(WPARAM, LPARAM); void __stdcall HideAllToasts(void*); int OnOptionsInitialized(WPARAM wParam, LPARAM); -- cgit v1.2.3