From 51b5164fd6c0ea0de58e4398e515dd73a0e12620 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 13 Apr 2013 19:59:11 +0000 Subject: - fix some own avatar get/set bugs git-svn-id: http://svn.miranda-ng.org/main/trunk@4449 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_services.cpp | 39 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 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 3b03b13807..509b3e422e 100644 --- a/protocols/Skype/src/skype_services.cpp +++ b/protocols/Skype/src/skype_services.cpp @@ -80,14 +80,13 @@ INT_PTR __cdecl CSkypeProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) if (!wParam) return -2; wchar_t *path = this->GetContactAvatarFilePath(NULL); - if (path && !_waccess(path, 0)) + if (path && ::PathFileExists(path)) { ::wcsncpy((wchar_t *)wParam, path, (int)lParam); delete path; return 0; } - delete path; return -1; } @@ -98,14 +97,6 @@ INT_PTR __cdecl CSkypeProto::SetMyAvatar(WPARAM, LPARAM lParam) if (path) { - /*int dwPaFormat = CSkypeProto::DetectAvatarFormat(path); - if (dwPaFormat != PA_FORMAT_XML) - { - HBITMAP avt = (HBITMAP)::CallService(MS_UTILS_LOADBITMAPT, 0, (WPARAM)path); - if (!avt) return iRet; - ::DeleteObject(avt); - }*/ - wchar_t *avatarPath = this->GetContactAvatarFilePath(NULL); if (::wcscmp(path, avatarPath) && !::CopyFile(path, avatarPath, FALSE)) { @@ -115,18 +106,34 @@ INT_PTR __cdecl CSkypeProto::SetMyAvatar(WPARAM, LPARAM lParam) int len; char *buffer; - FILE* fp = _wfopen(avatarPath, L"rb"); + FILE* fp = ::_wfopen(avatarPath, L"rb"); if (!fp) { this->Log(L"Failed to read avatar in local storage."); return iRet; } - fseek(fp, 0, SEEK_END); - len = ftell(fp); - fseek(fp, 0, SEEK_SET); + ::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); + ::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 (::memcmp(digest, dbv.pbVal, 16) == 0) + { + ::db_free(&dbv); + delete [] buffer; + return 0; + } + } + ::db_free(&dbv); int fbl; SEBinary avatar(buffer, len); -- cgit v1.2.3