From 0af77111dfb30477ef9e722f1c77091a49a8be8f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 27 Jun 2019 14:48:44 +0300 Subject: Skype: minor code cleaning --- protocols/SkypeWeb/src/skype_db.cpp | 8 +++----- protocols/SkypeWeb/src/skype_events.cpp | 8 +++----- protocols/SkypeWeb/src/skype_polling.cpp | 3 +-- protocols/SkypeWeb/src/skype_proto.h | 6 ++---- protocols/SkypeWeb/src/skype_search.cpp | 7 +++---- 5 files changed, 12 insertions(+), 20 deletions(-) (limited to 'protocols/SkypeWeb/src') diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp index f5459015fc..d253b9219a 100644 --- a/protocols/SkypeWeb/src/skype_db.cpp +++ b/protocols/SkypeWeb/src/skype_db.cpp @@ -62,12 +62,10 @@ void CSkypeProto::EditEvent(MCONTACT hContact, MEVENT hEvent, const char *szCont if (jMsg) { JSONNode &jEdits = jMsg["edits"]; if (jEdits) { - for (auto it = jEdits.begin(); it != jEdits.end(); ++it) { - const JSONNode &jEdit = *it; - - if (jEdit["time"].as_int() == edit_time) + for (auto &it : jEdits) + if (it["time"].as_int() == edit_time) return; - } + JSONNode jEdit; jEdit << JSONNode("time", (long)edit_time) diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp index 60e51ce522..a9547b872e 100644 --- a/protocols/SkypeWeb/src/skype_events.cpp +++ b/protocols/SkypeWeb/src/skype_events.cpp @@ -32,14 +32,12 @@ INT_PTR CSkypeProto::GetEventText(WPARAM pEvent, LPARAM datatype) JSONNode &jOriginalMsg = jMsg["original_message"]; szText.AppendFormat(bUseBB ? Translate("[b]Original message:[/b]\n%s\n") : Translate("Original message:\n%s\n"), mir_utf8decodeA(jOriginalMsg["text"].as_string().c_str())); JSONNode &jEdits = jMsg["edits"]; - for (auto it = jEdits.begin(); it != jEdits.end(); ++it) { - const JSONNode &jEdit = *it; - - time_t time = jEdit["time"].as_int(); + for (auto &it : jEdits) { + time_t time = it["time"].as_int(); char szTime[MAX_PATH]; strftime(szTime, sizeof(szTime), "%X %x", localtime(&time)); - szText.AppendFormat(bUseBB ? Translate("[b]Edited at %s:[/b]\n%s\n") : Translate("Edited at %s:\n%s\n"), szTime, mir_utf8decodeA(jEdit["text"].as_string().c_str())); + szText.AppendFormat(bUseBB ? Translate("[b]Edited at %s:[/b]\n%s\n") : Translate("Edited at %s:\n%s\n"), szTime, mir_utf8decodeA(it["text"].as_string().c_str())); } } } diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp index 750bca2a17..cb3ea22bce 100644 --- a/protocols/SkypeWeb/src/skype_polling.cpp +++ b/protocols/SkypeWeb/src/skype_polling.cpp @@ -79,8 +79,7 @@ void CSkypeProto::ParsePollData(const char *szData) const JSONNode &node = data["eventMessages"]; if (!node) return; - for (auto it = node.begin(); it != node.end(); ++it) { - const JSONNode &message = *it; + for (auto &message : node) { const JSONNode &resType = message["resourceType"]; const JSONNode &resource = message["resource"]; diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 70779bdc57..6c40be3f62 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -99,10 +99,8 @@ private: ~contacts_list() { - for (auto it = m_cache.begin(); it != m_cache.end(); ++it) - { - mir_free(it->second); - } + for (auto &it : m_cache) + mir_free(it.second); } const char* operator[](MCONTACT hContact) diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp index 28a3a32344..d71d825034 100644 --- a/protocols/SkypeWeb/src/skype_search.cpp +++ b/protocols/SkypeWeb/src/skype_search.cpp @@ -26,9 +26,8 @@ HANDLE CSkypeProto::SearchBasic(const wchar_t* id) void CSkypeProto::SearchBasicThread(void* id) { debugLogA("CSkypeProto::OnSearchBasicThread"); - if (IsOnline()) { + if (IsOnline()) SendRequest(new GetSearchRequest(mir_urlEncode(T2Utf((wchar_t*)id)), li), &CSkypeProto::OnSearch); - } } void CSkypeProto::OnSearch(const NETLIBHTTPREQUEST *response) @@ -52,8 +51,8 @@ void CSkypeProto::OnSearch(const NETLIBHTTPREQUEST *response) } const JSONNode &items = root["results"].as_array(); - for (auto it = items.begin(); it != items.end(); ++it) { - const JSONNode &item = (*it)["nodeProfileData"]; + for (auto &it : items) { + const JSONNode &item = it["nodeProfileData"]; std::string skypeId = item["skypeId"].as_string(); std::string name = item["name"].as_string(); -- cgit v1.2.3