From a8af35bf6e3de34405ce5dbc3b035039a9ee4806 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 18 Jan 2015 22:45:37 +0000 Subject: Tox: - added pause support for file sending - added resuming for broken file transfers - updated tox core git-svn-id: http://svn.miranda-ng.org/main/trunk@11875 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_contacts.cpp | 41 ++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'protocols/Tox/src/tox_contacts.cpp') diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 6a7321546f..5cd56e099d 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -73,7 +73,7 @@ MCONTACT CToxProto::FindContact(const std::string &id) } db_free(&dbv); - if (_strnicmp(id.c_str(), clientId.c_str(), TOX_CLIENT_ID_SIZE) == 0) + if (mir_strcmpi(id.c_str(), clientId.c_str()) == 0) { break; } @@ -221,22 +221,22 @@ void CToxProto::OnFriendRequest(Tox *tox, const uint8_t *address, const uint8_t ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre); } -void CToxProto::OnFriendNameChange(Tox *tox, const int number, const uint8_t *name, const uint16_t nameSize, void *arg) +void CToxProto::OnFriendNameChange(Tox *tox, const int friendNumber, const uint8_t *name, const uint16_t nameSize, void *arg) { CToxProto *proto = (CToxProto*)arg; - MCONTACT hContact = proto->FindContact(number); + MCONTACT hContact = proto->FindContact(friendNumber); if (hContact) { proto->setString(hContact, "Nick", (char*)name); } } -void CToxProto::OnStatusMessageChanged(Tox *tox, const int number, const uint8_t* message, const uint16_t messageSize, void *arg) +void CToxProto::OnStatusMessageChanged(Tox *tox, const int friendNumber, const uint8_t* message, const uint16_t messageSize, void *arg) { CToxProto *proto = (CToxProto*)arg; - MCONTACT hContact = proto->FindContact(number); + MCONTACT hContact = proto->FindContact(friendNumber); if (hContact) { ptrW statusMessage(mir_utf8decodeW((char*)message)); @@ -244,11 +244,11 @@ void CToxProto::OnStatusMessageChanged(Tox *tox, const int number, const uint8_t } } -void CToxProto::OnUserStatusChanged(Tox *tox, int32_t number, uint8_t usertatus, void *arg) +void CToxProto::OnUserStatusChanged(Tox *tox, int32_t friendNumber, uint8_t usertatus, void *arg) { CToxProto *proto = (CToxProto*)arg; - MCONTACT hContact = proto->FindContact(number); + MCONTACT hContact = proto->FindContact(friendNumber); if (hContact) { TOX_USERSTATUS userstatus = (TOX_USERSTATUS)usertatus; @@ -257,19 +257,40 @@ void CToxProto::OnUserStatusChanged(Tox *tox, int32_t number, uint8_t usertatus, } } -void CToxProto::OnConnectionStatusChanged(Tox *tox, const int number, const uint8_t status, void *arg) +void CToxProto::OnConnectionStatusChanged(Tox *tox, const int friendNumber, const uint8_t status, void *arg) { CToxProto *proto = (CToxProto*)arg; - MCONTACT hContact = proto->FindContact(number); + //mir_cslock lock(proto->toxLock); + + MCONTACT hContact = proto->FindContact(friendNumber); if (hContact) { int newStatus = status ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; proto->SetContactStatus(hContact, newStatus); if (status) { - tox_send_avatar_info(proto->tox, number); + tox_send_avatar_info(proto->tox, friendNumber); proto->delSetting(hContact, "Auth"); + + for (std::map::iterator it = proto->transfers.begin(); it != proto->transfers.end(); it++) + { + // only for receiving + if (it->second->friendNumber == friendNumber && it->second->GetDirection() == 1) + { + it->second->Broken(tox); + } + } + } + else + { + for (std::map::iterator it = proto->transfers.begin(); it != proto->transfers.end(); it++) + { + if (it->second->friendNumber == friendNumber) + { + it->second->status = PAUSED; + } + } } } } -- cgit v1.2.3