From bf23720e7c1d7de70d7d99167a42783f08ef8b17 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 17 Aug 2014 17:26:18 +0000 Subject: Tox: - fixed tox id convertation - fixed tox profile load in first start - fixed polling thread git-svn-id: http://svn.miranda-ng.org/main/trunk@10215 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_account.cpp | 48 +++++++++++++++------------------------ 1 file changed, 18 insertions(+), 30 deletions(-) (limited to 'protocols/Tox/src/tox_account.cpp') diff --git a/protocols/Tox/src/tox_account.cpp b/protocols/Tox/src/tox_account.cpp index a517673398..b4871425d2 100644 --- a/protocols/Tox/src/tox_account.cpp +++ b/protocols/Tox/src/tox_account.cpp @@ -49,6 +49,8 @@ void CToxProto::InitToxCore() void CToxProto::UninitToxCore() { + isTerminated = isConnected = false; + SaveToxData(); tox_kill(tox); @@ -68,10 +70,8 @@ void CToxProto::DoBootstrap() void CToxProto::DoTox() { - uint32_t interval = 1000; + uint32_t interval = 50; { - //mir_cslock lock(tox_lock); - tox_do(tox); interval = tox_do_interval(tox); } @@ -81,42 +81,30 @@ void CToxProto::DoTox() void CToxProto::PollingThread(void*) { debugLogA("CToxProto::PollingThread: entering"); - + while (!isTerminated) { DoTox(); - } - - debugLogA("CToxProto::PollingThread: leaving"); -} - -void CToxProto::ConnectionThread(void*) -{ - debugLogA("CToxProto::ConnectionThread: entering"); - - while (!isTerminated && !isConnected) - { - DoBootstrap(); - if (tox_isconnected(tox)) + if (!isConnected) { - isConnected = true; + if (tox_isconnected(tox)) + { + isConnected = true; - LoadContactList(); + LoadContactList(); - m_iStatus = m_iDesiredStatus = ID_STATUS_ONLINE; - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus); + m_iStatus = m_iDesiredStatus = ID_STATUS_ONLINE; + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus); - break; + debugLogA("CToxProto::PollingThread: successfuly connected to DHT"); + } + else + { + DoBootstrap(); + } } - - DoTox(); } - debugLogA("CToxProto::ConnectionThread: leaving"); - - if (!isTerminated && isConnected) - { - poolingThread = ForkThreadEx(&CToxProto::PollingThread, 0, NULL); - } + debugLogA("CToxProto::PollingThread: leaving"); } \ No newline at end of file -- cgit v1.2.3