summaryrefslogtreecommitdiff
path: root/plugins/StatusManager/src
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/StatusManager/src
parent2f880bda3aa2d8817ce43481df9d99b12ed82a58 (diff)
Accounts() : iterator for accounts
Diffstat (limited to 'plugins/StatusManager/src')
-rw-r--r--plugins/StatusManager/src/KeepStatus/keepstatus.cpp20
-rw-r--r--plugins/StatusManager/src/KeepStatus/ks_options.cpp14
-rw-r--r--plugins/StatusManager/src/StartupStatus/startupstatus.cpp7
-rw-r--r--plugins/StatusManager/src/commonstatus.cpp24
-rw-r--r--plugins/StatusManager/src/main.cpp10
5 files changed, 27 insertions, 48 deletions
diff --git a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
index 0d70c4d010..bb58b27323 100644
--- a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
+++ b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
@@ -726,27 +726,25 @@ static void CheckContinuouslyFunction(void *)
if (((!ping) && (!InternetGetConnectedState(nullptr, 0))) || ((ping) && (!bLastPingResult) && (pingFailures >= db_get_w(0, KSMODULENAME, SETTING_PINGCOUNT, DEFAULT_PINGCOUNT)))) {
pingFailures = 0;
- int count;
- PROTOACCOUNT** protos;
- Proto_EnumAccounts(&count, &protos);
-
- for (int i = 0; i < count; i++) {
- if (!IsSuitableProto(protos[i]))
+ for (auto &pa : Accounts()) {
+ if (!IsSuitableProto(pa))
continue;
- if (IsStatusConnecting(CallProtoService(protos[i]->szModuleName, PS_GETSTATUS, 0, 0))) {
- log_debugA("CheckContinuouslyFunction: %s is connecting", protos[i]->szModuleName);
+ if (IsStatusConnecting(CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0))) {
+ log_debugA("CheckContinuouslyFunction: %s is connecting", pa->szModuleName);
continue; // connecting, leave alone
}
- if (IsProtocolEnabledService(0, (LPARAM)protos[i]->szModuleName)) {
- log_debugA("CheckContinuouslyFunction: forcing %s offline", protos[i]->szModuleName);
- CallProtoService(protos[i]->szModuleName, PS_SETSTATUS, (WPARAM)ID_STATUS_OFFLINE, 0);
+ if (IsProtocolEnabledService(0, (LPARAM)pa->szModuleName)) {
+ log_debugA("CheckContinuouslyFunction: forcing %s offline", pa->szModuleName);
+ CallProtoService(pa->szModuleName, PS_SETSTATUS, (WPARAM)ID_STATUS_OFFLINE, 0);
}
}
+
if (StartTimer(IDT_CHECKCONN | IDT_PROCESSACK, -1, FALSE)) {// are our 'set offlines' noticed?
log_debugA("CheckContinuouslyFunction: currently checking");
return;
}
+
log_infoA("KeepStatus: connection lost! (continuesly check)");
NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_LOST, 0);
ProcessPopup(KS_CONN_STATE_LOST, 0);
diff --git a/plugins/StatusManager/src/KeepStatus/ks_options.cpp b/plugins/StatusManager/src/KeepStatus/ks_options.cpp
index 812d26ad6c..72b5bb2bd3 100644
--- a/plugins/StatusManager/src/KeepStatus/ks_options.cpp
+++ b/plugins/StatusManager/src/KeepStatus/ks_options.cpp
@@ -58,20 +58,16 @@ static INT_PTR CALLBACK DlgProcKSBasicOpts(HWND hwndDlg, UINT msg, WPARAM wParam
lvItem.iItem = 0;
lvItem.iSubItem = 0;
- int count;
- PROTOACCOUNT** protos;
- Proto_EnumAccounts(&count, &protos);
-
- for (int i = 0; i < count; i++) {
- if (!IsSuitableProto(protos[i]))
+ for (auto &pa : Accounts()) {
+ if (!IsSuitableProto(pa))
continue;
- lvItem.pszText = protos[i]->tszAccountName;
- lvItem.lParam = (LPARAM)protos[i]->szModuleName;
+ lvItem.pszText = pa->tszAccountName;
+ lvItem.lParam = (LPARAM)pa->szModuleName;
ListView_InsertItem(hList, &lvItem);
char dbSetting[128];
- mir_snprintf(dbSetting, "%s_enabled", protos[i]->szModuleName);
+ mir_snprintf(dbSetting, "%s_enabled", pa->szModuleName);
ListView_SetCheckState(hList, lvItem.iItem, db_get_b(0, KSMODULENAME, dbSetting, TRUE));
lvItem.iItem++;
}
diff --git a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
index 2a72f80300..793276ff6a 100644
--- a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
+++ b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
@@ -221,12 +221,7 @@ static void CALLBACK SetStatusTimed(HWND, UINT, UINT_PTR, DWORD)
static int OnOkToExit(WPARAM, LPARAM)
{
// save last protocolstatus
- int count;
- PROTOACCOUNT** protos;
- Proto_EnumAccounts(&count, &protos);
-
- for (int i = 0; i < count; i++) {
- PROTOACCOUNT *pa = protos[i];
+ for (auto &pa : Accounts()) {
if (!IsSuitableProto(pa))
continue;
diff --git a/plugins/StatusManager/src/commonstatus.cpp b/plugins/StatusManager/src/commonstatus.cpp
index a35b8496da..9bcfff4d89 100644
--- a/plugins/StatusManager/src/commonstatus.cpp
+++ b/plugins/StatusManager/src/commonstatus.cpp
@@ -151,25 +151,21 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps)
if (it->m_szMsg != nullptr && GetActualStatus(it) != ID_STATUS_OFFLINE)
return 0;
- int count;
- PROTOACCOUNT **protos;
- Proto_EnumAccounts(&count, &protos);
-
- for (int i = 0; i < count; i++) {
- if (!IsSuitableProto(protos[i]))
+ for (auto &pa : Accounts()) {
+ if (!IsSuitableProto(pa))
continue;
pstatus = 0;
for (j = 0; j < protoList.getCount(); j++)
- if (!mir_strcmp(protos[i]->szModuleName, ps[j]->m_szName))
+ if (!mir_strcmp(pa->szModuleName, ps[j]->m_szName))
pstatus = GetActualStatus(ps[j]);
if (pstatus == 0)
- pstatus = CallProtoService(protos[i]->szModuleName, PS_GETSTATUS, 0, 0);
+ pstatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
- if (db_get_b(0, protos[i]->szModuleName, "LockMainStatus", 0)) {
+ if (db_get_b(0, pa->szModuleName, "LockMainStatus", 0)) {
// if proto is locked, pstatus must be the current status
- if (pstatus != CallProtoService(protos[i]->szModuleName, PS_GETSTATUS, 0, 0))
+ if (pstatus != CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0))
return 0;
}
else {
@@ -295,12 +291,10 @@ INT_PTR SetStatusEx(WPARAM wParam, LPARAM)
static INT_PTR GetProtocolCountService(WPARAM, LPARAM)
{
- int pCount = 0, count;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&count, &accs);
+ int pCount = 0;
- for (int i = 0; i < count; i++)
- if (IsSuitableProto(accs[i]))
+ for (auto &pa : Accounts())
+ if (IsSuitableProto(pa))
pCount++;
return pCount;
diff --git a/plugins/StatusManager/src/main.cpp b/plugins/StatusManager/src/main.cpp
index 5d5db295e3..5996a200c6 100644
--- a/plugins/StatusManager/src/main.cpp
+++ b/plugins/StatusManager/src/main.cpp
@@ -83,13 +83,9 @@ int OnModulesLoaded(WPARAM, LPARAM)
////////////////////////////////////////////////////////////////////////////////////////
- int count;
- PROTOACCOUNT** protos;
- Proto_EnumAccounts(&count, &protos);
-
- for (int i = 0; i < count; i++)
- if (IsSuitableProto(protos[i]))
- protoList.insert(new SMProto(protos[i]));
+ for (auto &pa : Accounts())
+ if (IsSuitableProto(pa))
+ protoList.insert(new SMProto(pa));
return 0;
}