summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/misc.cpp
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2017-12-18 15:35:14 +0500
committerElzorFox <elzorfox@ya.ru>2017-12-18 15:35:29 +0500
commita1e85579f746d778c874cf083d154caa09965eea (patch)
treec5ac919e8f58b1255142a0788091cf191a97b82f /protocols/VKontakte/src/misc.cpp
parente41d801d1c41d51c6f220ab457eaa78bbcbb51ac (diff)
VKontakte:
add edited message support (only from vk to miranda) update VK_API to 5.68 version bump
Diffstat (limited to 'protocols/VKontakte/src/misc.cpp')
-rw-r--r--protocols/VKontakte/src/misc.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 67c1ff428a..27a8a8a8a2 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -343,6 +343,9 @@ bool CVkProto::CheckJsonResult(AsyncHttpRequest *pReq, const JSONNode &jnNode)
case VKERR_CANT_SEND_YOU_ON_BLACKLIST:
MsgPopup(TranslateT("Can't send messages to this user due to their privacy settings"), TranslateT("Error"), true);
break;
+ case VKERR_MESSAGE_IS_TOO_LONG:
+ MsgPopup(TranslateT("Message is too long"), TranslateT("Error"), true);
+ break;
case VKERR_COULD_NOT_SAVE_FILE:
case VKERR_INVALID_ALBUM_ID:
case VKERR_INVALID_SERVER:
@@ -1515,6 +1518,41 @@ void CVkProto::AddVkDeactivateEvent(MCONTACT hContact, CMStringW& wszType)
db_event_add(hContact, &dbei);
}
+MEVENT CVkProto::GetMessageFromDb(MCONTACT hContact, const char *messageId, UINT &timestamp, 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<BYTE> 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;
+
+ if (memcmp(&dbei.pBlob[cbLen + 1], messageId, messageIdLength) == 0) {
+ msg = ptrW(mir_utf8decodeW((char*)dbei.pBlob));
+ timestamp = dbei.timestamp;
+ return hDbEvent;
+ }
+
+ if (dbei.timestamp < timestamp)
+ break;
+ }
+
+ return 0;
+}
+
int CVkProto::DeleteContact(MCONTACT hContact)
{
setByte(hContact, "SilentDelete", 1);