From 99f2b086d395892fb24e14caa9a22f2df3c702bc Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sun, 25 Mar 2018 06:33:41 +0300 Subject: protocols: jabber: xep-0198 - empty handlers for most data types --- protocols/JabberG/src/jabber_thread.cpp | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'protocols/JabberG/src/jabber_thread.cpp') diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 8b9cdfd127..b545d40888 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -736,6 +736,24 @@ void CJabberProto::OnProcessFeatures(HXML node, ThreadData *info) else if (!mir_wstrcmp(XmlGetName(n), L"register")) isRegisterAvailable = true; else if (!mir_wstrcmp(XmlGetName(n), L"auth")) m_AuthMechs.isAuthAvailable = true; else if (!mir_wstrcmp(XmlGetName(n), L"session")) m_AuthMechs.isSessionAvailable = true; + else if (m_bEnableStreamMgmt && !mir_wstrcmp(XmlGetName(n), L"sm")) + { + if (mir_wstrcmp(XmlGetAttrValue(n, L"xmlns"), L"urn:xmpp:sm:3")) //we work only with version 3 or higher of sm + { + if (!(info->auth)) + { + //TODO: queue sm after successfully auth + } + else + { + XmlNode enable_sm(L"enable"); + XmlAddAttr(enable_sm, L"xmlns", L"urn:xmpp:sm:3"); + XmlAddAttr(enable_sm, L"resume", L"true"); //enable resumption (most useful part of this xep) + info->send(enable_sm); + //TODO: reset counters ? + } + } + } } if (areMechanismsDefined) { @@ -773,6 +791,38 @@ void CJabberProto::OnProcessFailure(HXML node, ThreadData *info) } } +void CJabberProto::OnProcessFailed(HXML node, ThreadData * /*info*/) //used failed instead of failure, notes: https://xmpp.org/extensions/xep-0198.html#errors +{ + if (m_bEnableStreamMgmt && mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:xmpp:sm:3")) + { + //TODO: handle failure + } +} + +void CJabberProto::OnProcessEnabled(HXML node, ThreadData * /*info*/) +{ + if (m_bEnableStreamMgmt && mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:xmpp:sm:3")) + { + //TODO: handle 'id', 'resume' attrs + } +} + +void CJabberProto::OnProcessSMa(HXML node, ThreadData * /*info*/) +{ + if (mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:xmpp:sm:3")) + { + //TODO: + } +} + +void CJabberProto::OnProcessSMr(HXML node, ThreadData * /*info*/) +{ + if (mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:xmpp:sm:3")) + { + //TODO: reply with ack with currently handled nodes for session + } +} + void CJabberProto::OnProcessError(HXML node, ThreadData *info) { //failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" @@ -872,6 +922,17 @@ void CJabberProto::OnProcessProtocol(HXML node, ThreadData *info) OnProcessPresence(node, info); else if (!mir_wstrcmp(XmlGetName(node), L"iq")) OnProcessIq(node); + else if (!mir_wstrcmp(XmlGetName(node), L"failed")) + OnProcessFailed(node, info); + else if (!mir_wstrcmp(XmlGetName(node), L"enabled")) + OnProcessEnabled(node, info); + else if (m_bEnableStreamMgmt) + { + if (!mir_wstrcmp(XmlGetName(node), L"r")) + OnProcessSMr(node, info); + else if (!mir_wstrcmp(XmlGetName(node), L"a")) + OnProcessSMa(node, info); + } else debugLogA("Invalid top-level tag (only and allowed)"); } -- cgit v1.2.3