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/AddContactPlus/src | |
parent | 2f880bda3aa2d8817ce43481df9d99b12ed82a58 (diff) |
Accounts() : iterator for accounts
Diffstat (limited to 'plugins/AddContactPlus/src')
-rw-r--r-- | plugins/AddContactPlus/src/addcontact.cpp | 27 | ||||
-rw-r--r-- | plugins/AddContactPlus/src/main.cpp | 11 |
2 files changed, 18 insertions, 20 deletions
diff --git a/plugins/AddContactPlus/src/addcontact.cpp b/plugins/AddContactPlus/src/addcontact.cpp index 479dfd3fed..a48157af37 100644 --- a/plugins/AddContactPlus/src/addcontact.cpp +++ b/plugins/AddContactPlus/src/addcontact.cpp @@ -79,15 +79,13 @@ void AddContactDlgOpts(HWND hdlg, const char* szProto, BOOL bAuthOptsOnly = FALS bool AddContactDlgAccounts(HWND hdlg, AddDialogParam *acs)
{
- PROTOACCOUNT** pAccounts;
- int iRealAccCount, iAccCount = 0;
+ int iAccCount = 0;
- Proto_EnumAccounts(&iRealAccCount, &pAccounts);
- for (int i = 0; i < iRealAccCount; i++) {
- if (!pAccounts[i]->IsEnabled())
+ for (auto &pa : Accounts()) {
+ if (!pa->IsEnabled())
continue;
- DWORD dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ DWORD dwCaps = (DWORD)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if (dwCaps & PF1_BASICSEARCH || dwCaps & PF1_EXTSEARCH || dwCaps & PF1_SEARCHBYEMAIL || dwCaps & PF1_SEARCHBYNAME)
iAccCount++;
}
@@ -112,23 +110,26 @@ bool AddContactDlgAccounts(HWND hdlg, AddDialogParam *acs) cbei.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT | CBEIF_LPARAM;
HDC hdc = GetDC(hdlg);
SelectObject(hdc, (HFONT)SendDlgItemMessage(hdlg, IDC_PROTO, WM_GETFONT, 0, 0));
- for (int i = 0; i < iRealAccCount; i++) {
- if (!pAccounts[i]->IsEnabled()) continue;
- DWORD dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+
+ for (auto &pa : Accounts()) {
+ if (!pa->IsEnabled())
+ continue;
+
+ DWORD dwCaps = (DWORD)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if (!(dwCaps & PF1_BASICSEARCH) && !(dwCaps & PF1_EXTSEARCH) && !(dwCaps & PF1_SEARCHBYEMAIL) && !(dwCaps & PF1_SEARCHBYNAME))
continue;
- cbei.pszText = pAccounts[i]->tszAccountName;
+ cbei.pszText = pa->tszAccountName;
GetTextExtentPoint32(hdc, cbei.pszText, (int)mir_wstrlen(cbei.pszText), &textSize);
if (textSize.cx > cbWidth)
cbWidth = textSize.cx;
- HICON hIcon = (HICON)CallProtoService(pAccounts[i]->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
+ HICON hIcon = (HICON)CallProtoService(pa->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
cbei.iImage = cbei.iSelectedImage = ImageList_AddIcon(hIml, hIcon);
DestroyIcon(hIcon);
- cbei.lParam = (LPARAM)pAccounts[i]->szModuleName;
+ cbei.lParam = (LPARAM)pa->szModuleName;
SendDlgItemMessage(hdlg, IDC_PROTO, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
- if (cbei.lParam && !mir_strcmp(acs->proto, pAccounts[i]->szModuleName))
+ if (cbei.lParam && !mir_strcmp(acs->proto, pa->szModuleName))
iIndex = cbei.iItem;
cbei.iItem++;
}
diff --git a/plugins/AddContactPlus/src/main.cpp b/plugins/AddContactPlus/src/main.cpp index 9c80075431..30611ab8aa 100644 --- a/plugins/AddContactPlus/src/main.cpp +++ b/plugins/AddContactPlus/src/main.cpp @@ -74,15 +74,12 @@ static INT_PTR AddContactPlusDialog(WPARAM, LPARAM) static int OnAccListChanged(WPARAM, LPARAM)
{
- PROTOACCOUNT** pAccounts;
- int iRealAccCount, iAccCount = 0;
-
- Proto_EnumAccounts(&iRealAccCount, &pAccounts);
- for (int i = 0; i < iRealAccCount; i++) {
- if (!pAccounts[i]->IsEnabled())
+ int iAccCount = 0;
+ for (auto &pa : Accounts()) {
+ if (!pa->IsEnabled())
continue;
- DWORD dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ DWORD dwCaps = (DWORD)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if (dwCaps & PF1_BASICSEARCH || dwCaps & PF1_EXTSEARCH || dwCaps & PF1_SEARCHBYEMAIL || dwCaps & PF1_SEARCHBYNAME)
iAccCount++;
}
|