From 6ea21b88c16c553aa97e2cd53266ffd4a689d581 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 25 Apr 2020 17:08:25 +0300 Subject: db_event_add / db_event_edit to receive const pointer to DBEVENTINFO --- plugins/Dbx_mdbx/src/dbevents.cpp | 11 ++++++----- plugins/Dbx_mdbx/src/dbintf.h | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'plugins/Dbx_mdbx') diff --git a/plugins/Dbx_mdbx/src/dbevents.cpp b/plugins/Dbx_mdbx/src/dbevents.cpp index 78d1531a29..6a7592a781 100644 --- a/plugins/Dbx_mdbx/src/dbevents.cpp +++ b/plugins/Dbx_mdbx/src/dbevents.cpp @@ -34,7 +34,7 @@ LONG CDbxMDBX::GetEventCount(MCONTACT contactID) /////////////////////////////////////////////////////////////////////////////// -MEVENT CDbxMDBX::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) +MEVENT CDbxMDBX::AddEvent(MCONTACT contactID, const DBEVENTINFO *dbei) { if (dbei == nullptr) return 0; if (dbei->timestamp == 0) return 0; @@ -127,11 +127,12 @@ BOOL CDbxMDBX::DeleteEvent(MEVENT hDbEvent) /////////////////////////////////////////////////////////////////////////////// -BOOL CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, DBEVENTINFO *dbei) +BOOL CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbei) { if (dbei == nullptr) return 1; if (dbei->timestamp == 0) return 1; + DBEVENTINFO tmp = *dbei; { txn_ptr_ro txn(m_txn_ro); MDBX_val key = { &hDbEvent, sizeof(MEVENT) }, data; @@ -139,13 +140,13 @@ BOOL CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, DBEVENTINFO *dbei) return 1; DBEvent *dbe = (DBEvent*)data.iov_base; - dbei->timestamp = dbe->timestamp; + tmp.timestamp = dbe->timestamp; } - return !EditEvent(contactID, hDbEvent, dbei, false); + return !EditEvent(contactID, hDbEvent, &tmp, false); } -bool CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, DBEVENTINFO *dbei, bool bNew) +bool CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbei, bool bNew) { DBEvent dbe; dbe.dwContactID = contactID; // store native or subcontact's id diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h index 4a089b8ef3..b74b6bbc12 100644 --- a/plugins/Dbx_mdbx/src/dbintf.h +++ b/plugins/Dbx_mdbx/src/dbintf.h @@ -168,7 +168,7 @@ class CDbxMDBX : public MDatabaseCommon, public MZeroedObject } bool CheckEvent(DBCachedContact *cc, const DBEvent *dbe, DBCachedContact *&cc2); - bool EditEvent(MCONTACT contactID, MEVENT hDbEvent, DBEVENTINFO *dbe, bool bNew); + bool EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbe, bool bNew); void FillContacts(void); int PrepareCheck(void); void TouchFile(void); @@ -267,9 +267,9 @@ public: STDMETHODIMP_(LONG) GetContactSize(void) override; STDMETHODIMP_(LONG) GetEventCount(MCONTACT contactID) override; - STDMETHODIMP_(MEVENT) AddEvent(MCONTACT contactID, DBEVENTINFO *dbe) override; + STDMETHODIMP_(MEVENT) AddEvent(MCONTACT contactID, const DBEVENTINFO *dbe) override; STDMETHODIMP_(BOOL) DeleteEvent(MEVENT hDbEvent) override; - STDMETHODIMP_(BOOL) EditEvent(MCONTACT contactID, MEVENT hDbEvent, DBEVENTINFO *dbe) override; + STDMETHODIMP_(BOOL) EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbe) override; STDMETHODIMP_(LONG) GetBlobSize(MEVENT hDbEvent) override; STDMETHODIMP_(BOOL) GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbe) override; STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) override; -- cgit v1.2.3