From 9613f96e6a6f96ad02a0fc926054132811ae2bb1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 3 Apr 2018 16:30:25 +0300 Subject: Accounts() : iterator for accounts --- utils/mir_options.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'utils') diff --git a/utils/mir_options.cpp b/utils/mir_options.cpp index 0f4239def3..c027b4e7e1 100644 --- a/utils/mir_options.cpp +++ b/utils/mir_options.cpp @@ -207,25 +207,20 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha lvi.iSubItem = 0; lvi.iItem = 1000; - int count; - PROTOACCOUNT **protos; - Proto_EnumAccounts(&count, &protos); - - for (int k = 0; k < count; k++) { - PROTOACCOUNT *p = protos[k]; - if (p->szModuleName == nullptr || p->szModuleName[0] == '\0') + for (auto &pa : Accounts()) { + if (pa->szModuleName == nullptr || pa->szModuleName[0] == '\0') continue; - if (ctrl->allowProtocol != nullptr && !ctrl->allowProtocol(p->szModuleName)) + if (ctrl->allowProtocol != nullptr && !ctrl->allowProtocol(pa->szModuleName)) continue; char *setting = (char *)mir_alloc(128 * sizeof(char)); - mir_snprintf(setting, 128, ctrl->setting, p->szModuleName); + mir_snprintf(setting, 128, ctrl->setting, pa->szModuleName); BOOL show = (BOOL)db_get_b(NULL, module, setting, ctrl->dwDefValue); lvi.lParam = (LPARAM)setting; - lvi.pszText = p->tszAccountName; + lvi.pszText = pa->tszAccountName; lvi.iItem = ListView_InsertItem(hwndProtocols, &lvi); ListView_SetItemState(hwndProtocols, lvi.iItem, INDEXTOSTATEIMAGEMASK(show ? 2 : 1), LVIS_STATEIMAGEMASK); } -- cgit v1.2.3