summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Dbx_mdb/src/dbcontacts.cpp47
-rw-r--r--plugins/Dbx_mdb/src/dbsettings.cpp2
2 files changed, 40 insertions, 9 deletions
diff --git a/plugins/Dbx_mdb/src/dbcontacts.cpp b/plugins/Dbx_mdb/src/dbcontacts.cpp
index 6a3c4dca44..958f48676a 100644
--- a/plugins/Dbx_mdb/src/dbcontacts.cpp
+++ b/plugins/Dbx_mdb/src/dbcontacts.cpp
@@ -152,23 +152,54 @@ BOOL CDbxMdb::MetaSetDefault(DBCachedContact *cc)
return db_set_dw(cc->contactID, META_PROTO, "Default", cc->nDefault);
}
-static int SortEvent(const DBEvent *p1, const DBEvent *p2)
-{
- return (LONG)p1->timestamp - (LONG)p2->timestamp;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
BOOL CDbxMdb::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
{
- mir_cslock lck(m_csDbAccess);
- return -11;
+ DBEventSortingKey keyVal = { 0, 0, ccSub->contactID }, insVal = { 0, 0, ccMeta->contactID };
+ MDB_val key = { sizeof(keyVal), &keyVal }, key2 = { sizeof(insVal), &insVal }, data;
+
+ txn_ptr trnlck(m_pMdbEnv);
+
+ cursor_ptr cursor(trnlck, m_dbEventsSort);
+ mdb_cursor_get(cursor, &key, &data, MDB_SET);
+ while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS) {
+ DBEventSortingKey *pKey = (DBEventSortingKey*)key.mv_data;
+ if (pKey->dwContactId != ccSub->contactID)
+ break;
+
+ insVal.ts = pKey->ts;
+ insVal.dwEventId = pKey->dwEventId;
+ mdb_put(trnlck, m_dbEventsSort, &key2, &data, 0);
+ }
+
+ trnlck.commit();
+ return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
BOOL CDbxMdb::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
{
- mir_cslock lck(m_csDbAccess);
- return -11;
+ DBEventSortingKey keyVal = { 0, 0, ccSub->contactID }, delVal = { 0, 0, ccMeta->contactID };
+ MDB_val key = { sizeof(keyVal), &keyVal }, key2 = { sizeof(delVal), &delVal }, data;
+
+ txn_ptr trnlck(m_pMdbEnv);
+
+ cursor_ptr cursor(trnlck, m_dbEventsSort);
+ mdb_cursor_get(cursor, &key, &data, MDB_SET);
+ while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS) {
+ DBEventSortingKey *pKey = (DBEventSortingKey*)key.mv_data;
+ if (pKey->dwContactId != ccSub->contactID)
+ break;
+
+ delVal.ts = pKey->ts;
+ delVal.dwEventId = pKey->dwEventId;
+ mdb_del(trnlck, m_dbEventsSort, &key2, &data);
+ }
+
+ trnlck.commit();
+ return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Dbx_mdb/src/dbsettings.cpp b/plugins/Dbx_mdb/src/dbsettings.cpp
index f9516e4a99..1d0a69bc0b 100644
--- a/plugins/Dbx_mdb/src/dbsettings.cpp
+++ b/plugins/Dbx_mdb/src/dbsettings.cpp
@@ -283,7 +283,7 @@ STDMETHODIMP_(BOOL) CDbxMdb::GetContactSettingStr(MCONTACT contactID, LPCSTR szM
if (iSaveType == DBVT_WCHAR) {
if (dbv->type != DBVT_UTF8) {
int len = MultiByteToWideChar(CP_ACP, 0, dbv->pszVal, -1, NULL, 0);
- wchar_t* wszResult = (wchar_t*)mir_alloc((len + 1)*sizeof(wchar_t));
+ wchar_t *wszResult = (wchar_t*)mir_alloc((len + 1)*sizeof(wchar_t));
if (wszResult == NULL)
return 1;