diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-04-27 13:41:57 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-04-27 13:41:57 +0000 |
commit | c39bccffa99e54f11a9512271a4d98f851c57823 (patch) | |
tree | da71d3ac7f0b82faa71657db22505b3048294db4 /protocols/Tox/src/tox_contacts.cpp | |
parent | fb5f50bc10318b32d3d99480874813a05551d740 (diff) |
Tox: extended transfer logs
git-svn-id: http://svn.miranda-ng.org/main/trunk@16775 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_contacts.cpp')
-rw-r--r-- | protocols/Tox/src/tox_contacts.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 02a1869a37..22901b5a6e 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -43,7 +43,7 @@ MCONTACT CToxProto::GetContact(const int friendNumber) TOX_ERR_FRIEND_GET_PUBLIC_KEY error;
if (!tox_friend_get_public_key(toxThread->Tox(), friendNumber, data, &error))
{
- logger->Log(__FUNCTION__": failed to get friend public key (%d)", error);
+ logger->Log(__FUNCTION__": failed to get friend (%d) public key (%d)", friendNumber, error);
return NULL;
}
ToxHexAddress pubKey(data, TOX_PUBLIC_KEY_SIZE);
@@ -63,6 +63,19 @@ MCONTACT CToxProto::GetContact(const char *pubKey) return hContact;
}
+ToxHexAddress CToxProto::GetContactPublicKey(const int friendNumber)
+{
+ uint8_t data[TOX_PUBLIC_KEY_SIZE];
+ TOX_ERR_FRIEND_GET_PUBLIC_KEY error;
+ if (!tox_friend_get_public_key(toxThread->Tox(), friendNumber, data, &error))
+ {
+ logger->Log(__FUNCTION__": failed to get friend (%d) public key (%d)", friendNumber, error);
+ return ToxHexAddress::Empty();
+ }
+ ToxHexAddress pubKey(data, TOX_PUBLIC_KEY_SIZE);
+ return pubKey;
+}
+
MCONTACT CToxProto::AddContact(const char *address, const char *nick, const char *dnsId, bool isTemporary)
{
MCONTACT hContact = GetContact(address);
@@ -117,13 +130,11 @@ void CToxProto::LoadFriendList(void*) for (size_t i = 0; i < count; i++)
{
uint32_t friendNumber = friends[i];
- TOX_ERR_FRIEND_GET_PUBLIC_KEY getPublicKeyResult;
- if (!tox_friend_get_public_key(toxThread->Tox(), friendNumber, data, &getPublicKeyResult))
- {
- logger->Log(__FUNCTION__": failed to get friend public key (%d)", getPublicKeyResult);
+
+ ToxHexAddress pubKey = GetContactPublicKey(friendNumber);
+ if (pubKey == ToxHexAddress::Empty())
continue;
- }
- ToxHexAddress pubKey(data, TOX_PUBLIC_KEY_SIZE);
+
MCONTACT hContact = AddContact(pubKey);
if (hContact)
{
|