void Client::createIdentity(const CertIdentity& id)
{
QVariantMap additional;
-#ifdef HAVE_SSL
additional["KeyPem"] = id.sslKey().toPem();
additional["CertPem"] = id.sslCert().toPem();
-#endif
emit instance()->requestCreateIdentity(id, additional);
}
#include "clientauthhandler.h"
#include <QtEndian>
-
-#ifdef HAVE_SSL
-# include <QSslSocket>
-#else
-# include <QTcpSocket>
-#endif
+#include <QSslSocket>
#include "client.h"
#include "clientsettings.h"
{
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(Protocol::RegisterClient(Quassel::Features{}, Quassel::buildInfo().fancyVersionString, Quassel::buildInfo().commitDate, useSsl));
}
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 */
void userAuthenticationRequired(CoreAccount* account, bool* valid, const QString& errorMessage = QString());
void handleNoSslInClient(bool* accepted);
void handleNoSslInCore(bool* accepted);
-#ifdef HAVE_SSL
void handleSslErrors(const QSslSocket* socket, bool* accepted, bool* permanently);
-#endif
void encrypted(bool isEncrypted = true);
void startCoreSetup(const QVariantList& backendInfo, const QVariantList& authenticatorInfo);
void onSocketDisconnected() override;
void onReadyRead();
-#ifdef HAVE_SSL
void onSslSocketEncrypted();
void onSslErrors();
-#endif
void onProtocolVersionMismatch(int actual, int expected);
CertIdentity::CertIdentity(const CertIdentity& other, QObject* parent)
: Identity(other, parent)
-#ifdef HAVE_SSL
, _isDirty(other._isDirty)
, _sslKey(other._sslKey)
, _sslCert(other._sslCert)
-#endif
{}
-#ifdef HAVE_SSL
void CertIdentity::enableEditSsl(bool enable)
{
if (!enable || _certManager)
{
_certIdentity->setSslCert(QSslCertificate(encoded));
}
-
-#endif // HAVE_SSL
CertIdentity(const Identity& other, QObject* parent = nullptr);
CertIdentity(const CertIdentity& other, QObject* parent = nullptr);
-#ifdef HAVE_SSL
inline bool isDirty() const { return _isDirty; }
-#else
- inline bool isDirty() const { return false; }
-#endif
-#ifdef HAVE_SSL
void enableEditSsl(bool enable = true);
inline const QSslKey& sslKey() const { return _sslKey; }
inline const QSslCertificate& sslCert() const { return _sslCert; }
bool _isDirty{false};
QSslKey _sslKey;
QSslCertificate _sslCert;
-#endif // HAVE_SSL
};
// ========================================
// ClientCertManager
// ========================================
-#ifdef HAVE_SSL
class ClientCertManager : public CertManager
{
CertIdentity* _certIdentity;
};
-#endif // HAVE_SSL
#include <utility>
#include <QHostAddress>
+#include <QSslSocket>
#include <QStringList>
-#ifdef HAVE_SSL
-# include <QSslSocket>
-#endif
#include "client.h"
#include "quassel.h"
connect(_authHandler, &ClientAuthHandler::userAuthenticationRequired, this, &CoreConnection::userAuthenticationRequired);
connect(_authHandler, &ClientAuthHandler::handleNoSslInClient, this, &CoreConnection::handleNoSslInClient);
connect(_authHandler, &ClientAuthHandler::handleNoSslInCore, this, &CoreConnection::handleNoSslInCore);
-#ifdef HAVE_SSL
connect(_authHandler, &ClientAuthHandler::handleSslErrors, this, &CoreConnection::handleSslErrors);
-#endif
connect(_authHandler, &ClientAuthHandler::loginSuccessful, this, &CoreConnection::onLoginSuccessful);
connect(_authHandler, &ClientAuthHandler::handshakeComplete, this, &CoreConnection::onHandshakeComplete);
#include <QNetworkConfigurationManager>
#include <QPointer>
+#include <QSslSocket>
#include <QTimer>
-#ifdef HAVE_SSL
-# include <QSslSocket>
-#else
-# include <QTcpSocket>
-#endif
-
#include "coreaccount.h"
#include "remotepeer.h"
#include "types.h"
void userAuthenticationRequired(CoreAccount*, bool* valid, const QString& errorMessage = QString());
void handleNoSslInClient(bool* accepted);
void handleNoSslInCore(bool* accepted);
-#ifdef HAVE_SSL
void handleSslErrors(const QSslSocket* socket, bool* accepted, bool* permanently);
-#endif
private slots:
void connectToCurrentAccount();
#include <QByteArray>
#include <QDataStream>
#include <QMetaType>
+#include <QSslCertificate>
+#include <QSslKey>
#include <QString>
#include <QStringList>
Q_DECLARE_METATYPE(Identity)
-#ifdef HAVE_SSL
-# include <QSslCertificate>
-# include <QSslKey>
-
class COMMON_EXPORT CertManager : public SyncableObject
{
Q_OBJECT
inline virtual void setSslKey(const QByteArray& encoded) { SYNC(ARG(encoded)) }
inline virtual void setSslCert(const QByteArray& encoded) { SYNC(ARG(encoded)) }
};
-
-#endif // HAVE_SSL
{"oidentd", tr("Enable oidentd integration. In most cases you should also enable --strict-ident.")},
{"oidentd-conffile", tr("Set path to oidentd configuration file."), tr("file")},
{"proxy-cidr", tr("Set IP range from which proxy protocol definitions are allowed"), tr("<address>[,...]"), "::1,127.0.0.1"},
-#ifdef HAVE_SSL
{"require-ssl", tr("Require SSL for remote (non-loopback) client connections.")},
{"ssl-cert", tr("Specify the path to the SSL certificate."), tr("path"), "configdir/quasselCert.pem"},
{"ssl-key", tr("Specify the path to the SSL key."), tr("path"), "ssl-cert-path"},
{"metrics-daemon", tr("Enable metrics API.")},
{"metrics-port", tr("The port quasselcore will listen at for metrics requests. Only meaningful with --metrics-daemon."), tr("port"), "9558"},
{"metrics-listen", tr("The address(es) quasselcore will listen on for metrics requests. Same format as --listen."), tr("<address>[,...]"), "::1,127.0.0.1"}
-#endif
};
}
#include <QtEndian>
#include <QHostAddress>
+#include <QSslSocket>
#include <QTimer>
-#ifdef HAVE_SSL
-# include <QSslSocket>
-#else
-# include <QTcpSocket>
-#endif
-
#include "proxyline.h"
#include "remotepeer.h"
#include "util.h"
connect(socket, selectOverload<QAbstractSocket::SocketError>(&QAbstractSocket::error), this, &RemotePeer::onSocketError);
connect(socket, &QAbstractSocket::disconnected, this, &Peer::disconnected);
-#ifdef HAVE_SSL
auto* sslSocket = qobject_cast<QSslSocket*>(socket);
if (sslSocket) {
connect(sslSocket, &QSslSocket::encrypted, this, [this]() { emit secureStateChanged(true); });
}
-#endif
connect(_compressor, &Compressor::readyRead, this, &RemotePeer::onReadyRead);
connect(_compressor, &Compressor::error, this, &RemotePeer::onCompressionError);
if (socket()) {
if (isLocal())
return true;
-#ifdef HAVE_SSL
auto* sslSocket = qobject_cast<QSslSocket*>(socket());
if (sslSocket && sslSocket->isEncrypted())
return true;
-#endif
}
return false;
}
#include <QHostAddress>
#include <QMetaMethod>
#include <QMetaProperty>
+#include <QSslSocket>
#include <QThread>
-#ifdef HAVE_SSL
-# include <QSslSocket>
-#endif
-
#include "peer.h"
#include "protocol.h"
#include "signalproxy.h"
if (Quassel::isOptionSet("metrics-daemon")) {
_metricsServer = new MetricsServer(this);
-#ifdef HAVE_SSL
_server.setMetricsServer(_metricsServer);
_v6server.setMetricsServer(_metricsServer);
-#endif
}
Quassel::registerReloadHandler([]() {
bool Core::sslSupported()
{
-#ifdef HAVE_SSL
auto* sslServer = qobject_cast<SslServer*>(&instance()->_server);
return sslServer && sslServer->isCertValid();
-#else
- return false;
-#endif
}
bool Core::reloadCerts()
{
-#ifdef HAVE_SSL
auto* sslServerv4 = qobject_cast<SslServer*>(&_server);
bool retv4 = sslServerv4->reloadCerts();
bool retv6 = sslServerv6->reloadCerts();
return retv4 && retv6;
-#else
- // SSL not supported, don't mark configuration reload as failed
- return true;
-#endif
}
void Core::cacheSysIdent()
#include <QDateTime>
#include <QPointer>
+#include <QSslSocket>
#include <QString>
#include <QTimer>
#include <QVariant>
-#ifdef HAVE_SSL
-# include <QSslSocket>
-
-# include "sslserver.h"
-#else
-# include <QTcpServer>
-# include <QTcpSocket>
-#endif
-
#include "authenticator.h"
#include "bufferinfo.h"
#include "deferredptr.h"
#include "oidentdconfiggenerator.h"
#include "sessionthread.h"
#include "singleton.h"
+#include "sslserver.h"
#include "storage.h"
#include "types.h"
QTimer _storageSyncTimer;
-#ifdef HAVE_SSL
SslServer _server, _v6server;
-#else
- QTcpServer _server, _v6server;
-#endif
OidentdConfigGenerator* _oidentdConfigGenerator{nullptr};
#include <QtEndian>
-#ifdef HAVE_SSL
-# include <QSslSocket>
-#endif
+#include <QSslSocket>
#include "core.h"
void CoreAuthHandler::startSsl()
{
-#ifdef HAVE_SSL
auto* sslSocket = qobject_cast<QSslSocket*>(socket());
Q_ASSERT(sslSocket);
connect(sslSocket, selectOverload<const QList<QSslError>&>(&QSslSocket::sslErrors), this, &CoreAuthHandler::onSslErrors);
sslSocket->flush(); // ensure that the write cache is flushed before we switch to ssl (bug 682)
sslSocket->startServerEncryption();
-#endif /* HAVE_SSL */
}
-#ifdef HAVE_SSL
void CoreAuthHandler::onSslErrors()
{
auto* sslSocket = qobject_cast<QSslSocket*>(socket());
Q_ASSERT(sslSocket);
sslSocket->ignoreSslErrors();
}
-#endif
private slots:
void onReadyRead();
-#ifdef HAVE_SSL
void onSslErrors();
-#endif
// only in legacy mode
void onProtocolVersionMismatch(int actual, int expected);
CoreIdentity::CoreIdentity(IdentityId id, QObject* parent)
: Identity(id, parent)
-#ifdef HAVE_SSL
, _certManager(this)
-#endif
{
-#ifdef HAVE_SSL
connect(this, &Identity::idSet, &_certManager, &CoreCertManager::setId);
connect(&_certManager, &SyncableObject::updated, this, &SyncableObject::updated);
-#endif
}
CoreIdentity::CoreIdentity(const Identity& other, QObject* parent)
: Identity(other, parent)
-#ifdef HAVE_SSL
, _certManager(this)
-#endif
{
-#ifdef HAVE_SSL
connect(this, &Identity::idSet, &_certManager, &CoreCertManager::setId);
connect(&_certManager, &SyncableObject::updated, this, &SyncableObject::updated);
-#endif
}
CoreIdentity::CoreIdentity(const CoreIdentity& other, QObject* parent)
: Identity(other, parent)
-#ifdef HAVE_SSL
, _sslKey(other._sslKey)
, _sslCert(other._sslCert)
, _certManager(this)
-#endif
{
-#ifdef HAVE_SSL
connect(this, &Identity::idSet, &_certManager, &CoreCertManager::setId);
connect(&_certManager, &SyncableObject::updated, this, &SyncableObject::updated);
-#endif
}
void CoreIdentity::synchronize(SignalProxy* proxy)
{
proxy->synchronize(this);
-#ifdef HAVE_SSL
proxy->synchronize(&_certManager);
-#endif
}
-#ifdef HAVE_SSL
void CoreIdentity::setSslKey(const QByteArray& encoded)
{
QSslKey key(encoded, QSsl::Rsa);
setSslCert(QSslCertificate(encoded));
}
-#endif
-
-#ifdef HAVE_SSL
// ========================================
// CoreCertManager
// ========================================
_identity->setSslCert(encoded);
CertManager::setSslCert(encoded);
}
-
-#endif // HAVE_SSL
#include "identity.h"
-#ifdef HAVE_SSL
-# include <QSslCertificate>
-# include <QSslKey>
-#endif // HAVE_SSL
+#include <QSslCertificate>
+#include <QSslKey>
class SignalProxy;
// ========================================
// CoreCertManager
// ========================================
-#ifdef HAVE_SSL
class CoreIdentity;
class CORE_EXPORT CoreCertManager : public CertManager
{
public:
CoreCertManager(CoreIdentity* identity);
-# ifdef HAVE_SSL
const QSslKey& sslKey() const override;
const QSslCertificate& sslCert() const override;
public slots:
void setSslKey(const QByteArray& encoded) override;
void setSslCert(const QByteArray& encoded) override;
-# endif
void setId(IdentityId id);
CoreIdentity* _identity{nullptr};
};
-#endif // HAVE_SSL
-
// =========================================
// CoreIdentity
// =========================================
void synchronize(SignalProxy* proxy);
-#ifdef HAVE_SSL
inline const QSslKey& sslKey() const { return _sslKey; }
inline void setSslKey(const QSslKey& key) { _sslKey = key; }
void setSslKey(const QByteArray& encoded);
inline const QSslCertificate& sslCert() const { return _sslCert; }
inline void setSslCert(const QSslCertificate& cert) { _sslCert = cert; }
void setSslCert(const QByteArray& encoded);
-#endif /* HAVE_SSL */
private:
-#ifdef HAVE_SSL
QSslKey _sslKey;
QSslCertificate _sslCert;
CoreCertManager _certManager;
-#endif
};
-#ifdef HAVE_SSL
inline const QSslKey& CoreCertManager::sslKey() const
{
return _identity->sslKey();
{
return _identity->sslCert();
}
-
-#endif
connect(&socket, selectOverload<QAbstractSocket::SocketError>(&QAbstractSocket::error), this, &CoreNetwork::onSocketError);
connect(&socket, &QAbstractSocket::stateChanged, this, &CoreNetwork::onSocketStateChanged);
connect(&socket, &QIODevice::readyRead, this, &CoreNetwork::onSocketHasData);
-#ifdef HAVE_SSL
connect(&socket, &QSslSocket::encrypted, this, &CoreNetwork::onSocketInitialized);
connect(&socket, selectOverload<const QList<QSslError>&>(&QSslSocket::sslErrors), this, &CoreNetwork::onSslErrors);
-#endif
connect(this, &CoreNetwork::newEvent, coreSession()->eventManager(), &EventManager::postEvent);
// Custom rate limiting
// hostname of the server. Qt's DNS cache also isn't used by the proxy so we don't need to refresh the entry.
QHostInfo::fromName(server.host);
}
-#ifdef HAVE_SSL
if (server.useSsl) {
CoreIdentity* identity = identityPtr();
if (identity) {
else {
socket.connectToHost(server.host, server.port);
}
-#else
- socket.connectToHost(server.host, server.port);
-#endif
}
void CoreNetwork::disconnectFromIrc(bool requested, const QString& reason, bool withReconnect)
Server server = usedServer();
-#ifdef HAVE_SSL
// Non-SSL connections enter here only once, always emit socketInitialized(...) in these cases
// SSL connections call socketInitialized() twice, only emit socketInitialized(...) on the first (not yet encrypted) run
if (!server.useSsl || !socket.isEncrypted()) {
// We'll finish setup once we're encrypted, and called again
return;
}
-#else
- emit socketInitialized(identity, localAddress(), localPort(), peerAddress(), peerPort(), _socketId);
-#endif
socket.setSocketOption(QAbstractSocket::KeepAliveOption, true);
// If SASL mechanisms specified, limit to what's accepted for authentication
// if the current identity has a cert set, use SASL EXTERNAL
// FIXME use event
-#ifdef HAVE_SSL
if (!identityPtr()->sslCert().isNull()) {
if (saslMaybeSupports(IrcCap::SaslMech::EXTERNAL)) {
// EXTERNAL authentication supported, send request
}
}
else {
-#endif
if (saslMaybeSupports(IrcCap::SaslMech::PLAIN)) {
// PLAIN authentication supported, send request
// Only working with PLAIN atm, blowfish later
));
sendNextCap();
}
-#ifdef HAVE_SSL
}
-#endif
}
}
}
}
-#ifdef HAVE_SSL
void CoreNetwork::onSslErrors(const QList<QSslError>& sslErrors)
{
Server server = usedServer();
}
}
-#endif // HAVE_SSL
-
void CoreNetwork::checkTokenBucket()
{
if (_skipMessageRates) {
#include <functional>
+#include <QSslError>
+#include <QSslSocket>
#include <QTimer>
-#ifdef HAVE_SSL
-# include <QSslError>
-# include <QSslSocket>
-#else
-# include <QTcpSocket>
-#endif
-
#ifdef HAVE_QCA2
# include "cipher.h"
#endif
void sendAutoWho();
void startAutoWhoCycle();
-#ifdef HAVE_SSL
void onSslErrors(const QList<QSslError>& errors);
-#endif
/**
* Check the message token bucket
bool _debugLogRawIrc; ///< If true, include raw IRC socket messages in the debug log
qint32 _debugLogRawNetId; ///< Network ID for logging raw IRC socket messages, or -1 for all
-#ifdef HAVE_SSL
QSslSocket socket;
-#else
- QTcpSocket socket;
-#endif
qint64 _socketId{0};
CoreUserInputHandler* _userInputHandler;
/*** Identity Handling ***/
void CoreSession::createIdentity(const Identity& identity, const QVariantMap& additional)
{
-#ifndef HAVE_SSL
- Q_UNUSED(additional)
-#endif
-
CoreIdentity coreIdentity(identity);
-#ifdef HAVE_SSL
if (additional.contains("KeyPem"))
coreIdentity.setSslKey(additional["KeyPem"].toByteArray());
if (additional.contains("CertPem"))
coreIdentity.setSslCert(additional["CertPem"].toByteArray());
-#endif
qDebug() << Q_FUNC_INFO;
IdentityId id = Core::createIdentity(user(), coreIdentity);
if (!id.isValid())
CoreNetwork* net = coreNetwork(e);
-#ifdef HAVE_SSL
if (net->identityPtr()->sslCert().isNull()) {
-#endif
QString construct = net->saslAccount();
construct.append(QChar(QChar::Null));
construct.append(net->saslAccount());
QByteArray saslData = QByteArray(construct.toLatin1().toBase64());
saslData.prepend("AUTHENTICATE ");
net->putRawLine(saslData);
-#ifdef HAVE_SSL
}
else {
net->putRawLine("AUTHENTICATE +");
}
-#endif
}
void CoreSessionEventProcessor::processIrcEventCap(IrcEvent* e)
query.bindValue(":kickreason", identity.kickReason());
query.bindValue(":partreason", identity.partReason());
query.bindValue(":quitreason", identity.quitReason());
-#ifdef HAVE_SSL
query.bindValue(":sslcert", identity.sslCert().toPem());
query.bindValue(":sslkey", identity.sslKey().toPem());
-#else
- query.bindValue(":sslcert", QByteArray());
- query.bindValue(":sslkey", QByteArray());
-#endif
safeExec(query);
if (!watchQuery(query)) {
db.rollback();
query.bindValue(":kickreason", identity.kickReason());
query.bindValue(":partreason", identity.partReason());
query.bindValue(":quitreason", identity.quitReason());
-#ifdef HAVE_SSL
query.bindValue(":sslcert", identity.sslCert().toPem());
query.bindValue(":sslkey", identity.sslKey().toPem());
-#else
- query.bindValue(":sslcert", QByteArray());
- query.bindValue(":sslkey", QByteArray());
-#endif
query.bindValue(":identityid", identity.id().toInt());
safeExec(query);
identity.setKickReason(query.value(15).toString());
identity.setPartReason(query.value(16).toString());
identity.setQuitReason(query.value(17).toString());
-#ifdef HAVE_SSL
identity.setSslCert(query.value(18).toByteArray());
identity.setSslKey(query.value(19).toByteArray());
-#endif
nickQuery.bindValue(":identityid", identity.id().toInt());
QList<QString> nicks;
query.bindValue(":kickreason", identity.kickReason());
query.bindValue(":partreason", identity.partReason());
query.bindValue(":quitreason", identity.quitReason());
-#ifdef HAVE_SSL
query.bindValue(":sslcert", identity.sslCert().toPem());
query.bindValue(":sslkey", identity.sslKey().toPem());
-#else
- query.bindValue(":sslcert", QByteArray());
- query.bindValue(":sslkey", QByteArray());
-#endif
lockForWrite();
safeExec(query);
query.bindValue(":kickreason", identity.kickReason());
query.bindValue(":partreason", identity.partReason());
query.bindValue(":quitreason", identity.quitReason());
-#ifdef HAVE_SSL
query.bindValue(":sslcert", identity.sslCert().toPem());
query.bindValue(":sslkey", identity.sslKey().toPem());
-#else
- query.bindValue(":sslcert", QByteArray());
- query.bindValue(":sslkey", QByteArray());
-#endif
query.bindValue(":identityid", identity.id().toInt());
safeExec(query);
watchQuery(query);
identity.setKickReason(query.value(15).toString());
identity.setPartReason(query.value(16).toString());
identity.setQuitReason(query.value(17).toString());
-#ifdef HAVE_SSL
identity.setSslCert(query.value(18).toByteArray());
identity.setSslKey(query.value(19).toByteArray());
-#endif
nickQuery.bindValue(":identityid", identity.id().toInt());
QList<QString> nicks;
#include "sslserver.h"
-#ifdef HAVE_SSL
-# include <QSslSocket>
-#endif
-
#include <QDateTime>
+#include <QSslSocket>
#include "core.h"
#include "quassel.h"
-#ifdef HAVE_SSL
-
SslServer::SslServer(QObject* parent)
: QTcpServer(parent)
{
_metricsServer->setCertificateExpires(_certificateExpires);
}
}
-
-#endif // HAVE_SSL
#pragma once
-#ifdef HAVE_SSL
+#include <QFile>
+#include <QLinkedList>
+#include <QSslCertificate>
+#include <QSslKey>
+#include <QTcpServer>
-# include <QFile>
-# include <QLinkedList>
-# include <QSslCertificate>
-# include <QSslKey>
-# include <QTcpServer>
-
-# include "metricsserver.h"
+#include "metricsserver.h"
class SslServer : public QTcpServer
{
QDateTime _certificateExpires;
};
-
-#endif // HAVE_SSL
#include "resourcetreedlg.h"
#include "settingsdlg.h"
#include "settingspagedlg.h"
+#include "sslinfodlg.h"
#include "statusnotifieritem.h"
#include "toolbaractionprovider.h"
#include "topicwidget.h"
# include "snorenotificationbackend.h"
#endif
-#ifdef HAVE_SSL
-# include "sslinfodlg.h"
-#endif
-
#ifdef HAVE_NOTIFICATION_CENTER
# include "osxnotificationbackend.h"
#endif
# include "dockmanagernotificationbackend.h"
#endif
-#include <settingspages/corehighlightsettingspage.h>
-
#include "settingspages/aliasessettingspage.h"
#include "settingspages/appearancesettingspage.h"
#include "settingspages/backlogsettingspage.h"
#include "settingspages/connectionsettingspage.h"
#include "settingspages/coreaccountsettingspage.h"
#include "settingspages/coreconnectionsettingspage.h"
+#include "settingspages/corehighlightsettingspage.h"
#include "settingspages/dccsettingspage.h"
#include "settingspages/highlightsettingspage.h"
#include "settingspages/identitiessettingspage.h"
connect(Client::coreConnection(), &CoreConnection::userAuthenticationRequired, this, &MainWin::userAuthenticationRequired);
connect(Client::coreConnection(), &CoreConnection::handleNoSslInClient, this, &MainWin::handleNoSslInClient);
connect(Client::coreConnection(), &CoreConnection::handleNoSslInCore, this, &MainWin::handleNoSslInCore);
-#ifdef HAVE_SSL
connect(Client::coreConnection(), &CoreConnection::handleSslErrors, this, &MainWin::handleSslErrors);
-#endif
// Setup Dock Areas
setDockNestingEnabled(true);
*accepted = (box.exec() == QMessageBox::Ignore);
}
-#ifdef HAVE_SSL
-
void MainWin::handleSslErrors(const QSslSocket* socket, bool* accepted, bool* permanently)
{
QString errorString = "<ul>";
}
}
-#endif /* HAVE_SSL */
-
void MainWin::handleCoreConnectionError(const QString& error)
{
QMessageBox::critical(this, tr("Core Connection Error"), error, QMessageBox::Ok);
void userAuthenticationRequired(CoreAccount*, bool* valid, const QString& errorMessage);
void handleNoSslInClient(bool* accepted);
void handleNoSslInCore(bool* accepted);
-#ifdef HAVE_SSL
void handleSslErrors(const QSslSocket* socket, bool* accepted, bool* permanently);
-#endif
void onConfigureNetworksTriggered();
void onConfigureViewsTriggered();
connect(Client::instance(), &Client::identityRemoved, this, &IdentitiesSettingsPage::clientIdentityRemoved);
connect(ui.identityEditor, &IdentityEditWidget::widgetHasChanged, this, &IdentitiesSettingsPage::widgetHasChanged);
-#ifdef HAVE_SSL
connect(ui.identityEditor, &IdentityEditWidget::requestEditSsl, this, &IdentitiesSettingsPage::continueUnsecured);
-#endif
currentId = 0;
}
{
setEnabled(connected);
if (connected) {
-#ifdef HAVE_SSL
if (Client::signalProxy()->isSecure()) {
ui.identityEditor->setSslState(IdentityEditWidget::AllowSsl);
_editSsl = true;
ui.identityEditor->setSslState(IdentityEditWidget::UnsecureSsl);
_editSsl = false;
}
-#else
- ui.identityEditor->setSslState(IdentityEditWidget::NoSsl);
-#endif
load();
}
else {
}
}
-#ifdef HAVE_SSL
void IdentitiesSettingsPage::continueUnsecured()
{
_editSsl = true;
ui.identityEditor->setSslState(IdentityEditWidget::AllowSsl);
}
-#endif
-
void IdentitiesSettingsPage::save()
{
setEnabled(false);
if (currentId != 0) {
changedIdentities.removeAll(currentId);
CertIdentity temp(currentId, this);
-#ifdef HAVE_SSL
// we need to set the cert and key manually, as they aren't synced
CertIdentity* old = identities[currentId];
temp.setSslKey(old->sslKey());
temp.setSslCert(old->sslCert());
-#endif
ui.identityEditor->saveToIdentity(&temp);
temp.setIdentityName(identities[currentId]->identityName());
if (temp != *Client::identity(currentId) || temp.isDirty())
void IdentitiesSettingsPage::clientIdentityCreated(IdentityId id)
{
auto* identity = new CertIdentity(*Client::identity(id), this);
-#ifdef HAVE_SSL
identity->enableEditSsl(_editSsl);
-#endif
insertIdentity(identity);
-#ifdef HAVE_SSL
connect(identity, &CertIdentity::sslSettingsUpdated, this, &IdentitiesSettingsPage::clientIdentityUpdated);
-#endif
connect(Client::identity(id), &SyncableObject::updatedRemotely, this, &IdentitiesSettingsPage::clientIdentityUpdated);
}
}
id = -id.toInt();
auto* newId = new CertIdentity(id, this);
-#ifdef HAVE_SSL
newId->enableEditSsl(_editSsl);
-#endif
if (dlg.duplicateId() != 0) {
// duplicate
newId->copyFrom(*identities[dlg.duplicateId()]);
}
connect(cid, &SyncableObject::updatedRemotely, this, &SaveIdentitiesDlg::clientEvent);
Client::updateIdentity(id->id(), id->toVariantMap());
-#ifdef HAVE_SSL
id->requestUpdateSslSettings();
-#endif
}
foreach (IdentityId id, toRemove) {
Client::removeIdentity(id);
void on_deleteIdentity_clicked();
void on_renameIdentity_clicked();
-#ifdef HAVE_SSL
void continueUnsecured();
-#endif
void widgetHasChanged();
void setWidgetStates();
void removeIdentity(Identity* identity);
void renameIdentity(IdentityId id, const QString& newName);
-#ifdef HAVE_SSL
QSslKey keyByFilename(const QString& filename);
void showKeyState(const QSslKey& key);
QSslCertificate certByFilename(const QString& filename);
void showCertState(const QSslCertificate& cert);
-#endif
bool testHasChanged();
};
ui.detachAwayEnabled->setVisible(!Client::internalCore());
-#ifdef HAVE_SSL
ui.sslKeyGroupBox->setAcceptDrops(true);
ui.sslKeyGroupBox->installEventFilter(this);
ui.sslCertGroupBox->setAcceptDrops(true);
ui.sslCertGroupBox->installEventFilter(this);
-#endif
if (Client::isCoreFeatureEnabled(Quassel::Feature::AwayFormatTimestamp)) {
// Core allows formatting %%timestamp%% messages in away strings. Update tooltips.
ui.kickReason->setText(id->kickReason());
ui.partReason->setText(id->partReason());
ui.quitReason->setText(id->quitReason());
-#ifdef HAVE_SSL
showKeyState(id->sslKey());
showCertState(id->sslCert());
-#endif
}
void IdentityEditWidget::saveToIdentity(CertIdentity* id)
id->setKickReason(ui.kickReason->text().remove(linebreaks));
id->setPartReason(ui.partReason->text().remove(linebreaks));
id->setQuitReason(ui.quitReason->text().remove(linebreaks));
-#ifdef HAVE_SSL
id->setSslKey(
QSslKey(ui.keyTypeLabel->property("sslKey").toByteArray(), (QSsl::KeyAlgorithm)(ui.keyTypeLabel->property("sslKeyType").toInt())));
id->setSslCert(QSslCertificate(ui.certOrgLabel->property("sslCert").toByteArray()));
-#endif
}
void IdentityEditWidget::on_addNick_clicked()
}
}
-#ifdef HAVE_SSL
bool IdentityEditWidget::eventFilter(QObject* watched, QEvent* event)
{
bool isCert = (watched == ui.sslCertGroupBox);
}
ui.certOrgLabel->setProperty("sslCert", cert.toPem());
}
-
-#endif // HAVE_SSL
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#ifndef IDENTITYEDITWIDGET_H
-#define IDENTITYEDITWIDGET_H
+#pragma once
-#include "ui_identityeditwidget.h"
-#include "ui_nickeditdlg.h"
-
-#ifdef HAVE_SSL
-# include <QSslCertificate>
-# include <QSslKey>
-#endif
+#include <QSslCertificate>
+#include <QSslKey>
#include "clientidentity.h"
+#include "ui_identityeditwidget.h"
+#include "ui_nickeditdlg.h"
+
class IdentityEditWidget : public QWidget
{
Q_OBJECT
void showAdvanced(bool advanced);
protected:
-#ifdef HAVE_SSL
bool eventFilter(QObject* watched, QEvent* event) override;
-#endif
signals:
void requestEditSsl();
void on_nickUp_clicked();
void on_nickDown_clicked();
-#ifdef HAVE_SSL
void on_clearOrLoadKeyButton_clicked();
void on_clearOrLoadCertButton_clicked();
-#endif
void setWidgetStates();
-#ifdef HAVE_SSL
void sslDragEnterEvent(QDragEnterEvent* event);
void sslDropEvent(QDropEvent* event, bool isCert);
-#endif
private:
Ui::IdentityEditWidget ui;
bool _editSsl;
-#ifdef HAVE_SSL
QSslKey keyByFilename(const QString& filename);
void showKeyState(const QSslKey& key);
QSslCertificate certByFilename(const QString& filename);
void showCertState(const QSslCertificate& cert);
-#endif
bool testHasChanged();
};
QString oldNick;
QStringList existing;
};
-
-#endif // IDENTITYEDITWIDGET_H
ui.sasl->hide();
if (!Client::isCoreFeatureEnabled(Quassel::Feature::SaslExternal))
ui.saslExtInfo->hide();
-#ifndef HAVE_SSL
- ui.saslExtInfo->hide();
-#endif
// set up icons
ui.renameNetwork->setIcon(icon::get("edit-rename"));
"modify message rate limits.")));
}
-#ifdef HAVE_SSL
// Hide the SASL EXTERNAL notice until a network's shown. Stops it from showing while loading
// backlog from the core.
sslUpdated();
-#endif
// Reset network capability status in case no valid networks get selected (a rare situation)
resetNetworkCapStates();
if (id != 0) {
NetworkInfo info = networkInfos[id];
-#ifdef HAVE_SSL
// this is only needed when the core supports SASL EXTERNAL
if (Client::isCoreFeatureEnabled(Quassel::Feature::SaslExternal)) {
if (_cid) {
_cid->enableEditSsl(true);
connect(_cid, &CertIdentity::sslSettingsUpdated, this, &NetworksSettingsPage::sslUpdated);
}
-#endif
ui.identityList->setCurrentIndex(ui.identityList->findData(info.identity.toInt()));
ui.serverList->clear();
}
else {
// just clear widgets
-#ifdef HAVE_SSL
if (_cid) {
disconnect(_cid, &CertIdentity::sslSettingsUpdated, this, &NetworksSettingsPage::sslUpdated);
delete _cid;
}
-#endif
ui.identityList->setCurrentIndex(-1);
ui.serverList->clear();
ui.performEdit->clear();
}
}
-#ifdef HAVE_SSL
void NetworksSettingsPage::sslUpdated()
{
if (_cid && !_cid->sslKey().isNull()) {
ui.saslExtInfo->setHidden(true);
}
}
-#endif
/*** Network list ***/
*/
void clientNetworkCapsUpdated();
-#ifdef HAVE_SSL
void sslUpdated();
-#endif
void on_networkList_itemSelectionChanged();
void on_addNetwork_clicked();
NetworkId currentId;
QHash<NetworkId, NetworkInfo> networkInfos;
bool _ignoreWidgetChanges{false};
-#ifdef HAVE_SSL
CertIdentity* _cid{nullptr};
-#endif
QIcon connectedIcon, connectingIcon, disconnectedIcon;