From 359b8eada7a52483c0447fd9cdbfc09517022668 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 1 Feb 2014 11:09:55 +0000 Subject: VK: fix for going offline while protocol is online git-svn-id: http://svn.miranda-ng.org/main/trunk@7984 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_proto.h | 3 ++- protocols/VKontakte/src/vk_thread.cpp | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'protocols/VKontakte/src') diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 9d104387e2..b4906e97d5 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -214,6 +214,8 @@ struct CVkProto : public PROTO __forceinline LPCTSTR getGroup() const { return m_defaultGroup; } __forceinline void setGroup(LPCTSTR grp) { m_defaultGroup = mir_tstrdup(grp); } + UINT_PTR m_timer; + private: friend struct AsyncHttpRequest; @@ -271,7 +273,6 @@ private: LONG m_myUserId; ptrA m_szAccessToken; ptrT m_defaultGroup; - UINT_PTR m_timer; ptrA m_pollingServer, m_pollingKey, m_pollingTs; HANDLE m_pollingConn, m_hPollingThread; diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index eb7e1a5344..99a790d206 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -44,13 +44,25 @@ static VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR pObject, DWORD) ppro->SetServerStatus(ppro->m_iStatus); } +static void CALLBACK VKSetTimer(void *pObject) +{ + CVkProto *ppro = (CVkProto*)pObject; + ppro->m_timer = SetTimer(NULL, (UINT_PTR)ppro, 870000, TimerProc); +} + +static void CALLBACK VKUnsetTimer(void *pObject) +{ + CVkProto *ppro = (CVkProto*)pObject; + KillTimer(NULL, ppro->m_timer); +} + void CVkProto::OnLoggedIn() { m_bOnline = true; SetServerStatus(m_iDesiredStatus); // initialize online timer - m_timer = SetTimer(NULL, (UINT_PTR)this, 870000, TimerProc); + CallFunctionAsync(VKSetTimer, this); } void CVkProto::OnLoggedOut() @@ -63,7 +75,7 @@ void CVkProto::OnLoggedOut() ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, ID_STATUS_OFFLINE); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; - KillTimer(NULL, m_timer); + CallFunctionAsync(VKUnsetTimer, this); SetAllContactStatuses(ID_STATUS_OFFLINE); m_chats.destroy(); } -- cgit v1.2.3