diff options
-rw-r--r-- | protocols/Skype/docs/todo_list.txt | 1 | ||||
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skype_profile.cpp | 3 | ||||
-rw-r--r-- | protocols/Skype/src/skype_services.cpp | 50 |
4 files changed, 41 insertions, 15 deletions
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;
}
|