diff options
| -rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
| -rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 1 | ||||
| -rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 1 | ||||
| -rw-r--r-- | protocols/VKontakte/src/vk_queue.cpp | 2 | ||||
| -rw-r--r-- | protocols/VKontakte/src/vk_struct.cpp | 4 | ||||
| -rw-r--r-- | protocols/VKontakte/src/vk_struct.h | 6 | ||||
| -rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 49 |
7 files changed, 47 insertions, 18 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 7973129c49..23a5262572 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 19
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 462de8a9d1..b9aa9b1c5f 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -34,6 +34,7 @@ CVkProto::CVkProto(const char *szModuleName, const wchar_t *pwszUserName) : m_chats(1, NumericKeySortT),
m_ChatsTyping(1, NumericKeySortT),
m_iLoadHistoryTask(0),
+ m_iLoadCListIntervalCounter(0),
m_bNotifyForEndLoadingHistory(false),
m_bNotifyForEndLoadingHistoryAllContact(false),
m_hAPIConnection(nullptr),
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 21f00c6280..605a446a5e 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -252,6 +252,7 @@ private: m_tPoolThreadTimer;
int m_iLoadHistoryTask;
+ int m_iLoadCListIntervalCounter;
OBJLIST<CVkChatInfo> m_chats;
OBJLIST<CVKChatContactTypingParam> m_ChatsTyping;
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index 6e71d6b8fc..0ccc372d05 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -190,6 +190,8 @@ void CVkProto::WorkerThread(void*) if (!(pReq->m_bApiReq))
lWaitingTime = 0;
+ else if (pReq->m_priority == AsyncHttpRequest::rpLowCListEvents) // for 'error 9' fix
+ lWaitingTime += m_vkOptions.iTimeoutForUserGet > 60000 ? 5000 : m_vkOptions.iTimeoutForUserGet;
}
if (m_bTerminated)
diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp index ca17e025a5..4f1d47af73 100644 --- a/protocols/VKontakte/src/vk_struct.cpp +++ b/protocols/VKontakte/src/vk_struct.cpp @@ -213,6 +213,7 @@ CVKOptions::CVKOptions(PROTO_INTERFACE* proto) : bShowVkDeactivateEvents(proto, "ShowVkDeactivateEvents", true),
bStickerBackground(proto, "StickerBackground", false),
bFilterAudioMessages(proto, "FilterAudioMessages", false),
+ bRepeatRequestAfterEmptyFrame(proto, "RepeatRequestAfterEmptyFrame", false),
bShowProtoMenuItem0(proto, "ShowProtoMenuItem0", true),
bShowProtoMenuItem1(proto, "ShowProtoMenuItem1", true),
@@ -240,7 +241,8 @@ CVKOptions::CVKOptions(PROTO_INTERFACE* proto) : iInvisibleInterval(proto, "InvisibleInterval", 10),
iMaxFriendsCount(proto, "MaxFriendsCount", 1000),
iStickerSize(proto, "StickerSize", 128),
- iTimeoutAfterUserGet(proto, "TimeoutAfterUserGet", 0),
+ iTimeoutForUserGet(proto, "TimeoutForUserGet", 0),
+ iLoadCListInterval(proto, "LoadCListInterval", 1),
pwszDefaultGroup(proto, "ProtoGroup", L"VKontakte"),
pwszVKLang(proto, "VKLang", nullptr)
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index 45b3c34a4b..34874efd56 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. struct AsyncHttpRequest : public MTHttpRequest<CVkProto>
{
- enum RequestPriority { rpLowLow, rpLow, rpMedium, rpHigh, rpRestart, rpCaptcha };
+ enum RequestPriority { rpLowLow, rpLowCListEvents, rpLow, rpMedium, rpHigh, rpRestart, rpCaptcha };
AsyncHttpRequest();
AsyncHttpRequest(CVkProto*, int iRequestType, LPCSTR szUrl, bool bSecure, MTHttpRequestHandler pFunc, RequestPriority rpPriority = rpMedium);
@@ -310,6 +310,7 @@ struct CVKOptions { CMOption<uint8_t> bShowVkDeactivateEvents;
CMOption<uint8_t> bStickerBackground;
CMOption<uint8_t> bFilterAudioMessages;
+ CMOption<uint8_t> bRepeatRequestAfterEmptyFrame;
CMOption<uint8_t> bShowProtoMenuItem0;
CMOption<uint8_t> bShowProtoMenuItem1;
@@ -327,7 +328,8 @@ struct CVKOptions { CMOption<uint32_t> iMaxFriendsCount;
CMOption<uint32_t> iStickerSize;
- CMOption<uint32_t> iTimeoutAfterUserGet;
+ CMOption<uint32_t> iTimeoutForUserGet;
+ CMOption<uint32_t> iLoadCListInterval;
CMOption<wchar_t*> pwszDefaultGroup;
CMOption<wchar_t*> pwszVKLang;
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index fe33329ad2..69548e32ea 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -118,7 +118,12 @@ static void CALLBACK VKUnsetTimer(void*) void CVkProto::OnTimerTic()
{
- RetrieveUsersInfo(true);
+
+ if (++m_iLoadCListIntervalCounter >= m_vkOptions.iLoadCListInterval) {
+ RetrieveUsersInfo(true);
+ m_iLoadCListIntervalCounter = 0;
+ }
+
RetrieveUnreadEvents();
SetServerStatus(m_iDesiredStatus);
}
@@ -392,6 +397,8 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool bFlag, VKContactT int iNewStatus = (jnItem["online"].as_int() == 0) ? ID_STATUS_OFFLINE : ID_STATUS_ONLINE;
setWord(hContact, "Status", iNewStatus);
+
+ db_unset(hContact, m_szModuleName, "EmptyFrameOffline");
if (iNewStatus == ID_STATUS_ONLINE) {
db_set_dw(hContact, "BuddyExpectator", "LastSeen", (uint32_t)time(0));
@@ -575,7 +582,13 @@ void CVkProto::RetrieveUsersFrameInfo(CMStringA& szUserIds, bool bFreeOffline, b if (!IsOnline() || szUserIds.IsEmpty())
return;
- Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.RetrieveUsersFrameInfo", true, &CVkProto::OnReceiveUserFrameInfo)
+ Push(new AsyncHttpRequest(this,
+ REQUEST_POST,
+ "/method/execute.RetrieveUsersFrameInfo",
+ true,
+ &CVkProto::OnReceiveUserFrameInfo,
+ bFreeOffline ? AsyncHttpRequest::rpLowCListEvents : AsyncHttpRequest::rpMedium
+ )
<< CHAR_PARAM("userids", szUserIds)
<< CHAR_PARAM("fields", (bFreeOffline ? "online,status,can_write_private_message" : szFieldsName))
<< INT_PARAM("norepeat", (int)bRepeat)
@@ -606,13 +619,17 @@ void CVkProto::OnReceiveUserFrameInfo(MHttpResponse* reply, AsyncHttpRequest* pR mir_free(pReq->pUserInfo);
}
- if (!jnResponse["norepeat"].as_bool() && jnResponse["usercount"].as_int() == 0) {
+ bool bEmptyFrame = !jnResponse["norepeat"].as_bool() && jnResponse["usercount"].as_int() == 0;
+
+
+
+ if (bEmptyFrame && m_vkOptions.bRepeatRequestAfterEmptyFrame) {
Sleep(5000);
RetrieveUsersFrameInfo(szUserIds, true, false, true);
return;
}
-
- LIST<void> arContacts(10, PtrKeySortT);
+
+ LIST<void> arContacts(100, PtrKeySortT);
for (auto& hContact : AccContacts())
if (!isChatRoom(hContact) && !IsGroupUser(hContact)) {
@@ -642,20 +659,24 @@ void CVkProto::OnReceiveUserFrameInfo(MHttpResponse* reply, AsyncHttpRequest* pR if (iUserId == m_iMyUserId || iUserId == VK_FEED_USER)
continue;
- int iContactStatus = getWord(cc, "Status", ID_STATUS_OFFLINE);
-
- if ((iContactStatus == ID_STATUS_ONLINE)
- || (iContactStatus == ID_STATUS_INVISIBLE && time(0) - getDword(cc, "InvisibleTS", 0) >= m_vkOptions.iInvisibleInterval * 60LL)) {
- setWord(cc, "Status", ID_STATUS_OFFLINE);
- SetMirVer(cc, -1);
- db_unset(cc, m_szModuleName, "ListeningTo");
+ if (getBool(cc, "EmptyFrameOffline")) {
+ int iContactStatus = getWord(cc, "Status", ID_STATUS_OFFLINE);
+ if ((iContactStatus == ID_STATUS_ONLINE)
+ || (iContactStatus == ID_STATUS_INVISIBLE && time(0) - getDword(cc, "InvisibleTS", 0) >= m_vkOptions.iInvisibleInterval * 60LL)) {
+ setWord(cc, "Status", ID_STATUS_OFFLINE);
+ SetMirVer(cc, -1);
+ db_unset(cc, m_szModuleName, "ListeningTo");
+ }
+ db_unset(cc, m_szModuleName, "EmptyFrameOffline");
}
+ else
+ setByte(cc, "EmptyFrameOffline", 1);
}
arContacts.destroy();
- if (m_vkOptions.iTimeoutAfterUserGet) // for 'error 9' fix
- Sleep(m_vkOptions.iTimeoutAfterUserGet > 5000 ? 5000 : m_vkOptions.iTimeoutAfterUserGet);
+ if (m_vkOptions.iTimeoutForUserGet) // for 'error 9' fix
+ Sleep(m_vkOptions.iTimeoutForUserGet > 60000 ? 5000 : m_vkOptions.iTimeoutForUserGet);
const JSONNode& jnRequests = jnResponse["requests"];
if (!jnRequests)
|
