summaryrefslogtreecommitdiff
path: root/plugins/UserInfoEx
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-04-03 16:30:25 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-04-03 16:30:25 +0300
commit9613f96e6a6f96ad02a0fc926054132811ae2bb1 (patch)
treef8fe94a3efe7598a2af926f264d354f7a08fb943 /plugins/UserInfoEx
parent2f880bda3aa2d8817ce43481df9d99b12ed82a58 (diff)
Accounts() : iterator for accounts
Diffstat (limited to 'plugins/UserInfoEx')
-rw-r--r--plugins/UserInfoEx/src/classPsTreeItem.cpp11
-rw-r--r--plugins/UserInfoEx/src/dlg_propsheet.cpp17
-rw-r--r--plugins/UserInfoEx/src/svc_refreshci.cpp13
3 files changed, 14 insertions, 27 deletions
diff --git a/plugins/UserInfoEx/src/classPsTreeItem.cpp b/plugins/UserInfoEx/src/classPsTreeItem.cpp
index 1bd103b6f3..36f8abde3c 100644
--- a/plugins/UserInfoEx/src/classPsTreeItem.cpp
+++ b/plugins/UserInfoEx/src/classPsTreeItem.cpp
@@ -275,16 +275,13 @@ HICON CPsTreeItem::ProtoIcon()
if (!_pszName)
return nullptr;
- PROTOACCOUNT **pa;
- int ProtoCount;
- Proto_EnumAccounts(&ProtoCount, &pa);
- for (int i = 0; i < ProtoCount; i++) {
- if (!mir_wstrncmpi(pa[i]->tszAccountName, _A2T(_pszName), mir_wstrlen(pa[i]->tszAccountName))) {
+ for (auto &pa : Accounts()) {
+ if (!mir_wstrncmpi(pa->tszAccountName, _A2T(_pszName), mir_wstrlen(pa->tszAccountName))) {
CHAR szIconID[MAX_PATH];
- mir_snprintf(szIconID, "core_status_%s1", pa[i]->szModuleName);
+ mir_snprintf(szIconID, "core_status_%s1", pa->szModuleName);
HICON hIco = IcoLib_GetIcon(szIconID);
if (!hIco)
- hIco = (HICON)CallProtoService(pa[i]->szModuleName, PS_LOADICON, PLI_PROTOCOL, NULL);
+ hIco = (HICON)CallProtoService(pa->szModuleName, PS_LOADICON, PLI_PROTOCOL, NULL);
return hIco;
}
diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp
index b5142bdcd4..3e4807a5ee 100644
--- a/plugins/UserInfoEx/src/dlg_propsheet.cpp
+++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp
@@ -562,15 +562,12 @@ void DlgContactInfoInitTreeIcons()
psh._dwFlags |= PSF_PROTOPAGESONLY_INIT;
// enumerate all protocols
- PROTOACCOUNT **pd;
- int ProtoCount = 0;
- Proto_EnumAccounts(&ProtoCount, &pd);
- for (int i = 0; i < ProtoCount; i++) {
+ for (auto &pa : Accounts()) {
// enumerate all contacts
for (psh._hContact = db_find_first(); psh._hContact != NULL; psh._hContact = db_find_next(psh._hContact)) {
// compare contact's protocol to the current one, to add
LPCSTR pszContactProto = Proto_GetBaseAccountName(psh._hContact);
- if ((INT_PTR)pszContactProto != CALLSERVICE_NOTFOUND && !mir_strcmp(pd[i]->szModuleName, pszContactProto)) {
+ if ((INT_PTR)pszContactProto != CALLSERVICE_NOTFOUND && !mir_strcmp(pa->szModuleName, pszContactProto)) {
// call a notification for the contact to retrieve all protocol specific tree items
NotifyEventHooks(g_hDetailsInitEvent, (WPARAM)&psh, (LPARAM)psh._hContact);
if (psh._pPages) {
@@ -630,12 +627,10 @@ void DlgContactInfoLoadModule()
// check whether changing my details via UserInfoEx is basically possible
myGlobals.CanChangeDetails = FALSE;
- PROTOACCOUNT **pAcc;
- int nAccCount;
- Proto_EnumAccounts(&nAccCount, &pAcc);
- for (int i = 0; (i < nAccCount) && !myGlobals.CanChangeDetails; i++)
- if (IsProtoAccountEnabled(pAcc[i])) // update my contact information on icq server
- myGlobals.CanChangeDetails = MIREXISTS(CallProtoService(pAcc[i]->szModuleName, PS_CHANGEINFOEX, NULL, NULL));
+ for (auto &pa : Accounts())
+ if (IsProtoAccountEnabled(pa)) // update my contact information on icq server
+ if (myGlobals.CanChangeDetails = MIREXISTS(CallProtoService(pa->szModuleName, PS_CHANGEINFOEX, NULL, NULL)))
+ break;
}
static void ResetUpdateInfo(LPPS pPs)
diff --git a/plugins/UserInfoEx/src/svc_refreshci.cpp b/plugins/UserInfoEx/src/svc_refreshci.cpp
index b409fb78b6..59b991cfb9 100644
--- a/plugins/UserInfoEx/src/svc_refreshci.cpp
+++ b/plugins/UserInfoEx/src/svc_refreshci.cpp
@@ -725,7 +725,6 @@ public:
RemoveAll();
ContinueWithNext();
}
-
};
static CContactUpdater *ContactUpdater = nullptr;
@@ -744,15 +743,11 @@ static CContactUpdater *ContactUpdater = nullptr;
**/
static BOOL IsMirandaOnline()
{
- BOOL bIsOnline = FALSE;
- PROTOACCOUNT **pAcc;
- int nAccCount;
- Proto_EnumAccounts(&nAccCount, &pAcc);
-
- for (int i = 0; (i < nAccCount) && !bIsOnline; i++)
- bIsOnline |= (IsProtoAccountEnabled(pAcc[i]) && IsProtoOnline(pAcc[i]->szModuleName));
+ for (auto &pa : Accounts())
+ if (IsProtoAccountEnabled(pa) && IsProtoOnline(pa->szModuleName))
+ return true;
- return bIsOnline;
+ return false;
}
/***********************************************************************************************************