/***************************************************************************
- * Copyright (C) 2005-2018 by the Quassel Project *
+ * Copyright (C) 2005-2020 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include "clientauthhandler.h"
#include <QtEndian>
-
-#ifdef HAVE_SSL
-# include <QSslSocket>
-#else
-# include <QTcpSocket>
-#endif
+#include <QSslSocket>
#include "client.h"
#include "clientsettings.h"
#include "peerfactory.h"
#include "util.h"
-using namespace Protocol;
-
ClientAuthHandler::ClientAuthHandler(CoreAccount account, QObject* parent)
: AuthHandler(parent)
, _peer(nullptr)
{
CoreAccountSettings s;
-#ifdef HAVE_SSL
auto* socket = new QSslSocket(this);
// make sure the warning is shown if we happen to connect without SSL support later
s.setAccountValue("ShowNoClientSslWarning", true);
-#else
- if (_account.useSsl()) {
- if (s.accountValue("ShowNoClientSslWarning", true).toBool()) {
- bool accepted = false;
- emit handleNoSslInClient(&accepted);
- if (!accepted) {
- emit errorMessage(tr("Unencrypted connection canceled"));
- return;
- }
- s.setAccountValue("ShowNoClientSslWarning", false);
- }
- }
- QTcpSocket* socket = new QTcpSocket(this);
-#endif
#ifndef QT_NO_NETWORKPROXY
QNetworkProxy proxy;
stream.setVersion(QDataStream::Qt_4_2);
quint32 magic = Protocol::magic;
-#ifdef HAVE_SSL
if (_account.useSsl())
magic |= Protocol::Encryption;
-#endif
magic |= Protocol::Compression;
stream << magic;
// useSsl will be ignored by non-legacy peers
bool useSsl = false;
-#ifdef HAVE_SSL
useSsl = _account.useSsl();
-#endif
- _peer->dispatch(RegisterClient(Quassel::Features{}, Quassel::buildInfo().fancyVersionString, Quassel::buildInfo().commitDate, useSsl));
+ _peer->dispatch(Protocol::RegisterClient(Quassel::Features{}, Quassel::buildInfo().fancyVersionString, Quassel::buildInfo().commitDate, useSsl));
}
-void ClientAuthHandler::handle(const ClientDenied& msg)
+void ClientAuthHandler::handle(const Protocol::ClientDenied& msg)
{
emit errorPopup(msg.errorString);
requestDisconnect(tr("The core refused connection from this client"));
}
-void ClientAuthHandler::handle(const ClientRegistered& msg)
+void ClientAuthHandler::handle(const Protocol::ClientRegistered& msg)
{
_coreConfigured = msg.coreConfigured;
_backendInfo = msg.backendInfo;
login();
}
-void ClientAuthHandler::setupCore(const SetupData& setupData)
+void ClientAuthHandler::setupCore(const Protocol::SetupData& setupData)
{
_peer->dispatch(setupData);
}
-void ClientAuthHandler::handle(const SetupFailed& msg)
+void ClientAuthHandler::handle(const Protocol::SetupFailed& msg)
{
emit coreSetupFailed(msg.errorString);
}
-void ClientAuthHandler::handle(const SetupDone& msg)
+void ClientAuthHandler::handle(const Protocol::SetupDone& msg)
{
Q_UNUSED(msg)
}
}
- _peer->dispatch(Login(_account.user(), _account.password()));
+ _peer->dispatch(Protocol::Login(_account.user(), _account.password()));
}
-void ClientAuthHandler::handle(const LoginFailed& msg)
+void ClientAuthHandler::handle(const Protocol::LoginFailed& msg)
{
login(msg.errorString);
}
-void ClientAuthHandler::handle(const LoginSuccess& msg)
+void ClientAuthHandler::handle(const Protocol::LoginSuccess& msg)
{
Q_UNUSED(msg)
emit loginSuccessful(_account);
}
-void ClientAuthHandler::handle(const SessionState& msg)
+void ClientAuthHandler::handle(const Protocol::SessionState& msg)
{
disconnect(socket(), nullptr, this, nullptr); // this is the last message we shall ever get
void ClientAuthHandler::checkAndEnableSsl(bool coreSupportsSsl)
{
-#ifndef HAVE_SSL
- Q_UNUSED(coreSupportsSsl);
-#else
CoreAccountSettings s;
if (coreSupportsSsl && _account.useSsl()) {
// Make sure the warning is shown next time we don't have SSL in the core
else
startRegistration();
}
-#endif
}
-#ifdef HAVE_SSL
void ClientAuthHandler::onSslSocketEncrypted()
{
socket->ignoreSslErrors();
}
-
-#endif /* HAVE_SSL */