summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-04-23 16:48:35 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-04-23 16:48:35 +0300
commit6ffc67311f6296d0989ee7be334a185b9f30b917 (patch)
treeec9bf03a4584237a7174cef01a1d360c7992136c
parent9dbe78ee5c1ee95454d411aabb9ba87bad77fefe (diff)
DbChecker: option for fixing old server message ids
-rw-r--r--plugins/DbChecker/res/resource.rc1
-rw-r--r--plugins/DbChecker/src/options.cpp12
-rw-r--r--plugins/DbChecker/src/resource.h1
-rw-r--r--plugins/DbChecker/src/stdafx.h4
-rw-r--r--plugins/DbChecker/src/version.h6
-rw-r--r--plugins/DbChecker/src/worker.cpp30
6 files changed, 38 insertions, 16 deletions
diff --git a/plugins/DbChecker/res/resource.rc b/plugins/DbChecker/res/resource.rc
index b5596e8b68..cfe7839e77 100644
--- a/plugins/DbChecker/res/resource.rc
+++ b/plugins/DbChecker/res/resource.rc
@@ -49,6 +49,7 @@ BEGIN
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
+ CONTROL "Fix server message ids",IDC_FIX_SERVER_IDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,111,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 4b646add38..70569d587e 100644
--- a/plugins/DbChecker/src/options.cpp
+++ b/plugins/DbChecker/src/options.cpp
@@ -23,7 +23,8 @@ COptionsPageDlg::COptionsPageDlg() :
btnFile(this, IDC_OPENFILE),
chkFixUtf(this, IDC_FIX_UTF8),
chkMarkRead(this, IDC_MARKREAD),
- chkRemoveDups(this, IDC_REMOVE_DUPS)
+ chkRemoveDups(this, IDC_REMOVE_DUPS),
+ chkFixServerIds(this, IDC_FIX_SERVER_IDS)
{
}
@@ -37,6 +38,7 @@ bool COptionsPageDlg::OnInitDialog()
chkFixUtf.SetState(opts->bCheckUtf);
chkMarkRead.SetState(opts->bMarkRead);
chkRemoveDups.SetState(opts->bCheckDups);
+ chkFixServerIds.SetState(opts->bCheckServerIds);
if (opts->dbChecker != nullptr) {
edtFile.Disable();
@@ -91,8 +93,10 @@ LBL_Error:
opts->db = pDb;
}
- opts->bCheckUtf = chkFixUtf.GetState();
- opts->bMarkRead = chkMarkRead.GetState();
- opts->bCheckDups = chkRemoveDups.GetState();
+ opts->bCheckUtf = chkFixUtf.IsChecked();
+ opts->bMarkRead = chkMarkRead.IsChecked();
+ opts->bCheckDups = chkRemoveDups.IsChecked();
+ opts->bCheckServerIds = chkFixServerIds.IsChecked();
+
changePage(new CProgressPageDlg());
}
diff --git a/plugins/DbChecker/src/resource.h b/plugins/DbChecker/src/resource.h
index bc1b841342..1309916af9 100644
--- a/plugins/DbChecker/src/resource.h
+++ b/plugins/DbChecker/src/resource.h
@@ -23,6 +23,7 @@
#define IDC_OPENFILE 1015
#define IDC_FIX_UTF8 1016
#define IDC_REMOVE_DUPS 1017
+#define IDC_FIX_SERVER_IDS 1018
// Next default values for new objects
//
diff --git a/plugins/DbChecker/src/stdafx.h b/plugins/DbChecker/src/stdafx.h
index 6bc009e0f6..7e2c07fc30 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, bCheckDups;
+ bool bFinished, bAutoExit, bOwnsDb, bMarkRead, bCheckUtf, bCheckDups, bCheckServerIds;
wchar_t filename[MAX_PATH];
};
@@ -113,7 +113,7 @@ class COptionsPageDlg : public CWizardPageDlg
CCtrlEdit edtFile;
CCtrlButton btnFile;
- CCtrlCheck chkMarkRead, chkFixUtf, chkRemoveDups;
+ CCtrlCheck chkMarkRead, chkFixUtf, chkRemoveDups, chkFixServerIds;
public:
COptionsPageDlg();
diff --git a/plugins/DbChecker/src/version.h b/plugins/DbChecker/src/version.h
index c6834dcd1a..bbd30292c8 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 3
+#define __MINOR_VERSION 96
+#define __RELEASE_NUM 3
+#define __BUILD_NUM 1
#include <stdver.h>
diff --git a/plugins/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp
index 8ee18e45da..b2bfcbb12b 100644
--- a/plugins/DbChecker/src/worker.cpp
+++ b/plugins/DbChecker/src/worker.cpp
@@ -83,14 +83,14 @@ void __cdecl WorkerThread(DbToolOptions *opts)
uint32_t sp = 0;
- if (opts->bMarkRead || opts->bCheckUtf || opts->bCheckDups) {
- int nCount = 0, nUtfCount = 0, nDups = 0;
+ if (opts->bMarkRead || opts->bCheckUtf || opts->bCheckDups || opts->bCheckServerIds) {
+ int nCount = 0, nUtfCount = 0, nDups = 0, nIds = 0;
for (auto &cc : Contacts()) {
DB::ECPTR pCursor(DB::Events(cc));
DBEVENTINFO dboldev = {};
while (MEVENT hEvent = pCursor.FetchNext()) {
- DB::EventInfo dbei(hEvent, opts->bCheckUtf || opts->bCheckDups);
+ DB::EventInfo dbei(hEvent, opts->bCheckUtf || opts->bCheckDups || opts->bCheckServerIds);
if (!dbei)
continue;
@@ -99,10 +99,23 @@ void __cdecl WorkerThread(DbToolOptions *opts)
nCount++;
}
- if (opts->bCheckUtf && dbei.eventType == EVENTTYPE_MESSAGE) {
- if (ConvertOldEvent(dbei)) {
- db_event_edit(hEvent, &dbei);
- nUtfCount++;
+ if (dbei.eventType == EVENTTYPE_MESSAGE) {
+ if (opts->bCheckUtf) {
+ if (ConvertOldEvent(dbei)) {
+ db_event_edit(hEvent, &dbei);
+ nUtfCount++;
+ }
+ }
+
+ if (opts->bCheckServerIds) {
+ // if a blob is longer than its text part, there's a nessage id after text
+ int iMsgLen = (int)mir_strlen((char *)dbei.pBlob);
+ if (dbei.cbBlob - iMsgLen > 2) {
+ dbei.cbBlob = iMsgLen;
+ dbei.szId = (char *)dbei.pBlob + iMsgLen + 1;
+ db_event_edit(hEvent, &dbei);
+ nIds++;
+ }
}
}
@@ -133,6 +146,9 @@ void __cdecl WorkerThread(DbToolOptions *opts)
if (nDups)
AddToStatus(STATUS_MESSAGE, TranslateT("%d duplicate events removed"), nDups);
+
+ if (nIds)
+ AddToStatus(STATUS_MESSAGE, TranslateT("%d server message ids fixed"), nIds);
}
DBCHeckCallback callback;