summaryrefslogtreecommitdiff
path: root/plugins/Clist_nicer
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/Clist_nicer
parent2f880bda3aa2d8817ce43481df9d99b12ed82a58 (diff)
Accounts() : iterator for accounts
Diffstat (limited to 'plugins/Clist_nicer')
-rw-r--r--plugins/Clist_nicer/src/clistopts.cpp13
-rw-r--r--plugins/Clist_nicer/src/clui.cpp11
-rw-r--r--plugins/Clist_nicer/src/cluiservices.cpp21
-rw-r--r--plugins/Clist_nicer/src/extBackg.cpp15
-rw-r--r--plugins/Clist_nicer/src/viewmodes.cpp14
5 files changed, 30 insertions, 44 deletions
diff --git a/plugins/Clist_nicer/src/clistopts.cpp b/plugins/Clist_nicer/src/clistopts.cpp
index d713c58080..44fab1e82e 100644
--- a/plugins/Clist_nicer/src/clistopts.cpp
+++ b/plugins/Clist_nicer/src/clistopts.cpp
@@ -89,16 +89,13 @@ INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
int item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Global"));
SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)0);
- int count;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&count, &accs);
- for (int i = 0; i < count; i++) {
- if (!accs[i]->IsEnabled() || CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
+ for (auto &pa : Accounts()) {
+ if (!pa->IsEnabled() || CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
continue;
- item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName);
- SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)accs[i]);
- if (!mir_strcmp(szPrimaryStatus, accs[i]->szModuleName))
+ item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)pa->tszAccountName);
+ SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)pa);
+ if (!mir_strcmp(szPrimaryStatus, pa->szModuleName))
SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETCURSEL, item, 0);
}
}
diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp
index bf76dfffae..78de87fb99 100644
--- a/plugins/Clist_nicer/src/clui.cpp
+++ b/plugins/Clist_nicer/src/clui.cpp
@@ -259,17 +259,14 @@ static void InitIcoLib()
Icon_RegisterT(g_hInst, LPGENW("Contact list") L"/" LPGENW("Overlay icons"), &icon, 1);
}
- PROTOACCOUNT **accs = nullptr;
- int p_count = 0;
- Proto_EnumAccounts(&p_count, &accs);
- for (int k = 0; k < p_count; k++) {
- if (!accs[k]->IsEnabled() || CallProtoService(accs[k]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
+ for (auto &pa : Accounts()) {
+ if (!pa->IsEnabled() || CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
continue;
wchar_t szDescr[128];
- mir_snwprintf(szDescr, TranslateT("%s connecting"), accs[k]->tszAccountName);
+ mir_snwprintf(szDescr, TranslateT("%s connecting"), pa->tszAccountName);
IconItemT icon = { szDescr, "conn", IDI_PROTOCONNECTING };
- Icon_RegisterT(g_hInst, LPGENW("Contact list") L"/" LPGENW("Connecting icons"), &icon, 1, accs[k]->szModuleName);
+ Icon_RegisterT(g_hInst, LPGENW("Contact list") L"/" LPGENW("Connecting icons"), &icon, 1, pa->szModuleName);
}
}
diff --git a/plugins/Clist_nicer/src/cluiservices.cpp b/plugins/Clist_nicer/src/cluiservices.cpp
index 2e84ed6039..7f88c7b9fe 100644
--- a/plugins/Clist_nicer/src/cluiservices.cpp
+++ b/plugins/Clist_nicer/src/cluiservices.cpp
@@ -57,10 +57,8 @@ void CluiProtocolStatusChanged(int, const char*)
if (pcli->hwndStatus == nullptr || cfg::shutDown)
return;
- int protoCount;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&protoCount, &accs);
- if (protoCount == 0)
+ auto &accs = Accounts();
+ if (accs.getCount() == 0)
return;
FreeProtocolData();
@@ -70,7 +68,7 @@ void CluiProtocolStatusChanged(int, const char*)
int borders[3];
SendMessage(pcli->hwndStatus, SB_GETBORDERS, 0, (LPARAM)&borders);
- int *partWidths = (int*)_alloca((protoCount + 1)*sizeof(int));
+ int *partWidths = (int*)_alloca((accs.getCount() + 1)*sizeof(int));
int partCount;
if (cfg::dat.bEqualSections) {
@@ -78,13 +76,14 @@ void CluiProtocolStatusChanged(int, const char*)
GetClientRect(pcli->hwndStatus, &rc);
rc.right -= borders[0] * 2;
int toshow = 0;
- for (int i = 0; i < protoCount; i++)
- if (accs[i]->IsVisible())
+ for (auto &pa : accs)
+ if (pa->IsVisible())
toshow++;
if (toshow > 0) {
- for (int part = 0, i = 0; i < protoCount; i++) {
- if (!accs[i]->IsVisible())
+ int part = 0;
+ for (auto &pa : accs) {
+ if (!pa->IsVisible())
continue;
partWidths[part] = ((rc.right - rc.left - rdelta) / toshow)*(part + 1) + cfg::dat.bCLeft;
@@ -106,7 +105,7 @@ void CluiProtocolStatusChanged(int, const char*)
// count down since built in ones tend to go at the end
partCount = 0;
- for (int i = 0; i < protoCount; i++) {
+ for (int i = 0; i < accs.getCount(); i++) {
int idx = pcli->pfnGetAccountIndexByPos(i);
if (idx == -1)
continue;
@@ -151,7 +150,7 @@ void CluiProtocolStatusChanged(int, const char*)
// count down since built in ones tend to go at the end
char *szMaxProto = nullptr;
partCount = 0;
- for (int i = 0; i < protoCount; i++) {
+ for (int i = 0; i < accs.getCount(); i++) {
int idx = pcli->pfnGetAccountIndexByPos(i);
if (idx == -1)
continue;
diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp
index 7b8ff8a8ff..fb674e4b5e 100644
--- a/plugins/Clist_nicer/src/extBackg.cpp
+++ b/plugins/Clist_nicer/src/extBackg.cpp
@@ -277,20 +277,17 @@ void LoadExtBkSettingsFromDB()
arStatusItems.insert(p);
}
- int protoCount;
- PROTOACCOUNT **accs;
- Proto_EnumAccounts(&protoCount, &accs);
-
- for (int i = 0; i < protoCount; i++) {
+ auto &accs = Accounts();
+ for (auto &pa : accs) {
StatusItems_t *p = (StatusItems_t*)mir_alloc(sizeof(StatusItems_t));
*p = _StatusItems[0];
ID_EXTBK_LAST++;
- mir_snprintf(p->szDBname, "EXBK_%s", accs[i]->szModuleName);
- if (i == 0)
- mir_snprintf(p->szName, "{-}%s", accs[i]->szModuleName);
+ mir_snprintf(p->szDBname, "EXBK_%s", pa->szModuleName);
+ if (accs.indexOf(&pa) == 0)
+ mir_snprintf(p->szName, "{-}%s", pa->szModuleName);
else
- strncpy_s(p->szName, accs[i]->szModuleName, _TRUNCATE);
+ strncpy_s(p->szName, pa->szModuleName, _TRUNCATE);
p->statusID = ID_EXTBK_LAST;
arStatusItems.insert(p);
}
diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp
index c6851bf790..1939f5ec24 100644
--- a/plugins/Clist_nicer/src/viewmodes.cpp
+++ b/plugins/Clist_nicer/src/viewmodes.cpp
@@ -160,8 +160,6 @@ static int FillDialog(HWND hwnd)
LVCOLUMN lvc = { 0 };
HWND hwndList = GetDlgItem(hwnd, IDC_PROTOCOLS);
LVITEM item = { 0 };
- int protoCount = 0, i;
- PROTOACCOUNT **accs = nullptr;
CLVM_EnumModes(FillModes);
ListView_SetExtendedListViewStyle(hwndList, LVS_EX_CHECKBOXES);
@@ -170,13 +168,11 @@ static int FillDialog(HWND hwnd)
ListView_InsertColumn(hwndList, 0, &lvc);
// fill protocols...
-
- Proto_EnumAccounts(&protoCount, &accs);
item.mask = LVIF_TEXT | LVIF_PARAM;
item.iItem = 1000;
- for (i = 0; i < protoCount; i++) {
- item.lParam = (LPARAM)accs[i]->szModuleName;
- item.pszText = accs[i]->tszAccountName;
+ for (auto &pa : Accounts()) {
+ item.lParam = (LPARAM)pa->szModuleName;
+ item.pszText = pa->tszAccountName;
ListView_InsertItem(hwndList, &item);
}
@@ -195,7 +191,7 @@ static int FillDialog(HWND hwnd)
SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item);
wchar_t *grpName;
- for (i = 1; (grpName = Clist_GroupGetName(i, nullptr)) != nullptr; i++) {
+ for (int i = 1; (grpName = Clist_GroupGetName(i, nullptr)) != nullptr; i++) {
item.pszText = grpName;
SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item);
}
@@ -209,7 +205,7 @@ static int FillDialog(HWND hwnd)
lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT;
ListView_InsertColumn(hwndList, 0, &lvc);
- for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
+ for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
item.pszText = TranslateW(pcli->pfnGetStatusModeDescription(i, 0));
item.iItem = i - ID_STATUS_OFFLINE;
ListView_InsertItem(hwndList, &item);