#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
Core::Core()
: Singleton<Core>{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);
Core::~Core()
{
- saveState();
qDeleteAll(_connectingClients);
qDeleteAll(_sessions);
syncStorage();
{
_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;
}
+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()
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));
}