diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-22 22:20:46 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-22 22:20:46 +0300 |
commit | 49959b6d4b0fa837e02ba03cc62bfb94dda517c0 (patch) | |
tree | 0018c7522b129a7c64f917d6ea1197bb688ebdae /plugins | |
parent | b97a2cf13002dd897e1021f4f5ae30006f87b269 (diff) |
Import - adaptation for batch import processing
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Import/src/main.cpp | 28 | ||||
-rw-r--r-- | plugins/Import/src/progress.cpp | 8 | ||||
-rw-r--r-- | plugins/Import/src/stdafx.h | 2 | ||||
-rw-r--r-- | plugins/Import/src/wizard.cpp | 3 |
4 files changed, 31 insertions, 10 deletions
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);
}
|