diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2013-04-20 10:14:05 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2013-04-20 10:14:05 +0000 |
commit | 5560fccb85a89bb668a79eed3d4cd0e668278331 (patch) | |
tree | a8c5949d9cc473c51af2712bb79c306f4a531932 /protocols/Skype/src/skype_services.cpp | |
parent | 5a5ffa5cc195669c48827e4cf9d948dfb3272e47 (diff) |
- temporary commit. may contain non-working code
git-svn-id: http://svn.miranda-ng.org/main/trunk@4480 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src/skype_services.cpp')
-rw-r--r-- | protocols/Skype/src/skype_services.cpp | 46 |
1 files changed, 10 insertions, 36 deletions
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
|