summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdb/src/dbintf.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-01-18 16:47:07 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-01-18 16:47:07 +0000
commitcdad72e9512d163ed15bc89bd0a93e7da2ee4c50 (patch)
treef2b6f3e70745bfcb4aeb9b28d7db16016014feae /plugins/Dbx_mdb/src/dbintf.cpp
parent23344057b3fb532ad37ed5f761c2b31ab6ad017c (diff)
first working version of events
git-svn-id: http://svn.miranda-ng.org/main/trunk@11872 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb/src/dbintf.cpp')
-rw-r--r--plugins/Dbx_mdb/src/dbintf.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/plugins/Dbx_mdb/src/dbintf.cpp b/plugins/Dbx_mdb/src/dbintf.cpp
index f519d3dd4b..01bbfe4fed 100644
--- a/plugins/Dbx_mdb/src/dbintf.cpp
+++ b/plugins/Dbx_mdb/src/dbintf.cpp
@@ -90,11 +90,29 @@ int CDbxMdb::Load(bool bSkipInit)
if (!bSkipInit) {
txn_ptr trnlck(m_pMdbEnv);
+ mdb_open(trnlck, "global", MDB_CREATE | MDB_INTEGERKEY, &m_dbGlobal);
mdb_open(trnlck, "contacts", MDB_CREATE | MDB_INTEGERKEY, &m_dbContacts);
mdb_open(trnlck, "modules", MDB_CREATE | MDB_INTEGERKEY, &m_dbModules);
mdb_open(trnlck, "events", MDB_CREATE | MDB_INTEGERKEY, &m_dbEvents);
- mdb_open(trnlck, "eventsrt", MDB_CREATE, &m_dbEvents);
+ mdb_open(trnlck, "eventsrt", MDB_CREATE | MDB_INTEGERKEY, &m_dbEventsSort);
mdb_open(trnlck, "settings", MDB_CREATE, &m_dbSettings);
+
+ DWORD keyVal = 1;
+ MDB_val key = { sizeof(DWORD), &keyVal }, data;
+ if (mdb_get(trnlck, m_dbGlobal, &key, &data) == MDB_SUCCESS) {
+ DBHeader *hdr = (DBHeader*)data.mv_data;
+ if (hdr->signature != DBHEADER_SIGNATURE)
+ DatabaseCorruption(NULL);
+
+ memcpy(&m_header, data.mv_data, sizeof(m_header));
+ }
+ else {
+ m_header.signature = DBHEADER_SIGNATURE;
+ m_header.dwVersion = 1;
+ m_header.eventCount = 0;
+ data.mv_data = &m_header; data.mv_size = sizeof(m_header);
+ mdb_put(trnlck, m_dbGlobal, &key, &data, 0);
+ }
trnlck.commit();
if (InitModuleNames()) return EGROKPRF_CANTREAD;