X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcore%2Fcore.cpp;h=556eec67ae0539168fe4045c28a9de2cd4368fa6;hb=6eefdfc697067d184a589fc8a231b16316c09106;hp=2634dd2852fb8e04ba240601f6579b7f095d042b;hpb=ddfb1d2574c4bffd180361a80df9b1cd584bb040;p=quassel.git diff --git a/src/core/core.cpp b/src/core/core.cpp index 2634dd28..556eec67 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -36,9 +36,8 @@ #include "types.h" #include "util.h" -// Currently building with LDAP bindings is optional. #ifdef HAVE_LDAP -#include "ldapauthenticator.h" +# include "ldapauthenticator.h" #endif // migration related @@ -71,6 +70,8 @@ public: Core::Core() : Singleton{this} { + Q_INIT_RESOURCE(sql); + // Parent all QObject-derived attributes, so when the Core instance gets moved into another // thread, they get moved with it _server.setParent(this); @@ -91,10 +92,6 @@ void Core::init() { _startTime = QDateTime::currentDateTime().toUTC(); // for uptime :) - if (Quassel::runMode() == Quassel::RunMode::CoreOnly) { - Quassel::loadTranslation(QLocale::system()); - } - // check settings version // so far, we only have 1 CoreSettings s; @@ -224,12 +221,12 @@ void Core::init() return false; }); - connect(&_storageSyncTimer, SIGNAL(timeout()), this, SLOT(syncStorage())); + connect(&_storageSyncTimer, &QTimer::timeout, this, &Core::syncStorage); _storageSyncTimer.start(10 * 60 * 1000); // 10 minutes } - connect(&_server, SIGNAL(newConnection()), this, SLOT(incomingConnection())); - connect(&_v6server, SIGNAL(newConnection()), this, SLOT(incomingConnection())); + connect(&_server, &QTcpServer::newConnection, this, &Core::incomingConnection); + connect(&_v6server, &QTcpServer::newConnection, this, &Core::incomingConnection); if (!startListening()) { throw ExitException{EXIT_FAILURE, tr("Cannot open port for listening!")}; @@ -276,7 +273,7 @@ void Core::shutdown() } for (auto &&session : _sessions) { - connect(session, SIGNAL(shutdownComplete(SessionThread*)), this, SLOT(onSessionShutdown(SessionThread*))); + connect(session, &SessionThread::shutdownComplete, this, &Core::onSessionShutdown); session->shutdown(); } } @@ -446,7 +443,7 @@ bool Core::initStorage(const QString &backend, const QVariantMap &settings, return false; } - connect(storage.get(), SIGNAL(dbUpgradeInProgress(bool)), this, SIGNAL(dbUpgradeInProgress(bool))); + connect(storage.get(), &Storage::dbUpgradeInProgress, this, &Core::dbUpgradeInProgress); Storage::State storageState = storage->init(settings, environment, loadFromEnvironment); switch (storageState) { @@ -468,8 +465,8 @@ bool Core::initStorage(const QString &backend, const QVariantMap &settings, case Storage::IsReady: // delete all other backends _registeredStorageBackends.clear(); - connect(storage.get(), SIGNAL(bufferInfoUpdated(UserId, const BufferInfo &)), - this, SIGNAL(bufferInfoUpdated(UserId, const BufferInfo &))); + connect(storage.get(), &Storage::bufferInfoUpdated, + this, &Core::bufferInfoUpdated); break; } _storage = std::move(storage); @@ -580,7 +577,7 @@ bool Core::initAuthenticator(const QString &backend, const QVariantMap &settings bool Core::sslSupported() { #ifdef HAVE_SSL - SslServer *sslServer = qobject_cast(&instance()->_server); + auto *sslServer = qobject_cast(&instance()->_server); return sslServer && sslServer->isCertValid(); #else return false; @@ -591,10 +588,10 @@ bool Core::sslSupported() bool Core::reloadCerts() { #ifdef HAVE_SSL - SslServer *sslServerv4 = qobject_cast(&_server); + auto *sslServerv4 = qobject_cast(&_server); bool retv4 = sslServerv4->reloadCerts(); - SslServer *sslServerv6 = qobject_cast(&_v6server); + auto *sslServerv6 = qobject_cast(&_v6server); bool retv6 = sslServerv6->reloadCerts(); return retv4 && retv6; @@ -739,17 +736,17 @@ void Core::stopListening(const QString &reason) void Core::incomingConnection() { - QTcpServer *server = qobject_cast(sender()); + auto *server = qobject_cast(sender()); Q_ASSERT(server); while (server->hasPendingConnections()) { QTcpSocket *socket = server->nextPendingConnection(); - CoreAuthHandler *handler = new CoreAuthHandler(socket, this); + auto *handler = new CoreAuthHandler(socket, this); _connectingClients.insert(handler); - connect(handler, SIGNAL(disconnected()), SLOT(clientDisconnected())); - connect(handler, SIGNAL(socketError(QAbstractSocket::SocketError,QString)), SLOT(socketError(QAbstractSocket::SocketError,QString))); - connect(handler, SIGNAL(handshakeComplete(RemotePeer*,UserId)), SLOT(setupClientSession(RemotePeer*,UserId))); + connect(handler, &AuthHandler::disconnected, this, &Core::clientDisconnected); + connect(handler, &AuthHandler::socketError, this, &Core::socketError); + connect(handler, &CoreAuthHandler::handshakeComplete, this, &Core::setupClientSession); quInfo() << qPrintable(tr("Client connected from")) << qPrintable(socket->peerAddress().toString()); @@ -763,7 +760,7 @@ void Core::incomingConnection() // Potentially called during the initialization phase (before handing the connection off to the session) void Core::clientDisconnected() { - CoreAuthHandler *handler = qobject_cast(sender()); + auto *handler = qobject_cast(sender()); Q_ASSERT(handler); quInfo() << qPrintable(tr("Non-authed client disconnected:")) << qPrintable(handler->socket()->peerAddress().toString()); @@ -782,11 +779,11 @@ void Core::clientDisconnected() void Core::setupClientSession(RemotePeer *peer, UserId uid) { - CoreAuthHandler *handler = qobject_cast(sender()); + auto *handler = qobject_cast(sender()); Q_ASSERT(handler); // From now on everything is handled by the client session - disconnect(handler, 0, this, 0); + disconnect(handler, nullptr, this, nullptr); _connectingClients.remove(handler); handler->deleteLater(); @@ -802,7 +799,7 @@ void Core::setupClientSession(RemotePeer *peer, UserId uid) void Core::customEvent(QEvent *event) { if (event->type() == AddClientEventId) { - AddClientEvent *addClientEvent = static_cast(event); + auto *addClientEvent = static_cast(event); addClientHelper(addClientEvent->peer, addClientEvent->userId); return; } @@ -854,7 +851,7 @@ void Core::setupInternalClientSession(QPointer clientPeer) return; } - InternalPeer *corePeer = new InternalPeer(this); + auto *corePeer = new InternalPeer(this); corePeer->setPeer(clientPeer); clientPeer->setPeer(corePeer); @@ -1184,7 +1181,7 @@ std::unique_ptr Core::getMigrationReader(Storage *st if (!storage) return nullptr; - AbstractSqlStorage *sqlStorage = qobject_cast(storage); + auto *sqlStorage = qobject_cast(storage); if (!sqlStorage) { qDebug() << "Core::migrateDb(): only SQL based backends can be migrated!"; return nullptr; @@ -1199,7 +1196,7 @@ std::unique_ptr Core::getMigrationWriter(Storage *st if (!storage) return nullptr; - AbstractSqlStorage *sqlStorage = qobject_cast(storage); + auto *sqlStorage = qobject_cast(storage); if (!sqlStorage) { qDebug() << "Core::migrateDb(): only SQL based backends can be migrated!"; return nullptr;