summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_contacts.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-01-18 22:45:37 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-01-18 22:45:37 +0000
commita8af35bf6e3de34405ce5dbc3b035039a9ee4806 (patch)
tree251e681398e7ed2b6a4707a1b1900822f3fbfae1 /protocols/Tox/src/tox_contacts.cpp
parent78b13a92fb3bbc7d7ae3cc31e84a99758e392d4d (diff)
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
Diffstat (limited to 'protocols/Tox/src/tox_contacts.cpp')
-rw-r--r--protocols/Tox/src/tox_contacts.cpp41
1 files changed, 31 insertions, 10 deletions
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<uint8_t, FileTransferParam*>::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<uint8_t, FileTransferParam*>::iterator it = proto->transfers.begin(); it != proto->transfers.end(); it++)
+ {
+ if (it->second->friendNumber == friendNumber)
+ {
+ it->second->status = PAUSED;
+ }
+ }
}
}
}