summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_proto.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-09-10 11:58:58 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-09-10 11:58:58 +0000
commit510f938a5c6f0ee95ac0b36e56aced065228298e (patch)
tree19f907a09498b6f76a4b7aae6ee90a16bf693aa2 /protocols/Tox/src/tox_proto.cpp
parent86c868a76a5ba3d638b3b7302cd5401df06591d8 (diff)
Tox: tox pointers should store in PollingThread to avoid cross thread using
git-svn-id: http://svn.miranda-ng.org/main/trunk@15316 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_proto.cpp')
-rw-r--r--protocols/Tox/src/tox_proto.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
index 1718f9f0bc..d2f9b943de 100644
--- a/protocols/Tox/src/tox_proto.cpp
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -2,8 +2,6 @@
CToxProto::CToxProto(const char* protoName, const TCHAR* userName)
: PROTO<CToxProto>(protoName, userName),
- tox(NULL), toxAv(NULL), password(NULL),
- isTerminated(false), isConnected(false),
hPollingThread(NULL), hOutDevice(NULL)
{
InitNetlib();
@@ -173,9 +171,9 @@ int CToxProto::SetStatus(int iNewStatus)
if (iNewStatus == ID_STATUS_OFFLINE)
{
// logout
- isTerminated = true;
- WaitForSingleObject(hPollingThread, INFINITE);
- hPollingThread = NULL;
+ if (toxThread)
+ toxThread->isTerminated = true;
+ toxThread = NULL;
if (!Miranda_Terminated())
{
@@ -194,23 +192,16 @@ int CToxProto::SetStatus(int iNewStatus)
if (old_status == ID_STATUS_OFFLINE && !IsOnline())
{
- if (hPollingThread != NULL)
- {
- m_iDesiredStatus = old_status;
- return 0;
- }
-
// login
m_iStatus = ID_STATUS_CONNECTING;
- isTerminated = false;
hPollingThread = ForkThreadEx(&CToxProto::PollingThread, 0, NULL);
}
else
{
// set tox status
m_iStatus = iNewStatus;
- tox_self_set_status(tox, MirandaToToxStatus(iNewStatus));
+ tox_self_set_status(toxThread->tox, MirandaToToxStatus(iNewStatus));
}
}
@@ -235,7 +226,7 @@ int CToxProto::SetAwayMsg(int, const TCHAR *msg)
{
T2Utf statusMessage(msg);
TOX_ERR_SET_INFO error;
- if (tox_self_set_status_message(tox, (uint8_t*)(char*)statusMessage, min(TOX_MAX_STATUS_MESSAGE_LENGTH, mir_strlen(statusMessage)), &error))
+ if (tox_self_set_status_message(toxThread->tox, (uint8_t*)(char*)statusMessage, min(TOX_MAX_STATUS_MESSAGE_LENGTH, mir_strlen(statusMessage)), &error))
debugLogA("CToxProto::SetAwayMsg: failed to set status status message %s (%d)", msg, error);
}