summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-06-22 20:19:01 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-06-22 20:19:01 +0300
commit581319b8cd1f774e5fc42db570d44ec2b4e41485 (patch)
tree42234da7ead10b3f9421602f5636913ffcb35c72
parent3285170a72a34d78e178b2b8117a3622f3a1840a (diff)
temporary return of DbChecker
-rw-r--r--include/m_database.h7
-rw-r--r--include/m_db_int.h30
-rw-r--r--libs/win32/mir_app.libbin207154 -> 207560 bytes
-rw-r--r--libs/win64/mir_app.libbin202776 -> 203192 bytes
-rw-r--r--plugins/DbChecker/dbchecker.vcxproj52
-rw-r--r--plugins/DbChecker/dbchecker.vcxproj.filters58
-rw-r--r--plugins/DbChecker/res/dbthdr.emfbin0 -> 2912 bytes
-rw-r--r--plugins/DbChecker/res/dbtool.emfbin0 -> 4380 bytes
-rw-r--r--plugins/DbChecker/res/dbtool.icobin0 -> 5430 bytes
-rw-r--r--plugins/DbChecker/res/delete.icobin0 -> 1150 bytes
-rw-r--r--plugins/DbChecker/res/profileg.icobin0 -> 1150 bytes
-rw-r--r--plugins/DbChecker/res/resource.rc267
-rw-r--r--plugins/DbChecker/res/version.rc9
-rw-r--r--plugins/DbChecker/src/cleaning.cpp59
-rw-r--r--plugins/DbChecker/src/fileaccess.cpp67
-rw-r--r--plugins/DbChecker/src/finished.cpp51
-rw-r--r--plugins/DbChecker/src/main.cpp98
-rw-r--r--plugins/DbChecker/src/openerror.cpp54
-rw-r--r--plugins/DbChecker/src/progress.cpp247
-rw-r--r--plugins/DbChecker/src/resource.h52
-rw-r--r--plugins/DbChecker/src/selectdb.cpp332
-rw-r--r--plugins/DbChecker/src/stdafx.cxx18
-rw-r--r--plugins/DbChecker/src/stdafx.h87
-rw-r--r--plugins/DbChecker/src/version.h13
-rw-r--r--plugins/DbChecker/src/welcome.cpp71
-rw-r--r--plugins/DbChecker/src/wizard.cpp157
-rw-r--r--plugins/DbChecker/src/worker.cpp148
-rw-r--r--plugins/Dbx_mdbx/dbx_mdbx.vcxproj1
-rw-r--r--plugins/Dbx_mdbx/dbx_mdbx.vcxproj.filters3
-rw-r--r--plugins/Dbx_mdbx/src/dbcheck.cpp29
-rw-r--r--plugins/Dbx_mdbx/src/dbintf.cpp29
-rw-r--r--plugins/Dbx_mdbx/src/dbintf.h16
-rw-r--r--plugins/PluginUpdater/src/DlgUpdate.cpp1
-rw-r--r--src/mir_app/src/MDatabaseCommon.cpp7
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/newplugins.cpp1
37 files changed, 1963 insertions, 3 deletions
diff --git a/include/m_database.h b/include/m_database.h
index c0df1392e7..cb6d0e55bf 100644
--- a/include/m_database.h
+++ b/include/m_database.h
@@ -432,6 +432,13 @@ bool Profile_GetSetting(const wchar_t *pwszSetting, wchar_t(&pwszBuf)[_Size], co
return Profile_GetSetting(pwszSetting, pwszBuf, _Size, pwszDefault);
}
+// Checks the specified profile like dbtool did.
+// Implemented in the dbchecker plugins, thus it might not exist
+// wParam = (WPARAM)(wchar_t*)ptszProfileName
+// lParam = (BOOL)bConversionMode
+
+#define MS_DB_CHECKPROFILE "DB/CheckProfile"
+
/////////////////////////////////////////////////////////////////////////////////////////
// Contact services
diff --git a/include/m_db_int.h b/include/m_db_int.h
index 775c066b5a..660d5791ac 100644
--- a/include/m_db_int.h
+++ b/include/m_db_int.h
@@ -28,6 +28,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_core.h>
#endif
+///////////////////////////////////////////////////////////////////////////////
+// basic database checker interface
+
+#define STATUS_MESSAGE 0
+#define STATUS_WARNING 1
+#define STATUS_ERROR 2
+#define STATUS_FATAL 3
+#define STATUS_SUCCESS 4
+
+struct DBCHeckCallback
+{
+ int cbSize;
+ DWORD spaceProcessed, spaceUsed;
+ HANDLE hOutFile;
+ bool bCheckOnly, bBackup, bAggressive, bEraseHistory, bMarkRead, bConvertUtf;
+
+ void (*pfnAddLogMessage)(int type, const wchar_t *ptszFormat, ...);
+};
+
+interface MIDatabaseChecker
+{
+ STDMETHOD_(BOOL, Start)(DBCHeckCallback *callback) PURE;
+ STDMETHOD_(BOOL, CheckDb)(int phase, int firstTime) PURE;
+ STDMETHOD_(VOID, Destroy)() PURE;
+};
+
/////////////////////////////////////////////////////////////////////////////////////////
// basic database interface
@@ -130,6 +156,8 @@ interface MIR_APP_EXPORT MIDatabase
STDMETHOD_(BOOL, Compact)(void) PURE;
STDMETHOD_(BOOL, Backup)(LPCWSTR) PURE;
+
+ STDMETHOD_(MIDatabaseChecker*, GetChecker)(void) PURE;
STDMETHOD_(MEVENT, GetEventById)(LPCSTR szModule, LPCSTR szId) PURE;
@@ -187,6 +215,8 @@ public:
STDMETHODIMP_(BOOL) Compact(void) override;
STDMETHODIMP_(BOOL) Backup(LPCWSTR) override;
+ STDMETHODIMP_(MIDatabaseChecker*) GetChecker(void) override;
+
STDMETHODIMP_(DB::EventCursor*) EventCursor(MCONTACT hContact, MEVENT hDbEvent) override;
STDMETHODIMP_(DB::EventCursor*) EventCursorRev(MCONTACT hContact, MEVENT hDbEvent) override;
};
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index d8e7e576ca..f4b3f25579 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index e2a276057e..40aa710ac6 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/DbChecker/dbchecker.vcxproj b/plugins/DbChecker/dbchecker.vcxproj
new file mode 100644
index 0000000000..07a3db537f
--- /dev/null
+++ b/plugins/DbChecker/dbchecker.vcxproj
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\cleaning.cpp" />
+ <ClCompile Include="src\fileaccess.cpp" />
+ <ClCompile Include="src\finished.cpp" />
+ <ClCompile Include="src\main.cpp" />
+ <ClCompile Include="src\openerror.cpp" />
+ <ClCompile Include="src\progress.cpp" />
+ <ClCompile Include="src\selectdb.cpp" />
+ <ClCompile Include="src\stdafx.cxx">
+ <PrecompiledHeader>Create</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="src\welcome.cpp" />
+ <ClCompile Include="src\wizard.cpp" />
+ <ClCompile Include="src\worker.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\resource.rc" />
+ <ResourceCompile Include="res\version.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h" />
+ <ClInclude Include="src\stdafx.h" />
+ <ClInclude Include="src\version.h" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>DbChecker</ProjectName>
+ <ProjectGuid>{A2E9DA24-95E4-4414-94AF-488A382E276A}</ProjectGuid>
+ </PropertyGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" />
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/plugins/DbChecker/dbchecker.vcxproj.filters b/plugins/DbChecker/dbchecker.vcxproj.filters
new file mode 100644
index 0000000000..f2f061898e
--- /dev/null
+++ b/plugins/DbChecker/dbchecker.vcxproj.filters
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(ProjectDir)..\..\build\vc.common\common.filters" />
+ <ItemGroup>
+ <ClCompile Include="src\cleaning.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\fileaccess.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\finished.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\main.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\openerror.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\progress.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\selectdb.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\welcome.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\wizard.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\worker.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\stdafx.cxx">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\resource.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ <ResourceCompile Include="res\version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\stdafx.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/plugins/DbChecker/res/dbthdr.emf b/plugins/DbChecker/res/dbthdr.emf
new file mode 100644
index 0000000000..554d11b5ea
--- /dev/null
+++ b/plugins/DbChecker/res/dbthdr.emf
Binary files differ
diff --git a/plugins/DbChecker/res/dbtool.emf b/plugins/DbChecker/res/dbtool.emf
new file mode 100644
index 0000000000..abce0632ee
--- /dev/null
+++ b/plugins/DbChecker/res/dbtool.emf
Binary files differ
diff --git a/plugins/DbChecker/res/dbtool.ico b/plugins/DbChecker/res/dbtool.ico
new file mode 100644
index 0000000000..452948a07c
--- /dev/null
+++ b/plugins/DbChecker/res/dbtool.ico
Binary files differ
diff --git a/plugins/DbChecker/res/delete.ico b/plugins/DbChecker/res/delete.ico
new file mode 100644
index 0000000000..086b3574e7
--- /dev/null
+++ b/plugins/DbChecker/res/delete.ico
Binary files differ
diff --git a/plugins/DbChecker/res/profileg.ico b/plugins/DbChecker/res/profileg.ico
new file mode 100644
index 0000000000..f912bb1111
--- /dev/null
+++ b/plugins/DbChecker/res/profileg.ico
Binary files differ
diff --git a/plugins/DbChecker/res/resource.rc b/plugins/DbChecker/res/resource.rc
new file mode 100644
index 0000000000..cd5ae96b6f
--- /dev/null
+++ b/plugins/DbChecker/res/resource.rc
@@ -0,0 +1,267 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "..\src\resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include <winres.h>
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_WELCOME DIALOGEX 0, 0, 262, 143
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "",IDC_WATERMARK,"Static",SS_ENHMETAFILE,0,0,63,143
+ LTEXT "whiterect",IDC_STATIC,63,0,199,143
+ LTEXT "Welcome to the Miranda Database Wizard",IDC_TITLE,77,12,178,24,0,WS_EX_TRANSPARENT
+ LTEXT "Using this Wizard you can compact your Miranda profile database to remove dead space created during normal usage, as well as repair a large number of issues that could affect the database.",IDC_STATIC,77,46,178,32,0,WS_EX_TRANSPARENT
+ LTEXT "To continue, click Next.",IDC_STATIC,77,85,178,8,0,WS_EX_TRANSPARENT
+ LTEXT "This program is licensed under the terms of the GNU General Public License.",IDC_STATIC,77,122,178,16,WS_DISABLED
+END
+
+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
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "Miranda Database Tool"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ PUSHBUTTON "< &Back",IDC_BACK,96,153,50,14
+ DEFPUSHBUTTON "&Next >",IDOK,146,153,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,205,153,50,14
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-5,143,269,1
+END
+
+IDD_SELECTDB 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 "Select Miranda Profile",IDC_STATIC,11,6,206,8,WS_BORDER
+ CONTROL "",IDC_HDRLOGO,"Static",SS_ENHMETAFILE,234,3,25,25
+ LTEXT "You can choose the Miranda profile database to compact or repair.",IDC_STATIC,20,14,197,16
+ LTEXT "Select the &profile database from the list below. If the database you wish to use is not listed here then click Other to browse your computer.",IDC_STATIC,10,35,242,16
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-1,32,264,1
+ CONTROL "List1",IDC_DBLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_AUTOARRANGE | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,10,53,242,72
+ RTEXT "&File:",IDC_STATIC,10,130,22,8
+ EDITTEXT IDC_FILE,31,128,177,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Other...",IDC_OTHER,212,128,40,12
+END
+
+IDD_OPENERROR 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 "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
+ 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
+ LTEXT "",IDC_FILE,23,57,226,8,SS_NOPREFIX
+END
+
+IDD_FILEACCESS 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 "File Access Options",IDC_STATIC,11,6,206,8,WS_BORDER
+ CONTROL "",IDC_HDRLOGO,"Static",SS_ENHMETAFILE,234,3,25,25
+ LTEXT "You can select low level options to determine how the database is processed.",IDC_STATIC,20,14,197,16
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-1,32,264,1
+ CONTROL "Create backup",IDC_BACKUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,69,226,10,WS_EX_CLIENTEDGE
+ LTEXT "Creates a backup copy of the database before any of the requested changes are made.",IDC_STBACKUP,37,80,212,16
+ CONTROL "Aggressively find corruption",IDC_AGGRESSIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,100,226,10,WS_EX_CLIENTEDGE
+ LTEXT "Scans the database for data that is not linked to any other data. This requires more disk space and more time, so is only required if you suspect corruption.",IDC_STATIC,37,111,212,24
+ CONTROL "Check consistency only",IDC_CHECKONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,38,226,10,WS_EX_CLIENTEDGE
+ LTEXT "Just checks that the database is valid, without writing anything to the disk.",IDC_STATIC,37,49,212,16
+END
+
+IDD_CLEANING 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 "Cleaning Options",IDC_STATIC,11,6,206,8,WS_BORDER
+ CONTROL "",IDC_HDRLOGO,"Static",SS_ENHMETAFILE,234,3,25,25
+ LTEXT "You can choose to remove information from the database while it is being processed.",IDC_STATIC,20,14,197,16
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-1,32,264,1
+ CONTROL "Erase all histories",IDC_ERASEHISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,38,226,10,WS_EX_CLIENTEDGE
+ LTEXT "Removes all the saved history for all contacts in the database.",IDC_STATIC,37,49,212,8
+ CONTROL "Mark all events read",IDC_MARKREAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,62,226,10,WS_EX_CLIENTEDGE
+ LTEXT "Marks all the history events as read. This will rectify any problems with old messages always appearing in the message window log box.",IDC_STATIC,37,73,212,24
+ CONTROL "Convert old Unicode messages to UTF8",IDC_CONVERTUTF,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,101,226,10,WS_EX_CLIENTEDGE
+ LTEXT "Converts history messages in pre-0.7 format (ANSI+UCS2) to the new UTF8 format supported by 0.7. Saves the database space in most cases (recommended).",IDC_STATIC,37,111,212,25
+END
+
+IDD_PROGRESS 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",-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
+ 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
+
+IDD_FINISHED 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 "Finished!",IDC_STATIC,11,6,206,8,WS_BORDER
+ CONTROL "",IDC_HDRLOGO,"Static",SS_ENHMETAFILE,234,3,25,25
+ LTEXT "All tasks have been completed.",IDC_STATIC,20,14,197,16
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-1,32,264,1
+ CONTROL "Launch Miranda with this profile",IDC_LAUNCHMIRANDA,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,87,226,10,WS_EX_CLIENTEDGE
+ LTEXT "Launches Miranda with the profile that was just worked on.",IDC_STATIC,37,98,212,16
+ LTEXT "",IDC_DBFILE,23,68,226,8,SS_NOPREFIX | WS_BORDER
+ RTEXT "Backup:",IDC_STBACKUP,23,76,30,8
+ LTEXT "",IDC_BACKUPFILE,56,76,193,8,SS_NOPREFIX
+ LTEXT "The processing of the database has been completed. Click Next to return to the start of the wizard to select another database to check, or click Finish to exit the wizard.",IDC_STATIC,23,38,226,24
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_WELCOME, DIALOG
+ BEGIN
+ LEFTMARGIN, 5
+ RIGHTMARGIN, 255
+ VERTGUIDE, 77
+ TOPMARGIN, 5
+ BOTTOMMARGIN, 138
+ END
+
+ IDD_WIZARD, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 255
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 167
+ END
+
+ IDD_SELECTDB, DIALOG
+ BEGIN
+ LEFTMARGIN, 23
+ RIGHTMARGIN, 249
+ TOPMARGIN, 38
+ BOTTOMMARGIN, 136
+ END
+
+ IDD_OPENERROR, DIALOG
+ BEGIN
+ LEFTMARGIN, 23
+ RIGHTMARGIN, 249
+ TOPMARGIN, 38
+ BOTTOMMARGIN, 136
+ END
+
+ IDD_FILEACCESS, DIALOG
+ BEGIN
+ LEFTMARGIN, 23
+ RIGHTMARGIN, 249
+ VERTGUIDE, 37
+ TOPMARGIN, 38
+ BOTTOMMARGIN, 136
+ END
+
+ IDD_CLEANING, DIALOG
+ BEGIN
+ LEFTMARGIN, 23
+ RIGHTMARGIN, 249
+ VERTGUIDE, 37
+ TOPMARGIN, 38
+ BOTTOMMARGIN, 136
+ END
+
+ IDD_PROGRESS, DIALOG
+ BEGIN
+ LEFTMARGIN, 20
+ RIGHTMARGIN, 242
+ TOPMARGIN, 38
+ BOTTOMMARGIN, 136
+ END
+
+ IDD_FINISHED, DIALOG
+ BEGIN
+ LEFTMARGIN, 23
+ RIGHTMARGIN, 249
+ VERTGUIDE, 37
+ TOPMARGIN, 38
+ BOTTOMMARGIN, 136
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// EMF
+//
+
+IDE_WATERMARK EMF "dbtool.emf"
+IDE_HDRLOGO EMF "dbthdr.emf"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_DBTOOL ICON "dbtool.ico"
+IDI_PROFILEGREEN ICON "profileg.ico"
+IDI_BAD ICON "delete.ico"
+
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
diff --git a/plugins/DbChecker/res/version.rc b/plugins/DbChecker/res/version.rc
new file mode 100644
index 0000000000..5a5ddd63ed
--- /dev/null
+++ b/plugins/DbChecker/res/version.rc
@@ -0,0 +1,9 @@
+// Microsoft Visual C++ generated resource script.
+//
+#ifdef APSTUDIO_INVOKED
+#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+#include "..\src\version.h"
+
+#include "..\..\build\Version.rc"
diff --git a/plugins/DbChecker/src/cleaning.cpp b/plugins/DbChecker/src/cleaning.cpp
new file mode 100644
index 0000000000..3a2541d364
--- /dev/null
+++ b/plugins/DbChecker/src/cleaning.cpp
@@ -0,0 +1,59 @@
+/*
+Miranda Database Tool
+Copyright (C) 2001-2005 Richard Hughes
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+INT_PTR CALLBACK CleaningDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ INT_PTR bReturn;
+ if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
+ return bReturn;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ CheckDlgButton(hdlg, IDC_ERASEHISTORY, opts.bEraseHistory ? BST_CHECKED : BST_UNCHECKED);
+ EnableWindow(GetDlgItem(hdlg, IDC_ERASEHISTORY), !opts.bAggressive);
+ CheckDlgButton(hdlg, IDC_MARKREAD, opts.bMarkRead ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_CONVERTUTF, opts.bConvertUtf ? BST_CHECKED : BST_UNCHECKED);
+ TranslateDialogDefault(hdlg);
+ return TRUE;
+
+ case WZN_PAGECHANGING:
+ opts.bEraseHistory = IsDlgButtonChecked(hdlg, IDC_ERASEHISTORY) && !opts.bAggressive;
+ opts.bMarkRead = IsDlgButtonChecked(hdlg, IDC_MARKREAD);
+ opts.bConvertUtf = IsDlgButtonChecked(hdlg, IDC_CONVERTUTF);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_BACK:
+ if (opts.bCheckOnly)
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc);
+ else
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc);
+ break;
+
+ case IDOK:
+ OpenDatabase(hdlg, IDD_PROGRESS);
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
diff --git a/plugins/DbChecker/src/fileaccess.cpp b/plugins/DbChecker/src/fileaccess.cpp
new file mode 100644
index 0000000000..2965dfc2d9
--- /dev/null
+++ b/plugins/DbChecker/src/fileaccess.cpp
@@ -0,0 +1,67 @@
+/*
+Miranda Database Tool
+Copyright (C) 2001-2005 Richard Hughes
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+INT_PTR CALLBACK FileAccessDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ INT_PTR bReturn;
+ if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
+ return bReturn;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ if (bShortMode)
+ EnableWindow(GetDlgItem(GetParent(hdlg), IDC_BACK), FALSE);
+ CheckDlgButton(hdlg, IDC_CHECKONLY, opts.bCheckOnly ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_BACKUP, opts.bBackup ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_AGGRESSIVE, opts.bAggressive ? BST_CHECKED : BST_UNCHECKED);
+ SendMessage(hdlg, WM_COMMAND, MAKEWPARAM(IDC_CHECKONLY, BN_CLICKED), 0);
+ TranslateDialogDefault(hdlg);
+ return TRUE;
+
+ case WZN_PAGECHANGING:
+ opts.bCheckOnly = IsDlgButtonChecked(hdlg, IDC_CHECKONLY);
+ opts.bAggressive = IsDlgButtonChecked(hdlg, IDC_AGGRESSIVE);
+ if (opts.bCheckOnly) opts.bBackup = 0;
+ else opts.bBackup = IsDlgButtonChecked(hdlg, IDC_BACKUP);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_BACK:
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc);
+ break;
+
+ case IDOK:
+ if (opts.bCheckOnly)
+ OpenDatabase(hdlg, IDD_PROGRESS);
+ else
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_CLEANING, (LPARAM)CleaningDlgProc);
+ break;
+
+ case IDC_CHECKONLY:
+ EnableWindow(GetDlgItem(hdlg, IDC_BACKUP), BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_CHECKONLY));
+ EnableWindow(GetDlgItem(hdlg, IDC_STBACKUP), BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_CHECKONLY));
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
diff --git a/plugins/DbChecker/src/finished.cpp b/plugins/DbChecker/src/finished.cpp
new file mode 100644
index 0000000000..e43fea8b45
--- /dev/null
+++ b/plugins/DbChecker/src/finished.cpp
@@ -0,0 +1,51 @@
+/*
+Miranda Database Tool
+Copyright (C) 2001-2005 Richard Hughes
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+INT_PTR CALLBACK FinishedDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ INT_PTR bReturn;
+ if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
+ return bReturn;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ EnableWindow(GetDlgItem(GetParent(hdlg), IDC_BACK), FALSE);
+ EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), FALSE);
+ SetDlgItemText(GetParent(hdlg), IDCANCEL, TranslateT("&Finish"));
+ SetWindowLongPtr(GetDlgItem(hdlg, IDC_DBFILE), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hdlg, IDC_DBFILE), GWL_STYLE) | SS_PATHELLIPSIS);
+ SetDlgItemText(hdlg, IDC_DBFILE, opts.filename);
+ if (opts.bBackup) {
+ ShowWindow(GetDlgItem(hdlg, IDC_STBACKUP), TRUE);
+ SetWindowLongPtr(GetDlgItem(hdlg, IDC_BACKUPFILE), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hdlg, IDC_BACKUPFILE), GWL_STYLE) | SS_PATHELLIPSIS);
+ SetDlgItemText(hdlg, IDC_BACKUPFILE, opts.backupFilename);
+ }
+ else ShowWindow(GetDlgItem(hdlg, IDC_STBACKUP), FALSE);
+ TranslateDialogDefault(hdlg);
+ return TRUE;
+
+ case WZN_CANCELCLICKED:
+ bLaunchMiranda = IsDlgButtonChecked(hdlg, IDC_LAUNCHMIRANDA) == BST_CHECKED;
+ Profile_SetDefault(opts.filename);
+ wizardResult = 1;
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/plugins/DbChecker/src/main.cpp b/plugins/DbChecker/src/main.cpp
new file mode 100644
index 0000000000..b4a06048a9
--- /dev/null
+++ b/plugins/DbChecker/src/main.cpp
@@ -0,0 +1,98 @@
+/*
+Miranda Database Tool
+Copyright (C) 2001-2005 Richard Hughes
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+int hLangpack = 0;
+bool bServiceMode, bLaunchMiranda, bShortMode, bAutoExit;
+
+DbToolOptions opts = { 0 };
+
+CMPlugin g_plugin;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfoEx =
+{
+ sizeof(pluginInfoEx),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE | STATIC_PLUGIN,
+ // {A0138FC6-4C52-4501-AF93-7D3E20BCAE5B}
+ { 0xa0138fc6, 0x4c52, 0x4501, { 0xaf, 0x93, 0x7d, 0x3e, 0x20, 0xbc, 0xae, 0x5b } }
+};
+
+CMPlugin::CMPlugin() :
+ PLUGIN<CMPlugin>(nullptr, pluginInfoEx)
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// we implement service mode interface
+
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SERVICEMODE, MIID_LAST };
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(DATABASELINK *) Profile_GetLink();
+
+static HANDLE hService; // do not remove it!
+
+static INT_PTR ServiceMode(WPARAM, LPARAM)
+{
+ bLaunchMiranda = bShortMode = bAutoExit = false;
+ bServiceMode = true;
+
+ opts.db = db_get_current();
+ wcsncpy_s(opts.filename, VARSW(L"%miranda_userdata%\\%miranda_profilename%.dat"), _TRUNCATE);
+
+ opts.dbChecker = opts.db->GetChecker();
+ if (opts.dbChecker == nullptr)
+ return SERVICE_FAILED;
+
+ DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WIZARD), nullptr, ProgressDlgProc);
+ return (bLaunchMiranda) ? SERVICE_CONTINUE : SERVICE_FAILED;
+}
+
+static INT_PTR CheckProfile(WPARAM wParam, LPARAM lParam)
+{
+ bShortMode = true;
+ bLaunchMiranda = lParam != 0;
+ bAutoExit = lParam == 2;
+ bServiceMode = false;
+ wcsncpy(opts.filename, (wchar_t*)wParam, _countof(opts.filename));
+ return DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc);
+}
+
+int CMPlugin::Load(void)
+{
+ CreateServiceFunction(MS_DB_CHECKPROFILE, CheckProfile);
+ hService = CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceMode);
+ return 0;
+}
+
+int CMPlugin::Unload(void)
+{
+ DestroyServiceFunction(hService);
+ return 0;
+}
diff --git a/plugins/DbChecker/src/openerror.cpp b/plugins/DbChecker/src/openerror.cpp
new file mode 100644
index 0000000000..42a4d4e2eb
--- /dev/null
+++ b/plugins/DbChecker/src/openerror.cpp
@@ -0,0 +1,54 @@
+/*
+Miranda Database Tool
+Copyright (C) 2001-2005 Richard Hughes
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+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)
+{
+ INT_PTR bReturn;
+ if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
+ return bReturn;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ {
+ wchar_t szError[256];
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, opts.error, 0, szError, _countof(szError), nullptr);
+ SetDlgItemText(hdlg, IDC_ERRORTEXT, szError);
+ }
+ 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;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_BACK:
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc);
+ break;
+
+ case IDOK:
+ OpenDatabase(hdlg, IDD_FILEACCESS);
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
diff --git a/plugins/DbChecker/src/progress.cpp b/plugins/DbChecker/src/progress.cpp
new file mode 100644
index 0000000000..eb8cc08141
--- /dev/null
+++ b/plugins/DbChecker/src/progress.cpp
@@ -0,0 +1,247 @@
+/*
+Miranda Database Tool
+Copyright (C) 2001-2005 Richard Hughes
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+#define WM_PROCESSINGDONE (WM_USER+1)
+
+void __cdecl WorkerThread(void *unused);
+static HWND hwndStatus, hdlgProgress, hwndBar;
+static bool bShortModeDone;
+HANDLE hEventRun = nullptr, hEventAbort = nullptr;
+int errorCount;
+LRESULT wizardResult;
+
+void AddToStatus(int flags, const wchar_t* fmt, ...)
+{
+ va_list vararg;
+ va_start(vararg, fmt);
+
+ wchar_t str[256];
+ mir_vsnwprintf(str, _countof(str), fmt, vararg);
+ va_end(vararg);
+
+ int i = SendMessage(hwndStatus, LB_ADDSTRING, 0, (LPARAM)str);
+ SendMessage(hwndStatus, LB_SETITEMDATA, i, flags);
+ InvalidateRect(hwndStatus, nullptr, FALSE);
+ SendMessage(hwndStatus, LB_SETTOPINDEX, i, 0);
+
+#ifdef _DEBUG
+ OutputDebugString(str);
+ OutputDebugStringA("\n");
+#endif
+
+ switch (flags & STATUS_CLASSMASK) {
+ case STATUS_ERROR:
+ case STATUS_FATAL:
+ errorCount++;
+ }
+}
+
+void SetProgressBar(int perThou)
+{
+ SendMessage(hwndBar, PBM_SETPOS, perThou, 0);
+}
+
+void ProcessingDone(void)
+{
+ SendMessage(hdlgProgress, WM_PROCESSINGDONE, 0, 0);
+}
+
+INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ static int fontHeight, listWidth;
+ static int manualAbort;
+ static HFONT hBoldFont = nullptr;
+
+ INT_PTR bReturn;
+ if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
+ return bReturn;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), FALSE);
+ hdlgProgress = hdlg;
+ hwndStatus = GetDlgItem(hdlg, IDC_STATUS);
+ errorCount = 0;
+ bShortModeDone = false;
+ hwndBar = GetDlgItem(hdlg, IDC_PROGRESS);
+ SendMessage(hwndBar, PBM_SETRANGE, 0, MAKELPARAM(0, 1000));
+ {
+ HDC hdc;
+ HFONT hFont, hoFont;
+ SIZE s;
+ hdc = GetDC(nullptr);
+ hFont = (HFONT)SendMessage(hdlg, WM_GETFONT, 0, 0);
+ hoFont = (HFONT)SelectObject(hdc, hFont);
+ 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;
+ hEventRun = CreateEvent(nullptr, TRUE, TRUE, nullptr);
+ hEventAbort = CreateEvent(nullptr, TRUE, FALSE, nullptr);
+ TranslateDialogDefault(hdlg);
+ _beginthread(WorkerThread, 0, nullptr);
+ return TRUE;
+
+ case WM_MEASUREITEM:
+ {
+ LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam;
+ mis->itemWidth = listWidth;
+ mis->itemHeight = fontHeight;
+ }
+ return TRUE;
+
+ case WM_DRAWITEM:
+ wchar_t str[256];
+ {
+ LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
+ int bold = 0;
+ HFONT hoFont = nullptr;
+ if ((int)dis->itemID == -1) break;
+ SendMessage(dis->hwndItem, LB_GETTEXT, dis->itemID, (LPARAM)str);
+ switch (dis->itemData & STATUS_CLASSMASK) {
+ case STATUS_MESSAGE:
+ SetTextColor(dis->hDC, RGB(0, 0, 0));
+ break;
+ case STATUS_WARNING:
+ SetTextColor(dis->hDC, RGB(192, 128, 0));
+ break;
+ case STATUS_ERROR:
+ SetTextColor(dis->hDC, RGB(192, 0, 0));
+ break;
+ case STATUS_FATAL:
+ bold = 1;
+ SetTextColor(dis->hDC, RGB(192, 0, 0));
+ break;
+ case STATUS_SUCCESS:
+ bold = 1;
+ SetTextColor(dis->hDC, RGB(0, 192, 0));
+ break;
+ }
+ if (bold) hoFont = (HFONT)SelectObject(dis->hDC, hBoldFont);
+ ExtTextOut(dis->hDC, dis->rcItem.left, dis->rcItem.top, ETO_CLIPPED | ETO_OPAQUE, &dis->rcItem, str, (UINT)mir_wstrlen(str), nullptr);
+ if (bold) SelectObject(dis->hDC, hoFont);
+ }
+ return TRUE;
+
+ case WM_PROCESSINGDONE:
+ SetProgressBar(1000);
+ if (bShortMode) {
+ EnableWindow(GetDlgItem(GetParent(hdlg), IDC_BACK), FALSE);
+ EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), FALSE);
+ SetDlgItemText(GetParent(hdlg), IDCANCEL, TranslateT("&Finish"));
+ bShortModeDone = true;
+ if (bAutoExit)
+ PostMessage(GetParent(hdlg), WM_COMMAND, IDCANCEL, 0);
+ }
+ 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)
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc);
+ else {
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_CLEANING, (LPARAM)CleaningDlgProc);
+ CloseHandle(opts.hOutFile);
+ opts.hOutFile = nullptr;
+ }
+ break;
+ }
+ break;
+
+ case WZN_CANCELCLICKED:
+ if (bShortModeDone) {
+ if (!errorCount) {
+ if (bLaunchMiranda)
+ Profile_SetDefault(opts.filename);
+ wizardResult = 1;
+ }
+ return TRUE;
+ }
+
+ ResetEvent(hEventRun);
+ 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);
+ }
+ SetEvent(hEventRun);
+ SetWindowLongPtr(hdlg, DWLP_MSGRESULT, TRUE);
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_BACK:
+ ResetEvent(hEventRun);
+ if (!IsWindowEnabled(GetDlgItem(GetParent(hdlg), IDOK))) {
+ if (MessageBox(hdlg, TranslateT("Processing has not yet completed, if you go back 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 go back?"), TranslateT("Miranda Database Tool"), MB_YESNO) == IDYES) {
+ manualAbort = 2;
+ SetEvent(hEventAbort);
+ }
+ SetEvent(hEventRun);
+ break;
+ }
+ SetEvent(hEventRun);
+ if (opts.bCheckOnly)
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc);
+ else
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_CLEANING, (LPARAM)CleaningDlgProc);
+ break;
+
+ case IDOK:
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FINISHED, (LPARAM)FinishedDlgProc);
+ break;
+ }
+ break;
+
+ case WM_DESTROY:
+ if (hEventAbort) {
+ CloseHandle(hEventAbort);
+ hEventAbort = nullptr;
+ }
+ if (hEventRun) {
+ CloseHandle(hEventRun);
+ hEventRun = nullptr;
+ }
+ if (hBoldFont) {
+ DeleteObject(hBoldFont);
+ hBoldFont = nullptr;
+ }
+ break;
+ }
+ return FALSE;
+}
diff --git a/plugins/DbChecker/src/resource.h b/plugins/DbChecker/src/resource.h
new file mode 100644
index 0000000000..cdd4a8e9ea
--- /dev/null
+++ b/plugins/DbChecker/src/resource.h
@@ -0,0 +1,52 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by resource.rc
+//
+#define IDC_BACK 3
+#define IDD_WIZARD 101
+#define IDE_WATERMARK 102
+#define IDI_DBTOOL 102
+#define IDE_HDRLOGO 103
+#define IDI_PROFILEGREEN 104
+#define IDR_DEFAULT1 104
+#define IDD_WELCOME 106
+#define IDD_SELECTDB 107
+#define IDD_OPENERROR 108
+#define IDD_FILEACCESS 109
+#define IDD_CLEANING 110
+#define IDD_PROGRESS 111
+#define IDD_FINISHED 112
+#define IDI_BAD 113
+#define IDC_WATERMARK 1000
+#define IDC_TITLE 1001
+#define IDC_HDRLOGO 1002
+#define IDC_DBLIST 1003
+#define IDC_FILE 1004
+#define IDC_OTHER 1005
+#define IDC_ERRORTEXT 1006
+#define IDC_INUSE 1007
+#define IDC_BACKUP 1008
+#define IDC_AGGRESSIVE 1009
+#define IDC_ERASEHISTORY 1010
+#define IDC_CHECKONLY 1010
+#define IDC_MARKREAD 1011
+#define IDC_PROGRESS 1011
+#define IDC_STATUS 1012
+#define IDC_STBACKUP 1013
+#define IDC_LAUNCHMIRANDA 1015
+#define IDC_DBFILE 1016
+#define IDC_BACKUPFILE 1017
+#define IDC_CHECK1 1018
+#define IDC_CONVERTUTF 1018
+#define IDC_STATIC -1
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1019
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/DbChecker/src/selectdb.cpp b/plugins/DbChecker/src/selectdb.cpp
new file mode 100644
index 0000000000..d395c6b4c4
--- /dev/null
+++ b/plugins/DbChecker/src/selectdb.cpp
@@ -0,0 +1,332 @@
+/*
+Miranda Database Tool
+Copyright (C) 2001-2005 Richard Hughes
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+static bool CheckBroken(const wchar_t *ptszFullPath)
+{
+ DATABASELINK *dblink = FindDatabasePlugin(ptszFullPath);
+ if (dblink == nullptr)
+ return true;
+
+ return dblink->grokHeader(ptszFullPath) != EGROKPRF_NOERROR;
+}
+
+int OpenDatabase(HWND hdlg, INT iNextPage)
+{
+ wchar_t tszMsg[1024];
+ int error = 0;
+
+ 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(GetParent(hdlg), WZM_GOTOPAGE, IDD_OPENERROR, (LPARAM)OpenErrorDlgProc);
+ return true;
+ }
+
+ 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;
+ }
+
+ // force check
+ if (error == EGROKPRF_OBSOLETE) {
+ opts.bAggressive = opts.bBackup = true;
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressDlgProc);
+ }
+ else if (iNextPage == IDD_FILEACCESS)
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc);
+ else
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_PROGRESS, (LPARAM)ProgressDlgProc);
+ return true;
+}
+
+void GetProfileDirectory(wchar_t* szMirandaDir, wchar_t* szPath, int cbPath)
+{
+ wchar_t szProfileDir[MAX_PATH], szExpandedProfileDir[MAX_PATH], szMirandaBootIni[MAX_PATH];
+
+ mir_wstrcpy(szMirandaBootIni, szMirandaDir);
+ mir_wstrcat(szMirandaBootIni, L"\\mirandaboot.ini");
+ GetPrivateProfileString(L"Database", L"ProfileDir", L"./Profiles", szProfileDir, _countof(szProfileDir), szMirandaBootIni);
+ ExpandEnvironmentStrings(szProfileDir, szExpandedProfileDir, _countof(szExpandedProfileDir));
+ _wchdir(szMirandaDir);
+ if (!_wfullpath(szPath, szExpandedProfileDir, cbPath))
+ mir_wstrncpy(szPath, szMirandaDir, cbPath);
+ if (szPath[mir_wstrlen(szPath) - 1] == '\\')
+ szPath[mir_wstrlen(szPath) - 1] = 0;
+}
+
+static int AddDatabaseToList(HWND hwndList, const wchar_t* filename, wchar_t* dir)
+{
+ LV_ITEM lvi;
+ lvi.mask = LVIF_PARAM;
+ lvi.iSubItem = 0;
+ for (lvi.iItem = ListView_GetItemCount(hwndList) - 1; lvi.iItem >= 0; lvi.iItem--) {
+ ListView_GetItem(hwndList, &lvi);
+ if (!mir_wstrcmpi((wchar_t*)lvi.lParam, filename))
+ return lvi.iItem;
+ }
+
+ struct _stat st;
+ if (_wstat(filename, &st) == -1)
+ return -1;
+
+ DWORD totalSize = st.st_size;
+
+ bool isBroken = CheckBroken(filename);
+
+ const wchar_t *pName = wcsrchr(filename, '\\');
+ if (pName == nullptr)
+ pName = (LPTSTR)filename;
+ else
+ pName++;
+
+ wchar_t szName[MAX_PATH];
+ mir_snwprintf(szName, L"%s%s", dir, pName);
+
+ wchar_t *pDot = wcsrchr(szName, '.');
+ if (pDot != nullptr && !mir_wstrcmpi(pDot, L".dat"))
+ *pDot = 0;
+
+ lvi.iItem = 0;
+ lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ lvi.iSubItem = 0;
+ lvi.lParam = (LPARAM)wcsdup(filename);
+ lvi.pszText = szName;
+ lvi.iImage = (isBroken) ? 1 : 0;
+
+ int iNewItem = ListView_InsertItem(hwndList, &lvi);
+ wchar_t szSize[20];
+ mir_snwprintf(szSize, L"%.2lf MB", totalSize / 1048576.0);
+ ListView_SetItemText(hwndList, iNewItem, 1, szSize);
+ return iNewItem;
+}
+
+void FindAdd(HWND hdlg, wchar_t *szProfileDir, wchar_t *szPrefix)
+{
+ HANDLE hFind;
+ WIN32_FIND_DATA fd;
+ wchar_t szSearchPath[MAX_PATH], szFilename[MAX_PATH];
+
+ mir_wstrcpy(szSearchPath, szProfileDir);
+ mir_wstrcat(szSearchPath, L"\\*.*");
+
+ hFind = FindFirstFile(szSearchPath, &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || !mir_wstrcmp(fd.cFileName, L".") || !mir_wstrcmp(fd.cFileName, L".."))
+ continue;
+
+ mir_snwprintf(szFilename, L"%s\\%s\\%s.dat", szProfileDir, fd.cFileName, fd.cFileName);
+ if (_waccess(szFilename, 0) == 0)
+ AddDatabaseToList(GetDlgItem(hdlg, IDC_DBLIST), szFilename, szPrefix);
+ } while (FindNextFile(hFind, &fd));
+ FindClose(hFind);
+ }
+}
+
+wchar_t *addstring(wchar_t *str, wchar_t *add)
+{
+ mir_wstrcpy(str, add);
+ return str + mir_wstrlen(add) + 1;
+}
+
+INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ INT_PTR bReturn;
+ if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
+ return bReturn;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hdlg);
+ {
+ HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 3, 3);
+ ImageList_AddIcon(hIml, LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_PROFILEGREEN)));
+ ImageList_AddIcon(hIml, LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_BAD)));
+ ListView_SetImageList(GetDlgItem(hdlg, IDC_DBLIST), hIml, LVSIL_SMALL);
+ }
+ ListView_SetExtendedListViewStyleEx(GetDlgItem(hdlg, IDC_DBLIST), LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
+ {
+ LV_COLUMN lvc;
+ lvc.mask = LVCF_WIDTH | LVCF_FMT | LVCF_TEXT;
+ lvc.cx = 290;
+ lvc.fmt = LVCFMT_LEFT;
+ lvc.pszText = TranslateT("Database");
+ ListView_InsertColumn(GetDlgItem(hdlg, IDC_DBLIST), 0, &lvc);
+ lvc.cx = 68;
+ lvc.fmt = LVCFMT_RIGHT;
+ lvc.pszText = TranslateT("Total size");
+ ListView_InsertColumn(GetDlgItem(hdlg, IDC_DBLIST), 1, &lvc);
+
+ wchar_t szMirandaPath[MAX_PATH];
+ GetModuleFileName(nullptr, szMirandaPath, _countof(szMirandaPath));
+ wchar_t *str2 = wcsrchr(szMirandaPath, '\\');
+ if (str2 != nullptr)
+ *str2 = 0;
+
+ int i = 0;
+ HKEY hKey;
+ wchar_t szProfileDir[MAX_PATH];
+ wchar_t szMirandaProfiles[MAX_PATH];
+ DWORD cbData = _countof(szMirandaPath);
+
+ mir_wstrcpy(szMirandaProfiles, szMirandaPath);
+ mir_wstrcat(szMirandaProfiles, L"\\Profiles");
+ GetProfileDirectory(szMirandaPath, szProfileDir, _countof(szProfileDir));
+
+ // search in profile dir (using ini file)
+ if (mir_wstrcmpi(szProfileDir, szMirandaProfiles))
+ FindAdd(hdlg, szProfileDir, L"[ini]\\");
+
+ FindAdd(hdlg, szMirandaProfiles, L"[prf]\\");
+ // search in current dir (as DBTOOL)
+ FindAdd(hdlg, szMirandaPath, L"[.]\\");
+
+ // search in profile dir (using registry path + ini file)
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\miranda32.exe", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
+ if (RegQueryValueEx(hKey, L"Path", nullptr, nullptr, (PBYTE)szMirandaPath, &cbData) == ERROR_SUCCESS) {
+ if (mir_wstrcmp(szProfileDir, szMirandaPath)) {
+ GetProfileDirectory(szMirandaPath, szProfileDir, _countof(szProfileDir));
+ FindAdd(hdlg, szProfileDir, L"[reg]\\");
+ }
+ }
+ RegCloseKey(hKey);
+ }
+ // select
+ if (opts.filename[0])
+ i = AddDatabaseToList(GetDlgItem(hdlg, IDC_DBLIST), opts.filename, L"");
+ if (i == -1)
+ i = 0;
+ ListView_SetItemState(GetDlgItem(hdlg, IDC_DBLIST), i, LVIS_SELECTED, LVIS_SELECTED);
+ }
+
+ if (opts.dbChecker != nullptr) {
+ opts.dbChecker->Destroy();
+ opts.dbChecker = nullptr;
+ }
+
+ if (bShortMode)
+ if (!OpenDatabase(hdlg, IDD_FILEACCESS)) {
+ EndDialog(GetParent(hdlg), 1);
+ return FALSE;
+ }
+ return TRUE;
+
+ case WZN_PAGECHANGING:
+ GetDlgItemText(hdlg, IDC_FILE, opts.filename, _countof(opts.filename));
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_FILE:
+ if (HIWORD(wParam) == EN_CHANGE)
+ EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), GetWindowTextLength(GetDlgItem(hdlg, IDC_FILE)));
+ break;
+
+ case IDC_OTHER:
+ {
+ OPENFILENAME ofn = { 0 };
+ wchar_t str[MAX_PATH];
+
+ // L"Miranda Databases (*.dat)\0*.DAT\0All Files (*)\0*\0";
+ wchar_t *filter, *tmp, *tmp1, *tmp2;
+ tmp1 = TranslateT("Miranda Databases (*.dat)");
+ tmp2 = TranslateT("All Files");
+ filter = tmp = (wchar_t*)_alloca((mir_wstrlen(tmp1) + mir_wstrlen(tmp2) + 11)*sizeof(wchar_t));
+ tmp = addstring(tmp, tmp1);
+ tmp = addstring(tmp, L"*.DAT");
+ tmp = addstring(tmp, tmp2);
+ tmp = addstring(tmp, L"*");
+ *tmp = 0;
+
+ GetDlgItemText(hdlg, IDC_FILE, str, _countof(str));
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = hdlg;
+ ofn.hInstance = nullptr;
+ ofn.lpstrFilter = filter;
+ ofn.lpstrDefExt = L"dat";
+ ofn.lpstrFile = str;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+ ofn.nMaxFile = _countof(str);
+ ofn.nMaxFileTitle = MAX_PATH;
+ if (GetOpenFileName(&ofn)) {
+ int i = AddDatabaseToList(GetDlgItem(hdlg, IDC_DBLIST), str, L"");
+ if (i == -1)
+ i = 0;
+ ListView_SetItemState(GetDlgItem(hdlg, IDC_DBLIST), i, LVIS_SELECTED, LVIS_SELECTED);
+ }
+ }
+ break;
+
+ case IDC_BACK:
+ if (!bShortMode)
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_WELCOME, (LPARAM)WelcomeDlgProc);
+ break;
+
+ case IDOK:
+ OpenDatabase(hdlg, IDD_FILEACCESS);
+ break;
+ }
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case IDC_DBLIST:
+ switch (((LPNMLISTVIEW)lParam)->hdr.code) {
+ case LVN_ITEMCHANGED:
+ LV_ITEM lvi;
+ lvi.iItem = ListView_GetNextItem(GetDlgItem(hdlg, IDC_DBLIST), -1, LVNI_SELECTED);
+ if (lvi.iItem == -1) break;
+ lvi.mask = LVIF_PARAM;
+ ListView_GetItem(GetDlgItem(hdlg, IDC_DBLIST), &lvi);
+ SetDlgItemText(hdlg, IDC_FILE, (wchar_t*)lvi.lParam);
+ SendMessage(hdlg, WM_COMMAND, MAKEWPARAM(IDC_FILE, EN_CHANGE), (LPARAM)GetDlgItem(hdlg, IDC_FILE));
+ }
+ break;
+ }
+ break;
+
+ case WM_DESTROY:
+ {
+ LV_ITEM lvi;
+ lvi.mask = LVIF_PARAM;
+ for (lvi.iItem = ListView_GetItemCount(GetDlgItem(hdlg, IDC_DBLIST)) - 1; lvi.iItem >= 0; lvi.iItem--) {
+ ListView_GetItem(GetDlgItem(hdlg, IDC_DBLIST), &lvi);
+ free((char*)lvi.lParam);
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
diff --git a/plugins/DbChecker/src/stdafx.cxx b/plugins/DbChecker/src/stdafx.cxx
new file mode 100644
index 0000000000..18ec0f9dc4
--- /dev/null
+++ b/plugins/DbChecker/src/stdafx.cxx
@@ -0,0 +1,18 @@
+/*
+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" \ No newline at end of file
diff --git a/plugins/DbChecker/src/stdafx.h b/plugins/DbChecker/src/stdafx.h
new file mode 100644
index 0000000000..a12e3e2306
--- /dev/null
+++ b/plugins/DbChecker/src/stdafx.h
@@ -0,0 +1,87 @@
+/*
+Miranda Database Tool
+Copyright 2000-2011 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#pragma once
+
+#include <windows.h>
+#include <process.h>
+#include <malloc.h>
+#include <commctrl.h>
+#include <time.h>
+
+#include <newpluginapi.h>
+#include <m_database.h>
+#include <m_db_int.h>
+#include <m_langpack.h>
+#include <win2k.h>
+
+#include "resource.h"
+#include "version.h"
+
+#define WZM_GOTOPAGE (WM_USER+1)
+#define WZN_PAGECHANGING (WM_USER+1221)
+#define WZN_CANCELCLICKED (WM_USER+1222)
+
+struct DbToolOptions
+{
+ wchar_t filename[MAX_PATH];
+ wchar_t workingFilename[MAX_PATH];
+ wchar_t outputFilename[MAX_PATH];
+ wchar_t backupFilename[MAX_PATH];
+ MDatabaseCommon *db;
+ MIDatabaseChecker *dbChecker;
+ HANDLE hOutFile;
+ DWORD error;
+ int bCheckOnly, bBackup, bAggressive;
+ int bEraseHistory, bMarkRead, bConvertUtf;
+};
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin();
+
+ int Load() override;
+ int Unload() override;
+};
+
+extern DbToolOptions opts;
+extern HANDLE hEventRun, hEventAbort;
+extern int errorCount;
+extern LRESULT wizardResult;
+extern bool bServiceMode, bLaunchMiranda, bShortMode, bAutoExit;
+
+int DoMyControlProcessing(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam, INT_PTR *bReturn);
+
+INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK CleaningDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK FileAccessDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK FinishedDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK WelcomeDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK OpenErrorDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam);
+
+int OpenDatabase(HWND hdlg, INT iNextPage);
+
+#define STATUS_CLASSMASK 0x0f
+void AddToStatus(int flags, const wchar_t* fmt, ...);
+void SetProgressBar(int perThou);
+
diff --git a/plugins/DbChecker/src/version.h b/plugins/DbChecker/src/version.h
new file mode 100644
index 0000000000..3d7b2f3d8b
--- /dev/null
+++ b/plugins/DbChecker/src/version.h
@@ -0,0 +1,13 @@
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 95
+#define __RELEASE_NUM 3
+#define __BUILD_NUM 1
+
+#include <stdver.h>
+
+#define __PLUGIN_NAME "Database checker"
+#define __FILENAME "DbChecker.dll"
+#define __DESCRIPTION "Miranda NG Database Checker."
+#define __AUTHOR "George Hazan"
+#define __AUTHORWEB "https://miranda-ng.org/p/DbChecker/"
+#define __COPYRIGHT "© 2012-18 George Hazan"
diff --git a/plugins/DbChecker/src/welcome.cpp b/plugins/DbChecker/src/welcome.cpp
new file mode 100644
index 0000000000..55d279e403
--- /dev/null
+++ b/plugins/DbChecker/src/welcome.cpp
@@ -0,0 +1,71 @@
+/*
+Miranda Database Tool
+Copyright (C) 2001-2005 Richard Hughes
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+INT_PTR CALLBACK WelcomeDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ static HENHMETAFILE hEmfWatermark;
+ static HFONT hTitleFont;
+
+ INT_PTR bReturn;
+ if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
+ return bReturn;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ {
+ HRSRC hRsrcWatermark = FindResourceA(g_plugin.getInst(), MAKEINTRESOURCEA(IDE_WATERMARK), "EMF");
+ HGLOBAL hGlobWatermark = LoadResource(g_plugin.getInst(), hRsrcWatermark);
+ hEmfWatermark = SetEnhMetaFileBits(SizeofResource(g_plugin.getInst(), hRsrcWatermark), (PBYTE)LockResource(hGlobWatermark));
+ }
+ SendDlgItemMessage(hdlg, IDC_WATERMARK, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hEmfWatermark);
+ {
+ NONCLIENTMETRICS ncm = { 0 };
+ ncm.cbSize = sizeof(ncm);
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
+ LOGFONT TitleLogFont = ncm.lfMessageFont;
+ TitleLogFont.lfWeight = FW_BOLD;
+ mir_wstrcpy(TitleLogFont.lfFaceName, TEXT("Verdana Bold"));
+
+ HDC hdc = GetDC(nullptr);
+ INT FontSize = 12;
+ TitleLogFont.lfHeight = 0 - GetDeviceCaps(hdc, LOGPIXELSY) * FontSize / 72;
+ hTitleFont = CreateFontIndirect(&TitleLogFont);
+ ReleaseDC(nullptr, hdc);
+ }
+ SendDlgItemMessage(hdlg, IDC_TITLE, WM_SETFONT, (WPARAM)hTitleFont, 0);
+ EnableWindow(GetDlgItem(GetParent(hdlg), IDC_BACK), FALSE);
+ return FALSE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc);
+ break;
+ }
+ break;
+
+ case WM_DESTROY:
+ DeleteEnhMetaFile(hEmfWatermark);
+ DeleteObject(hTitleFont);
+ break;
+ }
+ return FALSE;
+}
diff --git a/plugins/DbChecker/src/wizard.cpp b/plugins/DbChecker/src/wizard.cpp
new file mode 100644
index 0000000000..c69633794b
--- /dev/null
+++ b/plugins/DbChecker/src/wizard.cpp
@@ -0,0 +1,157 @@
+/*
+Miranda Database Tool
+Copyright 2000-2011 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+static HFONT hBoldFont = nullptr;
+static HENHMETAFILE hEmfHeaderLogo = nullptr;
+
+static BOOL CALLBACK MyControlsEnumChildren(HWND hwnd, LPARAM)
+{
+ DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
+ DWORD exstyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
+ char szClass[64];
+ int makeBold = 0;
+
+ 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;
+ }
+ else if (!mir_strcmp(szClass, "Button")) {
+ if (exstyle&WS_EX_CLIENTEDGE)
+ makeBold = 1;
+ }
+ if (makeBold) {
+ if (hBoldFont == nullptr) {
+ LOGFONT lf;
+ hBoldFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
+ GetObject(hBoldFont, sizeof(lf), &lf);
+ lf.lfWeight = FW_BOLD;
+ hBoldFont = CreateFontIndirect(&lf);
+ }
+ SendMessage(hwnd, WM_SETFONT, (WPARAM)hBoldFont, 0);
+ SetWindowLongPtr(hwnd, GWL_EXSTYLE, exstyle&~WS_EX_CLIENTEDGE);
+ SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
+ }
+ return TRUE;
+}
+
+int DoMyControlProcessing(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam, INT_PTR *bReturn)
+{
+ 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;
+ }
+ else {
+ SetBkMode((HDC)wParam, TRANSPARENT);
+ *bReturn = (INT_PTR)GetStockObject(NULL_BRUSH);
+ return TRUE;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ static HWND hdlgPage;
+
+ switch (message) {
+ case WM_INITDIALOG:
+ SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_DBTOOL)));
+ hdlgPage = nullptr;
+ if (bShortMode)
+ SendMessage(hdlg, WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc);
+ else
+ SendMessage(hdlg, WZM_GOTOPAGE, IDD_WELCOME, (LPARAM)WelcomeDlgProc);
+ TranslateDialogDefault(hdlg);
+ return TRUE;
+
+ case WZM_GOTOPAGE:
+ if (hdlgPage != nullptr) DestroyWindow(hdlgPage);
+ EnableWindow(GetDlgItem(hdlg, IDC_BACK), TRUE);
+ EnableWindow(GetDlgItem(hdlg, IDOK), TRUE);
+ EnableWindow(GetDlgItem(hdlg, IDCANCEL), TRUE);
+ SetDlgItemText(hdlg, IDCANCEL, TranslateT("Cancel"));
+ hdlgPage = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(wParam), hdlg, (DLGPROC)lParam);
+ 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 IDC_BACK:
+ 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;
+
+ case WM_DESTROY:
+ if (opts.dbChecker) {
+ opts.dbChecker->Destroy();
+ opts.dbChecker = nullptr;
+ }
+
+ if (opts.hOutFile)
+ CloseHandle(opts.hOutFile);
+
+ DestroyWindow(hdlgPage);
+ if (hBoldFont != nullptr) {
+ DeleteObject(hBoldFont);
+ hBoldFont = nullptr;
+ }
+ if (hEmfHeaderLogo != nullptr) {
+ DeleteEnhMetaFile(hEmfHeaderLogo);
+ hEmfHeaderLogo = nullptr;
+ }
+ break;
+ }
+ return FALSE;
+}
diff --git a/plugins/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp
new file mode 100644
index 0000000000..ff5a076191
--- /dev/null
+++ b/plugins/DbChecker/src/worker.cpp
@@ -0,0 +1,148 @@
+/*
+Miranda Database Tool
+Copyright (C) 2001-2005 Richard Hughes
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+void ProcessingDone(void);
+
+static void Finalize(time_t& ts)
+{
+ opts.dbChecker->Destroy();
+ opts.dbChecker = nullptr;
+
+ if (opts.hOutFile) {
+ CloseHandle(opts.hOutFile);
+ opts.hOutFile = nullptr;
+ }
+
+ if (errorCount && !opts.bBackup && !opts.bCheckOnly) {
+ time_t dlg_ts = time(nullptr);
+ if (IDYES == MessageBox(nullptr,
+ TranslateT("Errors were encountered, however you selected not to backup the original database. It is strongly recommended that you do so in case important data was omitted. Do you wish to keep a backup of the original database?"),
+ TranslateT("Miranda Database Tool"), MB_YESNO))
+ opts.bBackup = 1;
+ ts += time(nullptr) - dlg_ts;
+ }
+
+ if (opts.bBackup) {
+ wchar_t dbPath[MAX_PATH], dbFile[MAX_PATH];
+ mir_wstrcpy(dbPath, opts.filename);
+ wchar_t* str2 = wcsrchr(dbPath, '\\');
+ if (str2 != nullptr) {
+ mir_wstrcpy(dbFile, str2 + 1);
+ *str2 = 0;
+ }
+ else {
+ mir_wstrcpy(dbFile, dbPath);
+ dbPath[0] = 0;
+ }
+ for (int i = 1;; i++) {
+ if (i == 1)
+ mir_snwprintf(opts.backupFilename, TranslateT("%s\\Backup of %s"), dbPath, dbFile);
+ else
+ mir_snwprintf(opts.backupFilename, TranslateT("%s\\Backup (%d) of %s"), dbPath, i, dbFile);
+ if (_waccess(opts.backupFilename, 0) == -1) break;
+ }
+
+ if (!MoveFile(opts.filename, opts.backupFilename))
+ AddToStatus(STATUS_WARNING, TranslateT("Unable to rename original file"));
+ }
+ else if (!opts.bCheckOnly)
+ if (!DeleteFile(opts.filename))
+ AddToStatus(STATUS_WARNING, TranslateT("Unable to delete original file"));
+
+ if (!opts.bCheckOnly)
+ if (!MoveFile(opts.outputFilename, opts.filename))
+ AddToStatus(STATUS_WARNING, TranslateT("Unable to rename output file"));
+}
+
+void __cdecl WorkerThread(void *)
+{
+ int task, firstTime;
+ time_t ts = time(nullptr);
+
+ AddToStatus(STATUS_MESSAGE, TranslateT("Database worker thread activated"));
+
+ mir_wstrcpy(opts.workingFilename, opts.filename);
+
+ if (opts.bCheckOnly) {
+ mir_wstrcpy(opts.outputFilename, TranslateT("<check only>"));
+ opts.hOutFile = INVALID_HANDLE_VALUE;
+ }
+ else {
+ mir_wstrcpy(opts.outputFilename, opts.filename);
+ *wcsrchr(opts.outputFilename, '.') = 0;
+ mir_wstrcat(opts.outputFilename, TranslateT(" (Output).dat"));
+ opts.hOutFile = CreateFile(opts.outputFilename, GENERIC_WRITE, FILE_SHARE_READ, nullptr, CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN, nullptr);
+ if (opts.hOutFile == INVALID_HANDLE_VALUE) {
+ AddToStatus(STATUS_FATAL, TranslateT("Can't create output file (%u)"), GetLastError());
+ ProcessingDone();
+ return;
+ }
+ }
+
+ DWORD sp = 0;
+ firstTime = 0;
+
+ DBCHeckCallback callback;
+ callback.cbSize = sizeof(callback);
+ callback.spaceUsed = 1;
+ callback.spaceProcessed = 0;
+ callback.pfnAddLogMessage = AddToStatus;
+ callback.hOutFile = opts.hOutFile;
+ callback.bCheckOnly = opts.bCheckOnly;
+ callback.bBackup = opts.bBackup;
+ callback.bAggressive = opts.bAggressive;
+ callback.bEraseHistory = opts.bEraseHistory;
+ callback.bMarkRead = opts.bMarkRead;
+ callback.bConvertUtf = opts.bConvertUtf;
+ opts.dbChecker->Start(&callback);
+
+ for (task = 0;;) {
+ if (callback.spaceProcessed / (callback.spaceUsed / 1000 + 1) > sp) {
+ sp = callback.spaceProcessed / (callback.spaceUsed / 1000 + 1);
+ SetProgressBar(sp);
+ }
+ WaitForSingleObject(hEventRun, INFINITE);
+ if (WaitForSingleObject(hEventAbort, 0) == WAIT_OBJECT_0) {
+ AddToStatus(STATUS_FATAL, TranslateT("Processing aborted by user"));
+ break;
+ }
+
+ int ret = opts.dbChecker->CheckDb(task, firstTime);
+ firstTime = 0;
+ if (ret == ERROR_OUT_OF_PAPER) {
+ Finalize(ts);
+ AddToStatus(STATUS_MESSAGE, TranslateT("Elapsed time: %d sec"), time(nullptr) - ts);
+ if (errorCount)
+ AddToStatus(STATUS_SUCCESS, TranslateT("All tasks completed but with errors (%d)"), errorCount);
+ else
+ AddToStatus(STATUS_SUCCESS, TranslateT("All tasks completed successfully"));
+ break;
+ }
+ else if (ret == ERROR_NO_MORE_ITEMS) {
+ task++;
+ firstTime = 1;
+ }
+ else if (ret != ERROR_SUCCESS)
+ break;
+ }
+
+ ProcessingDone();
+}
diff --git a/plugins/Dbx_mdbx/dbx_mdbx.vcxproj b/plugins/Dbx_mdbx/dbx_mdbx.vcxproj
index f79541e90f..376b0734aa 100644
--- a/plugins/Dbx_mdbx/dbx_mdbx.vcxproj
+++ b/plugins/Dbx_mdbx/dbx_mdbx.vcxproj
@@ -31,6 +31,7 @@
<Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" />
</ImportGroup>
<ItemGroup>
+ <ClCompile Include="src\dbcheck.cpp" />
<ClCompile Include="src\dbcontacts.cpp" />
<ClCompile Include="src\dbcrypt.cpp" />
<ClCompile Include="src\dbevents.cpp" />
diff --git a/plugins/Dbx_mdbx/dbx_mdbx.vcxproj.filters b/plugins/Dbx_mdbx/dbx_mdbx.vcxproj.filters
index df30e9da3f..06ca8b9103 100644
--- a/plugins/Dbx_mdbx/dbx_mdbx.vcxproj.filters
+++ b/plugins/Dbx_mdbx/dbx_mdbx.vcxproj.filters
@@ -32,6 +32,9 @@
<ClCompile Include="src\ui.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\dbcheck.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\dbintf.h">
diff --git a/plugins/Dbx_mdbx/src/dbcheck.cpp b/plugins/Dbx_mdbx/src/dbcheck.cpp
new file mode 100644
index 0000000000..e636e196c4
--- /dev/null
+++ b/plugins/Dbx_mdbx/src/dbcheck.cpp
@@ -0,0 +1,29 @@
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright (C) 2012-20 Miranda NG team (https://miranda-ng.org)
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+int CDbxMDBX::CheckEvents1(void)
+{
+ return 0;
+}
diff --git a/plugins/Dbx_mdbx/src/dbintf.cpp b/plugins/Dbx_mdbx/src/dbintf.cpp
index 328a981880..6822eda603 100644
--- a/plugins/Dbx_mdbx/src/dbintf.cpp
+++ b/plugins/Dbx_mdbx/src/dbintf.cpp
@@ -289,3 +289,32 @@ void CDbxMDBX::DBFlush(bool bForce)
else if (m_safetyMode)
m_impl.m_timer.Start(50);
}
+
+///////////////////////////////////////////////////////////////////////////////
+// MIDatabaseChecker
+
+typedef int (CDbxMDBX::*CheckWorker)(void);
+
+int CDbxMDBX::Start(DBCHeckCallback *callback)
+{
+ cb = callback;
+ return ERROR_SUCCESS;
+}
+
+static CheckWorker Workers[] =
+{
+ &CDbxMDBX::CheckEvents1
+};
+
+int CDbxMDBX::CheckDb(int phase, int)
+{
+ if (phase >= _countof(Workers))
+ return ERROR_OUT_OF_PAPER;
+
+ return (this->*Workers[phase])();
+}
+
+void CDbxMDBX::Destroy()
+{
+ delete this;
+}
diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h
index 0a29c30a78..a16b7f85ee 100644
--- a/plugins/Dbx_mdbx/src/dbintf.h
+++ b/plugins/Dbx_mdbx/src/dbintf.h
@@ -136,7 +136,7 @@ struct EventItem
MEVENT eventId;
};
-class CDbxMDBX : public MDatabaseCommon, public MZeroedObject
+class CDbxMDBX : public MDatabaseCommon, public MIDatabaseChecker, public MZeroedObject
{
friend class CMdbxEventCursor;
@@ -251,6 +251,8 @@ public:
void StoreKey(void);
void SetPassword(const wchar_t *ptszPassword);
+ int CheckEvents1(void);
+
__forceinline LPSTR GetMenuTitle() const { return m_bUsesPassword ? (char*)LPGEN("Change/remove password") : (char*)LPGEN("Set password"); }
__forceinline bool isEncrypted() const { return m_bEncrypted; }
@@ -300,6 +302,18 @@ public:
STDMETHODIMP_(DB::EventCursor *) EventCursor(MCONTACT hContact, MEVENT hDbEvent) override;
STDMETHODIMP_(DB::EventCursor *) EventCursorRev(MCONTACT hContact, MEVENT hDbEvent) override;
+protected:
+ STDMETHODIMP_(MIDatabaseChecker *) GetChecker() override
+ {
+ return this;
+ }
+
+ STDMETHODIMP_(BOOL) Start(DBCHeckCallback *callback);
+ STDMETHODIMP_(BOOL) CheckDb(int phase, int firstTime);
+ STDMETHODIMP_(VOID) Destroy();
+
+ DBCHeckCallback *cb;
+
public:
MICryptoEngine *m_crypto;
};
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index 5466da6696..3ceb55a222 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -546,7 +546,6 @@ static renameTable[] =
{ L"advaimg.dll", nullptr },
{ L"aim.dll", nullptr },
- { L"dbchecker.dll", nullptr },
{ L"extraicons.dll", nullptr },
{ L"firstrun.dll", nullptr },
{ L"flashavatars.dll", nullptr },
diff --git a/src/mir_app/src/MDatabaseCommon.cpp b/src/mir_app/src/MDatabaseCommon.cpp
index db72861928..5e5feacd56 100644
--- a/src/mir_app/src/MDatabaseCommon.cpp
+++ b/src/mir_app/src/MDatabaseCommon.cpp
@@ -355,6 +355,13 @@ STDMETHODIMP_(BOOL) MDatabaseCommon::SetSettingResident(BOOL bIsResident, const
}
/////////////////////////////////////////////////////////////////////////////////////////
+
+STDMETHODIMP_(MIDatabaseChecker *) MDatabaseCommon::GetChecker()
+{
+ return nullptr;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Event cursors
STDMETHODIMP_(DB::EventCursor *) MDatabaseCommon::EventCursor(MCONTACT, MEVENT)
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 73c6f0edf6..81f35ed7c4 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -738,3 +738,4 @@ Chat_CreateMenu @824 NONAME
?Proto_GetInstance@@YGPAUPROTO_INTERFACE@@I@Z @826 NONAME
?Proto_GetInstance@@YGPAUPROTO_INTERFACE@@PBD@Z @827 NONAME
?OnEventEdited@PROTO_INTERFACE@@UAEXII@Z @828 NONAME
+?GetChecker@MDatabaseCommon@@UAGPAUMIDatabaseChecker@@XZ @829 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 9dcb0e0cab..1d5ffc95a3 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -738,3 +738,4 @@ Chat_CreateMenu @824 NONAME
?Proto_GetInstance@@YAPEAUPROTO_INTERFACE@@I@Z @826 NONAME
?Proto_GetInstance@@YAPEAUPROTO_INTERFACE@@PEBD@Z @827 NONAME
?OnEventEdited@PROTO_INTERFACE@@UEAAXII@Z @828 NONAME
+?GetChecker@MDatabaseCommon@@UEAAPEAUMIDatabaseChecker@@XZ @829 NONAME
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp
index 207e74ecc8..b82164ebd3 100644
--- a/src/mir_app/src/newplugins.cpp
+++ b/src/mir_app/src/newplugins.cpp
@@ -110,7 +110,6 @@ static const MUUID pluginBannedList[] =
{ 0x1e64fd80, 0x299e, 0x48a0, { 0x94, 0x41, 0xde, 0x28, 0x68, 0x56, 0x3b, 0x6f } }, // stdhelp
{ 0x3750a5a3, 0xbf0d, 0x490e, { 0xb6, 0x5d, 0x41, 0xac, 0x4d, 0x29, 0xae, 0xb3 } }, // aim
{ 0x7c070f7c, 0x459e, 0x46b7, { 0x8e, 0x6d, 0xbc, 0x6e, 0xfa, 0xa2, 0x2f, 0x78 } }, // advaimg
- { 0xa0138fc6, 0x4c52, 0x4501, { 0xaf, 0x93, 0x7d, 0x3e, 0x20, 0xbc, 0xae, 0x5b } }, // dbchecker
{ 0x53ac190b, 0xe223, 0x4341, { 0x82, 0x5f, 0x70, 0x9d, 0x85, 0x20, 0x21, 0x5b } }, // stdidle
{ 0x6f376b33, 0xd3f4, 0x4c4f, { 0xa9, 0x6b, 0x77, 0xda, 0x08, 0x04, 0x3b, 0x06 } }, // importtxt
{ 0xe7c48bab, 0x8ace, 0x4cb3, { 0x84, 0x46, 0xd4, 0xb7, 0x34, 0x81, 0xf4, 0x97 } }, // mra