From b172c4bbc75cdad0e8ccd22292aa671ba43cac45 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 18 Apr 2018 18:14:33 +0300 Subject: PLUGIN<> to half-automatically calculate the dll's g_hInstance and pass it inside --- plugins/CloudFile/src/Services/dropbox_service.cpp | 6 ++++-- plugins/CloudFile/src/Services/google_service.cpp | 2 +- plugins/CloudFile/src/Services/microsoft_service.cpp | 2 +- plugins/CloudFile/src/Services/yandex_service.cpp | 2 +- plugins/CloudFile/src/icons.cpp | 2 +- plugins/CloudFile/src/main.cpp | 8 +------- plugins/CloudFile/src/oauth.cpp | 2 +- plugins/CloudFile/src/options.cpp | 2 +- plugins/CloudFile/src/stdafx.h | 2 +- 9 files changed, 12 insertions(+), 16 deletions(-) (limited to 'plugins/CloudFile/src') diff --git a/plugins/CloudFile/src/Services/dropbox_service.cpp b/plugins/CloudFile/src/Services/dropbox_service.cpp index 34e779df1c..1dacf3112e 100644 --- a/plugins/CloudFile/src/Services/dropbox_service.cpp +++ b/plugins/CloudFile/src/Services/dropbox_service.cpp @@ -308,12 +308,14 @@ UINT CDropboxService::Upload(FileTransferParam *ftp) ///////////////////////////////////////////////////////////////////////////////////////// -struct CMPluginDropbox : public CMPluginBase +struct CMPluginDropbox : public PLUGIN { CMPluginDropbox() : - CMPluginBase(MODULE "/Dropbox") + PLUGIN(MODULE "/Dropbox") { RegisterProtocol(PROTOTYPE_PROTOCOL, (pfnInitProto)CDropboxService::Init, (pfnUninitProto)CDropboxService::UnInit); } } g_pluginDropbox; + +extern "C" _pfnCrtInit _pRawDllMain = &CMPluginDropbox::RawDllMain; diff --git a/plugins/CloudFile/src/Services/google_service.cpp b/plugins/CloudFile/src/Services/google_service.cpp index c7c24333ac..665f5bc511 100644 --- a/plugins/CloudFile/src/Services/google_service.cpp +++ b/plugins/CloudFile/src/Services/google_service.cpp @@ -295,7 +295,7 @@ UINT CGDriveService::Upload(FileTransferParam *ftp) struct CMPluginGoogle : public CMPluginBase { CMPluginGoogle() : - CMPluginBase(MODULE "/GDrive") + CMPluginBase(g_hInstance, MODULE "/GDrive") { RegisterProtocol(PROTOTYPE_PROTOCOL, (pfnInitProto)CGDriveService::Init, (pfnUninitProto)CGDriveService::UnInit); } diff --git a/plugins/CloudFile/src/Services/microsoft_service.cpp b/plugins/CloudFile/src/Services/microsoft_service.cpp index 05c4c5ca81..656ccbdd4b 100644 --- a/plugins/CloudFile/src/Services/microsoft_service.cpp +++ b/plugins/CloudFile/src/Services/microsoft_service.cpp @@ -280,7 +280,7 @@ UINT COneDriveService::Upload(FileTransferParam *ftp) struct CMPluginOnedrive : public CMPluginBase { CMPluginOnedrive() : - CMPluginBase(MODULE "/OneDrive") + CMPluginBase(g_hInstance, MODULE "/OneDrive") { RegisterProtocol(PROTOTYPE_PROTOCOL, (pfnInitProto)COneDriveService::Init, (pfnUninitProto)COneDriveService::UnInit); } diff --git a/plugins/CloudFile/src/Services/yandex_service.cpp b/plugins/CloudFile/src/Services/yandex_service.cpp index c3e32aa8c8..3212814db5 100644 --- a/plugins/CloudFile/src/Services/yandex_service.cpp +++ b/plugins/CloudFile/src/Services/yandex_service.cpp @@ -290,7 +290,7 @@ UINT CYandexService::Upload(FileTransferParam *ftp) struct CMPluginYandex : public CMPluginBase { CMPluginYandex() : - CMPluginBase(MODULE "/YandexDisk") + CMPluginBase(g_hInstance, MODULE "/YandexDisk") { RegisterProtocol(PROTOTYPE_PROTOCOL, (pfnInitProto)CYandexService::Init, (pfnUninitProto)CYandexService::UnInit); } diff --git a/plugins/CloudFile/src/icons.cpp b/plugins/CloudFile/src/icons.cpp index ed496f2430..bb9dd9096c 100644 --- a/plugins/CloudFile/src/icons.cpp +++ b/plugins/CloudFile/src/icons.cpp @@ -11,7 +11,7 @@ static IconItem iconList[] = void InitializeIcons() { - Icon_Register(hInstance, "Protocols/" MODULE, iconList, _countof(iconList), MODULE); + Icon_Register(g_hInstance, "Protocols/" MODULE, iconList, _countof(iconList), MODULE); } HANDLE GetIconHandle(int iconId) diff --git a/plugins/CloudFile/src/main.cpp b/plugins/CloudFile/src/main.cpp index 91d8a82f7c..e9c8a6fdd2 100644 --- a/plugins/CloudFile/src/main.cpp +++ b/plugins/CloudFile/src/main.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" int hLangpack; -HINSTANCE hInstance; +HINSTANCE g_hInstance; PLUGININFOEX pluginInfo = { @@ -17,12 +17,6 @@ PLUGININFOEX pluginInfo = { 0xe876fe63, 0x701, 0x4cda, { 0xbe, 0xd5, 0x7c, 0x73, 0xa3, 0x79, 0xc1, 0xd1 }} }; -DWORD WINAPI DllMain(HINSTANCE hInst, DWORD, LPVOID) -{ - hInstance = hInst; - return TRUE; -} - extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { return &pluginInfo; diff --git a/plugins/CloudFile/src/oauth.cpp b/plugins/CloudFile/src/oauth.cpp index 9d8e40cf73..0e0503f639 100644 --- a/plugins/CloudFile/src/oauth.cpp +++ b/plugins/CloudFile/src/oauth.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" COAuthDlg::COAuthDlg(CCloudService *service, const char *authUrl, pThreadFuncOwner requestAccessTokenThread) - : CDlgBase(hInstance, IDD_OAUTH), m_service(service), + : CDlgBase(g_hInstance, IDD_OAUTH), m_service(service), m_requestAccessTokenThread(requestAccessTokenThread), m_authorize(this, IDC_OAUTH_AUTHORIZE, authUrl), m_code(this, IDC_OAUTH_CODE), m_ok(this, IDOK) diff --git a/plugins/CloudFile/src/options.cpp b/plugins/CloudFile/src/options.cpp index 32eb485a31..09fb7df117 100644 --- a/plugins/CloudFile/src/options.cpp +++ b/plugins/CloudFile/src/options.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" COptionsMainDlg::COptionsMainDlg() - : CPluginDlgBase(hInstance, IDD_OPTIONS_MAIN, MODULE), + : CPluginDlgBase(g_hInstance, IDD_OPTIONS_MAIN, MODULE), m_defaultService(this, IDC_DEFAULTSERVICE), m_doNothingOnConflict(this, IDC_DONOTHINGONCONFLICT), m_renameOnConflict(this, IDC_RENAMEONCONFLICT), diff --git a/plugins/CloudFile/src/stdafx.h b/plugins/CloudFile/src/stdafx.h index 9e91769740..85ce23b8d7 100644 --- a/plugins/CloudFile/src/stdafx.h +++ b/plugins/CloudFile/src/stdafx.h @@ -41,7 +41,7 @@ class CCloudService; #include "options.h" -extern HINSTANCE hInstance; +extern HINSTANCE g_hInstance; extern HNETLIBUSER hNetlibConnection; class Exception -- cgit v1.2.3