diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-03 16:30:25 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-03 16:30:25 +0300 |
commit | 9613f96e6a6f96ad02a0fc926054132811ae2bb1 (patch) | |
tree | f8fe94a3efe7598a2af926f264d354f7a08fb943 /plugins/MirFox | |
parent | 2f880bda3aa2d8817ce43481df9d99b12ed82a58 (diff) |
Accounts() : iterator for accounts
Diffstat (limited to 'plugins/MirFox')
-rw-r--r-- | plugins/MirFox/src/MirandaUtils.cpp | 12 | ||||
-rw-r--r-- | plugins/MirFox/src/MirfoxData.cpp | 30 |
2 files changed, 13 insertions, 29 deletions
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; i<accountsTmpCount; i++) {
- logger->log_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; i<accountsCount; i++) {
-
- //checking account
- if(accounts[i]->bIsEnabled == 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
|