X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fclientsyncer.cpp;h=daff617636999094b2dd0fd7c4f3fdbb849e8451;hb=e8a5c49548759045b49c208c250c6f61c7fdfcd5;hp=952860a68390bc9765863410650e00b6dd04bfc4;hpb=b79832bf9c4c21b05629cfd2fdbd008ad690572f;p=quassel.git diff --git a/src/client/clientsyncer.cpp b/src/client/clientsyncer.cpp index 952860a6..daff6176 100644 --- a/src/client/clientsyncer.cpp +++ b/src/client/clientsyncer.cpp @@ -20,7 +20,9 @@ #include "clientsyncer.h" -#include +#ifndef QT_NO_NETWORKPROXY +# include +#endif #include "client.h" #include "global.h" @@ -31,17 +33,16 @@ #include "signalproxy.h" -ClientSyncer::ClientSyncer(QObject *parent) : QObject(parent) { +ClientSyncer::ClientSyncer(QObject *parent) + : QObject(parent) +{ socket = 0; blockSize = 0; connect(Client::signalProxy(), SIGNAL(disconnected()), this, SLOT(coreSocketDisconnected())); - } ClientSyncer::~ClientSyncer() { - - } void ClientSyncer::coreHasData() { @@ -125,13 +126,19 @@ void ClientSyncer::connectToCore(const QVariantMap &conn) { #ifndef QT_NO_OPENSSL QSslSocket *sock = new QSslSocket(Client::instance()); #else + if(conn["useSsl"].toBool()) { + emit connectionError(tr("This client is built without SSL Support!
Disable the usage of SSL in the account settings.")); + emit encrypted(false); + return; + } QTcpSocket *sock = new QTcpSocket(Client::instance()); #endif - +#ifndef QT_NO_NETWORKPROXY if(conn.contains("useProxy") && conn["useProxy"].toBool()) { QNetworkProxy proxy((QNetworkProxy::ProxyType)conn["proxyType"].toInt(), conn["proxyHost"].toString(), conn["proxyPort"].toUInt(), conn["proxyUser"].toString(), conn["proxyPassword"].toString()); sock->setProxy(proxy); } +#endif socket = sock; connect(sock, SIGNAL(readyRead()), this, SLOT(coreHasData())); connect(sock, SIGNAL(connected()), this, SLOT(coreSocketConnected())); @@ -150,10 +157,16 @@ void ClientSyncer::coreSocketConnected() { QVariantMap clientInit; clientInit["MsgType"] = "ClientInit"; clientInit["ClientVersion"] = Global::quasselVersion; - clientInit["ClientDate"] = Global::quasselDate; - clientInit["ClientBuild"] = Global::quasselBuild; // this is a minimum, since we probably won't update for every commit + clientInit["ClientBuild"] = 860; // FIXME legacy! + clientInit["ClientDate"] = Global::quasselBuildDate; + clientInit["ProtocolVersion"] = Global::protocolVersion; clientInit["UseSsl"] = coreConnectionInfo["useSsl"]; - +#ifndef QT_NO_COMPRESS + clientInit["UseCompression"] = true; +#else + clientInit["UseCompression"] = false; +#endif + SignalProxy::writeDataToDevice(socket, clientInit); } @@ -173,26 +186,26 @@ void ClientSyncer::coreSocketDisconnected() { void ClientSyncer::clientInitAck(const QVariantMap &msg) { // Core has accepted our version info and sent its own. Let's see if we accept it as well... - if(msg["CoreBuild"].toUInt() < Global::coreBuildNeeded) { + uint ver = 0; + if(!msg.contains("ProtocolVersion") && msg["CoreBuild"].toUInt() >= 732) ver = 1; // legacy! + if(msg.contains("ProtocolVersion")) ver = msg["ProtocolVersion"].toUInt(); + if(ver < Global::clientNeedsProtocol) { emit connectionError(tr("The Quassel Core you are trying to connect to is too old!
" - "Need at least a Core Version %1 (Build >= %2) to connect.").arg(Global::quasselVersion).arg(Global::coreBuildNeeded)); + "Need at least core/client protocol v%1 to connect.").arg(Global::clientNeedsProtocol)); disconnectFromCore(); return; } emit connectionMsg(msg["CoreInfo"].toString()); + +#ifndef QT_NO_OPENSSL if(coreConnectionInfo["useSsl"].toBool()) { if(msg["SupportSsl"].toBool()) { QSslSocket *sslSocket = qobject_cast(socket); - if(sslSocket) { - connect(sslSocket, SIGNAL(sslErrors(const QList &)), this, SLOT(sslErrors(const QList &))); - sslSocket->startClientEncryption(); - emit encrypted(true); - } else { - emit connectionError(tr("This client is built without SSL Support!
Disable the usage of SSL in the account settings.")); - emit encrypted(false); - disconnectFromCore(); - return; - } + Q_ASSERT(sslSocket); + connect(sslSocket, SIGNAL(sslErrors(const QList &)), this, SLOT(sslErrors(const QList &))); + sslSocket->startClientEncryption(); + emit encrypted(true); + Client::instance()->setSecuredConnection(); } else { emit connectionError(tr("The Quassel Core you are trying to connect to does not support SSL!
If you want to connect anyways, disable the usage of SSL in the account settings.")); emit encrypted(false); @@ -200,7 +213,14 @@ void ClientSyncer::clientInitAck(const QVariantMap &msg) { return; } } +#endif +#ifndef QT_NO_COMPRESS + if(msg["SupportsCompression"].toBool()) { + socket->setProperty("UseCompression", true); + } +#endif + if(!msg["Configured"].toBool()) { // start wizard emit startCoreSetup(msg["StorageBackends"].toList()); @@ -359,6 +379,7 @@ void ClientSyncer::checkSyncState() { } } +#ifndef QT_NO_OPENSSL void ClientSyncer::sslErrors(const QList &errors) { qDebug() << "SSL Errors:"; foreach(QSslError err, errors) @@ -368,3 +389,4 @@ void ClientSyncer::sslErrors(const QList &errors) { if(socket) socket->ignoreSslErrors(); } +#endif