diff options
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 34 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.cpp | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.h | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 11 |
6 files changed, 46 insertions, 9 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 2d252bf69c..26b813a19a 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -545,6 +545,38 @@ void CVkProto::ApplyCookies(AsyncHttpRequest *pReq) /////////////////////////////////////////////////////////////////////////////////////////
+bool CVkProto::IsAuthContactLater(MCONTACT hContact)
+{
+ if (hContact == 0
+ || hContact == INVALID_CONTACT_ID
+ || isChatRoom(hContact)
+ || IsGroupUser(hContact)
+ || getDword(hContact, "ReqAuthTime") == 0
+ || getBool(hContact, "friend"))
+ return false;
+
+ if (time(0) - getDword(hContact, "ReqAuthTime") >= m_vkOptions.iReqAuthTimeLater) {
+ db_unset(hContact, m_szModuleName, "ReqAuthTime");
+ return false;
+ }
+
+ return true;
+}
+
+bool CVkProto::AddAuthContactLater(MCONTACT hContact)
+{
+ if (hContact == 0
+ || hContact == INVALID_CONTACT_ID
+ || isChatRoom(hContact)
+ || IsGroupUser(hContact)
+ || getDword(hContact, "ReqAuthTime") != 0
+ || getBool(hContact, "friend"))
+ return false;
+
+ setDword(hContact, "ReqAuthTime", (DWORD)time(0));
+ return true;
+}
+
void __cdecl CVkProto::DBAddAuthRequestThread(void *p)
{
CVkDBAddAuthRequestThreadParam *param = (CVkDBAddAuthRequestThreadParam *)p;
@@ -599,7 +631,7 @@ MCONTACT CVkProto::MContactFromDbEvent(MEVENT hDbEvent) return INVALID_CONTACT_ID;
MCONTACT hContact = DbGetAuthEventContact(&dbei);
- db_unset(hContact, m_szModuleName, "ReqAuth");
+ db_unset(hContact, m_szModuleName, "ReqAuthTime");
return hContact;
}
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index aa0365ba93..e67758ac8f 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 9
-#define __BUILD_NUM 2
+#define __RELEASE_NUM 10
+#define __BUILD_NUM 0
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 3e5e888c79..b6c47ad180 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -343,6 +343,8 @@ private: CMStringW RunRenameNick(LPCWSTR pwszOldName);
void GrabCookies(NETLIBHTTPREQUEST *nhr);
void ApplyCookies(AsyncHttpRequest*);
+ bool IsAuthContactLater(MCONTACT hContact);
+ bool AddAuthContactLater(MCONTACT hContact);
void __cdecl DBAddAuthRequestThread(void *p);
void DBAddAuthRequest(const MCONTACT hContact, bool bAdded = false);
MCONTACT MContactFromDbEvent(MEVENT hDbEvent);
diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp index 8524d18538..c143e18093 100644 --- a/protocols/VKontakte/src/vk_struct.cpp +++ b/protocols/VKontakte/src/vk_struct.cpp @@ -149,7 +149,7 @@ CVkChatUser* CVkChatInfo::GetUserById(int user_id) /////////////////////////////////////////////////////////////////////////////////////////
-CVKOptions::CVKOptions(PROTO_INTERFACE *proto) :
+CVKOptions::CVKOptions(PROTO_INTERFACE* proto) :
bLoadLastMessageOnMsgWindowsOpen(proto, "LoadLastMessageOnMsgWindowsOpen", true),
bLoadOnlyFriends(proto, "LoadOnlyFriends", false),
bServerDelivery(proto, "BsDirect", true),
@@ -215,6 +215,7 @@ CVKOptions::CVKOptions(PROTO_INTERFACE *proto) : iBBCForNews(proto, "BBCForNews", BBCSupport::bbcBasic),
iBBCForAttachments(proto, "BBCForAttachments", BBCSupport::bbcBasic),
+ iReqAuthTimeLater(proto, "ReqAuthTimeLater", 60 * 60 * 24),
iNewsInterval(proto, "NewsInterval", 15),
iNotificationsInterval(proto, "NotificationsInterval", 1),
iNewsAutoClearHistoryInterval(proto, "NewsAutoClearHistoryInterval", 60 * 60 * 24 * 3),
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index 5b4609c681..c50e03aa51 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -307,6 +307,7 @@ struct CVKOptions { CMOption<BYTE> bShowProtoMenuItem5;
CMOption<BYTE> bShowProtoMenuItem6;
+ CMOption<DWORD> iReqAuthTimeLater;
CMOption<DWORD> iNewsInterval;
CMOption<DWORD> iNotificationsInterval;
CMOption<DWORD> iNewsAutoClearHistoryInterval;
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 087cbe418c..b61e2926e5 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -328,7 +328,7 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) RetrieveUserInfo(m_myUserId);
TrackVisitor();
RetrieveUnreadMessages();
- RetrieveFriends();
+ RetrieveFriends(m_vkOptions.bLoadOnlyFriends);
RetrievePollingInfo();
}
@@ -706,9 +706,9 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe break;
MCONTACT hContact = FindUser(userid, true);
- if (!getBool(hContact, "ReqAuth")) {
+ if (!IsAuthContactLater(hContact)) {
RetrieveUserInfo(userid);
- setByte(hContact, "ReqAuth", 1);
+ AddAuthContactLater(hContact);
CVkDBAddAuthRequestThreadParam *param = new CVkDBAddAuthRequestThreadParam(hContact, false);
ForkThread(&CVkProto::DBAddAuthRequestThread, (void *)param);
}
@@ -817,7 +817,6 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq for (auto &hContact : AccContacts()) {
if (!isChatRoom(hContact) && !IsGroupUser(hContact))
setByte(hContact, "Auth", 1);
- db_unset(hContact, m_szModuleName, "ReqAuth");
SetMirVer(hContact, -1);
if (bCleanContacts && !isChatRoom(hContact))
arContacts.insert((HANDLE)hContact);
@@ -834,6 +833,7 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq arContacts.remove((HANDLE)hContact);
setByte(hContact, "Auth", 0);
+ db_unset(hContact, m_szModuleName, "ReqAuthTime");
}
if (bCleanContacts)
@@ -843,7 +843,8 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq bool bIsFriendGroup = IsGroupUser(hContact) && getBool(hContact, "friend");
if (userID == m_myUserId || userID == VK_FEED_USER || bIsFriendGroup)
continue;
- DeleteContact(hContact);
+ if (!IsAuthContactLater(hContact))
+ DeleteContact(hContact);
}
arContacts.destroy();
|