summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_thread.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-23 22:40:56 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-23 22:40:56 +0000
commitcb4909f7f21641f40e2676a848304e54bc44328c (patch)
tree75142255eb38814ad0809fe7c777e3ae128672fe /protocols/VKontakte/src/vk_thread.cpp
parent02c5b3e97608972a9aa6638bb73b31a4c6bddcfd (diff)
VK:
- massive update for the status setting code; - connection icon doesn't rotate in tray; - connection status isn't restored after wake up from standby/sleep mode; - network errors weren't processed in the main cycle - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@6606 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_thread.cpp')
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index bb0bbb844b..5739321637 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -45,16 +45,10 @@ static VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR pObject, DWORD)
void CVkProto::OnLoggedIn()
{
m_bOnline = true;
-
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, m_iDesiredStatus);
- m_iStatus = m_iDesiredStatus;
+ SetServerStatus(m_iDesiredStatus);
// initialize online timer
- SetServerStatus(m_iStatus);
m_timer = SetTimer(NULL, (UINT_PTR)this, 870000, TimerProc);
-
- HttpParam param = { "access_token", m_szAccessToken };
- PushAsyncHttpRequest(REQUEST_GET, "/method/getUserInfoEx.json", true, &CVkProto::OnReceiveMyInfo, 1, &param);
}
void CVkProto::OnLoggedOut()
@@ -71,17 +65,24 @@ void CVkProto::OnLoggedOut()
SetAllContactStatuses(ID_STATUS_OFFLINE);
}
-int CVkProto::SetServerStatus(int iStatus)
+void CVkProto::SetServerStatus(int iNewStatus)
{
- if (iStatus == ID_STATUS_OFFLINE) {
+ if ( !IsOnline() || iNewStatus < ID_STATUS_OFFLINE || m_iStatus == iNewStatus)
+ return;
+
+ int iOldStatus = m_iStatus;
+
+ if (iNewStatus == ID_STATUS_OFFLINE) {
HttpParam param = { "access_token", m_szAccessToken };
PushAsyncHttpRequest(REQUEST_GET, "/method/account.setOffline.json", true, &CVkProto::OnReceiveSmth, 1, &param);
}
- else if (iStatus != ID_STATUS_INVISIBLE) {
+ else if (iNewStatus != ID_STATUS_INVISIBLE) {
HttpParam param = { "access_token", m_szAccessToken };
PushAsyncHttpRequest(REQUEST_GET, "/method/account.setOnline.json", true, &CVkProto::OnReceiveSmth, 1, &param);
}
- return 0;
+
+ m_iStatus = iNewStatus;
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -195,6 +196,7 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
}
}
+ OnLoggedIn();
RetrieveUserInfo(m_myUserId);
RetrieveFriends();
RetrieveUnreadMessages();