summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-17 13:41:03 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-17 13:41:03 +0300
commit3c641c02b973483e86b9562088719396bbdbe412 (patch)
treeb34befda4b7f9ca98092bccacdb2b9461894530e
parent73d93114e2c4d4c1c259fa1474a5c6bd723b92ee (diff)
ICQCorp -> CMPlugin
-rw-r--r--protocols/ICQCorp/src/corp.cpp24
-rw-r--r--protocols/ICQCorp/src/options.cpp2
-rw-r--r--protocols/ICQCorp/src/protocol.cpp6
-rw-r--r--protocols/ICQCorp/src/services.cpp2
-rw-r--r--protocols/ICQCorp/src/stdafx.h20
-rw-r--r--protocols/ICQCorp/src/user.cpp2
6 files changed, 25 insertions, 31 deletions
diff --git a/protocols/ICQCorp/src/corp.cpp b/protocols/ICQCorp/src/corp.cpp
index 523917cb3e..35292633dc 100644
--- a/protocols/ICQCorp/src/corp.cpp
+++ b/protocols/ICQCorp/src/corp.cpp
@@ -23,7 +23,7 @@
int hLangpack;
char protoName[64];
-HINSTANCE hInstance;
+CMPlugin g_plugin;
HNETLIBUSER hNetlibUser;
PLUGININFOEX pluginInfo =
@@ -50,28 +50,6 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC
///////////////////////////////////////////////////////////////////////////////
-BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD reason, LPVOID)
-{
- hInstance = hModule;
- if (reason == DLL_PROCESS_ATTACH) {
- char fileName[MAX_PATH];
- GetModuleFileNameA(hInstance, fileName, MAX_PATH);
-
- WIN32_FIND_DATAA findData;
- FindClose(FindFirstFileA(fileName, &findData));
- findData.cFileName[strlen(findData.cFileName) - 4] = 0;
- strncpy_s(protoName, findData.cFileName, _TRUNCATE);
-
- Proto_RegisterModule(PROTOTYPE_PROTOCOL, protoName);
- Proto_SetUniqueId(protoName, "UIN");
-
- DisableThreadLibraryCalls(hModule);
- }
- return TRUE;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
extern "C" __declspec(dllexport) int Load()
{
mir_getLP(&pluginInfo);
diff --git a/protocols/ICQCorp/src/options.cpp b/protocols/ICQCorp/src/options.cpp
index 5b1ed9414e..c463d41dfc 100644
--- a/protocols/ICQCorp/src/options.cpp
+++ b/protocols/ICQCorp/src/options.cpp
@@ -72,7 +72,7 @@ int icqOptionsInitialise(WPARAM wParam, LPARAM)
odp.szTitle.a = protoName;
odp.pfnDlgProc = icqOptionsDlgProc;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_ICQCORP);
- odp.hInstance = hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.szGroup.a = LPGEN("Network");
odp.flags = ODPF_BOLDGROUPS;
Options_AddPage(wParam, &odp);
diff --git a/protocols/ICQCorp/src/protocol.cpp b/protocols/ICQCorp/src/protocol.cpp
index 821a94c7d0..7faa6c832e 100644
--- a/protocols/ICQCorp/src/protocol.cpp
+++ b/protocols/ICQCorp/src/protocol.cpp
@@ -160,11 +160,11 @@ bool ICQ::load()
awayMessage = new char[1];
awayMessage[0] = 0;
- WNDCLASSA wc = { 0, messageWndProc, 0, 0, hInstance, nullptr, nullptr, nullptr, nullptr, protoName };
+ WNDCLASSA wc = { 0, messageWndProc, 0, 0, g_plugin.getInst(), nullptr, nullptr, nullptr, nullptr, protoName };
if (!RegisterClassA(&wc))
return false;
- hWnd = CreateWindowExA(0, protoName, nullptr, 0, 0, 0, 0, 0, (unsigned short)GetVersion() >= 5 ? HWND_MESSAGE : nullptr, nullptr, hInstance, nullptr);
+ hWnd = CreateWindowExA(0, protoName, nullptr, 0, 0, 0, 0, 0, (unsigned short)GetVersion() >= 5 ? HWND_MESSAGE : nullptr, nullptr, g_plugin.getInst(), nullptr);
if (hWnd == nullptr)
return false;
@@ -185,7 +185,7 @@ void ICQ::unload()
WSACleanup();
DestroyWindow(hWnd);
- UnregisterClassA(protoName, hInstance);
+ UnregisterClassA(protoName, g_plugin.getInst());
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/ICQCorp/src/services.cpp b/protocols/ICQCorp/src/services.cpp
index f0ff3c96f6..7b81bc5671 100644
--- a/protocols/ICQCorp/src/services.cpp
+++ b/protocols/ICQCorp/src/services.cpp
@@ -57,7 +57,7 @@ static INT_PTR icqLoadIcon(WPARAM wParam, LPARAM)
case PLI_PROTOCOL: id = IDI_ICQCORP; break;
default: return NULL;
}
- return (INT_PTR)LoadImage(hInstance, MAKEINTRESOURCE(id), IMAGE_ICON, GetSystemMetrics(wParam & PLIF_SMALL ? SM_CXSMICON : SM_CXICON), GetSystemMetrics(wParam & PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0);
+ return (INT_PTR)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(id), IMAGE_ICON, GetSystemMetrics(wParam & PLIF_SMALL ? SM_CXSMICON : SM_CXICON), GetSystemMetrics(wParam & PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/ICQCorp/src/stdafx.h b/protocols/ICQCorp/src/stdafx.h
index 55864cf479..d31ba24953 100644
--- a/protocols/ICQCorp/src/stdafx.h
+++ b/protocols/ICQCorp/src/stdafx.h
@@ -27,7 +27,6 @@
#include <vector>
#include <time.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_system.h>
#include <m_protosvc.h>
@@ -53,8 +52,25 @@
///////////////////////////////////////////////////////////////////////////////
extern HNETLIBUSER hNetlibUser;
-extern HINSTANCE hInstance;
extern char protoName[64];
extern int LoadServices();
extern int UnloadServices();
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(protoName)
+ {
+ char fileName[MAX_PATH];
+ GetModuleFileNameA(m_hInst, fileName, MAX_PATH);
+
+ WIN32_FIND_DATAA findData;
+ FindClose(FindFirstFileA(fileName, &findData));
+ findData.cFileName[strlen(findData.cFileName) - 4] = 0;
+ strncpy_s(protoName, findData.cFileName, _TRUNCATE);
+
+ Proto_RegisterModule(PROTOTYPE_PROTOCOL, protoName);
+ Proto_SetUniqueId(protoName, "UIN");
+ }
+};
diff --git a/protocols/ICQCorp/src/user.cpp b/protocols/ICQCorp/src/user.cpp
index 97ad5becb7..becb17221f 100644
--- a/protocols/ICQCorp/src/user.cpp
+++ b/protocols/ICQCorp/src/user.cpp
@@ -155,7 +155,7 @@ int icqUserInfoInitialise(WPARAM wParam, LPARAM lParam)
odp.szTitle.a = protoName;
odp.pfnDlgProc = icqUserInfoDlgProc;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_ICQCORP);
- odp.hInstance = hInstance;
+ odp.hInstance = g_plugin.getInst();
UserInfo_AddPage(wParam, &odp);
return 0;
}