From 61a5c4d8513e2cfdac47aca258f21665f6ec5cf7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 7 Jan 2014 13:56:53 +0000 Subject: VK: attacment types detection (fixes #541) git-svn-id: http://svn.miranda-ng.org/main/trunk@7533 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_thread.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'protocols/VKontakte/src') 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); -- cgit v1.2.3