void QXmppIncomingClient::handleStream(const QDomElement &streamElement) { if (d->idleTimer->interval()) d->idleTimer->start(); d->saslStep = 0; // start stream const QByteArray sessionId = generateStanzaHash().toAscii(); 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.toAscii()); sendData(response.toUtf8()); // check requested 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")); sendData(response.toUtf8()); disconnectFromHost(); return; } // send stream features QXmppStreamFeatures features; if (socket() && !socket()->isEncrypted() && !socket()->localCertificate().isNull() && !socket()->privateKey().isNull()) features.setTlsMode(QXmppStreamFeatures::Enabled); if (!d->username.isEmpty()) { features.setBindMode(QXmppStreamFeatures::Required); features.setSessionMode(QXmppStreamFeatures::Enabled); } else if (d->passwordChecker) { QList<QXmppConfiguration::SASLAuthMechanism> mechanisms; mechanisms << QXmppConfiguration::SASLPlain; if (d->passwordChecker->hasGetPassword()) mechanisms << QXmppConfiguration::SASLDigestMD5; features.setAuthMechanisms(mechanisms); } sendPacket(features); }
/// \cond void QXmppIncomingServer::handleStream(const QDomElement &streamElement) { const QString from = streamElement.attribute("from"); if (!from.isEmpty()) info(QString("Incoming server stream from %1 on %2").arg(from, d->origin())); // start stream d->localStreamId = QXmppUtils::generateStanzaHash().toLatin1(); QString data = QString("<?xml version='1.0'?><stream:stream" " xmlns='%1' xmlns:db='%2' xmlns:stream='%3'" " id='%4' version=\"1.0\">").arg( ns_server, ns_server_dialback, ns_stream, d->localStreamId); sendData(data.toUtf8()); // send stream features QXmppStreamFeatures features; if (!socket()->isEncrypted() && !socket()->localCertificate().isNull() && !socket()->privateKey().isNull()) features.setTlsMode(QXmppStreamFeatures::Enabled); sendPacket(features); }