From 7e78293fcbabc945a8a9e5bcaab121fbbf697c4c Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 7 May 2015 19:15:57 +0000 Subject: Tox: fixed avatar work git-svn-id: http://svn.miranda-ng.org/main/trunk@13480 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_avatars.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'protocols/Tox/src/tox_avatars.cpp') diff --git a/protocols/Tox/src/tox_avatars.cpp b/protocols/Tox/src/tox_avatars.cpp index cfab678533..5e9ddacef7 100644 --- a/protocols/Tox/src/tox_avatars.cpp +++ b/protocols/Tox/src/tox_avatars.cpp @@ -78,7 +78,7 @@ void CToxProto::SetToxAvatar(std::tstring path, bool checkHash) } TOX_ERR_FILE_SEND error; - uint32_t fileNumber = tox_file_send(tox, friendNumber, TOX_FILE_KIND_AVATAR, length, NULL, hash, TOX_HASH_LENGTH, &error); + uint32_t fileNumber = tox_file_send(tox, friendNumber, TOX_FILE_KIND_AVATAR, length, hash, NULL, 0, &error); if (error != TOX_ERR_FILE_SEND_OK) { mir_free(data); @@ -86,7 +86,8 @@ void CToxProto::SetToxAvatar(std::tstring path, bool checkHash) return; } - FileTransferParam *transfer = new FileTransferParam(friendNumber, fileNumber, _T("avatar"), length); + AvatarTransferParam *transfer = new AvatarTransferParam(friendNumber, fileNumber, NULL, length); + memcpy(transfer->hash, hash, TOX_HASH_LENGTH); transfer->pfts.hContact = hContact; transfer->hFile = _tfopen(path.c_str(), L"rb"); transfers.Add(transfer); @@ -136,7 +137,7 @@ INT_PTR CToxProto::GetAvatarInfo(WPARAM, LPARAM lParam) std::tstring path = GetAvatarFilePath(pai->hContact); if (IsFileExists(path)) { - _tcsncpy(pai->filename, path.c_str(), SIZEOF(pai->filename)); + mir_tstrncpy(pai->filename, path.c_str(), SIZEOF(pai->filename)); pai->format = PA_FORMAT_PNG; return GAIR_SUCCESS; @@ -156,7 +157,7 @@ INT_PTR CToxProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) std::tstring path = GetAvatarFilePath(); if (IsFileExists(path)) { - _tcsncpy((TCHAR*)wParam, path.c_str(), (int)lParam); + mir_tstrncpy((TCHAR*)wParam, path.c_str(), (int)lParam); return 0; } @@ -196,7 +197,7 @@ INT_PTR CToxProto::SetMyAvatar(WPARAM, LPARAM lParam) } TOX_ERR_FILE_SEND error; - if (!tox_file_send(tox, NULL, TOX_FILE_KIND_AVATAR, 0, NULL, NULL, 0, &error)) + if (!tox_file_send(tox, friendNumber, TOX_FILE_KIND_AVATAR, 0, NULL, NULL, 0, &error)) { debugLogA(__FUNCTION__": failed to unset avatar"); return -1; @@ -205,11 +206,9 @@ INT_PTR CToxProto::SetMyAvatar(WPARAM, LPARAM lParam) } if (IsFileExists(avatarPath)) - { DeleteFile(avatarPath.c_str()); - } - db_unset(NULL, m_szModuleName, TOX_SETTINGS_AVATAR_HASH); + delSetting(TOX_SETTINGS_AVATAR_HASH); } return 0; -- cgit v1.2.3