From be3185a374d39a8ee0f12a4e985ecca279633fff Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 28 Jul 2012 18:29:52 +0000 Subject: - MS_DB_CHECKPROFILE - service for checking databases - added menu item "Check" to a context menu in profile manager git-svn-id: http://svn.miranda-ng.org/main/trunk@1228 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/DbChecker/src/cleaning.cpp | 4 ++-- plugins/DbChecker/src/dbchecker.h | 2 +- plugins/DbChecker/src/fileaccess.cpp | 8 +++++--- plugins/DbChecker/src/main.cpp | 19 +++++++++++++------ plugins/DbChecker/src/openerror.cpp | 5 +++-- plugins/DbChecker/src/progress.cpp | 34 ++++++++++++++++++++++++++-------- plugins/DbChecker/src/selectdb.cpp | 12 ++++++++---- plugins/DbChecker/src/welcome.cpp | 2 +- plugins/DbChecker/src/wizard.cpp | 15 ++++++++++++--- 9 files changed, 71 insertions(+), 30 deletions(-) (limited to 'plugins/DbChecker') diff --git a/plugins/DbChecker/src/cleaning.cpp b/plugins/DbChecker/src/cleaning.cpp index bd8f296afb..b40bdb7244 100644 --- a/plugins/DbChecker/src/cleaning.cpp +++ b/plugins/DbChecker/src/cleaning.cpp @@ -43,9 +43,9 @@ INT_PTR CALLBACK CleaningDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM switch(LOWORD(wParam)) { case IDC_BACK: if (opts.bCheckOnly) - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc); else - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc); break; case IDOK: diff --git a/plugins/DbChecker/src/dbchecker.h b/plugins/DbChecker/src/dbchecker.h index 51a8466c7c..4039cab040 100644 --- a/plugins/DbChecker/src/dbchecker.h +++ b/plugins/DbChecker/src/dbchecker.h @@ -67,7 +67,7 @@ extern HINSTANCE hInst; extern DbToolOptions opts; extern HANDLE hEventRun, hEventAbort; extern int errorCount; -extern bool bServiceMode, bLaunchMiranda; +extern bool bServiceMode, bLaunchMiranda, bShortMode; int DoMyControlProcessing(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam, INT_PTR *bReturn); diff --git a/plugins/DbChecker/src/fileaccess.cpp b/plugins/DbChecker/src/fileaccess.cpp index ef19a1244f..b785d733d5 100644 --- a/plugins/DbChecker/src/fileaccess.cpp +++ b/plugins/DbChecker/src/fileaccess.cpp @@ -26,6 +26,8 @@ INT_PTR CALLBACK FileAccessDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARA switch(message) { case WM_INITDIALOG: + if (bShortMode) + EnableWindow(GetDlgItem(GetParent(hdlg), IDC_BACK), FALSE); CheckDlgButton(hdlg, IDC_CHECKONLY, opts.bCheckOnly); CheckDlgButton(hdlg, IDC_BACKUP, opts.bBackup); CheckDlgButton(hdlg, IDC_AGGRESSIVE, opts.bAggressive); @@ -43,14 +45,14 @@ INT_PTR CALLBACK FileAccessDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARA case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_BACK: - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc); break; case IDOK: if (opts.bCheckOnly) - OpenDatabase(hdlg, IDD_PROGRESS); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressDlgProc); else - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_CLEANING, (LPARAM)CleaningDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_CLEANING, (LPARAM)CleaningDlgProc); break; case IDC_CHECKONLY: diff --git a/plugins/DbChecker/src/main.cpp b/plugins/DbChecker/src/main.cpp index 4a98a5dd1d..a36f74f340 100644 --- a/plugins/DbChecker/src/main.cpp +++ b/plugins/DbChecker/src/main.cpp @@ -22,9 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. HINSTANCE hInst; int hLangpack = 0; -bool bServiceMode = false, bLaunchMiranda = false; - -static HANDLE hLaunchFunc; +bool bServiceMode, bLaunchMiranda, bShortMode; DbToolOptions opts = {0}; @@ -63,22 +61,31 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_SERVICE static INT_PTR ServiceMode(WPARAM, LPARAM) { - bLaunchMiranda = false; + bLaunchMiranda = bShortMode = false; bServiceMode = true; DialogBox(hInst, MAKEINTRESOURCE(IDD_WIZARD), NULL, WizardDlgProc); return (bLaunchMiranda) ? SERVICE_CONTINUE : SERVICE_FAILED; } +static INT_PTR CheckProfile(WPARAM wParam, LPARAM) +{ + bShortMode = true; + bLaunchMiranda = bServiceMode = false; + _tcsncpy(opts.filename, (TCHAR*)wParam, SIZEOF(opts.filename)); + DialogBox(hInst, MAKEINTRESOURCE(IDD_WIZARD), NULL, WizardDlgProc); + return 0; +} + extern "C" __declspec(dllexport) int Load(void) { mir_getLP(&pluginInfoEx); - hLaunchFunc = CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceMode); + CreateServiceFunction(MS_DB_CHECKPROFILE, CheckProfile); + CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceMode); return 0; } extern "C" __declspec(dllexport) int Unload(void) { - DestroyServiceFunction(hLaunchFunc); return 0; } diff --git a/plugins/DbChecker/src/openerror.cpp b/plugins/DbChecker/src/openerror.cpp index 0ae07ed2c4..5f8b769af6 100644 --- a/plugins/DbChecker/src/openerror.cpp +++ b/plugins/DbChecker/src/openerror.cpp @@ -21,8 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. INT_PTR CALLBACK OpenErrorDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { INT_PTR bReturn; + if ( DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn)) + return bReturn; - if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn)) return bReturn; switch(message) { case WM_INITDIALOG: { @@ -39,7 +40,7 @@ INT_PTR CALLBACK OpenErrorDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_BACK: - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc); break; case IDOK: diff --git a/plugins/DbChecker/src/progress.cpp b/plugins/DbChecker/src/progress.cpp index 4fe976f61f..f223066b1d 100644 --- a/plugins/DbChecker/src/progress.cpp +++ b/plugins/DbChecker/src/progress.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void __cdecl WorkerThread(void *unused); static HWND hwndStatus, hdlgProgress, hwndBar; +static bool bShortModeDone; HANDLE hEventRun = NULL, hEventAbort = NULL; int errorCount; @@ -74,6 +75,7 @@ INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM hdlgProgress = hdlg; hwndStatus = GetDlgItem(hdlg, IDC_STATUS); errorCount = 0; + bShortModeDone = false; hwndBar = GetDlgItem(hdlg, IDC_PROGRESS); SendMessage(hwndBar, PBM_SETRANGE, 0, MAKELPARAM(0, 1000)); { @@ -147,25 +149,41 @@ INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM case WM_PROCESSINGDONE: SetProgressBar(1000); - EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), TRUE); + if (bShortMode) { + EnableWindow(GetDlgItem(GetParent(hdlg), IDC_BACK), FALSE); + EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), FALSE); + SetDlgItemText(GetParent(hdlg), IDCANCEL, TranslateT("&Finish")); + bShortModeDone = true; + } + else { + AddToStatus(STATUS_SUCCESS, TranslateT("Click Next to continue")); + EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), TRUE); + } + if (manualAbort == 1) EndDialog(GetParent(hdlg), 0); else if (manualAbort == 2) { if (opts.bCheckOnly) - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc); else { - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_CLEANING, (LPARAM)CleaningDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_CLEANING, (LPARAM)CleaningDlgProc); CloseHandle(opts.hOutFile); opts.hOutFile = NULL; } break; } - AddToStatus(STATUS_SUCCESS, TranslateT("Click Next to continue")); break; case WZN_CANCELCLICKED: + if (bShortModeDone) { + EndDialog( GetParent(hdlg), 1); + return TRUE; + } + ResetEvent(hEventRun); - if (IsWindowEnabled(GetDlgItem(GetParent(hdlg), IDOK))) break; + if (IsWindowEnabled(GetDlgItem(GetParent(hdlg), IDOK))) + break; + if (MessageBox(hdlg, TranslateT("Processing has not yet completed, if you cancel now then the changes that have currently been made will be rolled back and the original database will be restored. Do you still want to cancel?"), TranslateT("Miranda Database Tool"), MB_YESNO) == IDYES) { manualAbort = 1; SetEvent(hEventAbort); @@ -188,12 +206,12 @@ INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM } SetEvent(hEventRun); if (opts.bCheckOnly) - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc); else - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_CLEANING, (LPARAM)CleaningDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_CLEANING, (LPARAM)CleaningDlgProc); break; case IDOK: - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FINISHED, (LPARAM)FinishedDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FINISHED, (LPARAM)FinishedDlgProc); break; } break; diff --git a/plugins/DbChecker/src/selectdb.cpp b/plugins/DbChecker/src/selectdb.cpp index a8b40af3d8..dbd7e8baaa 100644 --- a/plugins/DbChecker/src/selectdb.cpp +++ b/plugins/DbChecker/src/selectdb.cpp @@ -44,16 +44,16 @@ LBL_Error: opts.dbChecker = dblink->CheckDB(opts.filename, &error); if (opts.dbChecker == NULL) { opts.error = error; - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_OPENERROR, (LPARAM)OpenErrorDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_OPENERROR, (LPARAM)OpenErrorDlgProc); return; } opts.dblink = dblink; } if (iNextPage == IDD_FILEACCESS) - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc); else - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressDlgProc); } void GetProfileDirectory(TCHAR* szMirandaDir, TCHAR* szPath, int cbPath) @@ -237,6 +237,9 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM opts.dbChecker->Destroy(); opts.dbChecker = NULL; } + + if (bShortMode) + OpenDatabase(hdlg, IDD_FILEACCESS); return TRUE; case WZN_PAGECHANGING: @@ -286,7 +289,8 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM break; case IDC_BACK: - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_WELCOME, (LPARAM)WelcomeDlgProc); + if (!bShortMode) + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_WELCOME, (LPARAM)WelcomeDlgProc); break; case IDOK: diff --git a/plugins/DbChecker/src/welcome.cpp b/plugins/DbChecker/src/welcome.cpp index 99d7a3091a..214514715e 100644 --- a/plugins/DbChecker/src/welcome.cpp +++ b/plugins/DbChecker/src/welcome.cpp @@ -56,7 +56,7 @@ INT_PTR CALLBACK WelcomeDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM l case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: - SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc); + PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc); break; } break; diff --git a/plugins/DbChecker/src/wizard.cpp b/plugins/DbChecker/src/wizard.cpp index 7a49a06daf..bfc5c5774e 100644 --- a/plugins/DbChecker/src/wizard.cpp +++ b/plugins/DbChecker/src/wizard.cpp @@ -98,7 +98,10 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lP SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_DBTOOL))); hdlgPage = NULL; bLaunchMiranda = false; - SendMessage(hdlg, WZM_GOTOPAGE, IDD_WELCOME, (LPARAM)WelcomeDlgProc); + if (bShortMode) + SendMessage(hdlg, WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc); + else + SendMessage(hdlg, WZM_GOTOPAGE, IDD_WELCOME, (LPARAM)WelcomeDlgProc); TranslateDialogDefault(hdlg); return TRUE; @@ -138,8 +141,14 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lP CloseHandle(opts.hOutFile); DestroyWindow(hdlgPage); - if (hBoldFont != NULL) DeleteObject(hBoldFont); - if (hEmfHeaderLogo != NULL) DeleteEnhMetaFile(hEmfHeaderLogo); + if (hBoldFont != NULL) { + DeleteObject(hBoldFont); + hBoldFont = NULL; + } + if (hEmfHeaderLogo != NULL) { + DeleteEnhMetaFile(hEmfHeaderLogo); + hEmfHeaderLogo = NULL; + } break; } return FALSE; -- cgit v1.2.3