diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-09-23 08:02:18 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-09-23 08:02:18 +0000 |
commit | 08e2cef3aec75f8f913e6e1bab6b2a9b622ed640 (patch) | |
tree | 63be0a6159b1fb87b3ef2b30fa9c36a0173bf27e /protocols/VKontakte/src | |
parent | e214ccaf1647ba22768a5eeb08db038f957bb94a (diff) |
VKontakte: fix for loading contact avatars
git-svn-id: http://svn.miranda-ng.org/main/trunk@10562 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r-- | protocols/VKontakte/src/vk_avatars.cpp | 12 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 10 |
3 files changed, 19 insertions, 4 deletions
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)
|