From 84d614636040716d219b7d6adf470576411b5543 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 23 May 2015 20:56:32 +0000 Subject: Tox: attempt to fix own avatar setting git-svn-id: http://svn.miranda-ng.org/main/trunk@13798 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_avatars.cpp | 54 ++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 26 deletions(-) (limited to 'protocols/Tox') diff --git a/protocols/Tox/src/tox_avatars.cpp b/protocols/Tox/src/tox_avatars.cpp index 2837502959..70bd8fd299 100644 --- a/protocols/Tox/src/tox_avatars.cpp +++ b/protocols/Tox/src/tox_avatars.cpp @@ -66,34 +66,37 @@ void CToxProto::SetToxAvatar(std::tstring path) db_set_blob(NULL, m_szModuleName, TOX_SETTINGS_AVATAR_HASH, (void*)hash, TOX_HASH_LENGTH); - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) + if (IsOnline()) { - if (GetContactStatus(hContact) == ID_STATUS_OFFLINE) - continue; - - int32_t friendNumber = GetToxFriendNumber(hContact); - if (friendNumber == UINT32_MAX) + for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { - mir_free(data); - debugLogA(__FUNCTION__": failed to set new avatar"); - return; - } + if (GetContactStatus(hContact) == ID_STATUS_OFFLINE) + continue; - TOX_ERR_FILE_SEND 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); - debugLogA(__FUNCTION__": failed to set new avatar"); - return; - } + int32_t friendNumber = GetToxFriendNumber(hContact); + if (friendNumber == UINT32_MAX) + { + mir_free(data); + debugLogA(__FUNCTION__": failed to set new avatar"); + return; + } - AvatarTransferParam *transfer = new AvatarTransferParam(friendNumber, fileNumber, NULL, length); - transfer->pfts.flags |= PFTS_SENDING; - memcpy(transfer->hash, hash, TOX_HASH_LENGTH); - transfer->pfts.hContact = hContact; - transfer->hFile = _tfopen(path.c_str(), L"rb"); - transfers.Add(transfer); + TOX_ERR_FILE_SEND 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); + debugLogA(__FUNCTION__": failed to set new avatar"); + return; + } + + AvatarTransferParam *transfer = new AvatarTransferParam(friendNumber, fileNumber, NULL, length); + transfer->pfts.flags |= PFTS_SENDING; + memcpy(transfer->hash, hash, TOX_HASH_LENGTH); + transfer->pfts.hContact = hContact; + transfer->hFile = _tfopen(path.c_str(), L"rb"); + transfers.Add(transfer); + } } mir_free(data); @@ -157,8 +160,7 @@ INT_PTR CToxProto::SetMyAvatar(WPARAM, LPARAM lParam) return 0; } - if (IsOnline()) - SetToxAvatar(avatarPath); + SetToxAvatar(avatarPath); return 0; } -- cgit v1.2.3