From 5559ed29681d031f36e7a7d011e3ec4bec3635f5 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Sat, 24 Oct 2015 00:19:25 +0200 Subject: Implement XEP-0352: Client State Indication This commit is based on a pull request by fbeutel (GitHub) (see #87) and was rebased and slightly modified by me. --- src/client/QXmppOutgoingClient.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/client/QXmppOutgoingClient.cpp') diff --git a/src/client/QXmppOutgoingClient.cpp b/src/client/QXmppOutgoingClient.cpp index 9d5043d0..04929362 100644 --- a/src/client/QXmppOutgoingClient.cpp +++ b/src/client/QXmppOutgoingClient.cpp @@ -106,6 +106,9 @@ public: QString resumeHost; quint16 resumePort; + // Client State Indication + bool clientStateIndicationEnabled; + // Timers QTimer *pingTimer; QTimer *timeoutTimer; @@ -126,6 +129,7 @@ QXmppOutgoingClientPrivate::QXmppOutgoingClientPrivate(QXmppOutgoingClient *qq) , canResume(false) , isResuming(false) , resumePort(0) + , clientStateIndicationEnabled(false) , pingTimer(0) , timeoutTimer(0) , q(qq) @@ -294,6 +298,13 @@ bool QXmppOutgoingClient::isConnected() const return QXmppStream::isConnected() && d->sessionStarted; } +/// Returns true if client state indication (xep-0352) is supported by the server + +bool QXmppOutgoingClient::isClientStateIndicationEnabled() const +{ + return d->clientStateIndicationEnabled; +} + void QXmppOutgoingClient::_q_socketDisconnected() { debug("Socket disconnected"); @@ -400,6 +411,9 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv) QXmppStreamFeatures features; features.parse(nodeRecv); + if(features.clientStateIndicationMode() == QXmppStreamFeatures::Enabled) + d->clientStateIndicationEnabled = true; + if (!socket()->isEncrypted()) { // determine TLS mode to use -- cgit v1.2.3