summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/misc.cpp
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2016-07-13 08:25:04 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2016-07-13 08:25:04 +0000
commit46d6a43726d64a0d7f808ad55557bfc56b89f97d (patch)
tree4fea102a4cf636196b8ae6f6da8cdd627a4d14fe /protocols/VKontakte/src/misc.cpp
parentffb9e28990704074a63fc87d1a92621727a4c951 (diff)
VKontakte:
add ‘Send VK-objects links as attachments’ option move ‘Use non-standard popups for news and event notifications’ option to View page version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@17090 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/misc.cpp')
-rw-r--r--protocols/VKontakte/src/misc.cpp40
1 files changed, 40 insertions, 0 deletions
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;