diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-23 22:40:56 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-23 22:40:56 +0000 |
commit | cb4909f7f21641f40e2676a848304e54bc44328c (patch) | |
tree | 75142255eb38814ad0809fe7c777e3ae128672fe /protocols | |
parent | 02c5b3e97608972a9aa6638bb73b31a4c6bddcfd (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')
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 8 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_queue.cpp | 16 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 24 |
5 files changed, 32 insertions, 22 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 4ff3156678..f0c3ac76f1 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 0f671aaa6d..12f160d169 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -196,12 +196,10 @@ int CVkProto::SetStatus(int iNewStatus) ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
m_hWorkerThread = ForkThreadEx(&CVkProto::WorkerThread, 0, NULL);
}
- else {
- if ( IsOnline())
- SetServerStatus(iNewStatus);
- m_iStatus = iNewStatus;
+ else if ( IsOnline())
+ SetServerStatus(iNewStatus);
+ else
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
- }
return 0;
}
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index e045147af7..204694bd56 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -26,7 +26,7 @@ struct AsyncHttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject void AddHeader(LPCSTR, LPCSTR);
void Redirect(NETLIBHTTPREQUEST*);
- BOOL bNeedsRestart;
+ bool bNeedsRestart, bIsMainConn;
VK_REQUEST_HANDLER m_pFunc;
void *pUserInfo;
};
@@ -124,7 +124,7 @@ struct CVkProto : public PROTO<CVkProto> void PollUpdates(JSONNODE*);
void OnReceivePolling(NETLIBHTTPREQUEST*, AsyncHttpRequest *pReq);
- int SetServerStatus(int);
+ void SetServerStatus(int);
__forceinline bool IsOnline() const { return m_bOnline; }
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index 1b85a54691..782906ce6f 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -44,6 +44,12 @@ LBL_Restart: if (pReq->bNeedsRestart)
goto LBL_Restart;
}
+ else if (pReq->bIsMainConn) {
+ if (m_iStatus >= ID_STATUS_CONNECTING && m_iStatus < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)
+ ConnectionFailed(LOGINERR_NONETWORK);
+ else
+ ShutdownSession();
+ }
delete pReq;
}
@@ -57,9 +63,10 @@ bool CVkProto::PushAsyncHttpRequest(int iRequestType, LPCSTR szUrl, bool bSecure pReq->flags |= NLHRF_SSL;
CMStringA url;
- if (*szUrl == '/') {
+ if (*szUrl == '/') { // relative url leads to a site
url = VK_API_URL;
url += szUrl;
+ pReq->bIsMainConn = true;
}
else url = szUrl;
@@ -94,8 +101,11 @@ void CVkProto::WorkerThread(void*) debugLogA("CVkProto::WorkerThread: entering");
m_bTerminated = m_prevError = false;
m_szAccessToken = getStringA("AccessToken");
- if (m_szAccessToken != NULL)
- OnLoggedIn();
+ if (m_szAccessToken != NULL) {
+ // try to receive a response from server
+ HttpParam param = { "access_token", m_szAccessToken };
+ PushAsyncHttpRequest(REQUEST_GET, "/method/getUserInfoEx.json", true, &CVkProto::OnReceiveMyInfo, 1, ¶m);
+ }
else { // Initialize new OAuth session
HttpParam params[] = {
{ "client_id", VK_APP_ID },
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, ¶m);
}
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, ¶m);
}
- 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, ¶m);
}
- 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();
|