diff options
| author | Linus Jahn <lnj@kaidan.im> | 2020-02-02 18:14:27 +0100 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2020-02-03 00:11:55 +0100 |
| commit | 57f1b775197aed1d32e98b0299c0999339a7d5f6 (patch) | |
| tree | ce5702781e15f3a5c438ab153edf06f51a501b29 /src/server/QXmppIncomingClient.cpp | |
| parent | 99b850a3008bbb03d3449d683adb87839f7d5c4b (diff) | |
| download | qxmpp-57f1b775197aed1d32e98b0299c0999339a7d5f6.tar.gz | |
Run clang-format also on all cpp files
Diffstat (limited to 'src/server/QXmppIncomingClient.cpp')
| -rw-r--r-- | src/server/QXmppIncomingClient.cpp | 82 |
1 files changed, 32 insertions, 50 deletions
diff --git a/src/server/QXmppIncomingClient.cpp b/src/server/QXmppIncomingClient.cpp index 6142faab..919b2561 100644 --- a/src/server/QXmppIncomingClient.cpp +++ b/src/server/QXmppIncomingClient.cpp @@ -59,10 +59,7 @@ private: }; QXmppIncomingClientPrivate::QXmppIncomingClientPrivate(QXmppIncomingClient *qq) - : idleTimer(nullptr) - , passwordChecker(nullptr) - , saslServer(nullptr) - , q(qq) + : idleTimer(nullptr), passwordChecker(nullptr), saslServer(nullptr), q(qq) { } @@ -114,7 +111,7 @@ QXmppIncomingClient::QXmppIncomingClient(QSslSocket *socket, const QString &doma if (socket) { connect(socket, &QAbstractSocket::disconnected, - this, &QXmppIncomingClient::onSocketDisconnected); + this, &QXmppIncomingClient::onSocketDisconnected); setSocket(socket); } @@ -125,7 +122,7 @@ QXmppIncomingClient::QXmppIncomingClient(QSslSocket *socket, const QString &doma d->idleTimer = new QTimer(this); d->idleTimer->setSingleShot(true); connect(d->idleTimer, &QTimer::timeout, - this, &QXmppIncomingClient::onTimeout); + this, &QXmppIncomingClient::onTimeout); } /// Destroys the current stream. @@ -143,8 +140,8 @@ QXmppIncomingClient::~QXmppIncomingClient() bool QXmppIncomingClient::isConnected() const { return QXmppStream::isConnected() && - !d->jid.isEmpty() && - !d->resource.isEmpty(); + !d->jid.isEmpty() && + !d->resource.isEmpty(); } /// Returns the client's JID. @@ -189,23 +186,24 @@ void QXmppIncomingClient::handleStream(const QDomElement &streamElement) // start stream const QByteArray sessionId = QXmppUtils::generateStanzaHash().toLatin1(); QString response = QString("<?xml version='1.0'?><stream:stream" - " xmlns=\"%1\" xmlns:stream=\"%2\"" - " id=\"%3\" from=\"%4\" version=\"1.0\" xml:lang=\"en\">").arg( - ns_client, - ns_stream, - sessionId, - d->domain.toLatin1()); + " xmlns=\"%1\" xmlns:stream=\"%2\"" + " id=\"%3\" from=\"%4\" version=\"1.0\" xml:lang=\"en\">") + .arg( + ns_client, + ns_stream, + sessionId, + d->domain.toLatin1()); sendData(response.toUtf8()); // check requested domain - if (streamElement.attribute("to") != d->domain) - { + if (streamElement.attribute("to") != d->domain) { QString response = QString("<stream:error>" - "<host-unknown xmlns=\"urn:ietf:params:xml:ns:xmpp-streams\"/>" - "<text xmlns=\"urn:ietf:params:xml:ns:xmpp-streams\">" - "This server does not serve %1" - "</text>" - "</stream:error>").arg(streamElement.attribute("to")); + "<host-unknown xmlns=\"urn:ietf:params:xml:ns:xmpp-streams\"/>" + "<text xmlns=\"urn:ietf:params:xml:ns:xmpp-streams\">" + "This server does not serve %1" + "</text>" + "</stream:error>") + .arg(streamElement.attribute("to")); sendData(response.toUtf8()); disconnectFromHost(); return; @@ -215,13 +213,10 @@ void QXmppIncomingClient::handleStream(const QDomElement &streamElement) QXmppStreamFeatures features; if (socket() && !socket()->isEncrypted() && !socket()->localCertificate().isNull() && !socket()->privateKey().isNull()) features.setTlsMode(QXmppStreamFeatures::Enabled); - if (!d->jid.isEmpty()) - { + if (!d->jid.isEmpty()) { features.setBindMode(QXmppStreamFeatures::Required); features.setSessionMode(QXmppStreamFeatures::Enabled); - } - else if (d->passwordChecker) - { + } else if (d->passwordChecker) { QStringList mechanisms; mechanisms << "PLAIN"; if (d->passwordChecker->hasGetPassword()) @@ -278,9 +273,7 @@ void QXmppIncomingClient::handleStanza(const QDomElement &nodeRecv) disconnectFromHost(); return; } - } - else if (nodeRecv.tagName() == QLatin1String("response")) - { + } else if (nodeRecv.tagName() == QLatin1String("response")) { QXmppSaslResponse response; response.parse(nodeRecv); @@ -309,14 +302,10 @@ void QXmppIncomingClient::handleStanza(const QDomElement &nodeRecv) disconnectFromHost(); } } - } - else if (ns == ns_client) - { - if (nodeRecv.tagName() == QLatin1String("iq")) - { + } else if (ns == ns_client) { + if (nodeRecv.tagName() == QLatin1String("iq")) { const QString type = nodeRecv.attribute("type"); - if (QXmppBindIq::isBindIq(nodeRecv) && type == QLatin1String("set")) - { + if (QXmppBindIq::isBindIq(nodeRecv) && type == QLatin1String("set")) { QXmppBindIq bindSet; bindSet.parse(nodeRecv); d->resource = bindSet.resource().trimmed(); @@ -333,9 +322,7 @@ void QXmppIncomingClient::handleStanza(const QDomElement &nodeRecv) // bound emit connected(); return; - } - else if (QXmppSessionIq::isSessionIq(nodeRecv) && type == QLatin1String("set")) - { + } else if (QXmppSessionIq::isSessionIq(nodeRecv) && type == QLatin1String("set")) { QXmppSessionIq sessionSet; sessionSet.parse(nodeRecv); @@ -350,8 +337,7 @@ void QXmppIncomingClient::handleStanza(const QDomElement &nodeRecv) // check the sender is legitimate const QString from = nodeRecv.attribute("from"); - if (!from.isEmpty() && from != d->jid && from != QXmppUtils::jidToBareJid(d->jid)) - { + if (!from.isEmpty() && from != d->jid && from != QXmppUtils::jidToBareJid(d->jid)) { warning(QString("Received a stanza from unexpected JID %1").arg(from)); return; } @@ -359,16 +345,14 @@ void QXmppIncomingClient::handleStanza(const QDomElement &nodeRecv) // process unhandled stanzas if (nodeRecv.tagName() == QLatin1String("iq") || nodeRecv.tagName() == QLatin1String("message") || - nodeRecv.tagName() == QLatin1String("presence")) - { + nodeRecv.tagName() == QLatin1String("presence")) { QDomElement nodeFull(nodeRecv); // if the sender is empty, set it to the appropriate JID - if (nodeFull.attribute("from").isEmpty()) - { + if (nodeFull.attribute("from").isEmpty()) { if (nodeFull.tagName() == QLatin1String("presence") && (nodeFull.attribute("type") == QLatin1String("subscribe") || - nodeFull.attribute("type") == QLatin1String("subscribed"))) + nodeFull.attribute("type") == QLatin1String("subscribed"))) nodeFull.setAttribute("from", QXmppUtils::jidToBareJid(d->jid)); else nodeFull.setAttribute("from", d->jid); @@ -387,7 +371,7 @@ void QXmppIncomingClient::handleStanza(const QDomElement &nodeRecv) void QXmppIncomingClient::onDigestReply() { - auto *reply = qobject_cast<QXmppPasswordReply*>(sender()); + auto *reply = qobject_cast<QXmppPasswordReply *>(sender()); if (!reply) return; reply->deleteLater(); @@ -418,7 +402,7 @@ void QXmppIncomingClient::onDigestReply() void QXmppIncomingClient::onPasswordReply() { - auto *reply = qobject_cast<QXmppPasswordReply*>(sender()); + auto *reply = qobject_cast<QXmppPasswordReply *>(sender()); if (!reply) return; reply->deleteLater(); @@ -461,5 +445,3 @@ void QXmppIncomingClient::onTimeout() // make sure disconnected() gets emitted no matter what QTimer::singleShot(30, this, &QXmppStream::disconnected); } - - |
