summaryrefslogtreecommitdiff
path: root/plugins/DbChecker
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-02-06 18:17:49 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-02-06 18:17:49 +0300
commitd921b4639288df5e4be1350753ec7f369c2a0023 (patch)
tree15f06163a25f9e1c0d6dcc3fe7c217522119f16a /plugins/DbChecker
parent8975af6cee9cfed40a075a16841cb0e6428ebaa6 (diff)
fixes #3020 (DbChecker: добавить функцию удаления дубликатов событий из базы)
Diffstat (limited to 'plugins/DbChecker')
-rw-r--r--plugins/DbChecker/res/resource.rc1
-rw-r--r--plugins/DbChecker/src/options.cpp5
-rw-r--r--plugins/DbChecker/src/resource.h3
-rw-r--r--plugins/DbChecker/src/stdafx.h4
-rw-r--r--plugins/DbChecker/src/version.h2
-rw-r--r--plugins/DbChecker/src/worker.cpp10
6 files changed, 19 insertions, 6 deletions
diff --git a/plugins/DbChecker/res/resource.rc b/plugins/DbChecker/res/resource.rc
index f2d7c6849a..b5596e8b68 100644
--- a/plugins/DbChecker/res/resource.rc
+++ b/plugins/DbChecker/res/resource.rc
@@ -48,6 +48,7 @@ BEGIN
PUSHBUTTON "...",IDC_OPENFILE,243,49,15,13
CONTROL "Mark all events as read",IDC_MARKREAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,69,248,10
CONTROL "Fix UTF-8 encoding in old events",IDC_FIX_UTF8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,83,248,10
+ CONTROL "Remove duplicate events",IDC_REMOVE_DUPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,97,248,10
END
IDD_OPENERROR DIALOGEX 0, 0, 262, 143
diff --git a/plugins/DbChecker/src/options.cpp b/plugins/DbChecker/src/options.cpp
index 4ac947df57..4b646add38 100644
--- a/plugins/DbChecker/src/options.cpp
+++ b/plugins/DbChecker/src/options.cpp
@@ -22,7 +22,8 @@ COptionsPageDlg::COptionsPageDlg() :
edtFile(this, IDC_FILENAME),
btnFile(this, IDC_OPENFILE),
chkFixUtf(this, IDC_FIX_UTF8),
- chkMarkRead(this, IDC_MARKREAD)
+ chkMarkRead(this, IDC_MARKREAD),
+ chkRemoveDups(this, IDC_REMOVE_DUPS)
{
}
@@ -35,6 +36,7 @@ bool COptionsPageDlg::OnInitDialog()
chkFixUtf.SetState(opts->bCheckUtf);
chkMarkRead.SetState(opts->bMarkRead);
+ chkRemoveDups.SetState(opts->bCheckDups);
if (opts->dbChecker != nullptr) {
edtFile.Disable();
@@ -91,5 +93,6 @@ LBL_Error:
opts->bCheckUtf = chkFixUtf.GetState();
opts->bMarkRead = chkMarkRead.GetState();
+ opts->bCheckDups = chkRemoveDups.GetState();
changePage(new CProgressPageDlg());
}
diff --git a/plugins/DbChecker/src/resource.h b/plugins/DbChecker/src/resource.h
index fc35edc169..bc1b841342 100644
--- a/plugins/DbChecker/src/resource.h
+++ b/plugins/DbChecker/src/resource.h
@@ -22,12 +22,13 @@
#define IDC_FILENAME 1014
#define IDC_OPENFILE 1015
#define IDC_FIX_UTF8 1016
+#define IDC_REMOVE_DUPS 1017
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 107
+#define _APS_NEXT_RESOURCE_VALUE 108
#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 7453cc1686..6bc009e0f6 100644
--- a/plugins/DbChecker/src/stdafx.h
+++ b/plugins/DbChecker/src/stdafx.h
@@ -64,7 +64,7 @@ struct DbToolOptions : public MZeroedObject
MIDatabaseChecker *dbChecker;
uint32_t error;
HANDLE hEventRun, hEventAbort;
- bool bFinished, bAutoExit, bOwnsDb, bMarkRead, bCheckUtf;
+ bool bFinished, bAutoExit, bOwnsDb, bMarkRead, bCheckUtf, bCheckDups;
wchar_t filename[MAX_PATH];
};
@@ -113,7 +113,7 @@ class COptionsPageDlg : public CWizardPageDlg
CCtrlEdit edtFile;
CCtrlButton btnFile;
- CCtrlCheck chkMarkRead, chkFixUtf;
+ CCtrlCheck chkMarkRead, chkFixUtf, chkRemoveDups;
public:
COptionsPageDlg();
diff --git a/plugins/DbChecker/src/version.h b/plugins/DbChecker/src/version.h
index 7a7ee99aa9..5a472e17ea 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 2
+#define __BUILD_NUM 3
#include <stdver.h>
diff --git a/plugins/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp
index 732119bc46..f8d0766b04 100644
--- a/plugins/DbChecker/src/worker.cpp
+++ b/plugins/DbChecker/src/worker.cpp
@@ -64,7 +64,7 @@ void __cdecl WorkerThread(DbToolOptions *opts)
uint32_t sp = 0;
if (opts->bMarkRead || opts->bCheckUtf) {
- int nCount = 0, nUtfCount = 0;
+ int nCount = 0, nUtfCount = 0, nDups = 0;
for (auto &cc : Contacts()) {
DB::ECPTR pCursor(DB::Events(cc));
@@ -86,6 +86,11 @@ void __cdecl WorkerThread(DbToolOptions *opts)
nUtfCount++;
}
}
+
+ if (opts->bCheckDups && DB::IsDuplicateEvent(cc, dbei)) {
+ pCursor.DeleteEvent();
+ nDups++;
+ }
}
}
@@ -94,6 +99,9 @@ void __cdecl WorkerThread(DbToolOptions *opts)
if (nUtfCount)
AddToStatus(STATUS_MESSAGE, TranslateT("UTF-8 encoding fixed in %d events"), nUtfCount);
+
+ if (nDups)
+ AddToStatus(STATUS_MESSAGE, TranslateT("%d duplicate events removed"), nDups);
}
DBCHeckCallback callback;