summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_avatars.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-10-10 17:02:14 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-10-10 17:02:14 +0000
commitec0297e13b1a994384254abc87d3ed9f42edcf99 (patch)
treeb3c78db0e64c629148740a4c2e6b00bde5e0fc01 /protocols/SkypeWeb/src/skype_avatars.cpp
parent7177cd4cc38bb73338631381b802a7f7f6845f62 (diff)
SkypeWeb: correct mimetype in avatar request
git-svn-id: http://svn.miranda-ng.org/main/trunk@15530 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_avatars.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_avatars.cpp63
1 files changed, 30 insertions, 33 deletions
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<BYTE> 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
{