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/MirFox/src/MirandaUtils.cpp | 12 ++++-------- plugins/MirFox/src/MirfoxData.cpp | 30 +++++++++--------------------- 2 files changed, 13 insertions(+), 29 deletions(-) (limited to 'plugins/MirFox') diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp index 877ad01dbc..f4845deb7e 100644 --- a/plugins/MirFox/src/MirandaUtils.cpp +++ b/plugins/MirFox/src/MirandaUtils.cpp @@ -485,16 +485,12 @@ void MirandaUtils::translateOldDBNames() { db_free(&opt2Dbv); } - //account's settings "ACCOUNTSTATE_" - int accountsTmpCount = 0; - PROTOACCOUNT **accountsTmp; - Proto_EnumAccounts(&accountsTmpCount, &accountsTmp); - - for(int i=0; ilog_p(L"TranslateOldDBNames: found ACCOUNT: [%s] protocol: [%S]", accountsTmp[i]->tszAccountName, accountsTmp[i]->szProtoName); + // account's settings "ACCOUNTSTATE_" + for (auto &pa : Accounts()) { + logger->log_p(L"TranslateOldDBNames: found ACCOUNT: [%s] protocol: [%S]", pa->tszAccountName, pa->szProtoName); std::string mirandaAccountDBKey("ACCOUNTSTATE_"); - mirandaAccountDBKey += accountsTmp[i]->szModuleName; + mirandaAccountDBKey += pa->szModuleName; int keyValue = db_get_b(0, OLD_PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 0); if (keyValue != 0){ db_set_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), keyValue); diff --git a/plugins/MirFox/src/MirfoxData.cpp b/plugins/MirFox/src/MirfoxData.cpp index aad3018e48..9a29cf99d7 100644 --- a/plugins/MirFox/src/MirfoxData.cpp +++ b/plugins/MirFox/src/MirfoxData.cpp @@ -582,39 +582,27 @@ MirfoxData::initializeMirandaAccounts() clearMirandaAccounts(); //get accounts from Miranda by CallService MS_PROTO_ENUMACCOUNTS - int accountsCount = 0; - PROTOACCOUNT **accounts; - Proto_EnumAccounts(&accountsCount, &accounts); - - for(int i=0; ibIsEnabled == 0){ + for (auto &pa : Accounts()) { + // checking account + if (pa->bIsEnabled == 0) continue; - } - if(accounts[i]->bDynDisabled != 0){ + + if (pa->bDynDisabled != 0) continue; - } //add to list - MirandaAccount* mirandaAccountItemPtr = new MirandaAccount( - mirfoxAccountIdPool, - accounts[i]->szModuleName, - accounts[i]->tszAccountName, - accounts[i]->szProtoName, - accounts[i]->iOrder - ); + MirandaAccount* mirandaAccountItemPtr = new MirandaAccount(mirfoxAccountIdPool, pa->szModuleName, pa->tszAccountName, pa->szProtoName, pa->iOrder); MFLogger* logger = MFLogger::getInstance(); - logger->log_p(L"initializeMirandaAccounts: tszAccountName: [%s] protocol: [%S]", accounts[i]->tszAccountName, accounts[i]->szProtoName ); + logger->log_p(L"initializeMirandaAccounts: tszAccountName: [%s] protocol: [%S]", pa->tszAccountName, pa->szProtoName); mirfoxAccountIdPool++; - if (accounts[i]->iOrder > maxAccountIOrder) maxAccountIOrder = accounts[i]->iOrder; + if (pa->iOrder > maxAccountIOrder) + maxAccountIOrder = pa->iOrder; mirandaAccountItemPtr->accountState = createOrGetAccountStateFromDB(mirandaAccountItemPtr); addMirandaAccount(mirandaAccountItemPtr); - } //TODO - sort by mirandaAccount.displayOrder -- cgit v1.2.3