summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_contacts.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-12-04 06:53:31 +0000
committerRobert Pösel <robyer@seznam.cz>2014-12-04 06:53:31 +0000
commit355f69d42075967db7f51081f9520fed3ea9a801 (patch)
tree40c96765e2c187cc0ccd13fd112f813f5f156f6d /protocols/Steam/src/steam_contacts.cpp
parent2c53355b27f4a44f2109f9a045d2f9e40cb06216 (diff)
Steam: Reworked avatars support; version bump
This result in downloading avatars only when changed and not at every login git-svn-id: http://svn.miranda-ng.org/main/trunk@11236 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src/steam_contacts.cpp')
-rw-r--r--protocols/Steam/src/steam_contacts.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index 7354fa3395..8116588f0a 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -94,13 +94,8 @@ void CSteamProto::UpdateContact(MCONTACT hContact, JSONNODE *data)
// avatar
node = json_get(data, "avatarfull");
- ptrA avatarUrl(mir_u2a(json_as_string(node)));
- setString(hContact, "AvatarUrl", avatarUrl);
-
- PushRequest(
- new SteamWebApi::GetAvatarRequest(avatarUrl),
- &CSteamProto::OnGotAvatar,
- (void*)hContact);
+ std::string avatarUrl = _T2A(json_as_string(node));
+ CheckAvatarChange(hContact, avatarUrl);
// set country
node = json_get(data, "loccountrycode");
@@ -317,28 +312,30 @@ void CSteamProto::OnGotUserSummaries(const NETLIBHTTPREQUEST *response, void *ar
void CSteamProto::OnGotAvatar(const NETLIBHTTPREQUEST *response, void *arg)
{
- MCONTACT hContact = (MCONTACT)arg;
+ PROTO_AVATAR_INFORMATIONW pai = { sizeof(pai) };
+ pai.hContact = (MCONTACT)arg;
+ GetDbAvatarInfo(pai);
if (response == NULL || response->resultCode != HTTP_STATUS_OK)
{
- ptrA steamId(getStringA(hContact, "SteamID"));
+ ptrA steamId(getStringA(pai.hContact, "SteamID"));
debugLogA("CSteamProto::OnGotAvatar: failed to get avatar %s", steamId);
+
+ if (pai.hContact)
+ ProtoBroadcastAck(pai.hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&pai, 0);
return;
}
- ptrW avatarPath(GetAvatarFilePath(hContact));
- FILE *fp = _wfopen(avatarPath, L"wb");
+ FILE *fp = _tfopen(pai.filename, _T("wb"));
if (fp)
{
fwrite(response->pData, sizeof(char), response->dataLength, fp);
fclose(fp);
- PROTO_AVATAR_INFORMATIONW pai = { sizeof(pai) };
- pai.format = PA_FORMAT_JPEG;
- pai.hContact = hContact;
- wcscpy(pai.filename, avatarPath);
-
- ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0);
+ if (pai.hContact)
+ ProtoBroadcastAck(pai.hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0);
+ else
+ CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)m_szModuleName, 0);
}
}