X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.cpp;h=e1ea08320c4ca5b534c0fc86f9fc23cafa6da370;hp=7f69869a5c7d0dcf2a90a131d9a6372a99b2a618;hb=bad087a1b604c92c7c0bf3cf818b81d26e15c1c4;hpb=41b33277b11c69ae0138e8b463a4c695e9a80d14 diff --git a/src/core/core.cpp b/src/core/core.cpp index 7f69869a..e1ea0832 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 @@ -81,7 +80,6 @@ Core::Core() Core::~Core() { - saveState(); qDeleteAll(_connectingClients); qDeleteAll(_sessions); syncStorage(); @@ -92,10 +90,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; @@ -260,6 +254,39 @@ void Core::initAsync() } +void Core::shutdown() +{ + quInfo() << "Core shutting down..."; + + saveState(); + + for (auto &&client : _connectingClients) { + client->deleteLater(); + } + _connectingClients.clear(); + + if (_sessions.isEmpty()) { + emit shutdownComplete(); + return; + } + + for (auto &&session : _sessions) { + connect(session, SIGNAL(shutdownComplete(SessionThread*)), this, SLOT(onSessionShutdown(SessionThread*))); + session->shutdown(); + } +} + + +void Core::onSessionShutdown(SessionThread *session) +{ + _sessions.take(_sessions.key(session))->deleteLater(); + if (_sessions.isEmpty()) { + quInfo() << "Core shutdown complete!"; + emit shutdownComplete(); + } +} + + /*** Session Restore ***/ void Core::saveState() @@ -837,10 +864,7 @@ SessionThread *Core::sessionForUser(UserId uid, bool restore) if (_sessions.contains(uid)) return _sessions[uid]; - SessionThread *session = new SessionThread(uid, restore, strictIdentEnabled(), this); - _sessions[uid] = session; - session->start(); - return session; + return (_sessions[uid] = new SessionThread(uid, restore, strictIdentEnabled(), this)); }