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_proto.h | 5 +++ protocols/JabberG/src/jabber_thread.cpp | 61 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 27232f3fc0..f11c41656e 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -762,6 +762,8 @@ struct CJabberProto : public PROTO, public IJabberInterface void __cdecl ServerThread(JABBER_CONN_DATA *info); void OnProcessFailure(HXML node, ThreadData *info); + void OnProcessFailed(HXML node, ThreadData *info); + void OnProcessEnabled(HXML node, ThreadData *info); void OnProcessError(HXML node, ThreadData *info); void OnProcessSuccess(HXML node, ThreadData *info); void OnProcessChallenge(HXML node, ThreadData *info); @@ -771,6 +773,9 @@ struct CJabberProto : public PROTO, public IJabberInterface void OnProcessPresence(HXML node, ThreadData *info); void OnProcessPresenceCapabilites(HXML node, pResourceStatus &resource); void OnProcessPubsubEvent(HXML node); + //XEP-0198 specific types handlers + void OnProcessSMa(HXML node, ThreadData *info); + void OnProcessSMr(HXML node, ThreadData *info); void OnProcessStreamOpening(HXML node, ThreadData *info); void OnProcessProtocol(HXML node, ThreadData *info); 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