+signals:
+ void initialized();
+
+private:
+ UserId _userId;
+ bool _restoreState;
+ bool _strictIdentEnabled; ///< Whether or not strict ident mode is enabled, locking users' idents to Quassel username
+ QPointer<CoreSession> _session;
+};
+
+} // anon
+
+SessionThread::SessionThread(UserId uid, bool restoreState, bool strictIdentEnabled, QObject *parent)
+ : QObject(parent)
+{
+ auto worker = new Worker(uid, restoreState, strictIdentEnabled);
+ worker->moveToThread(&_sessionThread);
+ connect(&_sessionThread, SIGNAL(started()), worker, SLOT(initialize()));
+ connect(&_sessionThread, SIGNAL(finished()), worker, SLOT(deleteLater()));
+ connect(worker, SIGNAL(initialized()), this, SLOT(onSessionInitialized()));
+ connect(worker, SIGNAL(destroyed()), this, SLOT(onSessionDestroyed()));
+
+ connect(this, SIGNAL(addClientToWorker(Peer*)), worker, SLOT(addClient(Peer*)));
+ connect(this, SIGNAL(shutdownSession()), worker, SLOT(shutdown()));
+
+ // Defer thread start through the event loop, so the SessionThread instance is fully constructed before
+ QTimer::singleShot(0, &_sessionThread, SLOT(start()));