summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_thread.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-30 18:40:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-30 18:40:17 +0000
commit4239659c7d805936ca4defc3c418224ffbce12a6 (patch)
treef1ba3fa99cbe856adf23eca15a8450ed050690fd /protocols/VKontakte/src/vk_thread.cpp
parentc00d1d01ba72a6a00a915dd9c303e9322264f2ee (diff)
VK: contact list sync option
git-svn-id: http://svn.miranda-ng.org/main/trunk@7960 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_thread.cpp')
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 384fee7270..eb7e1a5344 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -296,6 +296,13 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
if (pResponse == NULL)
return;
+ bool bCleanContacts = getByte("AutoClean", 0) != 0;
+ LIST<void> arContacts(10, PtrKeySortT);
+ if (bCleanContacts)
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ if (!isChatRoom(hContact))
+ arContacts.insert(hContact);
+
for (int i = 0; (pInfo = json_at(pResponse, i)) != NULL; i++) {
ptrT szValue(json_as_string(json_get(pInfo, "uid")));
if (szValue == NULL)
@@ -303,6 +310,7 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
CMString tszNick;
HANDLE hContact = FindUser(_ttoi(szValue), true);
+ arContacts.remove(hContact);
szValue = json_as_string(json_get(pInfo, "first_name"));
if (szValue) {
setTString(hContact, "FirstName", szValue);
@@ -338,6 +346,10 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
if (szValue && *szValue)
setTString(hContact, "Phone", szValue);
}
+
+ if (bCleanContacts)
+ for (int i = 0; i < arContacts.getCount(); i++)
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)arContacts[i], 0);
}
/////////////////////////////////////////////////////////////////////////////////////////