diff options
Diffstat (limited to 'src/client/QXmppClient.cpp')
| -rw-r--r-- | src/client/QXmppClient.cpp | 23 |
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. |
