summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2015-02-18 10:35:21 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2015-02-18 10:35:21 +0000
commitd407d10b3c799fd0c4b323d87cf45c56197aedfc (patch)
tree423e73af5ceac78d3624e1eee059549c93824931 /protocols
parent776cf2cb82f9c95e18acbc2ec37ab6dbb8cebc74 (diff)
VKontakte:
LongPollServer always use ssl now fix false positives for set message read time and status invisible version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@12179 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/misc.cpp10
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp1
-rw-r--r--protocols/VKontakte/src/vk_proto.h3
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp19
5 files changed, 21 insertions, 14 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 71c109a042..7cb2638cf4 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -282,11 +282,11 @@ MCONTACT CVkProto::FindChat(LONG dwUserid)
/////////////////////////////////////////////////////////////////////////////////////////
-bool CVkProto::CheckMid(int guid)
+bool CVkProto::CheckMid(LIST<void> &lList, int guid)
{
- for (int i = m_sendIds.getCount() - 1; i >= 0; i--)
- if ((int)m_sendIds[i] == guid) {
- m_sendIds.remove(i);
+ for (int i = lList.getCount() - 1; i >= 0; i--)
+ if ((int)lList[i] == guid) {
+ lList.remove(i);
return true;
}
@@ -1142,9 +1142,11 @@ CMString CVkProto::GetFwdMessages(JSONNODE *pMessages, BBCSupport iBBC)
void CVkProto::SetInvisible(MCONTACT hContact)
{
+ debugLogA("CVkProto::SetInvisible %d", getDword(hContact, "ID", -1));
if (getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) {
setWord(hContact, "Status", ID_STATUS_INVISIBLE);
SetMirVer(hContact, 1);
+ debugLogA("CVkProto::SetInvisible %d set ID_STATUS_INVISIBLE", getDword(hContact, "ID", -1));
}
setDword(hContact, "InvisibleTS", time(NULL));
} \ No newline at end of file
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 12403c908a..ee7100bdab 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 47
+#define __BUILD_NUM 48
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index eb156680b4..ad34752ad3 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -30,6 +30,7 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
PROTO<CVkProto>(szModuleName, ptszUserName),
m_arRequestsQueue(10),
m_sendIds(3, PtrKeySortT),
+ m_incIds(3, PtrKeySortT),
m_cookies(5),
m_msgId(1),
m_chats(1, NumericKeySortT)
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 8bd95bdc02..5ce2dc5571 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -392,7 +392,7 @@ struct CVkProto : public PROTO<CVkProto>
MCONTACT FindUser(LONG userid, bool bCreate = false);
MCONTACT FindChat(LONG dwUserid);
- bool CheckMid(int guid);
+ bool CheckMid(LIST<void> &lList, int guid);
JSONNODE* CheckJsonResponse(AsyncHttpRequest *pReq, NETLIBHTTPREQUEST *reply, JSONROOT&);
bool CheckJsonResult(AsyncHttpRequest *pReq, JSONNODE*);
@@ -630,6 +630,7 @@ private:
ULONG m_msgId;
LIST<void> m_sendIds;
+ LIST<void> m_incIds;
static INT_PTR CALLBACK OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index a0aadbfbdd..e5f358da48 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -715,11 +715,13 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
debugLogA("CVkProto::OnReceiveMessages i = %d, mid = %d, datetime = %d, isOut = %d, isRead = %d, uid = %d", i, mid, datetime, isOut, isRead, uid);
- if (!CheckMid(mid)) {
+ if (!CheckMid(m_sendIds, mid)) {
debugLogA("CVkProto::OnReceiveMessages ProtoChainRecvMsg");
ProtoChainRecvMsg(hContact, &recv);
if (mid > getDword(hContact, "lastmsgid", -1))
setDword(hContact, "lastmsgid", mid);
+ if (!isOut)
+ m_incIds.insert((HANDLE)mid);
}
}
@@ -794,6 +796,7 @@ void CVkProto::RetrievePollingInfo()
if (!IsOnline())
return;
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.getLongPollServer.json", true, &CVkProto::OnReceivePollingInfo)
+ << INT_PARAM("use_ssl", 1)
<< VER_API);
}
@@ -843,14 +846,14 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates)
for (int i = 0; (pChild = json_at(pUpdates, i)) != NULL; i++) {
switch (json_as_int(json_at(pChild, 0))) {
case VKPOLL_MSG_DELFLAGS:
+ msgid = json_as_int(json_at(pChild, 1));
flags = json_as_int(json_at(pChild, 2));
uid = json_as_int(json_at(pChild, 3));
hContact = FindUser(uid);
- if (hContact != NULL) {
- if (flags & VKFLAG_MSGUNREAD) {
- setDword(hContact, "LastMsgReadTime", time(NULL));
- SetSrmmReadStatus(hContact);
- }
+
+ if (hContact != NULL && (flags & VKFLAG_MSGUNREAD) && !CheckMid(m_incIds, msgid)) {
+ setDword(hContact, "LastMsgReadTime", time(NULL));
+ SetSrmmReadStatus(hContact);
if (m_bUserForceOnlineOnActivity)
SetInvisible(hContact);
}
@@ -862,7 +865,7 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates)
// skip outgoing messages sent from a client
flags = json_as_int(json_at(pChild, 2));
if (flags & VKFLAG_MSGOUTBOX && !(flags & VKFLAG_MSGCHAT))
- if (CheckMid(msgid))
+ if (CheckMid(m_sendIds, msgid))
break;
if (!mids.IsEmpty())
@@ -931,7 +934,7 @@ int CVkProto::PollServer()
int iPollConnRetry = MAX_RETRIES;
NETLIBHTTPREQUEST *reply;
CMStringA szReqUrl;
- szReqUrl.AppendFormat("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);
+ szReqUrl.AppendFormat("https://%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)
NETLIBHTTPREQUEST req = { sizeof(req) };
req.requestType = REQUEST_GET;