diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-07 12:38:38 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-07 12:38:38 +0000 |
commit | 00d6d7d71a015dfeb34e891f0ebe39a7795ea57f (patch) | |
tree | 5a2d7dffd187774d8509746321063cc2135bacc0 /protocols/SkypeWeb/src/skype_avatars.cpp | |
parent | 2f4737000403cf82d38ac098f77fd071a3f9c027 (diff) |
git-svn-id: http://svn.miranda-ng.org/main/trunk@12648 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_avatars.cpp')
-rw-r--r-- | protocols/SkypeWeb/src/skype_avatars.cpp | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/protocols/SkypeWeb/src/skype_avatars.cpp b/protocols/SkypeWeb/src/skype_avatars.cpp index bdc8e2e45a..caa9ac88e0 100644 --- a/protocols/SkypeWeb/src/skype_avatars.cpp +++ b/protocols/SkypeWeb/src/skype_avatars.cpp @@ -57,6 +57,16 @@ void CSkypeProto::OnReceiveAvatar(const NETLIBHTTPREQUEST *response, void *arg) ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &AI, 0);
}
+void CSkypeProto::OnSentAvatar(const NETLIBHTTPREQUEST *response)
+{
+ if (response == NULL)
+ return;
+
+ JSONROOT root(response->pData);
+ if (root == NULL)
+ return;
+}
+
INT_PTR CSkypeProto::SvcGetAvatarInfo(WPARAM, LPARAM lParam)
{
PROTO_AVATAR_INFORMATIONT* AI = (PROTO_AVATAR_INFORMATIONT*)lParam;
@@ -136,4 +146,58 @@ void CSkypeProto::SetAvatarUrl(MCONTACT hContact, CMString &tszUrl) AI.format = ProtoGetAvatarFormat(AI.filename);
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&AI, 0);
}
-}
\ No newline at end of file +}
+
+INT_PTR CSkypeProto::SvcSetMyAvatar(WPARAM wParam, LPARAM lParam)
+{
+ TCHAR *path = (TCHAR*)lParam;
+ TCHAR avatarPath[MAX_PATH];
+ GetAvatarFileName(NULL, avatarPath, SIZEOF(avatarPath));
+ if (path != NULL)
+ {
+ if (!CopyFile(path, avatarPath, FALSE))
+ {
+ debugLogA("CSkypeProto::SetMyAvatar: failed to copy new avatar to avatar cache");
+ return -1;
+ }
+
+ size_t length;
+ char *data;
+ FILE *hFile = _tfopen(path, L"rb");
+ if (!hFile)
+ {
+ debugLogA("CSkypeProto::SetMyAvatar: failed to open avatar file");
+ return -1;
+ }
+
+ fseek(hFile, 0, SEEK_END);
+ length = ftell(hFile);
+ rewind(hFile);
+
+ data = (char*)mir_alloc(length);
+ size_t read = fread(data, sizeof(char), length, hFile);
+ if (read != length)
+ {
+ fclose(hFile);
+ debugLogA("CToxProto::SetToxAvatar: failed to read avatar file");
+ return -1;
+ }
+ fclose(hFile);
+
+
+ ptrA token(getStringA("TokenSecret"));
+ ptrA skypename(getStringA("Skypename"));
+ PushRequest(new SetAvatarRequest(token, skypename, data), &CSkypeProto::OnSentAvatar);
+ }
+ else
+ {
+ if (IsFileExists(avatarPath))
+ {
+ DeleteFile(avatarPath);
+ }
+
+ //db_unset(NULL, m_szModuleName, TOX_SETTINGS_AVATAR_HASH);
+ }
+
+ return 0;
+}
|