diff options
34 files changed, 206 insertions, 272 deletions
diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp index 091fe7d903..fe53b08299 100644 --- a/plugins/KeyboardNotify/src/main.cpp +++ b/plugins/KeyboardNotify/src/main.cpp @@ -26,10 +26,9 @@ #define NCONVERS_BLINKID ((MEVENT)123456) //nconvers' random identifier used to flash an icon for "incoming message" on contact list
-HINSTANCE g_hInst;
-
-CLIST_INTERFACE *pcli;
int hLangpack;
+CLIST_INTERFACE *pcli;
+CMPlugin g_plugin;
DWORD IDThread = 0;
HANDLE hThread = nullptr;
@@ -87,7 +86,8 @@ BOOL bReminderDisabled = FALSE; BYTE bMetaProtoEnabled = 0;
-PLUGININFOEX pluginInfo = {
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -105,12 +105,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) return &pluginInfo;
}
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- g_hInst = hinstDLL;
- return TRUE;
-}
-
int InitializeOptions(WPARAM, LPARAM);
BOOL CheckMsgWnd(MCONTACT, BOOL *);
diff --git a/plugins/KeyboardNotify/src/options.cpp b/plugins/KeyboardNotify/src/options.cpp index 7425a67cc3..82518f2420 100644 --- a/plugins/KeyboardNotify/src/options.cpp +++ b/plugins/KeyboardNotify/src/options.cpp @@ -22,8 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void LoadSettings(void); -extern HINSTANCE g_hInst; - extern BYTE bFlashOnMsg, bFlashOnURL, bFlashOnFile, bFlashOnOther, bFullScreenMode, bScreenSaverRunning, bWorkstationLocked, bProcessesAreRunning, bWorkstationActive, bFlashIfMsgOpen, bFlashIfMsgOlder, bFlashUntil, bMirandaOrWindows, bFlashLed[3], bFlashEffect, bSequenceOrder, bFlashSpeed, bEmulateKeypresses, bOverride, bFlashIfMsgWinNotTop, bTrillianLedsMsg, bTrillianLedsURL, bTrillianLedsFile, bTrillianLedsOther; @@ -725,11 +723,11 @@ static INT_PTR CALLBACK DlgProcBasicOptions(HWND hwndDlg, UINT msg, WPARAM wPara } return TRUE; case IDC_ASSIGNPGMS: - if (DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_PROCESSES), hwndDlg, DlgProcProcesses, 0) == IDC_OKPGM) + if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_PROCESSES), hwndDlg, DlgProcProcesses, 0) == IDC_OKPGM) SendMessage(GetParent(GetParent(hwndDlg)), PSM_CHANGED, 0, 0); return TRUE; case IDC_SELECTXSTATUS: - if (DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_XSTATUSES), hwndDlg, DlgProcXstatusList, 0) == IDC_OKXST) + if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_XSTATUSES), hwndDlg, DlgProcXstatusList, 0) == IDC_OKXST) SendMessage(GetParent(GetParent(hwndDlg)), PSM_CHANGED, 0, 0); return TRUE; case IDC_SREMCHECK: @@ -918,7 +916,7 @@ static INT_PTR CALLBACK DlgProcEffectOptions(HWND hwndDlg, UINT msg, WPARAM wPar SendMessage(GetParent(GetParent(hwndDlg)), PSM_CHANGED, 0, 0); return TRUE; case IDC_ASSIGNLEDS: - if (DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_EVENTLEDS), hwndDlg, DlgProcEventLeds, 0) == IDC_OK) + if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EVENTLEDS), hwndDlg, DlgProcEventLeds, 0) == IDC_OK) SendMessage(GetParent(GetParent(hwndDlg)), PSM_CHANGED, 0, 0); return TRUE; case IDC_SDELAY: @@ -1307,20 +1305,20 @@ static INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LP tci.pszText = TranslateT("Ignore"); TabCtrl_InsertItem(tc, 4, &tci); - hwndProto = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_PROTO_OPTIONS), hwndDlg, DlgProcProtoOptions, (LPARAM)NULL); + hwndProto = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_PROTO_OPTIONS), hwndDlg, DlgProcProtoOptions, (LPARAM)NULL); EnableThemeDialogTexture(hwndProto, ETDT_ENABLETAB); SetWindowPos(hwndProto, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); ShowWindow(hwndProto, SW_SHOW); - hwndBasic = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_BASIC_OPTIONS), hwndDlg, DlgProcBasicOptions, (LPARAM)NULL); + hwndBasic = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_BASIC_OPTIONS), hwndDlg, DlgProcBasicOptions, (LPARAM)NULL); EnableThemeDialogTexture(hwndBasic, ETDT_ENABLETAB); SetWindowPos(hwndBasic, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - hwndEffect = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_EFFECT_OPTIONS), hwndDlg, DlgProcEffectOptions, (LPARAM)NULL); + hwndEffect = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EFFECT_OPTIONS), hwndDlg, DlgProcEffectOptions, (LPARAM)NULL); EnableThemeDialogTexture(hwndEffect, ETDT_ENABLETAB); SetWindowPos(hwndEffect, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - hwndTheme = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_THEME_OPTIONS), hwndDlg, DlgProcThemeOptions, (LPARAM)NULL); + hwndTheme = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_THEME_OPTIONS), hwndDlg, DlgProcThemeOptions, (LPARAM)NULL); EnableThemeDialogTexture(hwndTheme, ETDT_ENABLETAB); SetWindowPos(hwndTheme, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - hwndIgnore = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_IGNORE_OPTIONS), hwndDlg, DlgProcIgnoreOptions, (LPARAM)NULL); + hwndIgnore = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_IGNORE_OPTIONS), hwndDlg, DlgProcIgnoreOptions, (LPARAM)NULL); EnableThemeDialogTexture(hwndIgnore, ETDT_ENABLETAB); SetWindowPos(hwndIgnore, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); hwndCurrentTab = hwndProto; @@ -1386,7 +1384,7 @@ static INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LP int InitializeOptions(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = g_hInst; + odp.hInstance = g_plugin.getInst(); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); odp.szTitle.a = LPGEN("Keyboard Flash"); odp.szGroup.a = LPGEN("Events"); diff --git a/plugins/KeyboardNotify/src/stdafx.h b/plugins/KeyboardNotify/src/stdafx.h index 2b36b23ed0..992962837a 100644 --- a/plugins/KeyboardNotify/src/stdafx.h +++ b/plugins/KeyboardNotify/src/stdafx.h @@ -28,8 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <winioctl.h>
#include <Uxtheme.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_database.h>
#include <m_options.h>
@@ -56,3 +54,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "keypresses.h"
#include "resource.h"
#include "version.h"
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(KEYBDMODULE)
+ {}
+};
diff --git a/plugins/ListeningTo/src/listeningto.cpp b/plugins/ListeningTo/src/listeningto.cpp index 955cbbd483..a9c88e09ce 100644 --- a/plugins/ListeningTo/src/listeningto.cpp +++ b/plugins/ListeningTo/src/listeningto.cpp @@ -894,5 +894,5 @@ void InitServices() HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SettingChanged);
// icons
- Icon_Register(hInst, LPGEN("ListeningTo"), iconList, _countof(iconList));
+ Icon_Register(g_plugin.getInst(), LPGEN("ListeningTo"), iconList, _countof(iconList));
}
diff --git a/plugins/ListeningTo/src/main.cpp b/plugins/ListeningTo/src/main.cpp index d175c983b9..b44b7bd50a 100644 --- a/plugins/ListeningTo/src/main.cpp +++ b/plugins/ListeningTo/src/main.cpp @@ -19,10 +19,13 @@ Boston, MA 02111-1307, USA. #include "stdafx.h"
-HINSTANCE hInst;
int hLangpack;
+CMPlugin g_plugin;
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -35,16 +38,6 @@ PLUGININFOEX pluginInfo = { { 0xf981f3f5, 0x35a, 0x444f,{ 0x98, 0x92, 0xca, 0x72, 0x2c, 0x19, 0x5a, 0xda } }
};
-// Functions ////////////////////////////////////////////////////////////////////////////
-
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
@@ -69,6 +62,5 @@ extern "C" int __declspec(dllexport) Load(void) extern "C" int __declspec(dllexport) Unload(void)
{
CoUninitialize();
-
return 0;
}
diff --git a/plugins/ListeningTo/src/options.cpp b/plugins/ListeningTo/src/options.cpp index aeea6a1b6e..549a3a1ef5 100644 --- a/plugins/ListeningTo/src/options.cpp +++ b/plugins/ListeningTo/src/options.cpp @@ -71,7 +71,7 @@ static OptPageControl playersControls[] = { int InitOptionsCallback(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.flags = ODPF_BOLDGROUPS;
odp.szGroup.a = LPGEN("Status");
diff --git a/plugins/ListeningTo/src/players/generic.cpp b/plugins/ListeningTo/src/players/generic.cpp index c4996d763b..309d424b6d 100644 --- a/plugins/ListeningTo/src/players/generic.cpp +++ b/plugins/ListeningTo/src/players/generic.cpp @@ -71,11 +71,11 @@ GenericPlayer::GenericPlayer() WNDCLASS wc = {};
wc.lpfnWndProc = ReceiverWndProc;
- wc.hInstance = hInst;
+ wc.hInstance = g_plugin.getInst();
wc.lpszClassName = MIRANDA_WINDOWCLASS;
RegisterClass(&wc);
- hWnd = CreateWindow(MIRANDA_WINDOWCLASS, LPGENW("Miranda ListeningTo receiver"), 0, 0, 0, 0, 0, nullptr, nullptr, hInst, nullptr);
+ hWnd = CreateWindow(MIRANDA_WINDOWCLASS, LPGENW("Miranda ListeningTo receiver"), 0, 0, 0, 0, 0, nullptr, nullptr, g_plugin.getInst(), nullptr);
}
GenericPlayer::~GenericPlayer()
@@ -88,7 +88,7 @@ GenericPlayer::~GenericPlayer() DestroyWindow(hWnd);
hWnd = nullptr;
- UnregisterClass(MIRANDA_WINDOWCLASS, hInst);
+ UnregisterClass(MIRANDA_WINDOWCLASS, g_plugin.getInst());
singleton = nullptr;
}
diff --git a/plugins/ListeningTo/src/players/player.cpp b/plugins/ListeningTo/src/players/player.cpp index 666f640cf8..23b10f3a8a 100644 --- a/plugins/ListeningTo/src/players/player.cpp +++ b/plugins/ListeningTo/src/players/player.cpp @@ -127,7 +127,7 @@ void CodeInjectionPlayer::InjectCode() // Get the dll path
char dll_path[1024] = { 0 };
- if (!GetModuleFileNameA(hInst, dll_path, _countof(dll_path)))
+ if (!GetModuleFileNameA(g_plugin.getInst(), dll_path, _countof(dll_path)))
return;
char *p = strrchr(dll_path, '\\');
diff --git a/plugins/ListeningTo/src/players/wmp.cpp b/plugins/ListeningTo/src/players/wmp.cpp index c69f288765..6bc244e742 100644 --- a/plugins/ListeningTo/src/players/wmp.cpp +++ b/plugins/ListeningTo/src/players/wmp.cpp @@ -35,11 +35,11 @@ WindowsMediaPlayer::WindowsMediaPlayer() WNDCLASS wc = {};
wc.lpfnWndProc = ReceiverWndProc;
- wc.hInstance = hInst;
+ wc.hInstance = g_plugin.getInst();
wc.lpszClassName = WMP_WINDOWCLASS;
RegisterClass(&wc);
- hWnd = CreateWindow(WMP_WINDOWCLASS, LPGENW("Miranda ListeningTo WMP receiver"), 0, 0, 0, 0, 0, nullptr, nullptr, hInst, nullptr);
+ hWnd = CreateWindow(WMP_WINDOWCLASS, LPGENW("Miranda ListeningTo WMP receiver"), 0, 0, 0, 0, 0, nullptr, nullptr, g_plugin.getInst(), nullptr);
}
WindowsMediaPlayer::~WindowsMediaPlayer()
@@ -52,7 +52,7 @@ WindowsMediaPlayer::~WindowsMediaPlayer() DestroyWindow(hWnd);
hWnd = nullptr;
- UnregisterClass(WMP_WINDOWCLASS, hInst);
+ UnregisterClass(WMP_WINDOWCLASS, g_plugin.getInst());
singleton = nullptr;
}
diff --git a/plugins/ListeningTo/src/stdafx.h b/plugins/ListeningTo/src/stdafx.h index bbb70355dd..905db9e8e9 100644 --- a/plugins/ListeningTo/src/stdafx.h +++ b/plugins/ListeningTo/src/stdafx.h @@ -28,8 +28,6 @@ Boston, MA 02111-1307, USA. #include <vector>
#include <algorithm>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <win2k.h>
#include <m_protosvc.h>
@@ -71,11 +69,16 @@ Boston, MA 02111-1307, USA. #define MS_LISTENINGTO_HOTKEYS_DISABLE "ListeningTo/HotkeysDisable"
#define MS_LISTENINGTO_HOTKEYS_TOGGLE "ListeningTo/HotkeysToggle"
-#define MODULE_NAME "ListeningTo"
+#define MODULE_NAME "ListeningTo"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE_NAME)
+ {}
+};
// Global Variables
-extern HINSTANCE hInst;
extern BOOL loaded;
#define MIR_FREE(_X_) { mir_free(_X_); _X_ = NULL; }
diff --git a/plugins/MessageState/src/main.cpp b/plugins/MessageState/src/main.cpp index 519522b54d..1eab147bb8 100644 --- a/plugins/MessageState/src/main.cpp +++ b/plugins/MessageState/src/main.cpp @@ -1,7 +1,9 @@ #include "stdafx.h"
int hLangpack;
-HINSTANCE g_hInst;
+CMPlugin g_plugin;
+
+/////////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfo =
{
@@ -18,17 +20,13 @@ PLUGININFOEX pluginInfo = };
-BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
-{
- g_hInst = hInstance;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
@@ -37,6 +35,8 @@ extern "C" int __declspec(dllexport) Load(void) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload(void)
{
return 0;
diff --git a/plugins/MessageState/src/messagestate.cpp b/plugins/MessageState/src/messagestate.cpp index 3512aed20d..d0fa273b89 100644 --- a/plugins/MessageState/src/messagestate.cpp +++ b/plugins/MessageState/src/messagestate.cpp @@ -99,7 +99,7 @@ int OnModulesLoaded(WPARAM, LPARAM) HookEvent(ME_PROTO_ACK, OnProtoAck);
HookEvent(ME_DB_EVENT_FILTER_ADD, OnEventFilterAdd);
- Icon_Register(g_hInst, MODULENAME, Icons, _countof(Icons));
+ Icon_Register(g_plugin.getInst(), MODULENAME, Icons, _countof(Icons));
StatusIconData sid = {};
sid.szModule = MODULENAME;
diff --git a/plugins/MessageState/src/stdafx.h b/plugins/MessageState/src/stdafx.h index 4efd7ab1f4..13827de990 100644 --- a/plugins/MessageState/src/stdafx.h +++ b/plugins/MessageState/src/stdafx.h @@ -4,8 +4,6 @@ #include <time.h>
#include <locale.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <m_messagestate.h>
#include <newpluginapi.h>
#include <m_database.h>
@@ -22,5 +20,11 @@ #define MODULENAME "MessageState"
-extern HINSTANCE g_hInst;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
+
extern IconItem Icons[];
\ No newline at end of file diff --git a/plugins/MirFox/src/MirandaInterface.cpp b/plugins/MirFox/src/MirandaInterface.cpp index b4f2f6ef0b..e744018012 100644 --- a/plugins/MirFox/src/MirandaInterface.cpp +++ b/plugins/MirFox/src/MirandaInterface.cpp @@ -2,8 +2,8 @@ #include "version.h"
#include "mirandaInterface.h"
-//Miranda - handle from DllMain
-HINSTANCE hInst;
+// Miranda - handle from DllMain
+CMPlugin g_plugin;
//Miranda - Langpack
int hLangpack;
@@ -18,7 +18,10 @@ HANDLE hPopupError; //main add-on's object
CMirfoxMiranda mirfoxMiranda;
-PLUGININFOEX pluginInfo={
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -30,21 +33,12 @@ PLUGININFOEX pluginInfo={ { 0xe99a09b2, 0xe05b, 0x4633, { 0xaa, 0x3a, 0x5c, 0x83, 0xef, 0x1c, 0xba, 0xb6 } }
};
-
-extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
-
- hInst = hinstDLL;
- return TRUE;
-}
-
-
-extern "C" __declspec (dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) {
+extern "C" __declspec (dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
return &pluginInfo;
}
-
-
-
+/////////////////////////////////////////////////////////////////////////////////////////
static int __cdecl onAccListChanged(WPARAM wParam, LPARAM lParam)
{
@@ -70,8 +64,8 @@ static int __cdecl onContactDeleted(WPARAM wParam, LPARAM) return 0;
}
-static int __cdecl onContactSettingChanged(WPARAM hContact, LPARAM lParam){
-
+static int __cdecl onContactSettingChanged(WPARAM hContact, LPARAM lParam)
+{
if (mirfoxMiranda.getMirfoxData().Plugin_Terminated)
return 0;
if (hContact == NULL || lParam == NULL)
@@ -95,15 +89,13 @@ static int __cdecl onContactSettingChanged(WPARAM hContact, LPARAM lParam){ return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// hook on ME_SYSTEM_MODULESLOADED at Load()
-
-/*
- * hook on ME_SYSTEM_MODULESLOADED at Load()
- */
static int onModulesLoaded(WPARAM, LPARAM)
{
//init popup classes
- POPUPCLASS puc = {0};
+ POPUPCLASS puc = { 0 };
puc.cbSize = sizeof(puc);
puc.flags = PCF_TCHAR;
@@ -112,7 +104,7 @@ static int onModulesLoaded(WPARAM, LPARAM) puc.colorBack = RGB(173, 206, 247); //light blue
puc.colorText = GetSysColor(COLOR_WINDOWTEXT);
puc.iSeconds = 3;
- puc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_PN));
+ puc.hIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ICON_PN));
hPopupNotify = Popup_RegisterClass(&puc);
puc.pszName = "MirFox_Error";
@@ -120,7 +112,7 @@ static int onModulesLoaded(WPARAM, LPARAM) puc.colorBack = RGB(255, 128, 128); //light red
puc.colorText = GetSysColor(COLOR_WINDOWTEXT);
puc.iSeconds = 20;
- puc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_PE));
+ puc.hIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ICON_PE));
hPopupError = Popup_RegisterClass(&puc);
@@ -142,6 +134,7 @@ static int OnShutdown(WPARAM, LPARAM) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
extern "C" int __declspec(dllexport) Load(void)
{
@@ -152,8 +145,8 @@ extern "C" int __declspec(dllexport) Load(void) hProtoAck = HookEvent(ME_PROTO_ACK, MirandaUtils::onProtoAck);
- //Ensure that the common control DLL is loaded. needed to use ICC_LISTVIEW_CLASSES control in options TODO move to InitOptions();?
- INITCOMMONCONTROLSEX icex = {0};
+ // Ensure that the common control DLL is loaded. needed to use ICC_LISTVIEW_CLASSES control in options TODO move to InitOptions();?
+ INITCOMMONCONTROLSEX icex = { 0 };
icex.dwSize = sizeof(icex);
icex.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx(&icex);
@@ -162,42 +155,35 @@ extern "C" int __declspec(dllexport) Load(void) mirfoxMiranda.getMirfoxData().setPluginState(MFENUM_PLUGIN_STATE_INIT);
mirfoxMiranda.onMirandaInterfaceLoad();
InitOptions();
-
- if (mirfoxMiranda.getMirfoxData().getPluginState() != MFENUM_PLUGIN_STATE_ERROR){
+
+ if (mirfoxMiranda.getMirfoxData().getPluginState() != MFENUM_PLUGIN_STATE_ERROR)
mirfoxMiranda.getMirfoxData().setPluginState(MFENUM_PLUGIN_STATE_WORK);
- } /*else {
- mirfoxMiranda.onMirandaInterfaceUnload();
- DeinitOptions();
- } */ //TODO
-
+
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
-extern "C" __declspec (dllexport) int Unload(void) {
-
+extern "C" __declspec (dllexport) int Unload(void)
+{
MFLogger::getInstance()->log(L"Unload: start");
-
- //wait for csmThread, msgQueueThread and userActionThread's end
+ // wait for csmThread, msgQueueThread and userActionThread's end
mirfoxMiranda.getMirfoxData().Plugin_Terminated = true;
UnhookEvent(hProtoAck);
int counter = 0;
const int UNLOAD_WAIT_TIME = 50; //[ms]
const int MAX_UNLOAD_WAIT_COUNTER = 10; //10 * 50ms = 0,5s
- while (mirfoxMiranda.getMirfoxData().workerThreadsCount > 0 ){
+ while (mirfoxMiranda.getMirfoxData().workerThreadsCount > 0) {
MFLogger::getInstance()->log_p(L"Unload: workerThreadsCount=%d > 0, waiting. counter=%d", mirfoxMiranda.getMirfoxData().workerThreadsCount, counter);
SleepEx(UNLOAD_WAIT_TIME, TRUE);
counter++;
}
- MFLogger::getInstance()->log_p(L"Unload: workerThreadsCount=%d. counter=%d", mirfoxMiranda.getMirfoxData().workerThreadsCount, counter);
-
+ MFLogger::getInstance()->log_p(L"Unload: workerThreadsCount=%d. counter=%d", mirfoxMiranda.getMirfoxData().workerThreadsCount, counter);
MFLogger::getInstance()->log(L"Unload: last log");
mirfoxMiranda.onMirandaInterfaceUnload();
DeinitOptions();
-
return 0;
}
-
diff --git a/plugins/MirFox/src/MirandaOptions.cpp b/plugins/MirFox/src/MirandaOptions.cpp index 8831b932da..b339b885c8 100644 --- a/plugins/MirFox/src/MirandaOptions.cpp +++ b/plugins/MirFox/src/MirandaOptions.cpp @@ -1,10 +1,7 @@ #include "common.h"
#include "MirandaOptions.h"
-
extern CMirfoxMiranda mirfoxMiranda;
-extern HINSTANCE hInst;
-
/*
* callback function for tab 1 options page
@@ -340,8 +337,8 @@ INT_PTR CALLBACK DlgProcOpts_Tab2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM hIml = ImageList_Create(smCx,smCy,((LOBYTE(LOWORD(GetVersion()))>=5 && LOWORD(GetVersion())!=5) ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, 4, 4);
//load icons (direct)
- icoHandle_ICON_OFF = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_OFF));
- icoHandle_ICON_FF = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_FF));
+ icoHandle_ICON_OFF = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ICON_OFF));
+ icoHandle_ICON_FF = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ICON_FF));
//add icons to ImageList list
ImageList_AddIcon(hIml, icoHandle_ICON_OFF);
@@ -674,7 +671,7 @@ int OptInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 };
odp.position = -790000000;
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.szTitle.a = LPGEN(PLUGIN_OPTIONS_NAME);
odp.szGroup.a = LPGEN("Services");
odp.flags = ODPF_BOLDGROUPS;
diff --git a/plugins/MirFox/src/MirfoxMiranda.cpp b/plugins/MirFox/src/MirfoxMiranda.cpp index 176929461c..e855537f5b 100644 --- a/plugins/MirFox/src/MirfoxMiranda.cpp +++ b/plugins/MirFox/src/MirfoxMiranda.cpp @@ -1,9 +1,6 @@ #include "common.h"
#include "MirfoxMiranda.h"
-
-
-
CMirfoxMiranda::CMirfoxMiranda()
: sharedMemoryUtils(SharedMemoryUtils::getInstance())
, mirandaUtils(MirandaUtils::getInstance())
@@ -17,15 +14,16 @@ CMirfoxMiranda::~CMirfoxMiranda() {
}
-MirfoxData& CMirfoxMiranda::getMirfoxData(){
+MirfoxData& CMirfoxMiranda::getMirfoxData()
+{
return mirfoxData;
}
-SharedMemoryUtils& CMirfoxMiranda::getSharedMemoryUtils(){
+SharedMemoryUtils& CMirfoxMiranda::getSharedMemoryUtils()
+{
return *sharedMemoryUtils;
}
-
int CMirfoxMiranda::onMirandaInterfaceLoad()
{
diff --git a/plugins/MirFox/src/common.h b/plugins/MirFox/src/common.h index aa36678281..95b80f9861 100644 --- a/plugins/MirFox/src/common.h +++ b/plugins/MirFox/src/common.h @@ -2,12 +2,10 @@ #include "MirFoxCommons_pch.h"
-
#pragma comment(lib, "comctl32.lib")
#include <commctrl.h>
// Miranda headers
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
#include <newpluginapi.h>
#include <m_system.h>
@@ -21,12 +19,15 @@ #include <m_extraicons.h>
#include <m_protocols.h>
+#define PLUGIN_DB_ID "MirFox"
+#define PLUGIN_OPTIONS_NAME "MirFox"
-#define PLUGIN_DB_ID "MirFox"
-#define PLUGIN_OPTIONS_NAME "MirFox"
-
-
-
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(PLUGIN_DB_ID)
+ {}
+};
//for MirandaUtils.h and MirfoxData.h and MirfoxMiranda.h
#include "MirFoxCommons_logger.h"
diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index 80181272d1..92b1fe1170 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -102,24 +102,24 @@ bool CAppletManager::Initialize(tstring strAppletName) } // load status bitmaps - m_ahStatusBitmaps[0] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_OFFLINE), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[1] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_ONLINE), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[2] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_AWAY), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[3] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_NA), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[4] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_OCCUPIED), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[5] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_DND), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[6] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_INVISIBLE), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); - m_ahStatusBitmaps[7] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS_FFC), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[0] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_STATUS_OFFLINE), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[1] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_STATUS_ONLINE), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[2] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_STATUS_AWAY), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[3] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_STATUS_NA), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[4] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_STATUS_OCCUPIED), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[5] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_STATUS_DND), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[6] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_STATUS_INVISIBLE), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); + m_ahStatusBitmaps[7] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_STATUS_FFC), IMAGE_BITMAP, 5, 5, LR_MONOCHROME); // Load event bitmaps - m_ahEventBitmaps[0] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_MSG), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); - m_ahEventBitmaps[1] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_CON), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); - m_ahEventBitmaps[2] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_USER), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); - m_ahEventBitmaps[3] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_INFO), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); - - m_ahLargeEventBitmaps[0] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_MSG_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); - m_ahLargeEventBitmaps[1] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_CON_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); - m_ahLargeEventBitmaps[2] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_USER_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); - m_ahLargeEventBitmaps[3] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDB_EVENT_INFO_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); + m_ahEventBitmaps[0] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_EVENT_MSG), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); + m_ahEventBitmaps[1] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_EVENT_CON), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); + m_ahEventBitmaps[2] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_EVENT_USER), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); + m_ahEventBitmaps[3] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_EVENT_INFO), IMAGE_BITMAP, 6, 6, LR_MONOCHROME); + + m_ahLargeEventBitmaps[0] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_EVENT_MSG_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); + m_ahLargeEventBitmaps[1] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_EVENT_CON_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); + m_ahLargeEventBitmaps[2] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_EVENT_USER_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); + m_ahLargeEventBitmaps[3] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_EVENT_INFO_LARGE), IMAGE_BITMAP, 8, 8, LR_MONOCHROME); // start the update timer m_uiTimer = SetTimer(nullptr, 0, 1000 / 10, CAppletManager::UpdateTimer); diff --git a/plugins/MirandaG15/src/CConfig.cpp b/plugins/MirandaG15/src/CConfig.cpp index 0d56bdf3a6..1aba05e6d0 100644 --- a/plugins/MirandaG15/src/CConfig.cpp +++ b/plugins/MirandaG15/src/CConfig.cpp @@ -1,5 +1,4 @@ #include "StdAfx.h"
-#include "Miranda.h"
#include "CConfig.h"
#include "CAppletManager.h"
@@ -244,7 +243,7 @@ int CConfig::InitOptionsDialog(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 847000000;
- odp.hInstance = hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.szGroup.a = LPGEN("MirandaG15");
odp.flags = ODPF_BOLDGROUPS;
@@ -573,8 +572,8 @@ INT_PTR CALLBACK CConfig::NotificationsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM w HIMAGELIST himlCheckBoxes;
himlCheckBoxes = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
- iRes = ImageList_AddIcon(himlCheckBoxes, LoadIcon(hInstance, MAKEINTRESOURCE(IDI_NOTICK)));
- iRes = ImageList_AddIcon(himlCheckBoxes, LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TICK)));
+ iRes = ImageList_AddIcon(himlCheckBoxes, LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_NOTICK)));
+ iRes = ImageList_AddIcon(himlCheckBoxes, LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_TICK)));
TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_PROTOCOLS), himlCheckBoxes, TVSIL_NORMAL);
FillTree(GetDlgItem(hwndDlg, IDC_PROTOCOLS));
@@ -744,8 +743,8 @@ INT_PTR CALLBACK CConfig::ContactlistDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wPa HIMAGELIST himlCheckBoxes;
himlCheckBoxes = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
- iRes = ImageList_AddIcon(himlCheckBoxes, LoadIcon(hInstance, MAKEINTRESOURCE(IDI_NOTICK)));
- iRes = ImageList_AddIcon(himlCheckBoxes, LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TICK)));
+ iRes = ImageList_AddIcon(himlCheckBoxes, LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_NOTICK)));
+ iRes = ImageList_AddIcon(himlCheckBoxes, LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_TICK)));
TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_CLIST_PROTOFILTER), himlCheckBoxes, TVSIL_NORMAL);
FillTree(GetDlgItem(hwndDlg, IDC_CLIST_PROTOFILTER), true);
diff --git a/plugins/MirandaG15/src/CScreen.cpp b/plugins/MirandaG15/src/CScreen.cpp index 08ed7cb155..90d053ed23 100644 --- a/plugins/MirandaG15/src/CScreen.cpp +++ b/plugins/MirandaG15/src/CScreen.cpp @@ -117,7 +117,7 @@ void CScreen::SetButtonBitmap(int iButton, int iBitmap) if(m_ahBitmaps[iButton] != nullptr)
DeleteObject(m_ahBitmaps[iButton]);
- m_ahBitmaps[iButton] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(iBitmap),
+ m_ahBitmaps[iButton] = (HBITMAP)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(iBitmap),
IMAGE_BITMAP,17, 3, LR_MONOCHROME);
m_aButtons[iButton].SetBitmap(m_ahBitmaps[iButton]);
diff --git a/plugins/MirandaG15/src/Miranda.cpp b/plugins/MirandaG15/src/Miranda.cpp index 10a1ec6919..6b6adb92d8 100644 --- a/plugins/MirandaG15/src/Miranda.cpp +++ b/plugins/MirandaG15/src/Miranda.cpp @@ -58,16 +58,18 @@ bool g_bInitialized; // Plugin Information
-CLIST_INTERFACE *pcli;
-HINSTANCE hInstance;
int hLangpack;
+CMPlugin g_plugin;
+CLIST_INTERFACE *pcli;
+
+// Function Prototypes
+int Init(WPARAM, LPARAM);
+void UnInit();
-// {58D63981-14C1-4099-A3F7-F4FAA4C8FC59}
-#define MIID_G15APPLET { 0x58d63981, 0x14c1, 0x4099, { 0xa3, 0xf7, 0xf4, 0xfa, 0xa4, 0xc8, 0xfc, 0x59 } }
+/////////////////////////////////////////////////////////////////////////////////////////
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_G15APPLET, MIID_LAST};
-
-PLUGININFOEX pluginInfoEx = {
+PLUGININFOEX pluginInfoEx =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -80,22 +82,16 @@ PLUGININFOEX pluginInfoEx = { {0x798221e1, 0xe47a, 0x4dc8, {0x90, 0x77, 0x1e, 0x57, 0x6f, 0x9c, 0x43, 0x7}}
};
-// Function Prototypes
-int Init(WPARAM,LPARAM);
-void UnInit();
-
-//************************************************************************
-// Exported Functions
-//************************************************************************
-
EXTERN_C __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
}
+/////////////////////////////////////////////////////////////////////////////////////////
// Called by Miranda to load the plugin.
// We defer initialization until Miranda's module loading process completed and return 0 to
// mark success, everything else will cause the plugin to be freed right away.
+
EXTERN_C int __declspec(dllexport) Load()
{
mir_getLP(&pluginInfoEx);
@@ -110,7 +106,9 @@ EXTERN_C int __declspec(dllexport) Load() return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
// Called by Miranda when the plugin should unload itself.
+
EXTERN_C int __declspec(dllexport) Unload(void)
{
if(!g_bInitialized) {
@@ -127,17 +125,6 @@ EXTERN_C int __declspec(dllexport) Unload(void) }
//************************************************************************
-// DllMain
-//
-// EntryPoint of the DLL
-//************************************************************************
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInstance = hinstDLL;
- return TRUE;
-}
-
-//************************************************************************
// Init
//
// Called after Miranda has finished loading all modules
diff --git a/plugins/MirandaG15/src/Miranda.h b/plugins/MirandaG15/src/Miranda.h deleted file mode 100644 index 22ad8e00a8..0000000000 --- a/plugins/MirandaG15/src/Miranda.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once
-
-extern HINSTANCE hInstance;
-extern char *MsgServiceName(MCONTACT hContact,bool bIsUnicode);
-
diff --git a/plugins/MirandaG15/src/StdAfx.h b/plugins/MirandaG15/src/StdAfx.h index deec9ef894..42620aaa32 100644 --- a/plugins/MirandaG15/src/StdAfx.h +++ b/plugins/MirandaG15/src/StdAfx.h @@ -16,10 +16,7 @@ using namespace std;
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
-
#include <m_message.h>
#include <m_protosvc.h>
#include <m_database.h>
@@ -32,17 +29,21 @@ using namespace std; #include <m_metacontacts.h>
#include <m_langpack.h>
-//#define IDF_ISIDLE 0x1 // idle has become active (if not set, inactive)
#define IDF_SHORT 0x2 // short idle mode
#define IDF_LONG 0x4 // long idle mode
-//#define IDF_PRIVACY 0x8 // if set, the information provided shouldn't be given to third parties.
#define IDF_ONFORCE 0x10
#define ASSERT assert
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(nullptr)
+ {}
+};
+
#include "LCDFramework/LCDFramework.h"
-#include "Miranda.h"
#include "CEvent.h"
#include "resource.h"
diff --git a/plugins/MsgPopup/src/main.cpp b/plugins/MsgPopup/src/main.cpp index cc39c0653e..f35ce90daa 100644 --- a/plugins/MsgPopup/src/main.cpp +++ b/plugins/MsgPopup/src/main.cpp @@ -22,8 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-HINSTANCE hInst;
int hLangpack;
+CMPlugin g_plugin;
MSGBOXOPTIONS optionsDefault =
{
@@ -34,7 +34,10 @@ MSGBOXOPTIONS optionsDefault = };
MSGBOXOPTIONS options;
-PLUGININFOEX pluginInfo={
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -47,6 +50,13 @@ PLUGININFOEX pluginInfo={ {0xcf25d645, 0x4dab, 0x4b0a, {0xb9, 0xf1, 0xde, 0x1e, 0x86, 0x23, 0x1f, 0x9b}}
};
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
typedef int (WINAPI *MSGBOXPROC)(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
MSGBOXPROC prevMessageBox;
@@ -183,7 +193,7 @@ int HookedOptions(WPARAM wParam, LPARAM) {
if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.szTitle.w = LPGENW("MessagePopup");
odp.szGroup.w = LPGENW("Popups");
@@ -209,6 +219,8 @@ void LoadConfig() options.Sound = db_get_b(NULL, SERVICENAME, "Sound", (DWORD)optionsDefault.Sound);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfo);
@@ -219,18 +231,9 @@ extern "C" __declspec(dllexport) int Load(void) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
return 0;
}
-
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfo;
-}
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
diff --git a/plugins/MsgPopup/src/stdafx.h b/plugins/MsgPopup/src/stdafx.h index 0344673222..c235239788 100644 --- a/plugins/MsgPopup/src/stdafx.h +++ b/plugins/MsgPopup/src/stdafx.h @@ -26,8 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <tlhelp32.h>
#include <dbghelp.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_utils.h>
#include <m_langpack.h>
@@ -41,6 +39,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SERVICENAME "MessagePopup"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(SERVICENAME)
+ {}
+};
+
struct MSGBOXOPTIONS
{
COLORREF FG[4];
diff --git a/plugins/Msg_Export/src/FileViewer.cpp b/plugins/Msg_Export/src/FileViewer.cpp index 2933989a93..074a89672c 100755 --- a/plugins/Msg_Export/src/FileViewer.cpp +++ b/plugins/Msg_Export/src/FileViewer.cpp @@ -119,7 +119,7 @@ public: acFindStr[0] = 0;
memset(&fr, 0, sizeof(fr));
fr.lStructSize = sizeof(fr);
- fr.hInstance = hInstance;
+ fr.hInstance = g_plugin.getInst();
fr.Flags = FR_NOUPDOWN | FR_HIDEUPDOWN;//|FR_MATCHCASE|FR_WHOLEWORD;
// FR_DOWN|FR_FINDNEXT|FR_NOMATCHCASE;
fr.lpstrFindWhat = acFindStr;
@@ -765,7 +765,7 @@ LRESULT CALLBACK EditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa switch (msg) {
case WM_CONTEXTMENU:
{
- HMENU nMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_FV_EDIT));
+ HMENU nMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_FV_EDIT));
HMENU nSubMenu = GetSubMenu(nMenu, 0);
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
@@ -943,7 +943,7 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
pclDlg = (CLHistoryDlg *)lParam;
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInstance, MAKEINTRESOURCE(IDI_EXPORT_MESSAGE)));
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_EXPORT_MESSAGE)));
{
HWND hRichEdit = GetDlgItem(hwndDlg, IDC_RICHEDIT);
mir_subclassWindow(hRichEdit, EditSubclassProc);
@@ -1201,7 +1201,7 @@ bool bShowFileViewer(MCONTACT hContact) }
CLHistoryDlg *pcl = new CLHistoryDlg(hContact);
- pcl->hWnd = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_FILE_VIEWER), nullptr, DlgProcFileViewer, (LPARAM)pcl);
+ pcl->hWnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FILE_VIEWER), nullptr, DlgProcFileViewer, (LPARAM)pcl);
if (pcl->hWnd) {
mir_cslock lck(csHistoryList);
clHistoryDlgList.push_front(pcl);
diff --git a/plugins/Msg_Export/src/main.cpp b/plugins/Msg_Export/src/main.cpp index 94c7188e9c..69dc23a94d 100755 --- a/plugins/Msg_Export/src/main.cpp +++ b/plugins/Msg_Export/src/main.cpp @@ -18,8 +18,8 @@ #include "stdafx.h"
-HINSTANCE hInstance = nullptr;
-int hLangpack = 0;
+int hLangpack;
+CMPlugin g_plugin;
MWindowList hInternalWindowList = nullptr;
@@ -40,6 +40,10 @@ PLUGININFOEX pluginInfo = { { 0x46102b07, 0xc215, 0x4162, { 0x9c, 0x83, 0xd3, 0x77, 0x88, 0x1d, 0xa7, 0xcc } }
};
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
/////////////////////////////////////////////////////////////////////
// Member Function : ShowExportHistory
@@ -57,8 +61,7 @@ PLUGININFOEX pluginInfo = { static INT_PTR ShowExportHistory(WPARAM wParam, LPARAM /*lParam*/)
{
- if (bUseInternalViewer())
- {
+ if (bUseInternalViewer()) {
bShowFileViewer(wParam);
return 0;
}
@@ -109,11 +112,10 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) HookEvent(ME_DB_CONTACT_DELETED, nContactDeleted);
HookEvent(ME_OPT_INITIALISE, OptionsInitialize);
- if (!bReplaceHistory)
- {
+ if (!bReplaceHistory) {
CMenuItem mi;
SET_UID(mi, 0x701c543, 0xd078, 0x41dd, 0x95, 0xe3, 0x96, 0x49, 0x8a, 0x72, 0xc7, 0x50);
- mi.hIcolibItem = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_EXPORT_MESSAGE));
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_EXPORT_MESSAGE));
mi.position = 1000090100;
mi.name.a = LPGEN("Open E&xported History");
mi.pszService = MS_SHOW_EXPORT_HISTORY;
@@ -124,48 +126,6 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) return 0;
}
-
-
-/////////////////////////////////////////////////////////////////////
-// Member Function : DllMain
-// Type : Global
-// Parameters : hinst - ?
-// fdwReason - ?
-// lpvReserved - ?
-// Returns : BOOL WINAPI
-// Description :
-//
-// References : -
-// Remarks : -
-// Created : 020422, 22 April 2002
-// Developer : KN
-/////////////////////////////////////////////////////////////////////
-
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD /*fdwReason*/, LPVOID /*lpvReserved*/)
-{
- hInstance = hinst;
- return 1;
-}
-
-
-/////////////////////////////////////////////////////////////////////
-// Member Function : MirandaPluginInfo
-// Type : Global
-// Parameters : mirandaVersion - ?
-// Returns :
-// Description :
-//
-// References : -
-// Remarks : -
-// Created : 020422, 22 April 2002
-// Developer : KN
-/////////////////////////////////////////////////////////////////////
-
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfo;
-}
-
/////////////////////////////////////////////////////////////////////
// Member Function : Load
// Type : Global
diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp index 88f4f6001f..d593c7f2e9 100755 --- a/plugins/Msg_Export/src/options.cpp +++ b/plugins/Msg_Export/src/options.cpp @@ -285,7 +285,7 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected) }
// Create progress dialog
- HWND hDlg = data->hDialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EXPORT_ALL_DLG), nullptr, DialogProc);
+ HWND hDlg = data->hDialog = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EXPORT_ALL_DLG), nullptr, DialogProc);
ShowWindow(hDlg, SW_SHOWNORMAL);
// Process the export in other thread
@@ -870,7 +870,7 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts(HWND hwndDlg, UINT msg, WPARAM wPar case WM_CONTEXTMENU:
if (wParam == (WPARAM)GetDlgItem(hwndDlg, IDC_MAP_USER_LIST)) {
- HMENU hMainMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MSG_EXPORT));
+ HMENU hMainMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MSG_EXPORT));
if (hMainMenu) {
HMENU hMenu = GetSubMenu(hMainMenu, 0);
@@ -1228,7 +1228,7 @@ int OptionsInitialize(WPARAM wParam, LPARAM /*lParam*/) OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
- odp.hInstance = hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MSGEXPORT);
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.szTitle.w = LPGENW("Message export");
diff --git a/plugins/Msg_Export/src/stdafx.h b/plugins/Msg_Export/src/stdafx.h index 6a4de3ead7..29ba199b25 100755 --- a/plugins/Msg_Export/src/stdafx.h +++ b/plugins/Msg_Export/src/stdafx.h @@ -28,8 +28,6 @@ using namespace std; #include <string>
#include <map>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_database.h>
#include <m_clist.h>
@@ -56,7 +54,12 @@ using namespace std; #define szFileViewDB "FileV_"
#define WM_RELOAD_FILE (WM_USER+10)
-extern HINSTANCE hInstance;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE)
+ {}
+};
extern MWindowList hInternalWindowList;
diff --git a/plugins/mTextControl/src/main.cpp b/plugins/mTextControl/src/main.cpp index 6c0a5d60a2..a710853b9c 100644 --- a/plugins/mTextControl/src/main.cpp +++ b/plugins/mTextControl/src/main.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-HINSTANCE hInst = nullptr;
+CMPlugin g_plugin;
int hLangpack;
HMODULE hMsfteditDll = nullptr;
@@ -29,6 +29,8 @@ HMODULE hMsfteditDll = nullptr; typedef HRESULT(WINAPI *pfnMyCreateTextServices)(IUnknown *punkOuter, ITextHost *pITextHost, IUnknown **ppUnk);
pfnMyCreateTextServices MyCreateTextServices = nullptr;
+/////////////////////////////////////////////////////////////////////////////////////////
+
PLUGININFOEX pluginInfoEx =
{
sizeof(PLUGININFOEX),
@@ -43,17 +45,13 @@ PLUGININFOEX pluginInfoEx = { 0x69b9443b, 0xdc58, 0x4876, { 0xad, 0x39, 0xe3, 0xf4, 0x18, 0xa1, 0x33, 0xc5 } }
};
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfoEx);
@@ -71,6 +69,8 @@ extern "C" __declspec(dllexport) int Load(void) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
UnloadTextUsers();
diff --git a/plugins/mTextControl/src/richeditutils.cpp b/plugins/mTextControl/src/richeditutils.cpp index 650c596129..694be13db4 100644 --- a/plugins/mTextControl/src/richeditutils.cpp +++ b/plugins/mTextControl/src/richeditutils.cpp @@ -130,7 +130,7 @@ void LoadRichEdit() wcl.style = CS_GLOBALCLASS;
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);
@@ -147,7 +147,7 @@ void UnloadRichEdit() HWND CreateProxyWindow(ITextServices *ts)
{
- HWND hwnd = CreateWindow(L"NBRichEditProxyWndClass", L"", 0, 0, 0, 0, 0, nullptr, nullptr, hInst, nullptr);
+ HWND hwnd = CreateWindow(L"NBRichEditProxyWndClass", L"", 0, 0, 0, 0, 0, nullptr, nullptr, g_plugin.getInst(), nullptr);
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)ts);
return hwnd;
}
diff --git a/plugins/mTextControl/src/services.cpp b/plugins/mTextControl/src/services.cpp index 162e87057a..c75673f918 100644 --- a/plugins/mTextControl/src/services.cpp +++ b/plugins/mTextControl/src/services.cpp @@ -328,7 +328,7 @@ INT_PTR MText_GetInterface(WPARAM, LPARAM lParam) if (MText == nullptr)
return CALLSERVICE_NOTFOUND;
- MText->version = pluginInfoEx.version;
+ MText->version = PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM);
MText->Register = MTI_TextUserAdd;
MText->Create = MTI_MTextCreateW;
MText->CreateEx = MTI_MTextCreateEx;
diff --git a/plugins/mTextControl/src/stdafx.h b/plugins/mTextControl/src/stdafx.h index 1adfef31b6..d669ffbc57 100644 --- a/plugins/mTextControl/src/stdafx.h +++ b/plugins/mTextControl/src/stdafx.h @@ -30,8 +30,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include <tom.h>
#include <textserv.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_database.h>
#include <m_langpack.h>
@@ -55,7 +53,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define MODULTITLE "Text Display"
// globals
-extern HINSTANCE hInst;
-extern PLUGININFOEX pluginInfoEx;
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULNAME)
+ {}
+};
#endif // __headers_h__
diff --git a/plugins/mTextControl/src/textcontrol.cpp b/plugins/mTextControl/src/textcontrol.cpp index b8f66ef432..a033bb1799 100644 --- a/plugins/mTextControl/src/textcontrol.cpp +++ b/plugins/mTextControl/src/textcontrol.cpp @@ -38,7 +38,7 @@ void MTextControl_RegisterClass() wcl.style = CS_GLOBALCLASS;
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);
|