From a83cc7cff781359710f0b41d037ebcec7757fdac Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Fri, 21 Sep 2018 10:57:30 +0500 Subject: VKontakte: version bump adapt GetMessageFromDb using db_event_getById --- protocols/VKontakte/src/misc.cpp | 38 +++++++++++---------------------- protocols/VKontakte/src/version.h | 4 ++-- protocols/VKontakte/src/vk_messages.cpp | 2 +- protocols/VKontakte/src/vk_proto.h | 4 ++-- 4 files changed, 17 insertions(+), 31 deletions(-) diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 1b32b50932..34b3f17614 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -1539,39 +1539,25 @@ void CVkProto::AddVkDeactivateEvent(MCONTACT hContact, CMStringW& wszType) db_event_add(hContact, &dbei); } -MEVENT CVkProto::GetMessageFromDb(MCONTACT hContact, const char *messageId, UINT ×tamp, CMStringW &msg) +MEVENT CVkProto::GetMessageFromDb(const char *messageId, UINT ×tamp, CMStringW &msg) { if (messageId == nullptr) return 0; - size_t messageIdLength = mir_strlen(messageId); - - for (MEVENT hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent)) { - DBEVENTINFO dbei = {}; - dbei.cbBlob = db_event_getBlobSize(hDbEvent); - - if (dbei.cbBlob < messageIdLength) - continue; - - mir_ptr blob((PBYTE)mir_alloc(dbei.cbBlob)); - dbei.pBlob = blob; - db_event_get(hDbEvent, &dbei); - - size_t cbLen = mir_strlen((char*)dbei.pBlob); - if ((dbei.eventType != EVENTTYPE_MESSAGE) || (cbLen + messageIdLength + 1 > dbei.cbBlob)) - continue; + MEVENT hDbEvent = db_event_getById(m_szModuleName, messageId); + if (!hDbEvent) + return 0; - if (memcmp(&dbei.pBlob[cbLen + 1], messageId, messageIdLength) == 0) { - msg = ptrW(mir_utf8decodeW((char*)dbei.pBlob)); - timestamp = dbei.timestamp; - return hDbEvent; - } + DBEVENTINFO dbei = {}; + dbei.cbBlob = db_event_getBlobSize(hDbEvent); + mir_ptr blob((PBYTE)mir_alloc(dbei.cbBlob)); + dbei.pBlob = blob; + db_event_get(hDbEvent, &dbei); - if (dbei.timestamp < timestamp) - break; - } + msg = ptrW(mir_utf8decodeW((char*)dbei.pBlob)); + timestamp = dbei.timestamp; - return 0; + return hDbEvent; } int CVkProto::DeleteContact(MCONTACT hContact) diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index a566618bc3..d8744cb847 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 -#define __RELEASE_NUM 5 -#define __BUILD_NUM 2 +#define __RELEASE_NUM 6 +#define __BUILD_NUM 0 #include diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 4e45bf7c3b..97d4c3418e 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -323,7 +323,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe wszBody; CMStringW wszOldMsg; - MEVENT hDbEvent = GetMessageFromDb(hContact, szMid, datetime, wszOldMsg); + MEVENT hDbEvent = GetMessageFromDb(szMid, datetime, wszOldMsg); if (hDbEvent) { wszBody += SetBBCString(TranslateT("\nOriginal message:\n"), m_vkOptions.BBCForAttachments(), vkbbcB) + wszOldMsg; diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index b0f82112f0..2a3542b6a7 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -65,7 +65,7 @@ struct CVkProto : public PROTO HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles) override; int SetStatus(int iNewStatus) override; int UserIsTyping(MCONTACT hContact, int type) override; - + void OnContactDeleted(MCONTACT) override; void OnModulesLoaded() override; void OnShutdown() override; @@ -358,7 +358,7 @@ private: void SetInvisible(MCONTACT hContact); CMStringW RemoveBBC(CMStringW& wszSrc); void AddVkDeactivateEvent(MCONTACT hContact, CMStringW & wszType); - MEVENT GetMessageFromDb(MCONTACT hContact, const char * messageId, UINT ×tamp, CMStringW &msg); + MEVENT GetMessageFromDb(const char * messageId, UINT ×tamp, CMStringW &msg); int DeleteContact(MCONTACT hContact); void InitQueue(); void UninitQueue(); -- cgit v1.2.3