diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-17 17:09:50 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-17 17:09:50 +0300 |
commit | bce8bc74daf1c5f510404c8bdf956b41fb1c10fc (patch) | |
tree | 9879ad5ce5f42087558601af6a6f2827d7df4c39 /plugins/wbOSD | |
parent | ba1083b4da33ca44a5ae7d90eabbe3d6d340a81e (diff) |
WinterSpeak, WhoUsesMyFiles, WhenWasIt, wbOSD, Watrack_MPD -> CMPlugin
Diffstat (limited to 'plugins/wbOSD')
-rw-r--r-- | plugins/wbOSD/src/main.cpp | 20 | ||||
-rw-r--r-- | plugins/wbOSD/src/options.cpp | 4 | ||||
-rw-r--r-- | plugins/wbOSD/src/stdafx.h | 21 | ||||
-rw-r--r-- | plugins/wbOSD/src/wbOSD.cpp | 16 |
4 files changed, 25 insertions, 36 deletions
diff --git a/plugins/wbOSD/src/main.cpp b/plugins/wbOSD/src/main.cpp index fdae90110a..486b5a7511 100644 --- a/plugins/wbOSD/src/main.cpp +++ b/plugins/wbOSD/src/main.cpp @@ -9,11 +9,11 @@ Distributed under GNU's GPL 2 or later #include "stdafx.h"
-HINSTANCE hI;
+int hLangpack;
+CMPlugin g_plugin;
HWND g_hWnd = nullptr;
-int hLangpack = 0;
-HANDLE hHookedInit, hProtoAck, hContactSettingChanged, hHookContactStatusChanged, hContactStatusChanged;
+HANDLE hHookContactStatusChanged;
void logmsg2(char *str);
int MainInit(WPARAM,LPARAM);
@@ -45,7 +45,7 @@ extern "C" __declspec(dllexport) int Load() mir_getLP(&pluginInfo);
logmsg("Load");
- hHookedInit = HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
+ HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
return 0;
}
@@ -54,19 +54,7 @@ extern "C" __declspec(dllexport) int Load() extern "C" __declspec(dllexport) int Unload()
{
logmsg("Unload");
- UnhookEvent(hProtoAck);
- UnhookEvent(hContactSettingChanged);
- UnhookEvent(hContactStatusChanged);
- UnhookEvent(hHookedInit);
DestroyHookableEvent(hHookContactStatusChanged);
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID)
-{
- hI = hinst;
- return TRUE;
-}
diff --git a/plugins/wbOSD/src/options.cpp b/plugins/wbOSD/src/options.cpp index 12ad300dae..0b041ed5d9 100644 --- a/plugins/wbOSD/src/options.cpp +++ b/plugins/wbOSD/src/options.cpp @@ -54,7 +54,7 @@ int selectColor(HWND hwnd, COLORREF *clr) CHOOSECOLOR cc = { 0 };
cc.lStructSize = sizeof(cc);
cc.hwndOwner = hwnd;
- cc.hInstance = (HWND)hI;
+ cc.hInstance = (HWND)g_plugin.getInst();
cc.rgbResult = *clr;
cc.lpCustColors = pencustcolors;
cc.Flags = CC_FULLOPEN | CC_RGBINIT;
@@ -411,7 +411,7 @@ int OptionsInit(WPARAM wparam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 150000000;
- odp.hInstance = hI;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG1);
odp.szGroup.w = LPGENW("Plugins");
odp.szTitle.w = LPGENW("OSD");
diff --git a/plugins/wbOSD/src/stdafx.h b/plugins/wbOSD/src/stdafx.h index 6d13b4fb9b..9d261f861d 100644 --- a/plugins/wbOSD/src/stdafx.h +++ b/plugins/wbOSD/src/stdafx.h @@ -13,7 +13,6 @@ Distributed under GNU's GPL 2 or later #include <shlwapi.h>
#include <commctrl.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_langpack.h>
#include <m_database.h>
@@ -29,7 +28,14 @@ Distributed under GNU's GPL 2 or later #define THIS_MODULE "mirandaosd"
-//SETTINGS DEFAULTS
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(THIS_MODULE)
+ {}
+};
+
+// Settings defaults
#define DEFAULT_FNT_HEIGHT -30
#define DEFAULT_FNT_WIDTH 0
#define DEFAULT_FNT_ESCAPEMENT 0
@@ -69,7 +75,7 @@ Distributed under GNU's GPL 2 or later #define DEFAULT_SHOWMSGWIN 1
#define DEFAULT_SHOWWHEN 0x00000002
-//HOOKS
+// Hooks
#define ME_STATUSCHANGE_CONTACTSTATUSCHANGED "Miranda/StatusChange/ContactStatusChanged"
int ContactStatusChanged(WPARAM wParam, LPARAM lParam);
@@ -77,11 +83,9 @@ int ProtoAck(WPARAM wparam,LPARAM lparam); int ContactSettingChanged(WPARAM wparam,LPARAM lparam);
int HookedNewEvent(WPARAM wParam, LPARAM lParam);
-//ANNOUNCING MESSAGES FROM OUTSIDE ;-)
+// Announcing messages from outside
INT_PTR OSDAnnounce(WPARAM wParam, LPARAM lParam);
-
-
#define ID_STATUS_MIN ID_STATUS_OFFLINE
#define ID_STATUS_MAX ID_STATUS_OUTTOLUNCH
@@ -114,6 +118,5 @@ int OptionsInit(WPARAM wparam,LPARAM lparam); void loadDBSettings(plgsettings *ps);
-extern HINSTANCE hI;
-extern HWND g_hWnd;
-extern HANDLE hHookedInit, hProtoAck, hContactSettingChanged, hHookContactStatusChanged, hContactStatusChanged;
\ No newline at end of file +extern HWND g_hWnd;
+extern HANDLE hHookContactStatusChanged;
diff --git a/plugins/wbOSD/src/wbOSD.cpp b/plugins/wbOSD/src/wbOSD.cpp index 7f10ac8ff3..7b227db5cb 100644 --- a/plugins/wbOSD/src/wbOSD.cpp +++ b/plugins/wbOSD/src/wbOSD.cpp @@ -259,7 +259,7 @@ int MainInit(WPARAM, LPARAM) HookEvent(ME_OPT_INITIALISE, OptionsInit);
WNDCLASSEX wincl;
- wincl.hInstance = hI;
+ wincl.hInstance = g_plugin.getInst();
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
@@ -282,7 +282,7 @@ int MainInit(WPARAM, LPARAM) db_get_dw(NULL, THIS_MODULE, "winypos", DEFAULT_WINYPOS),
db_get_dw(NULL, THIS_MODULE, "winx", DEFAULT_WINX),
db_get_dw(NULL, THIS_MODULE, "winy", DEFAULT_WINY),
- HWND_DESKTOP, nullptr, hI, nullptr);
+ HWND_DESKTOP, nullptr, g_plugin.getInst(), nullptr);
SetWindowLongPtr(g_hWnd, GWLP_USERDATA, 0);
@@ -293,16 +293,14 @@ int MainInit(WPARAM, LPARAM) HookEvent(ME_DB_EVENT_ADDED, HookedNewEvent);
// try to create ME_STATUSCHANGE_CONTACTSTATUSCHANGED event... I hope it fails when newstatusnotify or equal creates it before ;-)
-
- hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED, ContactStatusChanged);
+ HANDLE hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED, ContactStatusChanged);
if (!hContactStatusChanged) {
hHookContactStatusChanged = CreateHookableEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED);
- hContactSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged);
-
- hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED, ContactStatusChanged);
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged);
+ HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED, ContactStatusChanged);
}
- hProtoAck = HookEvent(ME_PROTO_ACK, ProtoAck);
-
+
+ HookEvent(ME_PROTO_ACK, ProtoAck);
HookEvent(ME_SYSTEM_SHUTDOWN, pluginShutDown);
return 0;
}
|