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 --- plugins/Clist_modern/src/modern_clcopts.cpp | 30 ++++++++++++----------------- 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'plugins/Clist_modern/src/modern_clcopts.cpp') diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp index 56b9b2ace6..11f08454c7 100644 --- a/plugins/Clist_modern/src/modern_clcopts.cpp +++ b/plugins/Clist_modern/src/modern_clcopts.cpp @@ -470,12 +470,9 @@ static INT_PTR CALLBACK DlgProcClistListOpts(HWND hwndDlg, UINT msg, WPARAM wPar static int _GetNetVisibleProtoCount() { - int count, netProtoCount; - PROTOACCOUNT **accs; - Proto_EnumAccounts(&count, &accs); - - for (int i = 0, netProtoCount = 0; i < count; i++) - if (accs[i]->IsVisible()) + int netProtoCount = 0; + for (auto &pa : Accounts()) + if (pa->IsVisible()) netProtoCount++; return netProtoCount; @@ -606,22 +603,19 @@ static INT_PTR CALLBACK DlgProcTrayOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L // == Tray icon mode == // preparing account list. { - int AccNum, i, siS, siV, item; - PROTOACCOUNT **acc; - Proto_EnumAccounts(&AccNum, &acc); - - for (siS = siV = -1, i = 0; i < AccNum; i++) { - if (!acc[i]->bIsVirtual && acc[i]->bIsVisible && !acc[i]->bDynDisabled && acc[i]->bIsEnabled) { - item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_ADDSTRING, 0, (LPARAM)acc[i]->tszAccountName); - SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_SETITEMDATA, item, (LPARAM)acc[i]); + int siS = -1, siV = -1; + for (auto &pa : Accounts()) { + if (!pa->bIsVirtual && pa->bIsVisible && !pa->bDynDisabled && pa->bIsEnabled) { + int item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_ADDSTRING, 0, (LPARAM)pa->tszAccountName); + SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_SETITEMDATA, item, (LPARAM)pa); - if (!mir_strcmp(acc[i]->szModuleName, db_get_sa(0, "CList", "tiAccS"))) + if (!mir_strcmp(pa->szModuleName, db_get_sa(0, "CList", "tiAccS"))) siS = item; - item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_ADDSTRING, 0, (LPARAM)acc[i]->tszAccountName); - SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_SETITEMDATA, item, (LPARAM)acc[i]); + item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_ADDSTRING, 0, (LPARAM)pa->tszAccountName); + SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_SETITEMDATA, item, (LPARAM)pa); - if (!mir_strcmp(acc[i]->szModuleName, db_get_sa(0, "CList", "tiAccV"))) + if (!mir_strcmp(pa->szModuleName, db_get_sa(0, "CList", "tiAccV"))) siV = item; } -- cgit v1.2.3