Verified Commit df3e1aac authored by Linus Jahn's avatar Linus Jahn 🍙

Use XEP-0352: Client State Indication in QXmpp v0.9.4 or later

As soon as Kaidan gets minimized now it will send the inactive state to
the server that will filter unimportant messages upon this. Most of the
filtered messages will be sent from the server when Kaidan gets active
again.
parent a4945e3a
......@@ -71,6 +71,11 @@ ClientWorker::ClientWorker(Caches *caches, Kaidan *kaidan, bool enableLogging, Q
client->versionManager().setClientName(APPLICATION_DISPLAY_NAME);
client->versionManager().setClientVersion(VERSION_STRING);
client->versionManager().setClientOs(QSysInfo::prettyProductName());
#if QXMPP_VERSION >= 0x000904
// Client State Indication
connect(app, &QGuiApplication::applicationStateChanged, this, &ClientWorker::setCsiState);
#endif
}
ClientWorker::~ClientWorker()
......@@ -159,3 +164,13 @@ QString ClientWorker::generateRandomString(unsigned int length) const
}
return randomString;
}
#if QXMPP_VERSION >= 0x000904 // after QXmpp v0.9.4
void ClientWorker::setCsiState(Qt::ApplicationState state)
{
if (state == Qt::ApplicationActive)
client->setActive(true);
else
client->setActive(false);
}
#endif
......@@ -174,6 +174,13 @@ private slots:
*/
void onConnectionError(QXmppClient::Error error);
#if QXMPP_VERSION >= 0x000904 // after QXmpp v0.9.4
/**
* Uses the QGuiApplication state to reduce network traffic when window is minimized
*/
void setCsiState(Qt::ApplicationState state);
#endif
private:
/**
* Generates a random alphanumeric string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment