From 9a36f8e55bfa485467e093fba669841fdfacda2f Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Mon, 31 Mar 2008 22:19:33 +0000 Subject: [PATCH] Quassel _should_ now compile again if Qt doesn't provide SSL-Support. This is untested, so please let me know if there's still work to be done. --- src/client/clientsyncer.cpp | 31 +++++++++++++++++-------------- src/client/clientsyncer.h | 10 ++++++++-- src/core/core.cpp | 11 +++++++++-- src/core/core.h | 11 +++++++++-- src/core/sslserver.cpp | 4 ++++ src/core/sslserver.h | 4 ++++ src/qtui/coreconnectdlg.cpp | 6 +++++- version.inc | 4 ++-- 8 files changed, 58 insertions(+), 23 deletions(-) diff --git a/src/client/clientsyncer.cpp b/src/client/clientsyncer.cpp index 952860a6..2c2a5df5 100644 --- a/src/client/clientsyncer.cpp +++ b/src/client/clientsyncer.cpp @@ -31,17 +31,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,6 +124,11 @@ 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 @@ -180,19 +184,15 @@ void ClientSyncer::clientInitAck(const QVariantMap &msg) { 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); } 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,6 +200,7 @@ void ClientSyncer::clientInitAck(const QVariantMap &msg) { return; } } +#endif if(!msg["Configured"].toBool()) { // start wizard @@ -359,6 +360,7 @@ void ClientSyncer::checkSyncState() { } } +#ifndef QT_NO_OPENSSL void ClientSyncer::sslErrors(const QList &errors) { qDebug() << "SSL Errors:"; foreach(QSslError err, errors) @@ -368,3 +370,4 @@ void ClientSyncer::sslErrors(const QList &errors) { if(socket) socket->ignoreSslErrors(); } +#endif diff --git a/src/client/clientsyncer.h b/src/client/clientsyncer.h index 5ea2ae42..44e33737 100644 --- a/src/client/clientsyncer.h +++ b/src/client/clientsyncer.h @@ -23,10 +23,14 @@ #include #include -#include -#include #include +#ifndef QT_NO_OPENSSL +#include +#else +#include +#endif + class IrcUser; class IrcChannel; @@ -85,7 +89,9 @@ class ClientSyncer : public QObject { void sessionStateReceived(const QVariantMap &state); void doCoreSetup(const QVariant &setupData); +#ifndef QT_NO_OPENSSL void sslErrors(const QList &errors); +#endif private: QPointer socket; diff --git a/src/core/core.cpp b/src/core/core.cpp index 50bfa739..8a1c7771 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -334,7 +334,6 @@ void Core::stopListening() { } void Core::incomingConnection() { - // TODO implement SSL while(server.hasPendingConnections()) { QTcpSocket *socket = server.nextPendingConnection(); connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); @@ -385,9 +384,14 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { "Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuild) .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime.toString(Qt::TextDate)); +#ifndef QT_NO_OPENSSL SslServer *sslServer = qobject_cast(&server); QSslSocket *sslSocket = qobject_cast(socket); bool supportSsl = (bool)sslServer && (bool)sslSocket && sslServer->certIsValid(); +#else + bool supportSsl = false; +#endif + reply["SupportSsl"] = supportSsl; // switch to ssl after client has been informed about our capabilities (see below) @@ -422,13 +426,14 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { reply["MsgType"] = "ClientInitAck"; SignalProxy::writeDataToDevice(socket, reply); +#ifndef QT_NO_OPENSSL // after we told the client that we are ssl capable we switch to ssl mode if(supportSsl && msg["UseSsl"].toBool()) { qDebug() << "Starting TLS for Client:" << qPrintable(socket->peerAddress().toString()); connect(sslSocket, SIGNAL(sslErrors(const QList &)), this, SLOT(sslErrors(const QList &))); sslSocket->startServerEncryption(); } - +#endif } else { // for the rest, we need an initialized connection @@ -515,12 +520,14 @@ SessionThread *Core::createSession(UserId uid, bool restore) { return sess; } +#ifndef QT_NO_OPENSSL void Core::sslErrors(const QList &errors) { Q_UNUSED(errors); QSslSocket *socket = qobject_cast(sender()); if(socket) socket->ignoreSslErrors(); } +#endif void Core::socketError(QAbstractSocket::SocketError err) { QAbstractSocket *socket = qobject_cast(sender()); diff --git a/src/core/core.h b/src/core/core.h index 277c43cc..f32502e7 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -26,14 +26,19 @@ #include #include #include -#include + +#ifndef QT_NO_OPENSSL #include +#include "sslserver.h" +#else +#include +#include +#endif #include "bufferinfo.h" #include "message.h" #include "global.h" #include "sessionthread.h" -#include "sslserver.h" #include "types.h" class CoreSession; @@ -271,7 +276,9 @@ class Core : public QObject { bool initStorage(QVariantMap dbSettings, bool setup = false); +#ifndef QT_NO_OPENSSL void sslErrors(const QList &errors); +#endif void socketError(QAbstractSocket::SocketError); private: diff --git a/src/core/sslserver.cpp b/src/core/sslserver.cpp index b007a65f..b19ee5fb 100644 --- a/src/core/sslserver.cpp +++ b/src/core/sslserver.cpp @@ -18,6 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#ifndef QT_NO_OPENSSL + #include "sslserver.h" #include @@ -66,3 +68,5 @@ void SslServer::incomingConnection(int socketDescriptor) { delete serverSocket; } } + +#endif // QT_NO_OPENSSL diff --git a/src/core/sslserver.h b/src/core/sslserver.h index 3dd5bd98..f96f54f4 100644 --- a/src/core/sslserver.h +++ b/src/core/sslserver.h @@ -18,6 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#ifndef QT_NO_OPENSSL + #ifndef SSLSERVER_H #define SSLSERVER_H @@ -50,3 +52,5 @@ private: }; #endif //SSLSERVER_H + +#endif QT_NO_OPENSSL diff --git a/src/qtui/coreconnectdlg.cpp b/src/qtui/coreconnectdlg.cpp index b4225efc..bc4cf31b 100644 --- a/src/qtui/coreconnectdlg.cpp +++ b/src/qtui/coreconnectdlg.cpp @@ -459,7 +459,6 @@ void CoreConnectDlg::syncFinished() { /***************************************************************************************** * CoreAccountEditDlg *****************************************************************************************/ - CoreAccountEditDlg::CoreAccountEditDlg(AccountId id, const QVariantMap &acct, const QStringList &_existing, QWidget *parent) : QDialog(parent) { ui.setupUi(this); existing = _existing; @@ -479,7 +478,12 @@ CoreAccountEditDlg::CoreAccountEditDlg(AccountId id, const QVariantMap &acct, co ui.port->setValue(acct["Port"].toUInt()); ui.useInternal->setChecked(acct["UseInternal"].toBool()); ui.accountName->setText(acct["AccountName"].toString()); +#ifndef QT_NO_OPENSSL ui.useSsl->setChecked(account["useSsl"].toBool()); +#else + ui.useSsl->setChecked(false); + ui.useSsl->setEnabled(false); +#endif ui.useProxy->setChecked(account["useProxy"].toBool()); ui.proxyHost->setText(account["proxyHost"].toString()); ui.proxyPort->setValue(account["proxyPort"].toUInt()); diff --git a/version.inc b/version.inc index 38887a29..7b919d65 100644 --- a/version.inc +++ b/version.inc @@ -4,8 +4,8 @@ { using namespace Global; quasselVersion = "0.2.0-alpha5-pre"; - quasselDate = "2008-03-31"; - quasselBuild = 677; + quasselDate = "2008-04-01"; + quasselBuild = 679; //! Minimum client build number the core needs clientBuildNeeded = 642; -- 2.20.1