diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-18 20:51:18 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-18 20:51:18 +0300 |
commit | 9cf1444eb7888f2d942d220f938aa893396a8a1b (patch) | |
tree | ea87e4cb78e9c26a651af00b2d423324ce4a85a6 /protocols | |
parent | 3936ebbc665c9653d9f62527c1e136944d52e2ca (diff) |
g_hInstance incapulated into PLUGIN<>, no need in the separate variable
Diffstat (limited to 'protocols')
114 files changed, 410 insertions, 422 deletions
diff --git a/protocols/Discord/src/main.cpp b/protocols/Discord/src/main.cpp index 3b50bc946b..c0c06bb5cc 100644 --- a/protocols/Discord/src/main.cpp +++ b/protocols/Discord/src/main.cpp @@ -17,20 +17,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h" -CMPlugin g_plugin; CHAT_MANAGER *pci; -HINSTANCE g_hInstance; int hLangpack = 0; HWND g_hwndHeartbeat; -extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; - -IconItem g_iconList[] = -{ - { LPGEN("Main icon"), "main", IDI_MAIN }, - { LPGEN("Group chats"), "groupchat", IDI_GROUPCHAT } -}; - PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -44,12 +34,18 @@ PLUGININFOEX pluginInfo = { { 0x88928401, 0x2ce8, 0x4568, { 0xaa, 0xa7, 0x22, 0x61, 0x41, 0x87, 0x0c, 0xbf } } }; - extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { return &pluginInfo; } ///////////////////////////////////////////////////////////////////////////////////////// + +CMPlugin g_plugin; + +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; + +///////////////////////////////////////////////////////////////////////////////////////// // Interface information extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; @@ -57,6 +53,12 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC ///////////////////////////////////////////////////////////////////////////////////////// // Load +IconItem g_iconList[] = +{ + { LPGEN("Main icon"), "main", IDI_MAIN }, + { LPGEN("Group chats"), "groupchat", IDI_GROUPCHAT } +}; + extern "C" int __declspec(dllexport) Load(void) { mir_getLP(&pluginInfo); @@ -64,7 +66,7 @@ extern "C" int __declspec(dllexport) Load(void) g_hwndHeartbeat = CreateWindowEx(0, L"STATIC", nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr); - Icon_Register(g_hInstance, "Discord", g_iconList, _countof(g_iconList)); + Icon_Register(g_plugin.getInst(), "Discord", g_iconList, _countof(g_iconList)); return 0; } diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index c3cd1eda57..f15f31bb1b 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -164,7 +164,7 @@ static INT_PTR CALLBACK AdvancedSearchDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa HWND CDiscordProto::CreateExtendedSearchUI(HWND hwndParent) { if (hwndParent) - return CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_EXTSEARCH), hwndParent, AdvancedSearchDlgProc, 0); + return CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EXTSEARCH), hwndParent, AdvancedSearchDlgProc, 0); return nullptr; } diff --git a/protocols/Discord/src/stdafx.h b/protocols/Discord/src/stdafx.h index 5c83a50ef0..76a0d44862 100644 --- a/protocols/Discord/src/stdafx.h +++ b/protocols/Discord/src/stdafx.h @@ -44,7 +44,6 @@ #include "../../libs/zlib/src/zlib.h" extern IconItem g_iconList[]; -extern HINSTANCE g_hInstance; extern HWND g_hwndHeartbeat; #define DB_KEY_ID "id" diff --git a/protocols/Dummy/src/dummy.h b/protocols/Dummy/src/dummy.h index 90b08dd243..32ddb8d345 100644 --- a/protocols/Dummy/src/dummy.h +++ b/protocols/Dummy/src/dummy.h @@ -18,8 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #pragma once
struct CDummyProto;
-extern LIST<CDummyProto> dummy_Instances;
-extern HINSTANCE g_hInstance;
#define DUMMY_ID_TEMPLATE "Template"
#define DUMMY_ID_TEXT "UniqueIdText"
@@ -34,36 +32,51 @@ struct message_data int msgid;
};
-typedef struct {
+struct ttemplate
+{
const char *name;
const char *setting;
const char *text;
-} ttemplate;
+};
+
+static const ttemplate templates[] =
+{
+ { LPGEN("Custom"), "", "" },
+ { "AIM", "SN", LPGEN("Screen name") },
+ { "EmLAN", "Nick", LPGEN("User name") },
+ { "Facebook", "ID", LPGEN("Facebook ID") },
+ { "GG", "UIN", LPGEN("Gadu-Gadu number") },
+ { "ICQ", "UIN", LPGEN("User ID") },
+ { "ICQCorp", "UIN", LPGEN("ICQ number") },
+ { "IRC", "Nick", LPGEN("Nickname") },
+ { "Jabber", "jid", LPGEN("JID") },
+ { "MinecraftDynmap", "Nick", LPGEN("Visible name") },
+ { "MRA", "e-mail", LPGEN("E-mail address") },
+ { "MSN", "e-mail", LPGEN("Live ID") },
+ { "Omegle", "nick", LPGEN("Visible name") },
+ { "Sametime", "stid", LPGEN("ID") },
+ { "Skype (SkypeKit)", "sid", LPGEN("Skype name") },
+ { "Skype (Classic)", "Username", LPGEN("Skype name") },
+ { "Skype (Web)", "Username", LPGEN("Skype name") },
+ { "Steam", "SteamID", LPGEN("Steam ID") },
+ { "Tlen", "jid", LPGEN("Tlen login") },
+ { "Tox", "ToxID", LPGEN("Tox ID") },
+ { "Twitter", "Username", LPGEN("Username") },
+ { "VK", "ID", LPGEN("VKontakte ID") },
+ { "WhatsApp", "ID", LPGEN("WhatsApp ID") },
+ { "XFire", "Username", LPGEN("Username") },
+ { "Yahoo", "yahoo_id", LPGEN("ID") },
+};
-static const ttemplate templates[] = {
- { LPGEN("Custom"), "", "" },
- { "AIM", "SN", LPGEN("Screen name") },
- { "EmLAN", "Nick", LPGEN("User name") },
- { "Facebook", "ID", LPGEN("Facebook ID") },
- { "GG", "UIN", LPGEN("Gadu-Gadu number") },
- { "ICQ", "UIN", LPGEN("User ID") },
- { "ICQCorp", "UIN", LPGEN("ICQ number") },
- { "IRC", "Nick", LPGEN("Nickname") },
- { "Jabber", "jid", LPGEN("JID") },
- { "MinecraftDynmap", "Nick", LPGEN("Visible name") },
- { "MRA", "e-mail", LPGEN("E-mail address") },
- { "MSN", "e-mail", LPGEN("Live ID") },
- { "Omegle", "nick", LPGEN("Visible name") },
- { "Sametime", "stid", LPGEN("ID") },
- { "Skype (SkypeKit)", "sid", LPGEN("Skype name") },
- { "Skype (Classic)", "Username", LPGEN("Skype name") },
- { "Skype (Web)", "Username", LPGEN("Skype name") },
- { "Steam", "SteamID", LPGEN("Steam ID") },
- { "Tlen", "jid", LPGEN("Tlen login") },
- { "Tox", "ToxID", LPGEN("Tox ID") },
- { "Twitter", "Username", LPGEN("Username") },
- { "VK", "ID", LPGEN("VKontakte ID") },
- { "WhatsApp", "ID", LPGEN("WhatsApp ID") },
- { "XFire", "Username", LPGEN("Username") },
- { "Yahoo", "yahoo_id", LPGEN("ID") },
+struct CMPlugin : public ACCPROTOPLUGIN<CDummyProto>
+{
+ CMPlugin() :
+ ACCPROTOPLUGIN<CDummyProto>("Dummy")
+ {
+ int id = db_get_b(0, m_szModuleName, DUMMY_ID_TEMPLATE, -1);
+ if (id < 0 || id >= _countof(templates))
+ SetUniqueId(ptrA(db_get_sa(0, m_szModuleName, DUMMY_ID_SETTING)));
+ else
+ SetUniqueId(templates[id].setting);
+ }
};
diff --git a/protocols/Dummy/src/dummy_options.cpp b/protocols/Dummy/src/dummy_options.cpp index 701d647589..3312d83f35 100644 --- a/protocols/Dummy/src/dummy_options.cpp +++ b/protocols/Dummy/src/dummy_options.cpp @@ -116,5 +116,5 @@ INT_PTR CALLBACK DummyAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM INT_PTR CDummyProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam)
{
- return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, DummyAccountProc, (LPARAM)this);
+ return (INT_PTR)CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, DummyAccountProc, (LPARAM)this);
}
diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp index f95c8ccfb4..c68b687c18 100644 --- a/protocols/Dummy/src/dummy_proto.cpp +++ b/protocols/Dummy/src/dummy_proto.cpp @@ -52,8 +52,6 @@ static int sttCompareProtocols(const CDummyProto *p1, const CDummyProto *p2) return mir_wstrcmp(p1->m_tszUserName, p2->m_tszUserName); } -LIST<CDummyProto> dummy_Instances(1, sttCompareProtocols); - CDummyProto::CDummyProto(const char *szModuleName, const wchar_t *ptszUserName) : PROTO<CDummyProto>(szModuleName, ptszUserName) { @@ -70,14 +68,12 @@ CDummyProto::CDummyProto(const char *szModuleName, const wchar_t *ptszUserName) else uniqueIdText[0] = '\0'; uniqueIdSetting[0] = '\0'; - - dummy_Instances.insert(this); } CDummyProto::~CDummyProto() { - Netlib_CloseHandle(m_hNetlibUser); m_hNetlibUser = nullptr; - dummy_Instances.remove(this); + Netlib_CloseHandle(m_hNetlibUser); + m_hNetlibUser = nullptr; } ////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Dummy/src/main.cpp b/protocols/Dummy/src/main.cpp index 93492c1df6..453a68b51c 100644 --- a/protocols/Dummy/src/main.cpp +++ b/protocols/Dummy/src/main.cpp @@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
#include "version.h"
-HINSTANCE g_hInstance;
int hLangpack;
CLIST_INTERFACE *pcli;
@@ -75,18 +74,6 @@ extern "C" int __declspec(dllexport) Unload(void) /////////////////////////////////////////////////////////////////////////////////////////
-struct CMPlugin : public ACCPROTOPLUGIN<CDummyProto>
-{
- CMPlugin() :
- ACCPROTOPLUGIN<CDummyProto>("Dummy")
- {
- int id = db_get_b(0, m_szModuleName, DUMMY_ID_TEMPLATE, -1);
- if (id < 0 || id >= _countof(templates))
- SetUniqueId(ptrA(db_get_sa(0, m_szModuleName, DUMMY_ID_SETTING)));
- else
- SetUniqueId(templates[id].setting);
- }
-}
- g_plugin;
+CMPlugin g_plugin;
extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
diff --git a/protocols/EmLanProto/src/amdproto.cpp b/protocols/EmLanProto/src/amdproto.cpp index 9efd5a1ac3..4e5db0990e 100644 --- a/protocols/EmLanProto/src/amdproto.cpp +++ b/protocols/EmLanProto/src/amdproto.cpp @@ -3,6 +3,21 @@ #include "stdafx.h"
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+//////////////////////////////////////////////////////////////////////////
+
+CMLan* g_lan = nullptr;
+
+int hLangpack;
+bool g_InitOptions = false;
+
+#ifdef VERBOSE
+std::fstream emlanLog("EmLanLog.txt", std::ios::out|std::ios::app);
+#endif
+
//////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfo = {
@@ -18,22 +33,12 @@ PLUGININFOEX pluginInfo = { { 0xe08ce7c4, 0x9eeb, 0x4272, { 0xb5, 0x44, 0xd, 0x32, 0xe1, 0x8d, 0x90, 0xde } }
};
-HINSTANCE g_hInstance = nullptr;
-CMLan* g_lan = nullptr;
-
-int hLangpack;
-bool g_InitOptions = false;
-
-#ifdef VERBOSE
-std::fstream emlanLog("EmLanLog.txt", std::ios::out|std::ios::app);
-#endif
-
extern "C" __declspec(dllexport) PLUGININFOEX* __cdecl MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
-//////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// Interface information
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
@@ -42,7 +47,6 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC BOOL APIENTRY DllMain(HINSTANCE hInstDLL, DWORD reason, LPVOID)
{
- g_hInstance = hInstDLL;
if (reason == DLL_PROCESS_ATTACH) {
EMLOG("EmLan Started");
DisableThreadLibraryCalls(hInstDLL);
@@ -84,7 +88,7 @@ static INT_PTR __cdecl EMPLoadIcon(WPARAM wParam, LPARAM) if ((wParam & 0xFFFF) != PLI_PROTOCOL)
return 0;
- return (INT_PTR)LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON_ONLINE));
+ return (INT_PTR)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ICON_ONLINE));
}
static INT_PTR __cdecl EMPGetStatus(WPARAM, LPARAM)
@@ -272,7 +276,7 @@ int __cdecl EMPCreateOptionsDlg(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_EMP_FORM_OPT);
odp.szTitle.a = LPGEN("E-mage LAN protocol");
odp.szGroup.a = LPGEN("Network");
@@ -359,18 +363,3 @@ extern "C" int __declspec(dllexport) __cdecl Unload() delete g_lan;
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-struct CMPlugin : public PLUGIN<CMPlugin>
-{
- CMPlugin() :
- PLUGIN<CMPlugin>(PROTONAME)
- {
- RegisterProtocol(PROTOTYPE_PROTOCOL);
- SetUniqueId("Nick");
- }
-}
- g_plugin;
-
-extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
diff --git a/protocols/EmLanProto/src/stdafx.h b/protocols/EmLanProto/src/stdafx.h index d80030c4b1..f3156dd280 100644 --- a/protocols/EmLanProto/src/stdafx.h +++ b/protocols/EmLanProto/src/stdafx.h @@ -26,13 +26,15 @@ #define PROTONAME "EM_LAN_PROTO"
-//#define ME_ICQ_STATUSMSGREQ "ICQ/StatusMsgReq"
-//
-//#define ICQ_MSGTYPE_GETAWAYMSG 0xE8
-//#define ICQ_MSGTYPE_GETOCCUMSG 0xE9
-//#define ICQ_MSGTYPE_GETNAMSG 0xEA
-//#define ICQ_MSGTYPE_GETDNDMSG 0xEB
-//#define ICQ_MSGTYPE_GETFFCMSG 0xEC
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(PROTONAME)
+ {
+ RegisterProtocol(PROTOTYPE_PROTOCOL);
+ SetUniqueId("Nick");
+ }
+};
//#define VERBOSE
diff --git a/protocols/FacebookRM/src/captcha.cpp b/protocols/FacebookRM/src/captcha.cpp index 96f13447d5..4ab92bd91b 100644 --- a/protocols/FacebookRM/src/captcha.cpp +++ b/protocols/FacebookRM/src/captcha.cpp @@ -126,7 +126,7 @@ bool FacebookProto::RunCaptchaForm(std::string captchaUrl, std::string &result) GetObject(param.bmp, sizeof(bmp), &bmp); param.w = bmp.bmWidth; param.h = bmp.bmHeight; - int res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CAPTCHAFORM), nullptr, CaptchaFormDlgProc, (LPARAM)¶m); + int res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CAPTCHAFORM), nullptr, CaptchaFormDlgProc, (LPARAM)¶m); if (res == 0) return false; diff --git a/protocols/FacebookRM/src/main.cpp b/protocols/FacebookRM/src/main.cpp index a2d89766aa..cb1d42f23b 100644 --- a/protocols/FacebookRM/src/main.cpp +++ b/protocols/FacebookRM/src/main.cpp @@ -22,12 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
-// TODO: Make following as "globals" structure?
-
-CMPlugin g_plugin;
int hLangpack;
-HINSTANCE g_hInstance;
std::string g_strUserAgent;
DWORD g_mirandaVersion;
@@ -51,6 +47,12 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda }
/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Interface information
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
@@ -91,5 +93,3 @@ extern "C" int __declspec(dllexport) Unload(void) {
return 0;
}
-
-extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index f8c66e68b5..61b3d8de79 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -415,7 +415,7 @@ int FacebookProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam) INT_PTR FacebookProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam) { - return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_FACEBOOKACCOUNT), + return (INT_PTR)CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FACEBOOKACCOUNT), (HWND)lParam, FBAccountProc, (LPARAM)this); } @@ -442,7 +442,7 @@ int FacebookProto::OnPreShutdown(WPARAM, LPARAM) int FacebookProto::OnOptionsInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = g_hInstance; + odp.hInstance = g_plugin.getInst(); odp.szTitle.w = m_tszUserName; odp.dwInitParam = LPARAM(this); odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE; @@ -516,7 +516,7 @@ INT_PTR FacebookProto::OnMind(WPARAM wParam, LPARAM) for (auto &iter : facy.pages) data->walls.push_back(new wall_data(iter.first, mir_utf8decodeW(iter.second.c_str()), true)); - HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MIND), (HWND)nullptr, FBMindProc, reinterpret_cast<LPARAM>(data)); + HWND hDlg = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_MIND), (HWND)nullptr, FBMindProc, reinterpret_cast<LPARAM>(data)); ShowWindow(hDlg, SW_SHOW); return 0; diff --git a/protocols/FacebookRM/src/stdafx.h b/protocols/FacebookRM/src/stdafx.h index 5d6a51b0ac..f41eb6c7f1 100644 --- a/protocols/FacebookRM/src/stdafx.h +++ b/protocols/FacebookRM/src/stdafx.h @@ -80,7 +80,6 @@ class FacebookProto; #include "resource.h"
#include "version.h"
-extern HINSTANCE g_hInstance;
extern std::string g_strUserAgent;
extern DWORD g_mirandaVersion;
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp index ce5fb25df3..71fb869c95 100644 --- a/protocols/FacebookRM/src/theme.cpp +++ b/protocols/FacebookRM/src/theme.cpp @@ -54,7 +54,7 @@ static IconItem icons[] = void InitIcons(void)
{
- Icon_Register(g_hInstance, "Protocols/Facebook", icons, _countof(icons), "Facebook");
+ Icon_Register(g_plugin.getInst(), "Protocols/Facebook", icons, _countof(icons), "Facebook");
}
HANDLE GetIconHandle(const char* name)
diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp index 5ebdb40815..bc311e486a 100644 --- a/protocols/Gadu-Gadu/src/dialogs.cpp +++ b/protocols/Gadu-Gadu/src/dialogs.cpp @@ -357,19 +357,19 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, dat.gg = gg; if (LOWORD(wParam) == IDC_CREATEACCOUNT) { dat.mode = GG_USERUTIL_CREATE; - ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); + ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); } else if (LOWORD(wParam) == IDC_CHPASS) { dat.mode = GG_USERUTIL_PASS; - ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHPASS), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); + ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHPASS), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); } else if (LOWORD(wParam) == IDC_CHEMAIL) { dat.mode = GG_USERUTIL_EMAIL; - ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHEMAIL), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); + ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHEMAIL), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); } else { dat.mode = GG_USERUTIL_REMOVE; - ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_REMOVEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); + ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_REMOVEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); } if (ret == IDOK) { @@ -759,7 +759,7 @@ int GaduProto::options_init(WPARAM wParam, LPARAM) OPTIONSDIALOGPAGE odp = { 0 }; odp.flags = ODPF_UNICODE; odp.position = 1003000; - odp.hInstance = g_hInstance; + odp.hInstance = g_plugin.getInst(); odp.szGroup.w = LPGENW("Network"); odp.szTitle.w = m_tszUserName; odp.dwInitParam = (LPARAM)this; @@ -809,7 +809,7 @@ int GaduProto::details_init(WPARAM wParam, LPARAM lParam) OPTIONSDIALOGPAGE odp = { 0 }; odp.flags = ODPF_DONTTRANSLATE | ODPF_UNICODE; - odp.hInstance = g_hInstance; + odp.hInstance = g_plugin.getInst(); odp.pfnDlgProc = gg_detailsdlgproc; odp.position = -1900000000; odp.pszTemplate = pszTemplate; @@ -867,7 +867,7 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP dat.email = email; dat.gg = gg; dat.mode = GG_USERUTIL_CREATE; - int ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); + int ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat); if (ret == IDOK) { DBVARIANT dbv; diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index bec809277c..8bd715294d 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -38,15 +38,16 @@ PLUGININFOEX pluginInfo = { };
// Other variables
-CMPlugin g_plugin;
-HINSTANCE g_hInstance;
-
SSL_API sslApi;
CLIST_INTERFACE *pcli;
int hLangpack;
static unsigned long crc_table[256];
+//////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
//////////////////////////////////////////////////////////
diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h index f96f613fdd..f02dc0be26 100644 --- a/protocols/Gadu-Gadu/src/gg.h +++ b/protocols/Gadu-Gadu/src/gg.h @@ -258,7 +258,6 @@ struct GGGETAVATARDATA struct GaduProto;
-extern HINSTANCE g_hInstance;
extern CLIST_INTERFACE *pcli;
extern PLUGININFOEX pluginInfo;
extern IconItem iconList[];
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp index 2b2c9eefc5..7e086f9060 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.cpp +++ b/protocols/Gadu-Gadu/src/gg_proto.cpp @@ -507,7 +507,7 @@ static INT_PTR CALLBACK gg_advancedsearchdlgproc(HWND hwndDlg, UINT message, WPA HWND GaduProto::CreateExtendedSearchUI(HWND owner)
{
- return CreateDialogParam(g_hInstance,
+ return CreateDialogParam(g_plugin.getInst(),
MAKEINTRESOURCE(IDD_GGADVANCEDSEARCH), owner, gg_advancedsearchdlgproc, (LPARAM)this);
}
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 1ea195a83b..d46c8584df 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -600,7 +600,7 @@ INT_PTR GaduProto::gc_openconf(WPARAM, LPARAM) return 0;
}
- CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_CONFERENCE), nullptr, gg_gc_openconfdlg, (LPARAM)this);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONFERENCE), nullptr, gg_gc_openconfdlg, (LPARAM)this);
return 1;
}
diff --git a/protocols/Gadu-Gadu/src/icolib.cpp b/protocols/Gadu-Gadu/src/icolib.cpp index 7ee2a5e5fd..93cd157edc 100644 --- a/protocols/Gadu-Gadu/src/icolib.cpp +++ b/protocols/Gadu-Gadu/src/icolib.cpp @@ -43,7 +43,7 @@ extern IconItem iconList[] = void gg_icolib_init()
{
- Icon_Register(g_hInstance, "Protocols/" GGDEF_PROTO, iconList, _countof(iconList), GGDEF_PROTO);
+ Icon_Register(g_plugin.getInst(), "Protocols/" GGDEF_PROTO, iconList, _countof(iconList), GGDEF_PROTO);
}
HICON LoadIconEx(const char* name, bool big)
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index 909ee5c078..2dc6c14b41 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -256,7 +256,7 @@ int gg_img_saveimage(HWND hwnd, GGIMAGEENTRY *dat) OPENFILENAME ofn = { 0 };
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwnd;
- ofn.hInstance = g_hInstance;
+ ofn.hInstance = g_plugin.getInst();
ofn.lpstrFile = szFileName;
ofn.lpstrFilter = szFilter;
ofn.nMaxFile = MAX_PATH;
@@ -439,7 +439,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE;
case WM_SIZE:
- Utils_ResizeDialog(hwndDlg, g_hInstance, dat->bReceiving ? MAKEINTRESOURCEA(IDD_IMAGE_RECV) : MAKEINTRESOURCEA(IDD_IMAGE_SEND), sttImageDlgResizer);
+ Utils_ResizeDialog(hwndDlg, g_plugin.getInst(), dat->bReceiving ? MAKEINTRESOURCEA(IDD_IMAGE_RECV) : MAKEINTRESOURCEA(IDD_IMAGE_SEND), sttImageDlgResizer);
if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED)
InvalidateRect(hwndDlg, nullptr, FALSE);
return 0;
@@ -669,7 +669,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP *szFileName = 0;
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwndDlg;
- ofn.hInstance = g_hInstance;
+ ofn.hInstance = g_plugin.getInst();
ofn.lpstrFilter = szFilter;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
@@ -708,7 +708,7 @@ void __cdecl GaduProto::img_dlgcallthread(void *param) HWND hMIWnd = nullptr;
GGIMAGEDLGDATA *dat = (GGIMAGEDLGDATA *)param;
- DialogBoxParam(g_hInstance, dat->bReceiving ? MAKEINTRESOURCE(IDD_IMAGE_RECV) : MAKEINTRESOURCE(IDD_IMAGE_SEND),
+ DialogBoxParam(g_plugin.getInst(), dat->bReceiving ? MAKEINTRESOURCE(IDD_IMAGE_RECV) : MAKEINTRESOURCE(IDD_IMAGE_SEND),
hMIWnd, gg_img_dlgproc, (LPARAM)dat);
#ifdef DEBUGMODE
diff --git a/protocols/Gadu-Gadu/src/links.cpp b/protocols/Gadu-Gadu/src/links.cpp index 7ef2ec6cf6..c1f56f702c 100644 --- a/protocols/Gadu-Gadu/src/links.cpp +++ b/protocols/Gadu-Gadu/src/links.cpp @@ -108,7 +108,7 @@ void gg_links_init() {
if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
CreateServiceFunction(GGS_PARSELINK, gg_parselink);
- AssocMgr_AddNewUrlTypeW("gg:", TranslateT("Gadu-Gadu Link Protocol"), g_hInstance, IDI_GG, GGS_PARSELINK, 0);
+ AssocMgr_AddNewUrlTypeW("gg:", TranslateT("Gadu-Gadu Link Protocol"), g_plugin.getInst(), IDI_GG, GGS_PARSELINK, 0);
}
}
diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp index 425eb044a2..f58bcc2e50 100644 --- a/protocols/Gadu-Gadu/src/services.cpp +++ b/protocols/Gadu-Gadu/src/services.cpp @@ -379,7 +379,7 @@ extern INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwnd, UINT msg, WPARAM wParam //
INT_PTR GaduProto::get_acc_mgr_gui(WPARAM, LPARAM lParam)
{
- return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, gg_acc_mgr_guidlgproc, (LPARAM)this);
+ return (INT_PTR)CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, gg_acc_mgr_guidlgproc, (LPARAM)this);
}
//////////////////////////////////////////////////////////
diff --git a/protocols/Gadu-Gadu/src/sessions.cpp b/protocols/Gadu-Gadu/src/sessions.cpp index 63ba37d099..10b4dc5c42 100644 --- a/protocols/Gadu-Gadu/src/sessions.cpp +++ b/protocols/Gadu-Gadu/src/sessions.cpp @@ -360,7 +360,7 @@ static INT_PTR CALLBACK gg_sessions_viewdlg(HWND hwndDlg, UINT message, WPARAM w return 0;
case WM_SIZE:
- Utils_ResizeDialog(hwndDlg, g_hInstance, MAKEINTRESOURCEA(IDD_SESSIONS), sttSessionsDlgResizer);
+ Utils_ResizeDialog(hwndDlg, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_SESSIONS), sttSessionsDlgResizer);
return 0;
case WM_SETCURSOR:
@@ -397,7 +397,7 @@ INT_PTR GaduProto::sessions_view(WPARAM, LPARAM) SetFocus(hwndSessionsDlg);
}
else
- CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SESSIONS), nullptr, gg_sessions_viewdlg, (LPARAM)this);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SESSIONS), nullptr, gg_sessions_viewdlg, (LPARAM)this);
return 0;
}
diff --git a/protocols/Gadu-Gadu/src/token.cpp b/protocols/Gadu-Gadu/src/token.cpp index 9f7f80b87c..322021b80b 100644 --- a/protocols/Gadu-Gadu/src/token.cpp +++ b/protocols/Gadu-Gadu/src/token.cpp @@ -145,7 +145,7 @@ int GaduProto::gettoken(GGTOKEN *token) }
// Load token dialog
- if (DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_TOKEN), nullptr, gg_tokendlgproc, (LPARAM)&dat) == IDCANCEL)
+ if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_TOKEN), nullptr, gg_tokendlgproc, (LPARAM)&dat) == IDCANCEL)
return FALSE;
// Fillup patterns
diff --git a/protocols/IRCG/src/main.cpp b/protocols/IRCG/src/main.cpp index 8b4c3597ad..af7f13d4b5 100644 --- a/protocols/IRCG/src/main.cpp +++ b/protocols/IRCG/src/main.cpp @@ -22,10 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
#include "version.h"
-CMPlugin g_plugin;
CHAT_MANAGER *pci;
CLIST_INTERFACE *pcli;
-HINSTANCE g_hInstance;
int hLangpack;
@@ -49,16 +47,23 @@ PLUGININFOEX pluginInfo = __COPYRIGHT,
__AUTHORWEB,
UNICODE_AWARE,
- {0x92382b4d, 0x5572, 0x48a0, {0xb0, 0xb9, 0x13, 0x36, 0xa6, 0x1, 0xd6, 0x89}} // {92382B4D-5572-48a0-B0B9-1336A601D689}
+ // {92382B4D-5572-48a0-B0B9-1336A601D689}
+ { 0x92382b4d, 0x5572, 0x48a0, {0xb0, 0xb9, 0x13, 0x36, 0xa6, 0x1, 0xd6, 0x89 }}
};
-extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index 344999e511..dc4a82a630 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -204,7 +204,7 @@ static IconItem iconList[] = void InitIcons(void)
{
- Icon_Register(g_hInstance, "Protocols/IRC", iconList, _countof(iconList), "IRC");
+ Icon_Register(g_plugin.getInst(), "Protocols/IRC", iconList, _countof(iconList), "IRC");
}
HICON LoadIconEx(int iconId, bool big)
@@ -1848,7 +1848,7 @@ void InitServers() wchar_t *szIniFile = Utils_ReplaceVarsW(L"%temp%\\default_servers.ini");
FILE *serverFile = _wfopen(szIniFile, L"a");
if (serverFile) {
- char* pszSvrs = (char*)LockResource(LoadResource(g_hInstance, FindResource(g_hInstance, MAKEINTRESOURCE(IDR_SERVERS), L"TEXT")));
+ char* pszSvrs = (char*)LockResource(LoadResource(g_plugin.getInst(), FindResource(g_plugin.getInst(), MAKEINTRESOURCE(IDR_SERVERS), L"TEXT")));
if (pszSvrs)
fwrite(pszSvrs, 1, mir_strlen(pszSvrs) + 1, serverFile);
fclose(serverFile);
diff --git a/protocols/IRCG/src/stdafx.h b/protocols/IRCG/src/stdafx.h index 896d6a6097..fff9477127 100644 --- a/protocols/IRCG/src/stdafx.h +++ b/protocols/IRCG/src/stdafx.h @@ -200,8 +200,6 @@ using namespace irc; // Functions
// main.cpp
-extern HINSTANCE g_hInstance;
-
extern OBJLIST<SERVER_INFO> g_servers;
CIrcProto* GetTimerOwner(UINT_PTR eventId);
diff --git a/protocols/IRCG/src/userinfo.cpp b/protocols/IRCG/src/userinfo.cpp index c04c7036a9..56946ec121 100644 --- a/protocols/IRCG/src/userinfo.cpp +++ b/protocols/IRCG/src/userinfo.cpp @@ -212,7 +212,7 @@ int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM lParam) odp.flags = ODPF_DONTTRANSLATE;
odp.szTitle.a = m_szModuleName;
odp.dwInitParam = (LPARAM)this;
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.position = -1900000000;
odp.pfnDlgProc = UserDetailsDlgProc;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO);
diff --git a/protocols/IcqOscarJ/src/dlgproc.cpp b/protocols/IcqOscarJ/src/dlgproc.cpp index d7c91e5e8c..8a83351565 100644 --- a/protocols/IcqOscarJ/src/dlgproc.cpp +++ b/protocols/IcqOscarJ/src/dlgproc.cpp @@ -440,7 +440,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (IsIconic(hwndDlg))
break;
- Utils_ResizeDialog(hwndDlg, g_hInstance, MAKEINTRESOURCEA(IDD_INFO_CHANGEINFO), ChangeInfoDlg_Resize);
+ Utils_ResizeDialog(hwndDlg, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_INFO_CHANGEINFO), ChangeInfoDlg_Resize);
{
RECT rc; // update listview column widths
GetClientRect(dat->hwndList, &rc);
diff --git a/protocols/IcqOscarJ/src/editlist.cpp b/protocols/IcqOscarJ/src/editlist.cpp index f0d88461dd..8f919b577f 100644 --- a/protocols/IcqOscarJ/src/editlist.cpp +++ b/protocols/IcqOscarJ/src/editlist.cpp @@ -80,7 +80,7 @@ void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey dataListEdit = this;
hwndListEdit = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, L"LISTBOX", L"", WS_POPUP | WS_BORDER | WS_VSCROLL,
- rc->left, rc->bottom, rc->right - rc->left, 150, nullptr, nullptr, g_hInstance, nullptr);
+ rc->left, rc->bottom, rc->right - rc->left, 150, nullptr, nullptr, g_plugin.getInst(), nullptr);
SendMessage(hwndListEdit, WM_SETFONT, (WPARAM)hListFont, 0);
int itemHeight = SendMessage(hwndListEdit, LB_GETITEMHEIGHT, 0, 0);
diff --git a/protocols/IcqOscarJ/src/editstring.cpp b/protocols/IcqOscarJ/src/editstring.cpp index feb334b34b..010f38e068 100644 --- a/protocols/IcqOscarJ/src/editstring.cpp +++ b/protocols/IcqOscarJ/src/editstring.cpp @@ -188,7 +188,7 @@ static LRESULT CALLBACK ExpandButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wPa SendMessage(hwndEdit, EM_GETSEL, (WPARAM)&selStart, (LPARAM)&selEnd);
DestroyWindow(hwndEdit);
EscapesToMultiline(text, &selStart, &selEnd);
- hwndEdit = CreateWindowExA(WS_EX_TOOLWINDOW, "EDIT", "", WS_POPUP | WS_BORDER | WS_VISIBLE | ES_WANTRETURN | ES_AUTOVSCROLL | WS_VSCROLL | ES_MULTILINE, rcStart.left, rcStart.top, rcStart.right - rcStart.left, rcStart.bottom - rcStart.top, nullptr, nullptr, g_hInstance, nullptr);
+ hwndEdit = CreateWindowExA(WS_EX_TOOLWINDOW, "EDIT", "", WS_POPUP | WS_BORDER | WS_VISIBLE | ES_WANTRETURN | ES_AUTOVSCROLL | WS_VSCROLL | ES_MULTILINE, rcStart.left, rcStart.top, rcStart.right - rcStart.left, rcStart.bottom - rcStart.top, nullptr, nullptr, g_plugin.getInst(), nullptr);
SetWindowTextUcs(hwndEdit, text);
mir_subclassWindow(hwndEdit, StringEditSubclassProc);
SendMessage(hwndEdit, WM_SETFONT, (WPARAM)dataStringEdit->hListFont, 0);
@@ -251,13 +251,13 @@ void ChangeInfoData::BeginStringEdit(int iItem, RECT *rc, int i, WORD wVKey) if ((si.displayType & LIM_TYPE) == LI_LONGSTRING) {
rc->right -= rc->bottom - rc->top;
- hwndExpandButton = CreateWindowA("BUTTON", "", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_ICON, rc->right, rc->top, rc->bottom - rc->top, rc->bottom - rc->top, hwndList, nullptr, g_hInstance, nullptr);
+ hwndExpandButton = CreateWindowA("BUTTON", "", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_ICON, rc->right, rc->top, rc->bottom - rc->top, rc->bottom - rc->top, hwndList, nullptr, g_plugin.getInst(), nullptr);
SendMessage(hwndExpandButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(iconList[0].hIcolib));
mir_subclassWindow(hwndExpandButton, ExpandButtonSubclassProc);
}
dataStringEdit = this;
- hwndEdit = CreateWindow(L"EDIT", L"", WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ((si.displayType&LIM_TYPE) == LI_NUMBER ? ES_NUMBER : 0) | (si.displayType&LIF_PASSWORD ? ES_PASSWORD : 0), rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, hwndList, nullptr, g_hInstance, nullptr);
+ hwndEdit = CreateWindow(L"EDIT", L"", WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ((si.displayType&LIM_TYPE) == LI_NUMBER ? ES_NUMBER : 0) | (si.displayType&LIF_PASSWORD ? ES_PASSWORD : 0), rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, hwndList, nullptr, g_plugin.getInst(), nullptr);
SetWindowTextUtf(hwndEdit, szValue);
if (alloced) SAFE_FREE(&szValue);
mir_subclassWindow(hwndEdit, StringEditSubclassProc);
@@ -265,7 +265,7 @@ void ChangeInfoData::BeginStringEdit(int iItem, RECT *rc, int i, WORD wVKey) if ((si.displayType & LIM_TYPE) == LI_NUMBER) {
int *range = (int*)si.pList;
RECT rcUpDown;
- hwndUpDown = CreateWindow(UPDOWN_CLASS, L"", WS_VISIBLE | WS_CHILD | UDS_AUTOBUDDY | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_NOTHOUSANDS | UDS_SETBUDDYINT, 0, 0, 0, 0, hwndList, nullptr, g_hInstance, nullptr);
+ hwndUpDown = CreateWindow(UPDOWN_CLASS, L"", WS_VISIBLE | WS_CHILD | UDS_AUTOBUDDY | UDS_ALIGNRIGHT | UDS_HOTTRACK | UDS_NOTHOUSANDS | UDS_SETBUDDYINT, 0, 0, 0, 0, hwndList, nullptr, g_plugin.getInst(), nullptr);
SendMessage(hwndUpDown, UDM_SETRANGE32, range[0], range[1]);
SendMessage(hwndUpDown, UDM_SETPOS32, 0, sid.value);
if (!(si.displayType & LIF_ZEROISVALID) && sid.value == 0)
diff --git a/protocols/IcqOscarJ/src/icq_firstrun.cpp b/protocols/IcqOscarJ/src/icq_firstrun.cpp index ea5254cf05..6dc0cb6e8f 100644 --- a/protocols/IcqOscarJ/src/icq_firstrun.cpp +++ b/protocols/IcqOscarJ/src/icq_firstrun.cpp @@ -104,5 +104,5 @@ INT_PTR CALLBACK icq_FirstRunDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR INT_PTR CIcqProto::OnCreateAccMgrUI(WPARAM, LPARAM lParam)
{
- return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ICQACCOUNT), (HWND)lParam, icq_FirstRunDlgProc, LPARAM(this));
+ return (INT_PTR)CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ICQACCOUNT), (HWND)lParam, icq_FirstRunDlgProc, LPARAM(this));
}
diff --git a/protocols/IcqOscarJ/src/icq_opts.cpp b/protocols/IcqOscarJ/src/icq_opts.cpp index f19dcaef7a..83229a25e2 100644 --- a/protocols/IcqOscarJ/src/icq_opts.cpp +++ b/protocols/IcqOscarJ/src/icq_opts.cpp @@ -506,7 +506,7 @@ int CIcqProto::OnOptionsInit(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = -800000000;
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.szGroup.w = LPGENW("Network");
odp.dwInitParam = LPARAM(this);
odp.szTitle.w = m_tszUserName;
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index a3ec27ff40..ba2ca46ae5 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -808,8 +808,8 @@ HANDLE __cdecl CIcqProto::SearchByName(const wchar_t *nick, const wchar_t *first HWND __cdecl CIcqProto::CreateExtendedSearchUI(HWND parent)
{
- if (parent && g_hInstance)
- return CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_ICQADVANCEDSEARCH), parent, AdvancedSearchDlgProc);
+ if (parent && g_plugin.getInst())
+ return CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ICQADVANCEDSEARCH), parent, AdvancedSearchDlgProc);
return nullptr; // Failure
}
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp index a7eb3bf6cd..fcf7058703 100644 --- a/protocols/IcqOscarJ/src/icq_uploadui.cpp +++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp @@ -866,7 +866,7 @@ void CIcqProto::ShowUploadContactsDialog(void) {
if (hwndUploadContacts == nullptr) {
hItemAll = nullptr;
- hwndUploadContacts = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ICQUPLOADLIST), nullptr, DlgProcUploadList, LPARAM(this));
+ hwndUploadContacts = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ICQUPLOADLIST), nullptr, DlgProcUploadList, LPARAM(this));
}
SetForegroundWindow(hwndUploadContacts);
diff --git a/protocols/IcqOscarJ/src/icq_xstatus.cpp b/protocols/IcqOscarJ/src/icq_xstatus.cpp index 0505ca7d43..2e0dba715b 100644 --- a/protocols/IcqOscarJ/src/icq_xstatus.cpp +++ b/protocols/IcqOscarJ/src/icq_xstatus.cpp @@ -807,7 +807,7 @@ void CIcqProto::setXStatusEx(BYTE bXStatus, BYTE bQuiet) init.bXStatus = bXStatus;
init.szXStatusName = szName;
init.szXStatusMsg = szMsg;
- CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)&init);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)&init);
}
else {
setByte(DBSETTING_XSTATUS_ID, bXStatus);
@@ -916,7 +916,7 @@ INT_PTR CIcqProto::ShowXStatusDetails(WPARAM hContact, LPARAM) init.ppro = this;
init.bAction = 1; // retrieve
init.hContact = hContact;
- CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)&init);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)&init);
return 0;
}
diff --git a/protocols/IcqOscarJ/src/init.cpp b/protocols/IcqOscarJ/src/init.cpp index 55d8c21fe8..8d21b12056 100644 --- a/protocols/IcqOscarJ/src/init.cpp +++ b/protocols/IcqOscarJ/src/init.cpp @@ -28,8 +28,6 @@ #include "m_extraicons.h"
#include "m_icolib.h"
-CMPlugin g_plugin;
-HINSTANCE g_hInstance;
int hLangpack;
bool g_bTerminated;
@@ -54,8 +52,14 @@ extern "C" PLUGININFOEX __declspec(dllexport) *MirandaPluginInfoEx(DWORD) return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -101,7 +105,7 @@ extern "C" int __declspec(dllexport) Load(void) hExtraXStatus = ExtraIcon_RegisterIcolib("xstatus", LPGEN("ICQ xStatus"), "icq_xstatus13");
- Icon_Register(g_hInstance, "ICQ", iconList, _countof(iconList));
+ Icon_Register(g_plugin.getInst(), "ICQ", iconList, _countof(iconList));
g_MenuInit();
return 0;
diff --git a/protocols/IcqOscarJ/src/loginpassword.cpp b/protocols/IcqOscarJ/src/loginpassword.cpp index 1a6d8c1e51..9cff0ea568 100644 --- a/protocols/IcqOscarJ/src/loginpassword.cpp +++ b/protocols/IcqOscarJ/src/loginpassword.cpp @@ -84,5 +84,5 @@ INT_PTR CALLBACK LoginPasswdDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA void CIcqProto::RequestPassword()
{
- DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_LOGINPW), nullptr, LoginPasswdDlgProc, LPARAM(this));
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_LOGINPW), nullptr, LoginPasswdDlgProc, LPARAM(this));
}
diff --git a/protocols/IcqOscarJ/src/userinfotab.cpp b/protocols/IcqOscarJ/src/userinfotab.cpp index 8bd0911293..76ec477cca 100644 --- a/protocols/IcqOscarJ/src/userinfotab.cpp +++ b/protocols/IcqOscarJ/src/userinfotab.cpp @@ -270,7 +270,7 @@ int CIcqProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam) OPTIONSDIALOGPAGE odp = { 0 };
odp.flags = ODPF_UNICODE | ODPF_DONTTRANSLATE;
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.dwInitParam = LPARAM(this);
odp.pfnDlgProc = IcqDlgProc;
odp.position = -1900000000;
diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index 9e8c7e3204..aef6f638ac 100755 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -35,10 +35,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #pragma comment(lib, "Dnsapi.lib")
#pragma comment(lib, "Secur32.lib")
-HINSTANCE g_hInstance;
HMODULE hMsftedit;
-CMPlugin g_plugin;
int hLangpack;
unsigned int g_nTempFileId;
CHAT_MANAGER *pci;
@@ -48,18 +46,6 @@ CountryListEntry *g_countries; wchar_t szCoreVersion[100];
-PLUGININFOEX pluginInfo = {
- sizeof(PLUGININFOEX),
- __PLUGIN_NAME,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
- __DESCRIPTION,
- __AUTHOR,
- __COPYRIGHT,
- __AUTHORWEB,
- UNICODE_AWARE,
- {0x144e80a2, 0xd198, 0x428b, {0xac, 0xbe, 0x9d, 0x55, 0xda, 0xcc, 0x7f, 0xde}} // {144E80A2-D198-428b-ACBE-9D55DACC7FDE}
-};
-
CLIST_INTERFACE* pcli;
HANDLE hExtraActivity = nullptr;
@@ -71,15 +57,33 @@ void JabberUserInfoUninit(void); bool bSecureIM, bMirOTR, bNewGPG, bPlatform;
-/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo = {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ { 0x144e80a2, 0xd198, 0x428b, {0xac, 0xbe, 0x9d, 0x55, 0xda, 0xcc, 0x7f, 0xde }} // {144E80A2-D198-428b-ACBE-9D55DACC7FDE}
+};
+
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
///////////////////////////////////////////////////////////////////////////////
@@ -108,7 +112,7 @@ static int OnModulesLoaded(WPARAM, LPARAM) // file associations manager plugin support
if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
CreateServiceFunction("JABBER/*" JS_PARSE_XMPP_URI, g_SvcParseXmppUri);
- AssocMgr_AddNewUrlTypeW("xmpp:", TranslateT("Jabber Link Protocol"), g_hInstance, IDI_JABBER, "JABBER/*" JS_PARSE_XMPP_URI, 0);
+ AssocMgr_AddNewUrlTypeW("xmpp:", TranslateT("Jabber Link Protocol"), g_plugin.getInst(), IDI_JABBER, "JABBER/*" JS_PARSE_XMPP_URI, 0);
}
// init fontservice for info frame
diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp index fccbbcdbd0..e69c40b6c0 100644 --- a/protocols/JabberG/src/jabber_adhoc.cpp +++ b/protocols/JabberG/src/jabber_adhoc.cpp @@ -339,7 +339,7 @@ int CJabberProto::AdHoc_AddCommandRadio(HWND hFrame, wchar_t * labelStr, int id, ctrlWidth = min(ctrlWidth, strRect.right - strRect.left + 20);
ReleaseDC(hFrame, hdc);
- HWND hCtrl = CreateWindowEx(0, L"button", labelStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, ctrlOffset, ypos, ctrlWidth, labelHeight, hFrame, (HMENU)id, g_hInstance, nullptr);
+ HWND hCtrl = CreateWindowEx(0, L"button", labelStr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, ctrlOffset, ypos, ctrlWidth, labelHeight, hFrame, (HMENU)id, g_plugin.getInst(), nullptr);
SendMessage(hCtrl, WM_SETFONT, (WPARAM)SendMessage(GetParent(hFrame), WM_GETFONT, 0, 0), 0);
SendMessage(hCtrl, BM_SETCHECK, value, 0);
return (ypos + labelHeight + verticalStep);
@@ -527,7 +527,7 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam) HMENU hMenu = CreatePopupMenu();
for (int i = 0; i < item->arResources.getCount(); i++)
AppendMenu(hMenu, MF_STRING, i + 1, item->arResources[i]->m_tszResourceName);
- HWND hwndTemp = CreateWindowEx(WS_EX_TOOLWINDOW, L"button", L"PopupMenuHost", 0, 0, 0, 10, 10, nullptr, nullptr, g_hInstance, nullptr);
+ HWND hwndTemp = CreateWindowEx(WS_EX_TOOLWINDOW, L"button", L"PopupMenuHost", 0, 0, 0, 10, 10, nullptr, nullptr, g_plugin.getInst(), nullptr);
SetForegroundWindow(hwndTemp);
RECT rc;
POINT pt;
@@ -551,11 +551,11 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam) if (item == nullptr || selected) {
CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams(this, jid, nullptr);
- CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, (LPARAM)pStartupParams);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, (LPARAM)pStartupParams);
}
}
else if (lParam != 0)
- CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, lParam);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, lParam);
}
return res;
}
@@ -563,5 +563,5 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM hContact, LPARAM lParam) void CJabberProto::ContactMenuAdhocCommands(CJabberAdhocStartupParams* param)
{
if (param)
- CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, (LPARAM)param);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FORM), nullptr, JabberAdHoc_CommandDlgProc, (LPARAM)param);
}
diff --git a/protocols/JabberG/src/jabber_bookmarks.cpp b/protocols/JabberG/src/jabber_bookmarks.cpp index 829d3dbfbe..bceb2b9689 100644 --- a/protocols/JabberG/src/jabber_bookmarks.cpp +++ b/protocols/JabberG/src/jabber_bookmarks.cpp @@ -197,7 +197,7 @@ private: JabberAddBookmarkDlgParam param;
param.ppro = m_proto;
param.m_item = nullptr;
- DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m);
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m);
}
void btnEdit_OnClick(CCtrlFilterListView *)
@@ -216,7 +216,7 @@ private: JabberAddBookmarkDlgParam param;
param.ppro = m_proto;
param.m_item = item;
- DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m);
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m);
}
void btnRemove_OnClick(CCtrlFilterListView *)
@@ -443,7 +443,7 @@ int CJabberProto::AddEditBookmark(JABBER_LIST_ITEM *item) JabberAddBookmarkDlgParam param;
param.ppro = this;
param.m_item = item;//(JABBER_LIST_ITEM*)lParam;
- DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), nullptr, JabberAddBookmarkDlgProc, (LPARAM)¶m);
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_BOOKMARK_ADD), nullptr, JabberAddBookmarkDlgProc, (LPARAM)¶m);
}
return 0;
}
diff --git a/protocols/JabberG/src/jabber_captcha.cpp b/protocols/JabberG/src/jabber_captcha.cpp index d9127e822c..f866614093 100644 --- a/protocols/JabberG/src/jabber_captcha.cpp +++ b/protocols/JabberG/src/jabber_captcha.cpp @@ -152,7 +152,7 @@ bool CJabberProto::ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info) GetObject(param.bmp, sizeof(bmp), &bmp);
param.w = bmp.bmWidth;
param.h = bmp.bmHeight;
- int res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CAPTCHAFORM), nullptr, JabberCaptchaFormDlgProc, (LPARAM)¶m);
+ int res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CAPTCHAFORM), nullptr, JabberCaptchaFormDlgProc, (LPARAM)¶m);
if (mir_wstrcmp(param.Result, L"") == 0 || !res)
sendCaptchaError(info, param.from, param.to, param.challenge);
else
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 3f7c381a15..e989a1e4d3 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -1036,7 +1036,7 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* dat->him = him;
dat->item = item;
dat->ppro = ppro;
- HWND hwndInfo = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_GROUPCHAT_INFO), nullptr, sttUserInfoDlgProc, (LPARAM)dat);
+ HWND hwndInfo = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_GROUPCHAT_INFO), nullptr, sttUserInfoDlgProc, (LPARAM)dat);
ShowWindow(hwndInfo, SW_SHOW);
}
break;
diff --git a/protocols/JabberG/src/jabber_filterlist.cpp b/protocols/JabberG/src/jabber_filterlist.cpp index 269468958e..a48a7fddd8 100644 --- a/protocols/JabberG/src/jabber_filterlist.cpp +++ b/protocols/JabberG/src/jabber_filterlist.cpp @@ -183,7 +183,7 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara fdat->m_hwndEditBox = CreateWindow(L"edit", fdat->m_filterText,
WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_LEFT|ES_AUTOHSCROLL,
0, 0, 0, 0,
- ::GetParent(m_hwnd), (HMENU)-1, g_hInstance, nullptr);
+ ::GetParent(m_hwnd), (HMENU)-1, g_plugin.getInst(), nullptr);
SendMessage(fdat->m_hwndEditBox, WM_SETFONT, (WPARAM)fdat->m_hfntNormal, 0);
diff --git a/protocols/JabberG/src/jabber_form.cpp b/protocols/JabberG/src/jabber_form.cpp index e7763d10da..3e427452fb 100644 --- a/protocols/JabberG/src/jabber_form.cpp +++ b/protocols/JabberG/src/jabber_form.cpp @@ -282,7 +282,7 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo #define JabberFormCreateLabel() \
CreateWindow(L"static", labelStr, WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE, \
- 0, 0, 0, 0, hwndStatic, (HMENU)-1, g_hInstance, nullptr)
+ 0, 0, 0, 0, hwndStatic, (HMENU)-1, g_plugin.getInst(), nullptr)
TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayoutInfo *layout_info, TJabberFormControlType type, const wchar_t *labelStr, const wchar_t *valueStr)
{
@@ -302,7 +302,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD,
0, 0, 0, 0,
- hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr);
+ hwndStatic, (HMENU)layout_info->id, g_plugin.getInst(), nullptr);
++layout_info->id;
break;
@@ -311,7 +311,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN,
0, 0, 0, 0,
- hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr);
+ hwndStatic, (HMENU)layout_info->id, g_plugin.getInst(), nullptr);
mir_subclassWindow(item->hCtrl, JabberFormMultiLineWndProc);
++layout_info->id;
break;
@@ -320,7 +320,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowEx(0, L"button", labelStr,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX | BS_MULTILINE,
0, 0, 0, 0,
- hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr);
+ hwndStatic, (HMENU)layout_info->id, g_plugin.getInst(), nullptr);
if (valueStr && !mir_wstrcmp(valueStr, L"1"))
SendMessage(item->hCtrl, BM_SETCHECK, 1, 0);
++layout_info->id;
@@ -331,7 +331,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowExA(WS_EX_CLIENTEDGE, "combobox", nullptr,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST,
0, 0, 0, 0,
- hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr);
+ hwndStatic, (HMENU)layout_info->id, g_plugin.getInst(), nullptr);
++layout_info->id;
break;
@@ -340,7 +340,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowExA(WS_EX_CLIENTEDGE, "listbox",
nullptr, WS_CHILD | WS_VISIBLE | WS_TABSTOP | LBS_MULTIPLESEL,
0, 0, 0, 0,
- hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr);
+ hwndStatic, (HMENU)layout_info->id, g_plugin.getInst(), nullptr);
++layout_info->id;
break;
@@ -348,7 +348,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindow(L"edit", valueStr,
WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_READONLY | ES_AUTOHSCROLL,
0, 0, 0, 0,
- hwndStatic, (HMENU)-1, g_hInstance, nullptr);
+ hwndStatic, (HMENU)-1, g_plugin.getInst(), nullptr);
break;
case JFORM_CTYPE_HIDDEN:
@@ -359,7 +359,7 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, L"edit", valueStr,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL,
0, 0, 0, 0,
- hwndStatic, (HMENU)layout_info->id, g_hInstance, nullptr);
+ hwndStatic, (HMENU)layout_info->id, g_plugin.getInst(), nullptr);
++layout_info->id;
break;
}
@@ -849,7 +849,7 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, static VOID CALLBACK JabberFormCreateDialogApcProc(void* param)
{
- CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_FORM), nullptr, JabberFormDlgProc, (LPARAM)param);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FORM), nullptr, JabberFormDlgProc, (LPARAM)param);
}
void CJabberProto::FormCreateDialog(HXML xNode, wchar_t* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata)
diff --git a/protocols/JabberG/src/jabber_frame.cpp b/protocols/JabberG/src/jabber_frame.cpp index 10a0a4218a..aff1bd2720 100644 --- a/protocols/JabberG/src/jabber_frame.cpp +++ b/protocols/JabberG/src/jabber_frame.cpp @@ -79,7 +79,7 @@ CJabberInfoFrame::CJabberInfoFrame(CJabberProto *proto): CLISTFrame frame = { sizeof(frame) };
HWND hwndClist = pcli->hwndContactList;
- frame.hWnd = CreateWindowEx(0, L"JabberInfoFrameClass", nullptr, WS_CHILD|WS_VISIBLE, 0, 0, 100, 100, hwndClist, nullptr, g_hInstance, this);
+ frame.hWnd = CreateWindowEx(0, L"JabberInfoFrameClass", nullptr, WS_CHILD|WS_VISIBLE, 0, 0, 100, 100, hwndClist, nullptr, g_plugin.getInst(), this);
frame.align = alBottom;
frame.height = 2 * SZ_FRAMEPADDING + GetSystemMetrics(SM_CYSMICON) + SZ_LINEPADDING; // compact height by default
frame.Flags = F_VISIBLE|F_LOCKED|F_NOBORDER|F_UNICODE;
@@ -98,7 +98,7 @@ CJabberInfoFrame::CJabberInfoFrame(CJabberProto *proto): m_hwndToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- m_hwnd, nullptr, g_hInstance, nullptr);
+ m_hwnd, nullptr, g_plugin.getInst(), nullptr);
SetWindowPos(m_hwndToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
CreateInfoItem("$", true);
@@ -136,7 +136,7 @@ void CJabberInfoFrame::InitClass() wcx.cbSize = sizeof(wcx);
wcx.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW;
wcx.lpfnWndProc = GlobalWndProc;
- wcx.hInstance = g_hInstance;
+ wcx.hInstance = g_plugin.getInst();
wcx.lpszClassName = L"JabberInfoFrameClass";
wcx.hCursor = LoadCursor(nullptr, IDC_ARROW);
RegisterClassEx(&wcx);
@@ -297,7 +297,7 @@ void CJabberInfoFrame::SetToolTip(int id, RECT *rc, wchar_t *pszText) ti.uFlags = TTF_SUBCLASS;
ti.hwnd = m_hwnd;
ti.uId = id;
- ti.hinst = g_hInstance;
+ ti.hinst = g_plugin.getInst();
ti.lpszText = pszText;
ti.rect = *rc;
SendMessage(m_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index 4c105cb6ae..05bb6107f4 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -522,10 +522,10 @@ static IconItem sharedIconList4[] = void g_IconsInit()
{
- Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("Jabber"), sharedIconList1, _countof(sharedIconList1), GLOBAL_SETTING_PREFIX);
- Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("Jabber") "/" LPGEN("Dialogs"), sharedIconList2, _countof(sharedIconList2), GLOBAL_SETTING_PREFIX);
- Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("Dialogs") "/" LPGEN("Discovery"), sharedIconList3, _countof(sharedIconList3), GLOBAL_SETTING_PREFIX);
- Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("Dialogs") "/" LPGEN("Privacy"), sharedIconList4, _countof(sharedIconList4), GLOBAL_SETTING_PREFIX);
+ Icon_Register(g_plugin.getInst(), LPGEN("Protocols") "/" LPGEN("Jabber"), sharedIconList1, _countof(sharedIconList1), GLOBAL_SETTING_PREFIX);
+ Icon_Register(g_plugin.getInst(), LPGEN("Protocols") "/" LPGEN("Jabber") "/" LPGEN("Dialogs"), sharedIconList2, _countof(sharedIconList2), GLOBAL_SETTING_PREFIX);
+ Icon_Register(g_plugin.getInst(), LPGEN("Protocols") "/" LPGEN("Dialogs") "/" LPGEN("Discovery"), sharedIconList3, _countof(sharedIconList3), GLOBAL_SETTING_PREFIX);
+ Icon_Register(g_plugin.getInst(), LPGEN("Protocols") "/" LPGEN("Dialogs") "/" LPGEN("Privacy"), sharedIconList4, _countof(sharedIconList4), GLOBAL_SETTING_PREFIX);
}
HANDLE g_GetIconHandle(int iconId)
diff --git a/protocols/JabberG/src/jabber_iqid_muc.cpp b/protocols/JabberG/src/jabber_iqid_muc.cpp index 98a2dadf9f..aaed20c1d3 100644 --- a/protocols/JabberG/src/jabber_iqid_muc.cpp +++ b/protocols/JabberG/src/jabber_iqid_muc.cpp @@ -212,7 +212,7 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w return TRUE;
case WM_SIZE:
- Utils_ResizeDialog(hwndDlg, g_hInstance, MAKEINTRESOURCEA(IDD_JIDLIST), sttJidListResizer);
+ Utils_ResizeDialog(hwndDlg, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_JIDLIST), sttJidListResizer);
RECT listrc;
LVCOLUMN lvc;
@@ -472,7 +472,7 @@ static void CALLBACK JabberMucJidListCreateDialogApcProc(void* param) SetForegroundWindow(*pHwndJidList);
SendMessage(*pHwndJidList, WM_JABBER_REFRESH, 0, (LPARAM)jidListInfo);
}
- else *pHwndJidList = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_JIDLIST), GetForegroundWindow(), JabberMucJidListDlgProc, (LPARAM)jidListInfo);
+ else *pHwndJidList = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_JIDLIST), GetForegroundWindow(), JabberMucJidListDlgProc, (LPARAM)jidListInfo);
}
void CJabberProto::OnIqResultMucGetJidList(HXML iqNode, JABBER_MUC_JIDLIST_TYPE listType)
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index ba8d77b14c..6d6946eca3 100755 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -1357,7 +1357,7 @@ static LRESULT CALLBACK _RosterNewListProc(HWND hList, UINT msg, WPARAM wParam, wchar_t buff[260];
ListView_GetSubItemRect(hList, lvhti.iItem, lvhti.iSubItem, LVIR_BOUNDS, &rc);
ListView_GetItemText(hList, lvhti.iItem, lvhti.iSubItem, buff, _countof(buff));
- HWND hEditor = CreateWindow(TEXT("EDIT"), buff, WS_CHILD | ES_AUTOHSCROLL, rc.left + 3, rc.top + 2, rc.right - rc.left - 3, rc.bottom - rc.top - 3, hList, nullptr, g_hInstance, nullptr);
+ HWND hEditor = CreateWindow(TEXT("EDIT"), buff, WS_CHILD | ES_AUTOHSCROLL, rc.left + 3, rc.top + 2, rc.right - rc.left - 3, rc.bottom - rc.top - 3, hList, nullptr, g_plugin.getInst(), nullptr);
SendMessage(hEditor, WM_SETFONT, (WPARAM)SendMessage(hList, WM_GETFONT, 0, 0), 0);
ShowWindow(hEditor, SW_SHOW);
SetWindowText(hEditor, buff);
@@ -1448,7 +1448,7 @@ static INT_PTR CALLBACK JabberRosterOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wP }
case WM_SIZE:
- Utils_ResizeDialog(hwndDlg, g_hInstance, MAKEINTRESOURCEA(IDD_OPT_JABBER3), sttRosterEditorResizer);
+ Utils_ResizeDialog(hwndDlg, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_OPT_JABBER3), sttRosterEditorResizer);
break;
case WM_COMMAND:
@@ -1486,7 +1486,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleRosterControl(WPARAM, LPARAM) if (rrud.hwndDlg && IsWindow(rrud.hwndDlg))
SetForegroundWindow(rrud.hwndDlg);
else
- CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_OPT_JABBER3), nullptr, JabberRosterOptDlgProc, (LPARAM)this);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_OPT_JABBER3), nullptr, JabberRosterOptDlgProc, (LPARAM)this);
return 0;
}
diff --git a/protocols/JabberG/src/jabber_password.cpp b/protocols/JabberG/src/jabber_password.cpp index 018446a3ab..6715ab5605 100644 --- a/protocols/JabberG/src/jabber_password.cpp +++ b/protocols/JabberG/src/jabber_password.cpp @@ -33,7 +33,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleChangePassword(WPARAM, LPARAM) if (IsWindow(m_hwndJabberChangePassword))
SetForegroundWindow(m_hwndJabberChangePassword);
else
- m_hwndJabberChangePassword = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_CHANGEPASSWORD), nullptr, JabberChangePasswordDlgProc, (LPARAM)this);
+ m_hwndJabberChangePassword = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHANGEPASSWORD), nullptr, JabberChangePasswordDlgProc, (LPARAM)this);
return 0;
}
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp index 204876b73a..85037d7630 100644 --- a/protocols/JabberG/src/jabber_search.cpp +++ b/protocols/JabberG/src/jabber_search.cpp @@ -105,8 +105,8 @@ static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat) int Order = (FieldDat->bHidden) ? -1 : FieldDat->Order; - HWND hwndLabel = CreateWindowEx(0, L"STATIC", (const wchar_t *)TranslateW(FieldDat->Label), WS_CHILD, CornerX, CornerY + Order * 40, width, 13, hwndParent, nullptr, g_hInstance, nullptr); - HWND hwndVar = CreateWindowEx(0 | WS_EX_CLIENTEDGE, L"EDIT", (const wchar_t *)FieldDat->defValue, WS_CHILD | WS_TABSTOP, CornerX + 5, CornerY + Order * 40 + 14, width, 20, hwndParent, nullptr, g_hInstance, nullptr); + HWND hwndLabel = CreateWindowEx(0, L"STATIC", (const wchar_t *)TranslateW(FieldDat->Label), WS_CHILD, CornerX, CornerY + Order * 40, width, 13, hwndParent, nullptr, g_plugin.getInst(), nullptr); + HWND hwndVar = CreateWindowEx(0 | WS_EX_CLIENTEDGE, L"EDIT", (const wchar_t *)FieldDat->defValue, WS_CHILD | WS_TABSTOP, CornerX + 5, CornerY + Order * 40 + 14, width, 20, hwndParent, nullptr, g_plugin.getInst(), nullptr); SendMessage(hwndLabel, WM_SETFONT, (WPARAM)hFont, 0); SendMessage(hwndVar, WM_SETFONT, (WPARAM)hFont, 0); if (!FieldDat->bHidden) { @@ -707,10 +707,10 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR HWND __cdecl CJabberProto::CreateExtendedSearchUI(HWND parent) { - if (parent && g_hInstance) { + if (parent && g_plugin.getInst()) { ptrW szServer(getWStringA("LoginServer")); if (szServer == nullptr || mir_wstrcmpi(szServer, L"S.ms")) - return CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, JabberSearchAdvancedDlgProc, (LPARAM)this); + return CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SEARCHUSER), parent, JabberSearchAdvancedDlgProc, (LPARAM)this); } return nullptr; // Failure diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index fdf951ad47..82bd29a43e 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -116,7 +116,7 @@ static INT_PTR CALLBACK JabberPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa static VOID CALLBACK JabberPasswordCreateDialogApcProc(void* param)
{
- CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_PASSWORD), nullptr, JabberPasswordDlgProc, (LPARAM)param);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_PASSWORD), nullptr, JabberPasswordDlgProc, (LPARAM)param);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index 35da917865..73f017b910 100755 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -822,7 +822,7 @@ int CJabberProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam) char *szProto = GetContactProto(hContact); if (szProto != nullptr && !mir_strcmp(szProto, m_szModuleName)) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = g_hInstance; + odp.hInstance = g_plugin.getInst(); odp.dwInitParam = (LPARAM)this; odp.pfnDlgProc = JabberUserInfoDlgProc; diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index f82b2e8c70..51676949ab 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -842,9 +842,9 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP EditDlgParam param = { -1, ppro };
int res;
if (nm->hdr.idFrom == IDC_PHONES)
- res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m);
+ res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m);
else
- res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
+ res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
if (res != IDOK)
break;
SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
@@ -882,9 +882,9 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP EditDlgParam param = { (int)lvi.lParam, ppro };
int res;
if (nm->hdr.idFrom == IDC_PHONES)
- res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m);
+ res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m);
else
- res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
+ res = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
if (res != IDOK)
break;
SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
@@ -1178,7 +1178,7 @@ void CJabberProto::OnUserInfoInit_VCard(WPARAM wParam, LPARAM) m_szPhotoFileName[0] = 0;
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.dwInitParam = (LPARAM)this;
odp.flags = ODPF_UNICODE | ODPF_USERINFOTAB | ODPF_DONTTRANSLATE;
odp.szTitle.w = m_tszUserName;
diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp index df48a3d90c..070af7048e 100644 --- a/protocols/JabberG/src/jabber_xstatus.cpp +++ b/protocols/JabberG/src/jabber_xstatus.cpp @@ -1496,7 +1496,7 @@ wchar_t* CJabberProto::ReadAdvStatusT(MCONTACT hContact, const char *pszSlot, co void g_XstatusIconsInit()
{
wchar_t szFile[MAX_PATH];
- GetModuleFileName(g_hInstance, szFile, _countof(szFile));
+ GetModuleFileName(g_plugin.getInst(), szFile, _countof(szFile));
if (wchar_t *p = wcsrchr(szFile, '\\'))
mir_wstrcpy(p + 1, L"..\\Icons\\xstatus_jabber.dll");
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index 37dacc2085..72833d8381 100755 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -577,8 +577,6 @@ private: /*******************************************************************
* Global variables
*******************************************************************/
-extern HINSTANCE g_hInstance;
-
extern HANDLE hExtraMood;
extern HANDLE hExtraActivity;
diff --git a/protocols/MRA/src/Mra.cpp b/protocols/MRA/src/Mra.cpp index 68373ab59b..58f455fc23 100644 --- a/protocols/MRA/src/Mra.cpp +++ b/protocols/MRA/src/Mra.cpp @@ -1,10 +1,18 @@ #include "stdafx.h"
-CMPlugin g_plugin;
-
int hLangpack;
CLIST_INTERFACE *pcli;
+HMODULE g_hDLLXStatusIcons;
+HICON g_hMainIcon;
+
+bool g_bChatExist, g_bShutdown = false;
+
+size_t g_dwMirWorkDirPathLen;
+WCHAR g_szMirWorkDirPath[MAX_FILEPATH];
+
+void IconsLoad();
+
PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
PROTOCOL_DISPLAY_NAME_ORIGA,
@@ -18,25 +26,20 @@ PLUGININFOEX pluginInfoEx = { { 0xe7c48bab, 0x8ace, 0x4cb3, { 0x84, 0x46, 0xd4, 0xb7, 0x34, 0x81, 0xf4, 0x97 } }
};
-HINSTANCE g_hInstance;
-HMODULE g_hDLLXStatusIcons;
-HICON g_hMainIcon;
-
-bool g_bChatExist, g_bShutdown = false;
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfoEx;
+}
-size_t g_dwMirWorkDirPathLen;
-WCHAR g_szMirWorkDirPath[MAX_FILEPATH];
+/////////////////////////////////////////////////////////////////////////////////////////
-void IconsLoad();
+CMPlugin g_plugin;
extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
+/////////////////////////////////////////////////////////////////////////////////////////
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
///////////////////////////////////////////////////////////////////////////////
@@ -58,6 +61,8 @@ extern "C" __declspec(dllexport) int Load(void) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
DestroyXStatusIcons();
diff --git a/protocols/MRA/src/MraAdvancedSearch.cpp b/protocols/MRA/src/MraAdvancedSearch.cpp index bb365c8c67..7377f97d1b 100644 --- a/protocols/MRA/src/MraAdvancedSearch.cpp +++ b/protocols/MRA/src/MraAdvancedSearch.cpp @@ -306,8 +306,8 @@ HWND CMraProto::SearchAdvanced(HWND hWndDlg) HWND CMraProto::CreateExtendedSearchUI(HWND owner)
{
- if (g_hInstance && owner)
- return CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MRAADVANCEDSEARCH), owner, AdvancedSearchDlgProc, (LPARAM)this);
+ if (g_plugin.getInst() && owner)
+ return CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_MRAADVANCEDSEARCH), owner, AdvancedSearchDlgProc, (LPARAM)this);
return nullptr;
}
diff --git a/protocols/MRA/src/MraIcons.cpp b/protocols/MRA/src/MraIcons.cpp index 99471e9fd4..2be25ea965 100644 --- a/protocols/MRA/src/MraIcons.cpp +++ b/protocols/MRA/src/MraIcons.cpp @@ -69,10 +69,10 @@ HICON IconLibGetIconEx(HANDLE hIcon, DWORD dwFlags) void IconsLoad()
{
- Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("MRA"), gdiMainIcon, 1, "MRA_");
- Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("MRA") "/" LPGEN("Main Menu"), gdiMenuItems, MAIN_MENU_ITEMS_COUNT, "MRA_");
- Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("MRA") "/" LPGEN("Contact Menu"), gdiContactMenuItems, CONTACT_MENU_ITEMS_COUNT, "MRA_");
- Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("MRA") "/" LPGEN("Extra status"), gdiExtraStatusIconsItems, ADV_ICON_MAX, "MRA_");
+ Icon_Register(g_plugin.getInst(), LPGEN("Protocols") "/" LPGEN("MRA"), gdiMainIcon, 1, "MRA_");
+ Icon_Register(g_plugin.getInst(), LPGEN("Protocols") "/" LPGEN("MRA") "/" LPGEN("Main Menu"), gdiMenuItems, MAIN_MENU_ITEMS_COUNT, "MRA_");
+ Icon_Register(g_plugin.getInst(), LPGEN("Protocols") "/" LPGEN("MRA") "/" LPGEN("Contact Menu"), gdiContactMenuItems, CONTACT_MENU_ITEMS_COUNT, "MRA_");
+ Icon_Register(g_plugin.getInst(), LPGEN("Protocols") "/" LPGEN("MRA") "/" LPGEN("Extra status"), gdiExtraStatusIconsItems, ADV_ICON_MAX, "MRA_");
g_hMainIcon = IconLibGetIcon(gdiMainIcon[0].hIcolib);
}
@@ -104,7 +104,7 @@ void InitXStatusIcons() }
}
- GetModuleFileName((g_hDLLXStatusIcons != nullptr) ? g_hDLLXStatusIcons : g_hInstance, szBuff, _countof(szBuff));
+ GetModuleFileName((g_hDLLXStatusIcons != nullptr) ? g_hDLLXStatusIcons : g_plugin.getInst(), szBuff, _countof(szBuff));
SKINICONDESC sid = {};
sid.section.w = LPGENW("Protocols")L"/" LPGENW("MRA") L"/" LPGENW("Custom Status");
diff --git a/protocols/MRA/src/MraPopUp.cpp b/protocols/MRA/src/MraPopUp.cpp index 6b0d4fd4bd..4d27b75bb3 100644 --- a/protocols/MRA/src/MraPopUp.cpp +++ b/protocols/MRA/src/MraPopUp.cpp @@ -129,7 +129,7 @@ int CMraProto::OnPopupOptInit(WPARAM wParam, LPARAM) OPTIONSDIALOGPAGE odp = { 0 };
odp.dwInitParam = (LPARAM)this;
odp.position = 100000000;
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_POPUPS);
odp.szTitle.w = m_tszUserName;
odp.szGroup.w = LPGENW("Popups");
@@ -242,7 +242,7 @@ void CMraProto::MraPopupShowW(MCONTACT hContact, DWORD dwType, LPWSTR lpszTitle, ppd.lchIcon = (HICON)LoadImage(nullptr, IDI_ERROR, IMAGE_ICON, 0, 0, LR_SHARED);
break;
case MRA_POPUP_TYPE_EMAIL_STATUS:
- ppd.lchIcon = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_MAIL_NOTIFY), IMAGE_ICON, 0, 0, LR_SHARED);
+ ppd.lchIcon = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_MAIL_NOTIFY), IMAGE_ICON, 0, 0, LR_SHARED);
break;
}
diff --git a/protocols/MRA/src/MraProto.cpp b/protocols/MRA/src/MraProto.cpp index 9d4cff4987..dc6b540008 100644 --- a/protocols/MRA/src/MraProto.cpp +++ b/protocols/MRA/src/MraProto.cpp @@ -75,7 +75,7 @@ CMraProto::~CMraProto() INT_PTR CMraProto::MraCreateAccMgrUI(WPARAM, LPARAM lParam)
{
- return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MRAACCOUNT),
+ return (INT_PTR)CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_MRAACCOUNT),
(HWND)lParam, DlgProcAccount, LPARAM(this));
}
diff --git a/protocols/MRA/src/MraSelectEMail.cpp b/protocols/MRA/src/MraSelectEMail.cpp index 68b1e65b31..19dac7a061 100644 --- a/protocols/MRA/src/MraSelectEMail.cpp +++ b/protocols/MRA/src/MraSelectEMail.cpp @@ -146,7 +146,7 @@ DWORD CMraProto::MraSelectEMailDlgShow(MCONTACT hContact, DWORD dwType) dat->ppro = this;
dat->hContact = hContact;
dat->dwType = dwType;
- DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_SELECT_EMAIL), nullptr, MraSelectEMailDlgProc, (LPARAM)dat);
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG_SELECT_EMAIL), nullptr, MraSelectEMailDlgProc, (LPARAM)dat);
}
return 0;
}
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index 1549e50769..1b2ec046c2 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -1066,7 +1066,7 @@ bool CMraProto::MraRequestXStatusDetails(DWORD dwXStatus) SetXStatusData *dat = (SetXStatusData*)mir_calloc(sizeof(SetXStatusData));
dat->dwXStatus = dwXStatus;
dat->ppro = this;
- return DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)dat) != -1;
+ return DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SETXSTATUS), nullptr, SetXStatusDlgProc, (LPARAM)dat) != -1;
}
return false;
@@ -1182,7 +1182,7 @@ bool CMraProto::MraSendReplyBlogStatus(MCONTACT hContact) SetBlogStatusData* dat = (SetBlogStatusData*)mir_calloc(sizeof(SetBlogStatusData));
dat->ppro = this;
dat->hContact = hContact;
- return CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MINIBLOG), nullptr, SendReplyBlogStatusDlgProc, (LPARAM)dat) != nullptr;
+ return CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_MINIBLOG), nullptr, SendReplyBlogStatusDlgProc, (LPARAM)dat) != nullptr;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/MRA/src/Mra_options.cpp b/protocols/MRA/src/Mra_options.cpp index aad1ff9c7c..794c7db3ea 100644 --- a/protocols/MRA/src/Mra_options.cpp +++ b/protocols/MRA/src/Mra_options.cpp @@ -215,7 +215,7 @@ int CMraProto::OnOptionsInit(WPARAM wParam, LPARAM lParam) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.dwInitParam = (LPARAM)this;
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.szTitle.w = m_tszUserName;
odp.szGroup.w = LPGENW("Network");
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
diff --git a/protocols/MRA/src/stdafx.h b/protocols/MRA/src/stdafx.h index 2e7594abef..bd34263f9b 100644 --- a/protocols/MRA/src/stdafx.h +++ b/protocols/MRA/src/stdafx.h @@ -157,14 +157,13 @@ extern IconItem gdiExtraStatusIconsItems[]; /////////////////////////////////////////////////////////////////////////////////////////
// plugin options
-extern HINSTANCE g_hInstance;
-extern HMODULE g_hDLLXStatusIcons;
-extern HICON g_hMainIcon;
+extern HMODULE g_hDLLXStatusIcons;
+extern HICON g_hMainIcon;
-extern bool g_bChatExist, g_bShutdown;
+extern bool g_bChatExist, g_bShutdown;
-extern size_t g_dwMirWorkDirPathLen;
-extern WCHAR g_szMirWorkDirPath[MAX_FILEPATH];
+extern size_t g_dwMirWorkDirPathLen;
+extern WCHAR g_szMirWorkDirPath[MAX_FILEPATH];
/////////////////////////////////////////////////////////////////////////////////////////
// External variables
diff --git a/protocols/MSN/src/msn.cpp b/protocols/MSN/src/msn.cpp index fe24b511e2..703df9323c 100644 --- a/protocols/MSN/src/msn.cpp +++ b/protocols/MSN/src/msn.cpp @@ -24,9 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "msn_proto.h"
#include "version.h"
-CMPlugin g_plugin;
CLIST_INTERFACE *pcli;
-HINSTANCE g_hInstance;
int hLangpack;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -55,33 +53,36 @@ static const PLUGININFOEX pluginInfo = {0x97724af9, 0xf3fb, 0x47d3, {0xa3, 0xbf, 0xea, 0xa9, 0x35, 0xc7, 0x4e, 0x6d}}
};
-// Protocol instances
-static int sttCompareProtocols(const CMsnProto *p1, const CMsnProto *p2)
+extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
- return mir_wstrcmp(p1->m_tszUserName, p2->m_tszUserName);
+ return &pluginInfo;
}
-// Main DLL function
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID)
-{
- if (fdwReason == DLL_PROCESS_ATTACH) {
- g_hInstance = hinstDLL;
- DisableThreadLibraryCalls(hinstDLL);
- }
- return TRUE;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
+// MirandaInterfaces - returns the protocol interface to the core
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+/////////////////////////////////////////////////////////////////////////////////////////
// OnModulesLoaded - finalizes plugin's configuration on load
+
static int OnModulesLoaded(WPARAM, LPARAM)
{
avsPresent = ServiceExists(MS_AV_SETMYAVATARW) != 0;
MsnLinks_Init();
-
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
// Performs a primary set of actions upon plugin loading
+
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
@@ -94,19 +95,12 @@ extern "C" int __declspec(dllexport) Load(void) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
// Unload a plugin
+
extern "C" int __declspec(dllexport) Unload(void)
{
MSN_RemoveContactMenus();
MsnLinks_Destroy();
return 0;
}
-
-// MirandaPluginInfoEx - returns an information about a plugin
-extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfo;
-}
-
-// MirandaInterfaces - returns the protocol interface to the core
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp index db67f3cbb1..135ffaf6c1 100644 --- a/protocols/MSN/src/msn_auth.cpp +++ b/protocols/MSN/src/msn_auth.cpp @@ -886,14 +886,14 @@ void __cdecl CMsnProto::msn_IEAuthThread(void *pParam) wc.cbSize = sizeof(WNDCLASSEX);
wc.cbWndExtra = sizeof(void*);
- wc.hInstance = g_hInstance;
+ wc.hInstance = g_plugin.getInst();
wc.lpfnWndProc = AuthWindowProc;
wc.lpszClassName = ClassName;
RegisterClassEx(&wc);
if ((hWnd = CreateWindowEx(0, ClassName, L"MSN Login", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
- HWND_DESKTOP, nullptr, g_hInstance, pParam))) {
+ HWND_DESKTOP, nullptr, g_plugin.getInst(), pParam))) {
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
@@ -903,7 +903,7 @@ void __cdecl CMsnProto::msn_IEAuthThread(void *pParam) }
}
- UnregisterClass(ClassName, g_hInstance);
+ UnregisterClass(ClassName, g_plugin.getInst());
CoUninitialize();
}
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index a10a43a2d6..61397d677b 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -495,7 +495,7 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) break;
case GC_USER_CHANMGR:
- DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat,
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat,
LPARAM(new InviteChatParam(gch->ptszID, NULL, this)));
break;
@@ -506,7 +506,7 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) case GC_USER_LOGMENU:
switch (gch->dwData) {
case 10:
- DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat,
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat,
LPARAM(new InviteChatParam(gch->ptszID, NULL, this)));
break;
diff --git a/protocols/MSN/src/msn_links.cpp b/protocols/MSN/src/msn_links.cpp index 16345a3b49..0235544138 100644 --- a/protocols/MSN/src/msn_links.cpp +++ b/protocols/MSN/src/msn_links.cpp @@ -135,7 +135,7 @@ void MsnLinks_Init(void) static const char szService[] = "MSN/ParseMsnimLink";
CreateServiceFunction(szService, ServiceParseMsnimLink);
- AssocMgr_AddNewUrlTypeW("msnim:", TranslateT("MSN Link Protocol"), g_hInstance, IDI_MSN, szService, 0);
+ AssocMgr_AddNewUrlTypeW("msnim:", TranslateT("MSN Link Protocol"), g_plugin.getInst(), IDI_MSN, szService, 0);
}
void MsnLinks_Destroy(void)
diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp index 6823338996..490a089a5d 100644 --- a/protocols/MSN/src/msn_lists.cpp +++ b/protocols/MSN/src/msn_lists.cpp @@ -397,7 +397,7 @@ static void SaveListItem(MCONTACT hContact, const char* szEmail, int list, int i if (iNewValue == 0) {
if (list & LIST_FL) {
DeleteParam param = { proto, hContact };
- DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_DELETECONTACT), nullptr, DlgDeleteContactUI, (LPARAM)¶m);
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DELETECONTACT), nullptr, DlgDeleteContactUI, (LPARAM)¶m);
return;
}
diff --git a/protocols/MSN/src/msn_menu.cpp b/protocols/MSN/src/msn_menu.cpp index 161258a4b7..43b1edfe27 100644 --- a/protocols/MSN/src/msn_menu.cpp +++ b/protocols/MSN/src/msn_menu.cpp @@ -100,7 +100,7 @@ INT_PTR CMsnProto::MsnEditProfile(WPARAM, LPARAM) // MsnInviteCommand - invite command callback function
INT_PTR CMsnProto::MsnInviteCommand(WPARAM, LPARAM)
{
- DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat,
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat,
LPARAM(new InviteChatParam(nullptr, NULL, this)));
return 0;
}
diff --git a/protocols/MSN/src/msn_opts.cpp b/protocols/MSN/src/msn_opts.cpp index 77b042b0c4..32b3c54cdc 100644 --- a/protocols/MSN/src/msn_opts.cpp +++ b/protocols/MSN/src/msn_opts.cpp @@ -47,7 +47,7 @@ static IconItem iconList[] = void MsnInitIcons(void)
{
- Icon_Register(g_hInstance, "Protocols/MSN", iconList, _countof(iconList), "MSN");
+ Icon_Register(g_plugin.getInst(), "Protocols/MSN", iconList, _countof(iconList), "MSN");
}
HICON LoadIconEx(const char* name, bool big)
@@ -593,7 +593,7 @@ int CMsnProto::OnOptionsInit(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = -790000000;
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MSN);
odp.szTitle.w = m_tszUserName;
odp.szGroup.w = LPGENW("Network");
@@ -623,7 +623,7 @@ int CMsnProto::OnOptionsInit(WPARAM wParam, LPARAM) INT_PTR CMsnProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam)
{
- return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ACCMGRUI),
+ return (INT_PTR)CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ACCMGRUI),
(HWND)lParam, DlgProcAccMgrUI, (LPARAM)this);
}
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h index 3f9af6c5d3..e8a327452b 100644 --- a/protocols/MSN/src/msn_proto.h +++ b/protocols/MSN/src/msn_proto.h @@ -497,6 +497,7 @@ struct CMPlugin : public ACCPROTOPLUGIN<CMsnProto> CMPlugin() :
ACCPROTOPLUGIN<CMsnProto>("MSN")
{
+ ::DisableThreadLibraryCalls(m_hInst);
SetUniqueId("wlid");
}
};
diff --git a/protocols/MSN/src/msn_svcs.cpp b/protocols/MSN/src/msn_svcs.cpp index 2e50f2548f..657aa54881 100644 --- a/protocols/MSN/src/msn_svcs.cpp +++ b/protocols/MSN/src/msn_svcs.cpp @@ -267,7 +267,7 @@ int CMsnProto::OnContactDeleted(WPARAM hContact, LPARAM) if (Lists_IsInList(LIST_FL, szEmail)) {
DeleteParam param = { this, MCONTACT(hContact) };
- DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_DELETECONTACT), nullptr, DlgDeleteContactUI, (LPARAM)¶m);
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DELETECONTACT), nullptr, DlgDeleteContactUI, (LPARAM)¶m);
MsnContact *msc = Lists_Get(szEmail);
if (msc)
@@ -406,7 +406,7 @@ int CMsnProto::OnWindowPopup(WPARAM, LPARAM lParam) case MSG_WINDOWPOPUP_SELECTED:
if (mwpd->selection == 13465)
- DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat, LPARAM(new InviteChatParam(nullptr, mwpd->hContact, this)));
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHATROOM_INVITE), nullptr, DlgInviteToChat, LPARAM(new InviteChatParam(nullptr, mwpd->hContact, this)));
break;
}
diff --git a/protocols/MSN/src/stdafx.h b/protocols/MSN/src/stdafx.h index 48fd351dfc..f996fcdecc 100644 --- a/protocols/MSN/src/stdafx.h +++ b/protocols/MSN/src/stdafx.h @@ -919,7 +919,6 @@ const char msnStoreAppId[] = "Skype"; const char msnProductVer[] = "0/6.16.0.105/259/";
const char msnProtID[] = "MSNP24";
-extern HINSTANCE g_hInstance;
extern bool g_bTerminated;
///////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/MinecraftDynmap/src/dialogs.cpp b/protocols/MinecraftDynmap/src/dialogs.cpp index 20585717d0..6bedca6e8b 100644 --- a/protocols/MinecraftDynmap/src/dialogs.cpp +++ b/protocols/MinecraftDynmap/src/dialogs.cpp @@ -24,8 +24,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. // Icons -extern HINSTANCE g_hInstance; - static IconItem icons[] = { { "proto", LPGEN("Protocol icon"), IDI_PROTO }, }; @@ -33,7 +31,7 @@ static IconItem icons[] = { static HANDLE hIconLibItem[_countof(icons)]; void InitIcons(void) { - Icon_Register(g_hInstance, "Protocols/MinecraftDynmap", icons, _countof(icons), "MinecraftDynmap"); + Icon_Register(g_plugin.getInst(), "Protocols/MinecraftDynmap", icons, _countof(icons), "MinecraftDynmap"); } HANDLE GetIconHandle(const char* name) { diff --git a/protocols/MinecraftDynmap/src/main.cpp b/protocols/MinecraftDynmap/src/main.cpp index 3c39f05077..d0edbe2b34 100644 --- a/protocols/MinecraftDynmap/src/main.cpp +++ b/protocols/MinecraftDynmap/src/main.cpp @@ -22,11 +22,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h" -CMPlugin g_plugin; CLIST_INTERFACE* pcli; int hLangpack; -HINSTANCE g_hInstance; std::string g_strUserAgent; DWORD g_mirandaVersion; @@ -44,13 +42,12 @@ PLUGININFOEX pluginInfo = { }; ///////////////////////////////////////////////////////////////////////////// -// Protocol instances -DWORD WINAPI DllMain(HINSTANCE hInstance,DWORD,LPVOID) -{ - g_hInstance = hInstance; - return TRUE; -} +CMPlugin g_plugin; + +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; + +///////////////////////////////////////////////////////////////////////////// extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) { diff --git a/protocols/MinecraftDynmap/src/proto.cpp b/protocols/MinecraftDynmap/src/proto.cpp index ea486cc3a7..871cc511f3 100644 --- a/protocols/MinecraftDynmap/src/proto.cpp +++ b/protocols/MinecraftDynmap/src/proto.cpp @@ -153,7 +153,7 @@ int MinecraftDynmapProto::OnEvent(PROTOEVENTTYPE event,WPARAM wParam,LPARAM lPar INT_PTR MinecraftDynmapProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam) { - return (INT_PTR)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_MinecraftDynmapACCOUNT), (HWND)lParam, MinecraftDynmapAccountProc, (LPARAM)this); + return (INT_PTR)CreateDialogParam(g_plugin.getInst(),MAKEINTRESOURCE(IDD_MinecraftDynmapACCOUNT), (HWND)lParam, MinecraftDynmapAccountProc, (LPARAM)this); } int MinecraftDynmapProto::OnModulesLoaded(WPARAM, LPARAM) @@ -170,7 +170,7 @@ int MinecraftDynmapProto::OnModulesLoaded(WPARAM, LPARAM) /*int MinecraftDynmapProto::OnOptionsInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = g_hInstance; + odp.hInstance = g_plugin.getInst(); odp.szTitle.w = m_tszUserName; odp.dwInitParam = LPARAM(this); odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE; diff --git a/protocols/MinecraftDynmap/src/stdafx.h b/protocols/MinecraftDynmap/src/stdafx.h index e164bf1c39..7613c4181d 100644 --- a/protocols/MinecraftDynmap/src/stdafx.h +++ b/protocols/MinecraftDynmap/src/stdafx.h @@ -71,6 +71,5 @@ class MinecraftDynmapProto; #include "dialogs.h" #include "resource.h" -extern HINSTANCE g_hInstance; extern std::string g_strUserAgent; extern DWORD g_mirandaVersion; diff --git a/protocols/Omegle/src/main.cpp b/protocols/Omegle/src/main.cpp index d1226e7f6e..ce2dbcfa74 100644 --- a/protocols/Omegle/src/main.cpp +++ b/protocols/Omegle/src/main.cpp @@ -24,11 +24,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. // TODO: Make following as "globals" structure?
-CMPlugin g_plugin;
CLIST_INTERFACE* pcli;
int hLangpack;
-HINSTANCE g_hInstance;
std::string g_strUserAgent;
DWORD g_mirandaVersion;
@@ -45,12 +43,6 @@ PLUGININFOEX pluginInfo = { { 0x9e1d9244, 0x606c, 0x4ef4, { 0x99, 0xa0, 0x1d, 0x7d, 0x23, 0xcb, 0x76, 0x1 } }
};
-DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
-{
- g_hInstance = hInstance;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
{
g_mirandaVersion = mirandaVersion;
@@ -58,6 +50,12 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda }
/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Interface information
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
@@ -65,15 +63,12 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC /////////////////////////////////////////////////////////////////////////////////////////
// Load
-static HANDLE g_hEvents[1];
-
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
pcli = Clist_GetInterface();
InitIcons();
- //InitContactMenus();
// Init native User-Agent
{
@@ -103,9 +98,5 @@ extern "C" int __declspec(dllexport) Load(void) extern "C" int __declspec(dllexport) Unload(void)
{
- //UninitContactMenus();
- for (size_t i = 0; i < _countof(g_hEvents); i++)
- UnhookEvent(g_hEvents[i]);
-
return 0;
}
diff --git a/protocols/Omegle/src/proto.cpp b/protocols/Omegle/src/proto.cpp index 60361f1974..a09c8f491c 100644 --- a/protocols/Omegle/src/proto.cpp +++ b/protocols/Omegle/src/proto.cpp @@ -156,7 +156,7 @@ int OmegleProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam) INT_PTR OmegleProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam)
{
- return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_OmegleACCOUNT),
+ return (INT_PTR)CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_OmegleACCOUNT),
(HWND)lParam, OmegleAccountProc, (LPARAM)this);
}
@@ -176,7 +176,7 @@ int OmegleProto::OnModulesLoaded(WPARAM, LPARAM) int OmegleProto::OnOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.szTitle.w = m_tszUserName;
odp.dwInitParam = LPARAM(this);
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE;
diff --git a/protocols/Omegle/src/stdafx.h b/protocols/Omegle/src/stdafx.h index 70f5586598..b6aec36b82 100644 --- a/protocols/Omegle/src/stdafx.h +++ b/protocols/Omegle/src/stdafx.h @@ -75,7 +75,6 @@ class OmegleProto; #include "theme.h"
#include "resource.h"
-extern HINSTANCE g_hInstance;
extern std::string g_strUserAgent;
extern DWORD g_mirandaVersion;
diff --git a/protocols/Omegle/src/theme.cpp b/protocols/Omegle/src/theme.cpp index fa89da9717..72af5190f4 100644 --- a/protocols/Omegle/src/theme.cpp +++ b/protocols/Omegle/src/theme.cpp @@ -31,7 +31,7 @@ static IconItem icons[] = void InitIcons(void)
{
- Icon_Register(g_hInstance, "Protocols/Omegle", icons, _countof(icons), "Omegle");
+ Icon_Register(g_plugin.getInst(), "Protocols/Omegle", icons, _countof(icons), "Omegle");
}
HANDLE GetIconHandle(const char* name)
diff --git a/protocols/Sametime/src/options.cpp b/protocols/Sametime/src/options.cpp index 4c140e9f38..b2a50a5fce 100644 --- a/protocols/Sametime/src/options.cpp +++ b/protocols/Sametime/src/options.cpp @@ -343,7 +343,7 @@ int CSametimeProto::OptInit(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE;
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTNET);
odp.szTitle.w = m_tszUserName;
odp.szGroup.w = LPGENW("Network");
diff --git a/protocols/Sametime/src/sametime.cpp b/protocols/Sametime/src/sametime.cpp index 7e842b1501..6adc868b82 100644 --- a/protocols/Sametime/src/sametime.cpp +++ b/protocols/Sametime/src/sametime.cpp @@ -3,6 +3,9 @@ #include "version.h"
// plugin stuff
+
+int hLangpack;
+
PLUGININFOEX pluginInfo =
{
sizeof(PLUGININFOEX),
@@ -13,23 +16,26 @@ PLUGININFOEX pluginInfo = __COPYRIGHT,
__AUTHORWEB,
UNICODE_AWARE,
- { 0xf1b0ba1b, 0xc91, 0x4313, { 0x85, 0xeb, 0x22, 0x50, 0x69, 0xd4, 0x4d, 0x1 } } // {F1B0BA1B-0C91-4313-85EB-225069D44D01}
+ // {F1B0BA1B-0C91-4313-85EB-225069D44D01}
+ { 0xf1b0ba1b, 0xc91, 0x4313, { 0x85, 0xeb, 0x22, 0x50, 0x69, 0xd4, 0x4d, 0x1 } }
};
-CMPlugin g_plugin;
-HINSTANCE g_hInstance;
-LIST<CSametimeProto> g_Instances(1, PtrKeySortT);
-int hLangpack;
-
-extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
{
return &pluginInfo;
}
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
+/////////////////////////////////////////////////////////////////////////////////////////
// protocol related services
/** Copy the name of the protocol into lParam
@@ -60,7 +66,7 @@ INT_PTR CSametimeProto::SametimeLoadIcon(WPARAM wParam, LPARAM lParam) return NULL;
}
- return (INT_PTR) LoadImage(g_hInstance, MAKEINTRESOURCE(id), IMAGE_ICON,
+ 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);
}
@@ -79,7 +85,7 @@ static IconItem iconList[] = void SametimeInitIcons(void)
{
- Icon_Register(g_hInstance, "Protocols/Sametime", iconList, _countof(iconList), "SAMETIME");
+ Icon_Register(g_plugin.getInst(), "Protocols/Sametime", iconList, _countof(iconList), "SAMETIME");
}
HANDLE GetIconHandle(int iconId)
diff --git a/protocols/Sametime/src/sametime.h b/protocols/Sametime/src/sametime.h index 9afa3230ad..b0e807489b 100644 --- a/protocols/Sametime/src/sametime.h +++ b/protocols/Sametime/src/sametime.h @@ -105,7 +105,6 @@ typedef struct FileTransferClientData_tag { // Global variables
struct CSametimeProto;
-extern HINSTANCE g_hInstance;
extern PLUGININFOEX pluginInfo;
#include "sametime_proto.h"
diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp index d1c5a0dcfe..6b34208431 100644 --- a/protocols/Sametime/src/sametime_proto.cpp +++ b/protocols/Sametime/src/sametime_proto.cpp @@ -174,7 +174,7 @@ HWND CSametimeProto::SearchAdvanced(HWND owner) HWND CSametimeProto::CreateExtendedSearchUI(HWND owner)
{
debugLogW(L"CSametimeProto::CreateExtendedSearchUI() start");
- return CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_USERSEARCH), owner, SearchDialogFunc, (LPARAM)this);
+ return CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_USERSEARCH), owner, SearchDialogFunc, (LPARAM)this);
}
diff --git a/protocols/Sametime/src/sametime_session.cpp b/protocols/Sametime/src/sametime_session.cpp index 7f87cd8456..fc029ee5ea 100644 --- a/protocols/Sametime/src/sametime_session.cpp +++ b/protocols/Sametime/src/sametime_session.cpp @@ -563,7 +563,7 @@ INT_PTR CSametimeProto::SessionAnnounce(WPARAM wParam, LPARAM lParam) SessionAnnounceDialogProc_arg* sadpArg = (SessionAnnounceDialogProc_arg*)mir_calloc(sizeof(SessionAnnounceDialogProc_arg));
sadpArg->proto = this;
sadpArg->sendAnnouncementFunc = SendAnnouncement;
- CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SESSIONANNOUNCE), GetDesktopWindow(), SessionAnnounceDialogProc, (LPARAM)sadpArg);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SESSIONANNOUNCE), GetDesktopWindow(), SessionAnnounceDialogProc, (LPARAM)sadpArg);
return 0;
}
diff --git a/protocols/SkypeWeb/src/main.cpp b/protocols/SkypeWeb/src/main.cpp index bc5ebf60f3..1b358e0651 100644 --- a/protocols/SkypeWeb/src/main.cpp +++ b/protocols/SkypeWeb/src/main.cpp @@ -17,9 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
-CMPlugin g_plugin;
int hLangpack;
-HINSTANCE g_hInstance;
CLIST_INTERFACE *pcli;
char g_szMirVer[100];
HANDLE g_hCallEvent;
@@ -39,15 +37,32 @@ PLUGININFOEX pluginInfo = { 0x57e90ac6, 0x1067, 0x423b, { 0x8c, 0xa3, 0x70, 0xa3, 0x9d, 0x20, 0xd, 0x4f } }
};
-extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM)
+{
+ if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
+ CreateServiceFunction(MODULE "/ParseUri", CSkypeProto::GlobalParseSkypeUriService);
+ AssocMgr_AddNewUrlTypeW("skype:", TranslateT("Skype Link Protocol"), g_plugin.getInst(), IDI_SKYPE, MODULE "/ParseUri", 0);
+ }
+ return 0;
+}
+
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
@@ -69,21 +84,10 @@ extern "C" int __declspec(dllexport) Load(void) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload(void)
{
-
DestroyHookableEvent(g_hCallEvent);
-
- return 0;
-}
-
-
-int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM)
-{
- if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE))
- {
- CreateServiceFunction(MODULE "/ParseUri", CSkypeProto::GlobalParseSkypeUriService);
- AssocMgr_AddNewUrlTypeW("skype:", TranslateT("Skype Link Protocol"), g_hInstance, IDI_SKYPE, MODULE "/ParseUri", 0);
- }
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_icons.cpp b/protocols/SkypeWeb/src/skype_icons.cpp index 412d0c0043..7aba64a40a 100644 --- a/protocols/SkypeWeb/src/skype_icons.cpp +++ b/protocols/SkypeWeb/src/skype_icons.cpp @@ -32,7 +32,7 @@ IconItemT CSkypeProto::Icons[] = void CSkypeProto::InitIcons()
{
- Icon_RegisterT(g_hInstance, LPGENW("Protocols") L"/" _A2W(MODULE), Icons, _countof(Icons), MODULE);
+ Icon_RegisterT(g_plugin.getInst(), LPGENW("Protocols") L"/" _A2W(MODULE), Icons, _countof(Icons), MODULE);
}
HICON CSkypeProto::GetIcon(int iconId)
diff --git a/protocols/SkypeWeb/src/skype_options.cpp b/protocols/SkypeWeb/src/skype_options.cpp index a8941a18ee..2bac189297 100644 --- a/protocols/SkypeWeb/src/skype_options.cpp +++ b/protocols/SkypeWeb/src/skype_options.cpp @@ -71,7 +71,7 @@ void CSkypeOptionsMain::OnApply() int CSkypeProto::OnOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.szTitle.w = m_tszUserName;
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE;
odp.szGroup.w = LPGENW("Network");
diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h index 2cb4883414..0be6ba5730 100644 --- a/protocols/SkypeWeb/src/stdafx.h +++ b/protocols/SkypeWeb/src/stdafx.h @@ -58,7 +58,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. struct CSkypeProto;
-extern HINSTANCE g_hInstance;
extern char g_szMirVer[];
extern HANDLE g_hCallEvent;
diff --git a/protocols/Steam/src/main.cpp b/protocols/Steam/src/main.cpp index f674bc4a09..2bf3ee3bdc 100644 --- a/protocols/Steam/src/main.cpp +++ b/protocols/Steam/src/main.cpp @@ -1,8 +1,6 @@ #include "stdafx.h"
int hLangpack;
-HINSTANCE g_hInstance;
-CMPlugin g_plugin;
HANDLE hExtraXStatus;
@@ -20,15 +18,23 @@ PLUGININFOEX pluginInfo = { 0x68f5a030, 0xba32, 0x48ec, { 0x95, 0x7, 0x5c, 0x2f, 0xbd, 0xea, 0x52, 0x17 }}
};
-extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
@@ -44,6 +50,8 @@ extern "C" int __declspec(dllexport) Load(void) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload(void)
{
return 0;
diff --git a/protocols/Steam/src/stdafx.h b/protocols/Steam/src/stdafx.h index 744cbb7f6d..4a70cb0159 100644 --- a/protocols/Steam/src/stdafx.h +++ b/protocols/Steam/src/stdafx.h @@ -49,7 +49,6 @@ #define STEAM_API_POLLING_ERRORS_LIMIT 5
class CSteamProto;
-extern HINSTANCE g_hInstance;
extern HANDLE hExtraXStatus;
diff --git a/protocols/Steam/src/steam_options.cpp b/protocols/Steam/src/steam_options.cpp index 21ecd18828..ed5fc00e36 100644 --- a/protocols/Steam/src/steam_options.cpp +++ b/protocols/Steam/src/steam_options.cpp @@ -76,7 +76,7 @@ void CSteamOptionsBlockList::OnBlock(CCtrlButton*) int CSteamProto::OnOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.szTitle.w = m_tszUserName;
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.szGroup.w = LPGENW("Network");
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index fde2920507..6ca91ace53 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -19,7 +19,7 @@ CSteamProto::CSteamProto(const char* protoName, const wchar_t* userName) // icons wchar_t filePath[MAX_PATH]; - GetModuleFileName(g_hInstance, filePath, MAX_PATH); + GetModuleFileName(g_plugin.getInst(), filePath, MAX_PATH); wchar_t sectionName[100]; mir_snwprintf(sectionName, L"%s/%s", LPGENW("Protocols"), _A2W(MODULE)); diff --git a/protocols/Tox/src/main.cpp b/protocols/Tox/src/main.cpp index ec6ae99f82..1b4c10f526 100644 --- a/protocols/Tox/src/main.cpp +++ b/protocols/Tox/src/main.cpp @@ -1,10 +1,8 @@ #include "stdafx.h" int hLangpack; -CMPlugin g_plugin; CHAT_MANAGER *pci; CLIST_INTERFACE *pcli; -HINSTANCE g_hInstance; HANDLE hProfileFolderPath; PLUGININFOEX pluginInfo = @@ -21,15 +19,23 @@ PLUGININFOEX pluginInfo = {0x272a3e, 0xf5fa, 0x4090, {0x8b, 0x67, 0x3e, 0x62, 0xac, 0x1e, 0xe0, 0xb4}} }; -extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; - extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { return &pluginInfo; } +///////////////////////////////////////////////////////////////////////////////////////// + +CMPlugin g_plugin; + +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; + +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; +///////////////////////////////////////////////////////////////////////////////////////// + int OnModulesLoaded(WPARAM, LPARAM) { CToxProto::InitIcons(); @@ -38,7 +44,7 @@ int OnModulesLoaded(WPARAM, LPARAM) if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) { CreateServiceFunction(MODULE "/ParseUri", CToxProto::ParseToxUri); - AssocMgr_AddNewUrlTypeW("tox:", TranslateT("Tox link protocol"), g_hInstance, IDI_TOX, MODULE "/ParseUri", 0); + AssocMgr_AddNewUrlTypeW("tox:", TranslateT("Tox link protocol"), g_plugin.getInst(), IDI_TOX, MODULE "/ParseUri", 0); } return 0; @@ -55,6 +61,8 @@ extern "C" int __declspec(dllexport) Load(void) return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" int __declspec(dllexport) Unload(void) { return 0; diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h index c59439eae6..be29bd7edb 100644 --- a/protocols/Tox/src/stdafx.h +++ b/protocols/Tox/src/stdafx.h @@ -90,7 +90,6 @@ struct CToxProto; #include "http_request.h"
-extern HINSTANCE g_hInstance;
extern HANDLE hProfileFolderPath;
#endif //_COMMON_H_
\ No newline at end of file diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 4920e71e44..6c93559463 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -353,7 +353,7 @@ int CToxProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam) if (szProto != nullptr && !mir_strcmp(szProto, m_szModuleName)) {
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.flags = ODPF_UNICODE | ODPF_DONTTRANSLATE;
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.dwInitParam = (LPARAM)this;
odp.szTitle.w = m_tszUserName;
diff --git a/protocols/Tox/src/tox_icons.cpp b/protocols/Tox/src/tox_icons.cpp index a94405982e..762266799f 100644 --- a/protocols/Tox/src/tox_icons.cpp +++ b/protocols/Tox/src/tox_icons.cpp @@ -9,7 +9,7 @@ IconItemT CToxProto::Icons[] = void CToxProto::InitIcons()
{
- Icon_RegisterT(g_hInstance, LPGENW("Protocols") L"/" _A2W(MODULE), Icons, _countof(Icons), MODULE);
+ Icon_RegisterT(g_plugin.getInst(), LPGENW("Protocols") L"/" _A2W(MODULE), Icons, _countof(Icons), MODULE);
}
HANDLE CToxProto::GetIconHandle(int iconId)
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index dfaa9d528d..952bf194f9 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -247,7 +247,7 @@ void CToxOptionsMain::OnApply() /////////////////////////////////////////////////////////////////////////////////
CToxNodeEditor::CToxNodeEditor(int iItem, CCtrlListView *m_nodes)
- : CSuper(g_hInstance, IDD_NODE_EDITOR),
+ : CSuper(g_plugin.getInst(), IDD_NODE_EDITOR),
m_ipv4(this, IDC_IPV4), m_ipv6(this, IDC_IPV6),
m_port(this, IDC_PORT), m_pkey(this, IDC_PKEY),
m_ok(this, IDOK), m_iItem(iItem)
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index 840436b149..ebbddf2ad8 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -112,5 +112,5 @@ HWND CToxProto::OnSearchAdvanced(HWND owner) HWND CToxProto::OnCreateExtendedSearchUI(HWND owner)
{
- return CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SEARCH), owner, SearchDlgProc, (LPARAM)this);
+ return CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SEARCH), owner, SearchDlgProc, (LPARAM)this);
}
diff --git a/protocols/Twitter/src/main.cpp b/protocols/Twitter/src/main.cpp index de7559e55e..94dd556b24 100644 --- a/protocols/Twitter/src/main.cpp +++ b/protocols/Twitter/src/main.cpp @@ -22,10 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "proto.h"
#include "theme.h"
-CMPlugin g_plugin;
-CLIST_INTERFACE* pcli;
+CLIST_INTERFACE *pcli;
-HINSTANCE g_hInstance;
int hLangpack = 0;
PLUGININFOEX pluginInfo = {
@@ -41,15 +39,18 @@ PLUGININFOEX pluginInfo = { { 0xbc09a71b, 0xb86e, 0x4d33, { 0xb1, 0x8d, 0x82, 0xd3, 0x4, 0x51, 0xdd, 0x3c } }
};
-extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
/////////////////////////////////////////////////////////////////////////////////////////
-// Interface information
+
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index f25e7d86df..b57cf5d452 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -191,14 +191,14 @@ int TwitterProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam) INT_PTR TwitterProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam)
{
- return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_TWITTERACCOUNT), (HWND)lParam, first_run_dialog, (LPARAM)this);
+ return (INT_PTR)CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_TWITTERACCOUNT), (HWND)lParam, first_run_dialog, (LPARAM)this);
}
INT_PTR TwitterProto::ReplyToTweet(WPARAM wParam, LPARAM)
{
MCONTACT hContact = (MCONTACT) wParam;
// TODO: support replying to tweets instead of just users
- HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_TWEET), nullptr, tweet_proc, reinterpret_cast<LPARAM>(this));
+ HWND hDlg = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_TWEET), nullptr, tweet_proc, reinterpret_cast<LPARAM>(this));
DBVARIANT dbv;
if (!getString(hContact, TWITTER_KEY_UN, &dbv)) {
@@ -252,7 +252,7 @@ int TwitterProto::OnOptionsInit(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 271828;
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.szGroup.w = LPGENW("Network");
odp.szTitle.w = m_tszUserName;
odp.dwInitParam = LPARAM(this);
@@ -277,7 +277,7 @@ INT_PTR TwitterProto::OnTweet(WPARAM, LPARAM) if (m_iStatus != ID_STATUS_ONLINE)
return 1;
- HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_TWEET), nullptr, tweet_proc, reinterpret_cast<LPARAM>(this));
+ HWND hDlg = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_TWEET), nullptr, tweet_proc, reinterpret_cast<LPARAM>(this));
ShowWindow(hDlg, SW_SHOW);
return 0;
}
@@ -343,7 +343,7 @@ int TwitterProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) int TwitterProto::ShowPinDialog()
{
- HWND hDlg = (HWND)DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_TWITTERPIN), nullptr, pin_proc, reinterpret_cast<LPARAM>(this));
+ HWND hDlg = (HWND)DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_TWITTERPIN), nullptr, pin_proc, reinterpret_cast<LPARAM>(this));
ShowWindow(hDlg, SW_SHOW);
return 0;
}
diff --git a/protocols/Twitter/src/stdafx.h b/protocols/Twitter/src/stdafx.h index 1183be966a..eaae38768d 100644 --- a/protocols/Twitter/src/stdafx.h +++ b/protocols/Twitter/src/stdafx.h @@ -65,8 +65,6 @@ typedef std::basic_string<wchar_t> wstring; #include "StringUtil.h"
-extern HINSTANCE g_hInstance;
-
#define TWITTER_KEY_NICK "Nick" // we need one called Nick for the chat thingo to work
#define TWITTER_KEY_UN "Username"
#define TWITTER_KEY_PASS "Password"
diff --git a/protocols/Twitter/src/theme.cpp b/protocols/Twitter/src/theme.cpp index 75c5252f34..e3b967caf3 100644 --- a/protocols/Twitter/src/theme.cpp +++ b/protocols/Twitter/src/theme.cpp @@ -38,7 +38,7 @@ void TwitterInitSounds(void) // TODO: uninit
void InitIcons(void)
{
- Icon_Register(g_hInstance, "Protocols/Twitter", icons, _countof(icons), "Twitter");
+ Icon_Register(g_plugin.getInst(), "Protocols/Twitter", icons, _countof(icons), "Twitter");
icons[_countof(icons) - 1].hIcolib = Skin_GetIconHandle(SKINICON_EVENT_URL);
}
diff --git a/protocols/VKontakte/src/main.cpp b/protocols/VKontakte/src/main.cpp index 01a6dfb66d..d87612bf7b 100644 --- a/protocols/VKontakte/src/main.cpp +++ b/protocols/VKontakte/src/main.cpp @@ -18,8 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
#include "version.h"
-CMPlugin g_plugin;
-HINSTANCE g_hInstance;
int hLangpack;
CLIST_INTERFACE *pcli;
@@ -37,15 +35,19 @@ PLUGININFOEX pluginInfo = { 0x32579908, 0x724b, 0x467f, {0xad, 0xad, 0x22, 0xb6, 0x35, 0x9a, 0x74, 0x9a}}
};
-/////////////////////////////////////////////////////////////////////////////////////////
-
-extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 1b18bc382b..78408b5e3e 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -79,7 +79,7 @@ static IconItem iconList[] = void InitIcons()
{
- Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("VKontakte"), iconList, _countof(iconList), "VKontakte");
+ Icon_Register(g_plugin.getInst(), LPGEN("Protocols") "/" LPGEN("VKontakte"), iconList, _countof(iconList), "VKontakte");
}
HANDLE GetIconHandle(int iCommand)
diff --git a/protocols/VKontakte/src/stdafx.h b/protocols/VKontakte/src/stdafx.h index e60368369e..5695d1bbf1 100644 --- a/protocols/VKontakte/src/stdafx.h +++ b/protocols/VKontakte/src/stdafx.h @@ -57,8 +57,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "win2k.h"
-extern HINSTANCE g_hInstance;
-
#include "resource.h"
#include "vk.h"
#include "vk_struct.h"
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index b40f8980ba..e894a6304e 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -101,9 +101,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #endif
struct CVkProto;
-extern LIST<CVkProto> vk_Instances;
extern mir_cs csInstances;
-extern HINSTANCE g_hInstance;
LPCSTR findHeader(NETLIBHTTPREQUEST *hdr, LPCSTR szField);
bool wlstrstr(wchar_t *_s1, wchar_t *_s2);
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 0253c96d6d..cdb207555a 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -29,7 +29,6 @@ static int sttCompareAsyncHttpRequest(const AsyncHttpRequest *p1, const AsyncHtt return (int)p2->m_priority - (int)p1->m_priority;
}
-LIST<CVkProto> vk_Instances(1, sttCompareProtocols);
mir_cs csInstances;
CVkProto::CVkProto(const char *szModuleName, const wchar_t *pwszUserName) :
@@ -78,10 +77,6 @@ CVkProto::CVkProto(const char *szModuleName, const wchar_t *pwszUserName) : // Set all contacts offline -- in case we crashed
SetAllContactStatuses(ID_STATUS_OFFLINE);
- {
- mir_cslock lck(csInstances);
- vk_Instances.insert(this);
- }
}
CVkProto::~CVkProto()
@@ -95,10 +90,6 @@ CVkProto::~CVkProto() Popup_UnregisterClass(m_hPopupClassError);
if (m_hPopupClassNotification)
Popup_UnregisterClass(m_hPopupClassNotification);
- {
- mir_cslock lck(csInstances);
- vk_Instances.remove(this);
- }
}
int CVkProto::OnModulesLoaded(WPARAM, LPARAM)
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index dc434c5606..1986b3a240 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -52,7 +52,7 @@ void CVkProto::ConnectionFailed(int iReason) static VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
mir_cslock lck(csInstances);
- for (auto &it : vk_Instances)
+ for (auto &it : g_plugin.g_arInstances)
if (it->IsOnline()) {
it->debugLogA("Tic timer for %s", it->m_szModuleName);
it->OnTimerTic();
@@ -124,7 +124,7 @@ void CVkProto::OnLoggedOut() bool bOnline = false;
{
mir_cslock lck(csInstances);
- for (auto &it : vk_Instances)
+ for (auto &it : g_plugin.g_arInstances)
bOnline = bOnline || it->IsOnline();
}
if (!bOnline)
|