/***************************************************************************
- * Copyright (C) 2005-08 by the Quassel IRC Team *
+ * Copyright (C) 2005-2020 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#ifndef _SESSIONTHREAD_H_
-#define _SESSIONTHREAD_H_
+#pragma once
+
+#include <memory>
-#include <QMutex>
#include <QThread>
#include "types.h"
class CoreSession;
-class QIODevice;
-
-class SessionThread : public QThread {
- Q_OBJECT
+class Peer;
+class InternalPeer;
+class RemotePeer;
- public:
- SessionThread(UserId user, bool restoreState, QObject *parent = 0);
- ~SessionThread();
+class SessionThread : public QObject
+{
+ Q_OBJECT
- void run();
+public:
+ SessionThread(UserId user, bool restoreState, bool strictIdentEnabled, QObject* parent = nullptr);
+ ~SessionThread() override;
- CoreSession *session();
- UserId user();
-
- public slots:
- void addClient(QIODevice *socket);
+public slots:
+ void addClient(Peer* peer);
+ void shutdown();
- private slots:
- void setSessionInitialized();
+private slots:
+ void onSessionInitialized();
+ void onSessionDestroyed();
- signals:
+signals:
void initialized();
- void shutdown();
+ void shutdownSession();
+ void shutdownComplete(SessionThread*);
- private:
- CoreSession *_session;
- UserId _user;
- QList<QIODevice *> clientQueue;
- bool _sessionInitialized;
- bool _restoreState;
+ void addClientToWorker(Peer* peer);
- bool isSessionInitialized();
- void addClientToSession(QIODevice *socket);
-};
+private:
+ QThread _sessionThread;
+ bool _sessionInitialized{false};
-#endif
+ std::vector<Peer*> _clientQueue;
+};