summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_db_int.h16
-rw-r--r--plugins/Db3x_mmap/db3x_mmap_10.vcxproj40
-rw-r--r--plugins/Db3x_mmap/db3x_mmap_10.vcxproj.filters58
-rw-r--r--plugins/Db3x_mmap/src/dbintf.h10
-rw-r--r--plugins/Db3x_mmap/src/dbtool/aggressive.cpp (renamed from tools/dbtool/aggressive.cpp)36
-rw-r--r--plugins/Db3x_mmap/src/dbtool/contactchain.cpp99
-rw-r--r--plugins/Db3x_mmap/src/dbtool/disk.cpp112
-rw-r--r--plugins/Db3x_mmap/src/dbtool/eventchain.cpp (renamed from tools/dbtool/eventchain.cpp)196
-rw-r--r--plugins/Db3x_mmap/src/dbtool/finaltasks.cpp (renamed from tools/dbtool/finaltasks.cpp)38
-rw-r--r--plugins/Db3x_mmap/src/dbtool/initialchecks.cpp (renamed from tools/dbtool/initialchecks.cpp)30
-rw-r--r--plugins/Db3x_mmap/src/dbtool/modulechain.cpp (renamed from tools/dbtool/modulechain.cpp)70
-rw-r--r--plugins/Db3x_mmap/src/dbtool/settingschain.cpp (renamed from tools/dbtool/settingschain.cpp)46
-rw-r--r--plugins/Db3x_mmap/src/dbtool/user.cpp (renamed from tools/dbtool/user.cpp)38
-rw-r--r--plugins/Db3x_mmap/src/init.cpp22
-rw-r--r--plugins/DbChecker/dbchecker_10.vcxproj (renamed from tools/dbtool/dbtool_10.vcxproj)63
-rw-r--r--plugins/DbChecker/dbchecker_10.vcxproj.filters68
-rw-r--r--plugins/DbChecker/docs/dbchecker-translation.txt (renamed from tools/dbtool/dbtool-translation.txt)0
-rw-r--r--plugins/DbChecker/res/dbthdr.emf (renamed from tools/dbtool/res/dbthdr.emf)bin2912 -> 2912 bytes
-rw-r--r--plugins/DbChecker/res/dbtool.cdr (renamed from tools/dbtool/res/dbtool.cdr)bin20826 -> 20826 bytes
-rw-r--r--plugins/DbChecker/res/dbtool.emf (renamed from tools/dbtool/res/dbtool.emf)bin4380 -> 4380 bytes
-rw-r--r--plugins/DbChecker/res/dbtool.ico (renamed from tools/dbtool/res/dbtool.ico)bin9062 -> 9062 bytes
-rw-r--r--plugins/DbChecker/res/delete.ico (renamed from tools/dbtool/res/delete.ico)bin2550 -> 2550 bytes
-rw-r--r--plugins/DbChecker/res/profileg.ico (renamed from tools/dbtool/res/profileg.ico)bin2550 -> 2550 bytes
-rw-r--r--plugins/DbChecker/res/profiler.ico (renamed from tools/dbtool/res/profiler.ico)bin2550 -> 2550 bytes
-rw-r--r--plugins/DbChecker/res/profiley.ico (renamed from tools/dbtool/res/profiley.ico)bin2550 -> 2550 bytes
-rw-r--r--plugins/DbChecker/res/resource.rc (renamed from tools/dbtool/resource.rc)51
-rw-r--r--plugins/DbChecker/res/version.rc59
-rw-r--r--plugins/DbChecker/src/cleaning.cpp67
-rw-r--r--plugins/DbChecker/src/dbchecker.h (renamed from tools/dbtool/dbtool.h)45
-rw-r--r--plugins/DbChecker/src/fileaccess.cpp73
-rw-r--r--plugins/DbChecker/src/finished.cpp86
-rw-r--r--plugins/DbChecker/src/main.cpp (renamed from tools/dbtool/main.cpp)15
-rw-r--r--plugins/DbChecker/src/openerror.cpp58
-rw-r--r--plugins/DbChecker/src/progress.cpp224
-rw-r--r--plugins/DbChecker/src/resource.h (renamed from tools/dbtool/resource.h)0
-rw-r--r--plugins/DbChecker/src/selectdb.cpp296
-rw-r--r--plugins/DbChecker/src/utf.cpp (renamed from tools/dbtool/utf.cpp)4
-rw-r--r--plugins/DbChecker/src/version.h5
-rw-r--r--plugins/DbChecker/src/welcome.cpp70
-rw-r--r--plugins/DbChecker/src/wizard.cpp141
-rw-r--r--plugins/DbChecker/src/worker.cpp79
-rw-r--r--tools/dbtool/cleaning.cpp63
-rw-r--r--tools/dbtool/contactchain.cpp105
-rw-r--r--tools/dbtool/database.h178
-rw-r--r--tools/dbtool/dbtool.exe.manifest31
-rw-r--r--tools/dbtool/dbtool_10.vcxproj.filters118
-rw-r--r--tools/dbtool/disk.cpp112
-rw-r--r--tools/dbtool/docs/dbtool-license.txt340
-rw-r--r--tools/dbtool/docs/dbtool-readme.txt27
-rw-r--r--tools/dbtool/fileaccess.cpp69
-rw-r--r--tools/dbtool/finished.cpp82
-rw-r--r--tools/dbtool/openerror.cpp55
-rw-r--r--tools/dbtool/progress.cpp213
-rw-r--r--tools/dbtool/selectdb.cpp303
-rw-r--r--tools/dbtool/welcome.cpp65
-rw-r--r--tools/dbtool/wizard.cpp137
-rw-r--r--tools/dbtool/worker.cpp76
57 files changed, 1850 insertions, 2339 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h
index 7a4e3759e4..aadc882b84 100644
--- a/include/m_db_int.h
+++ b/include/m_db_int.h
@@ -69,6 +69,15 @@ interface MIDatabase
///////////////////////////////////////////////////////////////////////////////
// Each database plugin should register itself using this structure
+struct DBCHeckCallback
+{
+ int cbSize;
+ MIDatabase* db;
+ DWORD spaceProcessed, spaceUsed;
+
+ void (*pfnAddLogMessage)(int type, const TCHAR* ptszFormat, ...);
+};
+
struct DATABASELINK
{
int cbSize;
@@ -108,6 +117,13 @@ struct DATABASELINK
Note: Unload() might be called even if Load(void) was never called, wasLoaded is set to 1 if Load(void) was ever called.
*/
int (*Unload)(MIDatabase*);
+
+ /*
+ Affect: performs one of the database check steps.
+ Returns: If there're no more steps to execute, returns ERROR_NO_MORE_ITEMS, or ERROR_SUCCESS, or the error code.
+ Warning: this code is never executed in the main thread.
+ */
+ int (*CheckDb)(DBCHeckCallback *callback, int phase, int firstTime);
};
///////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Db3x_mmap/db3x_mmap_10.vcxproj b/plugins/Db3x_mmap/db3x_mmap_10.vcxproj
index 620786b9c6..a96259c565 100644
--- a/plugins/Db3x_mmap/db3x_mmap_10.vcxproj
+++ b/plugins/Db3x_mmap/db3x_mmap_10.vcxproj
@@ -208,6 +208,46 @@
<ClCompile Include="src\dbintfm.cpp" />
<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 Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\contactchain.cpp">
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\eventchain.cpp">
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\finaltasks.cpp">
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\initialchecks.cpp">
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\modulechain.cpp">
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\settingschain.cpp">
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\user.cpp">
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\commonheaders.h</PrecompiledHeaderFile>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ </ClCompile>
<ClCompile Include="src\init.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
diff --git a/plugins/Db3x_mmap/db3x_mmap_10.vcxproj.filters b/plugins/Db3x_mmap/db3x_mmap_10.vcxproj.filters
index 2d3667a179..23c6351e22 100644
--- a/plugins/Db3x_mmap/db3x_mmap_10.vcxproj.filters
+++ b/plugins/Db3x_mmap/db3x_mmap_10.vcxproj.filters
@@ -13,52 +13,82 @@
<UniqueIdentifier>{e5e10389-c0d7-4cf8-8442-6714f0d5aff1}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
+ <Filter Include="Source Files\Checker">
+ <UniqueIdentifier>{18e1a858-92e5-48e6-98f1-e08f4b562ea8}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="database.cpp">
+ <ClCompile Include="src\database.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\dbcache.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="dbcontacts.cpp">
+ <ClCompile Include="src\dbcontacts.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="dbevents.cpp">
+ <ClCompile Include="src\dbevents.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="dbheaders.cpp">
+ <ClCompile Include="src\dbheaders.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="dbmodulechain.cpp">
+ <ClCompile Include="src\dbintf.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="dbsettings.cpp">
+ <ClCompile Include="src\dbintfm.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="init.cpp">
+ <ClCompile Include="src\dbmodulechain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="dbintf.cpp">
+ <ClCompile Include="src\dbsettings.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="dbcache.cpp">
+ <ClCompile Include="src\init.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\dbtool\aggressive.cpp">
+ <Filter>Source Files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\contactchain.cpp">
+ <Filter>Source Files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\eventchain.cpp">
+ <Filter>Source Files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\finaltasks.cpp">
+ <Filter>Source Files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\initialchecks.cpp">
+ <Filter>Source Files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\modulechain.cpp">
+ <Filter>Source Files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\settingschain.cpp">
+ <Filter>Source Files\Checker</Filter>
+ </ClCompile>
+ <ClCompile Include="src\dbtool\user.cpp">
+ <Filter>Source Files\Checker</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="commonheaders.h">
+ <ClInclude Include="src\commonheaders.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="database.h">
+ <ClInclude Include="src\database.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="dbintf.h">
+ <ClInclude Include="src\dbintf.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
- <ResourceCompile Include="db3x_mmap.rc">
+ <ResourceCompile Include="res\db3x_mmap.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
- <ResourceCompile Include="version.rc">
+ <ResourceCompile Include="res\version.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h
index 2aa1ceea73..c13bdc5eb0 100644
--- a/plugins/Db3x_mmap/src/dbintf.h
+++ b/plugins/Db3x_mmap/src/dbintf.h
@@ -221,6 +221,14 @@ protected:
virtual void EncodeDBWrite(DWORD ofs, void *src, int size);
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);
+
protected:
TCHAR* m_tszProfileName;
HANDLE m_hDbFile;
@@ -312,3 +320,5 @@ protected:
void Map();
void ReMap(DWORD needed);
};
+
+typedef int (CDb3Mmap::*CheckWorker)(DBCHeckCallback*, int);
diff --git a/tools/dbtool/aggressive.cpp b/plugins/Db3x_mmap/src/dbtool/aggressive.cpp
index 26312ea5b0..7cafb63043 100644
--- a/tools/dbtool/aggressive.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/aggressive.cpp
@@ -16,7 +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 "dbtool.h"
+#include "..\commonheaders.h"
#define BLOCKSIZE 65536
@@ -30,30 +30,34 @@ int WorkAggressive(int firstTime)
int blockBytes,i;
BYTE *buf;
- if(firstTime) {
- if(!opts.bAggressive) return ERROR_NO_MORE_ITEMS;
+ if (firstTime) {
+ if (!opts.bAggressive)
+ return ERROR_NO_MORE_ITEMS;
+
AddToStatus(STATUS_MESSAGE,TranslateT("Performing aggressive pass"));
- ofsCurrent=0;
- spaceProcessed=0;
- sp=0;
+ ofsCurrent = 0;
+ spaceProcessed = 0;
+ sp = 0;
}
- blockBytes=min(BLOCKSIZE+3,(int)(sourceFileSize-ofsCurrent));
- if(blockBytes<=0) return ERROR_NO_MORE_ITEMS;
+ 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)
+ 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;}
+ for(; i < blockBytes; i++)
+ if (buf[i] == 0) {i--; break;}
}
}
- ofsCurrent+=BLOCKSIZE;
- spaceProcessed=ofsCurrent;
+ ofsCurrent += BLOCKSIZE;
+ spaceProcessed = ofsCurrent;
return ERROR_SUCCESS;
}
diff --git a/plugins/Db3x_mmap/src/dbtool/contactchain.cpp b/plugins/Db3x_mmap/src/dbtool/contactchain.cpp
new file mode 100644
index 0000000000..0993371848
--- /dev/null
+++ b/plugins/Db3x_mmap/src/dbtool/contactchain.cpp
@@ -0,0 +1,99 @@
+/*
+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 "..\commonheaders.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;
+
+int WorkContactChain(int firstTime)
+{
+ int first = 0;
+ int ret;
+
+ if (firstTime) {
+ AddToStatus(STATUS_MESSAGE,TranslateT("Processing contact chain"));
+ ofsDestPrevContact = 0;
+ ofsThisContact = dbhdr.ofsFirstContact;
+ contactCount = 0;
+ dbhdr.ofsFirstContact = 0;
+ phase = 0;
+ }
+
+ switch(phase) {
+ case 0:
+ if (ofsThisContact == 0) {
+LBL_FinishUp:
+ if (contactCount != dbhdr.contactCount)
+ AddToStatus(STATUS_WARNING,TranslateT("Contact count marked wrongly: correcting"));
+ dbhdr.contactCount = contactCount;
+ return ERROR_NO_MORE_ITEMS;
+ }
+ if (!SignatureValid(ofsThisContact,DBCONTACT_SIGNATURE)) {
+ AddToStatus(STATUS_ERROR,TranslateT("Contact chain corrupted, further entries ignored"));
+ goto LBL_FinishUp;
+ }
+ if (ReadSegment(ofsThisContact,&dbc,sizeof(dbc)) != ERROR_SUCCESS)
+ goto LBL_FinishUp;
+
+ 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/Db3x_mmap/src/dbtool/disk.cpp b/plugins/Db3x_mmap/src/dbtool/disk.cpp
new file mode 100644
index 0000000000..2cf9136a71
--- /dev/null
+++ b/plugins/Db3x_mmap/src/dbtool/disk.cpp
@@ -0,0 +1,112 @@
+/*
+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/tools/dbtool/eventchain.cpp b/plugins/Db3x_mmap/src/dbtool/eventchain.cpp
index 8d319a5201..1e0076371d 100644
--- a/tools/dbtool/eventchain.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/eventchain.cpp
@@ -20,7 +20,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 "dbtool.h"
+#include "..\commonheaders.h"
static BOOL backLookup;
static DWORD ofsThisEvent,ofsPrevEvent;
@@ -32,57 +32,57 @@ static DWORD memsize = 0;
static DBEvent* memblock = NULL;
static DBEvent* dbePrevEvent = NULL;
-static void ConvertOldEvent( DBEvent*& dbei )
+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 ) {
+ 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))
+ 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;
+ 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 );
+ memcpy(&dbei->blob, utf8str, dbei->cbBlob);
free(utf8str);
} }
static void WriteOfsNextToPrevious(DWORD ofsPrev,DBContact *dbc,DWORD ofsNext)
{
- if(ofsPrev)
+ if (ofsPrev)
WriteSegment(ofsPrev+offsetof(DBEvent,ofsNext),&ofsNext,sizeof(DWORD));
else
- dbc->ofsFirstEvent=ofsNext;
+ dbc->ofsFirstEvent = ofsNext;
}
static void FinishUp(DWORD ofsLast,DBContact *dbc)
{
WriteOfsNextToPrevious(ofsLast,dbc,0);
- if(eventCount!=dbc->eventCount)
+ 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;
+ dbc->eventCount = eventCount;
+ dbc->ofsLastEvent = ofsLast;
+ if (opts.bMarkRead) {
+ dbc->ofsFirstUnreadEvent = 0;
+ dbc->timestampFirstUnread = 0;
}
else {
- dbc->ofsFirstUnreadEvent=ofsFirstUnread;
- dbc->timestampFirstUnread=timestampFirstUnread;
+ dbc->ofsFirstUnreadEvent = ofsFirstUnread;
+ dbc->timestampFirstUnread = timestampFirstUnread;
}
if (memsize && memblock) {
free(memblock);
@@ -93,9 +93,9 @@ static void FinishUp(DWORD ofsLast,DBContact *dbc)
static DWORD WriteEvent(DBEvent *dbe)
{
- DWORD ofs = WriteSegment( WSOFS_END, dbe, offsetof(DBEvent,blob)+dbe->cbBlob );
- if ( ofs == WS_ERROR ) {
- free( memblock );
+ DWORD ofs = WriteSegment(WSOFS_END, dbe, offsetof(DBEvent,blob)+dbe->cbBlob);
+ if (ofs == WS_ERROR) {
+ free(memblock);
memblock = NULL;
memsize = 0;
return 0;
@@ -108,31 +108,31 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
DBEvent *dbeNew,dbeOld;
DBEvent *dbePrev = NULL;
DWORD ofsDestThis;
- int isUnread=0;
+ int isUnread = 0;
- if(firstTime) {
+ 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;
+ 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) {
+ if (ofsThisEvent == 0) {
FinishUp(ofsDestPrevEvent,dbc);
return ERROR_NO_MORE_ITEMS;
}
- if(!SignatureValid(ofsThisEvent,DBEVENT_SIGNATURE))
+ if (!SignatureValid(ofsThisEvent,DBEVENT_SIGNATURE))
{
DWORD ofsNew = 0;
DWORD ofsTmp = dbc->ofsLastEvent;
@@ -141,7 +141,7 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
backLookup = 1;
while(SignatureValid(ofsTmp,DBEVENT_SIGNATURE))
{
- if(PeekSegment(ofsTmp,&dbeOld,sizeof(dbeOld))!=ERROR_SUCCESS)
+ if (PeekSegment(ofsTmp,&dbeOld,sizeof(dbeOld)) != ERROR_SUCCESS)
break;
ofsNew = ofsTmp;
ofsTmp = dbeOld.ofsPrev;
@@ -157,44 +157,44 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
}
}
- if(PeekSegment(ofsThisEvent,&dbeOld,sizeof(dbeOld))!=ERROR_SUCCESS) {
+ if (PeekSegment(ofsThisEvent,&dbeOld,sizeof(dbeOld)) != ERROR_SUCCESS) {
FinishUp(ofsDestPrevEvent,dbc);
return ERROR_NO_MORE_ITEMS;
}
- if(firstTime) {
- if(!(dbeOld.flags&DBEF_FIRST)) {
+ 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;
+ dbeOld.ofsPrev = ofsContact;
+ lastTimestamp = dbeOld.timestamp;
}
- else if(dbeOld.flags&DBEF_FIRST) {
+ 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)) {
+ 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)
+ 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;
+ isUnread = 1;
} }
- if(dbeOld.cbBlob>1024*1024 || dbeOld.cbBlob==0) {
+ if (dbeOld.cbBlob>1024*1024 || dbeOld.cbBlob == 0) {
AddToStatus(STATUS_ERROR,TranslateT("Infeasibly large event blob: skipping"));
- ofsThisEvent=dbeOld.ofsNext;
+ ofsThisEvent = dbeOld.ofsNext;
return ERROR_SUCCESS;
}
- if ( dbePrevEvent && dbeOld.timestamp == lastTimestamp ) {
+ if (dbePrevEvent && dbeOld.timestamp == lastTimestamp) {
int len = offsetof(DBEvent,blob)+dbePrevEvent->cbBlob;
dbePrev = (DBEvent*)malloc(len);
memcpy(dbePrev, dbePrevEvent, len);
@@ -204,48 +204,48 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
memsize = offsetof(DBEvent,blob)+dbeOld.cbBlob;
memblock = (DBEvent*)realloc(memblock, memsize);
}
- dbeNew=memblock;
+ dbeNew = memblock;
- if(ReadSegment(ofsThisEvent,dbeNew,offsetof(DBEvent,blob)+dbeOld.cbBlob)!=ERROR_SUCCESS) {
+ 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;
+ if ((dbeNew->ofsModuleName = ConvertModuleNameOfs(dbeOld.ofsModuleName)) == 0) {
+ ofsThisEvent = dbeOld.ofsNext;
return ERROR_SUCCESS;
}
- if(!firstTime && dbeOld.ofsPrev!=ofsPrevEvent)
+ if (!firstTime && dbeOld.ofsPrev != ofsPrevEvent)
AddToStatus(STATUS_WARNING,TranslateT("Event not backlinked correctly: fixing"));
- dbeNew->flags=dbeOld.flags;
- dbeNew->ofsPrev=ofsDestPrevEvent;
- dbeNew->ofsNext=0;
+ dbeNew->flags = dbeOld.flags;
+ dbeNew->ofsPrev = ofsDestPrevEvent;
+ dbeNew->ofsNext = 0;
- if ( dbeOld.eventType == EVENTTYPE_MESSAGE && opts.bConvertUtf )
+ if (dbeOld.eventType == EVENTTYPE_MESSAGE && opts.bConvertUtf)
ConvertOldEvent(dbeNew);
- if ( dbePrev )
+ if (dbePrev)
{
- if ( dbePrev->cbBlob == dbeNew->cbBlob &&
+ 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 )
+ !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;
+ ofsPrevEvent = ofsThisEvent;
+ ofsThisEvent = dbeOld.ofsNext;
return ERROR_SUCCESS;
}
free(dbePrev);
}
- else if ( !firstTime && dbeNew->timestamp < lastTimestamp )
+ else if (!firstTime && dbeNew->timestamp < lastTimestamp)
{
DWORD found = 0;
DBEvent dbeTmp;
@@ -256,7 +256,7 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
if (!opts.bAggressive)
{
ofsTmp = dbeOld.ofsPrev;
- while(PeekSegment(ofsTmp,&dbeTmp,sizeof(dbeTmp))==ERROR_SUCCESS)
+ while(PeekSegment(ofsTmp,&dbeTmp,sizeof(dbeTmp)) == ERROR_SUCCESS)
{
if (dbeTmp.ofsPrev == ofsContact) {
found = 1;
@@ -274,7 +274,7 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
else
{
ofsTmp = ofsDestPrevEvent;
- while(ReadWrittenSegment(ofsTmp,&dbeTmp,sizeof(dbeTmp))==ERROR_SUCCESS)
+ while(ReadWrittenSegment(ofsTmp,&dbeTmp,sizeof(dbeTmp)) == ERROR_SUCCESS)
{
if (dbeTmp.ofsPrev == ofsContact) {
found = 1;
@@ -295,16 +295,16 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
// insert before FIRST
if (found == 1 && !opts.bCheckOnly) {
dbeNew->flags|=DBEF_FIRST;
- dbeNew->ofsPrev=ofsContact;
- dbeNew->ofsNext=dbc->ofsFirstEvent;
+ dbeNew->ofsPrev = ofsContact;
+ dbeNew->ofsNext = dbc->ofsFirstEvent;
ofsDestThis = WriteEvent(dbeNew);
- if ( !ofsDestThis )
+ if (!ofsDestThis)
return ERROR_HANDLE_DISK_FULL;
- if ( isUnread && timestampFirstUnread >= dbeNew->timestamp ) {
- ofsFirstUnread=ofsDestThis;
- timestampFirstUnread=dbeNew->timestamp;
+ if (isUnread && timestampFirstUnread >= dbeNew->timestamp) {
+ ofsFirstUnread = ofsDestThis;
+ timestampFirstUnread = dbeNew->timestamp;
}
// fix first event
WriteOfsNextToPrevious(0,dbc,ofsDestThis);
@@ -315,16 +315,16 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
}
else if (found == 2 && !opts.bCheckOnly) {
- dbeNew->ofsPrev=ofsTmp;
- dbeNew->ofsNext=dbeTmp.ofsNext;
+ dbeNew->ofsPrev = ofsTmp;
+ dbeNew->ofsNext = dbeTmp.ofsNext;
ofsDestThis = WriteEvent(dbeNew);
- if ( !ofsDestThis )
+ if (!ofsDestThis)
return ERROR_HANDLE_DISK_FULL;
- if ( isUnread && timestampFirstUnread >= dbeNew->timestamp ) {
- ofsFirstUnread=ofsDestThis;
- timestampFirstUnread=dbeNew->timestamp;
+ if (isUnread && timestampFirstUnread >= dbeNew->timestamp) {
+ ofsFirstUnread = ofsDestThis;
+ timestampFirstUnread = dbeNew->timestamp;
}
// fix previous event
WriteOfsNextToPrevious(dbeNew->ofsPrev,dbc,ofsDestThis);
@@ -335,29 +335,29 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime)
if (found) {
eventCount++;
// ofsDestPrevEvent is still the same!
- ofsPrevEvent=ofsThisEvent;
- ofsThisEvent=dbeOld.ofsNext;
+ ofsPrevEvent = ofsThisEvent;
+ ofsThisEvent = dbeOld.ofsNext;
return ERROR_SUCCESS;
}
}
- lastTimestamp=dbeNew->timestamp;
+ lastTimestamp = dbeNew->timestamp;
dbePrevEvent = dbeNew;
ofsDestThis = WriteEvent(dbeNew);
- if ( !ofsDestThis )
+ if (!ofsDestThis)
return ERROR_HANDLE_DISK_FULL;
- if ( isUnread ) {
- ofsFirstUnread=ofsDestThis;
- timestampFirstUnread=dbeOld.timestamp;
+ if (isUnread) {
+ ofsFirstUnread = ofsDestThis;
+ timestampFirstUnread = dbeOld.timestamp;
}
eventCount++;
WriteOfsNextToPrevious(ofsDestPrevEvent,dbc,ofsDestThis);
- ofsDestPrevEvent=ofsDestThis;
- ofsPrevEvent=ofsThisEvent;
- ofsThisEvent=dbeOld.ofsNext;
+ ofsDestPrevEvent = ofsDestThis;
+ ofsPrevEvent = ofsThisEvent;
+ ofsThisEvent = dbeOld.ofsNext;
return ERROR_SUCCESS;
}
diff --git a/tools/dbtool/finaltasks.cpp b/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp
index b7a99a5189..939fd680d1 100644
--- a/tools/dbtool/finaltasks.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp
@@ -16,7 +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 "dbtool.h"
+#include "..\commonheaders.h"
extern int errorCount;
@@ -24,14 +24,14 @@ int WorkFinalTasks(int firstTime)
{
FreeModuleChain();
AddToStatus(STATUS_MESSAGE,TranslateT("Processing final tasks"));
- dbhdr.slackSpace=0;
- if(WriteSegment(0,&dbhdr,sizeof(dbhdr))==WS_ERROR)
+ 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 ) {
+ if (opts.hOutFile) {
CloseHandle(opts.hOutFile);
opts.hOutFile = NULL;
}
@@ -43,36 +43,36 @@ int WorkFinalTasks(int firstTime)
CloseHandle(opts.hMap);
opts.hMap = NULL;
}
- if(errorCount && !opts.bBackup && !opts.bCheckOnly) {
+ if (errorCount && !opts.bBackup && !opts.bCheckOnly) {
extern time_t ts;
time_t dlg_ts = time(NULL);
- if ( IDYES == MessageBox( 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 ))
+ TranslateT("Miranda Database Tool"), MB_YESNO))
opts.bBackup = 1;
- ts += time(NULL) - dlg_ts;
+ ts += time(NULL) - dlg_ts;
}
- if(opts.bBackup) {
+ 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 );
+ _tcscpy(dbPath, opts.filename);
+ TCHAR* str2 = _tcsrchr(dbPath, '\\');
+ if (str2 != NULL) {
+ _tcscpy(dbFile, str2+1);
*str2 = 0;
}
else {
- _tcscpy( dbFile, dbPath );
+ _tcscpy(dbFile, dbPath);
dbPath[0] = 0;
}
- for(i=1;;i++) {
- if(i==1) wsprintf(opts.backupFilename,TranslateT("%s\\Backup of %s"),dbPath,dbFile);
+ 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;
+ 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"));
+ 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/tools/dbtool/initialchecks.cpp b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp
index aa9a5527fa..21ccff5976 100644
--- a/tools/dbtool/initialchecks.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp
@@ -16,7 +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 "dbtool.h"
+#include "..\commonheaders.h"
extern DWORD sourceFileSize,spaceUsed;
@@ -24,37 +24,37 @@ int WorkInitialChecks(int firstTime)
{
DWORD bytesRead;
- sourceFileSize=GetFileSize(opts.hFile,NULL);
- if(sourceFileSize==0) {
+ 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)) {
+ 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))) {
+ if (memcmp(dbhdr.signature,&dbSignature,sizeof(dbhdr.signature))) {
AddToStatus(STATUS_FATAL,TranslateT("Database signature is corrupted, automatic repair is impossible"));
return ERROR_BAD_FORMAT;
}
- if(dbhdr.version!=0x00000700) {
+ if (dbhdr.version != 0x00000700) {
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;
+ if (opts.bCheckOnly) {
+ _tcscpy(opts.outputFilename, TranslateT("<check only>"));
+ opts.hOutFile = INVALID_HANDLE_VALUE;
}
else {
_tcscpy(opts.outputFilename,opts.filename);
- *_tcsrchr(opts.outputFilename,'.')=0;
+ *_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 ) {
+ if (opts.hOutFile == INVALID_HANDLE_VALUE) {
AddToStatus(STATUS_FATAL,TranslateT("Can't create output file (%u)"),GetLastError());
return ERROR_ACCESS_DENIED;
}
@@ -73,9 +73,9 @@ int WorkInitialChecks(int firstTime)
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);
+ 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/tools/dbtool/modulechain.cpp b/plugins/Db3x_mmap/src/dbtool/modulechain.cpp
index ffa7680dbb..f53f63c469 100644
--- a/tools/dbtool/modulechain.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/modulechain.cpp
@@ -16,13 +16,13 @@ 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"
+#include "..\commonheaders.h"
struct ModChainEntry {
DWORD ofsOld,ofsNew;
int size;
char name[257];
-} static *modChain=NULL;
+} static *modChain = NULL;
static int modChainCount;
static DWORD ofsCurrent;
static int phase,iCurrentModName;
@@ -33,66 +33,66 @@ int WorkModuleChain(int firstTime)
{
DBModuleName moduleName,*newModName;
- if(firstTime) {
+ if (firstTime) {
AddToStatus(STATUS_MESSAGE,TranslateT("Processing module name chain"));
- modChainCount=0;
+ modChainCount = 0;
last_mod = 0;
- if(modChain!=NULL) free(modChain);
+ if (modChain != NULL) free(modChain);
modChain = (ModChainEntry*)malloc(sizeof(ModChainEntry));
- phase=0;
- ofsCurrent=dbhdr.ofsFirstModuleName;
+ phase = 0;
+ ofsCurrent = dbhdr.ofsFirstModuleName;
}
switch(phase) {
case 0:
- if(ofsCurrent==0) {
+ if (ofsCurrent == 0) {
phase++;
return ERROR_SUCCESS;
}
- if(!SignatureValid(ofsCurrent,DBMODULENAME_SIGNATURE)) {
+ 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) {
+ if (PeekSegment(ofsCurrent,&moduleName,offsetof(DBModuleName,name)) != ERROR_SUCCESS) {
phase++;
return ERROR_SUCCESS;
}
- if(moduleName.cbName>256)
+ if (moduleName.cbName>256)
AddToStatus(STATUS_WARNING,TranslateT("Unreasonably long module name, skipping"));
else {
- modChain=(ModChainEntry*)realloc(modChain,sizeof(ModChainEntry)*++modChainCount);
+ 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;
+ 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;
+ modChain[modChainCount-1].name[moduleName.cbName] = 0;
}
- ofsCurrent=moduleName.ofsNext;
+ ofsCurrent = moduleName.ofsNext;
break;
case 1:
ofsLast = 0;
- iCurrentModName=0;
- dbhdr.ofsFirstModuleName=0;
+ iCurrentModName = 0;
+ dbhdr.ofsFirstModuleName = 0;
phase++;
case 2:
- if(iCurrentModName>=modChainCount) {
+ if (iCurrentModName >= modChainCount) {
DWORD dw = 0;
- if(ofsLast) WriteSegment(ofsLast+offsetof(DBModuleName,ofsNext),&dw,sizeof(DWORD));
+ 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)
+ 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)
+ 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)) {
+ 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++;
}
@@ -106,10 +106,10 @@ int WorkModuleChain(int firstTime)
AddToStatus(STATUS_WARNING,TranslateT("Module name '%s' is not unique: %d duplicates found)"), pszModuleName, n);
}
}
- if(iCurrentModName==0)
- dbhdr.ofsFirstModuleName=modChain[iCurrentModName].ofsNew;
+ if (iCurrentModName == 0)
+ dbhdr.ofsFirstModuleName = modChain[iCurrentModName].ofsNew;
else
- if(WriteSegment(ofsLast+offsetof(DBModuleName,ofsNext),&modChain[iCurrentModName].ofsNew,sizeof(DWORD))==WS_ERROR)
+ if (WriteSegment(ofsLast+offsetof(DBModuleName,ofsNext),&modChain[iCurrentModName].ofsNew,sizeof(DWORD)) == WS_ERROR)
return ERROR_HANDLE_DISK_FULL;
ofsLast = modChain[iCurrentModName].ofsNew;
}
@@ -123,11 +123,11 @@ DWORD ConvertModuleNameOfs(DWORD ofsOld)
{
int i;
- if ( modChain[last_mod].ofsOld==ofsOld )
+ if (modChain[last_mod].ofsOld == ofsOld)
return modChain[last_mod].ofsNew;
- for(i=0;i<modChainCount;i++)
- if(modChain[i].ofsOld==ofsOld) {
+ for(i = 0;i<modChainCount;i++)
+ if (modChain[i].ofsOld == ofsOld) {
last_mod = i;
return modChain[last_mod].ofsNew;
}
@@ -138,7 +138,7 @@ DWORD ConvertModuleNameOfs(DWORD ofsOld)
void FreeModuleChain()
{
- if(modChain!=NULL) {
+ if (modChain != NULL) {
free(modChain);
modChain = NULL;
last_mod = 0;
diff --git a/tools/dbtool/settingschain.cpp b/plugins/Db3x_mmap/src/dbtool/settingschain.cpp
index 6c7b95febc..a2bfc48482 100644
--- a/tools/dbtool/settingschain.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/settingschain.cpp
@@ -16,7 +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 "dbtool.h"
+#include "..\commonheaders.h"
static DWORD ofsThisSettings,ofsDestPrevSettings;
@@ -26,47 +26,47 @@ int WorkSettingsChain(DWORD ofsContact,DBContact *dbc,int firstTime)
DWORD ofsDestThis;
int ret;
- if(firstTime) {
- ofsDestPrevSettings=0;
- ofsThisSettings=dbc->ofsFirstSettings;
- dbc->ofsFirstSettings=0;
+ if (firstTime) {
+ ofsDestPrevSettings = 0;
+ ofsThisSettings = dbc->ofsFirstSettings;
+ dbc->ofsFirstSettings = 0;
}
- if(ofsThisSettings==0)
+ if (ofsThisSettings == 0)
return ERROR_NO_MORE_ITEMS;
- if(!SignatureValid(ofsThisSettings,DBCONTACTSETTINGS_SIGNATURE)) {
+ 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)
+ if (PeekSegment(ofsThisSettings,&dbcsOld,sizeof(dbcsOld)) != ERROR_SUCCESS)
return ERROR_NO_MORE_ITEMS;
- if(dbcsOld.cbBlob>256*1024 || dbcsOld.cbBlob==0) {
+ if (dbcsOld.cbBlob>256*1024 || dbcsOld.cbBlob == 0) {
AddToStatus(STATUS_ERROR,TranslateT("Infeasibly large settings blob: skipping"));
- ofsThisSettings=dbcsOld.ofsNext;
+ 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
+ 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;
+ if ((dbcsNew->ofsModuleName = ConvertModuleNameOfs(dbcsOld.ofsModuleName)) == 0) {
+ ofsThisSettings = dbcsOld.ofsNext;
return ERROR_SUCCESS;
}
- if(dbcsNew->blob[0]==0) {
+ if (dbcsNew->blob[0] == 0) {
AddToStatus(STATUS_MESSAGE,TranslateT("Empty settings group at %08X: skipping"),ofsThisSettings);
- ofsThisSettings=dbcsOld.ofsNext;
+ ofsThisSettings = dbcsOld.ofsNext;
return ERROR_SUCCESS;
}
- dbcsNew->ofsNext=0;
+ 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) {
+ 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;
+ 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/tools/dbtool/user.cpp b/plugins/Db3x_mmap/src/dbtool/user.cpp
index 79f30eace7..d61add09d4 100644
--- a/tools/dbtool/user.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/user.cpp
@@ -16,7 +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 "dbtool.h"
+#include "..\commonheaders.h"
static DBContact user;
static int phase;
@@ -27,44 +27,44 @@ int WorkEventChain(DWORD ofsContact,DBContact *dbc,int firstTime);
int WorkUser(int firstTime)
{
- int first=0;
+ int first = 0;
- if(firstTime) {
+ if (firstTime) {
AddToStatus(STATUS_MESSAGE,TranslateT("Processing user data"));
- if(!SignatureValid(dbhdr.ofsUser,DBCONTACT_SIGNATURE)) {
+ 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)
+ if (ReadSegment(dbhdr.ofsUser,&user,sizeof(DBContact)) != ERROR_SUCCESS)
return ERROR_NO_MORE_ITEMS;
- if(user.ofsNext) {
+ if (user.ofsNext) {
AddToStatus(STATUS_WARNING,TranslateT("More than one user contact: keeping only first"));
- user.ofsNext=0;
+ user.ofsNext = 0;
}
- if((ofsUser=WriteSegment(WSOFS_END,&user,sizeof(DBContact)))==WS_ERROR)
+ if ((ofsUser = WriteSegment(WSOFS_END,&user,sizeof(DBContact))) == WS_ERROR)
return ERROR_HANDLE_DISK_FULL;
- dbhdr.ofsUser=ofsUser;
- phase=0;
- first=1;
+ 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;
+ ret = WorkSettingsChain(ofsUser,&user,first);
+ if (ret == ERROR_NO_MORE_ITEMS) {
+ phase++; first = 1;
}
- else if(ret) return ret;
+ 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)
+ 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;
+ else if (ret) return ret;
break;
}
return ERROR_SUCCESS;
diff --git a/plugins/Db3x_mmap/src/init.cpp b/plugins/Db3x_mmap/src/init.cpp
index 032b43b5d4..ae530c6457 100644
--- a/plugins/Db3x_mmap/src/init.cpp
+++ b/plugins/Db3x_mmap/src/init.cpp
@@ -120,7 +120,26 @@ 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)
+{
+ if (phase >= SIZEOF(Workers))
+ return ERROR_NO_MORE_ITEMS;
+
+ CDb3Mmap* db = (CDb3Mmap*)callback->db;
+ return (db->*Workers[phase])(callback, firstTime);
+}
+*/
static DATABASELINK dblink =
{
sizeof(DATABASELINK),
@@ -129,7 +148,8 @@ static DATABASELINK dblink =
makeDatabase,
grokHeader,
LoadDatabase,
- UnloadDatabase
+ UnloadDatabase,
+ //CheckDb
};
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/tools/dbtool/dbtool_10.vcxproj b/plugins/DbChecker/dbchecker_10.vcxproj
index ac0048d971..e81afbb368 100644
--- a/tools/dbtool/dbtool_10.vcxproj
+++ b/plugins/DbChecker/dbchecker_10.vcxproj
@@ -19,16 +19,18 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectName>Dbtool</ProjectName>
+ <ProjectName>DbChecker</ProjectName>
<ProjectGuid>{A2E9DA24-95E4-4414-94AF-488A382E276A}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<CharacterSet>Unicode</CharacterSet>
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<CharacterSet>Unicode</CharacterSet>
@@ -55,11 +57,11 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Plugins\</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>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Plugins\</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>
@@ -73,14 +75,14 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>dbtool.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderFile>dbchecker.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\miranda\include\msapi</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\include;..\..\include\msapi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -88,7 +90,6 @@
<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=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
@@ -129,7 +130,7 @@
<ExceptionHandling>false</ExceptionHandling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>Use</PrecompiledHeader>
- <PrecompiledHeaderFile>dbtool.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderFile>dbchecker.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<BufferSecurityCheck>false</BufferSecurityCheck>
@@ -137,11 +138,10 @@
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\miranda\include\msapi</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\include;..\..\include\msapi;%(AdditionalIncludeDirectories)</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>
@@ -185,43 +185,26 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="disk.cpp" />
- <ClCompile Include="main.cpp">
+ <ClCompile Include="src\main.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
- <ClCompile Include="utf.cpp" />
- <ClCompile Include="wizard.cpp" />
- <ClCompile Include="worker.cpp" />
- <ClCompile Include="aggressive.cpp" />
- <ClCompile Include="contactchain.cpp" />
- <ClCompile Include="eventchain.cpp" />
- <ClCompile Include="finaltasks.cpp" />
- <ClCompile Include="initialchecks.cpp" />
- <ClCompile Include="modulechain.cpp" />
- <ClCompile Include="settingschain.cpp" />
- <ClCompile Include="user.cpp" />
- <ClCompile Include="cleaning.cpp" />
- <ClCompile Include="fileaccess.cpp" />
- <ClCompile Include="finished.cpp" />
- <ClCompile Include="openerror.cpp" />
- <ClCompile Include="progress.cpp" />
- <ClCompile Include="selectdb.cpp" />
- <ClCompile Include="welcome.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="database.h" />
- <ClInclude Include="dbtool.h" />
+ <ClCompile Include="src\utf.cpp" />
+ <ClCompile Include="src\wizard.cpp" />
+ <ClCompile Include="src\worker.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>
- <None Include="res\dbthdr.emf" />
- <None Include="res\dbtool.emf" />
- <None Include="res\dbtool.ico" />
- <None Include="res\profileg.ico" />
- <None Include="res\profiler.ico" />
- <None Include="res\profiley.ico" />
+ <ClInclude Include="src\dbchecker.h" />
</ItemGroup>
<ItemGroup>
- <ResourceCompile Include="resource.rc" />
+ <ResourceCompile Include="res\resource.rc" />
+ <ResourceCompile Include="res\version.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/plugins/DbChecker/dbchecker_10.vcxproj.filters b/plugins/DbChecker/dbchecker_10.vcxproj.filters
new file mode 100644
index 0000000000..0bf3b22913
--- /dev/null
+++ b/plugins/DbChecker/dbchecker_10.vcxproj.filters
@@ -0,0 +1,68 @@
+<?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\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\main.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\utf.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\worker.cpp">
+ <Filter>Source Files</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\wizard.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\dbchecker.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/tools/dbtool/dbtool-translation.txt b/plugins/DbChecker/docs/dbchecker-translation.txt
index f5d1b5eba0..f5d1b5eba0 100644
--- a/tools/dbtool/dbtool-translation.txt
+++ b/plugins/DbChecker/docs/dbchecker-translation.txt
diff --git a/tools/dbtool/res/dbthdr.emf b/plugins/DbChecker/res/dbthdr.emf
index 554d11b5ea..554d11b5ea 100644
--- a/tools/dbtool/res/dbthdr.emf
+++ b/plugins/DbChecker/res/dbthdr.emf
Binary files differ
diff --git a/tools/dbtool/res/dbtool.cdr b/plugins/DbChecker/res/dbtool.cdr
index e5aef201be..e5aef201be 100644
--- a/tools/dbtool/res/dbtool.cdr
+++ b/plugins/DbChecker/res/dbtool.cdr
Binary files differ
diff --git a/tools/dbtool/res/dbtool.emf b/plugins/DbChecker/res/dbtool.emf
index abce0632ee..abce0632ee 100644
--- a/tools/dbtool/res/dbtool.emf
+++ b/plugins/DbChecker/res/dbtool.emf
Binary files differ
diff --git a/tools/dbtool/res/dbtool.ico b/plugins/DbChecker/res/dbtool.ico
index e10cf950ad..e10cf950ad 100644
--- a/tools/dbtool/res/dbtool.ico
+++ b/plugins/DbChecker/res/dbtool.ico
Binary files differ
diff --git a/tools/dbtool/res/delete.ico b/plugins/DbChecker/res/delete.ico
index 6e39da592b..6e39da592b 100644
--- a/tools/dbtool/res/delete.ico
+++ b/plugins/DbChecker/res/delete.ico
Binary files differ
diff --git a/tools/dbtool/res/profileg.ico b/plugins/DbChecker/res/profileg.ico
index 1cd1caa5e4..1cd1caa5e4 100644
--- a/tools/dbtool/res/profileg.ico
+++ b/plugins/DbChecker/res/profileg.ico
Binary files differ
diff --git a/tools/dbtool/res/profiler.ico b/plugins/DbChecker/res/profiler.ico
index 2dc702c863..2dc702c863 100644
--- a/tools/dbtool/res/profiler.ico
+++ b/plugins/DbChecker/res/profiler.ico
Binary files differ
diff --git a/tools/dbtool/res/profiley.ico b/plugins/DbChecker/res/profiley.ico
index d482ee47ad..d482ee47ad 100644
--- a/tools/dbtool/res/profiley.ico
+++ b/plugins/DbChecker/res/profiley.ico
Binary files differ
diff --git a/tools/dbtool/resource.rc b/plugins/DbChecker/res/resource.rc
index 9b42a1332a..17e11c5796 100644
--- a/tools/dbtool/resource.rc
+++ b/plugins/DbChecker/res/resource.rc
@@ -1,6 +1,6 @@
// Microsoft Visual C++ generated resource script.
//
-#include "resource.h"
+#include "..\src\resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
@@ -23,13 +23,6 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
/////////////////////////////////////////////////////////////////////////////
//
-// RT_MANIFEST
-//
-
-1 RT_MANIFEST "dbtool.exe.manifest"
-
-/////////////////////////////////////////////////////////////////////////////
-//
// Dialog
//
@@ -167,7 +160,7 @@ END
//
#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
+GUIDELINES DESIGNINFO
BEGIN
IDD_WELCOME, DIALOG
BEGIN
@@ -239,7 +232,6 @@ BEGIN
END
#endif // APSTUDIO_INVOKED
-
/////////////////////////////////////////////////////////////////////////////
//
// EMF
@@ -261,44 +253,6 @@ IDI_PROFILEYELLOW ICON "res\\profiley.ico"
IDI_PROFILERED ICON "res\\profiler.ico"
IDI_BAD ICON "res\\delete.ico"
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 0,8,2,0
- PRODUCTVERSION 0,8,2,0
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x40004L
- FILETYPE 0x1L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "080904b0"
- BEGIN
- VALUE "CompanyName", " "
- VALUE "FileDescription", "Miranda NG Database Tool"
- VALUE "FileVersion", "0.8.2.0"
- VALUE "InternalName", "dbtool"
- VALUE "LegalCopyright", "Copyright © 2001-2008 Richard Hughes, Bio"
- VALUE "OriginalFilename", "dbtool.exe"
- VALUE "ProductName", "Miranda Database Tool"
- VALUE "ProductVersion", "0.8.2.0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x809, 1200
- END
-END
-
#endif // Neutral resources
/////////////////////////////////////////////////////////////////////////////
@@ -313,4 +267,3 @@ END
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
-
diff --git a/plugins/DbChecker/res/version.rc b/plugins/DbChecker/res/version.rc
new file mode 100644
index 0000000000..93ddb70b68
--- /dev/null
+++ b/plugins/DbChecker/res/version.rc
@@ -0,0 +1,59 @@
+// Microsoft Visual C++ generated resource script.
+//
+#ifdef APSTUDIO_INVOKED
+#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+#include "..\src\resource.h"
+#include "..\src\version.h"
+#include "winres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// 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
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "Miranda NG project"
+ VALUE "FileDescription", "Miranda NG Database Checker"
+ VALUE "FileVersion", __FILEVERSION_STRING
+ VALUE "InternalName", "dbchecker"
+ VALUE "LegalCopyright", "Copyright (C) 2012, George Hazan"
+ VALUE "LegalTrademarks", "Licensed under the Gnu General Public License V2 or any later version"
+ VALUE "OriginalFilename", "dbchecker.dll"
+ VALUE "ProductName", "Miranda NG Database Checker"
+ VALUE "ProductVersion", __FILEVERSION_STRING
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // AFX_RESOURCE_DLL
diff --git a/plugins/DbChecker/src/cleaning.cpp b/plugins/DbChecker/src/cleaning.cpp
new file mode 100644
index 0000000000..4ecd2772fb
--- /dev/null
+++ b/plugins/DbChecker/src/cleaning.cpp
@@ -0,0 +1,67 @@
+/*
+Miranda Database Tool
+Copyright (C) 2001-2005 Richard Hughes
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "dbchecker.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/tools/dbtool/dbtool.h b/plugins/DbChecker/src/dbchecker.h
index c674445a39..39d64cb089 100644
--- a/tools/dbtool/dbtool.h
+++ b/plugins/DbChecker/src/dbchecker.h
@@ -34,10 +34,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <time.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"
+#include <m_db_int.h>
+#include "resource.h"
#define WinVerMajor() LOBYTE(LOWORD(GetVersion()))
#define IsWinVerXPPlus() (WinVerMajor()>=5 && LOWORD(GetVersion())!=5)
@@ -56,30 +55,31 @@ struct DbToolOptions {
HANDLE hMap;
BYTE *pFile;
DWORD error;
- int bCheckOnly,bBackup,bAggressive;
- int bEraseHistory,bMarkRead,bConvertUtf;
+ int bCheckOnly, bBackup, bAggressive;
+ int bEraseHistory, bMarkRead, bConvertUtf;
};
extern HINSTANCE hInst;
extern DbToolOptions opts;
-extern DBHeader dbhdr;
+extern HANDLE hEventRun, hEventAbort;
+extern int errorCount;
-int DoMyControlProcessing(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam,INT_PTR *bReturn);
+int DoMyControlProcessing(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam, INT_PTR *bReturn);
-INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam);
-INT_PTR CALLBACK CleaningDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam);
-INT_PTR CALLBACK ProgressDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam);
-INT_PTR CALLBACK FileAccessDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam);
-INT_PTR CALLBACK WizardDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam);
-INT_PTR CALLBACK FinishedDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam);
-INT_PTR CALLBACK WelcomeDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam);
-INT_PTR CALLBACK OpenErrorDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam);
+INT_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 dbSignature = {"Miranda ICQ DB", 0x1A};
#define SIZEOF(X) (sizeof(X)/sizeof(X[0]))
@@ -89,18 +89,17 @@ static struct DBSignature dbSignature={"Miranda ICQ DB",0x1A};
#define STATUS_FATAL 3
#define STATUS_SUCCESS 4
#define STATUS_CLASSMASK 0x0f
-int AddToStatus(DWORD flags, TCHAR* fmt,...);
+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);
+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 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/fileaccess.cpp b/plugins/DbChecker/src/fileaccess.cpp
new file mode 100644
index 0000000000..f9b6e2d656
--- /dev/null
+++ b/plugins/DbChecker/src/fileaccess.cpp
@@ -0,0 +1,73 @@
+/*
+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 "dbchecker.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/DbChecker/src/finished.cpp b/plugins/DbChecker/src/finished.cpp
new file mode 100644
index 0000000000..96da1a0917
--- /dev/null
+++ b/plugins/DbChecker/src/finished.cpp
@@ -0,0 +1,86 @@
+/*
+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 "dbchecker.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(""), 0);
+ }
+ 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/tools/dbtool/main.cpp b/plugins/DbChecker/src/main.cpp
index 9297ba66e1..f59f66a13a 100644
--- a/tools/dbtool/main.cpp
+++ b/plugins/DbChecker/src/main.cpp
@@ -7,7 +7,7 @@ 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,
+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.
@@ -16,18 +16,11 @@ 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"
+
+#include "dbchecker.h"
HINSTANCE hInst;
-int hLangpack=0;
+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/DbChecker/src/openerror.cpp b/plugins/DbChecker/src/openerror.cpp
new file mode 100644
index 0000000000..f86ba163cb
--- /dev/null
+++ b/plugins/DbChecker/src/openerror.cpp
@@ -0,0 +1,58 @@
+/*
+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 "dbchecker.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/DbChecker/src/progress.cpp b/plugins/DbChecker/src/progress.cpp
new file mode 100644
index 0000000000..5465fee8fa
--- /dev/null
+++ b/plugins/DbChecker/src/progress.cpp
@@ -0,0 +1,224 @@
+/*
+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 "dbchecker.h"
+
+#define WM_PROCESSINGDONE (WM_USER+1)
+
+void __cdecl WorkerThread(void *unused);
+static HWND hwndStatus, hdlgProgress, hwndBar;
+HANDLE hEventRun = NULL, hEventAbort = NULL;
+int errorCount;
+
+void AddToStatus(int flags, const TCHAR* fmt, ...)
+{
+ va_list vararg;
+ va_start(vararg, fmt);
+
+ TCHAR str[256];
+ _vsntprintf(str, SIZEOF(str), fmt, vararg);
+ va_end(vararg);
+
+ int 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++;
+}
+
+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)
+{
+ static int fontHeight, listWidth;
+ static int manualAbort;
+ static HFONT hBoldFont = NULL;
+
+ INT_PTR bReturn;
+ if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
+ return bReturn;
+
+ switch(message) {
+ case WM_INITDIALOG:
+ EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), FALSE);
+ hdlgProgress = hdlg;
+ hwndStatus = GetDlgItem(hdlg, IDC_STATUS);
+ errorCount = 0;
+ 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/tools/dbtool/resource.h b/plugins/DbChecker/src/resource.h
index a76f82ee1c..a76f82ee1c 100644
--- a/tools/dbtool/resource.h
+++ b/plugins/DbChecker/src/resource.h
diff --git a/plugins/DbChecker/src/selectdb.cpp b/plugins/DbChecker/src/selectdb.cpp
new file mode 100644
index 0000000000..0b61d5c5b6
--- /dev/null
+++ b/plugins/DbChecker/src/selectdb.cpp
@@ -0,0 +1,296 @@
+/*
+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 "dbchecker.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, const TCHAR* filename, TCHAR* dir)
+{
+ LV_ITEM lvi;
+ lvi.mask = LVIF_PARAM;
+ lvi.iSubItem = 0;
+ for(lvi.iItem = ListView_GetItemCount(hwndList)-1;lvi.iItem >= 0;lvi.iItem--) {
+ ListView_GetItem(hwndList, &lvi);
+ if (!_tcsicmp((TCHAR*)lvi.lParam, filename))
+ return lvi.iItem;
+ }
+
+ _stat st;
+ if ( _tstat(filename, &st) == -1)
+ return -1;
+
+ int broken = 0;
+ DWORD totalSize = st.st_size;
+ DWORD wasted = 0;
+
+ const TCHAR *pName = _tcsrchr(filename, '\\');
+ if (pName == NULL)
+ pName = (LPTSTR)filename;
+ else
+ pName++;
+
+ TCHAR szName[MAX_PATH];
+ mir_sntprintf(szName, MAX_PATH, _T("%s%s"), dir, pName);
+
+ TCHAR *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;
+
+ int iNewItem = ListView_InsertItem(hwndList, &lvi);
+ TCHAR szSize[20];
+ _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("..")))
+ continue;
+
+ 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:
+ TranslateDialogDefault(hdlg);
+ {
+ HIMAGELIST 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 szMirandaPath[MAX_PATH];
+ GetModuleFileName(NULL, szMirandaPath, SIZEOF(szMirandaPath));
+ TCHAR *str2 = _tcsrchr(szMirandaPath, '\\');
+ if (str2 != NULL)
+ *str2 = 0;
+
+ int i = 0;
+ HKEY hKey;
+ TCHAR szProfileDir[MAX_PATH];
+ TCHAR szMirandaProfiles[MAX_PATH];
+ DWORD cbData = SIZEOF(szMirandaPath);
+
+ _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;
+ }
+ 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 = 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/tools/dbtool/utf.cpp b/plugins/DbChecker/src/utf.cpp
index c56db053d8..ffb73d3280 100644
--- a/tools/dbtool/utf.cpp
+++ b/plugins/DbChecker/src/utf.cpp
@@ -24,7 +24,7 @@ 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"
+#include "dbchecker.h"
bool is_utf8_string(const char* str)
{
@@ -59,7 +59,7 @@ bool is_utf8_string(const char* str)
}
/* OK, next byte of UTF-8 character */
/* Decrement number of expected bytes */
- if ( --expect_bytes == 0 )
+ if (--expect_bytes == 0)
utf_found = 1;
}
str++;
diff --git a/plugins/DbChecker/src/version.h b/plugins/DbChecker/src/version.h
new file mode 100644
index 0000000000..58f9cf348c
--- /dev/null
+++ b/plugins/DbChecker/src/version.h
@@ -0,0 +1,5 @@
+#include <m_version.h>
+
+#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION
+#define __VERSION_STRING MIRANDA_VERSION_STRING
+#define __VERSION_DWORD MIRANDA_VERSION_DWORD
diff --git a/plugins/DbChecker/src/welcome.cpp b/plugins/DbChecker/src/welcome.cpp
new file mode 100644
index 0000000000..99d7a3091a
--- /dev/null
+++ b/plugins/DbChecker/src/welcome.cpp
@@ -0,0 +1,70 @@
+/*
+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 "dbchecker.h"
+
+INT_PTR CALLBACK WelcomeDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ static HENHMETAFILE hEmfWatermark;
+ static HFONT hTitleFont;
+
+ INT_PTR bReturn;
+ if ( DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
+ return bReturn;
+
+ switch(message) {
+ case WM_INITDIALOG:
+ {
+ HRSRC hRsrcWatermark = FindResourceA(hInst, MAKEINTRESOURCEA(IDE_WATERMARK), "EMF");
+ HGLOBAL hGlobWatermark = LoadResource(hInst, hRsrcWatermark);
+ hEmfWatermark = SetEnhMetaFileBits(SizeofResource(hInst, hRsrcWatermark), (PBYTE)LockResource(hGlobWatermark));
+ }
+ SendDlgItemMessage(hdlg, IDC_WATERMARK, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hEmfWatermark);
+ {
+ NONCLIENTMETRICS ncm = {0};
+ ncm.cbSize = sizeof(ncm);
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
+ LOGFONT TitleLogFont = ncm.lfMessageFont;
+ TitleLogFont.lfWeight = FW_BOLD;
+ 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/DbChecker/src/wizard.cpp b/plugins/DbChecker/src/wizard.cpp
new file mode 100644
index 0000000000..dd10b614ac
--- /dev/null
+++ b/plugins/DbChecker/src/wizard.cpp
@@ -0,0 +1,141 @@
+/*
+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 "dbchecker.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);
+ if (hEmfHeaderLogo == NULL) {
+ HRSRC hRsrc = FindResourceA(hInst, MAKEINTRESOURCEA(IDE_HDRLOGO), "EMF");
+ HGLOBAL hGlob = LoadResource(hInst, hRsrc);
+ hEmfHeaderLogo = SetEnhMetaFileBits(SizeofResource(hInst, hRsrc), (PBYTE)LockResource(hGlob));
+ }
+ SendDlgItemMessage(hdlg, IDC_HDRLOGO, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hEmfHeaderLogo);
+ break;
+
+ case WM_CTLCOLORSTATIC:
+ if ((GetWindowLongPtr((HWND)lParam, GWL_STYLE)&0xFFFF) == 0) {
+ char szText[256];
+ GetWindowTextA((HWND)lParam, szText, sizeof(szText));
+ if (!strcmp(szText, "whiterect")) {
+ SetTextColor((HDC)wParam, RGB(255, 255, 255));
+ SetBkColor((HDC)wParam, RGB(255, 255, 255));
+ SetBkMode((HDC)wParam, OPAQUE);
+ *bReturn = (INT_PTR)GetStockObject(WHITE_BRUSH);
+ return TRUE;
+ }
+ else {
+ SetBkMode((HDC)wParam, TRANSPARENT);
+ *bReturn = (INT_PTR)GetStockObject(NULL_BRUSH);
+ return TRUE;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ static HWND hdlgPage;
+
+ switch(message) {
+ case WM_INITDIALOG:
+ SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(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/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp
new file mode 100644
index 0000000000..834a40f308
--- /dev/null
+++ b/plugins/DbChecker/src/worker.cpp
@@ -0,0 +1,79 @@
+/*
+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 "dbchecker.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);
+
+DATABASELINK* dblink;
+
+void __cdecl WorkerThread(void *unused)
+{
+ int task, firstTime;
+ time_t ts = time(NULL);
+
+ AddToStatus(STATUS_MESSAGE, TranslateT("Database worker thread activated"));
+ SetFilePointer(opts.hFile, 0, NULL, FILE_BEGIN);
+
+ DWORD sp = 0;
+ firstTime = 0;
+
+ DBCHeckCallback callback;
+ callback.cbSize = sizeof(callback);
+ callback.db = NULL;
+ callback.spaceUsed = 1;
+ callback.spaceProcessed = 0;
+ callback.pfnAddLogMessage = AddToStatus;
+
+ for(task = 0;;) {
+ if (callback.spaceProcessed/(callback.spaceUsed/1000+1) > sp) {
+ sp = callback.spaceProcessed/(callback.spaceUsed/1000+1);
+ SetProgressBar(sp);
+ }
+ WaitForSingleObject(hEventRun, INFINITE);
+ if (WaitForSingleObject(hEventAbort, 0) == WAIT_OBJECT_0) {
+ AddToStatus(STATUS_FATAL, TranslateT("Processing aborted by user"));
+ break;
+ }
+
+ int ret = dblink->CheckDb(&callback, task, firstTime);
+ firstTime = 0;
+ if (ret == ERROR_NO_MORE_ITEMS) {
+ 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;
+ }
+ else if (ret != ERROR_SUCCESS)
+ break;
+
+ task++;
+ firstTime = 1;
+ }
+
+ ProcessingDone();
+}
diff --git a/tools/dbtool/cleaning.cpp b/tools/dbtool/cleaning.cpp
deleted file mode 100644
index a16a11e7ac..0000000000
--- a/tools/dbtool/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/tools/dbtool/contactchain.cpp b/tools/dbtool/contactchain.cpp
deleted file mode 100644
index dd6d50556b..0000000000
--- a/tools/dbtool/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/tools/dbtool/database.h b/tools/dbtool/database.h
deleted file mode 100644
index 964ab6af25..0000000000
--- a/tools/dbtool/database.h
+++ /dev/null
@@ -1,178 +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
- DWORD version; //as 4 bytes, ie 1.2.3.10=0x0102030a
- //this version is 0x00000700
- 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/tools/dbtool/dbtool.exe.manifest b/tools/dbtool/dbtool.exe.manifest
deleted file mode 100644
index 1b6aab686b..0000000000
--- a/tools/dbtool/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/tools/dbtool/dbtool_10.vcxproj.filters b/tools/dbtool/dbtool_10.vcxproj.filters
deleted file mode 100644
index a3aa9aa299..0000000000
--- a/tools/dbtool/dbtool_10.vcxproj.filters
+++ /dev/null
@@ -1,118 +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="disk.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="main.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="wizard.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="worker.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="aggressive.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="contactchain.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="eventchain.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="finaltasks.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="initialchecks.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="modulechain.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="settingschain.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="user.cpp">
- <Filter>Source Files\Workers</Filter>
- </ClCompile>
- <ClCompile Include="cleaning.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="fileaccess.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="finished.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="openerror.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="progress.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="selectdb.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="welcome.cpp">
- <Filter>Source Files\Wizard Pages</Filter>
- </ClCompile>
- <ClCompile Include="utf.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="database.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="dbtool.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <None Include="res\dbthdr.emf">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="res\dbtool.emf">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="res\dbtool.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="res\profileg.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="res\profiler.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="res\profiley.ico">
- <Filter>Resource Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="resource.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/tools/dbtool/disk.cpp b/tools/dbtool/disk.cpp
deleted file mode 100644
index 685f86569f..0000000000
--- a/tools/dbtool/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/tools/dbtool/docs/dbtool-license.txt b/tools/dbtool/docs/dbtool-license.txt
deleted file mode 100644
index 45645b4b53..0000000000
--- a/tools/dbtool/docs/dbtool-license.txt
+++ /dev/null
@@ -1,340 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- 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
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/tools/dbtool/docs/dbtool-readme.txt b/tools/dbtool/docs/dbtool-readme.txt
deleted file mode 100644
index 26721a0d6c..0000000000
--- a/tools/dbtool/docs/dbtool-readme.txt
+++ /dev/null
@@ -1,27 +0,0 @@
- Miranda Database Tool
- ~~~~~~~~~~~~~~~~~~~~~
-
- www: http://www.miranda-im.org
- e-mail: info@miranda-im.org
-
-
-This is a thingy for compacting wasted space in your Miranda database and
-fixing inconsistencies that may have been introduced.
-
-To keep it simple and robust, Miranda will not by itself reclaim any blank
-space created by deleting information from its profile databases, so this tool
-will do that for you. It can also fix some problems that may occur in rare
-circumstances. Since it also re-writes the database in a more sensible order
-(a bit like defragmenting your hard disk) you may find that you get a speed
-improvement in Miranda by running your database through this tool.
-
-Todo: There is no support for any command line parameters to allow for
-unattended operation yet, and it would be helpful if there was better
-integration with Miranda to allow compaction when necessary. It's also
-possible to fix a larger range of faults than it currently can do, but that
-requires significantly more work.
-
-This programme is copyrighted by Richard Hughes 2001,2002,2003 and is covered
-under the terms of the GNU General Public License.
-
-Source code is available from the Miranda IM website.
diff --git a/tools/dbtool/fileaccess.cpp b/tools/dbtool/fileaccess.cpp
deleted file mode 100644
index d904daf5b9..0000000000
--- a/tools/dbtool/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/tools/dbtool/finished.cpp b/tools/dbtool/finished.cpp
deleted file mode 100644
index 03e4004268..0000000000
--- a/tools/dbtool/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(""), 0 );
- }
- 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/tools/dbtool/openerror.cpp b/tools/dbtool/openerror.cpp
deleted file mode 100644
index 1fa2964c20..0000000000
--- a/tools/dbtool/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/tools/dbtool/progress.cpp b/tools/dbtool/progress.cpp
deleted file mode 100644
index 67c463ec77..0000000000
--- a/tools/dbtool/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/tools/dbtool/selectdb.cpp b/tools/dbtool/selectdb.cpp
deleted file mode 100644
index 761d3af1d0..0000000000
--- a/tools/dbtool/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/tools/dbtool/welcome.cpp b/tools/dbtool/welcome.cpp
deleted file mode 100644
index 360b94ae00..0000000000
--- a/tools/dbtool/welcome.cpp
+++ /dev/null
@@ -1,65 +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:
- { HRSRC hRsrcWatermark=FindResourceA(hInst,MAKEINTRESOURCEA(IDE_WATERMARK),"EMF");
- HGLOBAL hGlobWatermark=LoadResource(hInst,hRsrcWatermark);
- hEmfWatermark=SetEnhMetaFileBits(SizeofResource(hInst,hRsrcWatermark),(PBYTE)LockResource(hGlobWatermark));
- }
- SendDlgItemMessage(hdlg,IDC_WATERMARK,STM_SETIMAGE,IMAGE_ENHMETAFILE,(LPARAM)hEmfWatermark);
- {
- NONCLIENTMETRICS ncm = {0};
- ncm.cbSize = sizeof(ncm);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
- LOGFONT TitleLogFont = ncm.lfMessageFont;
- TitleLogFont.lfWeight = FW_BOLD;
- 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/tools/dbtool/wizard.cpp b/tools/dbtool/wizard.cpp
deleted file mode 100644
index 10c711cd0f..0000000000
--- a/tools/dbtool/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);
- if(hEmfHeaderLogo==NULL) {
- HRSRC hRsrc=FindResourceA(hInst,MAKEINTRESOURCEA(IDE_HDRLOGO),"EMF");
- HGLOBAL hGlob=LoadResource(hInst,hRsrc);
- hEmfHeaderLogo=SetEnhMetaFileBits(SizeofResource(hInst,hRsrc),(PBYTE)LockResource(hGlob));
- }
- SendDlgItemMessage(hdlg,IDC_HDRLOGO,STM_SETIMAGE,IMAGE_ENHMETAFILE,(LPARAM)hEmfHeaderLogo);
- break;
- case WM_CTLCOLORSTATIC:
- if((GetWindowLongPtr((HWND)lParam,GWL_STYLE)&0xFFFF)==0) {
- char szText[256];
- GetWindowTextA((HWND)lParam,szText,sizeof(szText));
- if(!strcmp(szText,"whiterect")) {
- SetTextColor((HDC)wParam,RGB(255,255,255));
- SetBkColor((HDC)wParam,RGB(255,255,255));
- SetBkMode((HDC)wParam,OPAQUE);
- *bReturn=(INT_PTR)GetStockObject(WHITE_BRUSH);
- return TRUE;
- }
- else {
- SetBkMode((HDC)wParam,TRANSPARENT);
- *bReturn=(INT_PTR)GetStockObject(NULL_BRUSH);
- return TRUE;
- }
- }
- break;
- }
- return FALSE;
-}
-
-INT_PTR CALLBACK WizardDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam)
-{
- static HWND hdlgPage;
-
- switch(message) {
- case WM_INITDIALOG:
- SendMessage(hdlg,WM_SETICON,ICON_SMALL,(LPARAM)LoadIcon(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/tools/dbtool/worker.cpp b/tools/dbtool/worker.cpp
deleted file mode 100644
index 7f22539f8f..0000000000
--- a/tools/dbtool/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();
-}