From 39390b02dbd5aa7eb21a83773fa561b39f8828bc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 16 Mar 2018 20:01:14 +0300 Subject: always hated these long expressions: contact_iter makes them much shorter --- protocols/MSN/src/msn_chat.cpp | 3 +-- protocols/MSN/src/msn_contact.cpp | 6 +----- protocols/MSN/src/msn_misc.cpp | 5 +---- protocols/MSN/src/msn_proto.cpp | 2 +- 4 files changed, 4 insertions(+), 12 deletions(-) (limited to 'protocols/MSN') diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index 804cb64951..c484d9f2f6 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -241,10 +241,9 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID void CMsnProto::MSN_GCRefreshThreadsInfo(void) { CMStringA buf; - MCONTACT hContact; int nThreads = 0; - for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { + for (auto &hContact : acc_contact_iter()) { if (isChatRoom(hContact) != 0) { DBVARIANT dbv; if (getString(hContact, "ChatRoomID", &dbv) == 0) { diff --git a/protocols/MSN/src/msn_contact.cpp b/protocols/MSN/src/msn_contact.cpp index bf9de7dbfd..ae5abebf9d 100644 --- a/protocols/MSN/src/msn_contact.cpp +++ b/protocols/MSN/src/msn_contact.cpp @@ -53,11 +53,7 @@ MCONTACT CMsnProto::MSN_HContactFromEmail(const char* wlid, const char* msnNick, MCONTACT CMsnProto::MSN_HContactFromChatID(const char* wlid) { - MCONTACT hContact = NULL; - - for (hContact = db_find_first(m_szModuleName); hContact; - hContact = db_find_next(hContact, m_szModuleName)) - { + for (auto &hContact : acc_contact_iter()) { if (isChatRoom(hContact) != 0) { DBVARIANT dbv; if (getString(hContact, "ChatRoomID", &dbv) == 0) { diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 78ec94f5dd..8b82cd9231 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -674,11 +674,8 @@ void CMsnProto::MSN_FetchRecentMessages(time_t since) /* Assuming that you want all messages that were sent after the last * user conversation according to DB */ - MCONTACT hContact; MEVENT hDbEvent; - for (hContact = db_find_first(m_szModuleName); hContact; - hContact = db_find_next(hContact, m_szModuleName)) - { + for (auto &hContact : acc_contact_iter()) { if (!(hDbEvent = db_event_last(hContact))) continue; diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp index d4498913e1..85c2344b32 100644 --- a/protocols/MSN/src/msn_proto.cpp +++ b/protocols/MSN/src/msn_proto.cpp @@ -88,7 +88,7 @@ CMsnProto::CMsnProto(const char* aProtoName, const wchar_t* aUserName) : LoadOptions(); - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { + for (auto &hContact : acc_contact_iter()) { delSetting(hContact, "Status"); delSetting(hContact, "IdleTS"); delSetting(hContact, "p2pMsgId"); -- cgit v1.2.3