Skip to content

Commit

Permalink
Parse and emit connection timeout stream error
Browse files Browse the repository at this point in the history
  • Loading branch information
melvo committed Dec 2, 2023
1 parent 753ea0e commit d53d6f9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/base/QXmppStanza.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class QXMPP_EXPORT QXmppStanza : public QXmppNonza
UnexpectedRequest, ///< The request was unexpected.
PolicyViolation, ///< The entity has violated a local server policy. \since QXmpp 1.3
EmailConfirmationRequired, ///< The server requires the entitiy to confirm an email message that the server sent to the entity. \since QXmpp 1.6
ConnectionTimeout, ///< The server closed the connection to the entity because the server did not receive a response to a request from it. \since QXmpp 1.6
};

Error();
Expand Down
2 changes: 2 additions & 0 deletions src/client/QXmppOutgoingClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
d->xmppStreamError = QXmppStanza::Error::Conflict;
} else if (!nodeRecv.firstChildElement("not-authorized").isNull()) {
d->xmppStreamError = QXmppStanza::Error::NotAuthorized;
} else if (!nodeRecv.firstChildElement("connection-timeout").isNull()) {
d->xmppStreamError = QXmppStanza::Error::ConnectionTimeout;
} else {
d->xmppStreamError = QXmppStanza::Error::UndefinedCondition;
}
Expand Down
33 changes: 12 additions & 21 deletions src/client/QXmppRegistrationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,12 @@ class QXmppRegistrationManagerPrivate;
///
/// <h4>Filling out the registration form</h4>
///
/// Now you need to fill out the registration form. If this requires user
/// interaction, it is recommended that you disconnect from the server at this
/// point now. This is required, because some servers will kick inactive, not
/// authorized clients after a few seconds.
/// Now you need to fill out the registration form. If that takes some time, which is often the case
/// when user interaction is required, the server can close the connection triggering
/// QXmppClient::error() to emit QXmppStanza::Error::ConnectionTimeout before the completed form is
/// submitted to the server. That is due to some servers kicking unauthorized clients after a few
/// seconds when they are inactive. In order to support account creation for both servers closing
/// the connection and servers keeping it open, you need to handle those cases appropriately.
///
/// If the returned IQ contains a data form, that can be displayed to a user or
/// can be filled out in another way.
Expand All @@ -173,24 +175,20 @@ class QXmppRegistrationManagerPrivate;
///
/// <h4>Sending the completed form to the server</h4>
///
/// <b>Option A</b>: If filling out the form goes very quick, you can set the
/// filled out form directly using setRegistrationFormToSend() and then
/// directly trigger the form to be sent using sendCachedRegistrationForm().
/// <b>Option A</b>: If the connection is still open once the form is filled out, set the form using
/// setRegistrationFormToSend() and then trigger the form to be directly sent using
/// sendCachedRegistrationForm().
///
/// \code
/// registrationManager->setRegistrationFormToSend(completedForm);
/// registrationManager->sendCachedRegistrationForm();
/// \endcode
///
/// <b>Option B</b>: If filling out the form takes longer, i.e. because user
/// interaction is required, you should disconnect now. As soon as you have
/// completed the form, you can set it using setRegistrationFormToSend(). After
/// that you can reconnect to the server and the registration manager will
/// automatically send the set form.
/// <b>Option B</b>: If the connection is closed before the form is filled out, set the form using
/// setRegistrationFormToSend() and connect to the server again. The registration manager will
/// automatically send the set form once connected.
///
/// \code
/// client->disconnectFromServer();
/// // user fills out form ...
/// registrationManager->setRegistrationFormToSend(completedForm);
///
/// // As before, you only need to provide a domain to connectToServer()
Expand Down Expand Up @@ -294,13 +292,6 @@ class QXMPP_EXPORT QXmppRegistrationManager : public QXmppClientExtension
///
/// Emitted, when a registration form has been received.
///
/// When registering an account on the server and user interaction is
/// required now to complete the form, it is recommended to disconnect and
/// sending the completed registration form on reconnect using
/// QXmppRegistrationManager::setRegistrationFormToSend(). Some servers
/// (i.e. ejabberd) kick their clients after a timeout when they are not
/// active. This can be avoided this way.
///
/// \param iq The received form. If it does not contain a valid data form
/// (see QXmppRegisterIq::form()), the required fields should be marked by
/// empty (but not null) strings in the QXmppRegisterIq (i.e.
Expand Down

0 comments on commit d53d6f9

Please sign in to comment.