From e6ceeb9d5fe3f9f904d9c87d759ec8459ce24e33 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 6 Oct 2024 16:25:34 +0300 Subject: code cleaning --- protocols/JabberG/src/jabber_disco.cpp | 58 ++++++++++++---------------------- 1 file changed, 20 insertions(+), 38 deletions(-) (limited to 'protocols/JabberG/src/jabber_disco.cpp') diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index e427ad3ace..7ce1ec6a6a 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -170,9 +170,11 @@ void CJabberProto::OnIqResultServiceDiscoveryItems(const TiXmlElement *iqNode, C if (pNode->GetNode()) pQuery->SetAttribute("node", pNode->GetNode()); - auto *pNextSet = pQuery << XCHILDNS("set", JABBER_FEAT_RSM); - pNextSet << XCHILD("max", "100"); - pNextSet << XCHILD("after", pszLast); + if (pNode->HasFeature(JABBER_FEAT_RSM)) { + auto *pNextSet = pQuery << XCHILDNS("set", JABBER_FEAT_RSM); + pNextSet << XCHILD("max", "100"); + pNextSet << XCHILD("after", pszLast); + } m_ThreadInfo->send(iq); } @@ -307,9 +309,10 @@ bool CJabberProto::SendBothRequests(CJabberSDNode *pNode, TiXmlNode *parent) if (pNode->GetNode()) query->SetAttribute("node", pNode->GetNode()); - auto *pNextSet = query << XCHILDNS("set", JABBER_FEAT_RSM); - pNextSet << XCHILD("max", "100"); - pNextSet << XCHILD("after", " "); + if (pNode->HasFeature(JABBER_FEAT_RSM)) { + auto *pNextSet = query << XCHILDNS("set", JABBER_FEAT_RSM); + pNextSet << XCHILD("max", "100"); + } if (parent) parent->InsertEndChild(iq.node()->DeepClone(parent->GetDocument())); @@ -446,27 +449,14 @@ void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode) if (!it.iconIndex && !it.iconRes) continue; - if (it.category) { - CJabberSDIdentity *iIdentity; - for (iIdentity = pNode->GetFirstIdentity(); iIdentity; iIdentity = iIdentity->GetNext()) - if (!mir_strcmp(iIdentity->GetCategory(), it.category) && - (!it.type || !mir_strcmp(iIdentity->GetType(), it.type))) { - iIcon = it.listIndex; - break; - } - if (iIdentity) - break; + if (it.category && pNode->HasIdentity(it.category, it.type)) { + iIcon = it.listIndex; + break; } - if (it.feature) { - CJabberSDFeature *iFeature; - for (iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext()) - if (!mir_strcmp(iFeature->GetVar(), it.feature)) { - iIcon = it.listIndex; - break; - } - if (iFeature) - break; + if (it.feature && pNode->HasFeature(it.feature)) { + iIcon = it.listIndex; + break; } } @@ -999,11 +989,8 @@ public: bool bFeatureOk = !bFilterItems; if (bFilterItems) - for (auto *iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext()) - if (!mir_strcmp(iFeature->GetVar(), it.feature)) { - bFeatureOk = true; - break; - } + if (pNode->HasFeature(it.feature)) + bFeatureOk = true; if (bFeatureOk) { if (it.title) { @@ -1235,14 +1222,9 @@ public: HTREELISTITEM hItem = (HTREELISTITEM)lvi.lParam; mir_cslock lck(m_proto->m_SDManager.cs()); - if (CJabberSDNode *pNode = (CJabberSDNode *)TreeList_GetData(hItem)) { - for (auto *iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext()) { - if (!mir_strcmp(iFeature->GetVar(), JABBER_FEAT_MUC)) { - m_proto->GroupchatJoinRoomByJid(m_hwnd, pNode->GetJid()); - break; - } - } - } + if (CJabberSDNode *pNode = (CJabberSDNode *)TreeList_GetData(hItem)) + if (pNode->HasFeature(JABBER_FEAT_MUC)) + m_proto->GroupchatJoinRoomByJid(m_hwnd, pNode->GetJid()); } void lstDiscoTree_OnGetInfoTip(CCtrlListView::TEventInfo *ev) -- cgit v1.2.3