diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-08-16 16:02:58 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-08-16 16:02:58 +0000 |
commit | 2e93497d5b19b4fc46f84cb18267bce357e48747 (patch) | |
tree | 32682bcd95fa505aec3e8cf16023e8babfb07829 /protocols/Tox/src/tox_events.cpp | |
parent | 5cbde68cad776dd10e36b72f030712abdf3f225a (diff) |
Tox:
- added netlib logging
- minor fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@10203 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_events.cpp')
-rw-r--r-- | protocols/Tox/src/tox_events.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
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<uint8_t> 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<uint8_t> 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)
|