summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-27 15:33:58 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-27 15:33:58 +0000
commitdf77e258df8cec689a001ec92031538298661b1b (patch)
tree56ec236ca9675f049c4806e8d41986c40b537f07
parent414ffc78d69f09d48fc43051e0806a30e8fb5c67 (diff)
merge of dbtool & database plugins
git-svn-id: http://svn.miranda-ng.org/main/trunk@1213 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_db_int.h29
-rw-r--r--include/newpluginapi.h14
-rw-r--r--plugins/Db3x/db3x_10.vcxproj27
-rw-r--r--plugins/Db3x/db3x_10.vcxproj.filters30
-rw-r--r--plugins/Db3x/src/init.cpp23
-rw-r--r--plugins/Db3x_mmap/db3x_mmap_10.vcxproj27
-rw-r--r--plugins/Db3x_mmap/db3x_mmap_10.vcxproj.filters3
-rw-r--r--plugins/Db3x_mmap/src/dbheaders.cpp12
-rw-r--r--plugins/Db3x_mmap/src/dbintf.cpp34
-rw-r--r--plugins/Db3x_mmap/src/dbintf.h52
-rw-r--r--plugins/Db3x_mmap/src/dbintfm.cpp6
-rw-r--r--plugins/Db3x_mmap/src/dbsettings.cpp2
-rw-r--r--plugins/Db3x_mmap/src/dbtool/aggressive.cpp42
-rw-r--r--plugins/Db3x_mmap/src/dbtool/contactchain.cpp24
-rw-r--r--plugins/Db3x_mmap/src/dbtool/disk.cpp62
-rw-r--r--plugins/Db3x_mmap/src/dbtool/eventchain.cpp54
-rw-r--r--plugins/Db3x_mmap/src/dbtool/finaltasks.cpp64
-rw-r--r--plugins/Db3x_mmap/src/dbtool/initialchecks.cpp71
-rw-r--r--plugins/Db3x_mmap/src/dbtool/modulechain.cpp27
-rw-r--r--plugins/Db3x_mmap/src/dbtool/settingschain.cpp10
-rw-r--r--plugins/Db3x_mmap/src/dbtool/user.cpp59
-rw-r--r--plugins/Db3x_mmap/src/init.cpp63
-rw-r--r--plugins/DbChecker/src/dbchecker.h16
-rw-r--r--plugins/DbChecker/src/selectdb.cpp3
-rw-r--r--plugins/DbChecker/src/worker.cpp85
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj232
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters107
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/res/Version.rc42
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/res/dbtool.bmpbin66872 -> 0 bytes
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/res/dbtool.exe.manifest31
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/res/dbtool.icobin9062 -> 0 bytes
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/res/delete.icobin2550 -> 0 bytes
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/res/profileg.icobin2550 -> 0 bytes
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/res/profiler.icobin2550 -> 0 bytes
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/res/profiley.icobin2550 -> 0 bytes
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/res/resource.rc368
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/Version.h9
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/aggressive.cpp59
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/cleaning.cpp63
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/contactchain.cpp105
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/database.h179
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/dbtool.h106
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/disk.cpp112
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/encryption.cpp299
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/eventchain.cpp363
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/fileaccess.cpp69
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/finaltasks.cpp78
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/finished.cpp82
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/initialchecks.cpp98
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/main.cpp33
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/modulechain.cpp146
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/openerror.cpp55
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/progress.cpp213
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/resource.h58
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/selectdb.cpp303
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/settingschain.cpp72
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/user.cpp71
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/utf.cpp69
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/welcome.cpp61
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/wizard.cpp137
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/src/worker.cpp76
-rw-r--r--plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj27
-rw-r--r--plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters30
-rw-r--r--plugins/Dbx_mmap_SA/src/dbintf_sa.cpp30
-rw-r--r--plugins/Dbx_mmap_SA/src/dbintf_sa.h2
-rw-r--r--plugins/Dbx_mmap_SA/src/init.cpp23
-rw-r--r--plugins/Dbx_tree/DatabaseLink.cpp1
67 files changed, 593 insertions, 4055 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h
index e5e786cd66..64bbcbd9e5 100644
--- a/include/m_db_int.h
+++ b/include/m_db_int.h
@@ -72,23 +72,46 @@ interface MIDatabase
///////////////////////////////////////////////////////////////////////////////
// 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;
+ int cbSize;
+ DWORD spaceProcessed, spaceUsed;
+ HANDLE hOutFile;
+ int bCheckOnly, bBackup, bAggressive, bEraseHistory, bMarkRead, bConvertUtf;
void (*pfnAddLogMessage)(int type, const TCHAR* ptszFormat, ...);
};
interface MIDatabaseChecker
{
- STDMETHOD_(BOOL,CheckDb)(DBCHeckCallback *callback, int phase, int firstTime) PURE;
+ STDMETHOD_(BOOL,Start)(DBCHeckCallback *callback) PURE;
+ STDMETHOD_(BOOL,CheckDb)(int phase, int firstTime) PURE;
STDMETHOD_(VOID,Destroy)() PURE;
};
///////////////////////////////////////////////////////////////////////////////
// Each database plugin should register itself using this structure
+/*
+ Codes for DATABASELINK functions
+*/
+
+// grokHeader() error codes
+#define EGROKPRF_NOERROR 0
+#define EGROKPRF_CANTREAD 1 // can't open the profile for reading
+#define EGROKPRF_UNKHEADER 2 // header not supported, not a supported profile
+#define EGROKPRF_VERNEWER 3 // header correct, version in profile newer than reader/writer
+#define EGROKPRF_DAMAGED 4 // header/version fine, other internal data missing, damaged.
+
+// makeDatabase() error codes
+#define EMKPRF_CREATEFAILED 1 // for some reason CreateFile() didnt like something
+
struct DATABASELINK
{
int cbSize;
diff --git a/include/newpluginapi.h b/include/newpluginapi.h
index 5d2ed29b00..93e8d472f7 100644
--- a/include/newpluginapi.h
+++ b/include/newpluginapi.h
@@ -134,18 +134,4 @@ typedef struct PLUGININFOEX_tag
//lParam = HINSTANCE of the plugin to be unloaded
#define ME_SYSTEM_MODULEUNLOAD "Miranda/System/UnloadModule"
-/*
- Database plugin stuff
-*/
-
-// grokHeader() error codes
-#define EGROKPRF_NOERROR 0
-#define EGROKPRF_CANTREAD 1 // can't open the profile for reading
-#define EGROKPRF_UNKHEADER 2 // header not supported, not a supported profile
-#define EGROKPRF_VERNEWER 3 // header correct, version in profile newer than reader/writer
-#define EGROKPRF_DAMAGED 4 // header/version fine, other internal data missing, damaged.
-
-// makeDatabase() error codes
-#define EMKPRF_CREATEFAILED 1 // for some reason CreateFile() didnt like something
-
#endif // M_NEWPLUGINAPI_H__
diff --git a/plugins/Db3x/db3x_10.vcxproj b/plugins/Db3x/db3x_10.vcxproj
index ca0c4a5cbd..a3424d5068 100644
--- a/plugins/Db3x/db3x_10.vcxproj
+++ b/plugins/Db3x/db3x_10.vcxproj
@@ -206,6 +206,33 @@
<ClCompile Include="..\db3x_mmap\src\dbintf.cpp" />
<ClCompile Include="..\db3x_mmap\src\dbmodulechain.cpp" />
<ClCompile Include="..\db3x_mmap\src\dbsettings.cpp" />
+ <ClCompile Include="..\db3x_mmap\src\dbtool\aggressive.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\contactchain.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\disk.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\eventchain.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\finaltasks.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\initialchecks.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\modulechain.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\settingschain.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\user.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
<ClCompile Include="src\dbcache3x.cpp" />
<ClCompile Include="src\dbintf3x.cpp" />
<ClCompile Include="src\init.cpp">
diff --git a/plugins/Db3x/db3x_10.vcxproj.filters b/plugins/Db3x/db3x_10.vcxproj.filters
index a5829dde98..59595fa5ab 100644
--- a/plugins/Db3x/db3x_10.vcxproj.filters
+++ b/plugins/Db3x/db3x_10.vcxproj.filters
@@ -16,6 +16,9 @@
<Filter Include="Mmap">
<UniqueIdentifier>{640c5715-0e22-4240-8520-f7dedfc9fb87}</UniqueIdentifier>
</Filter>
+ <Filter Include="Mmap\Checker">
+ <UniqueIdentifier>{1603e383-8555-4ad2-b245-83442f3c44ee}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\init.cpp">
@@ -48,6 +51,33 @@
<ClCompile Include="..\db3x_mmap\src\dbsettings.cpp">
<Filter>Mmap</Filter>
</ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\aggressive.cpp">
+ <Filter>Mmap\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\user.cpp">
+ <Filter>Mmap\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\contactchain.cpp">
+ <Filter>Mmap\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\disk.cpp">
+ <Filter>Mmap\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\eventchain.cpp">
+ <Filter>Mmap\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\finaltasks.cpp">
+ <Filter>Mmap\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\initialchecks.cpp">
+ <Filter>Mmap\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\modulechain.cpp">
+ <Filter>Mmap\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\settingschain.cpp">
+ <Filter>Mmap\Checker</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\commonheaders.h">
diff --git a/plugins/Db3x/src/init.cpp b/plugins/Db3x/src/init.cpp
index 406db891a6..6f021aa283 100644
--- a/plugins/Db3x/src/init.cpp
+++ b/plugins/Db3x/src/init.cpp
@@ -121,6 +121,26 @@ static int UnloadDatabase(MIDatabase* db)
return 0;
}
+MIDatabaseChecker* CheckDb(const TCHAR* ptszFileName, int *error)
+{
+ CDb3x *tmp = new CDb3x(ptszFileName);
+ if (tmp->Load(true) != ERROR_SUCCESS) {
+ delete tmp;
+ if (error != NULL) *error = EGROKPRF_CANTREAD;
+ return NULL;
+ }
+
+ int chk = tmp->CheckDbHeaders();
+ if (chk != ERROR_SUCCESS) {
+ delete tmp;
+ *error = chk;
+ return NULL;
+ }
+
+ *error = 0;
+ return tmp;
+}
+
static DATABASELINK dblink =
{
sizeof(DATABASELINK),
@@ -129,7 +149,8 @@ static DATABASELINK dblink =
makeDatabase,
grokHeader,
LoadDatabase,
- UnloadDatabase
+ UnloadDatabase,
+ CheckDb
};
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Db3x_mmap/db3x_mmap_10.vcxproj b/plugins/Db3x_mmap/db3x_mmap_10.vcxproj
index bc2127c679..4a246247a0 100644
--- a/plugins/Db3x_mmap/db3x_mmap_10.vcxproj
+++ b/plugins/Db3x_mmap/db3x_mmap_10.vcxproj
@@ -209,36 +209,31 @@
<ClCompile Include="src\dbmodulechain.cpp" />
<ClCompile Include="src\dbsettings.cpp" />
<ClCompile Include="src\dbtool\aggressive.cpp">
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
- <ExcludedFromBuild>true</ExcludedFromBuild>
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="src\dbtool\contactchain.cpp">
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
- <ExcludedFromBuild>true</ExcludedFromBuild>
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\disk.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="src\dbtool\eventchain.cpp">
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
- <ExcludedFromBuild>true</ExcludedFromBuild>
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="src\dbtool\finaltasks.cpp">
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
- <ExcludedFromBuild>true</ExcludedFromBuild>
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="src\dbtool\initialchecks.cpp">
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
- <ExcludedFromBuild>true</ExcludedFromBuild>
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="src\dbtool\modulechain.cpp">
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
- <ExcludedFromBuild>true</ExcludedFromBuild>
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="src\dbtool\settingschain.cpp">
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
- <ExcludedFromBuild>true</ExcludedFromBuild>
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="src\dbtool\user.cpp">
- <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
- <ExcludedFromBuild>true</ExcludedFromBuild>
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="src\init.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
diff --git a/plugins/Db3x_mmap/db3x_mmap_10.vcxproj.filters b/plugins/Db3x_mmap/db3x_mmap_10.vcxproj.filters
index 23c6351e22..302caf3045 100644
--- a/plugins/Db3x_mmap/db3x_mmap_10.vcxproj.filters
+++ b/plugins/Db3x_mmap/db3x_mmap_10.vcxproj.filters
@@ -72,6 +72,9 @@
<ClCompile Include="src\dbtool\user.cpp">
<Filter>Source Files\Checker</Filter>
</ClCompile>
+ <ClCompile Include="src\dbtool\disk.cpp">
+ <Filter>Source Files\Checker</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\commonheaders.h">
diff --git a/plugins/Db3x_mmap/src/dbheaders.cpp b/plugins/Db3x_mmap/src/dbheaders.cpp
index 394b66acfc..68e7da15e1 100644
--- a/plugins/Db3x_mmap/src/dbheaders.cpp
+++ b/plugins/Db3x_mmap/src/dbheaders.cpp
@@ -58,8 +58,14 @@ int CDb3Base::CreateDbHeaders()
int CDb3Base::CheckDbHeaders()
{
- if (memcmp(m_dbHeader.signature, &dbSignature, sizeof(m_dbHeader.signature))) return 1;
- if (m_dbHeader.version != DB_THIS_VERSION) return 2;
- if (m_dbHeader.ofsUser == 0) return 3;
+ if (memcmp(m_dbHeader.signature, &dbSignature, sizeof(m_dbHeader.signature)))
+ return EGROKPRF_UNKHEADER;
+
+ if (m_dbHeader.version != DB_THIS_VERSION)
+ return EGROKPRF_VERNEWER;
+
+ if (m_dbHeader.ofsUser == 0)
+ return EGROKPRF_DAMAGED;
+
return 0;
}
diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp
index 0479be3691..84ddc64468 100644
--- a/plugins/Db3x_mmap/src/dbintf.cpp
+++ b/plugins/Db3x_mmap/src/dbintf.cpp
@@ -94,6 +94,9 @@ CDb3Base::~CDb3Base()
UnmapViewOfFile(m_pDbCache);
}
+ if (m_hMap)
+ CloseHandle(m_hMap);
+
// update profile last modified time
DWORD bytesWritten;
SetFilePointer(m_hDbFile, 0, NULL, FILE_BEGIN);
@@ -168,3 +171,34 @@ void CDb3Base::DecodeDBWrite(DWORD ofs, void *src, int size)
DBWrite(ofs, src, size);
}
+///////////////////////////////////////////////////////////////////////////////
+// MIDatabaseChecker
+
+static CheckWorker Workers[6] =
+{
+ &CDb3Base::WorkInitialChecks,
+ &CDb3Base::WorkModuleChain,
+ &CDb3Base::WorkUser,
+ &CDb3Base::WorkContactChain,
+ &CDb3Base::WorkAggressive,
+ &CDb3Base::WorkFinalTasks
+};
+
+int CDb3Base::Start(DBCHeckCallback *callback)
+{
+ cb = callback;
+ return ERROR_SUCCESS;
+}
+
+int CDb3Base::CheckDb(int phase, int firstTime)
+{
+ if (phase >= SIZEOF(Workers))
+ return ERROR_OUT_OF_PAPER;
+
+ return (this->*Workers[phase])(firstTime);
+}
+
+void CDb3Base::Destroy()
+{
+ delete this;
+}
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h
index c13bdc5eb0..f3d04d0959 100644
--- a/plugins/Db3x_mmap/src/dbintf.h
+++ b/plugins/Db3x_mmap/src/dbintf.h
@@ -47,6 +47,9 @@ DBHeader
#define DB_THIS_VERSION 0x00000700u
#define DB_SETTINGS_RESIZE_GRANULARITY 128
+#define WSOFS_END 0xFFFFFFFF
+#define WS_ERROR 0xFFFFFFFF
+
struct DBSignature {
char name[15];
BYTE eof;
@@ -156,7 +159,7 @@ struct DBCachedContactValueList
#define MAXCACHEDREADSIZE 65536
-struct CDb3Base : public MIDatabase, public MZeroedObject
+struct CDb3Base : public MIDatabase, public MIDatabaseChecker, public MZeroedObject
{
CDb3Base(const TCHAR* tszFileName);
~CDb3Base();
@@ -205,8 +208,14 @@ protected:
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
protected:
+ STDMETHODIMP_(BOOL) Start(DBCHeckCallback *callback);
+ STDMETHODIMP_(BOOL) CheckDb(int phase, int firstTime);
+ STDMETHODIMP_(VOID) Destroy();
+
+protected:
virtual DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc,DWORD ofsContact,DWORD ofsModuleName) = 0;
- virtual void InvalidateSettingsGroupOfsCacheEntry(DWORD ofsSettingsGroup) {}
+ virtual void InvalidateSettingsGroupOfsCacheEntry(DWORD ofsSettingsGroup) {}
+ virtual int WorkInitialCheckHeaders(void);
virtual void DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes) = 0;
virtual PBYTE DBRead(DWORD ofs, int bytesRequired, int *bytesAvail) = 0;
@@ -222,12 +231,12 @@ protected:
virtual void DecodeDBWrite(DWORD ofs, void *src, int size);
public: // Check functions
- int WorkInitialChecks(DBCHeckCallback*, int);
- int WorkModuleChain(DBCHeckCallback*, int);
- int WorkUser(DBCHeckCallback*, int);
- int WorkContactChain(DBCHeckCallback*, int);
- int WorkAggressive(DBCHeckCallback*, int);
- int WorkFinalTasks(DBCHeckCallback*, int);
+ int WorkInitialChecks(int);
+ int WorkModuleChain(int);
+ int WorkUser(int);
+ int WorkContactChain(int);
+ int WorkAggressive(int);
+ int WorkFinalTasks(int);
protected:
TCHAR* m_tszProfileName;
@@ -242,6 +251,7 @@ public:
UINT_PTR m_flushBuffersTimerId;
DWORD m_flushFailTick;
PBYTE m_pDbCache;
+ HANDLE m_hMap;
protected:
DWORD m_dwFileSize;
@@ -297,6 +307,29 @@ protected:
int InitModuleNames(void);
DWORD GetModuleNameOfs(const char *szName);
char *GetModuleNameByOfs(DWORD ofs);
+
+ ////////////////////////////////////////////////////////////////////////////
+ // checker
+
+ int PeekSegment(DWORD ofs, PVOID buf, int cbBytes);
+ int ReadSegment(DWORD ofs, PVOID buf, int cbBytes);
+ int ReadWrittenSegment(DWORD ofs, PVOID buf, int cbBytes);
+ int SignatureValid(DWORD ofs, DWORD signature);
+ void FreeModuleChain();
+
+ DWORD ConvertModuleNameOfs(DWORD ofsOld);
+ void ConvertOldEvent(DBEvent*& dbei);
+
+ int WorkSettingsChain(DWORD ofsContact, DBContact *dbc, int firstTime);
+ int WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime);
+
+ DWORD WriteSegment(DWORD ofs, PVOID buf, int cbBytes);
+ DWORD WriteEvent(DBEvent *dbe);
+ void WriteOfsNextToPrevious(DWORD ofsPrev,DBContact *dbc,DWORD ofsNext);
+ void FinishUp(DWORD ofsLast,DBContact *dbc);
+
+ DBCHeckCallback *cb;
+ DWORD sourceFileSize, ofsAggrCur;
};
struct CDb3Mmap : public CDb3Base
@@ -315,10 +348,9 @@ protected:
protected:
PBYTE m_pNull;
- HANDLE m_hMap;
void Map();
void ReMap(DWORD needed);
};
-typedef int (CDb3Mmap::*CheckWorker)(DBCHeckCallback*, int);
+typedef int (CDb3Base::*CheckWorker)(int);
diff --git a/plugins/Db3x_mmap/src/dbintfm.cpp b/plugins/Db3x_mmap/src/dbintfm.cpp
index 2f34f4e371..6b69bc5119 100644
--- a/plugins/Db3x_mmap/src/dbintfm.cpp
+++ b/plugins/Db3x_mmap/src/dbintfm.cpp
@@ -24,9 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
CDb3Mmap::CDb3Mmap(const TCHAR* tszFileName) :
- CDb3Base(tszFileName),
- m_hMap(NULL),
- m_pNull(NULL)
+ CDb3Base(tszFileName)
{
SYSTEM_INFO sinf;
GetSystemInfo(&sinf);
@@ -35,8 +33,6 @@ CDb3Mmap::CDb3Mmap(const TCHAR* tszFileName) :
CDb3Mmap::~CDb3Mmap()
{
- if (m_hMap)
- CloseHandle(m_hMap);
if (m_pNull)
free(m_pNull);
}
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp
index 4a92bf7d4a..fedc5f60d2 100644
--- a/plugins/Db3x_mmap/src/dbsettings.cpp
+++ b/plugins/Db3x_mmap/src/dbsettings.cpp
@@ -912,7 +912,7 @@ STDMETHODIMP_(BOOL) CDb3Base::EnumContactSettings(HANDLE hContact, DBCONTACTENUM
STDMETHODIMP_(BOOL) CDb3Base::EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam)
{
- for(int i = 0; i < m_lResidentSettings.getCount(); i++) {
+ for (int i = 0; i < m_lResidentSettings.getCount(); i++) {
int ret = pFunc(m_lResidentSettings[i], 0, (LPARAM)pParam);
if (ret) return ret;
}
diff --git a/plugins/Db3x_mmap/src/dbtool/aggressive.cpp b/plugins/Db3x_mmap/src/dbtool/aggressive.cpp
index 7cafb63043..0a47754920 100644
--- a/plugins/Db3x_mmap/src/dbtool/aggressive.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/aggressive.cpp
@@ -20,44 +20,36 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define BLOCKSIZE 65536
-extern DWORD sourceFileSize;
-extern DWORD spaceProcessed;
-extern DWORD sp;
-static DWORD ofsCurrent;
-
-int WorkAggressive(int firstTime)
+int CDb3Base::WorkAggressive(int firstTime)
{
- int blockBytes,i;
- BYTE *buf;
-
if (firstTime) {
- if (!opts.bAggressive)
+ if (!cb->bAggressive)
return ERROR_NO_MORE_ITEMS;
- AddToStatus(STATUS_MESSAGE,TranslateT("Performing aggressive pass"));
- ofsCurrent = 0;
- spaceProcessed = 0;
- sp = 0;
+ cb->pfnAddLogMessage(STATUS_MESSAGE,TranslateT("Performing aggressive pass"));
+ ofsAggrCur = 0;
+ cb->spaceProcessed = 0;
}
- blockBytes = min(BLOCKSIZE+3,(int)(sourceFileSize-ofsCurrent));
+
+ int blockBytes = min(BLOCKSIZE+3,(int)(sourceFileSize-ofsAggrCur));
if (blockBytes <= 0)
return ERROR_NO_MORE_ITEMS;
- buf = opts.pFile+ofsCurrent;
+ BYTE *buf = m_pDbCache + ofsAggrCur;
blockBytes -= 3;
- for(i = 0;i<blockBytes;i++) {
+ for (int i=0; i < blockBytes; i++) {
if (buf[i]) {
- if ((*(PDWORD)&buf[i]&0x00FFFFFF) != 0xDECADE)
- AddToStatus(STATUS_WARNING,TranslateT("Aggressive: random junk at %08X: skipping"),ofsCurrent+i);
- else {
+ if ((*(PDWORD)&buf[i] & 0x00FFFFFF) != 0xDECADE)
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Aggressive: random junk at %08X: skipping"),ofsAggrCur+i);
+ else
//TODO: give user the option of placing manually
- AddToStatus(STATUS_ERROR,TranslateT("Aggressive: unlinked data at %08X: can't automatically place"),ofsCurrent+i);
- }
- for(; i < blockBytes; i++)
+ cb->pfnAddLogMessage(STATUS_ERROR,TranslateT("Aggressive: unlinked data at %08X: can't automatically place"),ofsAggrCur+i);
+
+ for (; i < blockBytes; i++)
if (buf[i] == 0) {i--; break;}
}
}
- ofsCurrent += BLOCKSIZE;
- spaceProcessed = ofsCurrent;
+ ofsAggrCur += BLOCKSIZE;
+ cb->spaceProcessed = ofsAggrCur;
return ERROR_SUCCESS;
}
diff --git a/plugins/Db3x_mmap/src/dbtool/contactchain.cpp b/plugins/Db3x_mmap/src/dbtool/contactchain.cpp
index 0993371848..80c4b62168 100644
--- a/plugins/Db3x_mmap/src/dbtool/contactchain.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/contactchain.cpp
@@ -16,10 +16,8 @@ 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 "..\commonheaders.h"
-int WorkSettingsChain(DWORD ofsContact,DBContact *dbc,int firstTime);
-int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime);
+#include "..\commonheaders.h"
static DWORD ofsThisContact,ofsDestPrevContact;
static DWORD contactCount;
@@ -27,17 +25,17 @@ static DWORD ofsDestThis,ofsNextContact;
static int phase;
static DBContact dbc;
-int WorkContactChain(int firstTime)
+int CDb3Base::WorkContactChain(int firstTime)
{
int first = 0;
int ret;
if (firstTime) {
- AddToStatus(STATUS_MESSAGE,TranslateT("Processing contact chain"));
+ cb->pfnAddLogMessage(STATUS_MESSAGE,TranslateT("Processing contact chain"));
ofsDestPrevContact = 0;
- ofsThisContact = dbhdr.ofsFirstContact;
+ ofsThisContact = m_dbHeader.ofsFirstContact;
contactCount = 0;
- dbhdr.ofsFirstContact = 0;
+ m_dbHeader.ofsFirstContact = 0;
phase = 0;
}
@@ -45,13 +43,13 @@ int WorkContactChain(int firstTime)
case 0:
if (ofsThisContact == 0) {
LBL_FinishUp:
- if (contactCount != dbhdr.contactCount)
- AddToStatus(STATUS_WARNING,TranslateT("Contact count marked wrongly: correcting"));
- dbhdr.contactCount = contactCount;
+ if (contactCount != m_dbHeader.contactCount)
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Contact count marked wrongly: correcting"));
+ m_dbHeader.contactCount = contactCount;
return ERROR_NO_MORE_ITEMS;
}
if (!SignatureValid(ofsThisContact,DBCONTACT_SIGNATURE)) {
- AddToStatus(STATUS_ERROR,TranslateT("Contact chain corrupted, further entries ignored"));
+ cb->pfnAddLogMessage(STATUS_ERROR,TranslateT("Contact chain corrupted, further entries ignored"));
goto LBL_FinishUp;
}
if (ReadSegment(ofsThisContact,&dbc,sizeof(dbc)) != ERROR_SUCCESS)
@@ -59,13 +57,13 @@ LBL_FinishUp:
ofsNextContact = dbc.ofsNext;
dbc.ofsNext = 0;
- if (!opts.bCheckOnly) {
+ if (!cb->bCheckOnly) {
if ((ofsDestThis = WriteSegment(WSOFS_END,&dbc,sizeof(dbc))) == WS_ERROR)
return ERROR_HANDLE_DISK_FULL;
if (ofsDestPrevContact)
WriteSegment(ofsDestPrevContact+offsetof(DBContact,ofsNext),&ofsDestThis,sizeof(DWORD));
else
- dbhdr.ofsFirstContact = ofsDestThis;
+ m_dbHeader.ofsFirstContact = ofsDestThis;
} else
ofsDestThis = ofsThisContact; // needed in event chain worker
contactCount++;
diff --git a/plugins/Db3x_mmap/src/dbtool/disk.cpp b/plugins/Db3x_mmap/src/dbtool/disk.cpp
index 2cf9136a71..a5178c8ea2 100644
--- a/plugins/Db3x_mmap/src/dbtool/disk.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/disk.cpp
@@ -16,95 +16,91 @@ 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 "dbtool.h"
-extern DWORD spaceProcessed, sourceFileSize;
+#include "..\commonheaders.h"
-int SignatureValid(DWORD ofs, DWORD signature)
+int CDb3Base::SignatureValid(DWORD ofs, DWORD signature)
{
DWORD sig;
if (ofs+sizeof(sig) >= sourceFileSize) {
- AddToStatus(STATUS_ERROR, TranslateT("Invalid offset found (database truncated?)"));
+ cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Invalid offset found (database truncated?)"));
return 0;
}
- sig = *(DWORD*)(opts.pFile+ofs);
+ sig = *(DWORD*)(m_pDbCache+ofs);
return sig == signature;
}
-int PeekSegment(DWORD ofs, PVOID buf, int cbBytes)
+int CDb3Base::PeekSegment(DWORD ofs, PVOID buf, int cbBytes)
{
DWORD bytesRead;
if (ofs >= sourceFileSize) {
- AddToStatus(STATUS_ERROR, TranslateT("Invalid offset found"));
+ cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Invalid offset found"));
return ERROR_SEEK;
}
- if (ofs+cbBytes>sourceFileSize)
+ if (ofs+cbBytes > sourceFileSize)
bytesRead = sourceFileSize - ofs;
else
bytesRead = cbBytes;
if (bytesRead == 0) {
- AddToStatus(STATUS_ERROR, TranslateT("Error reading, database truncated? (%u)"), GetLastError());
+ cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Error reading, database truncated? (%u)"), GetLastError());
return ERROR_READ_FAULT;
}
- CopyMemory(buf, opts.pFile+ofs, bytesRead);
+ CopyMemory(buf, m_pDbCache+ofs, bytesRead);
if ((int)bytesRead<cbBytes) return ERROR_HANDLE_EOF;
return ERROR_SUCCESS;
}
-int ReadSegment(DWORD ofs, PVOID buf, int cbBytes)
+int CDb3Base::ReadSegment(DWORD ofs, PVOID buf, int cbBytes)
{
- int ret;
-
- ret = PeekSegment(ofs, buf, cbBytes);
+ int ret = PeekSegment(ofs, buf, cbBytes);
if (ret != ERROR_SUCCESS && ret != ERROR_HANDLE_EOF) return ret;
- if (opts.bAggressive) {
- if (ofs+cbBytes>sourceFileSize) {
- AddToStatus(STATUS_WARNING, TranslateT("Can't write to working file, aggressive mode may be too aggressive now"));
- ZeroMemory(opts.pFile+ofs, sourceFileSize-ofs);
+ if (cb->bAggressive) {
+ if (ofs+cbBytes > sourceFileSize) {
+ cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Can't write to working file, aggressive mode may be too aggressive now"));
+ ZeroMemory(m_pDbCache+ofs, sourceFileSize-ofs);
}
else
- ZeroMemory(opts.pFile+ofs, cbBytes);
+ ZeroMemory(m_pDbCache+ofs, cbBytes);
}
- spaceProcessed += cbBytes;
+ cb->spaceProcessed += cbBytes;
return ERROR_SUCCESS;
}
-DWORD WriteSegment(DWORD ofs, PVOID buf, int cbBytes)
+DWORD CDb3Base::WriteSegment(DWORD ofs, PVOID buf, int cbBytes)
{
DWORD bytesWritten;
- if (opts.bCheckOnly) return 0xbfbfbfbf;
+ if (cb->bCheckOnly) return 0xbfbfbfbf;
if (ofs == WSOFS_END) {
- ofs = dbhdr.ofsFileEnd;
- dbhdr.ofsFileEnd += cbBytes;
+ ofs = m_dbHeader.ofsFileEnd;
+ m_dbHeader.ofsFileEnd += cbBytes;
}
- SetFilePointer(opts.hOutFile, ofs, NULL, FILE_BEGIN);
- WriteFile(opts.hOutFile, buf, cbBytes, &bytesWritten, NULL);
+ SetFilePointer(cb->hOutFile, ofs, NULL, FILE_BEGIN);
+ WriteFile(cb->hOutFile, buf, cbBytes, &bytesWritten, NULL);
if ((int)bytesWritten<cbBytes) {
- AddToStatus(STATUS_FATAL, TranslateT("Can't write to output file - disk full? (%u)"), GetLastError());
+ cb->pfnAddLogMessage(STATUS_FATAL, TranslateT("Can't write to output file - disk full? (%u)"), GetLastError());
return WS_ERROR;
}
return ofs;
}
-
-int ReadWrittenSegment(DWORD ofs, PVOID buf, int cbBytes)
+int CDb3Base::ReadWrittenSegment(DWORD ofs, PVOID buf, int cbBytes)
{
DWORD bytesRead;
- if (opts.bCheckOnly) return 0xbfbfbfbf;
- if (ofs + cbBytes > dbhdr.ofsFileEnd)
+ if (cb->bCheckOnly) return 0xbfbfbfbf;
+ if (ofs + cbBytes > m_dbHeader.ofsFileEnd)
return ERROR_SEEK;
- SetFilePointer(opts.hOutFile, ofs, NULL, FILE_BEGIN);
- ReadFile(opts.hOutFile, buf, cbBytes, &bytesRead, NULL);
+ SetFilePointer(cb->hOutFile, ofs, NULL, FILE_BEGIN);
+ ReadFile(cb->hOutFile, buf, cbBytes, &bytesRead, NULL);
if ((int)bytesRead<cbBytes)
return ERROR_READ_FAULT;
diff --git a/plugins/Db3x_mmap/src/dbtool/eventchain.cpp b/plugins/Db3x_mmap/src/dbtool/eventchain.cpp
index 1e0076371d..9c9a41f999 100644
--- a/plugins/Db3x_mmap/src/dbtool/eventchain.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/eventchain.cpp
@@ -32,7 +32,7 @@ static DWORD memsize = 0;
static DBEvent* memblock = NULL;
static DBEvent* dbePrevEvent = NULL;
-static void ConvertOldEvent(DBEvent*& dbei)
+void CDb3Base::ConvertOldEvent(DBEvent*& dbei)
{
int msglen = (int)strlen((char*)dbei->blob) + 1, msglenW = 0;
if (msglen != (int) dbei->cbBlob) {
@@ -44,7 +44,7 @@ static void ConvertOldEvent(DBEvent*& dbei)
break;
} } }
else {
- if (!is_utf8_string((char*)dbei->blob))
+ if (!Utf8CheckString((char*)dbei->blob))
dbei->flags &= ~DBEF_UTF;
}
@@ -61,7 +61,7 @@ static void ConvertOldEvent(DBEvent*& dbei)
free(utf8str);
} }
-static void WriteOfsNextToPrevious(DWORD ofsPrev,DBContact *dbc,DWORD ofsNext)
+void CDb3Base::WriteOfsNextToPrevious(DWORD ofsPrev,DBContact *dbc,DWORD ofsNext)
{
if (ofsPrev)
WriteSegment(ofsPrev+offsetof(DBEvent,ofsNext),&ofsNext,sizeof(DWORD));
@@ -69,14 +69,14 @@ static void WriteOfsNextToPrevious(DWORD ofsPrev,DBContact *dbc,DWORD ofsNext)
dbc->ofsFirstEvent = ofsNext;
}
-static void FinishUp(DWORD ofsLast,DBContact *dbc)
+void CDb3Base::FinishUp(DWORD ofsLast,DBContact *dbc)
{
WriteOfsNextToPrevious(ofsLast,dbc,0);
if (eventCount != dbc->eventCount)
- AddToStatus(STATUS_WARNING,TranslateT("Event count marked wrongly: correcting"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Event count marked wrongly: correcting"));
dbc->eventCount = eventCount;
dbc->ofsLastEvent = ofsLast;
- if (opts.bMarkRead) {
+ if (cb->bMarkRead) {
dbc->ofsFirstUnreadEvent = 0;
dbc->timestampFirstUnread = 0;
}
@@ -91,7 +91,7 @@ static void FinishUp(DWORD ofsLast,DBContact *dbc)
}
}
-static DWORD WriteEvent(DBEvent *dbe)
+DWORD CDb3Base::WriteEvent(DBEvent *dbe)
{
DWORD ofs = WriteSegment(WSOFS_END, dbe, offsetof(DBEvent,blob)+dbe->cbBlob);
if (ofs == WS_ERROR) {
@@ -103,7 +103,7 @@ static DWORD WriteEvent(DBEvent *dbe)
return ofs;
}
-int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
+int CDb3Base::WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
{
DBEvent *dbeNew,dbeOld;
DBEvent *dbePrev = NULL;
@@ -119,7 +119,7 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
backLookup = 0;
lastTimestamp = 0;
ofsFirstUnread = timestampFirstUnread = 0;
- if (opts.bEraseHistory) {
+ if (cb->bEraseHistory) {
dbc->eventCount = 0;
dbc->ofsFirstEvent = 0;
dbc->ofsLastEvent = 0;
@@ -148,10 +148,10 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
}
}
if (ofsNew) {
- AddToStatus(STATUS_WARNING,TranslateT("Event chain corrupted, trying to recover..."));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Event chain corrupted, trying to recover..."));
ofsThisEvent = ofsNew;
} else {
- AddToStatus(STATUS_ERROR,TranslateT("Event chain corrupted, further entries ignored"));
+ cb->pfnAddLogMessage(STATUS_ERROR,TranslateT("Event chain corrupted, further entries ignored"));
FinishUp(ofsDestPrevEvent,dbc);
return ERROR_NO_MORE_ITEMS;
}
@@ -164,32 +164,32 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
if (firstTime) {
if (!(dbeOld.flags&DBEF_FIRST)) {
- AddToStatus(STATUS_WARNING,TranslateT("First event not marked as such: correcting"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("First event not marked as such: correcting"));
dbeOld.flags|=DBEF_FIRST;
}
dbeOld.ofsPrev = ofsContact;
lastTimestamp = dbeOld.timestamp;
}
else if (dbeOld.flags&DBEF_FIRST) {
- AddToStatus(STATUS_WARNING,TranslateT("Event marked as first which is not: correcting"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Event marked as first which is not: correcting"));
dbeOld.flags&=~DBEF_FIRST;
}
if (dbeOld.flags&~(DBEF_FIRST|DBEF_READ|DBEF_SENT|DBEF_RTL|DBEF_UTF)) {
- AddToStatus(STATUS_WARNING,TranslateT("Extra flags found in event: removing"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Extra flags found in event: removing"));
dbeOld.flags&=(DBEF_FIRST|DBEF_READ|DBEF_SENT|DBEF_RTL|DBEF_UTF);
}
if (!(dbeOld.flags&(DBEF_READ|DBEF_SENT))) {
- if (opts.bMarkRead) dbeOld.flags|=DBEF_READ;
+ if (cb->bMarkRead) dbeOld.flags|=DBEF_READ;
else if (ofsFirstUnread == 0) {
if (dbc->ofsFirstUnreadEvent != ofsThisEvent || dbc->timestampFirstUnread != dbeOld.timestamp)
- AddToStatus(STATUS_WARNING,TranslateT("First unread event marked wrong: fixing"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("First unread event marked wrong: fixing"));
isUnread = 1;
} }
if (dbeOld.cbBlob>1024*1024 || dbeOld.cbBlob == 0) {
- AddToStatus(STATUS_ERROR,TranslateT("Infeasibly large event blob: skipping"));
+ cb->pfnAddLogMessage(STATUS_ERROR,TranslateT("Infeasibly large event blob: skipping"));
ofsThisEvent = dbeOld.ofsNext;
return ERROR_SUCCESS;
}
@@ -217,13 +217,13 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
}
if (!firstTime && dbeOld.ofsPrev != ofsPrevEvent)
- AddToStatus(STATUS_WARNING,TranslateT("Event not backlinked correctly: fixing"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Event not backlinked correctly: fixing"));
dbeNew->flags = dbeOld.flags;
dbeNew->ofsPrev = ofsDestPrevEvent;
dbeNew->ofsNext = 0;
- if (dbeOld.eventType == EVENTTYPE_MESSAGE && opts.bConvertUtf)
+ if (dbeOld.eventType == EVENTTYPE_MESSAGE && cb->bConvertUtf)
ConvertOldEvent(dbeNew);
if (dbePrev)
@@ -234,7 +234,7 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
(dbePrev->flags & DBEF_SENT) == (dbeNew->flags & DBEF_SENT) &&
!memcmp(dbePrev->blob, dbeNew->blob, dbeNew->cbBlob)
) {
- AddToStatus(STATUS_WARNING,TranslateT("Duplicate event was found: skipping"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Duplicate event was found: skipping"));
if (dbc->eventCount)
dbc->eventCount--;
free(dbePrev);
@@ -251,9 +251,9 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
DBEvent dbeTmp;
DWORD ofsTmp;
- if (opts.bCheckOnly)
+ if (cb->bCheckOnly)
{
- if (!opts.bAggressive)
+ if (!cb->bAggressive)
{
ofsTmp = dbeOld.ofsPrev;
while(PeekSegment(ofsTmp,&dbeTmp,sizeof(dbeTmp)) == ERROR_SUCCESS)
@@ -269,7 +269,7 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
ofsTmp = dbeTmp.ofsPrev;
}
}
- AddToStatus(STATUS_WARNING,TranslateT("Event position in chain is not correct"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Event position in chain is not correct"));
}
else
{
@@ -287,13 +287,13 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
ofsTmp = dbeTmp.ofsPrev;
}
if (found)
- AddToStatus(STATUS_WARNING,TranslateT("Event position in chain is not correct: fixing"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Event position in chain is not correct: fixing"));
else
- AddToStatus(STATUS_WARNING,TranslateT("Event position in chain is not correct: unable to fix"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Event position in chain is not correct: unable to fix"));
}
// insert before FIRST
- if (found == 1 && !opts.bCheckOnly) {
+ if (found == 1 && !cb->bCheckOnly) {
dbeNew->flags|=DBEF_FIRST;
dbeNew->ofsPrev = ofsContact;
dbeNew->ofsNext = dbc->ofsFirstEvent;
@@ -313,7 +313,7 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
dbeTmp.flags &=~DBEF_FIRST;
WriteSegment(dbeNew->ofsNext+offsetof(DBEvent,flags),&dbeTmp.flags,sizeof(DWORD));
}
- else if (found == 2 && !opts.bCheckOnly) {
+ else if (found == 2 && !cb->bCheckOnly) {
dbeNew->ofsPrev = ofsTmp;
dbeNew->ofsNext = dbeTmp.ofsNext;
diff --git a/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp b/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp
index 939fd680d1..a307c0b9fb 100644
--- a/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp
@@ -18,61 +18,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "..\commonheaders.h"
-extern int errorCount;
-
-int WorkFinalTasks(int firstTime)
+int CDb3Base::WorkFinalTasks(int firstTime)
{
FreeModuleChain();
- AddToStatus(STATUS_MESSAGE,TranslateT("Processing final tasks"));
- dbhdr.slackSpace = 0;
- if (WriteSegment(0,&dbhdr,sizeof(dbhdr)) == WS_ERROR)
+ cb->pfnAddLogMessage(STATUS_MESSAGE,TranslateT("Processing final tasks"));
+ m_dbHeader.slackSpace = 0;
+ if (WriteSegment(0,&m_dbHeader,sizeof(m_dbHeader)) == WS_ERROR)
return ERROR_WRITE_FAULT;
- if (opts.hFile) {
- CloseHandle(opts.hFile);
- opts.hFile = NULL;
- }
- if (opts.hOutFile) {
- CloseHandle(opts.hOutFile);
- opts.hOutFile = NULL;
- }
- if (opts.pFile) {
- UnmapViewOfFile(opts.pFile);
- opts.pFile = NULL;
- }
- if (opts.hMap) {
- CloseHandle(opts.hMap);
- opts.hMap = NULL;
+
+ if (m_hDbFile) {
+ CloseHandle(m_hDbFile);
+ m_hDbFile = NULL;
}
- if (errorCount && !opts.bBackup && !opts.bCheckOnly) {
- extern time_t ts;
- time_t dlg_ts = time(NULL);
- if (IDYES == MessageBox(NULL,
- 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(NULL) - dlg_ts;
+ if (m_pDbCache) {
+ UnmapViewOfFile(m_pDbCache);
+ m_pDbCache = NULL;
}
- if (opts.bBackup) {
- int i;
- TCHAR dbPath[MAX_PATH],dbFile[MAX_PATH];
- _tcscpy(dbPath, opts.filename);
- TCHAR* str2 = _tcsrchr(dbPath, '\\');
- if (str2 != NULL) {
- _tcscpy(dbFile, str2+1);
- *str2 = 0;
- }
- else {
- _tcscpy(dbFile, dbPath);
- dbPath[0] = 0;
- }
- for(i = 1;;i++) {
- if (i == 1) wsprintf(opts.backupFilename,TranslateT("%s\\Backup of %s"),dbPath,dbFile);
- else wsprintf(opts.backupFilename,TranslateT("%s\\Backup (%d) of %s"),dbPath,i,dbFile);
- if (_taccess(opts.backupFilename,0) == -1) break;
- }
- MoveFile(opts.filename,opts.backupFilename) || AddToStatus(STATUS_WARNING,TranslateT("Unable to rename original file"));
+ if (m_hMap) {
+ CloseHandle(m_hMap);
+ m_hMap = NULL;
}
- else if (!opts.bCheckOnly) DeleteFile(opts.filename) || AddToStatus(STATUS_WARNING,TranslateT("Unable to delete original file"));
- if (!opts.bCheckOnly) MoveFile(opts.outputFilename,opts.filename) || AddToStatus(STATUS_WARNING,TranslateT("Unable to rename output file"));
return ERROR_NO_MORE_ITEMS;
}
diff --git a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp
index 21ccff5976..5769eff84d 100644
--- a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp
@@ -18,64 +18,49 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "..\commonheaders.h"
-extern DWORD sourceFileSize,spaceUsed;
+extern DBSignature dbSignature;
-int WorkInitialChecks(int firstTime)
+int CDb3Base::WorkInitialCheckHeaders()
{
- DWORD bytesRead;
-
- sourceFileSize = GetFileSize(opts.hFile,NULL);
- if (sourceFileSize == 0) {
- AddToStatus(STATUS_WARNING,TranslateT("Database is newly created and has no data to process"));
- AddToStatus(STATUS_SUCCESS,TranslateT("Processing completed successfully"));
- return ERROR_INVALID_DATA;
- }
- ReadFile(opts.hFile,&dbhdr,sizeof(dbhdr),&bytesRead,NULL);
- if (bytesRead<sizeof(dbhdr)) {
- AddToStatus(STATUS_FATAL,TranslateT("Database is corrupted and too small to contain any recoverable data"));
- return ERROR_BAD_FORMAT;
- }
- if (memcmp(dbhdr.signature,&dbSignature,sizeof(dbhdr.signature))) {
- AddToStatus(STATUS_FATAL,TranslateT("Database signature is corrupted, automatic repair is impossible"));
+ if (memcmp(m_dbHeader.signature, &dbSignature, sizeof(m_dbHeader.signature))) {
+ cb->pfnAddLogMessage(STATUS_FATAL,TranslateT("Database signature is corrupted, automatic repair is impossible"));
return ERROR_BAD_FORMAT;
}
- if (dbhdr.version != 0x00000700) {
- AddToStatus(STATUS_FATAL,TranslateT("Database is marked as belonging to an unknown version of Miranda"));
+ if (m_dbHeader.version != 0x00000700) {
+ cb->pfnAddLogMessage(STATUS_FATAL,TranslateT("Database is marked as belonging to an unknown version of Miranda"));
return ERROR_BAD_FORMAT;
}
- _tcscpy(opts.workingFilename,opts.filename);
+ return ERROR_SUCCESS;
+}
- if (opts.bCheckOnly) {
- _tcscpy(opts.outputFilename, TranslateT("<check only>"));
- opts.hOutFile = INVALID_HANDLE_VALUE;
- }
- else {
- _tcscpy(opts.outputFilename,opts.filename);
- *_tcsrchr(opts.outputFilename,'.') = 0;
- _tcscat(opts.outputFilename,TranslateT(" (Output).dat"));
- opts.hOutFile = CreateFile(opts.outputFilename,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_FLAG_SEQUENTIAL_SCAN,NULL);
- if (opts.hOutFile == INVALID_HANDLE_VALUE) {
- AddToStatus(STATUS_FATAL,TranslateT("Can't create output file (%u)"),GetLastError());
- return ERROR_ACCESS_DENIED;
- }
+int CDb3Base::WorkInitialChecks(int firstTime)
+{
+ sourceFileSize = GetFileSize(m_hDbFile,NULL);
+ if (sourceFileSize == 0) {
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Database is newly created and has no data to process"));
+ cb->pfnAddLogMessage(STATUS_SUCCESS,TranslateT("Processing completed successfully"));
+ return ERROR_INVALID_DATA;
}
- opts.hMap = CreateFileMapping(opts.hFile, NULL, opts.bAggressive?PAGE_WRITECOPY:PAGE_READONLY, 0, 0, NULL);
+ int res = WorkInitialCheckHeaders();
+ if (res)
+ return res;
- if (opts.hMap)
- opts.pFile = (BYTE*)MapViewOfFile(opts.hMap, opts.bAggressive?FILE_MAP_COPY:FILE_MAP_READ, 0, 0 ,0);
+ m_hMap = CreateFileMapping(m_hDbFile, NULL, cb->bAggressive?PAGE_WRITECOPY:PAGE_READONLY, 0, 0, NULL);
+ if (m_hMap)
+ m_pDbCache = (BYTE*)MapViewOfFile(m_hMap, cb->bAggressive?FILE_MAP_COPY:FILE_MAP_READ, 0, 0 ,0);
else {
- AddToStatus(STATUS_FATAL,TranslateT("Can't create file mapping (%u)"),GetLastError());
+ cb->pfnAddLogMessage(STATUS_FATAL,TranslateT("Can't create file mapping (%u)"),GetLastError());
return ERROR_ACCESS_DENIED;
}
- if (!opts.pFile) {
- AddToStatus(STATUS_FATAL,TranslateT("Can't create map view of file (%u)"),GetLastError());
+ if (!m_pDbCache) {
+ cb->pfnAddLogMessage(STATUS_FATAL,TranslateT("Can't create map view of file (%u)"),GetLastError());
return ERROR_ACCESS_DENIED;
}
- if (ReadSegment(0,&dbhdr,sizeof(dbhdr)) != ERROR_SUCCESS) return ERROR_READ_FAULT;
- if (WriteSegment(0,&dbhdr,sizeof(dbhdr)) == WS_ERROR) return ERROR_HANDLE_DISK_FULL;
- spaceUsed = dbhdr.ofsFileEnd-dbhdr.slackSpace;
- dbhdr.ofsFileEnd = sizeof(dbhdr);
+ if (ReadSegment(0,&m_dbHeader,sizeof(m_dbHeader)) != ERROR_SUCCESS) return ERROR_READ_FAULT;
+ if (WriteSegment(0,&m_dbHeader,sizeof(m_dbHeader)) == WS_ERROR) return ERROR_HANDLE_DISK_FULL;
+ cb->spaceUsed = m_dbHeader.ofsFileEnd-m_dbHeader.slackSpace;
+ m_dbHeader.ofsFileEnd = sizeof(m_dbHeader);
return ERROR_NO_MORE_ITEMS;
}
diff --git a/plugins/Db3x_mmap/src/dbtool/modulechain.cpp b/plugins/Db3x_mmap/src/dbtool/modulechain.cpp
index f53f63c469..56d784bcfb 100644
--- a/plugins/Db3x_mmap/src/dbtool/modulechain.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/modulechain.cpp
@@ -16,6 +16,7 @@ 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 "..\commonheaders.h"
struct ModChainEntry {
@@ -29,18 +30,18 @@ static int phase,iCurrentModName;
static DWORD ofsLast;
static int last_mod = 0;
-int WorkModuleChain(int firstTime)
+int CDb3Base::WorkModuleChain(int firstTime)
{
DBModuleName moduleName,*newModName;
if (firstTime) {
- AddToStatus(STATUS_MESSAGE,TranslateT("Processing module name chain"));
+ cb->pfnAddLogMessage(STATUS_MESSAGE,TranslateT("Processing module name chain"));
modChainCount = 0;
last_mod = 0;
if (modChain != NULL) free(modChain);
modChain = (ModChainEntry*)malloc(sizeof(ModChainEntry));
phase = 0;
- ofsCurrent = dbhdr.ofsFirstModuleName;
+ ofsCurrent = m_dbHeader.ofsFirstModuleName;
}
switch(phase) {
case 0:
@@ -49,7 +50,7 @@ int WorkModuleChain(int firstTime)
return ERROR_SUCCESS;
}
if (!SignatureValid(ofsCurrent,DBMODULENAME_SIGNATURE)) {
- AddToStatus(STATUS_ERROR,TranslateT("Module chain corrupted, further entries ignored"));
+ cb->pfnAddLogMessage(STATUS_ERROR,TranslateT("Module chain corrupted, further entries ignored"));
phase++;
return ERROR_SUCCESS;
}
@@ -58,7 +59,7 @@ int WorkModuleChain(int firstTime)
return ERROR_SUCCESS;
}
if (moduleName.cbName>256)
- AddToStatus(STATUS_WARNING,TranslateT("Unreasonably long module name, skipping"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Unreasonably long module name, skipping"));
else {
modChain = (ModChainEntry*)realloc(modChain,sizeof(ModChainEntry)*++modChainCount);
@@ -75,7 +76,7 @@ int WorkModuleChain(int firstTime)
case 1:
ofsLast = 0;
iCurrentModName = 0;
- dbhdr.ofsFirstModuleName = 0;
+ m_dbHeader.ofsFirstModuleName = 0;
phase++;
case 2:
if (iCurrentModName >= modChainCount) {
@@ -91,7 +92,7 @@ int WorkModuleChain(int firstTime)
return ERROR_HANDLE_DISK_FULL;
{ // check duplicated modulenames
int i, n = 0;
- for(i = iCurrentModName+1;i<modChainCount;i++)
+ for (i = iCurrentModName+1;i<modChainCount;i++)
if (!strcmp(modChain[i].name, modChain[iCurrentModName].name)) {
modChain[i].ofsNew = modChain[iCurrentModName].ofsNew;
n++;
@@ -103,11 +104,11 @@ int WorkModuleChain(int firstTime)
MultiByteToWideChar(CP_ACP, 0, modChain[iCurrentModName].name, -1, szModuleName, sizeof(szModuleName) / sizeof(TCHAR));
pszModuleName = szModuleName;
- AddToStatus(STATUS_WARNING,TranslateT("Module name '%s' is not unique: %d duplicates found)"), pszModuleName, n);
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("Module name '%s' is not unique: %d duplicates found)"), pszModuleName, n);
}
}
if (iCurrentModName == 0)
- dbhdr.ofsFirstModuleName = modChain[iCurrentModName].ofsNew;
+ m_dbHeader.ofsFirstModuleName = modChain[iCurrentModName].ofsNew;
else
if (WriteSegment(ofsLast+offsetof(DBModuleName,ofsNext),&modChain[iCurrentModName].ofsNew,sizeof(DWORD)) == WS_ERROR)
return ERROR_HANDLE_DISK_FULL;
@@ -119,24 +120,24 @@ int WorkModuleChain(int firstTime)
return ERROR_SUCCESS;
}
-DWORD ConvertModuleNameOfs(DWORD ofsOld)
+DWORD CDb3Base::ConvertModuleNameOfs(DWORD ofsOld)
{
int i;
if (modChain[last_mod].ofsOld == ofsOld)
return modChain[last_mod].ofsNew;
- for(i = 0;i<modChainCount;i++)
+ for (i = 0;i<modChainCount;i++)
if (modChain[i].ofsOld == ofsOld) {
last_mod = i;
return modChain[last_mod].ofsNew;
}
- AddToStatus(STATUS_ERROR,TranslateT("Invalid module name offset, skipping data"));
+ cb->pfnAddLogMessage(STATUS_ERROR,TranslateT("Invalid module name offset, skipping data"));
return 0;
}
-void FreeModuleChain()
+void CDb3Base::FreeModuleChain()
{
if (modChain != NULL) {
free(modChain);
diff --git a/plugins/Db3x_mmap/src/dbtool/settingschain.cpp b/plugins/Db3x_mmap/src/dbtool/settingschain.cpp
index a2bfc48482..aaa52d9e22 100644
--- a/plugins/Db3x_mmap/src/dbtool/settingschain.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/settingschain.cpp
@@ -16,11 +16,12 @@ 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 "..\commonheaders.h"
static DWORD ofsThisSettings,ofsDestPrevSettings;
-int WorkSettingsChain(DWORD ofsContact,DBContact *dbc,int firstTime)
+int CDb3Base::WorkSettingsChain(DWORD ofsContact,DBContact *dbc,int firstTime)
{
DBContactSettings *dbcsNew,dbcsOld;
DWORD ofsDestThis;
@@ -33,14 +34,15 @@ int WorkSettingsChain(DWORD ofsContact,DBContact *dbc,int firstTime)
}
if (ofsThisSettings == 0)
return ERROR_NO_MORE_ITEMS;
+
if (!SignatureValid(ofsThisSettings,DBCONTACTSETTINGS_SIGNATURE)) {
- AddToStatus(STATUS_ERROR,TranslateT("Settings chain corrupted, further entries ignored"));
+ cb->pfnAddLogMessage(STATUS_ERROR,TranslateT("Settings chain corrupted, further entries ignored"));
return ERROR_NO_MORE_ITEMS;
}
if (PeekSegment(ofsThisSettings,&dbcsOld,sizeof(dbcsOld)) != ERROR_SUCCESS)
return ERROR_NO_MORE_ITEMS;
if (dbcsOld.cbBlob>256*1024 || dbcsOld.cbBlob == 0) {
- AddToStatus(STATUS_ERROR,TranslateT("Infeasibly large settings blob: skipping"));
+ cb->pfnAddLogMessage(STATUS_ERROR,TranslateT("Infeasibly large settings blob: skipping"));
ofsThisSettings = dbcsOld.ofsNext;
return ERROR_SUCCESS;
}
@@ -55,7 +57,7 @@ int WorkSettingsChain(DWORD ofsContact,DBContact *dbc,int firstTime)
return ERROR_SUCCESS;
}
if (dbcsNew->blob[0] == 0) {
- AddToStatus(STATUS_MESSAGE,TranslateT("Empty settings group at %08X: skipping"),ofsThisSettings);
+ cb->pfnAddLogMessage(STATUS_MESSAGE,TranslateT("Empty settings group at %08X: skipping"),ofsThisSettings);
ofsThisSettings = dbcsOld.ofsNext;
return ERROR_SUCCESS;
}
diff --git a/plugins/Db3x_mmap/src/dbtool/user.cpp b/plugins/Db3x_mmap/src/dbtool/user.cpp
index d61add09d4..ac200d2409 100644
--- a/plugins/Db3x_mmap/src/dbtool/user.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/user.cpp
@@ -16,56 +16,59 @@ 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 "..\commonheaders.h"
static DBContact user;
static int phase;
static DWORD ofsUser;
-int WorkSettingsChain(DWORD ofsContact,DBContact *dbc,int firstTime);
-int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime);
-
-int WorkUser(int firstTime)
+int CDb3Base::WorkUser(int firstTime)
{
int first = 0;
if (firstTime) {
- AddToStatus(STATUS_MESSAGE,TranslateT("Processing user data"));
- if (!SignatureValid(dbhdr.ofsUser,DBCONTACT_SIGNATURE)) {
- AddToStatus(STATUS_ERROR,TranslateT("User corrupted, this could cause major problems"));
+ cb->pfnAddLogMessage(STATUS_MESSAGE,TranslateT("Processing user data"));
+ if ( !SignatureValid(m_dbHeader.ofsUser, DBCONTACT_SIGNATURE)) {
+ cb->pfnAddLogMessage(STATUS_ERROR,TranslateT("User corrupted, this could cause major problems"));
return ERROR_NO_MORE_ITEMS;
}
- if (ReadSegment(dbhdr.ofsUser,&user,sizeof(DBContact)) != ERROR_SUCCESS)
+
+ if ( ReadSegment(m_dbHeader.ofsUser,&user,sizeof(DBContact)) != ERROR_SUCCESS)
return ERROR_NO_MORE_ITEMS;
+
if (user.ofsNext) {
- AddToStatus(STATUS_WARNING,TranslateT("More than one user contact: keeping only first"));
+ cb->pfnAddLogMessage(STATUS_WARNING,TranslateT("More than one user contact: keeping only first"));
user.ofsNext = 0;
}
+
if ((ofsUser = WriteSegment(WSOFS_END,&user,sizeof(DBContact))) == WS_ERROR)
return ERROR_HANDLE_DISK_FULL;
- dbhdr.ofsUser = ofsUser;
+
+ m_dbHeader.ofsUser = ofsUser;
phase = 0;
first = 1;
}
+
+ int ret;
switch(phase) {
- int ret;
+ case 0:
+ ret = WorkSettingsChain(ofsUser,&user,first);
+ if (ret == ERROR_NO_MORE_ITEMS) {
+ phase++; first = 1;
+ }
+ else if (ret) return ret;
+ else break;
- case 0:
- ret = WorkSettingsChain(ofsUser,&user,first);
- if (ret == ERROR_NO_MORE_ITEMS) {
- phase++; first = 1;
- }
- else if (ret) return ret;
- else break;
- case 1:
- ret = WorkEventChain(ofsUser,&user,first);
- if (ret == ERROR_NO_MORE_ITEMS) {
- if (WriteSegment(ofsUser,&user,sizeof(DBContact)) == WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- return ERROR_NO_MORE_ITEMS;
- }
- else if (ret) return ret;
- break;
+ case 1:
+ ret = WorkEventChain(ofsUser,&user,first);
+ if (ret == ERROR_NO_MORE_ITEMS) {
+ if (WriteSegment(ofsUser,&user,sizeof(DBContact)) == WS_ERROR)
+ return ERROR_HANDLE_DISK_FULL;
+ return ERROR_NO_MORE_ITEMS;
+ }
+ else if (ret) return ret;
+ break;
}
return ERROR_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/plugins/Db3x_mmap/src/init.cpp b/plugins/Db3x_mmap/src/init.cpp
index d6dbdc5c25..d1ad13f859 100644
--- a/plugins/Db3x_mmap/src/init.cpp
+++ b/plugins/Db3x_mmap/src/init.cpp
@@ -69,33 +69,9 @@ static int grokHeader(const TCHAR *profile, int *error)
return 1;
}
- int chk = tmp->CheckDbHeaders();
+ *error = tmp->CheckDbHeaders();
delete tmp;
- if ( chk == 0 ) {
- // all the internal tests passed, hurrah
- if (error != NULL) *error = 0;
- return 0;
- }
-
- // didn't pass at all, or some did.
- switch ( chk ) {
- case 1:
- // "Miranda ICQ DB" wasn't present
- if (error != NULL) *error = EGROKPRF_UNKHEADER;
- break;
-
- case 2:
- // header was present, but version information newer
- if (error != NULL) *error = EGROKPRF_VERNEWER;
- break;
-
- case 3:
- // header/version OK, internal data missing
- if (error != NULL) *error = EGROKPRF_DAMAGED;
- break;
- }
-
- return 1;
+ return (*error == 0) ? 0 : 1;
}
// returns 0 if all the APIs are injected otherwise, 1
@@ -120,26 +96,27 @@ static int UnloadDatabase(MIDatabase* db)
delete (CDb3Mmap*)db;
return 0;
}
-/*
-static CheckWorker Workers[6] =
-{
- &CDb3Mmap::WorkInitialChecks,
- &CDb3Mmap::WorkModuleChain,
- &CDb3Mmap::WorkUser,
- &CDb3Mmap::WorkContactChain,
- &CDb3Mmap::WorkAggressive,
- &CDb3Mmap::WorkFinalTasks
-};
-static int CheckDb(DBCHeckCallback *callback, int phase, int firstTime)
+MIDatabaseChecker* CheckDb(const TCHAR* ptszFileName, int *error)
{
- if (phase >= SIZEOF(Workers))
- return ERROR_NO_MORE_ITEMS;
+ CDb3Mmap *tmp = new CDb3Mmap(ptszFileName);
+ if (tmp->Load(true) != ERROR_SUCCESS) {
+ delete tmp;
+ if (error != NULL) *error = EGROKPRF_CANTREAD;
+ return NULL;
+ }
+
+ int chk = tmp->CheckDbHeaders();
+ if (chk != ERROR_SUCCESS) {
+ delete tmp;
+ *error = chk;
+ return NULL;
+ }
- CDb3Mmap* db = (CDb3Mmap*)callback->db;
- return (db->*Workers[phase])(callback, firstTime);
+ *error = 0;
+ return tmp;
}
-*/
+
static DATABASELINK dblink =
{
sizeof(DATABASELINK),
@@ -149,7 +126,7 @@ static DATABASELINK dblink =
grokHeader,
LoadDatabase,
UnloadDatabase,
- //CheckDb
+ CheckDb
};
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/DbChecker/src/dbchecker.h b/plugins/DbChecker/src/dbchecker.h
index d333f51b02..9554ff7134 100644
--- a/plugins/DbChecker/src/dbchecker.h
+++ b/plugins/DbChecker/src/dbchecker.h
@@ -84,23 +84,7 @@ void OpenDatabase(HWND hdlg, INT iNextPage);
#define SIZEOF(X) (sizeof(X)/sizeof(X[0]))
-#define STATUS_MESSAGE 0
-#define STATUS_WARNING 1
-#define STATUS_ERROR 2
-#define STATUS_FATAL 3
-#define STATUS_SUCCESS 4
#define STATUS_CLASSMASK 0x0f
void AddToStatus(int flags, const TCHAR* fmt, ...);
void SetProgressBar(int perThou);
-int PeekSegment(DWORD ofs, PVOID buf, int cbBytes);
-int ReadSegment(DWORD ofs, PVOID buf, int cbBytes);
-#define WSOFS_END 0xFFFFFFFF
-#define WS_ERROR 0xFFFFFFFF
-DWORD WriteSegment(DWORD ofs, PVOID buf, int cbBytes);
-int ReadWrittenSegment(DWORD ofs, PVOID buf, int cbBytes);
-int SignatureValid(DWORD ofs, DWORD signature);
-DWORD ConvertModuleNameOfs(DWORD ofsOld);
-void FreeModuleChain();
-
-bool is_utf8_string(const char* str);
diff --git a/plugins/DbChecker/src/selectdb.cpp b/plugins/DbChecker/src/selectdb.cpp
index c1a6e75e90..a8b40af3d8 100644
--- a/plugins/DbChecker/src/selectdb.cpp
+++ b/plugins/DbChecker/src/selectdb.cpp
@@ -41,12 +41,13 @@ LBL_Error:
}
int error = 0;
- opts.dbChecker = opts.dblink->CheckDB(opts.filename, &error);
+ opts.dbChecker = dblink->CheckDB(opts.filename, &error);
if (opts.dbChecker == NULL) {
opts.error = error;
SendMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_OPENERROR, (LPARAM)OpenErrorDlgProc);
return;
}
+ opts.dblink = dblink;
}
if (iNextPage == IDD_FILEACCESS)
diff --git a/plugins/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp
index 9fa3e7aa2b..6847a47f13 100644
--- a/plugins/DbChecker/src/worker.cpp
+++ b/plugins/DbChecker/src/worker.cpp
@@ -28,6 +28,24 @@ void __cdecl WorkerThread(void *unused)
AddToStatus(STATUS_MESSAGE, TranslateT("Database worker thread activated"));
+ _tcscpy(opts.workingFilename,opts.filename);
+
+ if (opts.bCheckOnly) {
+ _tcscpy(opts.outputFilename, TranslateT("<check only>"));
+ opts.hOutFile = INVALID_HANDLE_VALUE;
+ }
+ else {
+ _tcscpy(opts.outputFilename,opts.filename);
+ *_tcsrchr(opts.outputFilename,'.') = 0;
+ _tcscat(opts.outputFilename,TranslateT(" (Output).dat"));
+ opts.hOutFile = CreateFile(opts.outputFilename,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_FLAG_SEQUENTIAL_SCAN,NULL);
+ if (opts.hOutFile == INVALID_HANDLE_VALUE) {
+ AddToStatus(STATUS_FATAL,TranslateT("Can't create output file (%u)"),GetLastError());
+ ProcessingDone();
+ return;
+ }
+ }
+
DWORD sp = 0;
firstTime = 0;
@@ -36,6 +54,14 @@ void __cdecl WorkerThread(void *unused)
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) {
@@ -48,9 +74,9 @@ void __cdecl WorkerThread(void *unused)
break;
}
- int ret = opts.dbChecker->CheckDb(&callback, task, firstTime);
+ int ret = opts.dbChecker->CheckDb(task, firstTime);
firstTime = 0;
- if (ret == ERROR_NO_MORE_ITEMS) {
+ if (ret == ERROR_OUT_OF_PAPER) {
AddToStatus(STATUS_MESSAGE, TranslateT("Elapsed time: %d sec"), time(NULL)-ts);
if (errorCount)
AddToStatus(STATUS_SUCCESS, TranslateT("All tasks completed but with errors (%d)"), errorCount);
@@ -58,12 +84,59 @@ void __cdecl WorkerThread(void *unused)
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;
-
- task++;
- firstTime = 1;
}
-
+
+ opts.dbChecker->Destroy();
+ opts.dbChecker = NULL;
+
+ if ( opts.hOutFile ) {
+ CloseHandle(opts.hOutFile);
+ opts.hOutFile = NULL;
+ }
+
+ if (errorCount && !opts.bBackup && !opts.bCheckOnly) {
+ time_t dlg_ts = time(NULL);
+ if (IDYES == MessageBox(NULL,
+ 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(NULL) - dlg_ts;
+ }
+
+ if (opts.bBackup) {
+ TCHAR dbPath[MAX_PATH],dbFile[MAX_PATH];
+ _tcscpy(dbPath, opts.filename);
+ TCHAR* str2 = _tcsrchr(dbPath, '\\');
+ if (str2 != NULL) {
+ _tcscpy(dbFile, str2+1);
+ *str2 = 0;
+ }
+ else {
+ _tcscpy(dbFile, dbPath);
+ dbPath[0] = 0;
+ }
+ for (int i = 1;;i++) {
+ if (i == 1) wsprintf(opts.backupFilename,TranslateT("%s\\Backup of %s"),dbPath,dbFile);
+ else wsprintf(opts.backupFilename,TranslateT("%s\\Backup (%d) of %s"),dbPath,i,dbFile);
+ if (_taccess(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"));
+
ProcessingDone();
}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj b/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj
deleted file mode 100644
index 7b734e1736..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj
+++ /dev/null
@@ -1,232 +0,0 @@
-<?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>
- <PropertyGroup Label="Globals">
- <ProjectName>Dbtool_SA</ProjectName>
- <ProjectGuid>{6E233FE8-8D90-454F-A9DC-AC2B5555D137}</ProjectGuid>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <CharacterSet>Unicode</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <CharacterSet>Unicode</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
- <IgnoreImportLibrary>true</IgnoreImportLibrary>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\..\..\include;..\..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>dbtool.h</PrecompiledHeaderFile>
- <WarningLevel>Level3</WarningLevel>
- <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
- </ClCompile>
- <ResourceCompile>
- <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..\include;..\..\include\msapi</AdditionalIncludeDirectories>
- </ResourceCompile>
- <Link>
- <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Windows</SubSystem>
- <RandomizedBaseAddress>false</RandomizedBaseAddress>
- <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalManifestDependencies>type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27X86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
- </Link>
- <PreBuildEvent>
- <Command>..\..\..\bin10\make_ver.bat</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\..\..\include;..\..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>dbtool.h</PrecompiledHeaderFile>
- <WarningLevel>Level3</WarningLevel>
- </ClCompile>
- <ResourceCompile>
- <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..\include;..\..\include\msapi</AdditionalIncludeDirectories>
- </ResourceCompile>
- <Link>
- <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalManifestDependencies>type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Windows</SubSystem>
- <RandomizedBaseAddress>false</RandomizedBaseAddress>
- <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
- </Link>
- <PreBuildEvent>
- <Command>..\..\..\bin10\make_ver.bat</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <Optimization>Full</Optimization>
- <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
- <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
- <AdditionalIncludeDirectories>..\..\..\include;..\..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <StringPooling>true</StringPooling>
- <ExceptionHandling>false</ExceptionHandling>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>dbtool.h</PrecompiledHeaderFile>
- <WarningLevel>Level3</WarningLevel>
- <BufferSecurityCheck>false</BufferSecurityCheck>
- <FloatingPointModel>Fast</FloatingPointModel>
- </ClCompile>
- <ResourceCompile>
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..\include;..\..\include\msapi</AdditionalIncludeDirectories>
- </ResourceCompile>
- <Link>
- <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalManifestDependencies>type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27X86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <OptimizeReferences>true</OptimizeReferences>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <RandomizedBaseAddress>false</RandomizedBaseAddress>
- <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <SubSystem>Windows</SubSystem>
- <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
- </Link>
- <PreBuildEvent>
- <Command>..\..\..\bin10\make_ver.bat</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <Optimization>Full</Optimization>
- <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
- <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
- <AdditionalIncludeDirectories>..\..\..\include;..\..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <StringPooling>true</StringPooling>
- <ExceptionHandling>false</ExceptionHandling>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>dbtool.h</PrecompiledHeaderFile>
- <WarningLevel>Level3</WarningLevel>
- <BufferSecurityCheck>false</BufferSecurityCheck>
- <FloatingPointModel>Fast</FloatingPointModel>
- </ClCompile>
- <ResourceCompile>
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..\include;..\..\include\msapi</AdditionalIncludeDirectories>
- </ResourceCompile>
- <Link>
- <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalManifestDependencies>type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
- <OptimizeReferences>true</OptimizeReferences>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <RandomizedBaseAddress>false</RandomizedBaseAddress>
- <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
- </Link>
- <PreBuildEvent>
- <Command>..\..\..\bin10\make_ver.bat</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="src\disk.cpp" />
- <ClCompile Include="src\encryption.cpp" />
- <ClCompile Include="src\main.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="src\utf.cpp" />
- <ClCompile Include="src\wizard.cpp" />
- <ClCompile Include="src\worker.cpp" />
- <ClCompile Include="src\aggressive.cpp" />
- <ClCompile Include="src\contactchain.cpp" />
- <ClCompile Include="src\eventchain.cpp" />
- <ClCompile Include="src\finaltasks.cpp" />
- <ClCompile Include="src\initialchecks.cpp" />
- <ClCompile Include="src\modulechain.cpp" />
- <ClCompile Include="src\settingschain.cpp" />
- <ClCompile Include="src\user.cpp" />
- <ClCompile Include="src\cleaning.cpp" />
- <ClCompile Include="src\fileaccess.cpp" />
- <ClCompile Include="src\finished.cpp" />
- <ClCompile Include="src\openerror.cpp" />
- <ClCompile Include="src\progress.cpp" />
- <ClCompile Include="src\selectdb.cpp" />
- <ClCompile Include="src\welcome.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="src\database.h" />
- <ClInclude Include="src\dbtool.h" />
- <ClInclude Include="src\Version.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="res\resource.rc" />
- <ResourceCompile Include="res\Version.rc" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters b/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters
deleted file mode 100644
index d7c4efe5f7..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{72e8c0e0-409e-4656-8598-9a0c769f0e34}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
- </Filter>
- <Filter Include="Source Files\Workers">
- <UniqueIdentifier>{c81aa4f4-b471-4488-909a-ab503857cb18}</UniqueIdentifier>
- </Filter>
- <Filter Include="Source Files\Wizard Pages">
- <UniqueIdentifier>{eccf4f04-aceb-441f-924b-ead9bbb92168}</UniqueIdentifier>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{12ab2eb9-15e3-4147-ae4a-847ddc95c531}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{07c47951-e20f-43c5-912f-ea300b807935}</UniqueIdentifier>
- <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="src\disk.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="src\main.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\aggressive.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="src\contactchain.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="src\eventchain.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="src\finaltasks.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="src\initialchecks.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="src\modulechain.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="src\settingschain.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="src\user.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="src\cleaning.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="src\fileaccess.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="src\finished.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="src\openerror.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="src\progress.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="src\selectdb.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="src\welcome.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="src\utf.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="src\encryption.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="src\database.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="src\dbtool.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="src\Version.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="res\resource.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- <ResourceCompile Include="res\Version.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/plugins/Dbx_mmap_SA/Dbtool/res/Version.rc b/plugins/Dbx_mmap_SA/Dbtool/res/Version.rc
deleted file mode 100644
index f9dd44c219..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/res/Version.rc
+++ /dev/null
@@ -1,42 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#ifdef APSTUDIO_INVOKED
-#error this file is not editable by Microsoft Visual C++
-#endif //APSTUDIO_INVOKED
-
-#include "afxres.h"
-#include "..\src\version.h"
-
-#ifdef _WIN32
-LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
-#endif //_WIN32
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION __FILEVERSION_STRING
- PRODUCTVERSION __FILEVERSION_STRING
- FILEFLAGSMASK 0x17L
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x4L
- FILETYPE 0x0L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "000004b0"
- BEGIN
- VALUE "FileDescription", __DESCRIPTION
- VALUE "InternalName", __INTERNAL_NAME
- VALUE "LegalCopyright", __COPYRIGHT
- VALUE "OriginalFilename", __FILENAME
- VALUE "ProductName", __DESCRIPTION
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x0, 1200
- END
-END
diff --git a/plugins/Dbx_mmap_SA/Dbtool/res/dbtool.bmp b/plugins/Dbx_mmap_SA/Dbtool/res/dbtool.bmp
deleted file mode 100644
index 30a050bd61..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/res/dbtool.bmp
+++ /dev/null
Binary files differ
diff --git a/plugins/Dbx_mmap_SA/Dbtool/res/dbtool.exe.manifest b/plugins/Dbx_mmap_SA/Dbtool/res/dbtool.exe.manifest
deleted file mode 100644
index 1b6aab686b..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/res/dbtool.exe.manifest
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity
- version="1.0.0.0"
- processorArchitecture="X86"
- name="Miranda.Miranda.Miranda"
- type="win32"
-/>
-<description>Miranda</description>
- <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
- <security>
- <requestedPrivileges>
- <requestedExecutionLevel
- level="asInvoker"
- uiAccess="false"/>
- </requestedPrivileges>
- </security>
- </trustInfo>
-<dependency>
- <dependentAssembly>
- <assemblyIdentity
- type="win32"
- name="Microsoft.Windows.Common-Controls"
- version="6.0.0.0"
- processorArchitecture="X86"
- publicKeyToken="6595b64144ccf1df"
- language="*"
- />
- </dependentAssembly>
-</dependency>
-</assembly>
diff --git a/plugins/Dbx_mmap_SA/Dbtool/res/dbtool.ico b/plugins/Dbx_mmap_SA/Dbtool/res/dbtool.ico
deleted file mode 100644
index b752129bc5..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/res/dbtool.ico
+++ /dev/null
Binary files differ
diff --git a/plugins/Dbx_mmap_SA/Dbtool/res/delete.ico b/plugins/Dbx_mmap_SA/Dbtool/res/delete.ico
deleted file mode 100644
index 6e39da592b..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/res/delete.ico
+++ /dev/null
Binary files differ
diff --git a/plugins/Dbx_mmap_SA/Dbtool/res/profileg.ico b/plugins/Dbx_mmap_SA/Dbtool/res/profileg.ico
deleted file mode 100644
index 1cd1caa5e4..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/res/profileg.ico
+++ /dev/null
Binary files differ
diff --git a/plugins/Dbx_mmap_SA/Dbtool/res/profiler.ico b/plugins/Dbx_mmap_SA/Dbtool/res/profiler.ico
deleted file mode 100644
index 2dc702c863..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/res/profiler.ico
+++ /dev/null
Binary files differ
diff --git a/plugins/Dbx_mmap_SA/Dbtool/res/profiley.ico b/plugins/Dbx_mmap_SA/Dbtool/res/profiley.ico
deleted file mode 100644
index d482ee47ad..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/res/profiley.ico
+++ /dev/null
Binary files differ
diff --git a/plugins/Dbx_mmap_SA/Dbtool/res/resource.rc b/plugins/Dbx_mmap_SA/Dbtool/res/resource.rc
deleted file mode 100644
index 25710d5ca8..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/res/resource.rc
+++ /dev/null
@@ -1,368 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "..\src\resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include <windows.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
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-IDB_BITMAP1 BITMAP "dbtool.bmp"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_LOGIN DIALOGEX 0, 0, 182, 78
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
-EXSTYLE WS_EX_TOPMOST | WS_EX_TOOLWINDOW
-CAPTION "Miranda MMAP Secured Database"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- DEFPUSHBUTTON "OK",IDOK,33,59,54,14
- PUSHBUTTON "Cancel",IDCANCEL,91,59,54,14
- CTEXT "Please enter password for",IDC_LOGININFO,6,4,169,8
- CTEXT "",IDC_DBNAME,5,14,169,8
- EDITTEXT IDC_USERPASS,15,33,132,14,ES_PASSWORD | ES_AUTOHSCROLL
- CTEXT "EN",IDC_LANG,155,32,16,14,SS_CENTERIMAGE
- CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,0,26,181,1
- CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,0,53,181,1
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
-BEGIN
- IDD_LOGIN, DIALOG
- BEGIN
- LEFTMARGIN, 6
- RIGHTMARGIN, 175
- TOPMARGIN, 7
- BOTTOMMARGIN, 73
- HORZGUIDE, 68
- END
-END
-#endif // APSTUDIO_INVOKED
-
-#endif // Russian resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// RT_MANIFEST
-//
-
-1 RT_MANIFEST "dbtool.exe.manifest"
-#endif // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.K.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
-#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 IDI_PROFILEYELLOW,IDC_WATERMARK,"Static",SS_BITMAP,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 programme is licenced 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,2,0,259,32
- LTEXT "Select Miranda Profile",IDC_STATIC,11,6,206,8,WS_BORDER
- ICON IDI_DBTOOL,IDC_HDRLOGO,234,3,20,20
- LTEXT "You can choose the Miranda profile database to compact or repair.",IDC_STATIC,20,14,220,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
- LTEXT "&File:",IDC_STATIC,10,130,20,8
- EDITTEXT IDC_FILE,32,128,176,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,261,32
- LTEXT "Error Opening Database",IDC_STATIC,11,6,206,8,WS_BORDER
- ICON IDI_DBTOOL,IDC_HDRLOGO,234,3,20,20
- 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,261,32
- LTEXT "File Access Options",IDC_STATIC,11,6,206,8,WS_BORDER
- ICON IDI_DBTOOL,IDC_HDRLOGO,234,3,20,20
- 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,261,32
- LTEXT "Cleaning Options",IDC_STATIC,11,6,206,8,WS_BORDER
- ICON IDI_DBTOOL,IDC_HDRLOGO,234,3,20,20
- LTEXT "You can choose to remove information from the database while it is being processed.",IDC_STATIC,20,14,220,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,261,32
- LTEXT "Working...",-1,11,6,206,8,WS_BORDER
- ICON IDI_DBTOOL,IDC_HDRLOGO,234,3,20,20
- 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
- ICON IDI_DBTOOL,IDC_HDRLOGO,234,3,20,20
- 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,239,10,WS_EX_CLIENTEDGE
- LTEXT "Launches Miranda with the profile that was just worked on.",IDC_STATIC,37,98,225,8
- LTEXT "",IDC_DBFILE,23,68,239,8,SS_NOPREFIX | WS_BORDER
- RTEXT "Backup:",IDC_STBACKUP,23,76,30,8
- LTEXT "",IDC_BACKUPFILE,69,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,220,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
- VERTGUIDE, 37
- TOPMARGIN, 38
- BOTTOMMARGIN, 136
- END
-END
-#endif // APSTUDIO_INVOKED
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "..\\src\\resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include <windows.h>\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// 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_PROFILEYELLOW ICON "profiley.ico"
-IDI_PROFILERED ICON "profiler.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/Dbx_mmap_SA/Dbtool/src/Version.h b/plugins/Dbx_mmap_SA/Dbtool/src/Version.h
deleted file mode 100644
index 1ee2b8a4cf..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/Version.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "m_version.h"
-
-#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION
-#define __VERSION_STRING MIRANDA_VERSION_STRING
-#define __VERSION_DWORD MIRANDA_VERSION_DWORD
-#define __INTERNAL_NAME "dbtool"
-#define __FILENAME "dbtool.exe"
-#define __DESCRIPTION "Miranda IM Database Tool"
-#define __COPYRIGHT "© 2000-2011 Miranda IM project"
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/aggressive.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/aggressive.cpp
deleted file mode 100644
index 5ec62707f1..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/aggressive.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-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 "dbtool.h"
-
-#define BLOCKSIZE 65536
-
-extern DWORD sourceFileSize;
-extern DWORD spaceProcessed;
-extern DWORD sp;
-static DWORD ofsCurrent;
-
-int WorkAggressive(int firstTime)
-{
- int blockBytes,i;
- BYTE *buf;
-
- if(firstTime) {
- if (!opts.bAggressive) return ERROR_NO_MORE_ITEMS;
- AddToStatus(STATUS_MESSAGE,TranslateT("Performing aggressive pass"));
- ofsCurrent=0;
- spaceProcessed=0;
- sp=0;
- }
- blockBytes=min(BLOCKSIZE+3,(int)(sourceFileSize-ofsCurrent));
- if(blockBytes<=0) return ERROR_NO_MORE_ITEMS;
- buf = opts.pFile+ofsCurrent;
- blockBytes-=3;
- for(i=0;i<blockBytes;i++) {
- if(buf[i]) {
- if ((*(PDWORD)&buf[i]&0x00FFFFFF)!=0xDECADE)
- AddToStatus(STATUS_WARNING,TranslateT("Aggressive: random junk at %08X: skipping"),ofsCurrent+i);
- else {
- //TODO: give user the option of placing manually
- AddToStatus(STATUS_ERROR,TranslateT("Aggressive: unlinked data at %08X: can't automatically place"),ofsCurrent+i);
- }
- for (;i<blockBytes;i++)
- if(buf[i]==0) {i--; break;}
- }
- }
- ofsCurrent+=BLOCKSIZE;
- spaceProcessed=ofsCurrent;
- return ERROR_SUCCESS;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/cleaning.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/cleaning.cpp
deleted file mode 100644
index a16a11e7ac..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/cleaning.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-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 "dbtool.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);
- EnableWindow(GetDlgItem(hdlg,IDC_ERASEHISTORY),!opts.bAggressive);
- CheckDlgButton(hdlg,IDC_MARKREAD,opts.bMarkRead);
- CheckDlgButton(hdlg,IDC_CONVERTUTF,opts.bConvertUtf);
- 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)
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_SELECTDB,(LPARAM)SelectDbDlgProc);
- else
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_FILEACCESS,(LPARAM)FileAccessDlgProc);
- break;
- case IDOK:
- if (!opts.hFile) {
- opts.hFile = CreateFile( opts.filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
- if ( opts.hFile == INVALID_HANDLE_VALUE ) {
- opts.hFile = NULL;
- opts.error = GetLastError();
- SendMessage( GetParent(hdlg), WZM_GOTOPAGE, IDD_OPENERROR, ( LPARAM )OpenErrorDlgProc );
- break;
- }
- }
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_PROGRESS,(LPARAM)ProgressDlgProc);
- break;
- }
- break;
- }
- return FALSE;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/contactchain.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/contactchain.cpp
deleted file mode 100644
index 0452f90d0d..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/contactchain.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
-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 "dbtool.h"
-
-int WorkSettingsChain(DWORD ofsContact,DBContact *dbc,int firstTime);
-int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime);
-
-static DWORD ofsThisContact,ofsDestPrevContact;
-static DWORD contactCount;
-static DWORD ofsDestThis,ofsNextContact;
-static int phase;
-static DBContact dbc;
-
-static void FinishUp(void)
-{
- if(contactCount!=dbhdr.contactCount)
- AddToStatus(STATUS_WARNING,TranslateT("Contact count marked wrongly: correcting"));
- dbhdr.contactCount=contactCount;
-}
-
-int WorkContactChain(int firstTime)
-{
- int first=0;
-
- if(firstTime) {
- AddToStatus(STATUS_MESSAGE,TranslateT("Processing contact chain"));
- ofsDestPrevContact=0;
- ofsThisContact=dbhdr.ofsFirstContact;
- contactCount=0;
- dbhdr.ofsFirstContact=0;
- phase=0;
- }
-
- switch(phase) {
- int ret;
- case 0:
- if(ofsThisContact==0) {
- FinishUp();
- return ERROR_NO_MORE_ITEMS;
- }
- if (!SignatureValid(ofsThisContact,DBCONTACT_SIGNATURE)) {
- AddToStatus(STATUS_ERROR,TranslateT("Contact chain corrupted, further entries ignored"));
- FinishUp();
- return ERROR_NO_MORE_ITEMS;
- }
- if(ReadSegment(ofsThisContact,&dbc,sizeof(dbc))!=ERROR_SUCCESS) {
- FinishUp();
- return ERROR_NO_MORE_ITEMS;
- }
- ofsNextContact=dbc.ofsNext;
- dbc.ofsNext=0;
- if (!opts.bCheckOnly) {
- if ((ofsDestThis=WriteSegment(WSOFS_END,&dbc,sizeof(dbc)))==WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- if(ofsDestPrevContact)
- WriteSegment(ofsDestPrevContact+offsetof(DBContact,ofsNext),&ofsDestThis,sizeof(DWORD));
- else
- dbhdr.ofsFirstContact=ofsDestThis;
- } else
- ofsDestThis = ofsThisContact; // needed in event chain worker
- contactCount++;
- phase++; first=1;
- //fall thru
- case 1:
- ret=WorkSettingsChain(ofsDestThis,&dbc,first);
- if(ret==ERROR_NO_MORE_ITEMS) {
- phase++; first=1;
- }
- else if(ret) return ret;
- else break;
- //fall thru
- case 2:
- ret=WorkEventChain(ofsDestThis,&dbc,first);
- if(ret==ERROR_NO_MORE_ITEMS) {
- phase++; first=1;
- }
- else if(ret) return ret;
- else break;
- //fall thru
- case 3:
- if(WriteSegment(ofsDestThis,&dbc,sizeof(DBContact))==WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- ofsDestPrevContact=ofsDestThis;
- ofsThisContact=ofsNextContact;
- phase=0;
- break;
- }
- return ERROR_SUCCESS;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/database.h b/plugins/Dbx_mmap_SA/Dbtool/src/database.h
deleted file mode 100644
index aa73d16362..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/database.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2005 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.
-*/
-
-//all offsets are relative to the start of the file
-//offsets are 0 if there is nothing in the chain or this is the last in the
-//chain
-
-/* tree diagram
-
-DBHeader
- |-->end of file (plain offset)
- |-->first contact (DBContact)
- | |-->next contact (DBContact)
- | | \--> ...
- | |-->first settings (DBContactSettings)
- | | |-->next settings (DBContactSettings)
- | | | \--> ...
- | | \-->module name (DBModuleName)
- | \-->first/last/firstunread event
- |-->user contact (DBContact)
- | |-->next contact=NULL
- | |-->first settings as above
- | \-->first/last/firstunread event as above
- \-->first module name (DBModuleName)
- \-->next module name (DBModuleName)
- \--> ...
-*/
-
-#define DB_RESIZE_GRANULARITY 16384
-#define DB_THIS_VERSION 0x00000700u
-#define DB_SETTINGS_RESIZE_GRANULARITY 128
-
-#include <pshpack1.h>
-struct DBHeader {
- BYTE signature[16]; // 'Miranda ICQ DB',0,26
-
- WORD checkWord;
- WORD cryptorUID;
- DWORD ofsFileEnd; //offset of the end of the database - place to write
- //new structures
- DWORD slackSpace; //a counter of the number of bytes that have been
- //wasted so far due to deleting structures and/or
- //re-making them at the end. We should compact when
- //this gets above a threshold
- DWORD contactCount; //number of contacts in the chain,excluding the user
- DWORD ofsFirstContact; //offset to first struct DBContact in the chain
- DWORD ofsUser; //offset to struct DBContact representing the user
- DWORD ofsFirstModuleName; //offset to first struct DBModuleName in the chain
-};
-
-#define DBCONTACT_SIGNATURE 0x43DECADEu
-struct DBContact {
- DWORD signature;
- DWORD ofsNext; //offset to the next contact in the chain. zero if
- //this is the 'user' contact or the last contact
- //in the chain
- DWORD ofsFirstSettings; //offset to the first DBContactSettings in the
- //chain for this contact.
- DWORD eventCount; //number of events in the chain for this contact
- DWORD ofsFirstEvent,ofsLastEvent; //offsets to the first and last DBEvent in
- //the chain for this contact
- DWORD ofsFirstUnreadEvent; //offset to the first (chronological) unread event
- //in the chain, 0 if all are read
- DWORD timestampFirstUnread; //timestamp of the event at ofsFirstUnreadEvent
-};
-
-#define DBMODULENAME_SIGNATURE 0x4DDECADEu
-struct DBModuleName {
- DWORD signature;
- DWORD ofsNext; //offset to the next module name in the chain
- BYTE cbName; //number of characters in this module name
- char name[1]; //name, no nul terminator
-};
-
-#define DBCONTACTSETTINGS_SIGNATURE 0x53DECADEu
-struct DBContactSettings {
- DWORD signature;
- DWORD ofsNext; //offset to the next contactsettings in the chain
- DWORD ofsModuleName; //offset to the DBModuleName of the owner of these
- //settings
- DWORD cbBlob; //size of the blob in bytes. May be larger than the
- //actual size for reducing the number of moves
- //required using granularity in resizing
- BYTE blob[1]; //the blob. a back-to-back sequence of DBSetting
- //structs, the last has cbName=0
-};
-
-/* not a valid structure, content is figured out on the fly
-struct DBSetting {
- BYTE cbName; //number of bytes in the name of this setting
- //this =0 marks the end
- char szName[...]; //setting name, excluding nul
- BYTE dataType; //type of data. see m_database.h, db/contact/getsetting
- union { //a load of types of data, length is defined by dataType
- BYTE bVal; WORD wVal; DWORD dVal;
- struct {
- WORD cbString;
- char szVal[...]; //excludes nul terminator
- };
- struct {
- WORD cbBlob;
- BYTE blobVal[...];
- };
- };
-};
-*/
-
-#define DBEVENT_SIGNATURE 0x45DECADEu
-struct DBEvent {
- DWORD signature;
- DWORD ofsPrev,ofsNext; //offset to the previous and next events in the
- //chain. Chain is sorted chronologically
- DWORD ofsModuleName; //offset to a DBModuleName struct of the name of
- //the owner of this event
- DWORD timestamp; //seconds since 00:00:00 01/01/1970
- DWORD flags; //see m_database.h, db/event/add
- WORD eventType; //module-defined event type
- DWORD cbBlob; //number of bytes in the blob
- BYTE blob[1]; //the blob. module-defined formatting
-};
-#include <poppack.h>
-
-//databasecorruption: called if any signatures are broken. very very fatal
-void DatabaseCorruption(const char *szPart);
-PBYTE DBRead(DWORD ofs,int bytesRequired,int *bytesAvail); //any preview result could be invalidated by the next call
-void DBWrite(DWORD ofs,PVOID pData,int count);
-void DBFlush(int setting);
-void DBMoveChunk(DWORD ofsDest,DWORD ofsSource,int bytes);
-DWORD CreateNewSpace(int bytes);
-void DeleteSpace(DWORD ofs,int bytes);
-void GetProfileDirectory(char *szPath,int cbPath);
-int GetDefaultProfilePath(char *szPath,int cbPath,int *specified);
-int ShouldShowProfileManager(void);
-
-#ifdef _DEBUG
-#define MAXCACHEDREADSIZE 512
-#else
-#define MAXCACHEDREADSIZE 2048 //technically 4096 would work, but I'm not going to push it
-#endif
-
-#ifdef _DEBUG
-//#define DBLOGGING
-#endif
-#ifdef DBLOGGING
-void DBLog(const char *file,int line,const char *fmt,...);
-#define logg() DBLog(__FILE__,__LINE__,"")
-#define log0(s) DBLog(__FILE__,__LINE__,s)
-#define log1(s,a) DBLog(__FILE__,__LINE__,s,a)
-#define log2(s,a,b) DBLog(__FILE__,__LINE__,s,a,b)
-#define log3(s,a,b,c) DBLog(__FILE__,__LINE__,s,a,b,c)
-#define log4(s,a,b,c,d) DBLog(__FILE__,__LINE__,s,a,b,c,d)
-#else
-#define logg()
-#define log0(s)
-#define log1(s,a)
-#define log2(s,a,b)
-#define log3(s,a,b,c)
-#define log4(s,a,b,c,d)
-#endif \ No newline at end of file
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/dbtool.h b/plugins/Dbx_mmap_SA/Dbtool/src/dbtool.h
deleted file mode 100644
index 7f89ecd7aa..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/dbtool.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-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.
-*/
-
-#define _CRT_SECURE_NO_WARNINGS
-#define _CRT_NON_CONFORMING_SWPRINTFS
-
-#include <tchar.h>
-
-#include <windows.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <io.h>
-#include <stdarg.h>
-#include <process.h>
-#include <direct.h>
-#include <malloc.h>
-#include <commctrl.h>
-#include <time.h>
-#include <win2k.h>
-
-#include "m_database.h"
-#include "database.h" // Note: This is a copy of database.h from the Miranda IM v0.3 tree.
- // Remember to update this when releasing new dbtool versions.
-#include "resource.h"
-
-#define WZM_GOTOPAGE (WM_USER+1)
-#define WZN_PAGECHANGING (WM_USER+1221)
-#define WZN_CANCELCLICKED (WM_USER+1222)
-
-struct DbToolOptions {
- TCHAR filename[MAX_PATH];
- TCHAR workingFilename[MAX_PATH];
- TCHAR outputFilename[MAX_PATH];
- TCHAR backupFilename[MAX_PATH];
- HANDLE hFile;
- HANDLE hOutFile;
- HANDLE hMap;
- BYTE *pFile;
- DWORD error;
- int bCheckOnly,bBackup,bAggressive;
- int bEraseHistory,bMarkRead,bConvertUtf;
-};
-
-extern HINSTANCE hInst;
-extern DbToolOptions opts;
-extern DBHeader dbhdr;
-
-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);
-
-struct DBSignature {
- char name[15];
- BYTE eof;
-};
-static struct DBSignature dbSignature={"Miranda ICQ DB",0x1A};
-static struct DBSignature dbSignatureEncrypted={"Miranda ICQ SD",0x1A};
-
-#define SIZEOF(X) (sizeof(X)/sizeof(X[0]))
-
-#define STATUS_MESSAGE 0
-#define STATUS_WARNING 1
-#define STATUS_ERROR 2
-#define STATUS_FATAL 3
-#define STATUS_SUCCESS 4
-#define STATUS_CLASSMASK 0x0f
-int AddToStatus(DWORD flags, TCHAR* fmt,...);
-void SetProgressBar(int perThou);
-
-int PeekSegment(DWORD ofs,PVOID buf,int cbBytes);
-int ReadSegment(DWORD ofs,PVOID buf,int cbBytes);
-#define WSOFS_END 0xFFFFFFFF
-#define WS_ERROR 0xFFFFFFFF
-DWORD WriteSegment(DWORD ofs,PVOID buf,int cbBytes);
-int ReadWrittenSegment(DWORD ofs,PVOID buf,int cbBytes);
-int SignatureValid(DWORD ofs,DWORD signature);
-DWORD ConvertModuleNameOfs(DWORD ofsOld);
-void FreeModuleChain();
-extern BOOL bEncrypted;
-
-bool is_utf8_string(const char* str);
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/disk.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/disk.cpp
deleted file mode 100644
index 1ac84a3dc6..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/disk.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
-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 "dbtool.h"
-
-extern DWORD spaceProcessed,sourceFileSize;
-
-int SignatureValid(DWORD ofs,DWORD signature)
-{
- DWORD sig;
-
- if(ofs+sizeof(sig)>=sourceFileSize) {
- AddToStatus(STATUS_ERROR,TranslateT("Invalid offset found (database truncated?)"));
- return 0;
- }
-
- sig = *(DWORD*)(opts.pFile+ofs);
-
- return sig==signature;
-}
-
-int PeekSegment(DWORD ofs,PVOID buf,int cbBytes)
-{
- DWORD bytesRead;
-
- if(ofs>=sourceFileSize) {
- AddToStatus(STATUS_ERROR,TranslateT("Invalid offset found"));
- return ERROR_SEEK;
- }
-
- if (ofs+cbBytes>sourceFileSize)
- bytesRead = sourceFileSize - ofs;
- else
- bytesRead = cbBytes;
-
- if(bytesRead==0) {
- AddToStatus(STATUS_ERROR,TranslateT("Error reading, database truncated? (%u)"),GetLastError());
- return ERROR_READ_FAULT;
- }
-
- CopyMemory(buf, opts.pFile+ofs, bytesRead);
-
- if ((int)bytesRead<cbBytes) return ERROR_HANDLE_EOF;
- return ERROR_SUCCESS;
-}
-
-int ReadSegment(DWORD ofs,PVOID buf,int cbBytes)
-{
- int ret;
-
- ret=PeekSegment(ofs,buf,cbBytes);
- if(ret!=ERROR_SUCCESS && ret!=ERROR_HANDLE_EOF) return ret;
-
- if(opts.bAggressive) {
- if (ofs+cbBytes>sourceFileSize) {
- AddToStatus(STATUS_WARNING,TranslateT("Can't write to working file, aggressive mode may be too aggressive now"));
- ZeroMemory(opts.pFile+ofs,sourceFileSize-ofs);
- }
- else
- ZeroMemory(opts.pFile+ofs,cbBytes);
- }
- spaceProcessed+=cbBytes;
- return ERROR_SUCCESS;
-}
-
-DWORD WriteSegment(DWORD ofs,PVOID buf,int cbBytes)
-{
- DWORD bytesWritten;
- if(opts.bCheckOnly) return 0xbfbfbfbf;
- if(ofs==WSOFS_END) {
- ofs=dbhdr.ofsFileEnd;
- dbhdr.ofsFileEnd+=cbBytes;
- }
- SetFilePointer(opts.hOutFile,ofs,NULL,FILE_BEGIN);
- WriteFile(opts.hOutFile,buf,cbBytes,&bytesWritten,NULL);
- if ((int)bytesWritten<cbBytes) {
- AddToStatus(STATUS_FATAL,TranslateT("Can't write to output file - disk full? (%u)"),GetLastError());
- return WS_ERROR;
- }
- return ofs;
-}
-
-
-int ReadWrittenSegment(DWORD ofs,PVOID buf,int cbBytes)
-{
- DWORD bytesRead;
- if(opts.bCheckOnly) return 0xbfbfbfbf;
- if(ofs + cbBytes > dbhdr.ofsFileEnd )
- return ERROR_SEEK;
-
- SetFilePointer(opts.hOutFile,ofs,NULL,FILE_BEGIN);
- ReadFile(opts.hOutFile,buf,cbBytes,&bytesRead,NULL);
- if ((int)bytesRead<cbBytes)
- return ERROR_READ_FAULT;
-
- return ERROR_SUCCESS;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/encryption.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/encryption.cpp
deleted file mode 100644
index 1e7b264efa..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/encryption.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-// (C) Artem Shpynov aka FYR and Igonin Vitaliy aka chaos.persei, 2007 - 2008
-
-#include "dbtool.h"
-
-typedef struct{
- void* (__stdcall *GenerateKey)(char* pwd);
- void (__stdcall *FreeKey)(void* key);
- void (__stdcall *EncryptMem)(BYTE* data, int size, void* key);
- void (__stdcall *DecryptMem)(BYTE* data, int size, void* key);
-
- char* Name;
- char* Info;
- char* Author;
- char* Site;
- char* Email;
-
- DWORD Version;
-
- WORD uid;
-} Cryptor;
-
-typedef struct{
- char dllname[255];
- HMODULE hLib;
- Cryptor* cryptor;
-} CryptoModule;
-
-BOOL CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
-char encryptKey[255];
-size_t encryptKeyLength;
-
-int wrongPass = 0;
-void* key;
-
-Cryptor* CryptoEngine = NULL;
-
-int ModulesCount = 0;
-CryptoModule* Modules[100];
-
-
-void zero_fill(BYTE * pBuf, size_t bufSize)
-{
- size_t i;
- for(i = 0; i < bufSize; i++)
- pBuf[i] = 0;
-}
-
-void InitSecurity()
-{
- HMODULE hLib;
- WIN32_FIND_DATAA fd;
-
- Cryptor* (__stdcall *GetCryptor)();
-
- {
- TCHAR szMirandaDir[MAX_PATH];
- szMirandaDir[ 0 ] = 0;
- TCHAR *str2;
- GetModuleFileName(NULL,szMirandaDir,SIZEOF(szMirandaDir));
- str2 = _tcsrchr(szMirandaDir,'\\');
- if ( str2 != NULL )
- *str2=0;
- _tchdir(szMirandaDir);
- }
-
- HANDLE hFile = FindFirstFileA(".\\plugins\\cryptors\\*.dll", &fd);
-
- AddToStatus(STATUS_MESSAGE,TranslateT("Scanning cryptors directory"));
-
- ModulesCount = 0;
- while (hFile != INVALID_HANDLE_VALUE)
- {
- char tmp[MAX_PATH], buf[255];
- strcpy(tmp, ".\\plugins\\cryptors\\");
- strcat(tmp, fd.cFileName);
-
- hLib = LoadLibraryA(tmp);
- if(hLib){
- GetCryptor = (Cryptor* (__stdcall *)()) GetProcAddress(hLib, "GetCryptor");
- if(GetCryptor){
- TCHAR Name[100], Version[100], DllName[100];
-
-
- Modules[ModulesCount] = (CryptoModule*) malloc(sizeof(CryptoModule));
- Modules[ModulesCount]->cryptor = GetCryptor();
- strcpy(Modules[ModulesCount]->dllname, fd.cFileName);
- Modules[ModulesCount]->hLib = hLib;
-
- _snprintf(buf,SIZEOF(buf),"%d.%d.%d.%d", HIBYTE(HIWORD(Modules[ModulesCount]->cryptor->Version)), LOBYTE(HIWORD(Modules[ModulesCount]->cryptor->Version)), HIBYTE(LOWORD(Modules[ModulesCount]->cryptor->Version)), LOBYTE(LOWORD(Modules[ModulesCount]->cryptor->Version)));
-
- mbstowcs(Name, Modules[ModulesCount]->cryptor->Name, 100);
- mbstowcs(Version, buf, 100);
- mbstowcs(DllName, Modules[ModulesCount]->dllname, 100);
-
- AddToStatus(STATUS_MESSAGE,TranslateT("Cryptor loaded: %s [%s] (%s)"), Name, Version, DllName);
-
- ModulesCount++;
- }else{
- FreeLibrary(hLib);
- }
- }
- if(ModulesCount >= 100) break;
- if (!FindNextFileA(hFile, &fd)) break;
- }
-
- AddToStatus(STATUS_MESSAGE,TranslateT("%d crypto modules loaded"), ModulesCount);
-}
-
-void UnloadSecurity()
-{
- int i;
-
- if(CryptoEngine) CryptoEngine->FreeKey(key);
-
- for(i = 0; i < ModulesCount; i++)
- {
- FreeLibrary(Modules[i]->hLib);
- free(Modules[i]);
- }
-}
-
-void EncoderInit()
-{
- encryptKey[encryptKeyLength] = 0;
- key = CryptoEngine->GenerateKey(encryptKey);
-}
-
-void EncodeCopyMemory(BYTE * dst, void * src, size_t size )
-{
- memcpy(dst, src, size);
- CryptoEngine->EncryptMem(dst, (int)size, key);
-}
-
-void DecodeCopyMemory(BYTE * dst, void * src, size_t size )
-{
- memcpy(dst, src, size);
- CryptoEngine->DecryptMem(dst, (int)size, key);
-}
-
-
-void EncodeMemory(BYTE * mem, size_t size)
-{
- CryptoEngine->EncryptMem(mem, (int)size, key);
-}
-
-void DecodeMemory(BYTE * mem, size_t size)
-{
- CryptoEngine->DecryptMem(mem, (int)size, key);
-}
-
-int bCheckingPass = 0;
-
-int CheckPassword(WORD checkWord, WORD cryptorUID, char * szDBName)
-{
- WORD ver;
- int res;
-
- if(bCheckingPass) return 0;
- bCheckingPass = 1;
-
- {
- int i;
- int Found = 0;
- for(i = 0; i < ModulesCount; i++) {
- if(cryptorUID == Modules[i]->cryptor->uid){
- CryptoEngine = Modules[i]->cryptor;
- Found = 1;
- break;
- }
- }
- if (!Found){
- AddToStatus(STATUS_FATAL, TranslateT("Sorry, but your database encrypted with unknown module"), MB_OK);
- bCheckingPass = 0;
- return 0;
- }
- }
-
- {
- wchar_t Name[100], Author[100];
-
- mbstowcs(Name, CryptoEngine->Name, 100);
- mbstowcs(Author, CryptoEngine->Author, 100);
-
- AddToStatus(STATUS_MESSAGE, TranslateT("Database encrypted with %s by %s"), Name, Author);
- }
-
- while(1){
- res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_LOGIN), NULL, (DLGPROC)DlgStdInProc, (LPARAM)szDBName);
- if(res == IDCANCEL)
- {
- wrongPass = 0;
- bCheckingPass = 0;
- return 0;
- }
- if(encryptKeyLength < 1) continue;
- EncoderInit();
- DecodeCopyMemory((BYTE*)&ver, &checkWord, sizeof(checkWord));
- if(ver == 0x5195)
- {
- wrongPass = 0;
- bCheckingPass = 0;
- return 1;
- }
- wrongPass++;
- }
-
- bCheckingPass = 0;
-}
-
-
-UINT oldLangID = 0;
-void LanguageChanged(HWND hDlg)
-{
- UINT LangID = (UINT)GetKeyboardLayout(0);
- char Lang[3] = {0};
- if (LangID != oldLangID)
- {
- oldLangID = LangID;
- GetLocaleInfoA(MAKELCID((LangID & 0xffffffff), SORT_DEFAULT), LOCALE_SABBREVLANGNAME, Lang, 2);
- SetDlgItemTextA(hDlg, IDC_LANG, Lang);
- }
-}
-
-BOOL CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
-{
- switch(uMsg)
- {
- case WM_INITDIALOG:
- {
- HWND hwndCtrl;
- TranslateDialogDefault(hDlg);
-
- if(lParam && !wrongPass) SetDlgItemTextA(hDlg, IDC_DBNAME, (LPCSTR)lParam);
- if(wrongPass)
- {
- if (wrongPass > 2)
- {
- hwndCtrl = GetDlgItem(hDlg, IDC_USERPASS);
- EnableWindow(hwndCtrl, FALSE);
- hwndCtrl = GetDlgItem(hDlg, IDOK);
- EnableWindow(hwndCtrl, FALSE);
-
- SetDlgItemText(hDlg, IDC_LOGININFO, TranslateT("Too many errors!"));
-
- }
- else
- {
- SetDlgItemText(hDlg, IDC_LOGININFO, TranslateT("Password is not correct!"));
- }
- }
- oldLangID = 0;
- SetTimer(hDlg,1,200,NULL);
- LanguageChanged(hDlg);
- return TRUE;
- }
-
- case WM_CTLCOLORSTATIC:
- {
- if ((HWND)lParam == GetDlgItem(hDlg, IDC_LANG))
- {
- SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
- SetBkMode((HDC)wParam, TRANSPARENT);
- return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
- }
-
- return FALSE;
- }
-
- case WM_COMMAND:
- {
- UINT uid = LOWORD(wParam);
-
- if(uid == IDOK){
- if (!GetWindowLongPtr(hDlg,GWLP_USERDATA))
- {
- encryptKeyLength = GetDlgItemTextA(hDlg, IDC_USERPASS, encryptKey, 254);
- EndDialog(hDlg,IDOK);
- }else{
-
- }
- }else if(uid == IDCANCEL){
- EndDialog(hDlg,IDCANCEL);
- }
- }
- case WM_TIMER:
- {
- LanguageChanged(hDlg);
- return FALSE;
- }
- case WM_DESTROY:
- {
- KillTimer(hDlg, 1);
- return FALSE;
- }
- }
-
- return FALSE;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/eventchain.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/eventchain.cpp
deleted file mode 100644
index 3c9e37668a..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/eventchain.cpp
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
-Miranda Database Tool
-Miranda IM: the free IM client for Microsoft* Windows*
-
-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 "dbtool.h"
-
-static BOOL backLookup;
-static DWORD ofsThisEvent,ofsPrevEvent;
-static DWORD ofsDestPrevEvent;
-static DWORD eventCount;
-static DWORD lastTimestamp;
-static DWORD ofsFirstUnread,timestampFirstUnread;
-static DWORD memsize = 0;
-static DBEvent* memblock = NULL;
-static DBEvent* dbePrevEvent = NULL;
-
-static void ConvertOldEvent( DBEvent*& dbei )
-{
- int msglen = (int)strlen(( char* )dbei->blob) + 1, msglenW = 0;
- if ( msglen != (int) dbei->cbBlob ) {
- int i, count = (( dbei->cbBlob - msglen ) / sizeof( WCHAR ));
- WCHAR* p = ( WCHAR* )&dbei->blob[ msglen ];
- for ( i=0; i < count; i++ ) {
- if ( p[i] == 0 ) {
- msglenW = i;
- break;
- } } }
- else {
- if ( !is_utf8_string(( char* )dbei->blob))
- dbei->flags &= ~DBEF_UTF;
- }
-
- if ( msglenW > 0 && msglenW <= msglen ) {
- char* utf8str = Utf8EncodeW(( WCHAR* )&dbei->blob[ msglen ] );
- dbei->cbBlob = (DWORD)strlen( utf8str )+1;
- dbei->flags |= DBEF_UTF;
- if (offsetof(DBEvent,blob)+dbei->cbBlob > memsize) {
- memsize = offsetof(DBEvent,blob)+dbei->cbBlob;
- memblock = (DBEvent*)realloc(memblock, memsize);
- dbei = memblock;
- }
- memcpy( &dbei->blob, utf8str, dbei->cbBlob );
- free(utf8str);
-} }
-
-static void WriteOfsNextToPrevious(DWORD ofsPrev,DBContact *dbc,DWORD ofsNext)
-{
- if(ofsPrev)
- WriteSegment(ofsPrev+offsetof(DBEvent,ofsNext),&ofsNext,sizeof(DWORD));
- else
- dbc->ofsFirstEvent=ofsNext;
-}
-
-static void FinishUp(DWORD ofsLast,DBContact *dbc)
-{
- WriteOfsNextToPrevious(ofsLast,dbc,0);
- if(eventCount!=dbc->eventCount)
- AddToStatus(STATUS_WARNING,TranslateT("Event count marked wrongly: correcting"));
- dbc->eventCount=eventCount;
- dbc->ofsLastEvent=ofsLast;
- if(opts.bMarkRead) {
- dbc->ofsFirstUnreadEvent=0;
- dbc->timestampFirstUnread=0;
- }
- else {
- dbc->ofsFirstUnreadEvent=ofsFirstUnread;
- dbc->timestampFirstUnread=timestampFirstUnread;
- }
- if (memsize && memblock) {
- free(memblock);
- memsize = 0;
- memblock = NULL;
- }
-}
-
-static DWORD WriteEvent(DBEvent *dbe)
-{
- DWORD ofs = WriteSegment( WSOFS_END, dbe, offsetof(DBEvent,blob)+dbe->cbBlob );
- if ( ofs == WS_ERROR ) {
- free( memblock );
- memblock = NULL;
- memsize = 0;
- return 0;
- }
- return ofs;
-}
-
-int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
-{
- DBEvent *dbeNew,dbeOld;
- DBEvent *dbePrev = NULL;
- DWORD ofsDestThis;
- int isUnread=0;
-
- if(firstTime) {
- dbePrevEvent = NULL;
- ofsPrevEvent=0;
- ofsDestPrevEvent=0;
- ofsThisEvent=dbc->ofsFirstEvent;
- eventCount=0;
- backLookup=0;
- lastTimestamp=0;
- ofsFirstUnread=timestampFirstUnread=0;
- if(opts.bEraseHistory) {
- dbc->eventCount=0;
- dbc->ofsFirstEvent=0;
- dbc->ofsLastEvent=0;
- dbc->ofsFirstUnreadEvent=0;
- dbc->timestampFirstUnread=0;
- return ERROR_NO_MORE_ITEMS;
- } }
-
- if(ofsThisEvent==0) {
- FinishUp(ofsDestPrevEvent,dbc);
- return ERROR_NO_MORE_ITEMS;
- }
- if (!SignatureValid(ofsThisEvent,DBEVENT_SIGNATURE))
- {
- DWORD ofsNew = 0;
- DWORD ofsTmp = dbc->ofsLastEvent;
-
- if (!backLookup && ofsTmp) {
- backLookup = 1;
- while(SignatureValid(ofsTmp,DBEVENT_SIGNATURE))
- {
- if(PeekSegment(ofsTmp,&dbeOld,sizeof(dbeOld))!=ERROR_SUCCESS)
- break;
- ofsNew = ofsTmp;
- ofsTmp = dbeOld.ofsPrev;
- }
- }
- if (ofsNew) {
- AddToStatus(STATUS_WARNING,TranslateT("Event chain corrupted, trying to recover..."));
- ofsThisEvent = ofsNew;
- } else {
- AddToStatus(STATUS_ERROR,TranslateT("Event chain corrupted, further entries ignored"));
- FinishUp(ofsDestPrevEvent,dbc);
- return ERROR_NO_MORE_ITEMS;
- }
- }
-
- if(PeekSegment(ofsThisEvent,&dbeOld,sizeof(dbeOld))!=ERROR_SUCCESS) {
- FinishUp(ofsDestPrevEvent,dbc);
- return ERROR_NO_MORE_ITEMS;
- }
-
- if(firstTime) {
- if (!(dbeOld.flags&DBEF_FIRST)) {
- AddToStatus(STATUS_WARNING,TranslateT("First event not marked as such: correcting"));
- dbeOld.flags|=DBEF_FIRST;
- }
- dbeOld.ofsPrev=ofsContact;
- lastTimestamp=dbeOld.timestamp;
- }
- else if(dbeOld.flags&DBEF_FIRST) {
- AddToStatus(STATUS_WARNING,TranslateT("Event marked as first which is not: correcting"));
- dbeOld.flags&=~DBEF_FIRST;
- }
-
- if(dbeOld.flags&~(DBEF_FIRST|DBEF_READ|DBEF_SENT|DBEF_RTL|DBEF_UTF)) {
- AddToStatus(STATUS_WARNING,TranslateT("Extra flags found in event: removing"));
- dbeOld.flags&=(DBEF_FIRST|DBEF_READ|DBEF_SENT|DBEF_RTL|DBEF_UTF);
- }
-
- if (!(dbeOld.flags&(DBEF_READ|DBEF_SENT))) {
- if(opts.bMarkRead) dbeOld.flags|=DBEF_READ;
- else if(ofsFirstUnread==0) {
- if(dbc->ofsFirstUnreadEvent!=ofsThisEvent || dbc->timestampFirstUnread!=dbeOld.timestamp)
- AddToStatus(STATUS_WARNING,TranslateT("First unread event marked wrong: fixing"));
- isUnread=1;
- } }
-
- if(dbeOld.cbBlob>1024*1024 || dbeOld.cbBlob==0) {
- AddToStatus(STATUS_ERROR,TranslateT("Infeasibly large event blob: skipping"));
- ofsThisEvent=dbeOld.ofsNext;
- return ERROR_SUCCESS;
- }
-
- if ( dbePrevEvent && dbeOld.timestamp == lastTimestamp ) {
- int len = offsetof(DBEvent,blob)+dbePrevEvent->cbBlob;
- dbePrev = (DBEvent*)malloc(len);
- memcpy(dbePrev, dbePrevEvent, len);
- }
-
- if (offsetof(DBEvent,blob)+dbeOld.cbBlob > memsize) {
- memsize = offsetof(DBEvent,blob)+dbeOld.cbBlob;
- memblock = (DBEvent*)realloc(memblock, memsize);
- }
- dbeNew=memblock;
-
- if(ReadSegment(ofsThisEvent,dbeNew,offsetof(DBEvent,blob)+dbeOld.cbBlob)!=ERROR_SUCCESS) {
- FinishUp(ofsDestPrevEvent,dbc);
- return ERROR_NO_MORE_ITEMS;
- }
-
- if ((dbeNew->ofsModuleName=ConvertModuleNameOfs(dbeOld.ofsModuleName))==0) {
- ofsThisEvent=dbeOld.ofsNext;
- return ERROR_SUCCESS;
- }
-
- if (!firstTime && dbeOld.ofsPrev!=ofsPrevEvent)
- AddToStatus(STATUS_WARNING,TranslateT("Event not backlinked correctly: fixing"));
-
- dbeNew->flags=dbeOld.flags;
- dbeNew->ofsPrev=ofsDestPrevEvent;
- dbeNew->ofsNext=0;
-
- if ( dbeOld.eventType == EVENTTYPE_MESSAGE && opts.bConvertUtf )
- ConvertOldEvent(dbeNew);
-
- if ( dbePrev )
- {
- if ( dbePrev->cbBlob == dbeNew->cbBlob &&
- dbePrev->ofsModuleName == dbeNew->ofsModuleName &&
- dbePrev->eventType == dbeNew->eventType &&
- (dbePrev->flags & DBEF_SENT) == (dbeNew->flags & DBEF_SENT) &&
- !memcmp( dbePrev->blob, dbeNew->blob, dbeNew->cbBlob )
- ) {
- AddToStatus(STATUS_WARNING,TranslateT("Duplicate event was found: skipping"));
- if (dbc->eventCount)
- dbc->eventCount--;
- free(dbePrev);
- // ofsDestPrevEvent is still the same!
- ofsPrevEvent=ofsThisEvent;
- ofsThisEvent=dbeOld.ofsNext;
- return ERROR_SUCCESS;
- }
- free(dbePrev);
- }
- else if ( !firstTime && dbeNew->timestamp < lastTimestamp )
- {
- DWORD found = 0;
- DBEvent dbeTmp;
- DWORD ofsTmp;
-
- if (opts.bCheckOnly)
- {
- if (!opts.bAggressive)
- {
- ofsTmp = dbeOld.ofsPrev;
- while(PeekSegment(ofsTmp,&dbeTmp,sizeof(dbeTmp))==ERROR_SUCCESS)
- {
- if (dbeTmp.ofsPrev == ofsContact) {
- found = 1;
- break;
- }
- if (dbeTmp.timestamp < dbeNew->timestamp) {
- found = 2;
- break;
- }
- ofsTmp = dbeTmp.ofsPrev;
- }
- }
- AddToStatus(STATUS_WARNING,TranslateT("Event position in chain is not correct"));
- }
- else
- {
- ofsTmp = ofsDestPrevEvent;
- while(ReadWrittenSegment(ofsTmp,&dbeTmp,sizeof(dbeTmp))==ERROR_SUCCESS)
- {
- if (dbeTmp.ofsPrev == ofsContact) {
- found = 1;
- break;
- }
- if (dbeTmp.timestamp < dbeNew->timestamp) {
- found = 2;
- break;
- }
- ofsTmp = dbeTmp.ofsPrev;
- }
- if (found)
- AddToStatus(STATUS_WARNING,TranslateT("Event position in chain is not correct: fixing"));
- else
- AddToStatus(STATUS_WARNING,TranslateT("Event position in chain is not correct: unable to fix"));
- }
-
- // insert before FIRST
- if (found == 1 && !opts.bCheckOnly) {
- dbeNew->flags|=DBEF_FIRST;
- dbeNew->ofsPrev=ofsContact;
- dbeNew->ofsNext=dbc->ofsFirstEvent;
-
- ofsDestThis = WriteEvent(dbeNew);
- if ( !ofsDestThis )
- return ERROR_HANDLE_DISK_FULL;
-
- if ( isUnread && timestampFirstUnread >= dbeNew->timestamp ) {
- ofsFirstUnread=ofsDestThis;
- timestampFirstUnread=dbeNew->timestamp;
- }
- // fix first event
- WriteOfsNextToPrevious(0,dbc,ofsDestThis);
- // fix next event
- WriteSegment(dbeNew->ofsNext+offsetof(DBEvent,ofsPrev),&ofsDestThis,sizeof(DWORD));
- dbeTmp.flags &=~DBEF_FIRST;
- WriteSegment(dbeNew->ofsNext+offsetof(DBEvent,flags),&dbeTmp.flags,sizeof(DWORD));
- }
- else if (found == 2 && !opts.bCheckOnly) {
-
- dbeNew->ofsPrev=ofsTmp;
- dbeNew->ofsNext=dbeTmp.ofsNext;
-
- ofsDestThis = WriteEvent(dbeNew);
- if ( !ofsDestThis )
- return ERROR_HANDLE_DISK_FULL;
-
- if ( isUnread && timestampFirstUnread >= dbeNew->timestamp ) {
- ofsFirstUnread=ofsDestThis;
- timestampFirstUnread=dbeNew->timestamp;
- }
- // fix previous event
- WriteOfsNextToPrevious(dbeNew->ofsPrev,dbc,ofsDestThis);
- // fix next event
- WriteSegment(dbeNew->ofsNext+offsetof(DBEvent,ofsPrev),&ofsDestThis,sizeof(DWORD));
- }
-
- if (found) {
- eventCount++;
- // ofsDestPrevEvent is still the same!
- ofsPrevEvent=ofsThisEvent;
- ofsThisEvent=dbeOld.ofsNext;
- return ERROR_SUCCESS;
- }
- }
-
- lastTimestamp=dbeNew->timestamp;
- dbePrevEvent = dbeNew;
-
- ofsDestThis = WriteEvent(dbeNew);
- if ( !ofsDestThis )
- return ERROR_HANDLE_DISK_FULL;
-
- if ( isUnread ) {
- ofsFirstUnread=ofsDestThis;
- timestampFirstUnread=dbeOld.timestamp;
- }
-
- eventCount++;
- WriteOfsNextToPrevious(ofsDestPrevEvent,dbc,ofsDestThis);
-
- ofsDestPrevEvent=ofsDestThis;
- ofsPrevEvent=ofsThisEvent;
- ofsThisEvent=dbeOld.ofsNext;
- return ERROR_SUCCESS;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/fileaccess.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/fileaccess.cpp
deleted file mode 100644
index d904daf5b9..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/fileaccess.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-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 "dbtool.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:
- CheckDlgButton(hdlg,IDC_CHECKONLY,opts.bCheckOnly);
- CheckDlgButton(hdlg,IDC_BACKUP,opts.bBackup);
- CheckDlgButton(hdlg,IDC_AGGRESSIVE,opts.bAggressive);
- 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:
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_SELECTDB,(LPARAM)SelectDbDlgProc);
- break;
- case IDOK:
- if(opts.bCheckOnly) {
- if (!opts.hFile) {
- opts.hFile = CreateFile( opts.filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
- if ( opts.hFile == INVALID_HANDLE_VALUE ) {
- opts.hFile = NULL;
- opts.error = GetLastError();
- SendMessage( GetParent(hdlg), WZM_GOTOPAGE, IDD_OPENERROR, ( LPARAM )OpenErrorDlgProc );
- break;
- }
- }
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_PROGRESS,(LPARAM)ProgressDlgProc);
- }
- else
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_CLEANING,(LPARAM)CleaningDlgProc);
- break;
- case IDC_CHECKONLY:
- EnableWindow(GetDlgItem(hdlg,IDC_BACKUP),!IsDlgButtonChecked(hdlg,IDC_CHECKONLY));
- EnableWindow(GetDlgItem(hdlg,IDC_STBACKUP),!IsDlgButtonChecked(hdlg,IDC_CHECKONLY));
- break;
- }
- break;
- }
- return FALSE;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/finaltasks.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/finaltasks.cpp
deleted file mode 100644
index 2ed8b7183d..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/finaltasks.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-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 "dbtool.h"
-
-extern int errorCount;
-
-int WorkFinalTasks(int firstTime)
-{
- FreeModuleChain();
- AddToStatus(STATUS_MESSAGE,TranslateT("Processing final tasks"));
- dbhdr.slackSpace=0;
- if(WriteSegment(0,&dbhdr,sizeof(dbhdr))==WS_ERROR)
- return ERROR_WRITE_FAULT;
- if (opts.hFile) {
- CloseHandle(opts.hFile);
- opts.hFile = NULL;
- }
- if ( opts.hOutFile ) {
- CloseHandle(opts.hOutFile);
- opts.hOutFile = NULL;
- }
- if (opts.pFile) {
- UnmapViewOfFile(opts.pFile);
- opts.pFile = NULL;
- }
- if (opts.hMap) {
- CloseHandle(opts.hMap);
- opts.hMap = NULL;
- }
- if(errorCount && !opts.bBackup && !opts.bCheckOnly) {
- extern time_t ts;
- time_t dlg_ts = time(NULL);
- if ( IDYES == MessageBox( NULL,
- 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(NULL) - dlg_ts;
- }
- if(opts.bBackup) {
- int i;
- TCHAR dbPath[MAX_PATH],dbFile[MAX_PATH];
- _tcscpy( dbPath, opts.filename );
- TCHAR* str2 = _tcsrchr( dbPath, '\\' );
- if ( str2 != NULL ) {
- _tcscpy( dbFile, str2+1 );
- *str2 = 0;
- }
- else {
- _tcscpy( dbFile, dbPath );
- dbPath[0] = 0;
- }
- for(i=1;;i++) {
- if(i==1) wsprintf(opts.backupFilename,TranslateT("%s\\Backup of %s"),dbPath,dbFile);
- else wsprintf(opts.backupFilename,TranslateT("%s\\Backup (%d) of %s"),dbPath,i,dbFile);
- if(_taccess(opts.backupFilename,0)==-1) break;
- }
- MoveFile(opts.filename,opts.backupFilename) || AddToStatus(STATUS_WARNING,TranslateT("Unable to rename original file"));
- }
- else if (!opts.bCheckOnly) DeleteFile(opts.filename) || AddToStatus(STATUS_WARNING,TranslateT("Unable to delete original file"));
- if (!opts.bCheckOnly) MoveFile(opts.outputFilename,opts.filename) || AddToStatus(STATUS_WARNING,TranslateT("Unable to rename output file"));
- return ERROR_NO_MORE_ITEMS;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/finished.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/finished.cpp
deleted file mode 100644
index 08d0f5c893..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/finished.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-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 "dbtool.h"
-
-#define WM_LAUNCHMIRANDA (WM_USER+1)
-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);
- 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 WM_LAUNCHMIRANDA:
- if(IsDlgButtonChecked(hdlg,IDC_LAUNCHMIRANDA)) {
- TCHAR dbFile[MAX_PATH],dbPath[MAX_PATH],*str2;
- _tcscpy(dbPath,opts.filename);
- str2 = _tcsrchr(dbPath,'\\');
- if ( str2 == NULL ) {
- _tcscpy( dbFile, dbPath );
- dbPath[ 0 ] = 0;
- }
- else {
- _tcscpy( dbFile, str2+1 );
- *str2 = 0;
- }
- str2 = _tcsrchr( dbFile, '.' );
- if ( str2 != NULL )
- *str2 = 0;
- _tcscat( dbPath, _T("\\miranda32.exe"));
- if ( GetFileAttributes( dbPath ) == INVALID_FILE_ATTRIBUTES ) {
- GetModuleFileName( NULL, dbPath, SIZEOF( dbPath ));
- if (( str2 = _tcsrchr( dbPath, '\\' )) != NULL )
- *str2 = 0;
- else
- dbPath[0] = 0;
- _tcscat( dbPath, _T("\\miranda32.exe"));
- }
- ShellExecute( hdlg, NULL, dbPath, dbFile, _T(""), SW_SHOW );
- }
- break;
- case WZN_CANCELCLICKED:
- SendMessage(hdlg,WM_LAUNCHMIRANDA,0,0);
- break;
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDOK:
- SendMessage(hdlg,WM_LAUNCHMIRANDA,0,0);
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_SELECTDB,(LPARAM)SelectDbDlgProc);
- break;
- }
- break;
- }
- return FALSE;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/initialchecks.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/initialchecks.cpp
deleted file mode 100644
index 385d31cb92..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/initialchecks.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-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 "dbtool.h"
-
-BOOL bEncrypted;
-extern DWORD sourceFileSize,spaceUsed;
-int CheckPassword(WORD version, WORD cryptorUID, char * szDBName);
-void InitSecurity();
-
-int WorkInitialChecks(int firstTime)
-{
- DWORD bytesRead;
-
- sourceFileSize=GetFileSize(opts.hFile,NULL);
- if(sourceFileSize==0) {
- AddToStatus(STATUS_WARNING,TranslateT("Database is newly created and has no data to process"));
- AddToStatus(STATUS_SUCCESS,TranslateT("Processing completed successfully"));
- return ERROR_INVALID_DATA;
- }
- ReadFile(opts.hFile,&dbhdr,sizeof(dbhdr),&bytesRead,NULL);
- if(bytesRead<sizeof(dbhdr)) {
- AddToStatus(STATUS_FATAL,TranslateT("Database is corrupted and too small to contain any recoverable data"));
- return ERROR_BAD_FORMAT;
- }
- bEncrypted = false;
- if(memcmp(dbhdr.signature,&dbSignature,sizeof(dbhdr.signature))) {
- if(memcmp(dbhdr.signature,&dbSignatureEncrypted,sizeof(dbhdr.signature))) {
- AddToStatus(STATUS_FATAL,TranslateT("Database signature is corrupted, automatic repair is impossible"));
- return ERROR_BAD_FORMAT;
- }
- AddToStatus(STATUS_SUCCESS,TranslateT("Database is Secured MMAP database"));
- InitSecurity();
- if(CheckPassword(dbhdr.checkWord, dbhdr.cryptorUID, (char*)Translate("your database"))) {
- AddToStatus(STATUS_SUCCESS,TranslateT("Secured MMAP: authorization successful"));
- bEncrypted = true;
- }
- else
- {
- AddToStatus(STATUS_FATAL,TranslateT("You are not authorized for access to Database"));
- return ERROR_BAD_FORMAT;
- }
- }
- if(dbhdr.checkWord!=0x0700 && !bEncrypted) {
- AddToStatus(STATUS_FATAL,TranslateT("Database is marked as belonging to an unknown version of Miranda"));
- return ERROR_BAD_FORMAT;
- }
- _tcscpy(opts.workingFilename,opts.filename);
-
- if(opts.bCheckOnly) {
- _tcscpy( opts.outputFilename, TranslateT("<check only>"));
- opts.hOutFile=INVALID_HANDLE_VALUE;
- }
- else {
- _tcscpy(opts.outputFilename,opts.filename);
- *_tcsrchr(opts.outputFilename,'.')=0;
- _tcscat(opts.outputFilename,TranslateT(" (Output).dat"));
- opts.hOutFile = CreateFile(opts.outputFilename,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_FLAG_SEQUENTIAL_SCAN,NULL);
- if ( opts.hOutFile == INVALID_HANDLE_VALUE ) {
- AddToStatus(STATUS_FATAL,TranslateT("Can't create output file (%u)"),GetLastError());
- return ERROR_ACCESS_DENIED;
- }
- }
-
- opts.hMap = CreateFileMapping(opts.hFile, NULL, opts.bAggressive?PAGE_WRITECOPY:PAGE_READONLY, 0, 0, NULL);
-
- if (opts.hMap)
- opts.pFile = (BYTE*)MapViewOfFile(opts.hMap, opts.bAggressive?FILE_MAP_COPY:FILE_MAP_READ, 0, 0 ,0);
- else {
- AddToStatus(STATUS_FATAL,TranslateT("Can't create file mapping (%u)"),GetLastError());
- return ERROR_ACCESS_DENIED;
- }
-
- if (!opts.pFile) {
- AddToStatus(STATUS_FATAL,TranslateT("Can't create map view of file (%u)"),GetLastError());
- return ERROR_ACCESS_DENIED;
- }
- if(ReadSegment(0,&dbhdr,sizeof(dbhdr))!=ERROR_SUCCESS) return ERROR_READ_FAULT;
- if(WriteSegment(0,&dbhdr,sizeof(dbhdr))==WS_ERROR) return ERROR_HANDLE_DISK_FULL;
- spaceUsed=dbhdr.ofsFileEnd-dbhdr.slackSpace;
- dbhdr.ofsFileEnd=sizeof(dbhdr);
- return ERROR_NO_MORE_ITEMS;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/main.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/main.cpp
deleted file mode 100644
index d505751bd5..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/main.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-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 "dbtool.h"
-
-HINSTANCE hInst;
-int hLangpack=0;
-
-DbToolOptions opts = {0};
-
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
-{
- hInst=hInstance;
- InitCommonControls();
- LoadLangPackModule();
- DialogBox(hInst,MAKEINTRESOURCE(IDD_WIZARD),NULL,WizardDlgProc);
- return 0;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/modulechain.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/modulechain.cpp
deleted file mode 100644
index 2b91059176..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/modulechain.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
-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 "dbtool.h"
-
-struct ModChainEntry {
- DWORD ofsOld,ofsNew;
- int size;
- char name[257];
-} static *modChain=NULL;
-static int modChainCount;
-static DWORD ofsCurrent;
-static int phase,iCurrentModName;
-static DWORD ofsLast;
-static int last_mod = 0;
-
-int WorkModuleChain(int firstTime)
-{
- DBModuleName moduleName,*newModName;
-
- if(firstTime) {
- AddToStatus(STATUS_MESSAGE,TranslateT("Processing module name chain"));
- modChainCount=0;
- last_mod = 0;
- if(modChain!=NULL) free(modChain);
- modChain = (ModChainEntry*)malloc(sizeof(ModChainEntry));
- phase=0;
- ofsCurrent=dbhdr.ofsFirstModuleName;
- }
- switch(phase) {
- case 0:
- if(ofsCurrent==0) {
- phase++;
- return ERROR_SUCCESS;
- }
- if (!SignatureValid(ofsCurrent,DBMODULENAME_SIGNATURE)) {
- AddToStatus(STATUS_ERROR,TranslateT("Module chain corrupted, further entries ignored"));
- phase++;
- return ERROR_SUCCESS;
- }
- if(PeekSegment(ofsCurrent,&moduleName,offsetof(DBModuleName,name))!=ERROR_SUCCESS) {
- phase++;
- return ERROR_SUCCESS;
- }
- if(moduleName.cbName>256)
- AddToStatus(STATUS_WARNING,TranslateT("Unreasonably long module name, skipping"));
- else {
- modChain=(ModChainEntry*)realloc(modChain,sizeof(ModChainEntry)*++modChainCount);
-
- modChain[modChainCount-1].ofsOld=ofsCurrent;
- modChain[modChainCount-1].size=offsetof(DBModuleName,name)+moduleName.cbName;
- modChain[modChainCount-1].ofsNew=0;
-
- if (moduleName.cbName)
- PeekSegment(ofsCurrent+offsetof(DBModuleName,name),&modChain[modChainCount-1].name,moduleName.cbName);
- modChain[modChainCount-1].name[moduleName.cbName]=0;
- }
- ofsCurrent=moduleName.ofsNext;
- break;
- case 1:
- ofsLast = 0;
- iCurrentModName=0;
- dbhdr.ofsFirstModuleName=0;
- phase++;
- case 2:
- if(iCurrentModName>=modChainCount) {
- DWORD dw = 0;
- if(ofsLast) WriteSegment(ofsLast+offsetof(DBModuleName,ofsNext),&dw,sizeof(DWORD));
- return ERROR_NO_MORE_ITEMS;
- }
- if(modChain[iCurrentModName].ofsNew==0) {
- newModName=(DBModuleName*)_alloca(modChain[iCurrentModName].size);
- if(ReadSegment(modChain[iCurrentModName].ofsOld,newModName,modChain[iCurrentModName].size)!=ERROR_SUCCESS)
- return ERROR_NO_MORE_ITEMS;
- if ((modChain[iCurrentModName].ofsNew=WriteSegment(WSOFS_END,newModName,modChain[iCurrentModName].size))==WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- { // check duplicated modulenames
- int i, n=0;
- for(i=iCurrentModName+1;i<modChainCount;i++)
- if (!strcmp(modChain[i].name, modChain[iCurrentModName].name)) {
- modChain[i].ofsNew = modChain[iCurrentModName].ofsNew;
- n++;
- }
- if (n) {
- TCHAR *pszModuleName;
-
- TCHAR szModuleName[257];
- MultiByteToWideChar(CP_ACP, 0, modChain[iCurrentModName].name, -1, szModuleName, sizeof(szModuleName) / sizeof(TCHAR));
- pszModuleName = szModuleName;
-
- AddToStatus(STATUS_WARNING,TranslateT("Module name '%s' is not unique: %d duplicates found)"), pszModuleName, n);
- }
- }
- if(iCurrentModName==0)
- dbhdr.ofsFirstModuleName=modChain[iCurrentModName].ofsNew;
- else
- if(WriteSegment(ofsLast+offsetof(DBModuleName,ofsNext),&modChain[iCurrentModName].ofsNew,sizeof(DWORD))==WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- ofsLast = modChain[iCurrentModName].ofsNew;
- }
- iCurrentModName++;
- break;
- }
- return ERROR_SUCCESS;
-}
-
-DWORD ConvertModuleNameOfs(DWORD ofsOld)
-{
- int i;
-
- if ( modChain[last_mod].ofsOld==ofsOld )
- return modChain[last_mod].ofsNew;
-
- for(i=0;i<modChainCount;i++)
- if(modChain[i].ofsOld==ofsOld) {
- last_mod = i;
- return modChain[last_mod].ofsNew;
- }
-
- AddToStatus(STATUS_ERROR,TranslateT("Invalid module name offset, skipping data"));
- return 0;
-}
-
-void FreeModuleChain()
-{
- if(modChain!=NULL) {
- free(modChain);
- modChain = NULL;
- last_mod = 0;
- }
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/openerror.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/openerror.cpp
deleted file mode 100644
index 1fa2964c20..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/openerror.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-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 "dbtool.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:
- { TCHAR szError[256];
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,opts.error,0,szError,SIZEOF(szError),NULL);
- 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:
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_SELECTDB,(LPARAM)SelectDbDlgProc);
- break;
- case IDOK:
- opts.hFile = CreateFile( opts.filename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
- if ( opts.hFile == INVALID_HANDLE_VALUE ) {
- opts.hFile = NULL;
- opts.error = GetLastError();
- SendMessage( GetParent( hdlg ), WZM_GOTOPAGE, IDD_OPENERROR, ( LPARAM )OpenErrorDlgProc );
- }
- else SendMessage( GetParent( hdlg ), WZM_GOTOPAGE, IDD_FILEACCESS, ( LPARAM )FileAccessDlgProc );
- break;
- }
- break;
- }
- return FALSE;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/progress.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/progress.cpp
deleted file mode 100644
index 5ddb8bd985..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/progress.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
-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 "dbtool.h"
-
-#define WM_PROCESSINGDONE (WM_USER+1)
-
-void __cdecl WorkerThread(void *unused);
-static HWND hwndStatus,hdlgProgress,hwndBar;
-HANDLE hEventRun = NULL, hEventAbort = NULL;
-int errorCount;
-
-int AddToStatus(DWORD flags, TCHAR* fmt,...)
-{
- va_list vararg;
- TCHAR str[256];
- int i,ret;
-
- va_start(vararg,fmt);
- ret=_vsntprintf(str,SIZEOF(str),fmt,vararg);
- va_end(vararg);
- i=SendMessage(hwndStatus,LB_ADDSTRING,0,(LPARAM)str);
- SendMessage(hwndStatus,LB_SETITEMDATA,i,flags);
- InvalidateRect(hwndStatus,NULL,FALSE);
- SendMessage(hwndStatus,LB_SETTOPINDEX,i,0);
-#ifdef _DEBUG
- OutputDebugString(str);
- OutputDebugStringA("\n");
-#endif
- if ((flags&STATUS_CLASSMASK)==STATUS_ERROR) errorCount++;
- return ret;
-}
-
-void SetProgressBar(int perThou)
-{
- SendMessage(hwndBar,PBM_SETPOS,perThou,0);
-}
-
-void ProcessingDone(void)
-{
- if (opts.pFile) {
- UnmapViewOfFile(opts.pFile);
- opts.pFile = NULL;
- }
- if (opts.hMap) {
- CloseHandle(opts.hMap);
- opts.hMap = NULL;
- }
- SendMessage(hdlgProgress,WM_PROCESSINGDONE,0,0);
-}
-
-INT_PTR CALLBACK ProgressDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam)
-{
- INT_PTR bReturn;
- static int fontHeight,listWidth;
- static int manualAbort;
- static HFONT hBoldFont = NULL;
-
- 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;
- hwndBar=GetDlgItem(hdlg,IDC_PROGRESS);
- SendMessage(hwndBar,PBM_SETRANGE,0,MAKELPARAM(0,1000));
- { HDC hdc;
- HFONT hFont,hoFont;
- SIZE s;
- hdc=GetDC(NULL);
- hFont=(HFONT)SendMessage(hdlg,WM_GETFONT,0,0);
- hoFont=(HFONT)SelectObject(hdc,hFont);
- GetTextExtentPoint32(hdc,_T("x"),1,&s);
- SelectObject(hdc,hoFont);
- ReleaseDC(NULL,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(NULL,TRUE,TRUE,NULL);
- hEventAbort=CreateEvent(NULL,TRUE,FALSE,NULL);
- TranslateDialogDefault(hdlg);
- _beginthread(WorkerThread,0,NULL);
- return TRUE;
- case WM_MEASUREITEM:
- { LPMEASUREITEMSTRUCT mis=(LPMEASUREITEMSTRUCT)lParam;
- mis->itemWidth=listWidth;
- mis->itemHeight=fontHeight;
- return TRUE;
- }
- case WM_DRAWITEM:
- { LPDRAWITEMSTRUCT dis=(LPDRAWITEMSTRUCT)lParam;
- TCHAR str[256];
- int bold=0;
- HFONT hoFont;
- 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)_tcslen(str),NULL);
- if(bold) SelectObject(dis->hDC,hoFont);
- return TRUE;
- }
- case WM_PROCESSINGDONE:
- SetProgressBar(1000);
- EnableWindow(GetDlgItem(GetParent(hdlg),IDOK),TRUE);
- if(manualAbort==1)
- EndDialog(GetParent(hdlg),0);
- else if(manualAbort==2) {
- if(opts.bCheckOnly)
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_FILEACCESS,(LPARAM)FileAccessDlgProc);
- else {
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_CLEANING,(LPARAM)CleaningDlgProc);
- CloseHandle(opts.hOutFile);
- opts.hOutFile = NULL;
- }
- break;
- }
- AddToStatus(STATUS_SUCCESS,TranslateT("Click Next to continue"));
- break;
- case WZN_CANCELCLICKED:
- 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)
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_FILEACCESS,(LPARAM)FileAccessDlgProc);
- else
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_CLEANING,(LPARAM)CleaningDlgProc);
- break;
- case IDOK:
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_FINISHED,(LPARAM)FinishedDlgProc);
- break;
- }
- break;
- case WM_DESTROY:
- if (hEventAbort) {
- CloseHandle(hEventAbort);
- hEventAbort = NULL;
- }
- if (hEventRun) {
- CloseHandle(hEventRun);
- hEventRun = NULL;
- }
- if (hBoldFont) {
- DeleteObject(hBoldFont);
- hBoldFont = NULL;
- }
- break;
- }
- return FALSE;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/resource.h b/plugins/Dbx_mmap_SA/Dbtool/src/resource.h
deleted file mode 100644
index f92176c33f..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/resource.h
+++ /dev/null
@@ -1,58 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by resource.rc
-//
-#define IDC_BACK 3
-#define IDD_WIZARD 101
-#define IDI_DBTOOL 102
-#define IDI_PROFILEGREEN 104
-#define IDR_DEFAULT1 104
-#define IDI_PROFILEYELLOW 105
-#define IDB_BITMAP1 105
-#define IDD_WELCOME 106
-#define IDI_PROFILERED 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 IDD_LOGIN 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_DBNAME 1019
-#define IDC_USERPASS 1021
-#define IDC_LANG 1022
-#define IDC_LOGININFO 1023
-#define IDC_STATIC -1
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 114
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1024
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/selectdb.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/selectdb.cpp
deleted file mode 100644
index 9db3517816..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/selectdb.cpp
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
-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 "dbtool.h"
-
-void GetProfileDirectory(TCHAR* szMirandaDir, TCHAR* szPath, int cbPath)
-{
- TCHAR szProfileDir[MAX_PATH], szExpandedProfileDir[MAX_PATH], szMirandaBootIni[MAX_PATH];
-
- lstrcpy(szMirandaBootIni,szMirandaDir);
- lstrcat(szMirandaBootIni,_T("\\mirandaboot.ini"));
- GetPrivateProfileString(_T("Database"),_T("ProfileDir"),_T("./Profiles"),szProfileDir,SIZEOF(szProfileDir),szMirandaBootIni);
- ExpandEnvironmentStrings(szProfileDir,szExpandedProfileDir,SIZEOF(szExpandedProfileDir));
- _tchdir(szMirandaDir);
- if (!_tfullpath(szPath,szExpandedProfileDir,cbPath))
- lstrcpyn(szPath,szMirandaDir,cbPath);
- if(szPath[lstrlen(szPath)-1]=='\\')
- szPath[lstrlen(szPath)-1] = 0;
-}
-
-static int AddDatabaseToList(HWND hwndList, TCHAR* filename, TCHAR* dir)
-{
- LV_ITEM lvi;
- int iNewItem;
- TCHAR szSize[20], *pName, *pDot, szName[MAX_PATH];
- HANDLE hDbFile;
- DBHeader dbhdr;
- DWORD bytesRead;
- DWORD totalSize,wasted=0;
- int broken=0;
-
- lvi.mask=LVIF_PARAM;
- lvi.iSubItem=0;
- for(lvi.iItem=ListView_GetItemCount(hwndList)-1;lvi.iItem>=0;lvi.iItem--) {
- ListView_GetItem(hwndList,&lvi);
- if ( !_tcsicmp(( TCHAR* )lvi.lParam,filename)) return lvi.iItem;
- }
- hDbFile=CreateFile(filename,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL);
- if ( hDbFile == INVALID_HANDLE_VALUE )
- return -1;
-
- ReadFile(hDbFile,&dbhdr,sizeof(dbhdr),&bytesRead,NULL);
- totalSize=GetFileSize(hDbFile,NULL);
-
- broken = (bytesRead<sizeof(dbhdr) || memcmp(dbhdr.signature,&dbSignature,sizeof(dbhdr.signature)));
-
- if (!broken) {
- wasted = dbhdr.slackSpace;
- if (totalSize>dbhdr.ofsFileEnd)
- wasted+=totalSize-dbhdr.ofsFileEnd;
- }
- CloseHandle(hDbFile);
-
- pName = _tcsrchr(filename,'\\');
- if ( pName == NULL )
- pName = ( LPTSTR )filename;
- else
- pName++;
- _tcscpy(szName,dir);
- _tcscat(szName,pName);
- pDot = _tcsrchr( szName, '.' );
- if ( pDot != NULL && !_tcsicmp( pDot, _T(".dat")))
- *pDot=0;
-
- lvi.iItem = 0;
- lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
- lvi.iSubItem = 0;
- lvi.lParam = ( LPARAM )_tcsdup(filename);
- lvi.pszText = szName;
- if (broken)
- lvi.iImage = 3;
- else if ( wasted < 1024*128 )
- lvi.iImage = 0;
- else if ( wasted < 1024*256 + (DWORD)(totalSize > 2*1024*1024 ) ? 256 * 1024 : 0 )
- lvi.iImage=1;
- else
- lvi.iImage=2;
-
- iNewItem = ListView_InsertItem(hwndList, &lvi );
- _stprintf(szSize,_T("%.2lf MB"),totalSize/1048576.0);
- ListView_SetItemText(hwndList,iNewItem,1,szSize);
- if ( !broken ) {
- _stprintf(szSize,_T("%.2lf MB"),wasted/1048576.0);
- ListView_SetItemText(hwndList,iNewItem,2,szSize);
- }
- return iNewItem;
-}
-
-void FindAdd(HWND hdlg, TCHAR *szProfileDir, TCHAR *szPrefix)
-{
- HANDLE hFind;
- WIN32_FIND_DATA fd;
- TCHAR szSearchPath[MAX_PATH],szFilename[MAX_PATH];
-
- lstrcpy(szSearchPath,szProfileDir);
- lstrcat(szSearchPath,_T("\\*.*"));
-
- hFind=FindFirstFile(szSearchPath,&fd);
- if (hFind!=INVALID_HANDLE_VALUE) {
- do {
- if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && _tcscmp(fd.cFileName, _T(".")) && _tcscmp(fd.cFileName, _T(".."))) {
- wsprintf(szFilename,_T("%s\\%s\\%s.dat"),szProfileDir,fd.cFileName,fd.cFileName);
- if (_taccess(szFilename, 0) == 0)
- AddDatabaseToList(GetDlgItem(hdlg,IDC_DBLIST),szFilename,szPrefix);
- }
- } while(FindNextFile(hFind,&fd));
- FindClose(hFind);
- }
-}
-
-TCHAR *addstring(TCHAR *str, TCHAR *add) {
- _tcscpy(str,add);
- return str + _tcslen(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:
- {
- TCHAR szMirandaPath[MAX_PATH];
- szMirandaPath[ 0 ] = 0;
- { HIMAGELIST hIml;
- hIml=ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
- (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, 3, 3);
- ImageList_AddIcon(hIml,LoadIcon(hInst,MAKEINTRESOURCE(IDI_PROFILEGREEN)));
- ImageList_AddIcon(hIml,LoadIcon(hInst,MAKEINTRESOURCE(IDI_PROFILEYELLOW)));
- ImageList_AddIcon(hIml,LoadIcon(hInst,MAKEINTRESOURCE(IDI_PROFILERED)));
- ImageList_AddIcon(hIml,LoadIcon(hInst,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 = 205;
- 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 );
- lvc.pszText = TranslateT("Wasted");
- ListView_InsertColumn(GetDlgItem(hdlg,IDC_DBLIST), 2, &lvc );
- }
- {
- TCHAR *str2;
- GetModuleFileName(NULL,szMirandaPath,SIZEOF(szMirandaPath));
- str2 = _tcsrchr(szMirandaPath,'\\');
- if ( str2 != NULL )
- *str2=0;
- }
- {
- int i = 0;
- HKEY hKey;
- TCHAR szProfileDir[MAX_PATH];
- DWORD cbData = SIZEOF(szMirandaPath);
- TCHAR szMirandaProfiles[MAX_PATH];
-
- _tcscpy(szMirandaProfiles, szMirandaPath);
- _tcscat(szMirandaProfiles, _T("\\Profiles"));
- GetProfileDirectory(szMirandaPath,szProfileDir,SIZEOF(szProfileDir));
-
- // search in profile dir (using ini file)
- if ( lstrcmpi(szProfileDir,szMirandaProfiles))
- FindAdd(hdlg, szProfileDir, _T("[ini]\\"));
-
- FindAdd(hdlg, szMirandaProfiles, _T("[prf]\\"));
- // search in current dir (as DBTOOL)
- FindAdd(hdlg, szMirandaPath, _T("[ . ]\\"));
-
- // search in profile dir (using registry path + ini file)
- if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\miranda32.exe"),0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) {
- if(RegQueryValueEx(hKey,_T("Path"),NULL,NULL,(PBYTE)szMirandaPath,&cbData) == ERROR_SUCCESS) {
- if ( lstrcmp(szProfileDir,szMirandaPath)) {
- GetProfileDirectory(szMirandaPath,szProfileDir,SIZEOF(szProfileDir));
- FindAdd(hdlg, szProfileDir, _T("[reg]\\"));
- }
- }
- RegCloseKey(hKey);
- }
- // select
- if ( opts.filename[0] )
- i = AddDatabaseToList( GetDlgItem( hdlg, IDC_DBLIST ), opts.filename, _T(""));
- if ( i == -1 )
- i = 0;
- ListView_SetItemState( GetDlgItem(hdlg,IDC_DBLIST), i, LVIS_SELECTED, LVIS_SELECTED );
- }
- if ( opts.hFile != NULL && opts.hFile != INVALID_HANDLE_VALUE ) {
- CloseHandle( opts.hFile );
- opts.hFile = NULL;
- }
- TranslateDialogDefault( hdlg );
- return TRUE;
- }
-
- case WZN_PAGECHANGING:
- GetDlgItemText( hdlg, IDC_FILE, opts.filename, SIZEOF(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};
- TCHAR str[MAX_PATH];
-
- // _T("Miranda Databases (*.dat)\0*.DAT\0All Files (*)\0*\0");
- TCHAR *filter, *tmp, *tmp1, *tmp2;
- tmp1 = TranslateT("Miranda Databases (*.dat)");
- tmp2 = TranslateT("All Files");
- filter = tmp = (TCHAR*)_alloca((_tcslen(tmp1)+_tcslen(tmp2)+11)*sizeof(TCHAR));
- tmp = addstring(tmp, tmp1);
- tmp = addstring(tmp, _T("*.DAT"));
- tmp = addstring(tmp, tmp2);
- tmp = addstring(tmp, _T("*"));
- *tmp = 0;
-
- GetDlgItemText( hdlg, IDC_FILE, str, SIZEOF( str ));
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = hdlg;
- ofn.hInstance = NULL;
- ofn.lpstrFilter = filter;
- ofn.lpstrDefExt = _T("dat");
- ofn.lpstrFile = str;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
- ofn.nMaxFile = SIZEOF(str);
- ofn.nMaxFileTitle = MAX_PATH;
- if ( GetOpenFileName( &ofn )) {
- int i;
- i = AddDatabaseToList( GetDlgItem(hdlg,IDC_DBLIST), str, _T(""));
- if ( i == -1 )
- i=0;
- ListView_SetItemState( GetDlgItem(hdlg,IDC_DBLIST), i, LVIS_SELECTED, LVIS_SELECTED );
- }
- break;
- }
- case IDC_BACK:
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_WELCOME,(LPARAM)WelcomeDlgProc);
- break;
- case IDOK:
- opts.hFile = CreateFile( opts.filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
- if ( opts.hFile == INVALID_HANDLE_VALUE ) {
- opts.hFile = NULL;
- opts.error = GetLastError();
- SendMessage( GetParent(hdlg), WZM_GOTOPAGE, IDD_OPENERROR, ( LPARAM )OpenErrorDlgProc );
- }
- else SendMessage( GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc );
- 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,(TCHAR*)lvi.lParam);
- SendMessage(hdlg,WM_COMMAND,MAKEWPARAM(IDC_FILE,EN_CHANGE),(LPARAM)GetDlgItem(hdlg,IDC_FILE));
- break;
- }
- }
- 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/Dbx_mmap_SA/Dbtool/src/settingschain.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/settingschain.cpp
deleted file mode 100644
index a6e7ecab3b..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/settingschain.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-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 "dbtool.h"
-
-static DWORD ofsThisSettings,ofsDestPrevSettings;
-
-int WorkSettingsChain(DWORD ofsContact,DBContact *dbc,int firstTime)
-{
- DBContactSettings *dbcsNew,dbcsOld;
- DWORD ofsDestThis;
- int ret;
-
- if(firstTime) {
- ofsDestPrevSettings=0;
- ofsThisSettings=dbc->ofsFirstSettings;
- dbc->ofsFirstSettings=0;
- }
- if(ofsThisSettings==0)
- return ERROR_NO_MORE_ITEMS;
- if (!SignatureValid(ofsThisSettings,DBCONTACTSETTINGS_SIGNATURE)) {
- AddToStatus(STATUS_ERROR,TranslateT("Settings chain corrupted, further entries ignored"));
- return ERROR_NO_MORE_ITEMS;
- }
- if(PeekSegment(ofsThisSettings,&dbcsOld,sizeof(dbcsOld))!=ERROR_SUCCESS)
- return ERROR_NO_MORE_ITEMS;
- if(dbcsOld.cbBlob>256*1024 || dbcsOld.cbBlob==0) {
- AddToStatus(STATUS_ERROR,TranslateT("Infeasibly large settings blob: skipping"));
- ofsThisSettings=dbcsOld.ofsNext;
- return ERROR_SUCCESS;
- }
- dbcsNew=(DBContactSettings*)_alloca(offsetof(DBContactSettings,blob)+dbcsOld.cbBlob);
- if ((ret=ReadSegment(ofsThisSettings,dbcsNew,offsetof(DBContactSettings,blob)+dbcsOld.cbBlob))!=ERROR_SUCCESS) {
- if(ret!=ERROR_HANDLE_EOF) { //eof is OK because blank space at the end doesn't matter
- return ERROR_NO_MORE_ITEMS;
- }
- }
- if ((dbcsNew->ofsModuleName=ConvertModuleNameOfs(dbcsOld.ofsModuleName))==0) {
- ofsThisSettings=dbcsOld.ofsNext;
- return ERROR_SUCCESS;
- }
- if(dbcsNew->blob[0]==0) {
- AddToStatus(STATUS_MESSAGE,TranslateT("Empty settings group at %08X: skipping"),ofsThisSettings);
- ofsThisSettings=dbcsOld.ofsNext;
- return ERROR_SUCCESS;
- }
- dbcsNew->ofsNext=0;
- //TODO? validate all settings in blob/compact if necessary
- if ((ofsDestThis=WriteSegment(WSOFS_END,dbcsNew,offsetof(DBContactSettings,blob)+dbcsNew->cbBlob))==WS_ERROR) {
- return ERROR_HANDLE_DISK_FULL;
- }
- if(ofsDestPrevSettings) WriteSegment(ofsDestPrevSettings+offsetof(DBContactSettings,ofsNext),&ofsDestThis,sizeof(DWORD));
- else dbc->ofsFirstSettings=ofsDestThis;
- ofsDestPrevSettings=ofsDestThis;
- ofsThisSettings=dbcsOld.ofsNext;
- return ERROR_SUCCESS;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/user.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/user.cpp
deleted file mode 100644
index 9922f1630f..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/user.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-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 "dbtool.h"
-
-static DBContact user;
-static int phase;
-static DWORD ofsUser;
-
-int WorkSettingsChain(DWORD ofsContact,DBContact *dbc,int firstTime);
-int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime);
-
-int WorkUser(int firstTime)
-{
- int first=0;
-
- if(firstTime) {
- AddToStatus(STATUS_MESSAGE,TranslateT("Processing user data"));
- if (!SignatureValid(dbhdr.ofsUser,DBCONTACT_SIGNATURE)) {
- AddToStatus(STATUS_ERROR,TranslateT("User corrupted, this could cause major problems"));
- return ERROR_NO_MORE_ITEMS;
- }
- if(ReadSegment(dbhdr.ofsUser,&user,sizeof(DBContact))!=ERROR_SUCCESS)
- return ERROR_NO_MORE_ITEMS;
- if(user.ofsNext) {
- AddToStatus(STATUS_WARNING,TranslateT("More than one user contact: keeping only first"));
- user.ofsNext=0;
- }
- if ((ofsUser=WriteSegment(WSOFS_END,&user,sizeof(DBContact)))==WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- dbhdr.ofsUser=ofsUser;
- phase=0;
- first=1;
- }
- switch(phase) {
- int ret;
-
- case 0:
- ret=WorkSettingsChain(ofsUser,&user,first);
- if(ret==ERROR_NO_MORE_ITEMS) {
- phase++; first=1;
- }
- else if(ret) return ret;
- else break;
- case 1:
- ret=WorkEventChain(ofsUser,&user,first);
- if(ret==ERROR_NO_MORE_ITEMS) {
- if(WriteSegment(ofsUser,&user,sizeof(DBContact))==WS_ERROR)
- return ERROR_HANDLE_DISK_FULL;
- return ERROR_NO_MORE_ITEMS;
- }
- else if(ret) return ret;
- break;
- }
- return ERROR_SUCCESS;
-} \ No newline at end of file
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/utf.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/utf.cpp
deleted file mode 100644
index c56db053d8..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/utf.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2009 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
- Copyright 2000 Alexandre Julliard of Wine project
- (UTF-8 conversion routines)
-
-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 "dbtool.h"
-
-bool is_utf8_string(const char* str)
-{
- int expect_bytes = 0, utf_found = 0;
-
- if (!str) return 0;
-
- while (*str) {
- if ((*str & 0x80) == 0) {
- /* Looks like an ASCII character */
- if (expect_bytes)
- /* byte of UTF-8 character expected */
- return 0;
- }
- else {
- /* Looks like byte of an UTF-8 character */
- if (expect_bytes) {
- /* expect_bytes already set: first byte of UTF-8 char already seen */
- if ((*str & 0xC0) != 0x80) {
- /* again first byte ?!?! */
- return 0;
- }
- }
- else {
- /* First byte of the UTF-8 character */
- /* count initial one bits and set expect_bytes to 1 less */
- char ch = *str;
- while (ch & 0x80) {
- expect_bytes++;
- ch = (ch & 0x7f) << 1;
- }
- }
- /* OK, next byte of UTF-8 character */
- /* Decrement number of expected bytes */
- if ( --expect_bytes == 0 )
- utf_found = 1;
- }
- str++;
- }
-
- return (utf_found && expect_bytes == 0);
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/welcome.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/welcome.cpp
deleted file mode 100644
index 291281e70a..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/welcome.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-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 "dbtool.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:
-
- {
- NONCLIENTMETRICS ncm = {0};
- ncm.cbSize = sizeof(ncm);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
- LOGFONT TitleLogFont = ncm.lfMessageFont;
- TitleLogFont.lfWeight = FW_BOLD;
- lstrcpy(TitleLogFont.lfFaceName, TEXT("Verdana Bold"));
-
- HDC hdc = GetDC(NULL);
- INT FontSize = 12;
- TitleLogFont.lfHeight = 0 - GetDeviceCaps(hdc, LOGPIXELSY) * FontSize / 72;
- hTitleFont = CreateFontIndirect(&TitleLogFont);
- ReleaseDC(NULL, 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:
- SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_SELECTDB,(LPARAM)SelectDbDlgProc);
- break;
- }
- break;
- case WM_DESTROY:
- DeleteEnhMetaFile(hEmfWatermark);
- DeleteObject(hTitleFont);
- break;
- }
- return FALSE;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/wizard.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/wizard.cpp
deleted file mode 100644
index 8f3a9d5ca8..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/wizard.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
-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 "dbtool.h"
-
-static HFONT hBoldFont=NULL;
-static HENHMETAFILE hEmfHeaderLogo=NULL;
-
-static BOOL CALLBACK MyControlsEnumChildren(HWND hwnd,LPARAM 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 (!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 (!strcmp(szClass,"Button")) {
- if(exstyle&WS_EX_CLIENTEDGE)
- makeBold=1;
- }
- if(makeBold) {
- if(hBoldFont==NULL) {
- 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,0,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);
-
- break;
- case WM_CTLCOLORSTATIC:
- if (GetWindowLongPtr((HWND)lParam, GWL_ID) == IDC_HDRLOGO){
- SetBkColor((HDC)wParam,RGB(255,255,255));
- *bReturn=(BOOL)GetStockObject(WHITE_BRUSH);
- return TRUE;
- }
- if ((GetWindowLongPtr((HWND)lParam,GWL_STYLE)&0xFFFF)==0) {
- TCHAR szText[256];
- GetWindowText((HWND)lParam,szText,SIZEOF(szText));
- if (!_tcscmp(szText,_T("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(hInst,MAKEINTRESOURCE(IDI_DBTOOL)));
- hdlgPage=NULL;
- SendMessage(hdlg,WZM_GOTOPAGE,IDD_WELCOME,(LPARAM)WelcomeDlgProc);
- TranslateDialogDefault(hdlg);
- return TRUE;
- case WZM_GOTOPAGE:
- if(hdlgPage!=NULL) 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(hInst,MAKEINTRESOURCE(wParam),hdlg,(DLGPROC)lParam);
- TranslateDialogDefault(hdlgPage);
- SetWindowPos(hdlgPage,0,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:
- if(SendMessage(hdlgPage,WZN_CANCELCLICKED,0,0)) break;
- EndDialog(hdlg,0);
- break;
- }
- break;
- case WM_DESTROY:
- if (opts.hFile)
- CloseHandle(opts.hFile);
- if (opts.hOutFile)
- CloseHandle(opts.hOutFile);
- DestroyWindow(hdlgPage);
- if(hBoldFont!=NULL) DeleteObject(hBoldFont);
- if(hEmfHeaderLogo!=NULL) DeleteEnhMetaFile(hEmfHeaderLogo);
- break;
- }
- return FALSE;
-}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/src/worker.cpp b/plugins/Dbx_mmap_SA/Dbtool/src/worker.cpp
deleted file mode 100644
index dd73c83947..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/src/worker.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
-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 "dbtool.h"
-
-void ProcessingDone(void);
-int WorkInitialChecks(int firstTime);
-int WorkModuleChain(int firstTime);
-int WorkUser(int firstTime);
-int WorkContactChain(int firstTime);
-int WorkAggressive(int firstTime);
-int WorkFinalTasks(int firstTime);
-
-extern HANDLE hEventRun,hEventAbort;
-extern int errorCount;
-time_t ts;
-DBHeader dbhdr;
-DWORD spaceProcessed,sourceFileSize;
-DWORD spaceUsed, sp;
-
-static int (*Workers[6])(int)=
- {WorkInitialChecks,WorkModuleChain,WorkUser,WorkContactChain,WorkAggressive,WorkFinalTasks};
-
-void __cdecl WorkerThread(void *unused)
-{
- int task,ret,firstTime;
- ts=time(NULL);
-
- AddToStatus(STATUS_MESSAGE,TranslateT("Database worker thread activated"));
- SetFilePointer(opts.hFile,0,NULL,FILE_BEGIN);
- spaceUsed=1; spaceProcessed=0; sp=0;
- firstTime=0;
-
- for(task=0;;) {
- if (spaceProcessed/(spaceUsed/1000+1) > sp) {
- sp = spaceProcessed/(spaceUsed/1000+1);
- SetProgressBar(sp);
- }
- WaitForSingleObject(hEventRun,INFINITE);
- if(WaitForSingleObject(hEventAbort,0)==WAIT_OBJECT_0) {
- AddToStatus(STATUS_FATAL,TranslateT("Processing aborted by user"));
- break;
- }
- ret=Workers[task](firstTime);
- firstTime=0;
- if(ret==ERROR_NO_MORE_ITEMS) {
- if (++task==sizeof(Workers)/sizeof(Workers[0])) {
- AddToStatus(STATUS_MESSAGE,TranslateT("Elapsed time: %d sec"), time(NULL)-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;
- }
- firstTime=1;
- }
- else if(ret!=ERROR_SUCCESS)
- break;
- }
- ProcessingDone();
-}
diff --git a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj
index b31504a3f1..0986511875 100644
--- a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj
+++ b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj
@@ -194,6 +194,33 @@
<ClCompile Include="..\Db3x_mmap\src\dbintfm.cpp" />
<ClCompile Include="..\Db3x_mmap\src\dbmodulechain.cpp" />
<ClCompile Include="..\Db3x_mmap\src\dbsettings.cpp" />
+ <ClCompile Include="..\db3x_mmap\src\dbtool\aggressive.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\contactchain.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\disk.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\eventchain.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\finaltasks.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\initialchecks.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\modulechain.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\settingschain.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\user.cpp">
+ <PrecompiledHeaderFile>..\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
<ClCompile Include="src\dbintf_sa.cpp" />
<ClCompile Include="src\dbpreset.cpp" />
<ClCompile Include="src\dialogs.cpp" />
diff --git a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters
index 92622e59c8..24a03b456a 100644
--- a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters
+++ b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters
@@ -16,6 +16,9 @@
<Filter Include="Mmap files">
<UniqueIdentifier>{9b94a455-bdbc-497d-b375-18c090cccc36}</UniqueIdentifier>
</Filter>
+ <Filter Include="Mmap files\Checker">
+ <UniqueIdentifier>{9236b59b-8511-4248-adfd-5ad1f36788dc}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\dbpreset.cpp">
@@ -60,6 +63,33 @@
<ClCompile Include="..\Db3x_mmap\src\dbintfm.cpp">
<Filter>Mmap files</Filter>
</ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\aggressive.cpp">
+ <Filter>Mmap files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\contactchain.cpp">
+ <Filter>Mmap files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\disk.cpp">
+ <Filter>Mmap files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\eventchain.cpp">
+ <Filter>Mmap files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\finaltasks.cpp">
+ <Filter>Mmap files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\initialchecks.cpp">
+ <Filter>Mmap files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\modulechain.cpp">
+ <Filter>Mmap files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\settingschain.cpp">
+ <Filter>Mmap files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="..\db3x_mmap\src\dbtool\user.cpp">
+ <Filter>Mmap files\Checker</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\commonheaders.h">
diff --git a/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp b/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp
index 05db621e7a..9bbf76da2d 100644
--- a/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp
+++ b/plugins/Dbx_mmap_SA/src/dbintf_sa.cpp
@@ -68,12 +68,12 @@ int CDdxMmapSA::CheckDbHeaders()
else {
m_bEncoding = false;
if ( memcmp(m_dbHeader.signature,&dbSignature,sizeof(m_dbHeader.signature)))
- return 1;
+ return EGROKPRF_UNKHEADER;
if ( LOWORD(m_dbHeader.version) != 0x0700)
- return 2;
+ return EGROKPRF_VERNEWER;
}
if (m_dbHeader.ofsUser == 0)
- return 3;
+ return EGROKPRF_DAMAGED;
return 0;
}
@@ -232,3 +232,27 @@ void CDdxMmapSA::DecodeContactEvents(HANDLE hContact)
hEvent = FindNextEvent(hEvent);
}
}
+
+int CDdxMmapSA::WorkInitialCheckHeaders(void)
+{
+ if (m_bEncoding) {
+ cb->pfnAddLogMessage(STATUS_SUCCESS,TranslateT("Database is Secured MMAP database"));
+
+ TCHAR* p = _tcsrchr(m_tszProfileName, '\\');
+ if (!p)
+ return ERROR_BAD_FORMAT;
+
+ g_Db = this;
+ if (!CheckPassword( LOWORD(m_dbHeader.version), p+1)) {
+ cb->pfnAddLogMessage(STATUS_FATAL,TranslateT("You are not authorized for access to Database"));
+ return ERROR_BAD_FORMAT;
+ }
+
+ cb->pfnAddLogMessage(STATUS_SUCCESS,TranslateT("Secured MMAP: authorization successful"));
+ }
+
+ if ( LOWORD(m_dbHeader.version) != 0x0700 && !m_bEncoding) {
+ cb->pfnAddLogMessage(STATUS_FATAL,TranslateT("Database is marked as belonging to an unknown version of Miranda"));
+ return ERROR_BAD_FORMAT;
+ }
+}
diff --git a/plugins/Dbx_mmap_SA/src/dbintf_sa.h b/plugins/Dbx_mmap_SA/src/dbintf_sa.h
index d532855420..a65b4ebe3d 100644
--- a/plugins/Dbx_mmap_SA/src/dbintf_sa.h
+++ b/plugins/Dbx_mmap_SA/src/dbintf_sa.h
@@ -47,6 +47,8 @@ protected:
virtual void EncodeDBWrite(DWORD ofs, void *src, int size);
virtual void DecodeDBWrite(DWORD ofs, void *src, int size);
+ virtual int WorkInitialCheckHeaders(void);
+
protected:
int CheckProto(HANDLE hContact, const char *proto);
diff --git a/plugins/Dbx_mmap_SA/src/init.cpp b/plugins/Dbx_mmap_SA/src/init.cpp
index 3112306d5e..a59ae1bc09 100644
--- a/plugins/Dbx_mmap_SA/src/init.cpp
+++ b/plugins/Dbx_mmap_SA/src/init.cpp
@@ -124,6 +124,26 @@ static int UnloadDatabase(MIDatabase* db)
return 0;
}
+MIDatabaseChecker* CheckDb(const TCHAR* ptszFileName, int *error)
+{
+ CDdxMmapSA *tmp = new CDdxMmapSA(ptszFileName);
+ if (tmp->Load(true) != ERROR_SUCCESS) {
+ delete tmp;
+ if (error != NULL) *error = EGROKPRF_CANTREAD;
+ return NULL;
+ }
+
+ int chk = tmp->CheckDbHeaders();
+ if (chk != ERROR_SUCCESS) {
+ delete tmp;
+ *error = chk;
+ return NULL;
+ }
+
+ *error = 0;
+ return tmp;
+}
+
static DATABASELINK dblink =
{
sizeof(DATABASELINK),
@@ -132,7 +152,8 @@ static DATABASELINK dblink =
makeDatabase,
grokHeader,
LoadDatabase,
- UnloadDatabase
+ UnloadDatabase,
+ CheckDb
};
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Dbx_tree/DatabaseLink.cpp b/plugins/Dbx_tree/DatabaseLink.cpp
index e2947bb72c..ec71cdeca1 100644
--- a/plugins/Dbx_tree/DatabaseLink.cpp
+++ b/plugins/Dbx_tree/DatabaseLink.cpp
@@ -99,4 +99,5 @@ DATABASELINK gDBLink = {
grokHeader,
LoadDatabase,
UnloadDatabase,
+ NULL // does not support file checking
};