summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdb
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-02-28 08:59:43 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-02-28 08:59:43 +0000
commitbdb57491b80e74a40d9eebf36b0be08bfd0fd320 (patch)
tree4929ddacfcf92b83871d3834fe817b7044316789 /plugins/Dbx_mdb
parent2297d8f2a8749ea9ffebbd13cdd9e903932fa3c8 (diff)
dbx_lmdb: fix events deletion; some fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@16367 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb')
-rw-r--r--plugins/Dbx_mdb/src/dbcrypt.cpp27
-rw-r--r--plugins/Dbx_mdb/src/dbevents.cpp14
-rw-r--r--plugins/Dbx_mdb/src/dbintf.cpp14
-rw-r--r--plugins/Dbx_mdb/src/dbintf.h1
-rw-r--r--plugins/Dbx_mdb/src/ui.cpp22
5 files changed, 36 insertions, 42 deletions
diff --git a/plugins/Dbx_mdb/src/dbcrypt.cpp b/plugins/Dbx_mdb/src/dbcrypt.cpp
index e55d7f38aa..66d74ebf67 100644
--- a/plugins/Dbx_mdb/src/dbcrypt.cpp
+++ b/plugins/Dbx_mdb/src/dbcrypt.cpp
@@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/////////////////////////////////////////////////////////////////////////////////////////
-#define DBKEY_PROVIDER "Provider"
-#define DBKEY_KEY "Key"
-#define DBKEY_IS_ENCRYPTED "EncryptedDB"
+#define DBKEY_PROVIDER "Provider"
+#define DBKEY_KEY "Key"
+#define DBKEY_IS_ENCRYPTED "EncryptedDB"
CRYPTO_PROVIDER* CDbxMdb::SelectProvider()
{
@@ -101,8 +101,25 @@ int CDbxMdb::InitCrypt()
else
{
if (!m_crypto->setKey((const BYTE*)value.mv_data, value.mv_size))
- if (!EnterPassword((const BYTE*)value.mv_data, value.mv_size)) // password protected?
- return 4;
+ {
+ DlgChangePassParam param = { this };
+ CEnterPasswordDialog dlg(&param);
+ while (true)
+ {
+ if (-128 != dlg.DoModal())
+ return 4;
+
+ m_crypto->setPassword(pass_ptrA(mir_utf8encodeT(param.newPass)));
+ if (m_crypto->setKey((const BYTE*)value.mv_data, value.mv_size))
+ {
+ m_bUsesPassword = true;
+ SecureZeroMemory(&param, sizeof(param));
+ break;
+ }
+
+ param.wrongPass++;
+ }
+ }
}
}
else
diff --git a/plugins/Dbx_mdb/src/dbevents.cpp b/plugins/Dbx_mdb/src/dbevents.cpp
index 03bd186165..bf7d39b253 100644
--- a/plugins/Dbx_mdb/src/dbevents.cpp
+++ b/plugins/Dbx_mdb/src/dbevents.cpp
@@ -245,7 +245,7 @@ void CDbxMdb::FindNextUnread(const txn_ptr &txn, DBCachedContact *cc, DBEventSor
MDB_val key = { sizeof(key2), &key2 }, data;
key2.dwEventId++;
- mdb_cursor_get(cursor, &key, &data, MDB_SET_KEY);
+ mdb_cursor_get(cursor, &key, &data, MDB_SET);
while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
DBEvent *dbe = (DBEvent*)data.mv_data;
if (!dbe->markedRead()) {
@@ -286,7 +286,7 @@ STDMETHODIMP_(BOOL) CDbxMdb::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent)
mdb_put(txn, m_dbEvents, &key, &data, 0);
FindNextUnread(txn, cc, key2);
- key.mv_data = &contactID;
+ key.mv_size = sizeof(MCONTACT); key.mv_data = &contactID;
data.mv_data = &cc->dbc; data.mv_size = sizeof(cc->dbc);
mdb_put(txn, m_dbContacts, &key, &data, 0);
@@ -322,9 +322,9 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindFirstEvent(MCONTACT contactID)
txn_ptr_ro txn(m_txn);
cursor_ptr_ro cursor(m_curEventsSort);
- mdb_cursor_get(cursor, &key, &data, MDB_SET);
- if (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) != MDB_SUCCESS)
- return m_evLast = 0;
+ mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE);
+// if (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) != MDB_SUCCESS)
+// return m_evLast = 0;
DBEventSortingKey *pKey = (DBEventSortingKey*)key.mv_data;
m_tsLast = pKey->ts;
@@ -346,7 +346,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindLastEvent(MCONTACT contactID)
txn_ptr_ro txn(m_txn);
cursor_ptr_ro cursor(m_curEventsSort);
- mdb_cursor_get(cursor, &key, &data, MDB_SET);
+ mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE);
if (mdb_cursor_get(cursor, &key, &data, MDB_PREV) != MDB_SUCCESS)
return m_evLast = 0;
@@ -412,7 +412,7 @@ STDMETHODIMP_(MEVENT) CDbxMdb::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent
MDB_val key = { sizeof(keyVal), &keyVal };
cursor_ptr_ro cursor(m_curEventsSort);
- if (mdb_cursor_get(cursor, &key, &data, MDB_SET) != MDB_SUCCESS)
+ if (mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE) != MDB_SUCCESS)
return m_evLast = 0;
if (mdb_cursor_get(cursor, &key, &data, MDB_PREV) != MDB_SUCCESS)
diff --git a/plugins/Dbx_mdb/src/dbintf.cpp b/plugins/Dbx_mdb/src/dbintf.cpp
index f6026e92e3..741fd0997f 100644
--- a/plugins/Dbx_mdb/src/dbintf.cpp
+++ b/plugins/Dbx_mdb/src/dbintf.cpp
@@ -86,13 +86,13 @@ int CDbxMdb::Load(bool bSkipInit)
if (!bSkipInit) {
txn_ptr trnlck(m_pMdbEnv);
- mdb_open(trnlck, "crypto", MDB_CREATE, &m_dbCrypto);
- 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 | MDB_INTEGERKEY, &m_dbEventsSort);
- mdb_open(trnlck, "settings", MDB_CREATE, &m_dbSettings);
+ mdb_dbi_open(trnlck, "global", MDB_CREATE | MDB_INTEGERKEY, &m_dbGlobal);
+ mdb_dbi_open(trnlck, "crypto", MDB_CREATE, &m_dbCrypto);
+ mdb_dbi_open(trnlck, "contacts", MDB_CREATE | MDB_INTEGERKEY, &m_dbContacts);
+ mdb_dbi_open(trnlck, "modules", MDB_CREATE | MDB_INTEGERKEY, &m_dbModules);
+ mdb_dbi_open(trnlck, "events", MDB_CREATE | MDB_INTEGERKEY, &m_dbEvents);
+ mdb_dbi_open(trnlck, "eventsrt", MDB_CREATE | MDB_INTEGERKEY, &m_dbEventsSort);
+ mdb_dbi_open(trnlck, "settings", MDB_CREATE, &m_dbSettings);
DWORD keyVal = 1;
MDB_val key = { sizeof(DWORD), &keyVal }, data;
diff --git a/plugins/Dbx_mdb/src/dbintf.h b/plugins/Dbx_mdb/src/dbintf.h
index 2c05fb6f46..2c95b6413d 100644
--- a/plugins/Dbx_mdb/src/dbintf.h
+++ b/plugins/Dbx_mdb/src/dbintf.h
@@ -330,5 +330,4 @@ protected:
void GenerateNewKey();
void InitDialogs();
- bool EnterPassword(const BYTE *pKey, const size_t keyLen);
};
diff --git a/plugins/Dbx_mdb/src/ui.cpp b/plugins/Dbx_mdb/src/ui.cpp
index 67fc6a5610..8c7ec8c52c 100644
--- a/plugins/Dbx_mdb/src/ui.cpp
+++ b/plugins/Dbx_mdb/src/ui.cpp
@@ -39,28 +39,6 @@ void LanguageChanged(HWND hwndDlg)
}
}
-/////////////////////////////////////////////////////////////////////////////////////////
-
-bool CDbxMdb::EnterPassword(const BYTE *pKey, const size_t keyLen)
-{
- DlgChangePassParam param = { this };
- CEnterPasswordDialog dlg(&param);
- while (true)
- {
- if (-128 != dlg.DoModal())
- return false;
-
- m_crypto->setPassword(pass_ptrA(mir_utf8encodeT(param.newPass)));
- if (m_crypto->setKey(pKey, keyLen))
- {
- m_bUsesPassword = true;
- SecureZeroMemory(&param, sizeof(param));
- return true;
- }
-
- param.wrongPass++;
- }
-}
/////////////////////////////////////////////////////////////////////////////////////////