From 2aa59179945482dee30935c991f9317dfbf31946 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 17 May 2018 18:23:34 +0300 Subject: Tipper, StopSpamMod, StopSpam, StatusManager, StatusChange, StartupSilence, StartPosition, SplashScreen, SpellChecker, Spamotron => CMPlugin --- plugins/SplashScreen/src/main.cpp | 51 +++++++++++------------------------- plugins/SplashScreen/src/options.cpp | 2 +- plugins/SplashScreen/src/splash.cpp | 4 +-- plugins/SplashScreen/src/stdafx.h | 9 +++++-- 4 files changed, 25 insertions(+), 41 deletions(-) (limited to 'plugins/SplashScreen') diff --git a/plugins/SplashScreen/src/main.cpp b/plugins/SplashScreen/src/main.cpp index e6d9106950..ab415fb252 100644 --- a/plugins/SplashScreen/src/main.cpp +++ b/plugins/SplashScreen/src/main.cpp @@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "stdafx.h" -HINSTANCE hInst = nullptr; int hLangpack; +CMPlugin g_plugin; BOOL bstartup = true; // startup? BOOL bserviceinvoked = false; @@ -36,6 +36,8 @@ wchar_t szLogFile[MAX_PATH]; SPLASHOPTS options; HWND hwndSplash; +///////////////////////////////////////////////////////////////////////////////////////// + PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -49,12 +51,13 @@ PLUGININFOEX pluginInfo = { { 0xc64cc8e0, 0xcf03, 0x474a, { 0x8b, 0x11, 0x8b, 0xd4, 0x56, 0x5c, 0xcf, 0x04 } } }; -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) { - hInst = hinstDLL; - return TRUE; + return &pluginInfo; } +///////////////////////////////////////////////////////////////////////////////////////// + void SplashMain() { if (bstartup) { @@ -187,36 +190,20 @@ void SplashMain() int PlugDisableHook(WPARAM wParam, LPARAM lParam) { - #ifdef _DEBUG - wchar_t buf[128]; - #endif DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; + if (options.inheritGS) { - if (!strcmp(cws->szModule, "Skin") && !strcmp(cws->szSetting, "UseSound")) { + if (!strcmp(cws->szModule, "Skin") && !strcmp(cws->szSetting, "UseSound")) db_set_b(NULL, MODNAME, "PlaySound", cws->value.bVal); - #ifdef _DEBUG - cws->value.bVal ? _DebugPopup(NULL, L"Sounds enabled.", L"") : _DebugPopup(NULL, L"Sounds disabled.", L""); - logMessage(L"Module", _A2T(cws->szModule)); - logMessage(L"Setting", _A2T(cws->szSetting)); - logMessage(L"Value", _itow(cws->value.bVal, buf, 10)); - #endif - } - if (!strcmp(cws->szModule, "PluginDisable") && !strcmp(cws->szSetting, _T2A(szDllName))) { + + if (!strcmp(cws->szModule, "PluginDisable") && !strcmp(cws->szSetting, _T2A(szDllName))) db_set_b(NULL, MODNAME, "Active", cws->value.bVal); - #ifdef _DEBUG - cws->value.bVal ? _DebugPopup(NULL, L"Disabled.", "") : _DebugPopup(NULL, L"Enabled.", L""); - logMessage(L"PlugDisableHook", L"Triggered"); - logMessage(L"Module", _A2T(cws->szModule)); - logMessage(L"Setting", _A2T(cws->szSetting)); - logMessage(L"Value", _itow(cws->value.bVal, buf, 10)); - #endif - } } return 0; } -int ModulesLoaded(WPARAM wParam, LPARAM lParam) +static int ModulesLoaded(WPARAM wParam, LPARAM lParam) { bmodulesloaded = true; // all modules are loaded now, let other parts know about this fact @@ -242,11 +229,6 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) return 0; } -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - extern "C" int __declspec(dllexport) Load(void) { mir_getLP(&pluginInfo); @@ -259,13 +241,10 @@ extern "C" int __declspec(dllexport) Load(void) return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" int __declspec(dllexport) Unload(void) { - UnregisterClass(SPLASH_CLASS, hInst); - - #ifdef _DEBUG - logMessage(L"Unload", L"Job done"); - #endif - + UnregisterClass(SPLASH_CLASS, g_plugin.getInst()); return 0; } diff --git a/plugins/SplashScreen/src/options.cpp b/plugins/SplashScreen/src/options.cpp index 4fe7173ad6..851c660c93 100644 --- a/plugins/SplashScreen/src/options.cpp +++ b/plugins/SplashScreen/src/options.cpp @@ -336,7 +336,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP int OptInit(WPARAM wParam, LPARAM lParam) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = hInst; + odp.hInstance = g_plugin.getInst(); odp.szGroup.a = LPGEN("Skins"); odp.pszTemplate = MAKEINTRESOURCEA(IDD_SPLASH_OPT); odp.szTitle.a = LPGEN("Splash Screen"); diff --git a/plugins/SplashScreen/src/splash.cpp b/plugins/SplashScreen/src/splash.cpp index c8f8c874ba..650be8de35 100644 --- a/plugins/SplashScreen/src/splash.cpp +++ b/plugins/SplashScreen/src/splash.cpp @@ -147,7 +147,7 @@ void __cdecl SplashThread(void *arg) wcl.style = 0; wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; - wcl.hInstance = hInst; + wcl.hInstance = g_plugin.getInst(); wcl.hIcon = nullptr; wcl.hCursor = LoadCursor(nullptr, IDC_ARROW); wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); @@ -181,7 +181,7 @@ void __cdecl SplashThread(void *arg) SplashBmp->getHeight(), // Height HWND_DESKTOP, //Parent nullptr, //menu handle - hInst, //Instance + g_plugin.getInst(), //Instance nullptr); RECT rc; GetWindowRect(hwndSplash, &rc); diff --git a/plugins/SplashScreen/src/stdafx.h b/plugins/SplashScreen/src/stdafx.h index 5f8b8c8660..f2630ef5e9 100644 --- a/plugins/SplashScreen/src/stdafx.h +++ b/plugins/SplashScreen/src/stdafx.h @@ -27,7 +27,6 @@ #include #include -#define __NO_CMPLUGIN_NEEDED #include #include #include @@ -53,6 +52,13 @@ #define MODNAME "SplashScreen" #define WM_LOADED (WM_USER + 10) +struct CMPlugin : public PLUGIN +{ + CMPlugin() : + PLUGIN(MODNAME) + {} +}; + struct SPLASHOPTS { byte active; @@ -73,7 +79,6 @@ extern wchar_t szSplashFile[MAX_PATH], szSoundFile[MAX_PATH], szPrefix[128]; extern wchar_t *szMirDir; extern char szVersion[MAX_PATH]; extern BOOL bserviceinvoked, bmodulesloaded, png2dibavail; -extern HINSTANCE hInst; extern int OptInit(WPARAM wParam, LPARAM lParam); extern BOOL ShowSplash(BOOL bpreview); -- cgit v1.2.3