From 5560fccb85a89bb668a79eed3d4cd0e668278331 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 20 Apr 2013 10:14:05 +0000 Subject: - temporary commit. may contain non-working code git-svn-id: http://svn.miranda-ng.org/main/trunk@4480 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_services.cpp | 46 ++++++++-------------------------- 1 file changed, 10 insertions(+), 36 deletions(-) (limited to 'protocols/Skype/src/skype_services.cpp') diff --git a/protocols/Skype/src/skype_services.cpp b/protocols/Skype/src/skype_services.cpp index 509b3e422e..9b97771d6d 100644 --- a/protocols/Skype/src/skype_services.cpp +++ b/protocols/Skype/src/skype_services.cpp @@ -104,54 +104,28 @@ INT_PTR __cdecl CSkypeProto::SetMyAvatar(WPARAM, LPARAM lParam) return iRet; } - int len; - char *buffer; - FILE* fp = ::_wfopen(avatarPath, L"rb"); - if (!fp) + SEBinary avatar = this->GetAvatarBinary(avatarPath); + if (avatar.size() == 0) { - this->Log(L"Failed to read avatar in local storage."); + this->Log(L"Failed to read avatar file."); return iRet; } - ::fseek(fp, 0, SEEK_END); - len = ::ftell(fp); - ::fseek(fp, 0, SEEK_SET); - buffer = new char[len + 1]; - ::fread(buffer, len, 1, fp); - ::fclose(fp); - - ::mir_md5_byte_t digest[16]; - ::mir_md5_hash((BYTE*)buffer, len, digest); - - DBVARIANT dbv; - ::db_get(NULL, this->m_szModuleName, "AvatarHash", &dbv); - if (dbv.type == DBVT_BLOB && dbv.pbVal && dbv.cpbVal == 16) + + if (!this->IsAvatarChanged(avatar)) { - if (::memcmp(digest, dbv.pbVal, 16) == 0) - { - ::db_free(&dbv); - delete [] buffer; - return 0; - } + this->Log(L"New avatar are same with old."); + return iRet; } - ::db_free(&dbv); - int fbl; - SEBinary avatar(buffer, len); Skype::VALIDATERESULT result = Skype::NOT_VALIDATED; - if (!this->skype->ValidateAvatar(avatar, result, fbl) || result != Skype::VALIDATED_OK) + if (!this->account->SetAvatar(avatar, result)) { this->Log(CSkypeProto::ValidationReasons[result]); return iRet; } - if (!this->account->SetBinProperty(Account::P_AVATAR_IMAGE, avatar)) - { - this->Log(L"Failed to send avatar on server."); - return iRet; - } - - delete [] buffer; - this->SetSettingDword("AvatarTS", time(NULL)); + uint newTS = this->account->GetUintProp(/* *::P_AVATAR_TIMESTAMP */ 182); + this->SetSettingDword("AvatarTS", newTS); iRet = 0; } else -- cgit v1.2.3