summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_disco.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-19 15:21:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-19 19:24:17 +0300
commitfc8f2a3b692878aa581bf3fcd5c1c3c2295bbcb5 (patch)
tree17ed9d45de9d7f293578150081b5e7e4617290eb /protocols/JabberG/src/jabber_disco.cpp
parentc9e483e0fb1566d210530339d13a0e6e91260200 (diff)
Jabber:
- XmlGetChildText / XmlGetChildInt - new handy helpers for tinyxml2; - Unicode logging replaced with ANSI when appropriate; - JabberErrorMsg rewritten to be more useful
Diffstat (limited to 'protocols/JabberG/src/jabber_disco.cpp')
-rw-r--r--protocols/JabberG/src/jabber_disco.cpp57
1 files changed, 23 insertions, 34 deletions
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp
index ed9898f5e1..a82b328c75 100644
--- a/protocols/JabberG/src/jabber_disco.cpp
+++ b/protocols/JabberG/src/jabber_disco.cpp
@@ -128,13 +128,10 @@ void CJabberProto::OnIqResultServiceDiscoveryInfo(const TiXmlElement *iqNode, CJ
}
}
else {
- if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR) {
- auto *errorNode = iqNode->FirstChildElement("error");
- wchar_t *str = JabberErrorMsg(errorNode);
- pNode->SetInfoRequestErrorText(str);
- mir_free(str);
- }
- else pNode->SetInfoRequestErrorText(TranslateT("request timeout."));
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR)
+ pNode->SetInfoRequestErrorText(JabberErrorMsg(iqNode));
+ else
+ pNode->SetInfoRequestErrorText(TranslateT("request timeout."));
pNode->SetInfoRequestId(JABBER_DISCO_RESULT_ERROR);
}
@@ -167,13 +164,11 @@ void CJabberProto::OnIqResultServiceDiscoveryItems(const TiXmlElement *iqNode, C
}
}
else {
- if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR) {
- auto *errorNode = iqNode->FirstChildElement("error");
- pNode->SetItemsRequestErrorText(JabberErrorMsg(errorNode));
- }
- else {
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR)
+ pNode->SetItemsRequestErrorText(JabberErrorMsg(iqNode));
+ else
pNode->SetItemsRequestErrorText(L"request timeout.");
- }
+
pNode->SetItemsRequestId(JABBER_DISCO_RESULT_ERROR);
}
@@ -191,14 +186,11 @@ void CJabberProto::OnIqResultServiceDiscoveryRootInfo(const TiXmlElement *iqNode
mir_cslockfull lck(m_SDManager.cs());
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- auto *query = iqNode->FirstChildElement("query");
- if (query) {
- for (auto *feature : TiXmlFilter(query, "feature")) {
- if (!mir_strcmp(feature->Attribute("var"), (char*)pInfo->m_pUserData)) {
- CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(pInfo->GetReceiver(), iqNode->Attribute("node"), nullptr);
- SendBothRequests(pNode, nullptr);
- break;
- }
+ for (auto *feature : TiXmlFilter(iqNode->FirstChildElement("query"), "feature")) {
+ if (!mir_strcmp(feature->Attribute("var"), (char*)pInfo->m_pUserData)) {
+ CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(pInfo->GetReceiver(), iqNode->Attribute("node"), nullptr);
+ SendBothRequests(pNode, nullptr);
+ break;
}
}
}
@@ -215,19 +207,16 @@ void CJabberProto::OnIqResultServiceDiscoveryRootItems(const TiXmlElement *iqNod
TiXmlDocument packet;
mir_cslockfull lck(m_SDManager.cs());
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- auto *query = iqNode->FirstChildElement("query");
- if (query) {
- for (auto *item : TiXmlFilter(query, "item")) {
- const char *szJid = item->Attribute("jid");
- const char *szNode = item->Attribute("node");
- CJabberIqInfo *pNewInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootInfo, JABBER_IQ_TYPE_GET, szJid);
- pNewInfo->m_pUserData = pInfo->m_pUserData;
- pNewInfo->SetTimeout(30000);
-
- XmlNodeIq iq(pNewInfo);
- iq << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR("node", szNode);
- packet.InsertEndChild(iq);
- }
+ for (auto *item : TiXmlFilter(iqNode->FirstChildElement("query"), "item")) {
+ const char *szJid = item->Attribute("jid");
+ const char *szNode = item->Attribute("node");
+ CJabberIqInfo *pNewInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootInfo, JABBER_IQ_TYPE_GET, szJid);
+ pNewInfo->m_pUserData = pInfo->m_pUserData;
+ pNewInfo->SetTimeout(30000);
+
+ XmlNodeIq iq(pNewInfo);
+ iq << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR("node", szNode);
+ packet.InsertEndChild(iq);
}
}
lck.unlock();