From fac653bb24ce1ab2786e4502419532d276f741fc Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 13 Apr 2013 17:31:27 +0000 Subject: - fixed avatar get (loading from skype server) git-svn-id: http://svn.miranda-ng.org/main/trunk@4442 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_profile.cpp | 38 +++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'protocols/Skype/src/skype_profile.cpp') 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); -- cgit v1.2.3