From 4262e8021c8ffdc0401d9ebe09899f90c654aa18 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 30 Apr 2021 11:37:17 +0300 Subject: we use contact iterators when possible --- plugins/UserInfoEx/src/dlg_propsheet.cpp | 5 +++-- plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp | 4 +--- plugins/UserInfoEx/src/ex_import/svc_ExImINI.cpp | 2 +- plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) (limited to 'plugins/UserInfoEx/src') diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp index e61f5e1e93..4267b8ab0e 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.cpp +++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp @@ -494,11 +494,12 @@ void DlgContactInfoInitTreeIcons() // enumerate all protocols for (auto &pa : Accounts()) { // enumerate all contacts - for (psh._hContact = db_find_first(); psh._hContact != NULL; psh._hContact = db_find_next(psh._hContact)) { + for (auto &cc: Contacts(pa->szModuleName)) { // compare contact's protocol to the current one, to add - LPCSTR pszContactProto = Proto_GetBaseAccountName(psh._hContact); + LPCSTR pszContactProto = Proto_GetBaseAccountName(cc); if ((INT_PTR)pszContactProto != CALLSERVICE_NOTFOUND && !mir_strcmp(pa->szModuleName, pszContactProto)) { // call a notification for the contact to retrieve all protocol specific tree items + psh._hContact = cc; NotifyEventHooks(g_hDetailsInitEvent, (WPARAM)&psh, (LPARAM)psh._hContact); if (psh._pPages) { psh.Free_pPages(); diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp index 945d404c2b..ec1cb4b629 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp @@ -273,9 +273,7 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar // module must exist in at least one contact if (pDat->ExImContact->Typ != EXIM_CONTACT) // TRUE = All Contacts { - MCONTACT hContact; - - for (hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) { + for (auto &hContact: Contacts()) { // ignore empty modules if (!DB::Module::IsEmpty(hContact, p)) { pszProto = Proto_GetBaseAccountName(hContact); diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImINI.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImINI.cpp index dc826a7139..a83438b9ad 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImINI.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImINI.cpp @@ -158,7 +158,7 @@ int SvcExImINI_Export(lpExImParam ExImContact, const wchar_t *pszFileName) ExportContact(NULL, &Modules, file); fprintf(file, "\n\n"); // Contacts - for (MCONTACT hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) { + for (auto &hContact: Contacts()) { ExportContact(hContact, &Modules, file); fprintf(file, "\n\n"); } diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp index 3022575e8e..09e8040a50 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp @@ -137,7 +137,7 @@ int CFileXml::Export(lpExImParam ExImContact, const wchar_t *pszFileName) vContact.Export(xmlfile, &Modules); // loop for all other contact - for (MCONTACT hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) { + for (auto &hContact: Contacts()) { switch (ExImContact->Typ) { case EXIM_ALL: case EXIM_GROUP: -- cgit v1.2.3