From 49959b6d4b0fa837e02ba03cc62bfb94dda517c0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 22 Mar 2018 22:20:46 +0300 Subject: Import - adaptation for batch import processing --- plugins/Import/src/main.cpp | 28 ++++++++++++++++++++++------ plugins/Import/src/progress.cpp | 8 ++++++-- plugins/Import/src/stdafx.h | 2 +- plugins/Import/src/wizard.cpp | 3 ++- 4 files changed, 31 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/Import/src/main.cpp b/plugins/Import/src/main.cpp index 61d6da6cce..d6c7389699 100644 --- a/plugins/Import/src/main.cpp +++ b/plugins/Import/src/main.cpp @@ -27,7 +27,7 @@ int nImportOptions; HINSTANCE hInst; INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam); -bool g_bServiceMode = false; +bool g_bServiceMode = false, g_bSendQuit = false; HWND hwndWizard, hwndAccMerge; int hLangpack; @@ -76,7 +76,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) ///////////////////////////////////////////////////////////////////////////////////////// // MirandaInterfaces - returns the protocol interface to the core -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_IMPORT, MIID_DATABASE, MIID_SERVICEMODE, MIID_LAST }; +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_IMPORT, MIID_SERVICEMODE, MIID_LAST }; ///////////////////////////////////////////////////////////////////////////////////////// // Performs a primary set of actions upon plugin loading @@ -108,11 +108,27 @@ static int OnExit(WPARAM, LPARAM) static INT_PTR ServiceMode(WPARAM, LPARAM) { - g_bServiceMode = true; + if (!g_bServiceMode) { + g_bServiceMode = true; + return SERVICE_ONLYDB; + } + + ptrW wszFullName(Utils_ReplaceVarsW(L"%miranda_userdata%\\%miranda_profilename%.dat.bak")); + if (!_waccess(wszFullName, 0)) { + nImportOptions = IOPT_ADDUNKNOWN + IOPT_COMPLETE; + wcsncpy_s(importFile, MAX_PATH, wszFullName, _TRUNCATE); + + WizardDlgParam param = { IDD_PROGRESS, (LPARAM)ProgressPageProc }; + DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, LPARAM(¶m)); + } + else { + g_bSendQuit = true; + + WizardDlgParam param = { IDD_WIZARDINTRO, (LPARAM)WizardIntroPageProc }; + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, (LPARAM)¶m); + } - WizardDlgParam param = { IDD_WIZARDINTRO, (LPARAM)WizardIntroPageProc }; - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, (LPARAM)¶m); - return SERVICE_ONLYDB; + return SERVICE_CONTINUE; } static INT_PTR CustomImport(WPARAM wParam, LPARAM) diff --git a/plugins/Import/src/progress.cpp b/plugins/Import/src/progress.cpp index 6fa32e8701..26708529c4 100644 --- a/plugins/Import/src/progress.cpp +++ b/plugins/Import/src/progress.cpp @@ -51,8 +51,12 @@ INT_PTR CALLBACK ProgressPageProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM case PROGM_START: MirandaImport(hdlg); - SendMessage(GetParent(hdlg), WIZM_ENABLEBUTTON, 1, 0); - SendMessage(GetParent(hdlg), WIZM_ENABLEBUTTON, 2, 0); + if (g_bServiceMode && !g_bSendQuit) + DestroyWindow(hwndWizard); + else { + SendMessage(GetParent(hdlg), WIZM_ENABLEBUTTON, 1, 0); + SendMessage(GetParent(hdlg), WIZM_ENABLEBUTTON, 2, 0); + } break; case WM_COMMAND: diff --git a/plugins/Import/src/stdafx.h b/plugins/Import/src/stdafx.h index 21007d9136..36e5156142 100644 --- a/plugins/Import/src/stdafx.h +++ b/plugins/Import/src/stdafx.h @@ -89,7 +89,7 @@ extern HWND hwndWizard, hwndAccMerge; extern int nImportOptions; extern wchar_t importFile[]; extern time_t dwSinceDate; -extern bool g_bServiceMode; +extern bool g_bServiceMode, g_bSendQuit; HANDLE GetIconHandle(int iIconId); void RegisterIcons(void); diff --git a/plugins/Import/src/wizard.cpp b/plugins/Import/src/wizard.cpp index 1decf1d74f..4f54560ddc 100644 --- a/plugins/Import/src/wizard.cpp +++ b/plugins/Import/src/wizard.cpp @@ -163,8 +163,9 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lP DestroyWindow(hwndPage); DestroyWindow(hdlg); break; + case WM_DESTROY: - if (g_bServiceMode) + if (g_bSendQuit) PostQuitMessage(0); } -- cgit v1.2.3