From 35a5290171ab6ae3c943af7c1fc21d99bae5242c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 22 Oct 2013 20:53:12 +0000 Subject: VK: fix for async avatars loading (especially for the case of avatars in clists) git-svn-id: http://svn.miranda-ng.org/main/trunk@6596 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk_avatars.cpp | 20 ++++++++++++++++++++ protocols/VKontakte/src/vk_proto.h | 1 + protocols/VKontakte/src/vk_thread.cpp | 8 ++++---- 4 files changed, 26 insertions(+), 5 deletions(-) (limited to 'protocols') diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 247b6da7f6..4ff3156678 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 0 -#define __BUILD_NUM 2 +#define __BUILD_NUM 3 #define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM diff --git a/protocols/VKontakte/src/vk_avatars.cpp b/protocols/VKontakte/src/vk_avatars.cpp index 3811ee9f64..59c9d5cbdb 100644 --- a/protocols/VKontakte/src/vk_avatars.cpp +++ b/protocols/VKontakte/src/vk_avatars.cpp @@ -113,3 +113,23 @@ void CVkProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbLen) mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%d%s"), id, szFileType); } +void CVkProto::SetAvatarUrl(HANDLE hContact, LPCTSTR ptszUrl) +{ + ptrT oldUrl( getTStringA(hContact, "AvatarUrl")); + if ( !lstrcmp(ptszUrl, oldUrl)) + return; + + if (ptszUrl == NULL) { + delSetting(hContact, "AvatarUrl"); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, 0); + } + else { + setTString(hContact, "AvatarUrl", ptszUrl); + + PROTO_AVATAR_INFORMATIONT AI = { sizeof(AI) }; + AI.hContact = hContact; + GetAvatarFileName(AI.hContact, AI.filename, SIZEOF(AI.filename)); + AI.format = ProtoGetAvatarFormat(AI.filename); + ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&AI, 0); + } +} diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 8e0860f479..e045147af7 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -169,6 +169,7 @@ private: void OnLoggedOut(); void ShutdownSession(); + void SetAvatarUrl(HANDLE hContact, LPCTSTR ptszUrl); void GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbLen); HANDLE FindUser(LONG userid, bool bCreate = false); diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 5dfabf3b08..1b73c38180 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -264,8 +264,8 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe } } - if (szValue = json_as_string( json_get(pRecord, "photo_medium"))) - setTString(hContact, "AvatarUrl", szValue); + szValue = json_as_string( json_get(pRecord, "photo_medium")); + SetAvatarUrl(hContact, szValue); } } @@ -317,8 +317,8 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq if ( !tszNick.IsEmpty()) setTString(hContact, "Nick", tszNick); - if (szValue = json_as_string( json_get(pInfo, "photo_medium"))) - setTString(hContact, "AvatarUrl", szValue); + szValue = json_as_string( json_get(pInfo, "photo_medium")); + SetAvatarUrl(hContact, szValue); setWord(hContact, "Status", (json_as_int( json_get(pInfo, "online")) == 0) ? ID_STATUS_OFFLINE : ID_STATUS_ONLINE); -- cgit v1.2.3