diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-20 11:09:16 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-20 11:09:16 +0000 |
commit | e35464b3a1c3a5af68b348803049d90d73c1bc0d (patch) | |
tree | be5f05a3cb1b490653132afb735d9befeba4352b /plugins/Db3x_mmap/src/dbtool | |
parent | 7663d8886a2e059232287b6652ead02142f6d6fc (diff) |
all profile conversion stuff moved to dbchecker
git-svn-id: http://svn.miranda-ng.org/main/trunk@9880 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src/dbtool')
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/contactchain.cpp | 15 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/disk.cpp | 4 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/eventchain.cpp | 37 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/finaltasks.cpp | 6 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/initialchecks.cpp | 15 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/user.cpp | 3 |
6 files changed, 69 insertions, 11 deletions
diff --git a/plugins/Db3x_mmap/src/dbtool/contactchain.cpp b/plugins/Db3x_mmap/src/dbtool/contactchain.cpp index f1ba3ebe61..d149bd0e86 100644 --- a/plugins/Db3x_mmap/src/dbtool/contactchain.cpp +++ b/plugins/Db3x_mmap/src/dbtool/contactchain.cpp @@ -52,8 +52,16 @@ LBL_FinishUp: cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Contact chain corrupted, further entries ignored"));
goto LBL_FinishUp;
}
- if (ReadSegment(ofsThisContact, &dbc, sizeof(dbc)) != ERROR_SUCCESS)
- goto LBL_FinishUp;
+
+ if (m_dbHeader.version < DB_095_VERSION) {
+ if (ReadSegment(ofsThisContact, &dbc, offsetof(DBContact, dwContactID)) != ERROR_SUCCESS)
+ goto LBL_FinishUp;
+ dbc.dwContactID = m_dwMaxContactId++;
+ }
+ else {
+ if (ReadSegment(ofsThisContact, &dbc, sizeof(dbc)) != ERROR_SUCCESS)
+ goto LBL_FinishUp;
+ }
ofsNextContact = dbc.ofsNext;
dbc.ofsNext = 0;
@@ -64,6 +72,9 @@ LBL_FinishUp: WriteSegment(ofsDestPrevContact + offsetof(DBContact, ofsNext), &ofsDestThis, sizeof(DWORD));
else
m_dbHeader.ofsFirstContact = ofsDestThis;
+
+ if (m_dbHeader.version < DB_095_VERSION)
+ m_contactsMap.insert(new ConvertedContact(ofsThisContact, ofsDestThis));
}
else ofsDestThis = ofsThisContact; // needed in event chain worker
diff --git a/plugins/Db3x_mmap/src/dbtool/disk.cpp b/plugins/Db3x_mmap/src/dbtool/disk.cpp index 7cd4dfd88c..692fdb7fde 100644 --- a/plugins/Db3x_mmap/src/dbtool/disk.cpp +++ b/plugins/Db3x_mmap/src/dbtool/disk.cpp @@ -26,8 +26,8 @@ int CDb3Mmap::SignatureValid(DWORD ofs, DWORD signature) return 0;
}
- DWORD sig = *(DWORD*)(m_pDbCache + ofs);
- return sig == signature;
+ DWORD *sig = (DWORD*)(m_pDbCache + ofs);
+ return *sig == signature;
}
int CDb3Mmap::PeekSegment(DWORD ofs, PVOID buf, int cbBytes)
diff --git a/plugins/Db3x_mmap/src/dbtool/eventchain.cpp b/plugins/Db3x_mmap/src/dbtool/eventchain.cpp index 9d3b227526..15fc96b0ec 100644 --- a/plugins/Db3x_mmap/src/dbtool/eventchain.cpp +++ b/plugins/Db3x_mmap/src/dbtool/eventchain.cpp @@ -102,6 +102,22 @@ void CDb3Mmap::FinishUp(DWORD ofsLast, DBContact *dbc) }
}
+DWORD CDb3Mmap::PeekEvent(DWORD ofs, DWORD dwContactID, DBEvent *dbe)
+{
+ if (m_dbHeader.version == DB_095_1_VERSION)
+ return PeekSegment(ofs, dbe, sizeof(DBEvent));
+
+ DBEvent_094 oldEvent;
+ DWORD ret = PeekSegment(ofs, &oldEvent, sizeof(oldEvent));
+ if (ret != ERROR_SUCCESS)
+ return ret;
+
+ dbe->signature = oldEvent.signature;
+ dbe->contactID = dwContactID;
+ memcpy(&dbe->ofsPrev, &oldEvent.ofsPrev, sizeof(oldEvent) - sizeof(DWORD));
+ return ERROR_SUCCESS;
+}
+
DWORD CDb3Mmap::WriteEvent(DBEvent *dbe)
{
DWORD ofs = WriteSegment(WSOFS_END, dbe, offsetof(DBEvent, blob) + dbe->cbBlob);
@@ -152,7 +168,7 @@ int CDb3Mmap::WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime) if (!backLookup && ofsTmp) {
backLookup = 1;
while (SignatureValid(ofsTmp, DBEVENT_SIGNATURE)) {
- if (PeekSegment(ofsTmp, &dbeOld, sizeof(dbeOld)) != ERROR_SUCCESS)
+ if (PeekEvent(ofsTmp, dbc->dwContactID, &dbeOld) != ERROR_SUCCESS)
break;
ofsNew = ofsTmp;
ofsTmp = dbeOld.ofsPrev;
@@ -169,7 +185,7 @@ int CDb3Mmap::WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime) }
}
- if (PeekSegment(ofsThisEvent, &dbeOld, sizeof(dbeOld)) != ERROR_SUCCESS) {
+ if (PeekEvent(ofsThisEvent, dbc->dwContactID, &dbeOld) != ERROR_SUCCESS) {
FinishUp(ofsDestPrevEvent, dbc);
return ERROR_NO_MORE_ITEMS;
}
@@ -217,7 +233,20 @@ int CDb3Mmap::WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime) }
dbeNew = memblock;
- if (ReadSegment(ofsThisEvent, dbeNew, offsetof(DBEvent, blob) + dbeOld.cbBlob) != ERROR_SUCCESS) {
+ DWORD ret;
+ if (m_dbHeader.version < DB_095_1_VERSION) {
+ DBEvent_094 oldEvent;
+ ret = ReadSegment(ofsThisEvent, &oldEvent, offsetof(DBEvent_094, blob));
+ if (ret == ERROR_SUCCESS) {
+ dbeNew->signature = oldEvent.signature;
+ dbeNew->contactID = dbc->dwContactID;
+ memcpy(&dbeNew->ofsPrev, &oldEvent.ofsPrev, offsetof(DBEvent_094, blob) - sizeof(DWORD));
+ ret = ReadSegment(ofsThisEvent + offsetof(DBEvent_094, blob), &dbeNew->blob, dbeOld.cbBlob);
+ }
+ }
+ else ret = ReadSegment(ofsThisEvent, dbeNew, offsetof(DBEvent, blob) + dbeOld.cbBlob);
+
+ if (ret != ERROR_SUCCESS) {
FinishUp(ofsDestPrevEvent, dbc);
return ERROR_NO_MORE_ITEMS;
}
@@ -273,7 +302,7 @@ int CDb3Mmap::WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime) if (cb->bCheckOnly) {
if (!cb->bAggressive) {
ofsTmp = dbeOld.ofsPrev;
- while (PeekSegment(ofsTmp, &dbeTmp, sizeof(dbeTmp)) == ERROR_SUCCESS) {
+ while (PeekEvent(ofsTmp, dbc->dwContactID, &dbeTmp) == ERROR_SUCCESS) {
if (dbeTmp.ofsPrev == ofsContact) {
found = 1;
break;
diff --git a/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp b/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp index 972999524b..5aa01e230c 100644 --- a/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp +++ b/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp @@ -24,6 +24,12 @@ int CDb3Mmap::WorkFinalTasks(int firstTime) FreeModuleChain();
cb->pfnAddLogMessage(STATUS_MESSAGE, TranslateT("Processing final tasks"));
m_dbHeader.slackSpace = 0;
+
+ if (m_dbHeader.version < DB_095_1_VERSION) {
+ memcpy(&m_dbHeader.signature, &dbSignatureU, sizeof(m_dbHeader.signature));
+ m_dbHeader.version = DB_095_1_VERSION;
+ }
+
if (WriteSegment(0, &m_dbHeader, sizeof(m_dbHeader)) == WS_ERROR)
return ERROR_WRITE_FAULT;
diff --git a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp index 86bad8729d..ec1339d787 100644 --- a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp +++ b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp @@ -22,15 +22,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int CDb3Mmap::WorkInitialCheckHeaders()
{
if (memcmp(m_dbHeader.signature, &dbSignatureU, sizeof(m_dbHeader.signature)) &&
- memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature)))
+ memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature)) &&
+ memcmp(m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature)) &&
+ memcmp(m_dbHeader.signature, &dbSignatureSA, sizeof(m_dbHeader.signature)))
{
cb->pfnAddLogMessage(STATUS_FATAL, TranslateT("Database signature is corrupted, automatic repair is impossible"));
return ERROR_BAD_FORMAT;
}
- if (m_dbHeader.version != DB_095_1_VERSION) {
+
+ switch (m_dbHeader.version) {
+ case DB_OLD_VERSION:
+ case DB_094_VERSION:
+ case DB_095_VERSION:
+ case DB_095_1_VERSION:
+ break;
+
+ default:
cb->pfnAddLogMessage(STATUS_FATAL, TranslateT("Database version doesn't match this driver's one. Convert a database first"));
return ERROR_BAD_FORMAT;
}
+
return ERROR_SUCCESS;
}
diff --git a/plugins/Db3x_mmap/src/dbtool/user.cpp b/plugins/Db3x_mmap/src/dbtool/user.cpp index 72d403f509..4f254bdbb9 100644 --- a/plugins/Db3x_mmap/src/dbtool/user.cpp +++ b/plugins/Db3x_mmap/src/dbtool/user.cpp @@ -34,7 +34,8 @@ int CDb3Mmap::WorkUser(int firstTime) return ERROR_NO_MORE_ITEMS;
}
- if (ReadSegment(m_dbHeader.ofsUser, &user, sizeof(DBContact)) != ERROR_SUCCESS)
+ DWORD dwSize = (m_dbHeader.version < DB_095_VERSION) ? offsetof(DBContact, dwContactID) : sizeof(DBContact);
+ if (ReadSegment(m_dbHeader.ofsUser, &user, dwSize) != ERROR_SUCCESS)
return ERROR_NO_MORE_ITEMS;
if (user.ofsNext) {
|