summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-09 19:32:32 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-09 19:32:39 +0300
commitdf6b0c988eb26339d4c7e4a1d0fe3b9717703c28 (patch)
tree5b4960edd6c9186e1fbc14f83f7f08a6a842f0a7 /protocols/JabberG/src
parent303dd9297732fc943ed3e20ab37587f0c009dfe5 (diff)
more loop-related code cleaning
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r--protocols/JabberG/src/jabber_opttree.cpp12
-rw-r--r--protocols/JabberG/src/jabber_search.cpp24
-rwxr-xr-xprotocols/JabberG/src/jabber_userinfo.cpp13
3 files changed, 22 insertions, 27 deletions
diff --git a/protocols/JabberG/src/jabber_opttree.cpp b/protocols/JabberG/src/jabber_opttree.cpp
index 047decb2be..c9ad4ba465 100644
--- a/protocols/JabberG/src/jabber_opttree.cpp
+++ b/protocols/JabberG/src/jabber_opttree.cpp
@@ -175,10 +175,10 @@ void CCtrlTreeOpts::OnApply()
{
CCtrlTreeView::OnApply();
- for (int i = 0; i < m_options.getCount(); i++) {
+ for (auto &it : m_options) {
TVITEMEX tvi;
- GetItem(m_options[i]->m_hItem, &tvi);
- *m_options[i]->m_option = ((tvi.iImage == IMG_CHECK) || (tvi.iImage == IMG_RCHECK)) ? 1 : 0;
+ GetItem(it->m_hItem, &tvi);
+ *it->m_option = ((tvi.iImage == IMG_CHECK) || (tvi.iImage == IMG_RCHECK)) ? 1 : 0;
}
}
@@ -208,11 +208,11 @@ void CCtrlTreeOpts::ProcessItemClick(HTREEITEM hti)
break;
case IMG_NORCHECK:
- for (int i = 0; i < m_options.getCount(); i++) {
- if (m_options[i]->m_groupId == m_options[tvi.lParam]->m_groupId) {
+ for (auto &it : m_options) {
+ if (it->m_groupId == m_options[tvi.lParam]->m_groupId) {
TVITEMEX tvi_tmp;
tvi_tmp.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvi_tmp.hItem = m_options[i]->m_hItem;
+ tvi_tmp.hItem = it->m_hItem;
tvi_tmp.iImage = tvi_tmp.iSelectedImage = IMG_NORCHECK;
SetItem(&tvi_tmp);
}
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp
index e325fad9fe..d0dfcfcbe3 100644
--- a/protocols/JabberG/src/jabber_search.cpp
+++ b/protocols/JabberG/src/jabber_search.cpp
@@ -209,12 +209,10 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M
{
LIST<wchar_t> ListOfNonEmptyFields(20, (LIST<wchar_t>::FTSortFunc)TCharKeyCmp);
LIST<wchar_t> ListOfFields(20);
- LIST<void>* plUsersInfo = (LIST<void>*)pvUsersInfo;
- int i, nUsersFound = plUsersInfo->getCount();
+ LIST<U_TCHAR_MAP> *plUsersInfo = (LIST<U_TCHAR_MAP>*)pvUsersInfo;
// lets fill the ListOfNonEmptyFields but in users order
- for (i = 0; i < nUsersFound; i++) {
- U_TCHAR_MAP* pmUserData = (U_TCHAR_MAP*)plUsersInfo->operator [](i);
+ for (auto &pmUserData : *plUsersInfo) {
int nUserFields = pmUserData->getCount();
for (int j = 0; j < nUserFields; j++) {
wchar_t *var = pmUserData->getKeyName(j);
@@ -225,7 +223,7 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M
// now fill the ListOfFields but order is from pmAllFields
int nAllCount = pmAllFields->getCount();
- for (i = 0; i < nAllCount; i++) {
+ for (int i = 0; i < nAllCount; i++) {
wchar_t *var = pmAllFields->getUnOrderedKeyName(i);
if (var && ListOfNonEmptyFields.getIndex(var) < 0)
continue;
@@ -241,7 +239,7 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M
Results.nFieldCount = nFieldCount;
/* Sending Columns Titles */
- for (i = 0; i < nFieldCount; i++) {
+ for (int i = 0; i < nFieldCount; i++) {
wchar_t *var = ListOfFields[i];
if (var)
Results.pszFields[i] = pmAllFields->operator [](var);
@@ -253,10 +251,9 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M
/* Sending Users Data */
Results.psr.cbSize = sizeof(Results.psr); // sending user data
- for (i = 0; i < nUsersFound; i++) {
+ for (auto &pmUserData : *plUsersInfo) {
wchar_t buff[200];
buff[0] = 0;
- U_TCHAR_MAP *pmUserData = (U_TCHAR_MAP *)plUsersInfo->operator [](i);
for (int j = 0; j < nFieldCount; j++) {
wchar_t *var = ListOfFields[j];
wchar_t *value = pmUserData->operator [](var);
@@ -554,14 +551,11 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR
SetDlgItemTextA(hwndDlg, IDC_SERVER, szServerName);
SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, (LPARAM)szServerName);
//TO DO: Add Transports here
- int i, transpCount = dat->ppro->m_lstTransports.getCount();
- for (i = 0; i < transpCount; i++) {
- wchar_t *szTransp = dat->ppro->m_lstTransports[i];
- if (szTransp)
- JabberSearchAddUrlToRecentCombo(hwndDlg, szTransp);
- }
+ for (auto &it : dat->ppro->m_lstTransports)
+ if (it != nullptr)
+ JabberSearchAddUrlToRecentCombo(hwndDlg, it);
- for (i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++) {
char key[30];
mir_snprintf(key, "RecentlySearched_%d", i);
ptrW szValue(dat->ppro->getWStringA(key));
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp
index 610cab6a87..203c1022e2 100755
--- a/protocols/JabberG/src/jabber_userinfo.cpp
+++ b/protocols/JabberG/src/jabber_userinfo.cpp
@@ -292,15 +292,16 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti
sttFillInfoLine(hwndTree, htiCaps, nullptr, nullptr, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i));
}
- for (int j = 0; j < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); j++, i++)
- if (jcb & ppro->m_lstJabberFeatCapPairsDynamic[j]->jcbCap) {
+ for (auto &it : ppro->m_lstJabberFeatCapPairsDynamic) {
+ if (jcb & it->jcbCap) {
wchar_t szDescription[1024];
- if (ppro->m_lstJabberFeatCapPairsDynamic[j]->szDescription)
- mir_snwprintf(szDescription, L"%s (%s)", TranslateW(ppro->m_lstJabberFeatCapPairsDynamic[j]->szDescription), ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature);
+ if (it->szDescription)
+ mir_snwprintf(szDescription, L"%s (%s)", TranslateW(it->szDescription), it->szFeature);
else
- wcsncpy_s(szDescription, ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature, _TRUNCATE);
- sttFillInfoLine(hwndTree, htiCaps, nullptr, nullptr, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i));
+ wcsncpy_s(szDescription, it->szFeature, _TRUNCATE);
+ sttFillInfoLine(hwndTree, htiCaps, nullptr, nullptr, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i++));
}
+ }
}
// Software info