From 8f9292d483fcf3a10d9284512359c4562f5311eb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 11 Apr 2023 17:07:04 +0300 Subject: DB::FILE_BLOB - file events' access unification --- plugins/Import/src/dbrw/dbevents.cpp | 2 +- plugins/Import/src/dbrw/dbintf.h | 2 +- plugins/Import/src/textjson.cpp | 18 ++---------------- 3 files changed, 4 insertions(+), 18 deletions(-) (limited to 'plugins/Import/src') diff --git a/plugins/Import/src/dbrw/dbevents.cpp b/plugins/Import/src/dbrw/dbevents.cpp index 06995bd4a9..95fc34eca3 100644 --- a/plugins/Import/src/dbrw/dbevents.cpp +++ b/plugins/Import/src/dbrw/dbevents.cpp @@ -44,7 +44,7 @@ STDMETHODIMP_(BOOL) CDbxSQLite::DeleteEvent(MEVENT) return FALSE; } -BOOL CDbxSQLite::EditEvent(MCONTACT, MEVENT, const DBEVENTINFO*) +BOOL CDbxSQLite::EditEvent(MEVENT, const DBEVENTINFO*) { return 1; } diff --git a/plugins/Import/src/dbrw/dbintf.h b/plugins/Import/src/dbrw/dbintf.h index 2a843b025d..b3494a44c1 100644 --- a/plugins/Import/src/dbrw/dbintf.h +++ b/plugins/Import/src/dbrw/dbintf.h @@ -134,7 +134,7 @@ public: STDMETHODIMP_(int) GetEventCount(MCONTACT contactID) override; STDMETHODIMP_(MEVENT) AddEvent(MCONTACT contactID, const DBEVENTINFO *dbe) override; STDMETHODIMP_(BOOL) DeleteEvent(MEVENT hDbEvent) override; - STDMETHODIMP_(BOOL) EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO *dbe) override; + STDMETHODIMP_(BOOL) EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbe) override; STDMETHODIMP_(int) GetBlobSize(MEVENT hDbEvent) override; STDMETHODIMP_(BOOL) GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbe) override; STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) override; diff --git a/plugins/Import/src/textjson.cpp b/plugins/Import/src/textjson.cpp index d419807ac0..540a414e32 100644 --- a/plugins/Import/src/textjson.cpp +++ b/plugins/Import/src/textjson.cpp @@ -156,23 +156,10 @@ public: } if (dbei->eventType == EVENTTYPE_FILE) { - std::string szFile = (*node)["file"].as_string(); - std::string szDescr = (*node)["descr"].as_string(); - dbei->flags |= DBEF_UTF; - MBinBuffer buf; - uint32_t tmp = 0; - buf.append(&tmp, sizeof(tmp)); - buf.append(szFile.c_str(), szFile.size()); - if (!szDescr.empty()) { - buf.append(&tmp, 1); - buf.append(szDescr.c_str(), szDescr.size()); - } - buf.append(&tmp, 1); - dbei->cbBlob = (int)buf.length(); - dbei->pBlob = (uint8_t*)mir_alloc(dbei->cbBlob); - memcpy(dbei->pBlob, buf.data(), buf.length()); + DB::FILE_BLOB blob((*node)["file"].as_mstring(), (*node)["descr"].as_mstring()); + blob.write(*(DB::EventInfo*)dbei); } else { std::string szBody = (*node)["body"].as_string(); @@ -180,7 +167,6 @@ public: int offset; switch (dbei->eventType) { case EVENTTYPE_ADDED: - case EVENTTYPE_FILE: offset = sizeof(uint32_t); break; -- cgit v1.2.3