summaryrefslogtreecommitdiff
path: root/protocols/VKontakte
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-22 20:53:12 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-22 20:53:12 +0000
commit35a5290171ab6ae3c943af7c1fc21d99bae5242c (patch)
treed4c3da969dfb6a43735620c874d66173e4fa5ef3 /protocols/VKontakte
parent15836886c666aa27d0fe5254dd356fc616c6c919 (diff)
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
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_avatars.cpp20
-rw-r--r--protocols/VKontakte/src/vk_proto.h1
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp8
4 files changed, 26 insertions, 5 deletions
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);