summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Tox/src/tox_messages.cpp16
-rw-r--r--protocols/Tox/src/tox_transfer.cpp2
2 files changed, 10 insertions, 8 deletions
diff --git a/protocols/Tox/src/tox_messages.cpp b/protocols/Tox/src/tox_messages.cpp
index a050b7f962..c513780f3f 100644
--- a/protocols/Tox/src/tox_messages.cpp
+++ b/protocols/Tox/src/tox_messages.cpp
@@ -35,8 +35,9 @@ void CToxProto::OnFriendAction(Tox *tox, const int number, const uint8_t *action
int __cdecl CToxProto::SendMsg(MCONTACT hContact, int flags, const char* msg)
{
- uint32_t number = 0;// getDword(hContact, TOX_SETTINGS_NUMBER, TOX_ERROR);
- if (number == TOX_ERROR)
+ ToxBinAddress pubKey = ptrA(getStringA(hContact, TOX_SETTINGS_ID));
+ int32_t friendNumber = tox_get_friend_number(tox, pubKey);
+ if (friendNumber == TOX_ERROR)
{
debugLogA("CToxProto::SendMsg: failed to get friend number");
return 0;
@@ -46,11 +47,11 @@ int __cdecl CToxProto::SendMsg(MCONTACT hContact, int flags, const char* msg)
{
if (strncmp(msg, "/me ", 4) != 0)
{
- result = tox_send_message(tox, number, (uint8_t*)msg, mir_strlen(msg));
+ result = tox_send_message(tox, friendNumber, (uint8_t*)msg, mir_strlen(msg));
}
else
{
- result = tox_send_action(tox, number, (uint8_t*)&msg[4], mir_strlen(msg) - 4);
+ result = tox_send_action(tox, friendNumber, (uint8_t*)&msg[4], mir_strlen(msg) - 4);
}
}
@@ -115,10 +116,11 @@ int __cdecl CToxProto::UserIsTyping(MCONTACT hContact, int type)
{
if (hContact && IsOnline())
{
- uint32_t number = 0;//getDword(hContact, TOX_SETTINGS_NUMBER, TOX_ERROR);
- if (number >= 0)
+ ToxBinAddress pubKey = ptrA(getStringA(hContact, TOX_SETTINGS_ID));
+ int32_t friendNumber = tox_get_friend_number(tox, pubKey);
+ if (friendNumber >= 0)
{
- tox_set_user_is_typing(tox, number, type);
+ tox_set_user_is_typing(tox, friendNumber, type);
return 0;
}
}
diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp
index fd244f5136..43656ce349 100644
--- a/protocols/Tox/src/tox_transfer.cpp
+++ b/protocols/Tox/src/tox_transfer.cpp
@@ -146,7 +146,7 @@ HANDLE __cdecl CToxProto::SendFile(MCONTACT hContact, const PROTOCHAR*, PROTOCHA
int32_t friendNumber = tox_get_friend_number(tox, pubKey);
if (friendNumber == TOX_ERROR)
{
- debugLogA("CToxProto::SendFilesAsync: cannot get friend number by public key");
+ debugLogA("CToxProto::SendMsg: failed to get friend number");
return NULL;
}