From 1592aaa2eb5fb9536d651cda57cc0006f2d57134 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 3 May 2020 15:12:11 +0300 Subject: fixes #2376 (Jabber: Add XEP-0319 support, XEP-0256 support discontinued) --- protocols/JabberG/src/jabber_caps.h | 3 ++- protocols/JabberG/src/jabber_thread.cpp | 12 +++++++++++- protocols/JabberG/src/jabber_util.cpp | 8 ++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'protocols/JabberG') diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h index 8da657548c..448c20952c 100755 --- a/protocols/JabberG/src/jabber_caps.h +++ b/protocols/JabberG/src/jabber_caps.h @@ -196,7 +196,8 @@ typedef unsigned __int64 JabberCapsBits; #define JABBER_FEAT_BIND "urn:ietf:params:xml:ns:xmpp-bind" #define JABBER_FEAT_CAPTCHA "urn:xmpp:captcha" #define JABBER_FEAT_CSI "urn:xmpp:csi:0" -#define JABBER_FEAT_JUD "jabber:iq:search" +#define JABBER_FEAT_JUD "jabber:iq:search" +#define JABBER_FEAT_IDLE "urn:xmpp:idle:1" #define JABBER_FEAT_SERVER_AVATAR "storage:client:avatar" #define JABBER_FEAT_UPLOAD "urn:xmpp:http:upload" #define JABBER_FEAT_UPLOAD0 "urn:xmpp:http:upload:0" diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index abc46ca6a2..e10d285b74 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1571,14 +1571,24 @@ void CJabberProto::OnProcessPresence(const TiXmlElement *node, ThreadData *info) else if (!mir_strcmp(show, "chat")) status = ID_STATUS_FREECHAT; } + int idleTime = 0; + if (auto *idle = XmlGetChildByTag(node, "idle", "xmlns", JABBER_FEAT_IDLE)) { + status = ID_STATUS_IDLE; + if (auto *szSince = XmlGetAttr(idle, "since")) + idleTime = str2time(szSince); + } + int priority = XmlGetChildInt(node, "priority"); const char *pszStatus = XmlGetChildText(node, "status"); ListAddResource(LIST_ROSTER, from, status, pszStatus, priority); // XEP-0115: Entity Capabilities pResourceStatus r(ResourceInfoFromJID(from)); - if (r != nullptr) + if (r != nullptr) { + if (idleTime) + r->m_dwIdleStartTime = idleTime; OnProcessPresenceCapabilites(node, r); + } UpdateJidDbSettings(from); diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index ec09d029ec..6a079d734e 100755 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -439,8 +439,12 @@ void CJabberProto::SendPresenceTo(int status, const char *to, const TiXmlElement } } - if (m_tmJabberIdleStartTime) - p << XQUERY(JABBER_FEAT_LAST_ACTIVITY) << XATTRI("seconds", time(0) - m_tmJabberIdleStartTime); + if (m_tmJabberIdleStartTime) { + // XEP-0319 support + char szSince[100]; + time2str(m_tmJabberIdleStartTime, szSince, _countof(szSince)); + p << XCHILDNS("idle", JABBER_FEAT_IDLE) << XATTR("since", szSince); + } if (m_bEnableAvatars) { TiXmlElement *x = p << XCHILDNS("x", "vcard-temp:x:update"); -- cgit v1.2.3