From baf91153953c36c58a321216eaf1490fa8e162e4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 22 Dec 2023 13:58:12 +0300 Subject: Jabber: XEP-0319 support --- protocols/JabberG/src/jabber_caps.cpp | 2 ++ protocols/JabberG/src/jabber_iq_handlers.cpp | 3 +++ protocols/JabberG/src/jabber_opt.cpp | 1 + protocols/JabberG/src/jabber_proto.cpp | 1 + protocols/JabberG/src/jabber_proto.h | 1 + protocols/JabberG/src/jabber_util.cpp | 2 +- 6 files changed, 9 insertions(+), 1 deletion(-) (limited to 'protocols') diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index dea74127ce..5a71713436 100644 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -342,6 +342,8 @@ JabberCapsBits CJabberProto::GetOwnCaps(bool IncludeDynamic) for (auto &it : m_lstJabberFeatCapPairsDynamic) jcb |= it->jcbCap; + if (!m_bAllowLast) + jcb &= ~JABBER_CAPS_LAST_ACTIVITY; if (!m_bAllowTimeReplies) jcb &= ~JABBER_CAPS_ENTITY_TIME; if (!m_bAllowVersionRequests) diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index 2b21589caa..4c2264fe56 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -63,6 +63,9 @@ bool CJabberProto::OnIqRequestVersion(const TiXmlElement*, CJabberIqInfo *pInfo) // last activity (XEP-0012) support bool CJabberProto::OnIqRequestLastActivity(const TiXmlElement*, CJabberIqInfo *pInfo) { + if (!m_bAllowLast) + return false; + m_ThreadInfo->send( XmlNodeIq("result", pInfo) << XQUERY(JABBER_FEAT_LAST_ACTIVITY) << XATTRI("seconds", m_tmJabberIdleStartTime ? time(0) - m_tmJabberIdleStartTime : 0)); diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 4dc0764e9d..7595738e36 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -726,6 +726,7 @@ public: m_options.AddOption(LPGENW("Security"), LPGENW("Allow local time and timezone requests (XEP-0202)"), proto->m_bAllowTimeReplies); m_options.AddOption(LPGENW("Security"), LPGENW("Allow servers to request version (XEP-0092)"), proto->m_bAllowVersionRequests); m_options.AddOption(LPGENW("Security"), LPGENW("Show information about operating system in version replies"), proto->m_bShowOSVersion); + m_options.AddOption(LPGENW("Security"), LPGENW("Allow last activity replies (XEP-0319 & XEP-0012)"), proto->m_bAllowLast); m_options.AddOption(LPGENW("Security"), LPGENW("Accept HTTP Authentication requests (XEP-0070)"), proto->m_bAcceptHttpAuth); m_options.AddOption(LPGENW("Security"), LPGENW("Use OMEMO encryption for messages if possible (XEP-0384) (basic support without GUI)"), proto->m_bUseOMEMO); } diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 8b6363b67a..e43d1b2ee3 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -80,6 +80,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : m_bAcceptNotes(this, "AcceptNotes", true), m_bAllowTimeReplies(this, "AllowTimeReplies", true), m_bAllowVersionRequests(this, "AllowVersionRequests", true), + m_bAllowLast(this, "AllowLast", false), m_bAutoAcceptAuthorization(this, "AutoAcceptAuthorization", false), m_bAutoAcceptMUC(this, "AutoAcceptMUC", false), m_bAutoAdd(this, "AutoAdd", true), diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 73f7b187a8..dcd6f753f2 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -185,6 +185,7 @@ struct CJabberProto : public PROTO, public IJabberInterface CMOption m_bAcceptNotes; CMOption m_bAllowTimeReplies; CMOption m_bAllowVersionRequests; + CMOption m_bAllowLast; CMOption m_bAutoAcceptAuthorization; CMOption m_bAutoAcceptMUC; CMOption m_bAutoAdd; diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index fb1af37244..5d63b0d5a0 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -510,7 +510,7 @@ void CJabberProto::SendPresenceTo(int status, const char *to, const TiXmlElement } } - if (m_tmJabberIdleStartTime) { + if (m_bAllowLast && m_tmJabberIdleStartTime) { // XEP-0319 support char szSince[100]; time2str(m_tmJabberIdleStartTime, szSince, _countof(szSince)); -- cgit v1.2.3