summaryrefslogtreecommitdiff
path: root/protocols/VKontakte
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-21 18:38:40 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-21 18:40:14 +0300
commit9d0174ebe2bd005418855b18f737c36d5c20ab4a (patch)
treedf3bce783a32e7cfcf14952da53a7b1adeb72f84 /protocols/VKontakte
parent007e02e4152c7282af4b8f844d927f223ce6f69f (diff)
VK: C++'11 iterators
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r--protocols/VKontakte/src/misc.cpp8
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp17
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp12
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp32
4 files changed, 34 insertions, 35 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 98e9020460..c8479c6911 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -537,15 +537,15 @@ void CVkProto::ApplyCookies(AsyncHttpRequest *pReq)
debugLogA("CVkProto::ApplyCookies");
CMStringA szCookie;
- for (int i = 0; i < m_cookies.getCount(); i++) {
- if (!strstr(pReq->m_szUrl, m_cookies[i].m_domain))
+ for (auto &it : m_cookies) {
+ if (!strstr(pReq->m_szUrl, it->m_domain))
continue;
if (!szCookie.IsEmpty())
szCookie.Append("; ");
- szCookie.Append(m_cookies[i].m_name);
+ szCookie.Append(it->m_name);
szCookie.AppendChar('=');
- szCookie.Append(m_cookies[i].m_value);
+ szCookie.Append(it->m_value);
}
if (!szCookie.IsEmpty())
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 8eb1e3ab46..4e82018e1a 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -133,8 +133,8 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
const JSONNode &jnUsers = jnResponse["users"];
if (jnUsers) {
- for (int i = 0; i < cc->m_users.getCount(); i++)
- cc->m_users[i].m_bDel = true;
+ for (auto &it : cc->m_users)
+ it->m_bDel = true;
for (auto &jnUser : jnUsers) {
if (!jnUser)
@@ -223,10 +223,9 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
}
}
- for (int j = 0; j < cc->m_msgs.getCount(); j++) {
- CVkChatMessage &p = cc->m_msgs[j];
- AppendChatMessage(cc, p.m_uid, p.m_date, p.m_wszBody, p.m_bHistory, p.m_bIsAction);
- }
+ for (auto &p : cc->m_msgs)
+ AppendChatMessage(cc, p->m_uid, p->m_date, p->m_wszBody, p->m_bHistory, p->m_bIsAction);
+
cc->m_msgs.destroy();
}
@@ -407,9 +406,9 @@ void CVkProto::AppendChatMessage(CVkChatInfo *cc, int uid, int msgTime, LPCWSTR
CVkChatInfo* CVkProto::GetChatById(LPCWSTR pwszId)
{
- for (int i = 0; i < m_chats.getCount(); i++)
- if (!mir_wstrcmp(m_chats[i].m_wszId, pwszId))
- return &m_chats[i];
+ for (auto &it : m_chats)
+ if (!mir_wstrcmp(it->m_wszId, pwszId))
+ return it;
return nullptr;
}
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp
index 67502aee15..86884a79ce 100644
--- a/protocols/VKontakte/src/vk_feed.cpp
+++ b/protocols/VKontakte/src/vk_feed.cpp
@@ -679,9 +679,9 @@ void CVkProto::OnReceiveUnreadNews(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *p
}
bool bNewsAdded = false;
- for (int i = 0; i < vkNews.getCount(); i++)
- if (!(m_vkOptions.bNewsSourceNoReposts && vkNews[i].bIsRepost)) {
- AddFeedEvent(vkNews[i]);
+ for (auto &it : vkNews)
+ if (!(m_vkOptions.bNewsSourceNoReposts && it->bIsRepost)) {
+ AddFeedEvent(*it);
bNewsAdded = true;
}
@@ -803,9 +803,9 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR
bool bNotificationCommentAdded = false;
bool bNotificationComment = false;
bool bNotificationAdded = false;
- for (int i = 0; i < vkNotification.getCount(); i++)
- if (FilterNotification(&vkNotification[i], bNotificationComment)) {
- AddFeedEvent(vkNotification[i]);
+ for (auto &it : vkNotification)
+ if (FilterNotification(it, bNotificationComment)) {
+ AddFeedEvent(*it);
bNotificationAdded = true;
bNotificationCommentAdded = bNotificationComment || bNotificationCommentAdded;
}
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index d49242f3ea..c7efb61344 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -52,10 +52,10 @@ void CVkProto::ConnectionFailed(int iReason)
static VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
mir_cslock lck(csInstances);
- for (int i = 0; i < vk_Instances.getCount(); i++)
- if (vk_Instances[i]->IsOnline()) {
- vk_Instances[i]->debugLogA("Tic timer for %i - %s", i, vk_Instances[i]->m_szModuleName);
- vk_Instances[i]->OnTimerTic();
+ for (auto &it : vk_Instances)
+ if (it->IsOnline()) {
+ it->debugLogA("Tic timer for %s", it->m_szModuleName);
+ it->OnTimerTic();
}
}
@@ -124,8 +124,8 @@ void CVkProto::OnLoggedOut()
bool bOnline = false;
{
mir_cslock lck(csInstances);
- for (int i = 0; i < vk_Instances.getCount(); i++)
- bOnline = bOnline || vk_Instances[i]->IsOnline();
+ for (auto &it : vk_Instances)
+ bOnline = bOnline || it->IsOnline();
}
if (!bOnline)
CallFunctionAsync(VKUnsetTimer, this);
@@ -613,19 +613,19 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
}
if (jnResponse["freeoffline"].as_bool())
- for (int i = 0; i < arContacts.getCount(); i++) {
- hContact = (UINT_PTR)arContacts[i];
- LONG userID = getDword(hContact, "ID", VK_INVALID_USER);
+ for (auto &it : arContacts) {
+ MCONTACT cc = (MCONTACT)it;
+ LONG userID = getDword(cc, "ID", VK_INVALID_USER);
if (userID == m_myUserId || userID == VK_FEED_USER)
continue;
- int iContactStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE);
+ int iContactStatus = getWord(cc, "Status", ID_STATUS_OFFLINE);
if ((iContactStatus == ID_STATUS_ONLINE)
- || (iContactStatus == ID_STATUS_INVISIBLE && time(nullptr) - getDword(hContact, "InvisibleTS", 0) >= m_vkOptions.iInvisibleInterval * 60LL)) {
- setWord(hContact, "Status", ID_STATUS_OFFLINE);
- SetMirVer(hContact, -1);
- db_unset(hContact, m_szModuleName, "ListeningTo");
+ || (iContactStatus == ID_STATUS_INVISIBLE && time(nullptr) - getDword(cc, "InvisibleTS", 0) >= m_vkOptions.iInvisibleInterval * 60LL)) {
+ setWord(cc, "Status", ID_STATUS_OFFLINE);
+ SetMirVer(cc, -1);
+ db_unset(cc, m_szModuleName, "ListeningTo");
}
}
@@ -778,8 +778,8 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
}
if (bCleanContacts)
- for (int i = 0; i < arContacts.getCount(); i++) {
- MCONTACT hContact = (UINT_PTR)arContacts[i];
+ for (auto &it : arContacts) {
+ MCONTACT hContact = (MCONTACT)it;
LONG userID = getDword(hContact, "ID", VK_INVALID_USER);
bool bIsFriendGroup = IsGroupUser(hContact) && getBool(hContact, "friend");
if (userID == m_myUserId || userID == VK_FEED_USER || bIsFriendGroup)