From 2e93497d5b19b4fc46f84cb18267bce357e48747 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 16 Aug 2014 16:02:58 +0000 Subject: Tox: - added netlib logging - minor fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@10203 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_events.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'protocols/Tox/src/tox_events.cpp') diff --git a/protocols/Tox/src/tox_events.cpp b/protocols/Tox/src/tox_events.cpp index d10e146aee..1c32597ce4 100644 --- a/protocols/Tox/src/tox_events.cpp +++ b/protocols/Tox/src/tox_events.cpp @@ -2,11 +2,19 @@ int CToxProto::OnModulesLoaded(WPARAM, LPARAM) { + InitNetlib(); HookEventObj(ME_OPT_INITIALISE, OnOptionsInit, this); return 0; } +int CToxProto::OnPreShutdown(WPARAM, LPARAM) +{ + UninitNetlib(); + + return 0; +} + INT_PTR CToxProto::OnAccountManagerInit(WPARAM, LPARAM lParam) { return (INT_PTR)CreateDialogParam( @@ -124,6 +132,12 @@ void CToxProto::OnStatusMessageChanged(Tox *tox, const int friendnumber, const u void CToxProto::OnUserStatusChanged(Tox *tox, int32_t friendnumber, uint8_t usertatus, void *arg) { + TOX_USERSTATUS userstatus = (TOX_USERSTATUS)usertatus; + if (userstatus == TOX_USERSTATUS::TOX_USERSTATUS_NONE) + { + return; + } + CToxProto *proto = (CToxProto*)arg; std::vector clientId(TOX_CLIENT_ID_SIZE); @@ -133,17 +147,30 @@ void CToxProto::OnUserStatusChanged(Tox *tox, int32_t friendnumber, uint8_t user MCONTACT hContact = proto->FindContact(toxId.c_str()); if (hContact) { - int status = proto->ToxToMirandaStatus((TOX_USERSTATUS)usertatus); + int status = proto->ToxToMirandaStatus(userstatus); proto->SetContactStatus(hContact, status); } } -void CToxProto::OnConnectionStatusChanged(Tox *tox, const int friendId, const uint8_t status, void *arg) +void CToxProto::OnConnectionStatusChanged(Tox *tox, const int friendnumber, const uint8_t status, void *arg) { + CToxProto *proto = (CToxProto*)arg; + + std::vector clientId(TOX_CLIENT_ID_SIZE); + tox_get_client_id(tox, friendnumber, &clientId[0]); + std::string toxId = proto->DataToHexString(clientId); + + MCONTACT hContact = proto->FindContact(toxId.c_str()); + if (hContact) + { + int newStatus = status ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; + proto->SetContactStatus(hContact, newStatus); + } } -void CToxProto::OnAction(Tox *tox, const int friendId, const uint8_t *message, const uint16_t messageSize, void *arg) +void CToxProto::OnAction(Tox *tox, const int friendnumber, const uint8_t *message, const uint16_t messageSize, void *arg) { + } void CToxProto::OnReadReceipt(Tox *tox, int32_t friendnumber, uint32_t receipt, void *arg) -- cgit v1.2.3