From 08e2cef3aec75f8f913e6e1bab6b2a9b622ed640 Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Tue, 23 Sep 2014 08:02:18 +0000 Subject: VKontakte: fix for loading contact avatars git-svn-id: http://svn.miranda-ng.org/main/trunk@10562 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_avatars.cpp | 12 ++++++++++-- protocols/VKontakte/src/vk_proto.h | 1 + protocols/VKontakte/src/vk_thread.cpp | 10 ++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'protocols/VKontakte/src') diff --git a/protocols/VKontakte/src/vk_avatars.cpp b/protocols/VKontakte/src/vk_avatars.cpp index a2c1923a1e..c69fab2f32 100644 --- a/protocols/VKontakte/src/vk_avatars.cpp +++ b/protocols/VKontakte/src/vk_avatars.cpp @@ -34,6 +34,7 @@ void CVkProto::OnReceiveAvatar(NETLIBHTTPREQUEST *reply, AsyncHttpRequest* pReq) fwrite(reply->pData, 1, reply->dataLength, out); fclose(out); + setByte((MCONTACT)pReq->pUserInfo, "NeedNewAvatar", 0); ProtoBroadcastAck((MCONTACT)pReq->pUserInfo, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &AI, 0); } @@ -59,6 +60,13 @@ INT_PTR CVkProto::SvcGetAvatarCaps(WPARAM wParam, LPARAM lParam) return 0; } +void CVkProto::ReloadAvatarInfo(MCONTACT hContact) +{ + PROTO_AVATAR_INFORMATIONT AI = { sizeof(AI) }; + AI.hContact = hContact; + SvcGetAvatarInfo(0, (LPARAM)&AI); +} + INT_PTR CVkProto::SvcGetAvatarInfo(WPARAM wParam, LPARAM lParam) { PROTO_AVATAR_INFORMATIONT* AI = (PROTO_AVATAR_INFORMATIONT*)lParam; @@ -73,7 +81,7 @@ INT_PTR CVkProto::SvcGetAvatarInfo(WPARAM wParam, LPARAM lParam) AI->format = ProtoGetAvatarFormat(AI->filename); - if (::_taccess(AI->filename, 0) == 0) + if ((::_taccess(AI->filename, 0) == 0) && !getBool(AI->hContact, "NeedNewAvatar", 0)) return GAIR_SUCCESS; if ( IsOnline()) { @@ -128,7 +136,7 @@ void CVkProto::SetAvatarUrl(MCONTACT hContact, LPCTSTR ptszUrl) } else { setTString(hContact, "AvatarUrl", ptszUrl); - + setByte(hContact,"NeedNewAvatar", 1); PROTO_AVATAR_INFORMATIONT AI = { sizeof(AI) }; AI.hContact = hContact; GetAvatarFileName(AI.hContact, AI.filename, SIZEOF(AI.filename)); diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index e206287497..4f36c7e95c 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -312,6 +312,7 @@ private: void SetAvatarUrl(MCONTACT hContact, LPCTSTR ptszUrl); void GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, size_t cbLen); + void ReloadAvatarInfo(MCONTACT hContact); MCONTACT FindUser(LONG userid, bool bCreate = false); diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 3259b53eca..0c059872d3 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -323,7 +323,10 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe } szValue = json_as_string( json_get(pRecord, "photo_100")); - SetAvatarUrl(hContact, szValue); + if (szValue && *szValue){ + SetAvatarUrl(hContact, szValue); + ReloadAvatarInfo(hContact); + } int iNewStatus = (json_as_int(json_get(pRecord, "online")) == 0) ? ID_STATUS_OFFLINE : ID_STATUS_ONLINE; if (getWord(hContact, "Status", 0) != iNewStatus) @@ -419,7 +422,10 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq setTString(hContact, "Nick", tszNick); szValue = json_as_string(json_get(pInfo, "photo_100")); - SetAvatarUrl(hContact, szValue); + if (szValue && *szValue){ + SetAvatarUrl(hContact, szValue); + ReloadAvatarInfo(hContact); + } int iNewStatus = (json_as_int(json_get(pInfo, "online")) == 0) ? ID_STATUS_OFFLINE : ID_STATUS_ONLINE; if (getWord(hContact, "Status", 0) != iNewStatus) -- cgit v1.2.3