aboutsummaryrefslogtreecommitdiff
path: root/src/client/QXmppClient.cpp
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2015-10-24 00:19:25 +0200
committerLinus Jahn <lnj@kaidan.im>2018-10-29 21:41:31 +0100
commit5559ed29681d031f36e7a7d011e3ec4bec3635f5 (patch)
treeb639a8c68f1d1255b5528bde34412ffc64a34fb6 /src/client/QXmppClient.cpp
parent3e2ca3c04a5a681fa97ebabf6f31b301ec9753a0 (diff)
downloadqxmpp-5559ed29681d031f36e7a7d011e3ec4bec3635f5.tar.gz
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.
Diffstat (limited to 'src/client/QXmppClient.cpp')
-rw-r--r--src/client/QXmppClient.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/client/QXmppClient.cpp b/src/client/QXmppClient.cpp
index bd28288f..e851e5fe 100644
--- a/src/client/QXmppClient.cpp
+++ b/src/client/QXmppClient.cpp
@@ -54,6 +54,9 @@ public:
int reconnectionTries;
QTimer *reconnectionTimer;
+ // Client state indication
+ bool isActive;
+
void addProperCapability(QXmppPresence& presence);
int getNextReconnectTime() const;
@@ -68,6 +71,7 @@ QXmppClientPrivate::QXmppClientPrivate(QXmppClient *qq)
, receivedConflict(false)
, reconnectionTries(0)
, reconnectionTimer(0)
+ , isActive(true)
, q(qq)
{
}
@@ -320,6 +324,25 @@ bool QXmppClient::isConnected() const
return d->stream->isConnected();
}
+/// Returns true if the current client state is "active", false if it is
+/// "inactive". See XEP-0352 for details.
+
+bool QXmppClient::isActive() const
+{
+ return d->isActive;
+}
+
+/// Sets the client state as described in XEP-0352
+
+void QXmppClient::setActive(bool active)
+{
+ if (active != d->isActive && d->stream->isClientStateIndicationEnabled()) {
+ d->isActive = active;
+ QString packet = "<%1 xmlns='%2'/>";
+ d->stream->sendData(packet.arg(active ? "active" : "inactive", ns_csi).toUtf8());
+ }
+}
+
/// Returns the reference to QXmppRosterManager object of the client.
/// \return Reference to the roster object of the connected client. Use this to
/// get the list of friends in the roster and their presence information.