diff options
author | George Hazan <ghazan@miranda.im> | 2019-03-17 17:50:47 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-03-17 17:50:47 +0300 |
commit | e69e0ee825baad1b09849eeb126df9a08501208b (patch) | |
tree | 0370c2b0a2e750e62519d08a3ef92142fa29d492 | |
parent | baa38b939c22325a255641e2bf483a202ec9bb08 (diff) |
fixes #1898 (XMPP/Jabber: Implement XEP-0352 (Client State Indication))
-rwxr-xr-x | protocols/JabberG/src/jabber_caps.h | 3 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_events.cpp | 10 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.h | 1 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_thread.cpp | 19 |
4 files changed, 23 insertions, 10 deletions
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h index 683b44b897..4899eced24 100755 --- a/protocols/JabberG/src/jabber_caps.h +++ b/protocols/JabberG/src/jabber_caps.h @@ -131,8 +131,9 @@ typedef unsigned __int64 JabberCapsBits; #define JABBER_FEAT_ARCHIVE_MANAGE "urn:xmpp:archive:manage"
#define JABBER_CAPS_ARCHIVE_MANAGE ((JabberCapsBits)1<<35)
-#define JABBER_FEAT_CAPTCHA "urn:xmpp:captcha"
#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_ATTENTION "urn:xmpp:attention:0"
#define JABBER_CAPS_ATTENTION ((JabberCapsBits)1<<36)
diff --git a/protocols/JabberG/src/jabber_events.cpp b/protocols/JabberG/src/jabber_events.cpp index fb21161328..325de81a36 100644 --- a/protocols/JabberG/src/jabber_events.cpp +++ b/protocols/JabberG/src/jabber_events.cpp @@ -190,8 +190,16 @@ int CJabberProto::OnIdleChanged(WPARAM, LPARAM lParam) MIRANDA_IDLE_INFO mii;
Idle_GetInfo(mii);
m_tmJabberIdleStartTime = time(0) - mii.idleTime * 60;
+
+ if (m_bCisAvailable)
+ m_ThreadInfo->send(XmlNode("inactive") << XATTR("xmlns", JABBER_FEAT_CSI));
+ }
+ else {
+ m_tmJabberIdleStartTime = 0;
+
+ if (m_bCisAvailable)
+ m_ThreadInfo->send(XmlNode("active") << XATTR("xmlns", JABBER_FEAT_CSI));
}
- else m_tmJabberIdleStartTime = 0;
return 0;
}
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index fb20d8838f..58685fa31f 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -208,6 +208,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface mir_cs m_csModeMsgMutex;
JABBER_MODEMSGS m_modeMsgs;
+ bool m_bCisAvailable;
bool m_bJabberOnline; // XMPP connection initialized and we can send XMPP packets
bool m_bShutdown;
bool m_bSendKeepAlive;
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 293da198d5..844ac3a1a1 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -689,15 +689,16 @@ void CJabberProto::OnProcessFeatures(const TiXmlElement *node, ThreadData *info) bool areMechanismsDefined = false;
for (auto *n : TiXmlEnum(node)) {
- if (!mir_strcmp(n->Name(), "starttls")) {
+ auto *pszName = n->Name();
+ if (!mir_strcmp(pszName, "starttls")) {
if (!info->conn.useSSL && m_bUseTLS) {
debugLogA("Requesting TLS");
- info->send(XmlNode(n->Name()) << XATTR("xmlns", "urn:ietf:params:xml:ns:xmpp-tls"));
+ info->send(XmlNode(pszName) << XATTR("xmlns", "urn:ietf:params:xml:ns:xmpp-tls"));
return;
}
}
- if (!mir_strcmp(n->Name(), "compression") && m_bEnableZlib == TRUE) {
+ if (!mir_strcmp(pszName, "compression") && m_bEnableZlib == TRUE) {
debugLogA("Server compression available");
for (auto *c : TiXmlFilter(n, "method")) {
if (!mir_strcmp(c->GetText(), "zlib") && info->zlibInit() == TRUE) {
@@ -709,7 +710,7 @@ void CJabberProto::OnProcessFeatures(const TiXmlElement *node, ThreadData *info) }
}
- if (!mir_strcmp(n->Name(), "mechanisms")) {
+ if (!mir_strcmp(pszName, "mechanisms")) {
m_AuthMechs.isPlainAvailable = false;
m_AuthMechs.isPlainOldAvailable = false;
m_AuthMechs.isMd5Available = false;
@@ -738,11 +739,13 @@ void CJabberProto::OnProcessFeatures(const TiXmlElement *node, ThreadData *info) }
}
}
- else if (!mir_strcmp(n->Name(), "register")) isRegisterAvailable = true;
- else if (!mir_strcmp(n->Name(), "auth")) m_AuthMechs.isAuthAvailable = true;
- else if (!mir_strcmp(n->Name(), "session")) m_AuthMechs.isSessionAvailable = true;
- else if (m_bEnableStreamMgmt && !mir_strcmp(n->Name(), "sm"))
+ else if (!mir_strcmp(pszName, "register")) isRegisterAvailable = true;
+ else if (!mir_strcmp(pszName, "auth")) m_AuthMechs.isAuthAvailable = true;
+ else if (!mir_strcmp(pszName, "session")) m_AuthMechs.isSessionAvailable = true;
+ else if (m_bEnableStreamMgmt && !mir_strcmp(pszName, "sm"))
m_StrmMgmt.CheckStreamFeatures(n);
+ else if (!mir_strcmp(pszName, "csi") && n->Attribute("xmlns", JABBER_FEAT_CSI))
+ m_bCisAvailable = true;
}
if (areMechanismsDefined) {
|