diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-18 18:14:33 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-18 18:14:33 +0300 |
commit | b172c4bbc75cdad0e8ccd22292aa671ba43cac45 (patch) | |
tree | 4677a04a47f3987c88f3fb44c6b70d2642b1f8a3 /plugins/YAMN/src | |
parent | 524d1c7186eca3f0a4da08548eeb919785227101 (diff) |
PLUGIN<> to half-automatically calculate the dll's g_hInstance and pass it inside
Diffstat (limited to 'plugins/YAMN/src')
-rw-r--r-- | plugins/YAMN/src/browser/badconnect.cpp | 2 | ||||
-rw-r--r-- | plugins/YAMN/src/browser/mailbrowser.cpp | 4 | ||||
-rw-r--r-- | plugins/YAMN/src/main.cpp | 43 | ||||
-rw-r--r-- | plugins/YAMN/src/proto/pop3/pop3opt.cpp | 4 |
4 files changed, 25 insertions, 28 deletions
diff --git a/plugins/YAMN/src/browser/badconnect.cpp b/plugins/YAMN/src/browser/badconnect.cpp index 6bc632e730..7b84b15c44 100644 --- a/plugins/YAMN/src/browser/badconnect.cpp +++ b/plugins/YAMN/src/browser/badconnect.cpp @@ -220,7 +220,7 @@ void __cdecl BadConnection(void *Param) SetEvent(MyParam.ThreadRunningEV);
__try {
- hBadConnect = CreateDialogParam(YAMNVar.hInst, MAKEINTRESOURCE(IDD_DLGBADCONNECT), nullptr, DlgProcYAMNBadConnection, (LPARAM)&MyParam);
+ hBadConnect = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_DLGBADCONNECT), nullptr, DlgProcYAMNBadConnection, (LPARAM)&MyParam);
Window_SetIcon_IcoLib(hBadConnect, g_GetIconHandle(3));
#ifdef DEBUG_SYNCHRO
diff --git a/plugins/YAMN/src/browser/mailbrowser.cpp b/plugins/YAMN/src/browser/mailbrowser.cpp index d26db00f7b..7ecab8374d 100644 --- a/plugins/YAMN/src/browser/mailbrowser.cpp +++ b/plugins/YAMN/src/browser/mailbrowser.cpp @@ -1604,7 +1604,7 @@ void __cdecl ShowEmailThread(void *Param) } else { CREADTEVIEWMESSAGEWINDOW: - MyParam.mail->MsgWindow = CreateDialogParamW(YAMNVar.hInst, MAKEINTRESOURCEW(IDD_DLGSHOWMESSAGE), nullptr, DlgProcYAMNShowMessage, (LPARAM)&MyParam); + MyParam.mail->MsgWindow = CreateDialogParamW(g_hInstance, MAKEINTRESOURCEW(IDD_DLGSHOWMESSAGE), nullptr, DlgProcYAMNShowMessage, (LPARAM)&MyParam); WindowList_Add(YAMNVar.MessageWnds, MyParam.mail->MsgWindow); MSG msg; while (GetMessage(&msg, nullptr, 0, 0)) { @@ -2318,7 +2318,7 @@ void __cdecl MailBrowser(void *Param) WndFound = TRUE; if ((hMailBrowser == nullptr) && ((MyParam.nflags & YAMN_ACC_MSG) || (MyParam.nflags & YAMN_ACC_ICO) || (MyParam.nnflags & YAMN_ACC_MSG))) { - hMailBrowser = CreateDialogParamW(YAMNVar.hInst, MAKEINTRESOURCEW(IDD_DLGVIEWMESSAGES), nullptr, DlgProcYAMNMailBrowser, (LPARAM)&MyParam); + hMailBrowser = CreateDialogParamW(g_hInstance, MAKEINTRESOURCEW(IDD_DLGVIEWMESSAGES), nullptr, DlgProcYAMNMailBrowser, (LPARAM)&MyParam); Window_SetIcon_IcoLib(hMailBrowser, g_GetIconHandle(2)); MoveWindow(hMailBrowser, PosX, PosY, SizeX, SizeY, TRUE); } diff --git a/plugins/YAMN/src/main.cpp b/plugins/YAMN/src/main.cpp index edfbf9c6ec..7491051500 100644 --- a/plugins/YAMN/src/main.cpp +++ b/plugins/YAMN/src/main.cpp @@ -23,6 +23,7 @@ int YAMN_STATUS; BOOL UninstallPlugins; HANDLE hAccountFolder; +HINSTANCE g_hInstance; HINSTANCE *hDllPlugins; static int iDllPlugins = 0; @@ -32,19 +33,6 @@ YAMN_VARIABLES YAMNVar; CLIST_INTERFACE *pcli; int hLangpack; -PLUGININFOEX pluginInfo = { - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), - __DESCRIPTION, - __AUTHOR, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - // {B047A7E5-027A-4CFC-8B18-EDA8345D2790} - {0xb047a7e5, 0x27a, 0x4cfc, {0x8b, 0x18, 0xed, 0xa8, 0x34, 0x5d, 0x27, 0x90}} -}; - HANDLE hNewMailHook; HANDLE NoWriterEV; HANDLE hTTButton; @@ -82,15 +70,22 @@ static void GetProfileDirectory(wchar_t *szPath, int cbPath) ///////////////////////////////////////////////////////////////////////////////////////// -extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) -{ - YAMNVar.hInst = hinstDLL; - return TRUE; -} +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; ///////////////////////////////////////////////////////////////////////////////////////// -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {B047A7E5-027A-4CFC-8B18-EDA8345D2790} + {0xb047a7e5, 0x27a, 0x4cfc, {0x8b, 0x18, 0xed, 0xa8, 0x34, 0x5d, 0x27, 0x90}} +}; extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { @@ -98,8 +93,8 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) } ///////////////////////////////////////////////////////////////////////////////////////// - // The callback function + BOOL CALLBACK EnumSystemCodePagesProc(LPTSTR cpStr) { // Convert code page string to number @@ -168,7 +163,7 @@ static IconItem iconList[] = void LoadIcons() { - Icon_Register(YAMNVar.hInst, "YAMN", iconList, _countof(iconList)); + Icon_Register(g_hInstance, "YAMN", iconList, _countof(iconList)); } HANDLE WINAPI g_GetIconHandle(int idx) @@ -362,13 +357,15 @@ extern "C" int __declspec(dllexport) Unload(void) ///////////////////////////////////////////////////////////////////////////////////////// -struct CMPlugin : public CMPluginBase +struct CMPlugin : public PLUGIN<CMPlugin> { CMPlugin() : - CMPluginBase(YAMN_DBMODULE) + PLUGIN<CMPlugin>(YAMN_DBMODULE) { RegisterProtocol(PROTOTYPE_VIRTUAL); SetUniqueId("Id"); } } g_plugin; + +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; diff --git a/plugins/YAMN/src/proto/pop3/pop3opt.cpp b/plugins/YAMN/src/proto/pop3/pop3opt.cpp index 07889eaee3..405e27ab4a 100644 --- a/plugins/YAMN/src/proto/pop3/pop3opt.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3opt.cpp @@ -154,7 +154,7 @@ INT_PTR CALLBACK DlgProcPluginOpt(HWND hDlg, UINT msg, WPARAM wParam, LPARAM) int YAMNOptInitSvc(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = YAMNVar.hInst;
+ odp.hInstance = g_hInstance;
odp.szGroup.a = LPGEN("Network");
odp.szTitle.a = LPGEN("YAMN");
odp.flags = ODPF_BOLDGROUPS;
@@ -809,7 +809,7 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP break;
case IDC_BTNSTATUS:
- DialogBoxParamW(pYAMNVar->hInst, MAKEINTRESOURCEW(IDD_CHOOSESTATUSMODES), hDlg, DlgProcPOP3AccStatusOpt, NULL);
+ DialogBoxParamW(g_hInstance, MAKEINTRESOURCEW(IDD_CHOOSESTATUSMODES), hDlg, DlgProcPOP3AccStatusOpt, NULL);
break;
case IDC_BTNADD:
|