summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp16
1 files changed, 9 insertions, 7 deletions
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;
}