From 002cab8875c415238cdcc74276872bb33f8523e1 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 13 Apr 2013 16:54:06 +0000 Subject: - fixed avatar set (loading on skype server) - fixed search by name git-svn-id: http://svn.miranda-ng.org/main/trunk@4439 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/docs/todo_list.txt | 1 - protocols/Skype/src/skype_contacts.cpp | 2 +- protocols/Skype/src/skype_profile.cpp | 3 +- protocols/Skype/src/skype_services.cpp | 50 ++++++++++++++++++++++++++-------- 4 files changed, 41 insertions(+), 15 deletions(-) (limited to 'protocols') diff --git a/protocols/Skype/docs/todo_list.txt b/protocols/Skype/docs/todo_list.txt index bf6823bd9c..d14e0d4651 100644 --- a/protocols/Skype/docs/todo_list.txt +++ b/protocols/Skype/docs/todo_list.txt @@ -1,5 +1,4 @@ Features: -- add avatar loading to skype server - add correct own info - multiuser chat - voice diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index acfa6a56e6..0ed653c7e6 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -468,7 +468,7 @@ void CSkypeProto::OnContactFinded(HANDLE hSearch, CContact::Ref contact) void __cdecl CSkypeProto::SearchBySidAsync(void* arg) { - const char *sid = (char *)arg; + const char *sid = ::mir_u2a((wchar_t*)arg); HANDLE hContact = this->GetContactBySid(sid); if (hContact) diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp index 081f8b22dc..360aa8eb75 100644 --- a/protocols/Skype/src/skype_profile.cpp +++ b/protocols/Skype/src/skype_profile.cpp @@ -8,7 +8,8 @@ void CSkypeProto::UpdateProfileAvatar(SEObject *obj, HANDLE hContact) wchar_t *path = this->GetContactAvatarFilePath(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) || (!newTS && data.size() > 0 && _waccess(path, 0) == -1) || (newTS && _waccess(path, 0) == -1)) //hack for avatars without timestamp + if ((newTS > oldTS) || (!::PathFileExists(path))) { FILE* fp = _wfopen(path, L"wb"); if (fp) diff --git a/protocols/Skype/src/skype_services.cpp b/protocols/Skype/src/skype_services.cpp index 9fae8d0ee0..3b03b13807 100644 --- a/protocols/Skype/src/skype_services.cpp +++ b/protocols/Skype/src/skype_services.cpp @@ -48,21 +48,20 @@ INT_PTR __cdecl CSkypeProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam) break; case AF_PROPORTION: - return PIP_SQUARE; + return PIP_NONE; case AF_FORMATSUPPORTED: - if (lParam == PA_FORMAT_JPEG) - return 1; + return lParam == PA_FORMAT_JPEG; case AF_ENABLED: return 1; case AF_DONTNEEDDELAYS: - break; + return 1; case AF_MAXFILESIZE: - // server accepts images of 7168 bytees, not bigger - return 7168; + // server accepts images of 32000 bytees, not bigger + return 32000; case AF_DELAYAFTERFAIL: // do not request avatar again if server gave an error @@ -99,13 +98,13 @@ INT_PTR __cdecl CSkypeProto::SetMyAvatar(WPARAM, LPARAM lParam) if (path) { - int dwPaFormat = CSkypeProto::DetectAvatarFormat(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)) @@ -113,17 +112,44 @@ INT_PTR __cdecl CSkypeProto::SetMyAvatar(WPARAM, LPARAM lParam) this->Log(L"Failed to copy our avatar to local storage."); return iRet; } - // need to validate avatar Skype::ValidateAvatar - //this->account->SetBinProperty(Account::P_AVATAR_IMAGE, avt); + + int len; + char *buffer; + 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); + buffer = new char[len + 1]; + fread(buffer, len, 1, fp); + fclose(fp); + + int fbl; + SEBinary avatar(buffer, len); + Skype::VALIDATERESULT result = Skype::NOT_VALIDATED; + if (!this->skype->ValidateAvatar(avatar, result, fbl) || result != Skype::VALIDATED_OK) + { + 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; + } - // todo: add avatar loading to skype server + delete [] buffer; this->SetSettingDword("AvatarTS", time(NULL)); iRet = 0; } else { - // todo: avatar deletig + this->account->SetBinProperty(Account::P_AVATAR_IMAGE, SEBinary()); this->DeleteSetting("AvatarTS"); iRet = 0; } -- cgit v1.2.3