diff options
author | George Hazan <ghazan@miranda.im> | 2018-01-26 22:31:20 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-01-26 22:31:27 +0300 |
commit | 391980ce1e890445542441eeb5d9f9cc18ae1baf (patch) | |
tree | ee1b165175dcdaeeaabd2ddb822542e648663a90 /protocols/JabberG | |
parent | bf8ad124d03b4fd059318d9ba8889b11faaf5b53 (diff) |
code optimization
Diffstat (limited to 'protocols/JabberG')
-rwxr-xr-x | protocols/JabberG/src/jabber_caps.cpp | 6 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_chat.cpp | 45 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_console.cpp | 35 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_disco.cpp | 71 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_groupchat.cpp | 6 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_icolib.cpp | 30 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iqid_muc.cpp | 12 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_misc.cpp | 6 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_opt.cpp | 8 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_privacy.cpp | 20 |
10 files changed, 119 insertions, 120 deletions
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index ae95ee5216..4b99b77219 100755 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -276,9 +276,9 @@ JabberCapsBits CJabberProto::GetResourceCapabilities(const wchar_t *jid, pResour wchar_t *token = wcstok(caps, L" ");
while (token) {
- for (int i = 0; i < _countof(g_JabberFeatCapPairsExt); i++) {
- if (!mir_wstrcmp(g_JabberFeatCapPairsExt[i].szFeature, token)) {
- jcbCaps |= g_JabberFeatCapPairsExt[i].jcbCap;
+ for (auto &it : g_JabberFeatCapPairsExt) {
+ if (!mir_wstrcmp(it.szFeature, token)) {
+ jcbCaps |= it.jcbCap;
break;
}
}
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 016a549279..bc0a6b43fb 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -121,10 +121,10 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) return 1;
// translate string for menus (this can't be done in initializer)
- for (int i = 0; i < _countof(sttAffiliationItems); i++)
- sttAffiliationItems[i].translate();
- for (int i = 0; i < _countof(sttRoleItems); i++)
- sttRoleItems[i].translate();
+ for (auto &it : sttAffiliationItems)
+ it.translate();
+ for (auto &it : sttRoleItems)
+ it.translate();
ptrW szNick(JabberNickFromJID(item->jid));
GCSessionInfoBase *si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, item->jid, szNick);
@@ -568,16 +568,16 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam) for (; idx <= IDM_LINK9; ++idx)
sttFindGcMenuItem(_countof(sttListItems), sttListItems, idx)->uType = 0;
- for (i = 0; i < _countof(sttAffiliationItems); i++) {
- gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, sttAffiliationItems[i].id);
- pItem->uType = (him->m_affiliation == sttAffiliationItems[i].value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
- pItem->bDisabled = !(force || sttAffiliationItems[i].check(me, him));
+ for (auto &it : sttAffiliationItems) {
+ gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, it.id);
+ pItem->uType = (him->m_affiliation == it.value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
+ pItem->bDisabled = !(force || it.check(me, him));
}
- for (i = 0; i < _countof(sttRoleItems); i++) {
- gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, sttRoleItems[i].id);
- pItem->uType = (him->m_role == sttRoleItems[i].value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
- pItem->bDisabled = !(force || sttRoleItems[i].check(me, him));
+ for (auto &it : sttRoleItems) {
+ gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, it.id);
+ pItem->uType = (him->m_role == it.value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
+ pItem->bDisabled = !(force || it.check(me, him));
}
if (him->m_tszRealJid && *him->m_tszRealJid) {
@@ -847,21 +847,22 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam SetDlgItemText(hwndDlg, IDC_TXT_JID, dat->him->m_tszRealJid ? dat->him->m_tszRealJid : TranslateT("Real JID not available"));
SetDlgItemText(hwndDlg, IDC_TXT_STATUS, dat->him->m_tszStatusMessage);
- for (int i = 0; i < _countof(sttRoleItems); i++) {
- if ((sttRoleItems[i].value == dat->him->m_role) || sttRoleItems[i].check(dat->me, dat->him)) {
+ for (auto &it : sttRoleItems) {
+ if ((it.value == dat->him->m_role) || it.check(dat->me, dat->him)) {
SendDlgItemMessage(hwndDlg, IDC_TXT_ROLE, CB_SETITEMDATA,
- idx = SendDlgItemMessage(hwndDlg, IDC_TXT_ROLE, CB_ADDSTRING, 0, (LPARAM)sttRoleItems[i].title),
- sttRoleItems[i].value);
- if (sttRoleItems[i].value == dat->him->m_role)
+ idx = SendDlgItemMessage(hwndDlg, IDC_TXT_ROLE, CB_ADDSTRING, 0, (LPARAM)it.title),
+ it.value);
+ if (it.value == dat->him->m_role)
SendDlgItemMessage(hwndDlg, IDC_TXT_ROLE, CB_SETCURSEL, idx, 0);
}
}
- for (int i = 0; i < _countof(sttAffiliationItems); i++) {
- if ((sttAffiliationItems[i].value == dat->him->m_affiliation) || sttAffiliationItems[i].check(dat->me, dat->him)) {
+
+ for (auto &it : sttAffiliationItems) {
+ if ((it.value == dat->him->m_affiliation) || it.check(dat->me, dat->him)) {
SendDlgItemMessage(hwndDlg, IDC_TXT_AFFILIATION, CB_SETITEMDATA,
- idx = SendDlgItemMessage(hwndDlg, IDC_TXT_AFFILIATION, CB_ADDSTRING, 0, (LPARAM)sttAffiliationItems[i].title),
- sttAffiliationItems[i].value);
- if (sttAffiliationItems[i].value == dat->him->m_affiliation)
+ idx = SendDlgItemMessage(hwndDlg, IDC_TXT_AFFILIATION, CB_ADDSTRING, 0, (LPARAM)it.title),
+ it.value);
+ if (it.value == dat->him->m_affiliation)
SendDlgItemMessage(hwndDlg, IDC_TXT_AFFILIATION, CB_SETCURSEL, idx, 0);
}
}
diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp index 6dcd528ddd..32ba0492f0 100644 --- a/protocols/JabberG/src/jabber_console.cpp +++ b/protocols/JabberG/src/jabber_console.cpp @@ -370,18 +370,20 @@ void CJabberDlgConsole::OnInitDialog() { IDC_BTN_FILTER_REFRESH, "Refresh list", "sd_nav_refresh", false, FALSE},
};
- for (int i=0; i < _countof(buttons); i++) {
- SendDlgItemMessage(m_hwnd, buttons[i].idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(buttons[i].icon));
- SendDlgItemMessage(m_hwnd, buttons[i].idc, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(m_hwnd, buttons[i].idc, BUTTONADDTOOLTIP, (WPARAM)buttons[i].title, 0);
- if (buttons[i].push) SendDlgItemMessage(m_hwnd, buttons[i].idc, BUTTONSETASPUSHBTN, TRUE, 0);
- if (buttons[i].pushed) CheckDlgButton(m_hwnd, buttons[i].idc, BST_CHECKED);
+ for (auto &it : buttons) {
+ SendDlgItemMessage(m_hwnd, it.idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon));
+ SendDlgItemMessage(m_hwnd, it.idc, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(m_hwnd, it.idc, BUTTONADDTOOLTIP, (WPARAM)it.title, 0);
+ if (it.push)
+ SendDlgItemMessage(m_hwnd, it.idc, BUTTONSETASPUSHBTN, TRUE, 0);
+ if (it.pushed)
+ CheckDlgButton(m_hwnd, it.idc, BST_CHECKED);
}
- for (int i=0; i < _countof(filter_modes); i++)
- if (filter_modes[i].type == m_proto->m_filterInfo.type) {
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(filter_modes[i].icon)));
- SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(filter_modes[i].icon));
+ for (auto &it : filter_modes)
+ if (it.type == m_proto->m_filterInfo.type) {
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon)));
+ SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon));
break;
}
@@ -563,12 +565,9 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) break;
case IDC_BTN_FILTER:
- int i;
HMENU hMenu = CreatePopupMenu();
- for (i = 0; i < _countof(filter_modes); i++)
- AppendMenu(hMenu,
- MF_STRING | ((filter_modes[i].type == m_proto->m_filterInfo.type) ? MF_CHECKED : 0),
- filter_modes[i].type + 1, TranslateW(filter_modes[i].title));
+ for (auto &it : filter_modes)
+ AppendMenu(hMenu, MF_STRING | ((it.type == m_proto->m_filterInfo.type) ? MF_CHECKED : 0), it.type + 1, TranslateW(it.title));
RECT rc; GetWindowRect(GetDlgItem(m_hwnd, IDC_BTN_FILTER), &rc);
CheckDlgButton(m_hwnd, IDC_BTN_FILTER, BST_CHECKED);
@@ -578,9 +577,9 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (res) {
m_proto->m_filterInfo.type = (TFilterInfo::Type)(res - 1);
- for (i = 0; i < _countof(filter_modes); i++) {
- if (filter_modes[i].type == m_proto->m_filterInfo.type) {
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(filter_modes[i].icon)));
+ for (auto &it : filter_modes) {
+ if (it.type == m_proto->m_filterInfo.type) {
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon)));
break;
}
}
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index 3d22509c35..04dae8fcf2 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -512,25 +512,26 @@ void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode) iOverlay = SD_OVERLAY_NONE;
}
- for (int i = 0; i < _countof(sttNodeIcons); i++) {
- if (!sttNodeIcons[i].iconIndex && !sttNodeIcons[i].iconName) continue;
+ for (auto &it : sttNodeIcons) {
+ if (!it.iconIndex && !it.iconName)
+ continue;
- if (sttNodeIcons[i].category) {
+ if (it.category) {
CJabberSDIdentity *iIdentity;
for (iIdentity = pNode->GetFirstIdentity(); iIdentity; iIdentity = iIdentity->GetNext())
- if (!mir_wstrcmp(iIdentity->GetCategory(), sttNodeIcons[i].category) &&
- (!sttNodeIcons[i].type || !mir_wstrcmp(iIdentity->GetType(), sttNodeIcons[i].type))) {
- iIcon = sttNodeIcons[i].listIndex;
+ if (!mir_wstrcmp(iIdentity->GetCategory(), it.category) &&
+ (!it.type || !mir_wstrcmp(iIdentity->GetType(), it.type))) {
+ iIcon = it.listIndex;
break;
}
if (iIdentity) break;
}
- if (sttNodeIcons[i].feature) {
+ if (it.feature) {
CJabberSDFeature *iFeature;
for (iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext())
- if (!mir_wstrcmp(iFeature->GetVar(), sttNodeIcons[i].feature)) {
- iIcon = sttNodeIcons[i].listIndex;
+ if (!mir_wstrcmp(iFeature->GetVar(), it.feature)) {
+ iIcon = it.listIndex;
break;
}
if (iFeature) break;
@@ -677,19 +678,19 @@ void CJabberDlgDiscovery::OnInitDialog() TreeList_Create(hwndList);
TreeList_AddIcon(hwndList, m_proto->LoadIconEx("main"), 0);
- for (int i = 0; i < _countof(sttNodeIcons); i++) {
+ for (auto &it : sttNodeIcons) {
bool needDestroy = false;
HICON hIcon;
- if ((sttNodeIcons[i].iconIndex == SKINICON_STATUS_ONLINE) && sttNodeIcons[i].iconName) {
- hIcon = (HICON)CallProtoService(sttNodeIcons[i].iconName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
+ if ((it.iconIndex == SKINICON_STATUS_ONLINE) && it.iconName) {
+ hIcon = (HICON)CallProtoService(it.iconName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
needDestroy = true;
}
- else if (sttNodeIcons[i].iconName)
- hIcon = m_proto->LoadIconEx(sttNodeIcons[i].iconName);
- else if (sttNodeIcons[i].iconIndex)
- hIcon = Skin_LoadIcon(sttNodeIcons[i].iconIndex);
+ else if (it.iconName)
+ hIcon = m_proto->LoadIconEx(it.iconName);
+ else if (it.iconIndex)
+ hIcon = Skin_LoadIcon(it.iconIndex);
else continue;
- sttNodeIcons[i].listIndex = TreeList_AddIcon(hwndList, hIcon, 0);
+ it.listIndex = TreeList_AddIcon(hwndList, hIcon, 0);
if (needDestroy) DestroyIcon(hIcon);
}
TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_fail"), SD_OVERLAY_FAIL);
@@ -1207,37 +1208,37 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM HMENU hMenu = CreatePopupMenu();
BOOL lastSeparator = TRUE;
bool bFilterItems = !GetAsyncKeyState(VK_CONTROL);
- for (int i = 0; i < _countof(items); i++) {
+ for (auto &it : items) {
JABBER_LIST_ITEM *rosterItem = nullptr;
if (bFilterItems) {
- if ((items[i].flags & SD_FLG_NONODE) && pNode->GetNode())
+ if ((it.flags & SD_FLG_NONODE) && pNode->GetNode())
continue;
- if ((items[i].flags & SD_FLG_NOTONROSTER) && (rosterItem = ListGetItemPtr(LIST_ROSTER, pNode->GetJid())))
+ if ((it.flags & SD_FLG_NOTONROSTER) && (rosterItem = ListGetItemPtr(LIST_ROSTER, pNode->GetJid())))
continue;
- if ((items[i].flags & SD_FLG_ONROSTER) && !(rosterItem = ListGetItemPtr(LIST_ROSTER, pNode->GetJid())))
+ if ((it.flags & SD_FLG_ONROSTER) && !(rosterItem = ListGetItemPtr(LIST_ROSTER, pNode->GetJid())))
continue;
- if ((items[i].flags & SD_FLG_SUBSCRIBED) && (!rosterItem || (rosterItem->subscription == SUB_NONE)))
+ if ((it.flags & SD_FLG_SUBSCRIBED) && (!rosterItem || (rosterItem->subscription == SUB_NONE)))
continue;
- if ((items[i].flags & SD_FLG_NOTSUBSCRIBED) && (rosterItem && (rosterItem->subscription != SUB_NONE)))
+ if ((it.flags & SD_FLG_NOTSUBSCRIBED) && (rosterItem && (rosterItem->subscription != SUB_NONE)))
continue;
- if ((items[i].flags & SD_FLG_ONLINE) && rosterItem && (rosterItem->getTemp()->m_iStatus != ID_STATUS_OFFLINE))
+ if ((it.flags & SD_FLG_ONLINE) && rosterItem && (rosterItem->getTemp()->m_iStatus != ID_STATUS_OFFLINE))
continue;
- if ((items[i].flags & SD_FLG_NOTONLINE) && rosterItem && (rosterItem->getTemp()->m_iStatus == ID_STATUS_OFFLINE))
+ if ((it.flags & SD_FLG_NOTONLINE) && rosterItem && (rosterItem->getTemp()->m_iStatus == ID_STATUS_OFFLINE))
continue;
- if ((items[i].flags & SD_FLG_NORESOURCE) && wcschr(pNode->GetJid(), '/'))
+ if ((it.flags & SD_FLG_NORESOURCE) && wcschr(pNode->GetJid(), '/'))
continue;
- if ((items[i].flags & SD_FLG_HASUSER) && !wcschr(pNode->GetJid(), '@'))
+ if ((it.flags & SD_FLG_HASUSER) && !wcschr(pNode->GetJid(), '@'))
continue;
}
- if (!items[i].feature) {
- if (items[i].title) {
+ if (!it.feature) {
+ if (it.title) {
MCONTACT hContact;
- if ((items[i].action == SD_ACT_USERMENU) && (hContact = HContactFromJID(pNode->GetJid()))) {
+ if ((it.action == SD_ACT_USERMENU) && (hContact = HContactFromJID(pNode->GetJid()))) {
HMENU hContactMenu = Menu_BuildContactMenu(hContact);
- AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hContactMenu, TranslateW(items[i].title));
+ AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hContactMenu, TranslateW(it.title));
}
- else AppendMenu(hMenu, MF_STRING, items[i].action, TranslateW(items[i].title));
+ else AppendMenu(hMenu, MF_STRING, it.action, TranslateW(it.title));
lastSeparator = FALSE;
}
else if (!lastSeparator) {
@@ -1250,14 +1251,14 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM bool bFeatureOk = !bFilterItems;
if (bFilterItems)
for (CJabberSDFeature *iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext())
- if (!mir_wstrcmp(iFeature->GetVar(), items[i].feature)) {
+ if (!mir_wstrcmp(iFeature->GetVar(), it.feature)) {
bFeatureOk = true;
break;
}
if (bFeatureOk) {
- if (items[i].title) {
- AppendMenu(hMenu, MF_STRING, items[i].action, TranslateW(items[i].title));
+ if (it.title) {
+ AppendMenu(hMenu, MF_STRING, it.action, TranslateW(it.title));
lastSeparator = FALSE;
}
else if (!lastSeparator) {
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 378716e219..c93f8397e0 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -369,10 +369,10 @@ static void sttJoinDlgShowRecentItems(HWND hwndDlg, int newCount) RECT rc;
int ctrls[] = { IDC_BOOKMARKS, IDOK, IDCANCEL };
- for (int i = 0; i < _countof(ctrls); i++) {
- GetWindowRect(GetDlgItem(hwndDlg, ctrls[i]), &rc);
+ for (auto &it : ctrls) {
+ GetWindowRect(GetDlgItem(hwndDlg, it), &rc);
MapWindowPoints(nullptr, hwndDlg, (LPPOINT)&rc, 2);
- SetWindowPos(GetDlgItem(hwndDlg, ctrls[i]), nullptr, rc.left, rc.top + offset, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+ SetWindowPos(GetDlgItem(hwndDlg, it), nullptr, rc.left, rc.top + offset, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
GetWindowRect(hwndDlg, &rc);
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index af4f030dd3..5eb0a99b24 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -423,8 +423,8 @@ BOOL CJabberProto::DBCheckIsTransportedContact(const wchar_t *jid, MCONTACT hCon if (resourcepos != nullptr)
*resourcepos = '\0';
- for (int i = 0; i < _countof(TransportProtoTable); i++)
- if (MatchMask(domain, TransportProtoTable[i].mask)) {
+ for (auto &it : TransportProtoTable)
+ if (MatchMask(domain, it.mask)) {
GetTransportStatusIconIndex(GetTransportProtoID(domain), ID_STATUS_OFFLINE);
isTransported = TRUE;
break;
@@ -530,23 +530,21 @@ void g_IconsInit() HANDLE g_GetIconHandle(int iconId)
{
- int i;
-
- for (i = 0; i < _countof(sharedIconList1); i++)
- if (sharedIconList1[i].defIconID == iconId)
- return sharedIconList1[i].hIcolib;
+ for (auto &it : sharedIconList1)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
- for (i = 0; i < _countof(sharedIconList2); i++)
- if (sharedIconList2[i].defIconID == iconId)
- return sharedIconList2[i].hIcolib;
+ for (auto &it : sharedIconList2)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
- for (i = 0; i < _countof(sharedIconList3); i++)
- if (sharedIconList3[i].defIconID == iconId)
- return sharedIconList3[i].hIcolib;
+ for (auto &it : sharedIconList3)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
- for (i = 0; i < _countof(sharedIconList4); i++)
- if (sharedIconList4[i].defIconID == iconId)
- return sharedIconList4[i].hIcolib;
+ for (auto &it : sharedIconList4)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
return nullptr;
}
diff --git a/protocols/JabberG/src/jabber_iqid_muc.cpp b/protocols/JabberG/src/jabber_iqid_muc.cpp index 576589110f..7610621e28 100644 --- a/protocols/JabberG/src/jabber_iqid_muc.cpp +++ b/protocols/JabberG/src/jabber_iqid_muc.cpp @@ -199,12 +199,12 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w SendMessage(hwndDlg, WM_JABBER_REFRESH, 0, lParam);
dat = (JABBER_MUC_JIDLIST_INFO*)lParam;
- for (int i = 0; i < _countof(buttons); i++) {
- SendDlgItemMessage(hwndDlg, buttons[i].idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)dat->ppro->LoadIconEx(buttons[i].icon));
- SendDlgItemMessage(hwndDlg, buttons[i].idc, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwndDlg, buttons[i].idc, BUTTONADDTOOLTIP, (WPARAM)buttons[i].title, 0);
- if (buttons[i].push)
- SendDlgItemMessage(hwndDlg, buttons[i].idc, BUTTONSETASPUSHBTN, TRUE, 0);
+ for (auto &it : buttons) {
+ SendDlgItemMessage(hwndDlg, it.idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)dat->ppro->LoadIconEx(it.icon));
+ SendDlgItemMessage(hwndDlg, it.idc, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, it.idc, BUTTONADDTOOLTIP, (WPARAM)it.title, 0);
+ if (it.push)
+ SendDlgItemMessage(hwndDlg, it.idc, BUTTONSETASPUSHBTN, TRUE, 0);
}
Utils_RestoreWindowPosition(hwndDlg, 0, dat->ppro->m_szModuleName, "jidListWnd_");
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index b90a09bc53..7c1c4a0b5b 100755 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -262,9 +262,9 @@ static sttCapsNodeToName_Map[] = const wchar_t* CJabberProto::GetSoftName(const wchar_t *wszName)
{
// search through known software list
- for (int i = 0; i < _countof(sttCapsNodeToName_Map); i++)
- if (wcsstr(wszName, sttCapsNodeToName_Map[i].node))
- return sttCapsNodeToName_Map[i].name;
+ for (auto &it : sttCapsNodeToName_Map)
+ if (wcsstr(wszName, it.node))
+ return it.name;
return nullptr;
}
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 6387b0ab1c..5b751fc96f 100755 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -435,8 +435,8 @@ protected: // fill predefined resources
wchar_t *szResources[] = { L"Home", L"Work", L"Office", L"Miranda" };
- for (int i = 0; i < _countof(szResources); i++)
- m_cbResource.AddString(szResources[i]);
+ for (auto &it : szResources)
+ m_cbResource.AddString(it);
// append computer name to the resource list
wchar_t szCompName[MAX_COMPUTERNAME_LENGTH + 1];
@@ -1585,8 +1585,8 @@ protected: // fill predefined resources
wchar_t *szResources[] = { L"Home", L"Work", L"Office", L"Miranda" };
- for (int i = 0; i < _countof(szResources); i++)
- m_cbResource.AddString(szResources[i]);
+ for (auto &it : szResources)
+ m_cbResource.AddString(it);
// append computer name to the resource list
wchar_t szCompName[MAX_COMPUTERNAME_LENGTH + 1];
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index 6ae2f75dc1..f189e90b17 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -378,9 +378,9 @@ public: SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_RESETCONTENT, 0, 0);
wchar_t *szSubscriptions[] = { L"none", L"from", L"to", L"both" };
- for (i=0; i < _countof(szSubscriptions); i++) {
- LRESULT nItem = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_ADDSTRING, 0, (LPARAM)TranslateW(szSubscriptions[i]));
- SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETITEMDATA, nItem, (LPARAM)szSubscriptions[i]);
+ for (auto &it : szSubscriptions) {
+ LRESULT nItem = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETITEMDATA, nItem, (LPARAM)it);
}
PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_COMBO_TYPE, CBN_SELCHANGE), 0);
@@ -945,11 +945,11 @@ BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam) else if (lpdis->CtlID == IDC_LB_LISTS)
DrawLists(lpdis);
else if (lpdis->CtlID == IDC_CANVAS) {
- int i, totalWidth = -5; // spacing for last item
- for (i=0; i < _countof(drawItems); i++) {
+ int totalWidth = -5; // spacing for last item
+ for (auto &it : drawItems) {
SIZE sz = {0};
- drawItems[i].text = TranslateW(drawItems[i].textEng);
- GetTextExtentPoint32(lpdis->hDC, drawItems[i].text, (int)mir_wstrlen(drawItems[i].text), &sz);
+ it.text = TranslateW(it.textEng);
+ GetTextExtentPoint32(lpdis->hDC, it.text, (int)mir_wstrlen(it.text), &sz);
totalWidth += sz.cx + 18 + 5; // 18 pixels for icon, 5 pixel spacing
}
@@ -957,11 +957,11 @@ BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam) RECT rc = lpdis->rcItem;
rc.left = (rc.left + rc.right - totalWidth)/2;
- for (i=0; i < _countof(drawItems); i++) {
- DrawIconEx(lpdis->hDC, rc.left, (rc.top+rc.bottom-16)/2, m_proto->LoadIconEx(drawItems[i].icon),
+ for (auto &it : drawItems) {
+ DrawIconEx(lpdis->hDC, rc.left, (rc.top+rc.bottom-16)/2, m_proto->LoadIconEx(it.icon),
16, 16, 0, nullptr, DI_NORMAL);
rc.left += 18;
- DrawNextRulePart(lpdis->hDC, clText, drawItems[i].text, &rc);
+ DrawNextRulePart(lpdis->hDC, clText, it.text, &rc);
rc.left += 5;
}
}
|