summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-21 18:36:32 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-21 18:40:14 +0300
commit6e96535fdbb886dcad1a3396659b368283922e64 (patch)
treeef1a35a5ca0c43fcf10a1190a47853588e90cddc /protocols/JabberG/src
parentfd23a292afc4aa760a0ff8ab646eebe5942fb06d (diff)
Jabber: C++'11 iterators
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r--protocols/JabberG/src/jabber_api.cpp34
-rwxr-xr-xprotocols/JabberG/src/jabber_caps.cpp37
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp31
-rw-r--r--protocols/JabberG/src/jabber_form.cpp24
-rw-r--r--protocols/JabberG/src/jabber_frame.cpp37
-rw-r--r--protocols/JabberG/src/jabber_iq.cpp20
-rwxr-xr-xprotocols/JabberG/src/jabber_iqid.cpp8
-rw-r--r--protocols/JabberG/src/jabber_list.cpp25
-rw-r--r--protocols/JabberG/src/jabber_menu.cpp16
-rw-r--r--protocols/JabberG/src/jabber_message_manager.cpp18
-rw-r--r--protocols/JabberG/src/jabber_notes.cpp25
-rw-r--r--protocols/JabberG/src/jabber_opttree.cpp4
-rw-r--r--protocols/JabberG/src/jabber_presence_manager.cpp8
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp20
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.cpp50
-rw-r--r--protocols/JabberG/src/jabber_search.cpp4
-rw-r--r--protocols/JabberG/src/jabber_search.h123
-rw-r--r--protocols/JabberG/src/jabber_send_manager.cpp8
-rwxr-xr-xprotocols/JabberG/src/jabber_thread.cpp6
-rw-r--r--protocols/JabberG/src/jabber_treelist.cpp18
-rwxr-xr-xprotocols/JabberG/src/jabber_userinfo.cpp60
-rwxr-xr-xprotocols/JabberG/src/jabber_util.cpp12
-rw-r--r--protocols/JabberG/src/jabber_xstatus.h38
23 files changed, 293 insertions, 333 deletions
diff --git a/protocols/JabberG/src/jabber_api.cpp b/protocols/JabberG/src/jabber_api.cpp
index bc5011c7cd..a00cdab090 100644
--- a/protocols/JabberG/src/jabber_api.cpp
+++ b/protocols/JabberG/src/jabber_api.cpp
@@ -88,8 +88,8 @@ LPTSTR CJabberProto::GetResourceList(LPCTSTR jid)
return nullptr;
CMStringW res;
- for (int i=0; i < item->arResources.getCount(); i++) {
- res.Append(item->arResources[i]->m_tszResourceName);
+ for (auto &it : item->arResources) {
+ res.Append(it->m_tszResourceName);
res.AppendChar(0);
}
res.AppendChar(0);
@@ -198,9 +198,9 @@ int CJabberProto::RemoveHandler(HJHANDLER hHandler)
JabberFeatCapPairDynamic *CJabberProto::FindFeature(LPCTSTR szFeature)
{
- for (int i=0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++)
- if (!mir_wstrcmp(m_lstJabberFeatCapPairsDynamic[i]->szFeature, szFeature))
- return m_lstJabberFeatCapPairsDynamic[i];
+ for (auto &it : m_lstJabberFeatCapPairsDynamic)
+ if (!mir_wstrcmp(it->szFeature, szFeature))
+ return it;
return nullptr;
}
@@ -226,8 +226,8 @@ int CJabberProto::RegisterFeature(LPCTSTR szFeature, LPCTSTR szDescription)
jcb |= g_JabberFeatCapPairs[i].jcbCap;
// set all bits already occupied by external plugins
- for (i=0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++)
- jcb |= m_lstJabberFeatCapPairsDynamic[i]->jcbCap;
+ for (auto &it : m_lstJabberFeatCapPairsDynamic)
+ jcb |= it->jcbCap;
// Now get first zero bit. The line below is a fast way to do it. If there are no zero bits, it returns 0.
jcb = (~jcb) & (JabberCapsBits)(-(__int64)(~jcb));
@@ -323,30 +323,30 @@ LPTSTR CJabberProto::GetResourceFeatures(LPCTSTR jid)
return nullptr;
mir_cslockfull lck(m_csLists);
- int i;
+
size_t iLen = 1; // 1 for extra zero terminator at the end of the string
// calculate total necessary string length
- for (i=0; g_JabberFeatCapPairs[i].szFeature; i++)
+ for (int i=0; g_JabberFeatCapPairs[i].szFeature; i++)
if (jcb & g_JabberFeatCapPairs[i].jcbCap)
iLen += mir_wstrlen(g_JabberFeatCapPairs[i].szFeature) + 1;
- for (i=0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++)
- if (jcb & m_lstJabberFeatCapPairsDynamic[i]->jcbCap)
- iLen += mir_wstrlen(m_lstJabberFeatCapPairsDynamic[i]->szFeature) + 1;
+ for (auto &it : m_lstJabberFeatCapPairsDynamic)
+ if (jcb & it->jcbCap)
+ iLen += mir_wstrlen(it->szFeature) + 1;
// allocate memory and fill it
LPTSTR str = (LPTSTR)mir_alloc(iLen * sizeof(wchar_t));
LPTSTR p = str;
- for (i=0; g_JabberFeatCapPairs[i].szFeature; i++)
+ for (int i=0; g_JabberFeatCapPairs[i].szFeature; i++)
if (jcb & g_JabberFeatCapPairs[i].jcbCap) {
mir_wstrcpy(p, g_JabberFeatCapPairs[i].szFeature);
p += mir_wstrlen(g_JabberFeatCapPairs[i].szFeature) + 1;
}
- for (i=0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++)
- if (jcb & m_lstJabberFeatCapPairsDynamic[i]->jcbCap) {
- mir_wstrcpy(p, m_lstJabberFeatCapPairsDynamic[i]->szFeature);
- p += mir_wstrlen(m_lstJabberFeatCapPairsDynamic[i]->szFeature) + 1;
+ for (auto &it : m_lstJabberFeatCapPairsDynamic)
+ if (jcb & it->jcbCap) {
+ mir_wstrcpy(p, it->szFeature);
+ p += mir_wstrlen(it->szFeature) + 1;
}
*p = 0; // extra zero terminator
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp
index 83a13dcd39..51b10cfd8a 100755
--- a/protocols/JabberG/src/jabber_caps.cpp
+++ b/protocols/JabberG/src/jabber_caps.cpp
@@ -218,10 +218,10 @@ JabberCapsBits CJabberProto::GetTotalJidCapabilities(const wchar_t *jid)
}
if (item) {
- for (int i = 0; i < item->arResources.getCount(); i++) {
+ for (auto &it : item->arResources) {
wchar_t szFullJid[JABBER_MAX_JID_LEN];
- mir_snwprintf(szFullJid, L"%s/%s", szBareJid, item->arResources[i]->m_tszResourceName);
- pResourceStatus r(item->arResources[i]);
+ mir_snwprintf(szFullJid, L"%s/%s", szBareJid, it->m_tszResourceName);
+ pResourceStatus r(it);
JabberCapsBits jcb = GetResourceCapabilities(szFullJid, r);
if (!(jcb & JABBER_RESOURCE_CAPS_ERROR))
jcbToReturn |= jcb;
@@ -467,8 +467,8 @@ void CJabberClientCapsManager::UpdateFeatHash()
m_szFeaturesCrc.Empty();
JabberCapsBits jcb = JABBER_CAPS_MIRANDA_ALL;
- for (int i = 0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++)
- jcb |= ppro->m_lstJabberFeatCapPairsDynamic[i]->jcbCap;
+ for (auto &it : ppro->m_lstJabberFeatCapPairsDynamic)
+ jcb |= it->jcbCap;
if (!ppro->m_options.AllowVersionRequests)
jcb &= ~JABBER_CAPS_VERSION;
@@ -482,9 +482,9 @@ void CJabberClientCapsManager::UpdateFeatHash()
feat_buf.AppendChar('<');
}
- for (int i = 0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++)
- if (jcb & ppro->m_lstJabberFeatCapPairsDynamic[i]->jcbCap) {
- feat_buf.Append(_T2A(ppro->m_lstJabberFeatCapPairsDynamic[i]->szFeature));
+ for (auto &it : ppro->m_lstJabberFeatCapPairsDynamic)
+ if (jcb & it->jcbCap) {
+ feat_buf.Append(_T2A(it->szFeature));
feat_buf.AppendChar('<');
}
@@ -555,7 +555,6 @@ CJabberClientPartialCaps* CJabberClientCapsManager::SetClientCaps(const wchar_t
bool CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, const wchar_t *szNode)
{
- int i;
JabberCapsBits jcb = 0;
if (szNode) {
@@ -566,7 +565,7 @@ bool CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, con
goto LBL_All;
}
- for (i = 0; g_JabberFeatCapPairsExt[i].szFeature; i++) {
+ for (int i = 0; g_JabberFeatCapPairsExt[i].szFeature; i++) {
if (!g_JabberFeatCapPairsExt[i].Valid())
continue;
// TODO: something better here
@@ -579,12 +578,12 @@ bool CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, con
}
// check features registered through IJabberNetInterface::RegisterFeature() and IJabberNetInterface::AddFeatures()
- for (i = 0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
+ for (auto &it : ppro->m_lstJabberFeatCapPairsDynamic) {
// TODO: something better here
- mir_snwprintf(szExtCap, L"%s#%s", JABBER_CAPS_MIRANDA_NODE, ppro->m_lstJabberFeatCapPairsDynamic[i]->szExt);
+ mir_snwprintf(szExtCap, L"%s#%s", JABBER_CAPS_MIRANDA_NODE, it->szExt);
mir_snwprintf(szExtCapWHash, L"%s %s", szExtCap, m_szFeaturesCrc.c_str());
if (!mir_wstrcmp(szNode, szExtCap) || !mir_wstrcmp(szNode, szExtCapWHash)) {
- jcb = ppro->m_lstJabberFeatCapPairsDynamic[i]->jcbCap;
+ jcb = it->jcbCap;
break;
}
}
@@ -596,8 +595,8 @@ bool CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, con
else {
LBL_All:
jcb = JABBER_CAPS_MIRANDA_ALL;
- for (i=0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++)
- jcb |= ppro->m_lstJabberFeatCapPairsDynamic[i]->jcbCap;
+ for (auto &it : ppro->m_lstJabberFeatCapPairsDynamic)
+ jcb |= it->jcbCap;
}
if (ppro->m_options.UseOMEMO)
@@ -615,13 +614,13 @@ LBL_All:
CMStringW szName(FORMAT, L"Miranda %d.%d.%d.%d", __MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM);
query << XCHILD(L"identity") << XATTR(L"category", L"client") << XATTR(L"type", L"pc") << XATTR(L"name", szName);
- for (i=0; g_JabberFeatCapPairs[i].szFeature; i++)
+ for (int i=0; g_JabberFeatCapPairs[i].szFeature; i++)
if (jcb & g_JabberFeatCapPairs[i].jcbCap)
query << XCHILD(L"feature") << XATTR(L"var", g_JabberFeatCapPairs[i].szFeature);
- for (i=0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++)
- if (jcb & ppro->m_lstJabberFeatCapPairsDynamic[i]->jcbCap)
- query << XCHILD(L"feature") << XATTR(L"var", ppro->m_lstJabberFeatCapPairsDynamic[i]->szFeature);
+ for (auto &it : ppro->m_lstJabberFeatCapPairsDynamic)
+ if (jcb & it->jcbCap)
+ query << XCHILD(L"feature") << XATTR(L"var", it->szFeature);
if (ppro->m_options.AllowVersionRequests && !szNode) {
HXML form = query << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"result");
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index bc0a6b43fb..cf8ee50da7 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -274,8 +274,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t
default:
mir_cslock lck(m_csLists);
- for (int i = 0; i < item->arResources.getCount(); i++) {
- JABBER_RESOURCE_STATUS *JS = item->arResources[i];
+ for (auto &JS : item->arResources) {
if (!mir_wstrcmp(resource, JS->m_tszResourceName)) {
if (action != GC_EVENT_JOIN) {
switch (action) {
@@ -495,8 +494,7 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
return 0;
pResourceStatus me(nullptr), him(nullptr);
- for (int i = 0; i < item->arResources.getCount(); i++) {
- JABBER_RESOURCE_STATUS *p = item->arResources[i];
+ for (auto &p : item->arResources) {
if (!mir_wstrcmp(p->m_tszResourceName, item->nick))
me = p;
if (!mir_wstrcmp(p->m_tszResourceName, gcmi->pszUID))
@@ -645,6 +643,15 @@ class CGroupchatInviteDlg : public CJabberDlgBase
CCtrlEdit m_txtReason;
CCtrlClc m_clc;
+ bool FindJid(const wchar_t *buf)
+ {
+ for (auto &it : m_newJids)
+ if (!mir_wstrcmp(it->jid, buf))
+ return true;
+
+ return false;
+ }
+
void FilterList(CCtrlClc *)
{
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
@@ -700,8 +707,8 @@ public:
~CGroupchatInviteDlg()
{
- for (int i = 0; i < m_newJids.getCount(); i++)
- mir_free(m_newJids[i]);
+ for (auto &it : m_newJids)
+ mir_free(it);
mir_free(m_room);
}
@@ -733,11 +740,7 @@ public:
return;
}
- int i;
- for (i = 0; i < m_newJids.getCount(); i++)
- if (!mir_wstrcmp(m_newJids[i]->jid, buf))
- break;
- if (i != m_newJids.getCount())
+ if (FindJid(buf))
return;
JabberGcLogInviteDlgJidData *jidData = (JabberGcLogInviteDlgJidData *)mir_alloc(sizeof(JabberGcLogInviteDlgJidData));
@@ -774,9 +777,9 @@ public:
}
// invite others
- for (int i = 0; i < m_newJids.getCount(); i++)
- if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)m_newJids[i]->hItem, 0))
- InviteUser(m_newJids[i]->jid, text);
+ for (auto &it : m_newJids)
+ if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)it->hItem, 0))
+ InviteUser(it->jid, text);
Close();
}
diff --git a/protocols/JabberG/src/jabber_form.cpp b/protocols/JabberG/src/jabber_form.cpp
index 931e3703f7..1b4219d5b7 100644
--- a/protocols/JabberG/src/jabber_form.cpp
+++ b/protocols/JabberG/src/jabber_form.cpp
@@ -110,7 +110,7 @@ void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text)
size_t len = mir_wstrlen(text);
size_t fixedLen = len;
- for (int i = 1; i < len; i++)
+ for (size_t i = 1; i < len; i++)
if ((text[i - 1] == '\n') && (text[i] != '\r'))
++fixedLen;
@@ -118,7 +118,7 @@ void JabberFormSetInstruction(HWND hwndForm, const wchar_t *text)
if (fixedLen != len) {
fixedText = (wchar_t *)mir_alloc(sizeof(wchar_t) * (fixedLen + 1));
wchar_t *p = fixedText;
- for (int i = 0; i < len; i++) {
+ for (size_t i = 0; i < len; i++) {
*p = text[i];
if (i && (text[i] == '\n') && (text[i] != '\r')) {
*p++ = '\r';
@@ -394,17 +394,17 @@ void JabberFormLayoutControls(HWND hwndStatic, TJabberFormLayoutInfo *layout_inf
TJabberFormControlList *controls = (TJabberFormControlList *)GetWindowLongPtr(hwndStatic, GWLP_USERDATA);
if (!controls) return;
- for (int i = 0; i < controls->getCount(); i++) {
- if ((*controls)[i]->hLabel)
- SetWindowPos((*controls)[i]->hLabel, nullptr,
- layout_info->offset + (*controls)[i]->ptLabel.x, layout_info->y_pos + (*controls)[i]->ptLabel.y, 0, 0,
+ for (auto &it : *controls) {
+ if (it->hLabel)
+ SetWindowPos(it->hLabel, nullptr,
+ layout_info->offset + it->ptLabel.x, layout_info->y_pos + it->ptLabel.y, 0, 0,
SWP_NOZORDER | SWP_NOSIZE);
- if ((*controls)[i]->hCtrl)
- SetWindowPos((*controls)[i]->hCtrl, nullptr,
- layout_info->offset + (*controls)[i]->ptCtrl.x, layout_info->y_pos + (*controls)[i]->ptCtrl.y, 0, 0,
+ if (it->hCtrl)
+ SetWindowPos(it->hCtrl, nullptr,
+ layout_info->offset + it->ptCtrl.x, layout_info->y_pos + it->ptCtrl.y, 0, 0,
SWP_NOZORDER | SWP_NOSIZE);
- layout_info->y_pos += (*controls)[i]->szBlock.cy;
+ layout_info->y_pos += it->szBlock.cy;
layout_info->y_pos += layout_info->y_spacing;
}
@@ -562,8 +562,8 @@ void JabberFormDestroyUI(HWND hwndStatic)
{
TJabberFormControlList *controls = (TJabberFormControlList *)GetWindowLongPtr(hwndStatic, GWLP_USERDATA);
if (controls) {
- for (int i = 0; i < controls->getCount(); i++)
- mir_free((*controls)[i]);
+ for (auto &it : *controls)
+ mir_free(it);
delete controls;
SetWindowLongPtr(hwndStatic, GWLP_USERDATA, 0);
}
diff --git a/protocols/JabberG/src/jabber_frame.cpp b/protocols/JabberG/src/jabber_frame.cpp
index 6c99725585..db7a6dc8f1 100644
--- a/protocols/JabberG/src/jabber_frame.cpp
+++ b/protocols/JabberG/src/jabber_frame.cpp
@@ -394,22 +394,20 @@ void CJabberInfoFrame::PaintNormal(HDC hdc)
int line_height = cy_icon + SZ_LINEPADDING;
int cy = SZ_FRAMEPADDING;
- for (int i=0; i < m_pItems.getCount(); i++) {
- CJabberInfoFrameItem &item = m_pItems[i];
-
- if (!item.m_bShow) {
- SetRect(&item.m_rcItem, 0, 0, 0, 0);
+ for (auto &it : m_pItems) {
+ if (!it->m_bShow) {
+ SetRect(&it->m_rcItem, 0, 0, 0, 0);
continue;
}
int cx = SZ_FRAMEPADDING;
int depth = 0;
- for (char *p = item.m_pszName; p = strchr(p+1, '/'); cx += cx_icon) ++depth;
+ for (char *p = it->m_pszName; p = strchr(p+1, '/'); cx += cx_icon) ++depth;
- SetRect(&item.m_rcItem, cx, cy, rc.right - SZ_FRAMEPADDING, cy + line_height);
+ SetRect(&it->m_rcItem, cx, cy, rc.right - SZ_FRAMEPADDING, cy + line_height);
- if (item.m_hIcolibIcon) {
- HICON hIcon = IcoLib_GetIconByHandle(item.m_hIcolibIcon);
+ if (it->m_hIcolibIcon) {
+ HICON hIcon = IcoLib_GetIconByHandle(it->m_hIcolibIcon);
if (hIcon) {
DrawIconEx(hdc, cx, cy + (line_height-cy_icon)/2, hIcon, cx_icon, cy_icon, 0, nullptr, DI_NORMAL);
cx += cx_icon + SZ_ICONSPACING;
@@ -422,9 +420,9 @@ void CJabberInfoFrame::PaintNormal(HDC hdc)
SetTextColor(hdc, depth ? m_clText : m_clTitle);
RECT rcText; SetRect(&rcText, cx, cy, rc.right - SZ_FRAMEPADDING, cy + line_height);
- DrawText(hdc, item.m_pszText, -1, &rcText, DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS);
+ DrawText(hdc, it->m_pszText, -1, &rcText, DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS);
- RemoveTooltip(item.m_tooltipId);
+ RemoveTooltip(it->m_tooltipId);
cy += line_height + SZ_LINESPACING;
}
@@ -461,9 +459,9 @@ void CJabberInfoFrame::ShowInfoItem(char *pszName, bool bShow)
{
bool bUpdate = false;
size_t length = mir_strlen(pszName);
- for (int i=0; i < m_pItems.getCount(); i++)
- if ((m_pItems[i].m_bShow != bShow) && !strncmp(m_pItems[i].m_pszName, pszName, length)) {
- m_pItems[i].m_bShow = bShow;
+ for (auto &it : m_pItems)
+ if ((it->m_bShow != bShow) && !strncmp(it->m_pszName, pszName, length)) {
+ it->m_bShow = bShow;
m_hiddenItemCount += bShow ? -1 : 1;
bUpdate = true;
}
@@ -476,14 +474,17 @@ void CJabberInfoFrame::RemoveInfoItem(char *pszName)
{
bool bUpdate = false;
size_t length = mir_strlen(pszName);
- for (int i=0; i < m_pItems.getCount(); i++)
- if (!strncmp(m_pItems[i].m_pszName, pszName, length)) {
- if (!m_pItems[i].m_bShow) --m_hiddenItemCount;
- RemoveTooltip(m_pItems[i].m_tooltipId);
+ for (int i = 0; i < m_pItems.getCount(); i++) {
+ auto &p = m_pItems[i];
+ if (!strncmp(p.m_pszName, pszName, length)) {
+ if (!p.m_bShow)
+ --m_hiddenItemCount;
+ RemoveTooltip(p.m_tooltipId);
m_pItems.remove(i);
bUpdate = true;
--i;
}
+ }
if (bUpdate)
UpdateSize();
diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp
index a8fbaf9914..6474d0b5b9 100644
--- a/protocols/JabberG/src/jabber_iq.cpp
+++ b/protocols/JabberG/src/jabber_iq.cpp
@@ -291,8 +291,7 @@ bool CJabberIqManager::HandleIq(int nIqId, HXML pNode)
bool CJabberIqManager::HandleIqPermanent(HXML pNode)
{
- for (int i = 0; i < m_arHandlers.getCount(); i++) {
- CJabberIqPermanentInfo &pInfo = m_arHandlers[i];
+ for (auto &pInfo : m_arHandlers) {
// have to get all data here, in the loop, because there's always possibility that previous handler modified it
const wchar_t *szType = XmlGetAttrValue(pNode, L"type");
if (!szType)
@@ -307,7 +306,7 @@ bool CJabberIqManager::HandleIqPermanent(HXML pNode)
else
return FALSE;
- if (!(pInfo.m_nIqTypes & iqInfo.m_nIqType))
+ if (!(pInfo->m_nIqTypes & iqInfo.m_nIqType))
continue;
HXML pFirstChild = XmlGetChild(pNode , 0);
@@ -317,27 +316,27 @@ bool CJabberIqManager::HandleIqPermanent(HXML pNode)
const wchar_t *szTagName = XmlGetName(pFirstChild);
const wchar_t *szXmlns = XmlGetAttrValue(pFirstChild, L"xmlns");
- if ((!pInfo.m_szXmlns || (szXmlns && !mir_wstrcmp(pInfo.m_szXmlns, szXmlns))) &&
- (!pInfo.m_szTag || !mir_wstrcmp(pInfo.m_szTag, szTagName)))
+ if ((!pInfo->m_szXmlns || (szXmlns && !mir_wstrcmp(pInfo->m_szXmlns, szXmlns))) &&
+ (!pInfo->m_szTag || !mir_wstrcmp(pInfo->m_szTag, szTagName)))
{
// node suits handler criteria, call the handler
iqInfo.m_pChildNode = pFirstChild;
iqInfo.m_szChildTagName = (wchar_t*)szTagName;
iqInfo.m_szChildTagXmlns = (wchar_t*)szXmlns;
iqInfo.m_szId = (wchar_t*)XmlGetAttrValue(pNode, L"id");
- iqInfo.m_pUserData = pInfo.m_pUserData;
+ iqInfo.m_pUserData = pInfo->m_pUserData;
- if (pInfo.m_dwParamsToParse & JABBER_IQ_PARSE_TO)
+ if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
iqInfo.m_szTo = (wchar_t*)XmlGetAttrValue(pNode, L"to");
- if (pInfo.m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
+ if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
iqInfo.m_szFrom = (wchar_t*)XmlGetAttrValue(pNode, L"from");
- if ((pInfo.m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT) && (iqInfo.m_szFrom))
+ if ((pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT) && (iqInfo.m_szFrom))
iqInfo.m_hContact = ppro->HContactFromJID(iqInfo.m_szFrom);
ppro->debugLogW(L"Handling iq id %s, type %s, from %s", iqInfo.m_szId, szType, iqInfo.m_szFrom);
- if ((ppro->*(pInfo.m_pHandler))(pNode, &iqInfo))
+ if ((ppro->*(pInfo->m_pHandler))(pNode, &iqInfo))
return true;
}
}
@@ -366,6 +365,7 @@ CJabberIqInfo* CJabberIqManager::DetouchInfo(int nIqId)
return pInfo;
}
}
+
return nullptr;
}
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index 3780c794bd..62e71554bb 100755
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -147,9 +147,7 @@ void CJabberProto::OnProcessLoginRq(ThreadData *info, DWORD rq)
ll.insert(item);
}
- for (int j=0; j < ll.getCount(); j++) {
- JABBER_LIST_ITEM *item = ll[j];
-
+ for (auto &item : ll) {
wchar_t room[256], text[128];
wcsncpy_s(text, item->jid, _TRUNCATE);
wcsncpy_s(room, text, _TRUNCATE);
@@ -509,8 +507,8 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo)
SetServerStatus(m_iDesiredStatus);
if (m_options.AutoJoinConferences)
- for (int i = 0; i < chatRooms.getCount(); i++)
- GroupchatJoinByHContact((DWORD_PTR)chatRooms[i], true);
+ for (auto &it : chatRooms)
+ GroupchatJoinByHContact((DWORD_PTR)it, true);
UI_SAFE_NOTIFY_HWND(m_hwndJabberAddBookmark, WM_JABBER_CHECK_ONLINE);
WindowList_Broadcast(m_hWindowList, WM_JABBER_CHECK_ONLINE, 0, 0);
diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp
index 6f879479c5..0d102bf196 100644
--- a/protocols/JabberG/src/jabber_list.cpp
+++ b/protocols/JabberG/src/jabber_list.cpp
@@ -38,8 +38,8 @@ JABBER_LIST_ITEM::JABBER_LIST_ITEM() :
JABBER_LIST_ITEM::~JABBER_LIST_ITEM()
{
- for (int i = 0; i < arResources.getCount(); i++)
- delete arResources[i];
+ for (auto &it : arResources)
+ delete it;
if (m_pItemResource)
delete m_pItemResource;
@@ -107,8 +107,8 @@ void CJabberProto::ListInit(void)
void CJabberProto::ListWipe(void)
{
mir_cslock lck(m_csLists);
- for (int i = 0; i < m_lstRoster.getCount(); i++)
- delete m_lstRoster[i];
+ for (auto &it : m_lstRoster)
+ delete it;
m_lstRoster.destroy();
}
@@ -243,11 +243,9 @@ pResourceStatus JABBER_LIST_ITEM::findResource(const wchar_t *resourceName) cons
if (arResources.getCount() == 0 || resourceName == nullptr || *resourceName == 0)
return nullptr;
- for (int i = 0; i < arResources.getCount(); i++) {
- JABBER_RESOURCE_STATUS *r = arResources[i];
- if (!mir_wstrcmp(r->m_tszResourceName, resourceName))
- return r;
- }
+ for (auto &it : arResources)
+ if (!mir_wstrcmp(it->m_tszResourceName, resourceName))
+ return it;
return nullptr;
}
@@ -396,10 +394,9 @@ wchar_t* CJabberProto::ListGetBestClientResourceNamePtr(const wchar_t *jid)
int status = ID_STATUS_OFFLINE;
wchar_t *res = nullptr;
- for (int i = 0; i < LI->arResources.getCount(); i++) {
- r = LI->arResources[i];
+ for (auto &it : LI->arResources) {
bool foundBetter = false;
- switch (r->m_iStatus) {
+ switch (it->m_iStatus) {
case ID_STATUS_FREECHAT:
foundBetter = true;
break;
@@ -421,8 +418,8 @@ wchar_t* CJabberProto::ListGetBestClientResourceNamePtr(const wchar_t *jid)
break;
}
if (foundBetter) {
- res = r->m_tszResourceName;
- status = r->m_iStatus;
+ res = it->m_tszResourceName;
+ status = it->m_iStatus;
}
}
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp
index 35d24eb16d..f5026821e6 100644
--- a/protocols/JabberG/src/jabber_menu.cpp
+++ b/protocols/JabberG/src/jabber_menu.cpp
@@ -81,9 +81,9 @@ static CJabberProto* JabberGetInstanceByHContact(MCONTACT hContact)
if (szProto == nullptr)
return nullptr;
- for (int i = 0; i < g_Instances.getCount(); i++)
- if (!mir_strcmp(szProto, g_Instances[i]->m_szModuleName))
- return g_Instances[i];
+ for (auto &it : g_Instances)
+ if (!mir_strcmp(szProto, it->m_szModuleName))
+ return it;
return nullptr;
}
@@ -863,8 +863,8 @@ void CJabberProto::CheckMenuItems()
Menu_ShowItem(m_hMenuPriorityRoot, m_menuItemsStatus != 0);
- for (int i = 0; i < m_pepServices.getCount(); i++)
- Menu_ShowItem(m_pepServices[i].GetMenu(), m_bPepSupported);
+ for (auto &it : m_pepServices)
+ Menu_ShowItem(it->GetMenu(), m_bPepSupported);
JabberUpdateDialogs(m_menuItemsStatus);
}
@@ -1062,9 +1062,9 @@ CJabberProto* JabberChooseInstance(bool bIsLink)
}
if (bIsLink)
- for (int i = 0; i < g_Instances.getCount(); i++)
- if (g_Instances[i]->m_options.ProcessXMPPLinks)
- return g_Instances[i];
+ for (auto &it : g_Instances)
+ if (it->m_options.ProcessXMPPLinks)
+ return it;
int nItems = 0, lastItemId = 0;
for (int i = 0; i < g_Instances.getCount(); i++) {
diff --git a/protocols/JabberG/src/jabber_message_manager.cpp b/protocols/JabberG/src/jabber_message_manager.cpp
index 77a01d0945..632dcb28e5 100644
--- a/protocols/JabberG/src/jabber_message_manager.cpp
+++ b/protocols/JabberG/src/jabber_message_manager.cpp
@@ -51,9 +51,7 @@ void CJabberMessageManager::FillPermanentHandlers()
bool CJabberMessageManager::HandleMessagePermanent(HXML node, ThreadData *pThreadData)
{
- for (int k = 0; k < m_arHandlers.getCount(); k++) {
- CJabberMessagePermanentInfo &pInfo = m_arHandlers[k];
-
+ for (auto &it : m_arHandlers) {
// have to get all data here, in the loop, because there's always possibility that previous handler modified it
CJabberMessageInfo messageInfo;
@@ -74,7 +72,7 @@ bool CJabberMessageManager::HandleMessagePermanent(HXML node, ThreadData *pThrea
}
else messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_NORMAL;
- if (pInfo.m_nMessageTypes & messageInfo.m_nMessageType) {
+ if (it->m_nMessageTypes & messageInfo.m_nMessageType) {
for (int i = XmlGetChildCount(node) - 1; i >= 0; i--) {
// enumerate all children and see whether this node suits handler criteria
HXML child = XmlGetChild(node, i);
@@ -82,26 +80,26 @@ bool CJabberMessageManager::HandleMessagePermanent(HXML node, ThreadData *pThrea
LPCTSTR szTagName = XmlGetName(child);
LPCTSTR szXmlns = XmlGetAttrValue(child, L"xmlns");
- if ((!pInfo.m_szXmlns || (szXmlns && !mir_wstrcmp(pInfo.m_szXmlns, szXmlns))) && (!pInfo.m_szTag || !mir_wstrcmp(pInfo.m_szTag, szTagName))) {
+ if ((!it->m_szXmlns || (szXmlns && !mir_wstrcmp(it->m_szXmlns, szXmlns))) && (!it->m_szTag || !mir_wstrcmp(it->m_szTag, szTagName))) {
// node suits handler criteria, call the handler
messageInfo.m_hChildNode = child;
messageInfo.m_szChildTagName = szTagName;
messageInfo.m_szChildTagXmlns = szXmlns;
- messageInfo.m_pUserData = pInfo.m_pUserData;
+ messageInfo.m_pUserData = it->m_pUserData;
messageInfo.m_szFrom = XmlGetAttrValue(node, L"from"); // is necessary for ppro->debugLogA() below, that's why we must parse it even if JABBER_MESSAGE_PARSE_FROM flag is not set
- if (pInfo.m_dwParamsToParse & JABBER_MESSAGE_PARSE_ID_STR)
+ if (it->m_dwParamsToParse & JABBER_MESSAGE_PARSE_ID_STR)
messageInfo.m_szId = XmlGetAttrValue(node, L"id");
- if (pInfo.m_dwParamsToParse & JABBER_IQ_PARSE_TO)
+ if (it->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
messageInfo.m_szTo = XmlGetAttrValue(node, L"to");
- if (pInfo.m_dwParamsToParse & JABBER_MESSAGE_PARSE_HCONTACT)
+ if (it->m_dwParamsToParse & JABBER_MESSAGE_PARSE_HCONTACT)
messageInfo.m_hContact = ppro->HContactFromJID(messageInfo.m_szFrom);
if (messageInfo.m_szFrom)
ppro->debugLogW(L"Handling message from %s", messageInfo.m_szFrom);
- if ((ppro->*(pInfo.m_pHandler))(node, pThreadData, &messageInfo))
+ if ((ppro->*(it->m_pHandler))(node, pThreadData, &messageInfo))
return true;
}
}
diff --git a/protocols/JabberG/src/jabber_notes.cpp b/protocols/JabberG/src/jabber_notes.cpp
index 604dce58a3..cefcb8df19 100644
--- a/protocols/JabberG/src/jabber_notes.cpp
+++ b/protocols/JabberG/src/jabber_notes.cpp
@@ -150,13 +150,12 @@ void CNoteList::LoadXml(HXML hXml)
void CNoteList::SaveXml(HXML hXmlParent)
{
m_bIsModified = false;
- CNoteList &me = *this;
- for (int i = 0; i < getCount(); i++) {
+ for (auto &it : *this) {
HXML hXmlItem = hXmlParent << XCHILD(L"note");
- hXmlItem << XATTR(L"from", me[i].GetFrom()) << XATTR(L"tags", me[i].GetTagsStr());
- hXmlItem << XCHILD(L"title", me[i].GetTitle());
- hXmlItem << XCHILD(L"text", me[i].GetText());
+ hXmlItem << XATTR(L"from", it->GetFrom()) << XATTR(L"tags", it->GetTagsStr());
+ hXmlItem << XCHILD(L"title", it->GetTitle());
+ hXmlItem << XCHILD(L"text", it->GetText());
}
}
@@ -481,18 +480,18 @@ private:
void PopulateTags(HTREEITEM htiRoot, wchar_t *szActiveTag)
{
LIST<wchar_t> tagSet(5, wcscmp);
- for (int i = 0; i < m_proto->m_notes.getCount(); i++) {
- wchar_t *tags = m_proto->m_notes[i].GetTags();
+ for (auto &it : m_proto->m_notes) {
+ wchar_t *tags = it->GetTags();
for (wchar_t *tag = tags; tag && *tag; tag = tag + mir_wstrlen(tag) + 1)
if (!tagSet.find(tag))
tagSet.insert(tag);
}
bool selected = false;
- for (int j = 0; j < tagSet.getCount(); ++j) {
- bool select = !mir_wstrcmp(szActiveTag, tagSet[j]);
+ for (auto &it : tagSet) {
+ bool select = !mir_wstrcmp(szActiveTag, it);
selected |= select;
- InsertTag(htiRoot, tagSet[j], select);
+ InsertTag(htiRoot, it, select);
}
if (!selected)
@@ -528,9 +527,9 @@ private:
void ListItems(const wchar_t *tag)
{
m_lstNotes.ResetContent();
- for (int i = 0; i < m_proto->m_notes.getCount(); i++)
- if (m_proto->m_notes[i].HasTag(tag))
- InsertItem(m_proto->m_notes[i]);
+ for (auto &it : m_proto->m_notes)
+ if (it->HasTag(tag))
+ InsertItem(*it);
EnableControls();
}
diff --git a/protocols/JabberG/src/jabber_opttree.cpp b/protocols/JabberG/src/jabber_opttree.cpp
index 2c7582045a..047decb2be 100644
--- a/protocols/JabberG/src/jabber_opttree.cpp
+++ b/protocols/JabberG/src/jabber_opttree.cpp
@@ -37,8 +37,8 @@ CCtrlTreeOpts::CCtrlTreeOpts(CDlgBase* dlg, int ctrlId):
CCtrlTreeOpts::~CCtrlTreeOpts()
{
- for (int i=0; i < m_options.getCount(); i++)
- delete m_options[i];
+ for (auto &it : m_options)
+ delete it;
}
void CCtrlTreeOpts::AddOption(wchar_t *szOption, CMOption<BYTE> &option)
diff --git a/protocols/JabberG/src/jabber_presence_manager.cpp b/protocols/JabberG/src/jabber_presence_manager.cpp
index aab96871a7..083cb89f55 100644
--- a/protocols/JabberG/src/jabber_presence_manager.cpp
+++ b/protocols/JabberG/src/jabber_presence_manager.cpp
@@ -66,12 +66,10 @@ bool CJabberPresenceManager::DeletePermanentHandler(CJabberPresencePermanentInfo
bool CJabberPresenceManager::HandlePresencePermanent(HXML node, ThreadData *pThreadData)
{
- for (int i = 0; i < m_arHandlers.getCount(); i++) {
- CJabberPresencePermanentInfo &pInfo = m_arHandlers[i];
-
+ for (auto &it : m_arHandlers) {
CJabberPresenceInfo presenceInfo;
- presenceInfo.m_pUserData = pInfo.m_pUserData;
- if ((ppro->*(pInfo.m_pHandler))(node, pThreadData, &presenceInfo))
+ presenceInfo.m_pUserData = it->m_pUserData;
+ if ((ppro->*(it->m_pHandler))(node, pThreadData, &presenceInfo))
return true;
}
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index f189e90b17..4e37896abd 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -651,9 +651,9 @@ protected:
TCLCInfo(): newJids(1, TJidData::cmp), bChanged(false), pList(nullptr) {}
~TCLCInfo()
{
- for (int i=0; i < newJids.getCount(); i++) {
- mir_free(newJids[i]->jid);
- mir_free(newJids[i]);
+ for (auto &it : newJids) {
+ mir_free(it->jid);
+ mir_free(it);
}
}
@@ -1367,8 +1367,8 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList)
CListResetIcons(hwndList, hItem, bHideIcons);
}
- for (int iJid = 0; iJid < clc_info.newJids.getCount(); ++iJid)
- CListResetIcons(hwndList, clc_info.newJids[iJid]->hItem, bHideIcons);
+ for (auto &it : clc_info.newJids)
+ CListResetIcons(hwndList, it->hItem, bHideIcons);
if (!pList)
goto lbl_return;
@@ -1449,9 +1449,9 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList)
pList->RemoveAllRules();
- for (int iJid = 0; iJid < clc_info.newJids.getCount(); ++iJid) {
- hItem = clc_info.newJids[iJid]->hItem;
- szJid = clc_info.newJids[iJid]->jid;
+ for (auto &it : clc_info.newJids) {
+ hItem = it->hItem;
+ szJid = it->jid;
if (dwPackets = CListGetPackets(hwndList, hItem, true))
pList->AddRule(Jid, szJid, TRUE, dwOrder++, dwPackets);
@@ -2111,8 +2111,8 @@ void CJabberProto::BuildPrivacyMenu()
void CJabberProto::BuildPrivacyListsMenu(bool bDeleteOld)
{
if (bDeleteOld)
- for (int i = 0; i < m_hPrivacyMenuItems.getCount(); i++)
- Menu_RemoveItem((HGENMENU)m_hPrivacyMenuItems[i]);
+ for (auto &it : m_hPrivacyMenuItems)
+ Menu_RemoveItem((HGENMENU)it);
m_hPrivacyMenuItems.destroy();
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 38e378b18c..9fce6b38b9 100755
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -190,14 +190,14 @@ CJabberProto::~CJabberProto()
mir_free(m_transportProtoTableStartIndex);
- for (int i = 0; i < m_lstTransports.getCount(); i++)
- mir_free(m_lstTransports[i]);
-
- for (int i = 0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
- mir_free(m_lstJabberFeatCapPairsDynamic[i]->szExt);
- mir_free(m_lstJabberFeatCapPairsDynamic[i]->szFeature);
- mir_free(m_lstJabberFeatCapPairsDynamic[i]->szDescription);
- delete m_lstJabberFeatCapPairsDynamic[i];
+ for (auto &it : m_lstTransports)
+ mir_free(it);
+
+ for (auto &it : m_lstJabberFeatCapPairsDynamic) {
+ mir_free(it->szExt);
+ mir_free(it->szFeature);
+ mir_free(it->szDescription);
+ delete it;
}
}
@@ -596,8 +596,8 @@ int __cdecl CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/)
if (item != nullptr) {
if (item->arResources.getCount()) {
- for (int i = 0; i < item->arResources.getCount(); i++) {
- pResourceStatus r(item->arResources[i]);
+ for (auto &it : item->arResources) {
+ pResourceStatus r(it);
wchar_t tmp[JABBER_MAX_JID_LEN];
mir_snwprintf(tmp, L"%s/%s", szBareJid, r->m_tszResourceName);
@@ -1113,32 +1113,14 @@ void __cdecl CJabberProto::GetAwayMsgThread(void *param)
if (item != nullptr) {
if (item->arResources.getCount() > 0) {
debugLogA("arResources.getCount() > 0");
- int msgCount = 0;
- size_t len = 0;
- for (int i = 0; i < item->arResources.getCount(); i++) {
- JABBER_RESOURCE_STATUS *r = item->arResources[i];
- if (r->m_tszStatusMessage) {
- msgCount++;
- len += (mir_wstrlen(r->m_tszResourceName) + mir_wstrlen(r->m_tszStatusMessage) + 8);
- }
- }
- wchar_t *str = (wchar_t*)alloca(sizeof(wchar_t)*(len + 1));
- str[0] = str[len] = '\0';
- for (int i = 0; i < item->arResources.getCount(); i++) {
- JABBER_RESOURCE_STATUS *r = item->arResources[i];
- if (r->m_tszStatusMessage) {
- if (str[0] != '\0') mir_wstrcat(str, L"\r\n");
- if (msgCount > 1) {
- mir_wstrcat(str, L"(");
- mir_wstrcat(str, r->m_tszResourceName);
- mir_wstrcat(str, L"): ");
- }
- mir_wstrcat(str, r->m_tszStatusMessage);
- }
- }
+ CMStringW str;
+ for (auto &r : item->arResources)
+ if (r->m_tszStatusMessage)
+ str.AppendFormat(L"(%s): %s\r\n", r->m_tszResourceName, r->m_tszStatusMessage);
- ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)str);
+ str.TrimRight();
+ ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)str.c_str());
return;
}
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp
index 001c4b2a04..1872aef10a 100644
--- a/protocols/JabberG/src/jabber_search.cpp
+++ b/protocols/JabberG/src/jabber_search.cpp
@@ -400,8 +400,8 @@ void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode, CJabberIqInfo*)
SearchReturnResults((HANDLE)id, (void*)&SearchResults, (U_TCHAR_MAP *)&mColumnsNames);
- for (int i = 0; i < SearchResults.getCount(); i++)
- delete ((U_TCHAR_MAP*)SearchResults[i]);
+ for (auto &it : SearchResults)
+ delete ((U_TCHAR_MAP*)it);
//send success to finish searching
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
diff --git a/protocols/JabberG/src/jabber_search.h b/protocols/JabberG/src/jabber_search.h
index f56d06a3a6..a869d24c0f 100644
--- a/protocols/JabberG/src/jabber_search.h
+++ b/protocols/JabberG/src/jabber_search.h
@@ -60,7 +60,7 @@ typedef struct tag_Data
} Data;
-static HWND searchHandleDlg=nullptr;
+static HWND searchHandleDlg = nullptr;
//local functions declarations
static int JabberSearchFrameProc(HWND hwnd, int msg, WPARAM wParam, LPARAM lParam);
@@ -69,28 +69,28 @@ static void JabberIqResultGetSearchFields(HXML iqNode, void *userdata);
static void JabberSearchFreeData(HWND hwndDlg, JabberSearchData * dat);
static void JabberSearchRefreshFrameScroll(HWND hwndDlg, JabberSearchData * dat);
static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static void JabberSearchDeleteFromRecent(wchar_t * szAddr,BOOL deleteLastFromDB);
+static void JabberSearchDeleteFromRecent(wchar_t * szAddr, BOOL deleteLastFromDB);
void SearchAddToRecent(wchar_t * szAddr, HWND hwnd);
// Implementation of MAP class (the list
-template <typename _KEYTYPE , int (*COMPARATOR)(_KEYTYPE*, _KEYTYPE*) >
+template <typename _KEYTYPE, int(*COMPARATOR)(_KEYTYPE*, _KEYTYPE*) >
class UNIQUE_MAP
{
public:
typedef _KEYTYPE* (*COPYKEYPROC)(_KEYTYPE*);
- typedef void (*DESTROYKEYPROC)(_KEYTYPE*);
+ typedef void(*DESTROYKEYPROC)(_KEYTYPE*);
private:
typedef struct _tagRECORD
{
- _tagRECORD(_KEYTYPE * key, wchar_t * value=nullptr) { _key=key; _value=value; _order=0; _destroyKeyProc=nullptr; }
+ _tagRECORD(_KEYTYPE * key, wchar_t * value = nullptr) { _key = key; _value = value; _order = 0; _destroyKeyProc = nullptr; }
~_tagRECORD()
{
if (_key && _destroyKeyProc)
_destroyKeyProc(_key);
- _key=nullptr;
- _destroyKeyProc=nullptr;
+ _key = nullptr;
+ _destroyKeyProc = nullptr;
}
_KEYTYPE *_key;
wchar_t * _value;
@@ -104,96 +104,84 @@ private:
static int _KeysEqual(const _RECORD* p1, const _RECORD* p2)
{
if (COMPARATOR)
- return (int)(COMPARATOR((p1->_key),(p2->_key)));
+ return (int)(COMPARATOR((p1->_key), (p2->_key)));
else
- return (int) (p1->_key < p2->_key);
+ return (int)(p1->_key < p2->_key);
}
inline int _remove(_RECORD* p)
{
- int _itemOrder=p->_order;
- if (_Records.remove(p))
- {
+ int _itemOrder = p->_order;
+ if (_Records.remove(p)) {
delete(p);
_nextOrder--;
- for (int i=0; i<_Records.getCount(); i++)
- {
- _RECORD * temp=_Records[i];
- if (temp && temp->_order>_itemOrder)
+ for (auto &temp : _Records)
+ if (temp && temp->_order > _itemOrder)
temp->_order--;
- }
return 1;
}
return 0;
}
- inline _RECORD * _getUnorderedRec (int index)
+ inline _RECORD * _getUnorderedRec(int index)
{
- for (int i=0; i<_Records.getCount(); i++)
- {
- _RECORD * rec=_Records[i];
- if (rec->_order==index) return rec;
- }
+ for (auto &rec : _Records)
+ if (rec->_order == index)
+ return rec;
+
return nullptr;
}
public:
- UNIQUE_MAP(int incr):_Records(incr,_KeysEqual)
+ UNIQUE_MAP(int incr) :_Records(incr, _KeysEqual)
{
- _nextOrder=0;
+ _nextOrder = 0;
};
~UNIQUE_MAP()
{
_RECORD * record;
- int i=0;
- while (record=_Records[i++]) delete record;
+ int i = 0;
+ while (record = _Records[i++]) delete record;
}
int insert(_KEYTYPE* Key, wchar_t *Value)
{
- _RECORD * rec= new _RECORD(Key,Value);
- int index=_Records.getIndex(rec);
- if (index<0)
- {
+ _RECORD * rec = new _RECORD(Key, Value);
+ int index = _Records.getIndex(rec);
+ if (index < 0) {
if (!_Records.insert(rec)) delete rec;
- else
- {
- index=_Records.getIndex(rec);
- rec->_order=_nextOrder++;
+ else {
+ index = _Records.getIndex(rec);
+ rec->_order = _nextOrder++;
}
}
- else
- {
- _Records[index]->_value=Value;
+ else {
+ _Records[index]->_value = Value;
delete rec;
}
return index;
}
int insertCopyKey(_KEYTYPE* Key, wchar_t *Value, _KEYTYPE** _KeyReturn, COPYKEYPROC CopyProc, DESTROYKEYPROC DestroyProc)
{
- _RECORD * rec= new _RECORD(Key,Value);
- int index=_Records.getIndex(rec);
- if (index<0)
- {
- _KEYTYPE* newKey=CopyProc(Key);
- if (!_Records.insert(rec))
- {
+ _RECORD * rec = new _RECORD(Key, Value);
+ int index = _Records.getIndex(rec);
+ if (index < 0) {
+ _KEYTYPE* newKey = CopyProc(Key);
+ if (!_Records.insert(rec)) {
delete rec;
DestroyProc(newKey);
- if (_KeyReturn) *_KeyReturn=nullptr;
+ if (_KeyReturn) *_KeyReturn = nullptr;
}
- else
- {
- rec->_key=newKey;
- rec->_destroyKeyProc=DestroyProc;
- index=_Records.getIndex(rec);
- rec->_order=_nextOrder++;
- if (_KeyReturn) *_KeyReturn=newKey;
+ else {
+ rec->_key = newKey;
+ rec->_destroyKeyProc = DestroyProc;
+ index = _Records.getIndex(rec);
+ rec->_order = _nextOrder++;
+ if (_KeyReturn) *_KeyReturn = newKey;
}
}
- else
- {
- _Records[index]->_value=Value;
- if (_KeyReturn) *_KeyReturn=_Records[index]->_key;
+ else {
+ _Records[index]->_value = Value;
+ if (_KeyReturn) *_KeyReturn = _Records[index]->_key;
delete rec;
}
return index;
@@ -201,10 +189,9 @@ public:
inline wchar_t* operator[](_KEYTYPE* _KEY) const
{
_RECORD rec(_KEY);
- int index=_Records.getIndex(&rec);
- _RECORD * rv=_Records[index];
- if (rv)
- {
+ int index = _Records.getIndex(&rec);
+ _RECORD * rv = _Records[index];
+ if (rv) {
if (rv->_value)
return rv->_value;
else
@@ -215,25 +202,25 @@ public:
}
inline wchar_t* operator[](int index) const
{
- _RECORD * rv=_Records[index];
+ _RECORD * rv = _Records[index];
if (rv) return rv->_value;
else return nullptr;
}
inline _KEYTYPE* getKeyName(int index)
{
- _RECORD * rv=_Records[index];
+ _RECORD * rv = _Records[index];
if (rv) return rv->_key;
else return nullptr;
}
inline wchar_t * getUnOrdered(int index)
{
- _RECORD * rec=_getUnorderedRec(index);
+ _RECORD * rec = _getUnorderedRec(index);
if (rec) return rec->_value;
else return nullptr;
}
inline _KEYTYPE * getUnOrderedKeyName(int index)
{
- _RECORD * rec=_getUnorderedRec(index);
+ _RECORD * rec = _getUnorderedRec(index);
if (rec) return rec->_key;
else return nullptr;
}
@@ -243,13 +230,13 @@ public:
}
inline int removeUnOrdered(int index)
{
- _RECORD * p=_getUnorderedRec(index);
+ _RECORD * p = _getUnorderedRec(index);
if (p) return _remove(p);
else return 0;
}
inline int remove(int index)
{
- _RECORD * p=_Records[index];
+ _RECORD * p = _Records[index];
if (p) return _remove(p);
else return 0;
}
@@ -262,5 +249,5 @@ public:
inline int TCharKeyCmp(wchar_t* a, wchar_t* b)
{
- return (int)(mir_wstrcmpi(a,b));
+ return (int)(mir_wstrcmpi(a, b));
}
diff --git a/protocols/JabberG/src/jabber_send_manager.cpp b/protocols/JabberG/src/jabber_send_manager.cpp
index 426a576253..9ee4df3119 100644
--- a/protocols/JabberG/src/jabber_send_manager.cpp
+++ b/protocols/JabberG/src/jabber_send_manager.cpp
@@ -62,12 +62,10 @@ bool CJabberSendManager::DeletePermanentHandler(CJabberSendPermanentInfo *pInfo)
bool CJabberSendManager::HandleSendPermanent(HXML node, ThreadData *pThreadData)
{
- for (int i = 0; i < m_arHandlers.getCount(); i++) {
- CJabberSendPermanentInfo &pInfo = m_arHandlers[i];
-
+ for (auto &pInfo : m_arHandlers) {
CJabberSendInfo sendInfo;
- sendInfo.m_pUserData = pInfo.m_pUserData;
- if ((ppro->*(pInfo.m_pHandler))(node, pThreadData, &sendInfo))
+ sendInfo.m_pUserData = pInfo->m_pUserData;
+ if ((ppro->*(pInfo->m_pHandler))(node, pThreadData, &sendInfo))
return true;
}
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 4801e50179..700512d631 100755
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -157,9 +157,9 @@ void ThreadData::xmpp_client_query(void)
if (rec->Data.Srv.pNameTarget && rec->wType == DNS_TYPE_SRV)
dnsList.insert(&rec->Data.Srv);
- for (int i = 0; i < dnsList.getCount(); i++) {
- WORD dnsPort = (conn.port == 0 || conn.port == 5222) ? dnsList[i]->wPort : conn.port;
- char* dnsHost = dnsList[i]->pNameTarget;
+ for (auto &it : dnsList) {
+ WORD dnsPort = (conn.port == 0 || conn.port == 5222) ? it->wPort : conn.port;
+ char* dnsHost = it->pNameTarget;
proto->debugLogA("%s%s resolved to %s:%d", "_xmpp-client._tcp.", conn.server, dnsHost, dnsPort);
s = proto->WsConnect(dnsHost, dnsPort);
diff --git a/protocols/JabberG/src/jabber_treelist.cpp b/protocols/JabberG/src/jabber_treelist.cpp
index 5b8681b1ea..fcfba8f7b7 100644
--- a/protocols/JabberG/src/jabber_treelist.cpp
+++ b/protocols/JabberG/src/jabber_treelist.cpp
@@ -50,11 +50,11 @@ struct TTreeList_ItemInfo
flags(0), indent(0), sortIndex(0), iIcon(0), iOverlay(0), data(0) {}
~TTreeList_ItemInfo()
{
- for (int i = text.getCount(); i--;)
- mir_free(text[i]);
+ for (auto &it : text)
+ mir_free(it);
- for (int k = subItems.getCount(); k--;)
- delete subItems[k];
+ for (auto &it : subItems)
+ delete it;
}
};
@@ -222,8 +222,8 @@ void TreeList_ResetItem(HWND hwnd, HTREELISTITEM hParent)
{
TTreeList_Data *data = (TTreeList_Data *)sttTreeList_GeWindowData(hwnd);
- for (int i = hParent->subItems.getCount(); i--;)
- delete hParent->subItems[i];
+ for (auto &it : hParent->subItems)
+ delete it;
hParent->subItems.destroy();
data->hItemSelected = hParent;
@@ -263,9 +263,9 @@ void TreeList_SetIcon(HTREELISTITEM hItem, int iIcon, int iOverlay)
void TreeList_RecursiveApply(HTREELISTITEM hItem, void (*func)(HTREELISTITEM, LPARAM), LPARAM data)
{
- for (int i = 0; i < hItem->subItems.getCount(); i++) {
- func(hItem->subItems[i], data);
- TreeList_RecursiveApply(hItem->subItems[i], func, data);
+ for (auto &it : hItem->subItems) {
+ func(it, data);
+ TreeList_RecursiveApply(it, func, data);
}
}
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp
index ca396d758e..610cab6a87 100755
--- a/protocols/JabberG/src/jabber_userinfo.cpp
+++ b/protocols/JabberG/src/jabber_userinfo.cpp
@@ -43,7 +43,8 @@ struct UserInfoStringBuf
UserInfoStringBuf() { buf = nullptr; size = 0; offset = 0; }
~UserInfoStringBuf() { mir_free(buf); }
- void append(wchar_t *str) {
+ void append(wchar_t *str)
+ {
if (!str) return;
size_t length = mir_wstrlen(str);
@@ -55,7 +56,8 @@ struct UserInfoStringBuf
offset += length;
}
- wchar_t* allocate(int length) {
+ wchar_t* allocate(int length)
+ {
if (size - offset < length) {
size += (length + STRINGBUF_INCREMENT);
buf = (wchar_t *)mir_realloc(buf, size * sizeof(wchar_t));
@@ -63,7 +65,8 @@ struct UserInfoStringBuf
return buf + offset;
}
- void actualize() {
+ void actualize()
+ {
if (buf) offset = mir_wstrlen(buf);
}
};
@@ -81,11 +84,11 @@ struct JabberUserInfoDlgData
enum
{
- INFOLINE_DELETE = 0x80000000,
- INFOLINE_MASK = 0x7fffffff,
- INFOLINE_BAD_ID = 0x7fffffff,
+ INFOLINE_DELETE = 0x80000000,
+ INFOLINE_MASK = 0x7fffffff,
+ INFOLINE_BAD_ID = 0x7fffffff,
- INFOLINE_NAME = 1,
+ INFOLINE_NAME = 1,
INFOLINE_MOOD,
INFOLINE_ACTIVITY,
INFOLINE_TUNE,
@@ -104,21 +107,20 @@ enum
INFOLINE_LASTACTIVE,
};
-__forceinline DWORD sttInfoLineId(DWORD res, DWORD type, DWORD line=0)
+__forceinline DWORD sttInfoLineId(DWORD res, DWORD type, DWORD line = 0)
{
return
(type << 24) & 0x7f000000 |
- (res << 12) & 0x00fff000 |
- (line ) & 0x00000fff;
+ (res << 12) & 0x00fff000 |
+ (line) & 0x00000fff;
}
-static HTREEITEM sttFindInfoLine(HWND hwndTree, HTREEITEM htiRoot, LPARAM id=INFOLINE_BAD_ID)
+static HTREEITEM sttFindInfoLine(HWND hwndTree, HTREEITEM htiRoot, LPARAM id = INFOLINE_BAD_ID)
{
if (id == INFOLINE_BAD_ID) return nullptr;
- for (HTREEITEM hti = TreeView_GetChild(hwndTree, htiRoot); hti; hti = TreeView_GetNextSibling(hwndTree, hti))
- {
- TVITEMEX tvi = {0};
- tvi.mask = TVIF_HANDLE|TVIF_PARAM;
+ for (HTREEITEM hti = TreeView_GetChild(hwndTree, htiRoot); hti; hti = TreeView_GetNextSibling(hwndTree, hti)) {
+ TVITEMEX tvi = { 0 };
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
tvi.hItem = hti;
TreeView_GetItem(hwndTree, &tvi);
if ((tvi.lParam&INFOLINE_MASK) == (id&INFOLINE_MASK))
@@ -131,8 +133,8 @@ void sttCleanupInfo(HWND hwndTree, int stage)
{
HTREEITEM hItem = TreeView_GetRoot(hwndTree);
while (hItem) {
- TVITEMEX tvi = {0};
- tvi.mask = TVIF_HANDLE|TVIF_PARAM;
+ TVITEMEX tvi = { 0 };
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
tvi.hItem = hItem;
TreeView_GetItem(hwndTree, &tvi);
@@ -181,15 +183,15 @@ static HTREEITEM sttFillInfoLine(HWND hwndTree, HTREEITEM htiRoot, HICON hIcon,
TVINSERTSTRUCT tvis = {};
tvis.hParent = htiRoot;
tvis.hInsertAfter = TVI_LAST;
- tvis.itemex.mask = TVIF_TEXT|TVIF_PARAM;
+ tvis.itemex.mask = TVIF_TEXT | TVIF_PARAM;
tvis.itemex.pszText = buf;
tvis.itemex.lParam = id;
if (hIcon) {
HIMAGELIST himl = TreeView_GetImageList(hwndTree, TVSIL_NORMAL);
- tvis.itemex.mask |= TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+ tvis.itemex.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvis.itemex.iImage =
- tvis.itemex.iSelectedImage = ImageList_AddIcon(himl, hIcon);
+ tvis.itemex.iSelectedImage = ImageList_AddIcon(himl, hIcon);
IcoLib_ReleaseIcon(hIcon);
}
@@ -212,7 +214,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti
{
wchar_t buf[256];
HTREEITEM htiResource = htiRoot;
- pResourceStatus r = resource ? item->arResources[resource-1] : item->getTemp();
+ pResourceStatus r = resource ? item->arResources[resource - 1] : item->getTemp();
if (r->m_tszResourceName && *r->m_tszResourceName)
htiResource = sttFillInfoLine(hwndTree, htiRoot, Skin_LoadProtoIcon(ppro->m_szModuleName, r->m_iStatus),
@@ -264,7 +266,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti
mir_wstrncpy(buf, _wctime(&r->m_dwIdleStartTime), _countof(buf));
size_t len = mir_wstrlen(buf);
if (len > 0)
- buf[len-1] = 0;
+ buf[len - 1] = 0;
}
else if (!r->m_dwIdleStartTime)
mir_wstrncpy(buf, TranslateT("unknown"), _countof(buf));
@@ -280,9 +282,9 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti
if (!(jcb & JABBER_RESOURCE_CAPS_ERROR)) {
HTREEITEM htiCaps = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), nullptr, TranslateT("Client capabilities"), sttInfoLineId(resource, INFOLINE_CAPS));
int i;
- for (i=0; g_JabberFeatCapPairs[i].szFeature; i++)
+ for (i = 0; g_JabberFeatCapPairs[i].szFeature; i++)
if (jcb & g_JabberFeatCapPairs[i].jcbCap) {
- wchar_t szDescription[ 1024 ];
+ wchar_t szDescription[1024];
if (g_JabberFeatCapPairs[i].tszDescription)
mir_snwprintf(szDescription, L"%s (%s)", TranslateW(g_JabberFeatCapPairs[i].tszDescription), g_JabberFeatCapPairs[i].szFeature);
else
@@ -292,7 +294,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti
for (int j = 0; j < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); j++, i++)
if (jcb & ppro->m_lstJabberFeatCapPairsDynamic[j]->jcbCap) {
- wchar_t szDescription[ 1024 ];
+ 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);
else
@@ -375,7 +377,7 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM
mir_wstrncpy(buf, _wctime(&r->m_dwIdleStartTime), _countof(buf));
size_t len = mir_wstrlen(buf);
if (len > 0)
- buf[len-1] = 0;
+ buf[len - 1] = 0;
}
else if (!r->m_dwIdleStartTime)
mir_wstrncpy(buf, TranslateT("unknown"), _countof(buf));
@@ -400,8 +402,8 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM
// resources
if (item->arResources.getCount()) {
- for (int i=0; i < item->arResources.getCount(); i++)
- sttFillResourceInfo(ppro, hwndTree, htiRoot, item, i+1);
+ for (int i = 0; i < item->arResources.getCount(); i++)
+ sttFillResourceInfo(ppro, hwndTree, htiRoot, item, i + 1);
}
else if (!wcschr(item->jid, '@') || (r->m_iStatus != ID_STATUS_OFFLINE))
sttFillResourceInfo(ppro, hwndTree, htiRoot, item, 0);
@@ -760,7 +762,7 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP
}
}
- RECT rc;
+ RECT rc;
if (IsThemeActive()) {
GetClientRect(hwndCanvas, &rc);
DrawThemeParentBackground(hwndCanvas, hdcCanvas, &rc);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 68fc2a919a..10a110b1b8 100755
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -432,9 +432,9 @@ void CJabberProto::SendPresenceTo(int status, const wchar_t* to, HXML extra, con
NotifyFastHook(hExtListInit, (WPARAM)&arrExtCaps, (LPARAM)(IJabberInterface*)this);
// add features enabled through IJabberNetInterface::AddFeatures()
- for (int i = 0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++)
- if (m_uEnabledFeatCapsDynamic & m_lstJabberFeatCapPairsDynamic[i]->jcbCap)
- arrExtCaps.insert(m_lstJabberFeatCapPairsDynamic[i]->szExt);
+ for (auto &it : m_lstJabberFeatCapPairsDynamic)
+ if (m_uEnabledFeatCapsDynamic & it->jcbCap)
+ arrExtCaps.insert(it->szExt);
if (arrExtCaps.getCount()) {
CMStringW szExtCaps = arrExtCaps[0];
@@ -890,12 +890,12 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param)
OBJLIST<JABBER_HTTP_AVATARS> &avs = *(OBJLIST<JABBER_HTTP_AVATARS>*)param;
HNETLIBCONN hHttpCon = nullptr;
- for (int i = 0; i < avs.getCount(); i++) {
+ for (auto &it : avs) {
NETLIBHTTPREQUEST nlhr = { 0 };
nlhr.cbSize = sizeof(nlhr);
nlhr.requestType = REQUEST_GET;
nlhr.flags = NLHRF_HTTP11 | NLHRF_REDIRECT | NLHRF_PERSISTENT;
- nlhr.szUrl = avs[i].Url;
+ nlhr.szUrl = it->Url;
nlhr.nlc = hHttpCon;
NETLIBHTTPREQUEST *res = Netlib_HttpTransaction(m_hNetlibUser, &nlhr);
@@ -906,7 +906,7 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param)
if (pictureType != PA_FORMAT_UNKNOWN) {
PROTO_AVATAR_INFORMATION ai;
ai.format = pictureType;
- ai.hContact = avs[i].hContact;
+ ai.hContact = it->hContact;
if (getByte(ai.hContact, "AvatarType", PA_FORMAT_UNKNOWN) != (unsigned char)pictureType) {
wchar_t tszFileName[MAX_PATH];
diff --git a/protocols/JabberG/src/jabber_xstatus.h b/protocols/JabberG/src/jabber_xstatus.h
index 62b805829a..b74a80b62d 100644
--- a/protocols/JabberG/src/jabber_xstatus.h
+++ b/protocols/JabberG/src/jabber_xstatus.h
@@ -66,56 +66,54 @@ public:
void ProcessEvent(const wchar_t *from, HXML eventNode)
{
- for (int i=0; i < getCount(); i++)
- {
- CPepService &pepSvc = (*this)[i];
- HXML itemsNode = XmlGetChildByTag(eventNode, L"items", L"node", pepSvc.GetNode());
+ for (auto &it : *this) {
+ HXML itemsNode = XmlGetChildByTag(eventNode, L"items", L"node", it->GetNode());
if (itemsNode)
- pepSvc.ProcessItems(from, itemsNode);
+ it->ProcessItems(from, itemsNode);
}
}
void InitGui()
{
- for (int i=0; i < getCount(); i++)
- (*this)[i].InitGui();
+ for (auto &it : *this)
+ it->InitGui();
}
void RebuildMenu()
{
- for (int i=0; i < getCount(); i++)
- (*this)[i].RebuildMenu();
+ for (auto &it : *this)
+ it->RebuildMenu();
}
void ResetExtraIcon(MCONTACT hContact)
{
- for (int i=0; i < getCount(); i++)
- (*this)[i].ResetExtraIcon(hContact);
+ for (auto &it : *this)
+ it->ResetExtraIcon(hContact);
}
void PublishAll()
{
- for (int i=0; i < getCount(); i++)
- (*this)[i].Publish();
+ for (auto &it : *this)
+ it->Publish();
}
void RetractAll()
{
- for (int i=0; i < getCount(); i++)
- (*this)[i].Retract();
+ for (auto &it : *this)
+ it->Retract();
}
void ResetPublishAll()
{
- for(int i=0; i < getCount(); i++)
- (*this)[i].ResetPublish();
+ for (auto &it : *this)
+ it->ResetPublish();
}
CPepService *Find(wchar_t *node)
{
- for (int i=0; i < getCount(); i++)
- if (!mir_wstrcmp((*this)[i].GetNode(), node))
- return &((*this)[i]);
+ for (auto &it : *this)
+ if (!mir_wstrcmp(it->GetNode(), node))
+ return it;
return nullptr;
}
};