summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/VKontakte/src/misc.cpp4
-rw-r--r--protocols/VKontakte/src/vk_avatars.cpp1
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp1
-rw-r--r--protocols/VKontakte/src/vk_proto.h1
-rw-r--r--protocols/VKontakte/src/vk_queue.cpp11
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp22
6 files changed, 24 insertions, 16 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index d7f678a29a..f8ef8c415c 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -211,7 +211,7 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul
AsyncHttpRequest::AsyncHttpRequest()
{
cbSize = sizeof(NETLIBHTTPREQUEST);
-
+ m_bApiReq = true;
AddHeader("Connection", "keep-alive");
AddHeader("Accept-Encoding", "booo");
}
@@ -219,7 +219,7 @@ AsyncHttpRequest::AsyncHttpRequest()
AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url, bool bSecure, VK_REQUEST_HANDLER pFunc)
{
cbSize = sizeof(NETLIBHTTPREQUEST);
-
+ m_bApiReq = true;
AddHeader("Connection", "keep-alive");
AddHeader("Accept-Encoding", "booo");
diff --git a/protocols/VKontakte/src/vk_avatars.cpp b/protocols/VKontakte/src/vk_avatars.cpp
index 560bf5dd75..a2c1923a1e 100644
--- a/protocols/VKontakte/src/vk_avatars.cpp
+++ b/protocols/VKontakte/src/vk_avatars.cpp
@@ -83,6 +83,7 @@ INT_PTR CVkProto::SvcGetAvatarInfo(WPARAM wParam, LPARAM lParam)
pReq->pUserInfo = (char*)AI->hContact;
pReq->m_pFunc = &CVkProto::OnReceiveAvatar;
pReq->requestType = REQUEST_GET;
+ pReq->m_bApiReq = false;
Push(pReq);
debugLogA("Requested to read an avatar from '%s'", szUrl);
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 59f896c6f5..9d0ac6a4b1 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -114,7 +114,6 @@ int CVkProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
mi.flags = CMIF_TCHAR;
mi.position = -200001000+1;
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_HISTORY);
- mi.position = -201001000+102;
mi.ptszName = LPGENT("Reload all messages from vk.com");
Menu_AddContactMenuItem(&mi);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index aa5497f93d..ba6c0aa8d6 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -36,6 +36,7 @@ struct AsyncHttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject
bool bNeedsRestart, bIsMainConn;
VK_REQUEST_HANDLER m_pFunc;
void *pUserInfo;
+ bool m_bApiReq;
};
struct PARAM
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp
index c1934fa190..b736fad51a 100644
--- a/protocols/VKontakte/src/vk_queue.cpp
+++ b/protocols/VKontakte/src/vk_queue.cpp
@@ -91,10 +91,13 @@ void CVkProto::WorkerThread(void*)
else {
// Initialize new OAuth session
extern char szBlankUrl[];
- //need rework
Push(new AsyncHttpRequest(this, REQUEST_GET, "/oauth/authorize", false, &CVkProto::OnOAuthAuthorize)
- << INT_PARAM("client_id", VK_APP_ID) << CHAR_PARAM("scope", "friends,photos,audio,video,wall,messages,offline")
- << CHAR_PARAM("redirect_uri", szBlankUrl) << CHAR_PARAM("display", "wap") << CHAR_PARAM("response_type", "token"));
+ << INT_PARAM("client_id", VK_APP_ID)
+ << CHAR_PARAM("scope", "friends,photos,audio,video,wall,messages,offline,status")
+ << CHAR_PARAM("redirect_uri", szBlankUrl)
+ << CHAR_PARAM("display", "mobile")
+ << CHAR_PARAM("response_type", "token")
+ << VER_API)->m_bApiReq = false;;
}
while(true) {
@@ -112,7 +115,7 @@ void CVkProto::WorkerThread(void*)
pReq = m_arRequestsQueue[0];
m_arRequestsQueue.remove(0);
- need_sleep = (m_arRequestsQueue.getCount() > 1); // more than two to not gather
+ need_sleep = (m_arRequestsQueue.getCount() > 1) && (pReq->m_bApiReq); // more than two to not gather
}
ExecuteRequest(pReq);
if (need_sleep) // There can be maximum 3 requests to API methods per second from a client
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 4e534ec2e9..02d2199fba 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -230,7 +230,7 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
/////////////////////////////////////////////////////////////////////////////////////////
-static char fieldsName[] = "id, first_name, last_name, photo_100, sex, country, timezone, contacts, online, status, about";
+static char fieldsName[] = "id, first_name, last_name, photo_100, sex, timezone, contacts, online, status, about";
void CVkProto::RetrieveUserInfo(LONG userID)
{
@@ -333,9 +333,12 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
setTString(hContact, "Phone", szValue);
szValue = json_as_string(json_get(pRecord, "status"));
- if (szValue && *szValue)
- if (_tcscmp(db_get_tsa(hContact, "CList", "StatusMsg"), szValue))
- db_set_ts(hContact, "CList", "StatusMsg", szValue);
+ if (szValue && *szValue) {
+ ptrT tszOldStatus(db_get_tsa(hContact, "CList", "StatusMsg"));
+ if (tszOldStatus)
+ if (_tcscmp(tszOldStatus, szValue))
+ db_set_ts(hContact, "CList", "StatusMsg", szValue);
+ }
szValue = json_as_string(json_get(pRecord, "about"));
if (szValue && *szValue)
@@ -425,8 +428,9 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
szValue = json_as_string(json_get(pInfo, "status"));
if (szValue && *szValue) {
ptrT tszOldStatus(db_get_tsa(hContact, "CList", "StatusMsg"));
- if (_tcscmp(tszOldStatus, szValue))
- db_set_ts(hContact, "CList", "StatusMsg", szValue);
+ if (tszOldStatus)
+ if (_tcscmp(tszOldStatus, szValue))
+ db_set_ts(hContact, "CList", "StatusMsg", szValue);
}
szValue = json_as_string(json_get(pInfo, "about"));
@@ -548,7 +552,6 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
if (!m_bMarkReadOnReply)
MarkMessagesRead(mids);
- RetrieveUsersInfo();
}
void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
@@ -610,6 +613,7 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
MarkMessagesRead(hContact);
}
}
+ RetrieveUsersInfo();
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -828,10 +832,10 @@ int CVkProto::PollServer()
{
debugLogA("CVkProto::PollServer");
- //need rework
NETLIBHTTPREQUEST req = { sizeof(req) };
req.requestType = REQUEST_GET;
- req.szUrl = NEWSTR_ALLOCA(CMStringA().Format("http://%s?act=a_check&key=%s&ts=%s&wait=25&access_token=%s", m_pollingServer, m_pollingKey, m_pollingTs, m_szAccessToken));
+ req.szUrl = NEWSTR_ALLOCA(CMStringA().Format("http://%s?act=a_check&key=%s&ts=%s&wait=25&access_token=%s&mode=%d", m_pollingServer, m_pollingKey, m_pollingTs, m_szAccessToken, 106));
+ // see mode parametr description on https://vk.com/dev/using_longpoll (Russian version)
req.flags = VK_NODUMPHEADERS | NLHRF_PERSISTENT;
req.timeout = 30000;
req.nlc = m_pollingConn;