From 46d6a43726d64a0d7f808ad55557bfc56b89f97d Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Wed, 13 Jul 2016 08:25:04 +0000 Subject: =?UTF-8?q?VKontakte:=20add=20=E2=80=98Send=20VK-objects=20links?= =?UTF-8?q?=20as=20attachments=E2=80=99=20option=20move=20=E2=80=98Use=20n?= =?UTF-8?q?on-standard=20popups=20for=20news=20and=20event=20notifications?= =?UTF-8?q?=E2=80=99=20option=20to=20View=20page=20version=20bump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.miranda-ng.org/main/trunk@17090 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/misc.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'protocols/VKontakte/src/misc.cpp') diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 1996ad9bdd..34ee94993d 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -21,6 +21,9 @@ static const char *szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", " static const char *szGiftTypes[] = { "thumb_256", "thumb_96", "thumb_48" }; +static const char *szVKUrls[] = { "http://vk.com/", "https://vk.com/", "http://new.vk.com/", "https://new.vk.com/", "http://m.vk.com/", "https://m.vk.com/" }; +static const char *szAttachmentMasks[] = { "wall%d_%d", "video%d_%d", "photo%d_%d", "audio%d_%d", "doc%d_%d", "market%d_%d" }; + JSONNode nullNode(JSON_NULL); bool IsEmpty(LPCTSTR str) @@ -733,6 +736,43 @@ char* CVkProto::GetStickerId(const char *Msg, int &stickerid) return retMsg; } +CMStringA CVkProto::GetAttachmentsFromMessage(const char *Msg) +{ + if (IsEmpty(Msg)) + return CMStringA(); + + const char *pos = NULL; + for (int i = 0; i < _countof(szVKUrls) && !pos; i++) { + pos = strstr(Msg, szVKUrls[i]); + if (pos) { + pos += mir_strlen(szVKUrls[i]); + break; + } + } + + if (!pos || pos >= (Msg + mir_strlen(Msg))) + return CMStringA(); + + int iRes = 0, + iOwner = 0, + iId = 0; + + for (int i = 0; i < _countof(szAttachmentMasks); i++) { + iRes = sscanf(pos, szAttachmentMasks[i], &iOwner, &iId); + if (iRes == 2) { + CMStringA szAttacment(FORMAT, szAttachmentMasks[i], iOwner, iId); + CMStringA szAttacment2 = GetAttachmentsFromMessage(pos + szAttacment.GetLength()); + if (!szAttacment2.IsEmpty()) + szAttacment += "," + szAttacment2; + return szAttacment; + } + else if (iRes == 1) + break; + } + + return GetAttachmentsFromMessage(pos); +} + int CVkProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; -- cgit v1.2.3