-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set errors to be ignored during account creation/deletion
Some servers close the connection during account creation with a <connection-timeout/> stream error which can be ignored. https://xmpp.org/extensions/xep-0077.html#usecases-cancel specifies the usage of the stream error <not-authorized/>. That is now handled as a valid response to the account deletion request instead of a result IQ stanza or in addition to it. The <conflict> stream error is now handled as well since some servers send it instead of the <not-authorized/> stream error. The KeepAliveError was emitted during testing between requesting the deletion of an account and the server's response. That seems to be due to an XMPP ping that could not be handled appropriately by the server. The error is now handled as a response to a successful account deletion.
- Loading branch information
Showing
5 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// SPDX-FileCopyrightText: 2009 Manjeet Dahiya <[email protected]> | ||
// SPDX-FileCopyrightText: 2023 Melvin Keskin <[email protected]> | ||
// | ||
// SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
|
@@ -891,6 +892,18 @@ bool QXmppClient::injectMessage(QXmppMessage &&message) | |
return handled; | ||
} | ||
|
||
/// | ||
/// Sets errors that are ignored if they occur. | ||
/// | ||
/// \param ignoredErrors errors to be ignored | ||
/// | ||
/// \since QXmpp 1.6 | ||
/// | ||
void QXmppClient::setIgnoredErrors(const QMap<QXmppClient::Error, QVector<QXmppStanza::Error::Condition>> &ignoredErrors) | ||
{ | ||
d->ignoredErrors = ignoredErrors; | ||
} | ||
|
||
/// | ||
/// Give extensions a chance to handle incoming stanzas. | ||
/// | ||
|
@@ -943,6 +956,13 @@ void QXmppClient::_q_streamDisconnected() | |
|
||
void QXmppClient::_q_streamError(QXmppClient::Error err) | ||
{ | ||
// SKip errors that are valid during special procedures such as account creation/deletion. | ||
if (d->ignoredErrors.contains(err) && | ||
(err != QXmppClient::XmppStreamError || | ||
d->ignoredErrors.value(err).contains(d->stream->xmppStreamError()))) { | ||
return; | ||
} | ||
|
||
if (d->stream->configuration().autoReconnectionEnabled()) { | ||
if (err == QXmppClient::XmppStreamError) { | ||
// if we receive a resource conflict, inhibit reconnection | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// SPDX-FileCopyrightText: 2009 Manjeet Dahiya <[email protected]> | ||
// SPDX-FileCopyrightText: 2023 Melvin Keskin <[email protected]> | ||
// | ||
// SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
|
@@ -325,6 +326,8 @@ public Q_SLOTS: | |
void injectIq(const QDomElement &element, const std::optional<QXmppE2eeMetadata> &e2eeMetadata); | ||
bool injectMessage(QXmppMessage &&message); | ||
|
||
void setIgnoredErrors(const QMap<QXmppClient::Error, QVector<QXmppStanza::Error::Condition>> &ignoredErrors); | ||
|
||
private Q_SLOTS: | ||
void _q_elementReceived(const QDomElement &element, bool &handled); | ||
void _q_reconnect(); | ||
|
@@ -339,6 +342,7 @@ private Q_SLOTS: | |
friend class QXmppClientExtension; | ||
friend class QXmppInternalClientExtension; | ||
friend class TestClient; | ||
friend class QXmppRegistrationManager; | ||
}; | ||
|
||
#endif // QXMPPCLIENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// SPDX-FileCopyrightText: 2020 Manjeet Dahiya <[email protected]> | ||
// SPDX-FileCopyrightText: 2020 Linus Jahn <[email protected]> | ||
// SPDX-FileCopyrightText: 2023 Melvin Keskin <[email protected]> | ||
// | ||
// SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
|
@@ -18,9 +19,9 @@ | |
#ifndef QXMPPCLIENT_P_H | ||
#define QXMPPCLIENT_P_H | ||
|
||
#include "QXmppClient.h" | ||
#include "QXmppPresence.h" | ||
|
||
class QXmppClient; | ||
class QXmppClientExtension; | ||
class QXmppE2eeExtension; | ||
class QXmppLogger; | ||
|
@@ -38,6 +39,7 @@ class QXmppClientPrivate | |
QXmppLogger *logger; | ||
/// Pointer to the XMPP stream | ||
QXmppOutgoingClient *stream; | ||
QMap<QXmppClient::Error, QVector<QXmppStanza::Error::Condition>> ignoredErrors; | ||
|
||
QXmppE2eeExtension *encryptionExtension; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters