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 --- plugins/CmdLine/src/mimcmd_handlers.cpp | 8 ++++---- plugins/CmdLine/src/utils.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins/CmdLine/src') diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index ad5a1cb216..122f7bfedd 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -1227,7 +1227,7 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r int count = 0; reply->code = MIMRES_SUCCESS; - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + for (auto &hContact : contact_iter()) { GetContactProto(hContact, protocol, _countof(protocol)); ptrW contact(GetContactName(hContact, protocol)); @@ -1257,7 +1257,7 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r reply->code = MIMRES_SUCCESS; *reply->message = 0; - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + for (auto &hContact : contact_iter()) { GetContactProto(hContact, protocol, _countof(protocol)); ptrW contact(GetContactName(hContact, protocol)); @@ -1270,7 +1270,7 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r reply->code = MIMRES_SUCCESS; *reply->message = 0; - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + for (auto &hContact : contact_iter()) { MEVENT hUnreadEvent = db_event_firstUnread(hContact); if (hUnreadEvent != NULL) mir_forkthread(OpenMessageWindowThread, (void*)hContact); @@ -1324,7 +1324,7 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re reply->code = MIMRES_SUCCESS; mir_snwprintf(reply->message, TranslateT("No unread messages found.")); - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + for (auto &hContact : contact_iter()) { MEVENT hEvent = db_event_firstUnread(hContact); if (hEvent != NULL) { count = 0; diff --git a/plugins/CmdLine/src/utils.cpp b/plugins/CmdLine/src/utils.cpp index 97c2ef57f7..a7298887c6 100644 --- a/plugins/CmdLine/src/utils.cpp +++ b/plugins/CmdLine/src/utils.cpp @@ -171,7 +171,7 @@ MCONTACT GetContactFromID(wchar_t *szID, char *szProto) char cProtocol[256]; int found = 0; - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + for (auto &hContact : contact_iter()) { GetContactProto(hContact, cProtocol, sizeof(cProtocol)); ptrW szHandle(GetContactID(hContact, cProtocol)); -- cgit v1.2.3