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/Import/src/import.cpp | 19 ++++++------------- plugins/Import/src/main.cpp | 5 +---- 2 files changed, 7 insertions(+), 17 deletions(-) (limited to 'plugins/Import/src') diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index c1ad7c19d5..127a21ff5e 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -261,14 +261,12 @@ static LRESULT CALLBACK ListWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)TranslateT("")); SendMessage(hwndCombo, CB_SETITEMDATA, 0, lvitem.lParam); - int protoCount, iSel = 0; - PROTOACCOUNT **accs; - Proto_EnumAccounts(&protoCount, &accs); - for (int i = 0; i < protoCount; i++) { - int idx = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName); - SendMessage(hwndCombo, CB_SETITEMDATA, idx, (LPARAM)accs[i]); + int iSel = 0; + for (auto &it : Accounts()) { + int idx = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)it->tszAccountName); + SendMessage(hwndCombo, CB_SETITEMDATA, idx, (LPARAM)it); - if (!mir_wstrcmpi(accs[i]->tszAccountName, tszText)) + if (!mir_wstrcmpi(it->tszAccountName, tszText)) iSel = idx; } @@ -379,13 +377,8 @@ static bool FindDestAccount(const char *szProto) static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto, const wchar_t *ptszName, bool bStrict) { - int destProtoCount; - PROTOACCOUNT **destAccs; - Proto_EnumAccounts(&destProtoCount, &destAccs); - PROTOACCOUNT *pProto = nullptr; - for (int i = 0; i < destProtoCount; i++) { - PROTOACCOUNT *pa = destAccs[i]; + for (auto &pa : Accounts()) { // already used? skip if (FindDestAccount(pa->szModuleName)) continue; diff --git a/plugins/Import/src/main.cpp b/plugins/Import/src/main.cpp index 86706d178a..3e6a15fdfb 100644 --- a/plugins/Import/src/main.cpp +++ b/plugins/Import/src/main.cpp @@ -94,10 +94,7 @@ static int ModulesLoaded(WPARAM, LPARAM) if (!db_get_b(NULL, IMPORT_MODULE, IMP_KEY_FR, 0)) { // Only autorun import wizard if at least one protocol is installed - int nProtocols = 0; - PROTOACCOUNT **ppProtos = nullptr; - Proto_EnumAccounts(&nProtocols, &ppProtos); - if (nProtocols > 0) { + if (Accounts().getCount() > 0) { CallService(IMPORT_SERVICE, 0, 0); db_set_b(NULL, IMPORT_MODULE, IMP_KEY_FR, 1); } -- cgit v1.2.3