diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2013-04-13 17:31:27 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2013-04-13 17:31:27 +0000 |
commit | fac653bb24ce1ab2786e4502419532d276f741fc (patch) | |
tree | 2a77dea67113d708d86778b1f3c0cc10bdaa723d /protocols/Skype | |
parent | f371b89aaeab7bc60dc19e428c3a494edd370812 (diff) |
- fixed avatar get (loading from skype server)
git-svn-id: http://svn.miranda-ng.org/main/trunk@4442 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype')
-rw-r--r-- | protocols/Skype/src/skype_profile.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp index 360aa8eb75..c7ecd37e5d 100644 --- a/protocols/Skype/src/skype_profile.cpp +++ b/protocols/Skype/src/skype_profile.cpp @@ -9,27 +9,38 @@ void CSkypeProto::UpdateProfileAvatar(SEObject *obj, HANDLE hContact) SEBinary data = obj->GetBinProp(/* *::P_AVATAR_IMAGE */ 37);
//if ((newTS > oldTS) || (!newTS && data.size() > 0 && _waccess(path, 0) == -1) || (newTS && _waccess(path, 0) == -1)) //hack for avatars without timestamp
- if ((newTS > oldTS) || (!::PathFileExists(path)))
+ bool hasNewAvatar = newTS > oldTS;
+ bool isAvatarEmpty = data.size() == 0;
+ bool isAvatarFileExists = ::PathFileExists(path);
+ if ( !isAvatarEmpty)
{
- FILE* fp = _wfopen(path, L"wb");
- if (fp)
+ if (hasNewAvatar || !isAvatarFileExists)
{
- fwrite(data.data(), sizeof(char), data.size(), fp);
- fclose(fp);
+ FILE* fp = ::_wfopen(path, L"wb");
+ if (fp)
+ {
+ ::fwrite(data.data(), sizeof(char), data.size(), fp);
+ ::fclose(fp);
- this->SetSettingDword("AvatarTS", newTS);
+ this->SetSettingDword("AvatarTS", newTS);
- PROTO_AVATAR_INFORMATIONW pai = {0};
- pai.cbSize = sizeof(pai);
- pai.format = PA_FORMAT_JPEG;
- pai.hContact = hContact;
- wcscpy(pai.filename, path);
+ PROTO_AVATAR_INFORMATIONW pai = {0};
+ pai.cbSize = sizeof(pai);
+ pai.format = PA_FORMAT_JPEG;
+ pai.hContact = hContact;
+ ::wcscpy(pai.filename, path);
- this->SendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0);
+ this->SendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0);
+ }
}
}
+ else if (isAvatarFileExists)
+ {
+ ::_wremove(path);
+ this->SendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, 0);
+ }
- delete path;
+ delete [] path;
}
void CSkypeProto::UpdateProfileAboutText(SEObject *obj, HANDLE hContact)
@@ -280,6 +291,7 @@ void CSkypeProto::UpdateProfile(SEObject *obj, HANDLE hContact) uint newTS = obj->GetUintProp(/* *::P_PROFILE_TIMESTAMP */ 19);
if (newTS > this->GetSettingDword("ProfileTS"))
{
+ this->UpdateProfileAvatar(obj, hContact);
this->UpdateProfileAboutText(obj, hContact);
this->UpdateProfileBirthday(obj, hContact);
this->UpdateProfileCity(obj, hContact);
|