summaryrefslogtreecommitdiff
path: root/protocols/MRA/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-04-18 20:51:18 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-04-18 20:51:18 +0300
commit9cf1444eb7888f2d942d220f938aa893396a8a1b (patch)
treeea87e4cb78e9c26a651af00b2d423324ce4a85a6 /protocols/MRA/src
parent3936ebbc665c9653d9f62527c1e136944d52e2ca (diff)
g_hInstance incapulated into PLUGIN<>, no need in the separate variable
Diffstat (limited to 'protocols/MRA/src')
-rw-r--r--protocols/MRA/src/Mra.cpp35
-rw-r--r--protocols/MRA/src/MraAdvancedSearch.cpp4
-rw-r--r--protocols/MRA/src/MraIcons.cpp10
-rw-r--r--protocols/MRA/src/MraPopUp.cpp4
-rw-r--r--protocols/MRA/src/MraProto.cpp2
-rw-r--r--protocols/MRA/src/MraSelectEMail.cpp2
-rw-r--r--protocols/MRA/src/Mra_functions.cpp4
-rw-r--r--protocols/MRA/src/Mra_options.cpp2
-rw-r--r--protocols/MRA/src/stdafx.h11
9 files changed, 39 insertions, 35 deletions
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