summaryrefslogtreecommitdiff
path: root/plugins/DbChecker
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-01-17 22:40:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-01-17 22:40:11 +0300
commit13f77569325efda3683e5ac0f63dcd418daf1cac (patch)
tree01ae75890c14f22bb75fea473ea592cc1942f1f1 /plugins/DbChecker
parente5e57900ba47ffe47c0bd284e3eb039a85db970a (diff)
fixes #2691 (DbChecker: add "Mark all events as read" option)
Diffstat (limited to 'plugins/DbChecker')
-rw-r--r--plugins/DbChecker/dbchecker.vcxproj4
-rw-r--r--plugins/DbChecker/dbchecker.vcxproj.filters8
-rw-r--r--plugins/DbChecker/res/resource.rc85
-rw-r--r--plugins/DbChecker/src/main.cpp8
-rw-r--r--plugins/DbChecker/src/openerror.cpp82
-rw-r--r--plugins/DbChecker/src/options.cpp92
-rw-r--r--plugins/DbChecker/src/progress.cpp163
-rw-r--r--plugins/DbChecker/src/resource.h18
-rw-r--r--plugins/DbChecker/src/stdafx.h115
-rw-r--r--plugins/DbChecker/src/version.h2
-rw-r--r--plugins/DbChecker/src/wizard.cpp239
-rw-r--r--plugins/DbChecker/src/worker.cpp21
12 files changed, 580 insertions, 257 deletions
diff --git a/plugins/DbChecker/dbchecker.vcxproj b/plugins/DbChecker/dbchecker.vcxproj
index 71f8179d96..00ac8e13d3 100644
--- a/plugins/DbChecker/dbchecker.vcxproj
+++ b/plugins/DbChecker/dbchecker.vcxproj
@@ -21,6 +21,7 @@
<ItemGroup>
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\openerror.cpp" />
+ <ClCompile Include="src\options.cpp" />
<ClCompile Include="src\progress.cpp" />
<ClCompile Include="src\stdafx.cxx">
<PrecompiledHeader>Create</PrecompiledHeader>
@@ -37,6 +38,9 @@
<ClInclude Include="src\stdafx.h" />
<ClInclude Include="src\version.h" />
</ItemGroup>
+ <ItemGroup>
+ <Image Include="res\dbtool.ico" />
+ </ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>DbChecker</ProjectName>
<ProjectGuid>{A2E9DA24-95E4-4414-94AF-488A382E276A}</ProjectGuid>
diff --git a/plugins/DbChecker/dbchecker.vcxproj.filters b/plugins/DbChecker/dbchecker.vcxproj.filters
index 1b59a81264..acb8e16265 100644
--- a/plugins/DbChecker/dbchecker.vcxproj.filters
+++ b/plugins/DbChecker/dbchecker.vcxproj.filters
@@ -20,6 +20,9 @@
<ClCompile Include="src\stdafx.cxx">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\options.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\resource.rc">
@@ -40,4 +43,9 @@
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
+ <ItemGroup>
+ <Image Include="res\dbtool.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/plugins/DbChecker/res/resource.rc b/plugins/DbChecker/res/resource.rc
index 23c21db6f4..e405434f7b 100644
--- a/plugins/DbChecker/res/resource.rc
+++ b/plugins/DbChecker/res/resource.rc
@@ -8,7 +8,6 @@
// Generated from the TEXTINCLUDE 2 resource.
//
#include <winres.h>
-
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
@@ -16,10 +15,8 @@
// Neutral resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
-#ifdef _WIN32
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(1252)
-#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
@@ -27,14 +24,29 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
//
IDD_WIZARD DIALOGEX 0, 0, 262, 174
-STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
+STYLE DS_SETFONT | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_CONTROLPARENT
CAPTION "Miranda Database Tool"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "&Next >",IDOK,146,153,50,14
PUSHBUTTON "Cancel",IDCANCEL,205,153,50,14
- CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-5,143,269,1
+ CONTROL "",IDC_SPLITTER,"Static",SS_ETCHEDHORZ,-5,143,269,1
+END
+
+IDD_OPTPAGE DIALOGEX 0, 0, 262, 143
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ LTEXT "whiterect",IDC_STATIC,0,0,262,32
+ LTEXT "Checker's options",IDC_STATIC,11,6,206,8,WS_BORDER
+ LTEXT "Customize settings and proceed to the checking.",IDC_STATIC,20,14,197,16
+ CONTROL "",IDC_SPLITTER,"Static",SS_ETCHEDHORZ,-1,32,264,1
+ LTEXT "File name:",IDC_STATIC,6,39,252,8
+ EDITTEXT IDC_FILENAME,6,50,235,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_OPENFILE,243,49,15,13
+ CONTROL "Mark all events as read",IDC_MARKREAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,69,248,10
END
IDD_OPENERROR DIALOGEX 0, 0, 262, 143
@@ -44,9 +56,8 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
LTEXT "whiterect",IDC_STATIC,0,0,262,32
LTEXT "Error Opening Database",IDC_STATIC,11,6,206,8,WS_BORDER
- CONTROL "",IDC_HDRLOGO,"Static",SS_ENHMETAFILE,234,3,25,25
LTEXT "There was an error opening the profile database given.",IDC_STATIC,20,14,197,16
- CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-1,32,264,1
+ CONTROL "",IDC_SPLITTER,"Static",SS_ETCHEDHORZ,-1,32,264,1
LTEXT "",IDC_ERRORTEXT,23,38,226,16,SS_NOPREFIX | WS_BORDER
LTEXT "Click Next to try opening the file again, or click Back to select a new profile database to manipulate.",IDC_STATIC,23,67,226,16
LTEXT "The file may be in use by a currently running copy of Miranda. Exit any running Mirandas and click Next to retry.",IDC_INUSE,23,87,226,16,NOT WS_VISIBLE
@@ -58,11 +69,10 @@ STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- LTEXT "whiterect",-1,0,0,262,32
- LTEXT "Working...",-1,11,6,206,8,WS_BORDER
- CONTROL "",IDC_HDRLOGO,"Static",SS_ENHMETAFILE,234,3,25,25
- LTEXT "Please wait while the requested operations are being performed.",-1,20,14,197,16
- CONTROL "",-1,"Static",SS_ETCHEDHORZ,-1,32,264,1
+ LTEXT "whiterect",IDC_STATIC,0,0,262,32
+ LTEXT "Working...",IDC_STATIC,11,6,206,8,WS_BORDER
+ LTEXT "Please wait while the requested operations are being performed.",IDC_STATIC,20,14,197,16
+ CONTROL "",IDC_SPLITTER,"Static",SS_ETCHEDHORZ,-1,32,264,1
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | WS_BORDER,20,38,222,11
LISTBOX IDC_STATUS,20,52,222,84,NOT LBS_NOTIFY | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL | WS_TABSTOP
END
@@ -84,6 +94,10 @@ BEGIN
BOTTOMMARGIN, 167
END
+ IDD_OPTPAGE, DIALOG
+ BEGIN
+ END
+
IDD_OPENERROR, DIALOG
BEGIN
LEFTMARGIN, 23
@@ -112,10 +126,56 @@ END
// remains consistent on all systems.
IDI_DBTOOL ICON "dbtool.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_OPTPAGE AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // Neutral resources
/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+// English (United States) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "..\\src\\resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include <winres.h>\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
@@ -126,3 +186,4 @@ IDI_DBTOOL ICON "dbtool.ico"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/DbChecker/src/main.cpp b/plugins/DbChecker/src/main.cpp
index 25214e05e9..4f8d43dcd8 100644
--- a/plugins/DbChecker/src/main.cpp
+++ b/plugins/DbChecker/src/main.cpp
@@ -38,7 +38,7 @@ PLUGININFOEX pluginInfoEx =
};
CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>(nullptr, pluginInfoEx)
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
{
}
@@ -49,8 +49,6 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SERVIC
/////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(DATABASELINK *) Profile_GetLink();
-
static HANDLE hService; // do not remove it!
static INT_PTR ServiceMode(WPARAM, LPARAM)
@@ -64,7 +62,7 @@ static INT_PTR ServiceMode(WPARAM, LPARAM)
}
wcsncpy_s(opts->filename, VARSW(L"%miranda_userdata%\\%miranda_profilename%.dat"), _TRUNCATE);
- DialogBoxParamW(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, LPARAM(opts));
+ CWizardDlg(opts).DoModal();
return SERVICE_FAILED;
}
@@ -88,7 +86,7 @@ static INT_PTR CheckProfile(WPARAM wParam, LPARAM lParam)
wcsncpy_s(opts->filename, VARSW(L"%miranda_userdata%\\%miranda_profilename%.dat"), _TRUNCATE);
}
- return DialogBoxParamW(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc, LPARAM(opts));
+ return CWizardDlg(opts).DoModal();
}
static int OnModulesLoaded(WPARAM, LPARAM)
diff --git a/plugins/DbChecker/src/openerror.cpp b/plugins/DbChecker/src/openerror.cpp
index 54e13398d3..fa0c005f71 100644
--- a/plugins/DbChecker/src/openerror.cpp
+++ b/plugins/DbChecker/src/openerror.cpp
@@ -19,71 +19,39 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
-INT_PTR CALLBACK OpenErrorDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+COpenErrorDlg::COpenErrorDlg() :
+ CSuper(IDD_OPENERROR)
{
- INT_PTR bReturn;
- if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
- return bReturn;
+}
- switch (message) {
- case WM_INITDIALOG:
- {
- auto *opts = (DbToolOptions *)lParam;
+bool COpenErrorDlg::OnInitDialog()
+{
+ CSuper::OnInitDialog();
- wchar_t szError[256];
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, opts->error, 0, szError, _countof(szError), nullptr);
- SetDlgItemText(hdlg, IDC_ERRORTEXT, szError);
+ auto *opts = getOpts();
- if (opts->error == ERROR_SHARING_VIOLATION)
- ShowWindow(GetDlgItem(hdlg, IDC_INUSE), SW_SHOW);
- SetWindowLongPtr(GetDlgItem(hdlg, IDC_FILE), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hdlg, IDC_FILE), GWL_STYLE) | SS_PATHELLIPSIS);
- TranslateDialogDefault(hdlg);
- SetDlgItemText(hdlg, IDC_FILE, opts->filename);
- }
- return TRUE;
+ wchar_t szError[256];
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, opts->error, 0, szError, _countof(szError), nullptr);
+ SetDlgItemText(m_hwnd, IDC_ERRORTEXT, szError);
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDOK:
- OpenDatabase(GetParent(hdlg));
- break;
- }
- break;
- }
- return FALSE;
+ if (opts->error == ERROR_SHARING_VIOLATION)
+ ShowWindow(GetDlgItem(m_hwnd, IDC_INUSE), SW_SHOW);
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_FILE), GWL_STYLE, GetWindowLongPtr(GetDlgItem(m_hwnd, IDC_FILE), GWL_STYLE) | SS_PATHELLIPSIS);
+ SetDlgItemText(m_hwnd, IDC_FILE, opts->filename);
+ return true;
}
-int OpenDatabase(HWND hdlg)
+int COpenErrorDlg::Resizer(UTILRESIZECONTROL *urc)
{
- auto *opts = (DbToolOptions *)GetWindowLongPtr(hdlg, GWLP_USERDATA);
- wchar_t tszMsg[1024];
-
- if (opts->dbChecker == nullptr) {
- DATABASELINK *dblink = FindDatabasePlugin(opts->filename);
- if (dblink == nullptr) {
- mir_snwprintf(tszMsg,
- TranslateT("Database Checker cannot find a suitable database plugin to open '%s'."),
- opts->filename);
- LBL_Error:
- MessageBox(hdlg, tszMsg, TranslateT("Error"), MB_OK | MB_ICONERROR);
- return false;
- }
-
- auto *pDb = dblink->Load(opts->filename, false);
- if (pDb == nullptr) {
- PostMessage(hdlg, WZM_GOTOPAGE, IDD_OPENERROR, (LPARAM)OpenErrorDlgProc);
- return true;
- }
+ switch (urc->wId) {
+ case IDC_SPLITTER:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+ }
- opts->dbChecker = pDb->GetChecker();
- if (opts->dbChecker == nullptr) {
- mir_snwprintf(tszMsg, TranslateT("Database driver '%s' doesn't support checking."), TranslateW(dblink->szFullName));
- goto LBL_Error;
- }
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
+}
- opts->db = pDb;
- }
-
- PostMessage(hdlg, WZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressDlgProc);
- return true;
+void COpenErrorDlg::OnNext()
+{
+ changePage(new COptionsPageDlg());
}
diff --git a/plugins/DbChecker/src/options.cpp b/plugins/DbChecker/src/options.cpp
new file mode 100644
index 0000000000..a06a39d1f3
--- /dev/null
+++ b/plugins/DbChecker/src/options.cpp
@@ -0,0 +1,92 @@
+/*
+Copyright (C) 2012-18 Miranda NG team (https://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+
+COptionsPageDlg::COptionsPageDlg() :
+ CSuper(IDD_OPTPAGE),
+ edtFile(this, IDC_FILENAME),
+ btnFile(this, IDC_OPENFILE),
+ chkMarkRead(this, IDC_MARKREAD)
+{
+}
+
+bool COptionsPageDlg::OnInitDialog()
+{
+ CSuper::OnInitDialog();
+
+ auto *opts = getOpts();
+ edtFile.SetText(opts->filename);
+
+ chkMarkRead.SetState(opts->bMarkRead);
+
+ if (opts->dbChecker != nullptr) {
+ edtFile.Disable();
+ btnFile.Disable();
+ }
+ return true;
+}
+
+int COptionsPageDlg::Resizer(UTILRESIZECONTROL *urc)
+{
+ switch (urc->wId) {
+ case IDC_FILENAME:
+ case IDC_MARKREAD:
+ case IDC_SPLITTER:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+
+ case IDC_OPENFILE:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_TOP;
+ }
+
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
+}
+
+void COptionsPageDlg::OnNext()
+{
+ wchar_t tszMsg[1024];
+
+ auto *opts = getOpts();
+ if (opts->dbChecker == nullptr) {
+ DATABASELINK *dblink = FindDatabasePlugin(opts->filename);
+ if (dblink == nullptr) {
+ mir_snwprintf(tszMsg,
+ TranslateT("Database Checker cannot find a suitable database plugin to open '%s'."),
+ opts->filename);
+LBL_Error:
+ MessageBox(m_hwnd, tszMsg, TranslateT("Error"), MB_OK | MB_ICONERROR);
+ return;
+ }
+
+ auto *pDb = dblink->Load(opts->filename, false);
+ if (pDb == nullptr) {
+ changePage(new COpenErrorDlg());
+ return;
+ }
+
+ opts->dbChecker = pDb->GetChecker();
+ if (opts->dbChecker == nullptr) {
+ mir_snwprintf(tszMsg, TranslateT("Database driver '%s' doesn't support checking."), TranslateW(dblink->szFullName));
+ goto LBL_Error;
+ }
+
+ opts->db = pDb;
+ }
+
+ opts->bMarkRead = chkMarkRead.GetState();
+ changePage(new CProgressPageDlg());
+}
diff --git a/plugins/DbChecker/src/progress.cpp b/plugins/DbChecker/src/progress.cpp
index 55f55b3a43..b3458cadc9 100644
--- a/plugins/DbChecker/src/progress.cpp
+++ b/plugins/DbChecker/src/progress.cpp
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void __cdecl WorkerThread(DbToolOptions *opts);
static HWND hwndStatus, hdlgProgress, hwndBar;
int errorCount;
-LRESULT wizardResult;
+extern HFONT hBoldFont;
void AddToStatus(int flags, const wchar_t* fmt, ...)
{
@@ -60,54 +60,76 @@ void ProcessingDone(void)
SendMessage(hdlgProgress, WM_PROCESSINGDONE, 0, 0);
}
-INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+// CProgressDlg implementation
+
+CProgressPageDlg::CProgressPageDlg() :
+ CSuper(IDD_PROGRESS)
{
- static int fontHeight, listWidth;
- static int manualAbort;
- static HFONT hBoldFont = nullptr;
-
- INT_PTR bReturn;
- if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
- return bReturn;
-
- auto *opts = (DbToolOptions *)GetWindowLongPtrW(hdlg, GWLP_USERDATA);
-
- switch (message) {
- case WM_INITDIALOG:
- opts = (DbToolOptions *)lParam;
- SetWindowLongPtrW(hdlg, GWLP_USERDATA, lParam);
-
- EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), FALSE);
- hdlgProgress = hdlg;
- hwndStatus = GetDlgItem(hdlg, IDC_STATUS);
- errorCount = 0;
- hwndBar = GetDlgItem(hdlg, IDC_PROGRESS);
- SendMessage(hwndBar, PBM_SETRANGE, 0, MAKELPARAM(0, 1000));
- {
- HDC hdc = GetDC(nullptr);
- HFONT hFont = (HFONT)SendMessage(hdlg, WM_GETFONT, 0, 0);
- HFONT hoFont = (HFONT)SelectObject(hdc, hFont);
-
- SIZE s;
- GetTextExtentPoint32(hdc, L"x", 1, &s);
- SelectObject(hdc, hoFont);
- ReleaseDC(nullptr, hdc);
- fontHeight = s.cy;
-
- RECT rc;
- GetClientRect(GetDlgItem(hdlg, IDC_STATUS), &rc);
- listWidth = rc.right;
-
- LOGFONT lf;
- GetObject((HFONT)SendDlgItemMessage(hdlg, IDC_STATUS, WM_GETFONT, 0, 0), sizeof(lf), &lf);
- lf.lfWeight = FW_BOLD;
- hBoldFont = CreateFontIndirect(&lf);
- }
- manualAbort = 0;
- TranslateDialogDefault(hdlg);
- mir_forkThread<DbToolOptions>(WorkerThread, opts);
- return TRUE;
+}
+
+bool CProgressPageDlg::OnInitDialog()
+{
+ CSuper::OnInitDialog();
+
+ EnableWindow(GetDlgItem(m_hwndParent, IDOK), FALSE);
+ hdlgProgress = m_hwnd;
+ hwndStatus = GetDlgItem(m_hwnd, IDC_STATUS);
+ errorCount = 0;
+ hwndBar = GetDlgItem(m_hwnd, IDC_PROGRESS);
+ SendMessage(hwndBar, PBM_SETRANGE, 0, MAKELPARAM(0, 1000));
+ {
+ HDC hdc = GetDC(nullptr);
+ HFONT hFont = (HFONT)SendMessage(m_hwnd, WM_GETFONT, 0, 0);
+ HFONT hoFont = (HFONT)SelectObject(hdc, hFont);
+
+ SIZE s;
+ GetTextExtentPoint32(hdc, L"x", 1, &s);
+ SelectObject(hdc, hoFont);
+ ReleaseDC(nullptr, hdc);
+ fontHeight = s.cy;
+
+ RECT rc;
+ GetClientRect(GetDlgItem(m_hwnd, IDC_STATUS), &rc);
+ listWidth = rc.right;
+
+ LOGFONT lf;
+ GetObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_STATUS, WM_GETFONT, 0, 0), sizeof(lf), &lf);
+ lf.lfWeight = FW_BOLD;
+ hBoldFont = CreateFontIndirect(&lf);
+ }
+ manualAbort = 0;
+ TranslateDialogDefault(m_hwnd);
+ mir_forkThread<DbToolOptions>(WorkerThread, getOpts());
+ return true;
+}
+void CProgressPageDlg::OnDestroy()
+{
+ if (hBoldFont) {
+ DeleteObject(hBoldFont);
+ hBoldFont = nullptr;
+ }
+}
+
+int CProgressPageDlg::Resizer(UTILRESIZECONTROL *urc)
+{
+ switch (urc->wId) {
+ case IDC_STATUS:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+ }
+
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+}
+
+void CProgressPageDlg::OnNext()
+{
+ EndDialog(m_hwndParent, 1);
+}
+
+INT_PTR CProgressPageDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
case WM_MEASUREITEM:
{
LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam;
@@ -153,16 +175,16 @@ INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM
case WM_PROCESSINGDONE:
SetProgressBar(1000);
- if (opts->bAutoExit)
- PostMessage(GetParent(hdlg), WM_COMMAND, IDCANCEL, 0);
+ if (getOpts()->bAutoExit)
+ PostMessage(GetParent(m_hwnd), WM_COMMAND, IDCANCEL, 0);
- SetDlgItemText(GetParent(hdlg), IDCANCEL, TranslateT("&Finish"));
+ SetDlgItemText(GetParent(m_hwnd), IDCANCEL, TranslateT("&Finish"));
AddToStatus(STATUS_SUCCESS, TranslateT("Click Finish to continue"));
if (manualAbort == 1)
- EndDialog(GetParent(hdlg), 0);
+ EndDialog(GetParent(m_hwnd), 0);
else if (manualAbort == 2) {
- PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressDlgProc);
+ changePage(new CProgressPageDlg());
break;
}
break;
@@ -178,32 +200,21 @@ INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM
break;
case WZN_CANCELCLICKED:
- ResetEvent(opts->hEventRun);
- if (opts->bFinished)
- break;
+ {
+ auto *opts = getOpts();
+ ResetEvent(opts->hEventRun);
+ if (getOpts()->bFinished)
+ 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(opts->hEventAbort);
+ if (MessageBox(m_hwnd, 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(opts->hEventAbort);
+ }
+ SetEvent(opts->hEventRun);
}
- SetEvent(opts->hEventRun);
- SetWindowLongPtr(hdlg, DWLP_MSGRESULT, TRUE);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
return TRUE;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDOK:
- EndDialog(GetParent(hdlg), 1);
- break;
- }
- break;
-
- case WM_DESTROY:
- if (hBoldFont) {
- DeleteObject(hBoldFont);
- hBoldFont = nullptr;
- }
- break;
}
- return FALSE;
+
+ return CSuper::DlgProc(msg, wParam, lParam);
}
diff --git a/plugins/DbChecker/src/resource.h b/plugins/DbChecker/src/resource.h
index 1695ebd6dd..bc00166ba9 100644
--- a/plugins/DbChecker/src/resource.h
+++ b/plugins/DbChecker/src/resource.h
@@ -1,32 +1,32 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by resource.rc
+// Used by w:\miranda-ng\plugins\DbChecker\res\resource.rc
//
-
#define IDD_WIZARD 101
#define IDE_WATERMARK 102
#define IDI_DBTOOL 102
#define IDE_HDRLOGO 103
-#define IDD_WELCOME 106
-#define IDD_OPENERROR 108
-#define IDD_PROGRESS 111
+#define IDD_OPTPAGE 104
+#define IDD_OPENERROR 105
+#define IDD_PROGRESS 106
#define IDC_WATERMARK 1000
#define IDC_TITLE 1001
#define IDC_HDRLOGO 1002
+#define IDC_SPLITTER 1003
#define IDC_FILE 1004
#define IDC_ERRORTEXT 1006
#define IDC_INUSE 1007
#define IDC_PROGRESS 1011
#define IDC_STATUS 1012
-#define IDC_BACKUPFILE 1017
-#define IDC_CHECK1 1018
-#define IDC_STATIC -1
+#define IDC_MARKREAD 1013
+#define IDC_FILENAME 1014
+#define IDC_OPENFILE 1015
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_RESOURCE_VALUE 107
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1019
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/plugins/DbChecker/src/stdafx.h b/plugins/DbChecker/src/stdafx.h
index e912983a10..c08189312e 100644
--- a/plugins/DbChecker/src/stdafx.h
+++ b/plugins/DbChecker/src/stdafx.h
@@ -32,13 +32,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_database.h>
#include <m_db_int.h>
#include <m_genmenu.h>
+#include <m_gui.h>
+#include <m_icolib.h>
#include <m_langpack.h>
#include <win2k.h>
#include "resource.h"
#include "version.h"
-#define WZM_GOTOPAGE (WM_USER+1)
+#define MODULENAME "DbChecker"
+
#define WZN_PAGECHANGING (WM_USER+1221)
#define WZN_CANCELCLICKED (WM_USER+1222)
@@ -62,7 +65,7 @@ struct DbToolOptions : public MZeroedObject
MIDatabaseChecker *dbChecker;
DWORD error;
HANDLE hEventRun, hEventAbort;
- bool bFinished, bAutoExit, bOwnsDb;
+ bool bFinished, bAutoExit, bOwnsDb, bMarkRead;
wchar_t filename[MAX_PATH];
};
@@ -75,17 +78,107 @@ struct CMPlugin : public PLUGIN<CMPlugin>
};
extern int errorCount;
-extern LRESULT wizardResult;
-
-int DoMyControlProcessing(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam, INT_PTR *bReturn);
-
-INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK OpenErrorDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
-
-int OpenDatabase(HWND hdlg);
#define STATUS_CLASSMASK 0x0f
void AddToStatus(int flags, const wchar_t* fmt, ...);
void SetProgressBar(int perThou);
+/////////////////////////////////////////////////////////////////////////////////////////
+// UI classes
+
+class CWizardPageDlg : public CDlgBase
+{
+ typedef CDlgBase CSuper;
+
+ CCtrlButton btnOk, btnCancel;
+
+protected:
+ virtual void OnNext() PURE;
+ virtual void OnCancel();
+
+ DbToolOptions* getOpts() const;
+ void changePage(CWizardPageDlg *);
+
+public:
+ CWizardPageDlg(int dlgId);
+
+ bool OnInitDialog() override;
+
+ void onClick_Ok(CCtrlButton*) { OnNext(); }
+ void onClick_Cancel(CCtrlButton*) { OnCancel(); }
+};
+
+class COptionsPageDlg : public CWizardPageDlg
+{
+ typedef CWizardPageDlg CSuper;
+
+ CCtrlEdit edtFile;
+ CCtrlButton btnFile;
+ CCtrlCheck chkMarkRead;
+
+public:
+ COptionsPageDlg();
+
+ bool OnInitDialog() override;
+
+ int Resizer(UTILRESIZECONTROL *urc) override;
+
+ void OnNext() override;
+};
+
+class CProgressPageDlg : public CWizardPageDlg
+{
+ typedef CWizardPageDlg CSuper;
+
+ int fontHeight, listWidth;
+ int manualAbort;
+
+public:
+ CProgressPageDlg();
+
+ bool OnInitDialog() override;
+ void OnDestroy() override;
+
+ int Resizer(UTILRESIZECONTROL *urc) override;
+ INT_PTR DlgProc(UINT, WPARAM, LPARAM) override;
+
+ void OnNext() override;
+};
+
+class COpenErrorDlg : public CWizardPageDlg
+{
+ typedef CWizardPageDlg CSuper;
+
+public:
+ COpenErrorDlg();
+
+ bool OnInitDialog() override;
+ int Resizer(UTILRESIZECONTROL *urc) override;
+
+ void OnNext() override;
+};
+
+class CWizardDlg : public CDlgBase
+{
+ HWND hwndPage = nullptr;
+ int m_splitterX, m_splitterY;
+ DbToolOptions *m_opts;
+
+ CTimer timerStart;
+ CCtrlButton btnCancel;
+
+ LRESULT ChangePage(CWizardPageDlg *pPage);
+
+public:
+ CWizardDlg(DbToolOptions *opts);
+
+ bool OnInitDialog() override;
+ bool OnApply() override;
+ void OnDestroy() override;
+
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+ int Resizer(UTILRESIZECONTROL *urc) override;
+
+ void onClick_Cancel(CCtrlButton *);
+ void onTimer(CTimer *);
+};
diff --git a/plugins/DbChecker/src/version.h b/plugins/DbChecker/src/version.h
index ef6d141d15..7a7ee99aa9 100644
--- a/plugins/DbChecker/src/version.h
+++ b/plugins/DbChecker/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 95
#define __RELEASE_NUM 13
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
diff --git a/plugins/DbChecker/src/wizard.cpp b/plugins/DbChecker/src/wizard.cpp
index a1b2b65645..370b3935a1 100644
--- a/plugins/DbChecker/src/wizard.cpp
+++ b/plugins/DbChecker/src/wizard.cpp
@@ -21,8 +21,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
-static HFONT hBoldFont = nullptr;
-static HENHMETAFILE hEmfHeaderLogo = nullptr;
+#define WZM_GETOPTS (WM_USER+1)
+#define WZM_GOTOPAGE (WM_USER+2)
+
+HFONT hBoldFont = nullptr;
static BOOL CALLBACK MyControlsEnumChildren(HWND hwnd, LPARAM)
{
@@ -33,8 +35,12 @@ static BOOL CALLBACK MyControlsEnumChildren(HWND hwnd, LPARAM)
GetClassNameA(hwnd, szClass, sizeof(szClass));
if (!mir_strcmp(szClass, "Static")) {
- if (((style & SS_TYPEMASK) == SS_LEFT || (style & SS_TYPEMASK) == SS_CENTER || (style & SS_TYPEMASK) == SS_RIGHT) && exstyle & WS_EX_CLIENTEDGE)
- makeBold = 1;
+ if (exstyle & WS_EX_CLIENTEDGE) {
+ switch (style & SS_TYPEMASK) {
+ case SS_LEFT: case SS_CENTER: case SS_RIGHT:
+ makeBold = 1;
+ }
+ }
}
else if (!mir_strcmp(szClass, "Button")) {
if (exstyle & WS_EX_CLIENTEDGE)
@@ -55,98 +61,159 @@ static BOOL CALLBACK MyControlsEnumChildren(HWND hwnd, LPARAM)
return TRUE;
}
-int DoMyControlProcessing(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam, INT_PTR *bReturn)
+/////////////////////////////////////////////////////////////////////////////////////////
+// Basic wizard dialog class
+
+CWizardPageDlg::CWizardPageDlg(int iDlgId) :
+ CSuper(g_plugin, iDlgId),
+ btnOk(this, IDOK),
+ btnCancel(this, IDCANCEL)
{
- switch (message) {
- case WM_INITDIALOG:
- EnumChildWindows(hdlg, MyControlsEnumChildren, 0);
- if (hEmfHeaderLogo == nullptr) {
- HRSRC hRsrc = FindResourceA(g_plugin.getInst(), MAKEINTRESOURCEA(IDE_HDRLOGO), "EMF");
- HGLOBAL hGlob = LoadResource(g_plugin.getInst(), hRsrc);
- hEmfHeaderLogo = SetEnhMetaFileBits(SizeofResource(g_plugin.getInst(), hRsrc), (PBYTE)LockResource(hGlob));
- }
- SendDlgItemMessage(hdlg, IDC_HDRLOGO, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hEmfHeaderLogo);
- break;
-
- case WM_CTLCOLORSTATIC:
- if ((GetWindowLongPtr((HWND)lParam, GWL_STYLE) & 0xFFFF) == 0) {
- char szText[256];
- GetWindowTextA((HWND)lParam, szText, _countof(szText));
- if (!mir_strcmp(szText, "whiterect")) {
- SetTextColor((HDC)wParam, RGB(255, 255, 255));
- SetBkColor((HDC)wParam, RGB(255, 255, 255));
- SetBkMode((HDC)wParam, OPAQUE);
- *bReturn = (INT_PTR)GetStockObject(WHITE_BRUSH);
- return TRUE;
- }
+ m_autoClose = 0; // disable built-in IDOK & IDCANCEL handlers;
+ m_forceResizable = true;
- SetBkMode((HDC)wParam, TRANSPARENT);
- *bReturn = (INT_PTR)GetStockObject(NULL_BRUSH);
- return TRUE;
- }
- break;
- }
- return FALSE;
+ btnOk.OnClick = Callback(this, &CWizardPageDlg::onClick_Ok);
+ btnCancel.OnClick = Callback(this, &CWizardPageDlg::onClick_Cancel);
+}
+
+void CWizardPageDlg::OnCancel()
+{
+ PostMessage(m_hwndParent, WM_CLOSE, 0, 0);
}
-INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+bool CWizardPageDlg::OnInitDialog()
{
- static HWND hdlgPage;
- auto *opts = (DbToolOptions *)GetWindowLongPtr(hdlg, GWLP_USERDATA);
+ EnumChildWindows(m_hwnd, MyControlsEnumChildren, 0);
+ return true;
+}
- switch (message) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hdlg);
- SetWindowLongPtr(hdlg, GWLP_USERDATA, lParam);
- SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_DBTOOL)));
- hdlgPage = nullptr;
+void CWizardPageDlg::changePage(CWizardPageDlg *pNewPage)
+{
+ PostMessage(m_hwndParent, WZM_GOTOPAGE, 0, (LPARAM)pNewPage);
+}
- OpenDatabase(hdlg);
- return TRUE;
+DbToolOptions* CWizardPageDlg::getOpts() const
+{
+ return (DbToolOptions *)SendMessage(m_hwndParent, WZM_GETOPTS, 0, 0);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Wizard dialog class
+
+CWizardDlg::CWizardDlg(DbToolOptions *opts) :
+ CDlgBase(g_plugin, IDD_WIZARD),
+ m_opts(opts),
+ btnCancel(this, IDCANCEL),
+ timerStart(this, 1)
+{
+ m_autoClose = CLOSE_ON_OK;
+ SetMinSize(450, 300);
+
+ btnCancel.OnClick = Callback(this, &CWizardDlg::onClick_Cancel);
+
+ timerStart.OnEvent = Callback(this, &CWizardDlg::onTimer);
+}
+
+bool CWizardDlg::OnInitDialog()
+{
+ Utils_RestoreWindowPosition(m_hwnd, 0, MODULENAME, "Wizard_");
+ Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_DBTOOL));
+ timerStart.Start(100);
+ return true;
+}
+
+bool CWizardDlg::OnApply()
+{
+ SendMessage(hwndPage, WZN_PAGECHANGING, 0, 0);
+ SendMessage(hwndPage, WM_COMMAND, IDOK, 0);
+ return false;
+}
+
+void CWizardDlg::OnDestroy()
+{
+ Utils_SaveWindowPosition(m_hwnd, 0, MODULENAME, "Wizard_");
+
+ if (m_opts->dbChecker) {
+ m_opts->dbChecker->Destroy();
+ m_opts->dbChecker = nullptr;
+ }
+ delete m_opts;
+
+ if (hwndPage)
+ DestroyWindow(hwndPage);
+
+ if (hBoldFont != nullptr) {
+ DeleteObject(hBoldFont);
+ hBoldFont = nullptr;
+ }
+}
+
+INT_PTR CWizardDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg) {
+ case WZM_GETOPTS:
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, (LPARAM)m_opts);
+ return true;
case WZM_GOTOPAGE:
- if (hdlgPage != nullptr) DestroyWindow(hdlgPage);
- EnableWindow(GetDlgItem(hdlg, IDOK), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDCANCEL), TRUE);
- SetDlgItemText(hdlg, IDCANCEL, TranslateT("Cancel"));
- hdlgPage = CreateDialogParamW(g_plugin.getInst(), MAKEINTRESOURCE(wParam), hdlg, (DLGPROC)lParam, LPARAM(opts));
- TranslateDialogDefault(hdlgPage);
- SetWindowPos(hdlgPage, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- ShowWindow(hdlgPage, SW_SHOW);
- break;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDOK:
- SendMessage(hdlgPage, WZN_PAGECHANGING, wParam, 0);
- SendMessage(hdlgPage, message, wParam, lParam);
- break;
-
- case IDCANCEL:
- wizardResult = 0;
- SendMessage(hdlgPage, WZN_CANCELCLICKED, 0, 0);
- EndDialog(hdlg, wizardResult);
- break;
- }
- break;
+ ChangePage((CWizardPageDlg *)lParam);
+ return FALSE;
+ }
- case WM_DESTROY:
- if (opts->dbChecker) {
- opts->dbChecker->Destroy();
- opts->dbChecker = nullptr;
- }
- delete opts;
+ INT_PTR res = CDlgBase::DlgProc(msg, wParam, lParam);
+ if (msg == WM_SIZE && hwndPage) {
+ SetWindowPos(hwndPage, 0, 0, 0, m_splitterX, m_splitterY, SWP_NOZORDER | SWP_NOACTIVATE);
+ SendMessage(hwndPage, WM_SIZE, wParam, lParam);
+ InvalidateRect(hwndPage, 0, 0);
+ }
- DestroyWindow(hdlgPage);
- if (hBoldFont != nullptr) {
- DeleteObject(hBoldFont);
- hBoldFont = nullptr;
- }
- if (hEmfHeaderLogo != nullptr) {
- DeleteEnhMetaFile(hEmfHeaderLogo);
- hEmfHeaderLogo = nullptr;
- }
- break;
+ return res;
+}
+
+int CWizardDlg::Resizer(UTILRESIZECONTROL *urc)
+{
+ switch (urc->wId) {
+ case IDC_SPLITTER:
+ m_splitterX = urc->dlgNewSize.cx;
+ m_splitterY = urc->dlgNewSize.cy - (urc->dlgOriginalSize.cy - urc->rcItem.top);
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
+
+ case IDOK:
+ case IDCANCEL:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
}
- return FALSE;
+
+ return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
+}
+
+void CWizardDlg::onClick_Cancel(CCtrlButton *)
+{
+ SendMessage(hwndPage, WZN_CANCELCLICKED, 0, 0);
+ EndModal(0);
+}
+
+void CWizardDlg::onTimer(CTimer *pTimer)
+{
+ pTimer->Stop();
+
+ ChangePage(new COptionsPageDlg());
+}
+
+LRESULT CWizardDlg::ChangePage(CWizardPageDlg *pPage)
+{
+ if (hwndPage != nullptr)
+ DestroyWindow(hwndPage);
+
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDCANCEL), TRUE);
+ SetDlgItemText(m_hwnd, IDCANCEL, TranslateT("Cancel"));
+ {
+ pPage->SetParent(m_hwnd);
+ pPage->Show();
+ hwndPage = pPage->GetHwnd();
+ }
+ SetWindowPos(hwndPage, nullptr, 0, 0, m_splitterX, m_splitterY, SWP_NOZORDER);
+
+ ShowWindow(hwndPage, SW_SHOW);
+ return 0;
}
diff --git a/plugins/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp
index b77bb94469..a31d723eff 100644
--- a/plugins/DbChecker/src/worker.cpp
+++ b/plugins/DbChecker/src/worker.cpp
@@ -29,6 +29,27 @@ void __cdecl WorkerThread(DbToolOptions *opts)
DWORD sp = 0;
+ if (opts->bMarkRead) {
+ int nCount = 0;
+
+ for (auto &cc : Contacts()) {
+ DB::ECPTR pCursor(DB::Events(cc));
+ while (MEVENT hEvent = pCursor.FetchNext()) {
+ DBEVENTINFO dbei = {};
+ if (db_event_get(hEvent, &dbei))
+ continue;
+
+ if (!dbei.markedRead()) {
+ db_event_markRead(cc, hEvent);
+ nCount++;
+ }
+ }
+ }
+
+ if (nCount)
+ AddToStatus(STATUS_MESSAGE, TranslateT("%d events marked as read"), nCount);
+ }
+
DBCHeckCallback callback;
callback.pfnAddLogMessage = AddToStatus;
opts->dbChecker->Start(&callback);