X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fidentserver.h;h=f9f26a7732b3d0a89568641f9e25f839f93ec930;hb=db00831bca59a012242d1ad5fac52a20c6cd2956;hp=3c0fd2a9a7e6a96ac91fe09403f1a907f59fd9e4;hpb=afc90943c558eaca765530fa90ff8b656dc04a99;p=quassel.git diff --git a/src/core/identserver.h b/src/core/identserver.h index 3c0fd2a9..f9f26a77 100644 --- a/src/core/identserver.h +++ b/src/core/identserver.h @@ -20,47 +20,64 @@ #pragma once +#include + +#include +#include +#include +#include #include #include #include "coreidentity.h" -struct Request { - QTcpSocket *socket; +struct Request +{ + QPointer socket; uint16_t localPort; QString query; qint64 transactionId; qint64 requestId; - friend bool operator==(const Request &a, const Request &b); + friend bool operator==(const Request& a, const Request& b); - void respondSuccess(const QString &user); - void respondError(const QString &error); + void respondSuccess(const QString& user); + void respondError(const QString& error); }; -class IdentServer : public QObject { -Q_OBJECT +class IdentServer : public QObject +{ + Q_OBJECT + public: - IdentServer(bool strict, QObject *parent); - ~IdentServer() override; + IdentServer(QObject* parent = nullptr); bool startListening(); - void stopListening(const QString &msg); + void stopListening(const QString& msg); qint64 addWaitingSocket(); + public slots: - bool addSocket(const CoreIdentity *identity, const QHostAddress &localAddress, quint16 localPort, const QHostAddress &peerAddress, quint16 peerPort, qint64 socketId); - bool removeSocket(const CoreIdentity *identity, const QHostAddress &localAddress, quint16 localPort, const QHostAddress &peerAddress, quint16 peerPort, qint64 socketId); + void addSocket(const CoreIdentity* identity, + const QHostAddress& localAddress, + quint16 localPort, + const QHostAddress& peerAddress, + quint16 peerPort, + qint64 socketId); + void removeSocket(const CoreIdentity* identity, + const QHostAddress& localAddress, + quint16 localPort, + const QHostAddress& peerAddress, + quint16 peerPort, + qint64 socketId); private slots: void incomingConnection(); void respond(); private: - bool responseAvailable(Request request); + bool responseAvailable(Request request) const; - QString sysIdentForIdentity(const CoreIdentity *identity) const; - - qint64 lowestSocketId(); + qint64 lowestSocketId() const; void processWaiting(qint64 socketId); @@ -68,11 +85,9 @@ private: QTcpServer _server, _v6server; - bool _strict; - QHash _connections; std::list _requestQueue; std::list _waiting; - qint64 _socketId; - qint64 _requestId; + qint64 _socketId{0}; + qint64 _requestId{0}; };