From ec0297e13b1a994384254abc87d3ed9f42edcf99 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sat, 10 Oct 2015 17:02:14 +0000 Subject: SkypeWeb: correct mimetype in avatar request git-svn-id: http://svn.miranda-ng.org/main/trunk@15530 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_avatars.cpp | 63 +++++++++++++++----------------- 1 file changed, 30 insertions(+), 33 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_avatars.cpp') diff --git a/protocols/SkypeWeb/src/skype_avatars.cpp b/protocols/SkypeWeb/src/skype_avatars.cpp index b306a3d4a0..7622ad09e4 100644 --- a/protocols/SkypeWeb/src/skype_avatars.cpp +++ b/protocols/SkypeWeb/src/skype_avatars.cpp @@ -22,8 +22,8 @@ INT_PTR CSkypeProto::SvcGetAvatarCaps(WPARAM wParam, LPARAM lParam) switch (wParam) { case AF_MAXSIZE: - ((POINT*)lParam)->x = 150; - ((POINT*)lParam)->y = 150; + ((POINT*)lParam)->x = 98; + ((POINT*)lParam)->y = 98; return 0; case AF_MAXFILESIZE: @@ -171,39 +171,36 @@ INT_PTR CSkypeProto::SvcSetMyAvatar(WPARAM, LPARAM lParam) GetAvatarFileName(NULL, avatarPath, _countof(avatarPath)); if (path != NULL) { - if (!CopyFile(path, avatarPath, FALSE)) + if (CopyFile(path, avatarPath, FALSE)) { - debugLogA("CSkypeProto::SetMyAvatar: failed to copy new avatar to avatar cache"); - return -1; + FILE *hFile = _tfopen(path, L"rb"); + if (hFile) + { + fseek(hFile, 0, SEEK_END); + size_t length = ftell(hFile); + if (length != -1) + { + rewind(hFile); + + mir_ptr data((PBYTE)mir_alloc(length)); + + if (data != NULL && fread(data, sizeof(BYTE), length, hFile) == length) + { + FI_INTERFACE *fii = NULL; + const char *szMime = "image/jpeg"; + if (CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&fii) == S_OK && fii) + { + szMime = fii->FI_GetFIFMimeType(fii->FI_GetFIFFromFilenameU(path)); + } + + PushRequest(new SetAvatarRequest(data, length, szMime, li), &CSkypeProto::OnSentAvatar); + return 0; + } + } + fclose(hFile); + } } - - FILE *hFile = _tfopen(path, L"rb"); - if (!hFile) - { - debugLogA("CSkypeProto::SetMyAvatar: failed to open avatar file"); - return -1; - } - - fseek(hFile, 0, SEEK_END); - size_t length = ftell(hFile); - if (length == -1) - { - debugLogA("CSkypeProto::SvcSetMyAvatar: failed to get avatar file size"); - fclose(hFile); - return -1; - } - rewind(hFile); - - ptrA data((char*)mir_alloc(length)); - - if (data == NULL || fread(data, sizeof(char), length, hFile) != length) - { - debugLogA("CSkypeProto::SvcSetMyAvatar: failed to read avatar file"); - fclose(hFile); - return -1; - } - fclose(hFile); - PushRequest(new SetAvatarRequest(data, length, li), &CSkypeProto::OnSentAvatar); + return -1; } else { -- cgit v1.2.3