cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / core / coreauthhandler.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2022 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #pragma once
22
23 #include "authhandler.h"
24 #include "metricsserver.h"
25 #include "peerfactory.h"
26 #include "proxyline.h"
27 #include "remotepeer.h"
28 #include "types.h"
29
30 class CoreAuthHandler : public AuthHandler
31 {
32     Q_OBJECT
33
34 public:
35     CoreAuthHandler(QSslSocket* socket, QObject* parent = nullptr);
36
37     QHostAddress hostAddress() const;
38     bool isLocal() const override;
39
40 signals:
41     void handshakeComplete(RemotePeer* peer, UserId uid);
42
43 private:
44     using AuthHandler::handle;
45
46     void handle(const Protocol::RegisterClient& msg) override;
47     void handle(const Protocol::SetupData& msg) override;
48     void handle(const Protocol::Login& msg) override;
49
50     void setPeer(RemotePeer* peer);
51     void startSsl();
52
53     bool checkClientRegistered();
54
55 private slots:
56     void onReadyRead();
57
58     void onSslErrors();
59
60     // only in legacy mode
61     void onProtocolVersionMismatch(int actual, int expected);
62
63 private:
64     RemotePeer* _peer;
65     MetricsServer* _metricsServer;
66
67     bool _proxyReceived;
68     ProxyLine _proxyLine;
69     bool _useProxyLine;
70     bool _magicReceived;
71     bool _legacy;
72     bool _clientRegistered;
73     quint8 _connectionFeatures;
74     QVector<PeerFactory::ProtoDescriptor> _supportedProtos;
75 };