summaryrefslogtreecommitdiff
path: root/protocols/VKontakte
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-02-01 11:09:55 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-02-01 11:09:55 +0000
commit359b8eada7a52483c0447fd9cdbfc09517022668 (patch)
tree658283da9c133c1c2e2e30317e39ae8a4304ee78 /protocols/VKontakte
parentf648e8aba5e2580aa1da0f80f9626f89d465d778 (diff)
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
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r--protocols/VKontakte/src/vk_proto.h3
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp16
2 files changed, 16 insertions, 3 deletions
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<CVkProto>
__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();
}