summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-08 09:25:41 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-08 09:25:41 +0000
commita458170ae1bf6f6d8ec56a1e3ce04a7d1b5db2a7 (patch)
tree51e1a6a2d24aabf923d5b3730eb544c3b86f610f /protocols
parent5832f4823b326d02cc873cd4be8cf5361e36a0d5 (diff)
VK: fix to choose maximum photo size available
git-svn-id: http://svn.miranda-ng.org/main/trunk@7539 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index fdcfa44742..f4acb24a5e 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -392,6 +392,8 @@ void CVkProto::RetrieveUnreadMessages()
PushAsyncHttpRequest(REQUEST_GET, "/method/messages.get.json", true, &CVkProto::OnReceiveMessages, SIZEOF(params), params);
}
+static char* szImageTypes[] = { "src_xxxbig", "src_xxbig", "src_xbig", "src_big", "src", "src_small" };
+
void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
debugLogA("CVkProto::OnReceiveMessages %d", reply->resultCode);
@@ -441,17 +443,21 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
tszBody += TranslateT("Attachments:");
tszBody.AppendChar('\n');
JSONNODE *pAttach;
- for (int k=0; (pAttach = json_at(pAttachments, k)) != NULL; k++) {
+ for (int k = 0; (pAttach = json_at(pAttachments, k)) != NULL; k++) {
tszBody.AppendChar('\t');
ptrT ptszType(json_as_string(json_get(pAttach, "type")));
- if ( !lstrcmp(ptszType, _T("photo"))) {
+ if (!lstrcmp(ptszType, _T("photo"))) {
JSONNODE *pPhoto = json_get(pAttach, "photo");
if (pPhoto == NULL) continue;
- ptrT ptszLink( json_as_string( json_get(pPhoto, "src_big")));
- int iWidth = json_as_int( json_get(pPhoto, "width"));
- int iHeight = json_as_int( json_get(pPhoto, "height"));
- tszBody.AppendFormat( _T("%s: %s (%dx%d)"), TranslateT("Photo"), ptszLink, iWidth, iHeight);
+ ptrT ptszLink;
+ for (int i = 0; i < SIZEOF(szImageTypes); i++)
+ if ((ptszLink = json_as_string(json_get(pPhoto, szImageTypes[i]))) != NULL)
+ break;
+
+ int iWidth = json_as_int(json_get(pPhoto, "width"));
+ 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");
@@ -484,7 +490,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
TranslateT("Document"), ptszTitle, ptszUrl);
}
else tszBody.AppendFormat(TranslateT("Unsupported or unknown attachment type: %s"), ptszType);
-
+
tszBody.AppendChar('\n');
}
ptszBody = mir_tstrdup(tszBody);