/***************************************************************************
- * Copyright (C) 2005-2018 by the Quassel Project *
+ * Copyright (C) 2005-2022 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
+#include "sessionthread.h"
+
#include <QPointer>
#include <QTimer>
#include "coresession.h"
#include "internalpeer.h"
#include "remotepeer.h"
-#include "sessionthread.h"
#include "signalproxy.h"
namespace {
: _userId{userId}
, _restoreState{restoreState}
, _strictIdentEnabled{strictIdentEnabled}
- {
- }
+ {}
public slots:
void initialize()
{
_session = new CoreSession{_userId, _restoreState, _strictIdentEnabled, this};
connect(_session, &QObject::destroyed, QThread::currentThread(), &QThread::quit);
- connect(_session, SIGNAL(sessionState(Protocol::SessionState)), Core::instance(), SIGNAL(sessionState(Protocol::SessionState)));
+ connect(_session, &CoreSession::sessionStateReceived, Core::instance(), &Core::sessionStateReceived);
emit initialized();
}
}
}
- void addClient(Peer *peer)
+ void addClient(Peer* peer)
{
if (!_session) {
qWarning() << "Session not initialized!";
QPointer<CoreSession> _session;
};
-} // anon
+} // namespace
-SessionThread::SessionThread(UserId uid, bool restoreState, bool strictIdentEnabled, QObject *parent)
+SessionThread::SessionThread(UserId uid, bool restoreState, bool strictIdentEnabled, QObject* parent)
: QObject(parent)
{
auto worker = new Worker(uid, restoreState, strictIdentEnabled);
QTimer::singleShot(0, &_sessionThread, SLOT(start()));
}
-
SessionThread::~SessionThread()
{
// shut down thread gracefully
_sessionThread.wait(30000);
}
-
void SessionThread::shutdown()
{
emit shutdownSession();
}
-
void SessionThread::onSessionInitialized()
{
_sessionInitialized = true;
- for (auto &&peer : _clientQueue) {
+ for (auto&& peer : _clientQueue) {
peer->setParent(nullptr);
peer->moveToThread(&_sessionThread);
emit addClientToWorker(peer);
_clientQueue.clear();
}
-
void SessionThread::onSessionDestroyed()
{
emit shutdownComplete(this);
}
-void SessionThread::addClient(Peer *peer)
+void SessionThread::addClient(Peer* peer)
{
if (_sessionInitialized) {
peer->setParent(nullptr);