From 22a4d712bff13ce22553f986aba0185d14c0a4a3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 13 Oct 2013 10:24:42 +0000 Subject: fix against going idle git-svn-id: http://svn.miranda-ng.org/main/trunk@6484 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_proto.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'protocols/VKontakte') diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index b2f8326b9a..ebc02964c3 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -175,7 +175,7 @@ void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, void*) int CVkProto::SetStatus(int iNewStatus) { - if (m_iDesiredStatus == iNewStatus) + if (m_iDesiredStatus == iNewStatus || iNewStatus == ID_STATUS_IDLE) return 0; int oldStatus = m_iStatus; @@ -188,16 +188,18 @@ int CVkProto::SetStatus(int iNewStatus) m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); } - else if ( !(m_iStatus >= ID_STATUS_CONNECTING && m_iStatus < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) { + else if (m_hWorkerThread == NULL && !(m_iStatus >= ID_STATUS_CONNECTING && m_iStatus < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) { m_iStatus = ID_STATUS_CONNECTING; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); - if (m_hWorkerThread == NULL) - m_hWorkerThread = ForkThreadEx(&CVkProto::WorkerThread, 0, NULL); + m_hWorkerThread = ForkThreadEx(&CVkProto::WorkerThread, 0, NULL); } - else if ( IsOnline()) - SetServerStatus(iNewStatus); - else + else { + if ( IsOnline()) + SetServerStatus(iNewStatus); + m_iStatus = iNewStatus; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus); + } + return 0; } -- cgit v1.2.3