diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-05-23 20:56:32 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-05-23 20:56:32 +0000 |
commit | 84d614636040716d219b7d6adf470576411b5543 (patch) | |
tree | 53221188e3bed885c18e8ef81304f9479ecf7869 | |
parent | 2e5c904f370d48a8e780ce64db2633d54ec0f5cd (diff) |
Tox: attempt to fix own avatar setting
git-svn-id: http://svn.miranda-ng.org/main/trunk@13798 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/Tox/src/tox_avatars.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
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;
}
|