From 11a0af384ff12e96827a08dd378c7b1830c31790 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Tue, 8 Sep 2020 17:31:34 +0200 Subject: QXmppClient: Reset Stream Management package cache on JID changes The stream management mechanisms cache sent packages until the client receives an acknowledgement from the server. When the connection gets lost, the client resends all packages from the last connection that have not been acknowledged. And here comes the problem: When connecting with a different JID, the client still resends all packages from the last connection. Packages that were never intended to be sent from another account / to another server. This commit fixes this behaviour by resetting the package cache, when the JID changes. --- src/client/QXmppClient.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/client/QXmppClient.cpp') diff --git a/src/client/QXmppClient.cpp b/src/client/QXmppClient.cpp index db935f1e..5509eb24 100644 --- a/src/client/QXmppClient.cpp +++ b/src/client/QXmppClient.cpp @@ -232,17 +232,23 @@ QXmppConfiguration& QXmppClient::configuration() return d->stream->configuration(); } +/// /// Attempts to connect to the XMPP server. Server details and other configurations /// are specified using the config parameter. Use signals connected(), error(QXmppClient::Error) /// and disconnected() to know the status of the connection. +/// /// \param config Specifies the configuration object for connecting the XMPP server. /// This contains the host name, user, password etc. See QXmppConfiguration for details. /// \param initialPresence The initial presence which will be set for this user /// after establishing the session. The default value is QXmppPresence::Available - +/// void QXmppClient::connectToServer(const QXmppConfiguration& config, const QXmppPresence& initialPresence) { + // reset package cache from last connection + if (d->stream->configuration().jidBare() != config.jidBare()) + d->stream->resetPacketCache(); + d->stream->configuration() = config; d->clientPresence = initialPresence; d->addProperCapability(d->clientPresence); -- cgit v1.2.3