summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2018-01-31 11:03:05 +0500
committerElzorFox <elzorfox@ya.ru>2018-01-31 11:03:05 +0500
commitb05eab27cf16f2316694d43211fb31827ceea727 (patch)
treebfeb5d39b0200d3ebb50198e9b201beb32bf5b9d /protocols/VKontakte/src
parentac25aecfd65f1e68677ca93e0f26138fd9dc6f3e (diff)
VKontakte: ะก++ 11 scope for
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r--protocols/VKontakte/src/misc.cpp48
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp9
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp31
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp21
-rw-r--r--protocols/VKontakte/src/vk_pollserver.cpp4
-rw-r--r--protocols/VKontakte/src/vk_search.cpp6
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp16
7 files changed, 58 insertions, 77 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 95510c591d..453f886766 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -1069,9 +1069,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
res += SetBBCString(TranslateT("Attachments:"), iBBC, vkbbcB);
res.AppendChar('\n');
- for (auto it = jnAttachments.begin(); it != jnAttachments.end(); ++it) {
- const JSONNode &jnAttach = (*it);
-
+ for (auto &jnAttach : jnAttachments) {
res.AppendChar('\t');
CMStringW wszType(jnAttach["type"].as_mstring());
if (wszType == L"photo") {
@@ -1137,24 +1135,24 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
wszText.IsEmpty() ? L" " : wszText.c_str());
const JSONNode &jnCopyHystory = jnWall["copy_history"];
- for (auto aCHit = jnCopyHystory.begin(); aCHit != jnCopyHystory.end(); ++aCHit) {
- const JSONNode &jnCopyHystoryItem = (*aCHit);
-
- CMStringW wszCHText(jnCopyHystoryItem["text"].as_mstring());
- int iCHid = jnCopyHystoryItem["id"].as_int();
- int iCHfromID = jnCopyHystoryItem["from_id"].as_int();
- CMStringW wszCHUrl(FORMAT, L"https://vk.com/wall%d_%d", iCHfromID, iCHid);
- wszCHText.Replace(L"\n", L"\n\t\t");
- res.AppendFormat(L"\n\t\t%s: %s",
- SetBBCString(TranslateT("Wall post"), iBBC, vkbbcUrl, wszCHUrl).c_str(),
- wszCHText.IsEmpty() ? L" " : wszCHText.c_str());
-
- const JSONNode &jnSubAttachments = jnCopyHystoryItem["attachments"];
- if (jnSubAttachments) {
- debugLogA("CVkProto::GetAttachmentDescr SubAttachments");
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC);
- wszAttachmentDescr.Replace(L"\n", L"\n\t\t");
- res += L"\n\t\t" + wszAttachmentDescr;
+ if (jnCopyHystory) {
+ for (auto &jnCopyHystoryItem : jnCopyHystory) {
+ CMStringW wszCHText(jnCopyHystoryItem["text"].as_mstring());
+ int iCHid = jnCopyHystoryItem["id"].as_int();
+ int iCHfromID = jnCopyHystoryItem["from_id"].as_int();
+ CMStringW wszCHUrl(FORMAT, L"https://vk.com/wall%d_%d", iCHfromID, iCHid);
+ wszCHText.Replace(L"\n", L"\n\t\t");
+ res.AppendFormat(L"\n\t\t%s: %s",
+ SetBBCString(TranslateT("Wall post"), iBBC, vkbbcUrl, wszCHUrl).c_str(),
+ wszCHText.IsEmpty() ? L" " : wszCHText.c_str());
+
+ const JSONNode &jnSubAttachments = jnCopyHystoryItem["attachments"];
+ if (jnSubAttachments) {
+ debugLogA("CVkProto::GetAttachmentDescr SubAttachments");
+ CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC);
+ wszAttachmentDescr.Replace(L"\n", L"\n\t\t");
+ res += L"\n\t\t" + wszAttachmentDescr;
+ }
}
}
@@ -1285,9 +1283,7 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j
OBJLIST<CVkUserInfo> vkUsers(2, NumericKeySortT);
- for (auto it = jnFUsers.begin(); it != jnFUsers.end(); ++it) {
- const JSONNode &jnUser = (*it);
-
+ for (auto &jnUser : jnFUsers) {
int iUserId = jnUser["id"].as_int();
CMStringW wszNick(FORMAT, L"%s %s", jnUser["first_name"].as_mstring().c_str(), jnUser["last_name"].as_mstring().c_str());
CMStringW wszLink(FORMAT, L"https://vk.com/id%d", iUserId);
@@ -1297,9 +1293,7 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j
}
- for (auto it = jnMessages.begin(); it != jnMessages.end(); ++it) {
- const JSONNode &jnMsg = (*it);
-
+ for (auto &jnMsg : jnMessages) {
UINT uid = jnMsg["user_id"].as_int();
CVkUserInfo *vkUser = vkUsers.find((CVkUserInfo *)&uid);
CMStringW wszNick, wszUrl;
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 9594e80f11..fec559ad87 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -136,8 +136,7 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
for (int i = 0; i < cc->m_users.getCount(); i++)
cc->m_users[i].m_bDel = true;
- for (auto it = jnUsers.begin(); it != jnUsers.end(); ++it) {
- const JSONNode &jnUser = (*it);
+ for (auto &jnUser : jnUsers) {
if (!jnUser)
break;
@@ -195,8 +194,7 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
}
const JSONNode &jnMsgsUsers = jnResponse["msgs_users"];
- for (auto it = jnMsgsUsers.begin(); it != jnMsgsUsers.end(); ++it) {
- const JSONNode &jnUser = (*it);
+ for (auto &jnUser : jnMsgsUsers) {
LONG uid = jnUser["id"].as_int();
CVkChatUser *cu = cc->m_users.find((CVkChatUser*)&uid);
if (cu)
@@ -215,8 +213,7 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
if (jnMsgs) {
const JSONNode &jnItems = jnMsgs["items"];
if (jnItems) {
- for (auto it = jnItems.begin(); it != jnItems.end(); ++it) {
- const JSONNode &jnMsg = (*it);
+ for (auto &jnMsg : jnItems) {
if (!jnMsg)
break;
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp
index 6920e73f28..67502aee15 100644
--- a/protocols/VKontakte/src/vk_feed.cpp
+++ b/protocols/VKontakte/src/vk_feed.cpp
@@ -122,8 +122,7 @@ void CVkProto::CreateVkUserInfoList(OBJLIST<CVkUserInfo> &vkUsers, const JSONNod
const JSONNode &jnProfiles = jnResponse["profiles"];
if (jnProfiles)
- for (auto it = jnProfiles.begin(); it != jnProfiles.end(); ++it) {
- const JSONNode &jnProfile = (*it);
+ for (auto &jnProfile : jnProfiles) {
if (!jnProfile["id"])
continue;
LONG UserId = jnProfile["id"].as_int();
@@ -142,8 +141,7 @@ void CVkProto::CreateVkUserInfoList(OBJLIST<CVkUserInfo> &vkUsers, const JSONNod
const JSONNode &jnGroups = jnResponse["groups"];
if (jnGroups)
- for (auto it = jnGroups.begin(); it != jnGroups.end(); ++it) {
- const JSONNode &jnProfile = (*it);
+ for (auto &jnProfile : jnGroups) {
if (!jnProfile["id"])
continue;
LONG UserId = -jnProfile["id"].as_int();
@@ -189,8 +187,8 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo
if (jnPhotoItems) {
wszText = TranslateT("User was tagged in these photos:");
wszPopupText = wszText + TranslateT("(photos)");
- for (auto it = jnPhotoItems.begin(); it != jnPhotoItems.end(); ++it)
- wszText += L"\n" + GetVkPhotoItem((*it), m_vkOptions.BBCForNews());
+ for (auto &it : jnPhotoItems)
+ wszText += L"\n" + GetVkPhotoItem(it, m_vkOptions.BBCForNews());
}
}
}
@@ -202,8 +200,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo
const JSONNode &jnPhotoItems = jnPhotos["items"];
if (jnPhotoItems) {
wszPopupText += TranslateT("(photos)");
- for (auto it = jnPhotoItems.begin(); it != jnPhotoItems.end(); ++it) {
- const JSONNode &jnPhotoItem = (*it);
+ for (auto &jnPhotoItem : jnPhotoItems) {
wszText += GetVkPhotoItem(jnPhotoItem, m_vkOptions.BBCForNews()) + L"\n";
if (i == 0 && vkNewsItem->wszType == L"wall_photo") {
if (jnPhotoItem["post_id"]) {
@@ -301,8 +298,7 @@ CMStringW CVkProto::GetVkFeedback(const JSONNode &jnFeedback, VKObjType vkFeedba
const JSONNode &jnUsers = jnFeedback["items"];
CMStringW wszUsers;
- for (auto it = jnUsers.begin(); it != jnUsers.end(); ++it) {
- const JSONNode &jnUserItem = (*it);
+ for (auto &jnUserItem : jnUsers) {
if (!jnUserItem["from_id"])
continue;
iUserId = jnUserItem["from_id"].as_int();
@@ -513,8 +509,7 @@ void CVkProto::OnFriendAccepted(const JSONNode & jnFeedback)
{
const JSONNode &jnUsers = jnFeedback["items"];
- for (auto it = jnUsers.begin(); it != jnUsers.end(); ++it) {
- const JSONNode &jnUserItem = (*it);
+ for (auto &jnUserItem : jnUsers) {
if (!jnUserItem["from_id"])
continue;
@@ -668,8 +663,8 @@ void CVkProto::OnReceiveUnreadNews(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *p
OBJLIST<CVKNewsItem> vkNews(5, sttCompareVKNewsItems);
if (jnItems)
- for (auto it = jnItems.begin(); it != jnItems.end(); ++it) {
- CVKNewsItem *vkNewsItem = GetVkNewsItem((*it), vkUsers);
+ for (auto &it : jnItems) {
+ CVKNewsItem *vkNewsItem = GetVkNewsItem(it, vkUsers);
if (!vkNewsItem)
continue;
CVKNewsItem *vkNewsFoundItem = vkNews.find(vkNewsItem);
@@ -779,8 +774,8 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR
const JSONNode &jnItems = jnNotifications["items"];
if (jnItems)
- for (auto it = jnItems.begin(); it != jnItems.end(); ++it) {
- CVKNewsItem *vkNotificationItem = GetVkNotificationsItem((*it), vkUsers);
+ for (auto &it : jnItems) {
+ CVKNewsItem *vkNotificationItem = GetVkNotificationsItem(it, vkUsers);
if (!vkNotificationItem)
continue;
if (vkNotification.find(vkNotificationItem) == nullptr)
@@ -794,8 +789,8 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR
const JSONNode &jnItems = jnGroupInvates["items"];
if (jnItems)
- for (auto it = jnItems.begin(); it != jnItems.end(); ++it) {
- CVKNewsItem *vkNotificationItem = GetVkGroupInvates((*it), vkUsers);
+ for (auto &it : jnItems) {
+ CVKNewsItem *vkNotificationItem = GetVkGroupInvates(it, vkUsers);
if (!vkNotificationItem)
continue;
if (vkNotification.find(vkNotificationItem) == nullptr)
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index 9a7ebf0f95..cd37e5c30c 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -241,8 +241,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
debugLogA("CVkProto::OnReceiveMessages numMessages = %d", numMessages);
- for (auto it = jnMsgs.begin(); it != jnMsgs.end(); ++it) {
- const JSONNode &jnMsg = (*it);
+ for (auto &jnMsg : jnMsgs) {
if (!jnMsg) {
debugLogA("CVkProto::OnReceiveMessages pMsg == nullptr");
break;
@@ -378,9 +377,9 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
LIST<void> lufUsers(20, PtrKeySortT);
const JSONNode &jnUsers = jnResponse["users"];
if (jnUsers)
- for (auto it = jnUsers.begin(); it != jnUsers.end(); ++it) {
- int iUserId = (*it)["user_id"].as_int();
- int iStatus = (*it)["friend_status"].as_int();
+ for (auto &it : jnUsers) {
+ int iUserId = it["user_id"].as_int();
+ int iStatus = it["friend_status"].as_int();
// iStatus == 3 - user is friend
// uid < 0 - user is group
@@ -392,8 +391,8 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
const JSONNode &jnGroups = jnResponse["groups"];
if (jnGroups)
- for (auto it = jnGroups.begin(); it != jnGroups.end(); ++it) {
- int iUserId = 1000000000 + (*it).as_int();
+ for (auto &it : jnGroups) {
+ int iUserId = 1000000000 + it.as_int();
if (lufUsers.indexOf((HANDLE)iUserId) != -1)
continue;
@@ -403,11 +402,11 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
CMStringA szGroupIds;
- for (auto it = jnDlgs.begin(); it != jnDlgs.end(); ++it) {
- if (!(*it))
+ for (auto &it : jnDlgs) {
+ if (!it)
break;
- int numUnread = (*it)["unread"].as_int();
- const JSONNode &jnDlg = (*it)["message"];
+ int numUnread = it["unread"].as_int();
+ const JSONNode &jnDlg = it["message"];
if (!jnDlg)
break;
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp
index 77fceab9a3..49c9b017eb 100644
--- a/protocols/VKontakte/src/vk_pollserver.cpp
+++ b/protocols/VKontakte/src/vk_pollserver.cpp
@@ -81,8 +81,8 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates)
bool bNonEdited = true;
MCONTACT hContact;
- for (auto it = jnUpdates.begin(); it != jnUpdates.end(); ++it) {
- const JSONNode &jnChild = (*it).as_array();
+ for (auto &it : jnUpdates) {
+ const JSONNode &jnChild = it.as_array();
switch (jnChild[json_index_t(0)].as_int()) {
case VKPOLL_MSG_DELFLAGS:
if (jnChild.size() < 4)
diff --git a/protocols/VKontakte/src/vk_search.cpp b/protocols/VKontakte/src/vk_search.cpp
index 085e382e1d..3796fbb530 100644
--- a/protocols/VKontakte/src/vk_search.cpp
+++ b/protocols/VKontakte/src/vk_search.cpp
@@ -112,8 +112,7 @@ void CVkProto::OnSearch(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
}
const JSONNode &jnItems = !jnResponse["items"] ? jnResponse : jnResponse["items"];
- for (auto it = jnItems.begin(); it != jnItems.end(); ++it) {
- const JSONNode &jnRecord = (*it);
+ for (auto &jnRecord : jnItems) {
if (!jnRecord)
break;
@@ -170,8 +169,7 @@ void CVkProto::OnSearchByMail(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
return;
}
- for (auto it = jnItems.begin(); it != jnItems.end(); ++it) {
- const JSONNode &jnRecord = (*it);
+ for (auto &jnRecord : jnItems) {
if (!jnRecord)
break;
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index a9016dde16..d49242f3ea 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -606,8 +606,8 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
if (!isChatRoom(hContact) && !IsGroupUser(hContact))
arContacts.insert((HANDLE)hContact);
- for (auto it = jnUsers.begin(); it != jnUsers.end(); ++it) {
- hContact = SetContactInfo((*it));
+ for (auto &it : jnUsers) {
+ hContact = SetContactInfo(it);
if (hContact)
arContacts.remove((HANDLE)hContact);
}
@@ -642,8 +642,8 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
return;
debugLogA("CVkProto::OnReceiveUserInfo AuthRequests");
- for (auto it = jnItems.begin(); it != jnItems.end(); ++it) {
- LONG userid = (*it).as_int();
+ for (auto it : jnItems) {
+ LONG userid = it.as_int();
if (userid == 0)
break;
hContact = FindUser(userid, true);
@@ -668,9 +668,7 @@ void CVkProto::OnReceiveGroupInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
if (!jnResponse)
return;
- for (auto it = jnResponse.begin(); it != jnResponse.end(); ++it) {
- const JSONNode &jnItem = (*it);
-
+ for (auto &jnItem : jnResponse) {
int iGroupId = (-1)*jnItem["id"].as_int();
bool bIsMember = jnItem["is_member"].as_bool();
@@ -769,8 +767,8 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
const JSONNode &jnItems = jnResponse["items"];
if (jnItems)
- for (auto it = jnItems.begin(); it != jnItems.end(); ++it) {
- MCONTACT hContact = SetContactInfo((*it), true);
+ for (auto &it : jnItems) {
+ MCONTACT hContact = SetContactInfo(it, true);
if (hContact == 0 || hContact == INVALID_CONTACT_ID)
continue;