From 73d93114e2c4d4c1c259fa1474a5c6bd723b92ee Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 17 May 2018 11:42:46 +0300 Subject: IEView, IgnoreState, Import: cmplugin adaptation --- plugins/Import/src/import.cpp | 14 ++++++++------ plugins/Import/src/main.cpp | 16 +++++----------- plugins/Import/src/stdafx.h | 10 +++++++--- plugins/Import/src/utils.cpp | 8 ++++---- plugins/Import/src/wizard.cpp | 4 ++-- 5 files changed, 26 insertions(+), 26 deletions(-) (limited to 'plugins/Import/src') diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 1e54739a08..bbc55b940c 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -43,11 +43,13 @@ struct AccountMap }; static int CompareAccs(const AccountMap *p1, const AccountMap *p2) -{ return mir_strcmpi(p1->szSrcAcc, p2->szSrcAcc); +{ + return mir_strcmpi(p1->szSrcAcc, p2->szSrcAcc); } static int CompareAccByIds(const AccountMap *p1, const AccountMap *p2) -{ return p1->iOrder - p2->iOrder; +{ + return p1->iOrder - p2->iOrder; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -251,7 +253,7 @@ static LRESULT CALLBACK ListWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM SendMessage(hwndCombo, WM_KILLFOCUS, 0, (LPARAM)hwndCombo); hwndCombo = CreateWindowEx(WS_EX_CLIENTEDGE, WC_COMBOBOX, L"", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, - r.left + 3, r.top, r.right - r.left - 3, r.bottom - r.top, hwnd, nullptr, hInst, nullptr); + r.left + 3, r.top, r.right - r.left - 3, r.bottom - r.top, hwnd, nullptr, g_plugin.getInst(), nullptr); // copy a font from listview HFONT hFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0); @@ -461,7 +463,7 @@ bool ImportAccounts(OBJLIST &arSkippedModules) // all accounts to be converted automatically, no need to raise a dialog if (bNeedManualMerge) - if (DialogBox(hInst, MAKEINTRESOURCE(IDD_ACCMERGE), nullptr, AccountsMatcherProc) != IDOK) + if (DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ACCMERGE), nullptr, AccountsMatcherProc) != IDOK) return false; bool bImportSysAll = (nImportOptions & IOPT_SYS_SETTINGS) != 0; @@ -552,7 +554,7 @@ int ModulesEnumProc(const char *szModuleName, void *pParam) CopySettings(icd->from, szModuleName, icd->to, icd->szDstProto); } else CopySettings(icd->from, szModuleName, icd->to, szModuleName); - + return 0; } @@ -976,7 +978,7 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC nDupes++; continue; } - + // no need to display all these dialogs again if (dbei.eventType == EVENTTYPE_AUTHREQUEST || dbei.eventType == EVENTTYPE_ADDED) dbei.flags |= DBEF_READ; diff --git a/plugins/Import/src/main.cpp b/plugins/Import/src/main.cpp index 3e6a15fdfb..c3025c70bb 100644 --- a/plugins/Import/src/main.cpp +++ b/plugins/Import/src/main.cpp @@ -24,11 +24,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int nImportOptions; -HINSTANCE hInst; INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam); bool g_bServiceMode = false, g_bSendQuit = false; HWND hwndWizard, hwndAccMerge; +CMPlugin g_plugin; int hLangpack; PLUGININFOEX pluginInfo = @@ -45,12 +45,6 @@ PLUGININFOEX pluginInfo = {0x2d77a746, 0xa6, 0x4343, {0xbf, 0xc5, 0xf8, 0x8, 0xcd, 0xd7, 0x72, 0xea}} }; -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) -{ - hInst = hinstDLL; - return TRUE; -} - static INT_PTR ImportCommand(WPARAM, LPARAM) { if (IsWindow(hwndWizard)) { @@ -59,7 +53,7 @@ static INT_PTR ImportCommand(WPARAM, LPARAM) } else { WizardDlgParam param = { IDD_WIZARDINTRO, (LPARAM)WizardIntroPageProc }; - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, (LPARAM)¶m); + CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, (LPARAM)¶m); } return 0; @@ -121,14 +115,14 @@ static INT_PTR ServiceMode(WPARAM, LPARAM) wcsncpy_s(importFile, MAX_PATH, wszFullName, _TRUNCATE); WizardDlgParam param = { IDD_PROGRESS, (LPARAM)ProgressPageProc }; - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, LPARAM(¶m)); + DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, LPARAM(¶m)); return SERVICE_CONTINUE; } g_bSendQuit = true; WizardDlgParam param = { IDD_WIZARDINTRO, (LPARAM)WizardIntroPageProc }; - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, (LPARAM)¶m); + CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, (LPARAM)¶m); return SERVICE_ONLYDB; } @@ -139,7 +133,7 @@ static INT_PTR CustomImport(WPARAM wParam, LPARAM) nImportOptions = opts->dwFlags; WizardDlgParam param = { IDD_PROGRESS, (LPARAM)ProgressPageProc }; - return DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, LPARAM(¶m)); + return DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, LPARAM(¶m)); } extern "C" __declspec(dllexport) int Load(void) diff --git a/plugins/Import/src/stdafx.h b/plugins/Import/src/stdafx.h index 73d12fe83d..822cf6721e 100644 --- a/plugins/Import/src/stdafx.h +++ b/plugins/Import/src/stdafx.h @@ -30,8 +30,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#define __NO_CMPLUGIN_NEEDED - #include #include #include @@ -56,6 +54,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define IMPORT_MODULE "MIMImport" // Module name #define IMPORT_SERVICE "MIMImport/Import" // Service for menu item +struct CMPlugin : public PLUGIN +{ + CMPlugin() : + PLUGIN(IMPORT_MODULE) + {} +}; + // Keys #define IMP_KEY_FR "FirstRun" // First run @@ -86,7 +91,6 @@ bool IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei); int CreateGroup(const wchar_t *name, MCONTACT hContact); -extern HINSTANCE hInst; extern HWND hwndWizard, hwndAccMerge; extern int nImportOptions; extern wchar_t importFile[]; diff --git a/plugins/Import/src/utils.cpp b/plugins/Import/src/utils.cpp index ee85e71287..a96fafebd5 100644 --- a/plugins/Import/src/utils.cpp +++ b/plugins/Import/src/utils.cpp @@ -51,9 +51,9 @@ int CreateGroup(const wchar_t *group, MCONTACT hContact) static bool IsEqualEvent(const DBEVENTINFO &ev1, const DBEVENTINFO &ev2) { return (ev1.timestamp == ev2.timestamp && - ev1.eventType == ev2.eventType && - ev1.cbBlob == ev2.cbBlob && - (ev1.flags & DBEF_SENT) == (ev2.flags & DBEF_SENT)); + ev1.eventType == ev2.eventType && + ev1.cbBlob == ev2.cbBlob && + (ev1.flags & DBEF_SENT) == (ev2.flags & DBEF_SENT)); } // Returns TRUE if the event already exist in the database @@ -206,5 +206,5 @@ HANDLE GetIconHandle(int iIconId) void RegisterIcons() { - Icon_Register(hInst, "Import", iconList, _countof(iconList)); + Icon_Register(g_plugin.getInst(), "Import", iconList, _countof(iconList)); } diff --git a/plugins/Import/src/wizard.cpp b/plugins/Import/src/wizard.cpp index b264818be6..7849b9292d 100644 --- a/plugins/Import/src/wizard.cpp +++ b/plugins/Import/src/wizard.cpp @@ -64,7 +64,7 @@ INT_PTR CALLBACK FinishedPageProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM case IDCANCEL: if (IsDlgButtonChecked(hdlg, IDC_DONTLOADPLUGIN)) { char sModuleFileName[MAX_PATH]; - GetModuleFileNameA(hInst, sModuleFileName, sizeof(sModuleFileName)); + GetModuleFileNameA(g_plugin.getInst(), sModuleFileName, sizeof(sModuleFileName)); char *pszFileName = strrchr(sModuleFileName, '\\'); if (pszFileName == nullptr) pszFileName = sModuleFileName; @@ -112,7 +112,7 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lP EnableWindow(GetDlgItem(hdlg, IDOK), TRUE); EnableWindow(GetDlgItem(hdlg, IDCANCEL), TRUE); SetDlgItemText(hdlg, IDCANCEL, TranslateT("Cancel")); - hwndPage = CreateDialog(hInst, MAKEINTRESOURCE(wParam), hdlg, (DLGPROC)lParam); + hwndPage = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(wParam), hdlg, (DLGPROC)lParam); SetWindowPos(hwndPage, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE); ShowWindow(hwndPage, SW_SHOW); if (bFirstLaunch) -- cgit v1.2.3