summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2016-04-01 19:30:30 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2016-04-01 19:30:30 +0000
commiteba8d089881ba440d2067cb441539517e577d37b (patch)
tree88e51ae8b583cf7b129995bae2872583099fc58c /protocols
parent532867c22a80206120cd461d673775fdaafbe4d9 (diff)
VKontakte:
gzip support support persistent connection to api.vk.com (patch by MikalaiR) version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@16568 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp4
-rw-r--r--protocols/VKontakte/src/vk_proto.h1
-rw-r--r--protocols/VKontakte/src/vk_queue.cpp22
-rw-r--r--protocols/VKontakte/src/vk_struct.cpp4
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp3
6 files changed, 31 insertions, 5 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 6aec70d8c1..022a5fbe57 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 1
-#define __BUILD_NUM 25
+#define __BUILD_NUM 26
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index fec5c09f06..8382ce48e1 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -44,7 +44,9 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
m_ChatsTyping(1, NumericKeySortT),
m_iLoadHistoryTask(0),
m_bNotifyForEndLoadingHistory(false),
- m_bNotifyForEndLoadingHistoryAllContact(false)
+ m_bNotifyForEndLoadingHistoryAllContact(false),
+ m_hAPIConnection(NULL),
+ m_pollingConn(NULL)
{
InitQueue();
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 410180dd0e..388a4247b7 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -454,6 +454,7 @@ private:
HANDLE
m_pollingConn,
m_hPollingThread,
+ m_hAPIConnection,
m_hPopupClassError,
m_hPopupClassNotification;
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp
index 2a6bae1e38..2f969937fc 100644
--- a/protocols/VKontakte/src/vk_queue.cpp
+++ b/protocols/VKontakte/src/vk_queue.cpp
@@ -48,11 +48,21 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq)
pReq->dataLength = pReq->m_szParam.GetLength();
}
}
+
+ if (pReq->m_bApiReq) {
+ pReq->flags |= NLHRF_PERSISTENT;
+ pReq->nlc = m_hAPIConnection;
+ }
+
debugLogA("CVkProto::ExecuteRequest \n====\n%s\n====\n", pReq->szUrl);
NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)pReq);
if (reply != NULL) {
if (pReq->m_pFunc != NULL)
- (this->*(pReq->m_pFunc))(reply, pReq); // may be set pReq->bNeedsRestart
+ (this->*(pReq->m_pFunc))(reply, pReq); // may be set pReq->bNeedsRestart
+
+ if (pReq->m_bApiReq)
+ m_hAPIConnection = reply->nlc;
+
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
}
else if (pReq->bIsMainConn) {
@@ -70,6 +80,10 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq)
}
}
debugLogA("CVkProto::ExecuteRequest pReq->bNeedsRestart = %d", (int)pReq->bNeedsRestart);
+
+ if (!reply)
+ m_hAPIConnection = NULL;
+
} while (pReq->bNeedsRestart && !m_bTerminated);
delete pReq;
}
@@ -129,6 +143,8 @@ void CVkProto::WorkerThread(void*)
Push(pReq);
}
+ m_hAPIConnection = NULL;
+
while (true) {
WaitForSingleObject(m_evRequestsQueue, 1000);
if (m_bTerminated)
@@ -156,6 +172,10 @@ void CVkProto::WorkerThread(void*)
}
}
+ if (m_hAPIConnection)
+ Netlib_CloseHandle(m_hAPIConnection);
+
+ m_hAPIConnection = NULL;
m_hWorkerThread = 0;
debugLogA("CVkProto::WorkerThread: leaving");
}
diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp
index 06253eb8af..1214e9ecf0 100644
--- a/protocols/VKontakte/src/vk_struct.cpp
+++ b/protocols/VKontakte/src/vk_struct.cpp
@@ -26,7 +26,7 @@ AsyncHttpRequest::AsyncHttpRequest()
cbSize = sizeof(NETLIBHTTPREQUEST);
m_bApiReq = true;
AddHeader("Connection", "keep-alive");
- AddHeader("Accept-Encoding", "booo");
+ AddHeader("Accept-Encoding", "gzip, deflate");
pUserInfo = NULL;
m_iRetry = MAX_RETRIES;
m_iErrorCode = 0;
@@ -45,7 +45,7 @@ AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url
bIsMainConn = false;
bExpUrlEncode = ppro->m_bUseNonStandardUrlEncode;
AddHeader("Connection", "keep-alive");
- AddHeader("Accept-Encoding", "booo");
+ AddHeader("Accept-Encoding", "gzip, deflate");
flags = VK_NODUMPHEADERS | NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_REDIRECT;
if (bSecure)
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 363761a888..5f454cf5a2 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -99,6 +99,9 @@ void CVkProto::OnLoggedOut()
debugLogA("CVkProto::OnLoggedOut");
m_bOnline = false;
+ if (m_hAPIConnection)
+ Netlib_CloseHandle(m_hAPIConnection);
+
if (m_pollingConn)
CallService(MS_NETLIB_SHUTDOWN, (WPARAM)m_pollingConn);