diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-09-02 19:48:43 +0200 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-09-02 19:48:43 +0200 |
| commit | fb7ff81285b0d42071b4b211bd15c43800f7d180 (patch) | |
| tree | 0850b4551260440845444d9f4d0c14eb1d549184 /src/client/QXmppOutgoingClient.cpp | |
| parent | bb6f1e575a1d65162c73ff4f3042c6febd4c939e (diff) | |
| download | qxmpp-fb7ff81285b0d42071b4b211bd15c43800f7d180.tar.gz | |
Add support for see-other-host server change.
Diffstat (limited to 'src/client/QXmppOutgoingClient.cpp')
| -rw-r--r-- | src/client/QXmppOutgoingClient.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/client/QXmppOutgoingClient.cpp b/src/client/QXmppOutgoingClient.cpp index 9b379272..50d2d110 100644 --- a/src/client/QXmppOutgoingClient.cpp +++ b/src/client/QXmppOutgoingClient.cpp @@ -73,6 +73,10 @@ public: QString streamFrom; QString streamVersion; + // Redirection + QString redirectHost; + quint16 redirectPort; + // Session QString bindId; QString sessionId; @@ -92,7 +96,8 @@ private: }; QXmppOutgoingClientPrivate::QXmppOutgoingClientPrivate(QXmppOutgoingClient *qq) - : sessionAvailable(false) + : redirectPort(0) + , sessionAvailable(false) , saslClient(0) , q(qq) { @@ -225,7 +230,13 @@ bool QXmppOutgoingClient::isConnected() const void QXmppOutgoingClient::_q_socketDisconnected() { debug("Socket disconnected"); - emit disconnected(); + if (!d->redirectHost.isEmpty() && d->redirectPort > 0) { + d->connectToHost(d->redirectHost, d->redirectPort); + d->redirectHost = QString(); + d->redirectPort = 0; + } else { + emit disconnected(); + } } void QXmppOutgoingClient::socketSslErrors(const QList<QSslError> & error) @@ -415,6 +426,15 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv) } else if(ns == ns_stream && nodeRecv.tagName() == "error") { + // handle redirects + QRegExp redirectRegex("([^:]+)(:[0-9]+)?"); + if (redirectRegex.exactMatch(nodeRecv.firstChildElement("see-other-host").text())) { + d->redirectHost = redirectRegex.cap(0); + d->redirectPort = 5222; //hostPort.size() > 1 ? hostPort[1].toUShort() : 5222; + disconnectFromHost(); + return; + } + if (!nodeRecv.firstChildElement("conflict").isNull()) d->xmppStreamError = QXmppStanza::Error::Conflict; else |
