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/Sametime/src/sametime.cpp | 2 +- protocols/Sametime/src/session_announce_win.cpp | 2 +- protocols/Sametime/src/userlist.cpp | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'protocols/Sametime/src') diff --git a/protocols/Sametime/src/sametime.cpp b/protocols/Sametime/src/sametime.cpp index dfb4166223..01770d382c 100644 --- a/protocols/Sametime/src/sametime.cpp +++ b/protocols/Sametime/src/sametime.cpp @@ -223,7 +223,7 @@ void CSametimeProto::SetAllOffline() { debugLogW(L"SetAllOffline() start"); - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { + for (auto &hContact : acc_contact_iter()) { if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0)) { db_delete_contact(hContact); continue; diff --git a/protocols/Sametime/src/session_announce_win.cpp b/protocols/Sametime/src/session_announce_win.cpp index 45c4dffa2d..50f564f1d3 100644 --- a/protocols/Sametime/src/session_announce_win.cpp +++ b/protocols/Sametime/src/session_announce_win.cpp @@ -40,7 +40,7 @@ INT_PTR CALLBACK SessionAnnounceDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wPara lvI.iItem = 0; lvI.iSubItem = 0; - for (MCONTACT hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName)) { + for (auto &hContact : proto->acc_contact_iter()) { if (db_get_b(hContact, proto->m_szModuleName, "ChatRoom", 0) == 0 && db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) { lvI.lParam = (LPARAM)hContact; diff --git a/protocols/Sametime/src/userlist.cpp b/protocols/Sametime/src/userlist.cpp index a61398189a..777d174aa0 100644 --- a/protocols/Sametime/src/userlist.cpp +++ b/protocols/Sametime/src/userlist.cpp @@ -4,7 +4,7 @@ MCONTACT CSametimeProto::FindContactByUserId(const char* id) { DBVARIANT dbv; - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { + for (auto &hContact : acc_contact_iter()) { if (!db_get_utf(hContact, m_szModuleName, "stid", &dbv)) { if (dbv.pszVal && mir_strcmp(id, dbv.pszVal) == 0) { db_free(&dbv); @@ -204,7 +204,7 @@ void CSametimeProto::ExportContactsToList(mwSametimeList* user_list) mwIdBlock uid; GList* gl = nullptr; - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { + for (auto &hContact : acc_contact_iter()) { if (!db_get_utf(hContact, m_szModuleName, "stid", &dbv)) { if (dbv.pszVal) { if (GetAwareIdFromContact(hContact, &id_block)) { @@ -223,7 +223,6 @@ void CSametimeProto::ExportContactsToList(mwSametimeList* user_list) db_free(&dbv); free(id_block.user); free(group_alias); - hContact = db_find_next(hContact, m_szModuleName); continue; } @@ -595,7 +594,7 @@ void CSametimeProto::UserListCreate() mwAwareIdBlock id_block; GList *gl = nullptr; - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { + for (auto &hContact : acc_contact_iter()) { if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0) == 0 /*&& proto && !mir_strcmp( PROTO, proto)*/) { if (!db_get_utf(hContact, m_szModuleName, "stid", &dbv)) { if (dbv.pszVal) { -- cgit v1.2.3