summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-07 13:56:53 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-07 13:56:53 +0000
commit61a5c4d8513e2cfdac47aca258f21665f6ec5cf7 (patch)
treeefdbe7f7e3c882a97cdfcb76009fe1c157c76652 /protocols
parent5f6bd397c41eaddf74debb7c7c59f3fd73fabc4b (diff)
VK: attacment types detection (fixes #541)
git-svn-id: http://svn.miranda-ng.org/main/trunk@7533 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 8c624d95d8..33a449ce95 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -442,7 +442,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
JSONNODE *pAttach;
for (int k=0; (pAttach = json_at(pAttachments, k)) != NULL; k++) {
tszBody.AppendChar('\t');
- ptrT ptszType( json_as_string( json_get(pAttach, "type")));
+ ptrT ptszType(json_as_string(json_get(pAttach, "type")));
if ( !lstrcmp(ptszType, _T("photo"))) {
JSONNODE *pPhoto = json_get(pAttach, "photo");
if (pPhoto == NULL) continue;
@@ -452,6 +452,38 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
int iHeight = json_as_int( json_get(pPhoto, "height"));
tszBody.AppendFormat( _T("%s: %s (%dx%d)"), TranslateT("Photo"), ptszLink, iWidth, iHeight);
}
+ else if (!lstrcmp(ptszType, _T("audio"))) {
+ JSONNODE *pAudio = json_get(pAttach, "audio");
+ if (pAudio == NULL) continue;
+
+ int aid = json_as_int(json_get(pAudio, "aid"));
+ int ownerID = json_as_int(json_get(pAudio, "owner_id"));
+ ptrT ptszArtist(json_as_string(json_get(pAudio, "artist")));
+ ptrT ptszTitle(json_as_string(json_get(pAudio, "title")));
+ tszBody.AppendFormat(_T("%s: (%s - %s) - http://%S/audio%d_%d"),
+ TranslateT("Audio"), ptszArtist, ptszTitle, m_baseDomain, ownerID, aid);
+ }
+ else if (!lstrcmp(ptszType, _T("video"))) {
+ JSONNODE *pVideo = json_get(pAttach, "video");
+ if (pVideo == NULL) continue;
+
+ ptrT ptszTitle(json_as_string(json_get(pVideo, "title")));
+ int vid = json_as_int(json_get(pVideo, "vid"));
+ int ownerID = json_as_int(json_get(pVideo, "owner_id"));
+ tszBody.AppendFormat(_T("%s: %s - http://%S/video%d_%d"),
+ TranslateT("Video"), ptszTitle, m_baseDomain, ownerID, vid);
+ }
+ else if (!lstrcmp(ptszType, _T("doc"))) {
+ JSONNODE *pDoc = json_get(pAttach, "doc");
+ if (pDoc == NULL) continue;
+
+ ptrT ptszTitle(json_as_string(json_get(pDoc, "title")));
+ ptrT ptszUrl(json_as_string(json_get(pDoc, "url")));
+ tszBody.AppendFormat(_T("%s: (%s) - %s"),
+ TranslateT("Document"), ptszTitle, ptszUrl);
+ }
+ else tszBody.AppendFormat(TranslateT("Unsupported or unknown attachment type: %s"), ptszType);
+
tszBody.AppendChar('\n');
}
ptszBody = mir_tstrdup(tszBody);