Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
clientauthhandler.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 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 #ifndef CLIENTAUTHHANDLER_H
22 #define CLIENTAUTHHANDLER_H
23 
24 #include "compressor.h"
25 #include "authhandler.h"
26 #include "coreaccount.h"
27 
28 class QSslSocket;
29 
30 class RemotePeer;
31 
33 {
34  Q_OBJECT
35 
36 public:
37  ClientAuthHandler(CoreAccount account, QObject *parent = 0);
38 
39 public slots:
40  void connectToCore();
41 
42  void login(const QString &previousError = QString());
43  void login(const QString &user, const QString &password, bool remember);
44  void setupCore(const Protocol::SetupData &setupData);
45 
46 signals:
47  void statusMessage(const QString &message);
48  void errorMessage(const QString &message);
49  void errorPopup(const QString &message);
50  void transferProgress(int current, int max);
51 
52  void requestDisconnect(const QString &errorString = QString(), bool wantReconnect = false);
53 
54  void connectionReady();
55  void loginSuccessful(const CoreAccount &account);
56  void handshakeComplete(RemotePeer *peer, const Protocol::SessionState &sessionState);
57 
58  // These signals MUST be handled synchronously!
59  void userAuthenticationRequired(CoreAccount *account, bool *valid, const QString &errorMessage = QString());
60  void handleNoSslInClient(bool *accepted);
61  void handleNoSslInCore(bool *accepted);
62 #ifdef HAVE_SSL
63  void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
64 #endif
65 
66  void encrypted(bool isEncrypted = true);
67  void startCoreSetup(const QVariantList &backendInfo);
68  void coreSetupSuccessful();
69  void coreSetupFailed(const QString &error);
70 
71 private:
72  using AuthHandler::handle;
73 
74  void handle(const Protocol::ClientDenied &msg);
75  void handle(const Protocol::ClientRegistered &msg);
76  void handle(const Protocol::SetupFailed &msg);
77  void handle(const Protocol::SetupDone &msg);
78  void handle(const Protocol::LoginFailed &msg);
79  void handle(const Protocol::LoginSuccess &msg);
80  void handle(const Protocol::SessionState &msg);
81 
82  void setPeer(RemotePeer *peer);
83  void checkAndEnableSsl(bool coreSupportsSsl);
84  void startRegistration();
85 
86 private slots:
87  void onSocketConnected();
88  void onSocketStateChanged(QAbstractSocket::SocketState state);
89  void onSocketError(QAbstractSocket::SocketError);
90  void onSocketDisconnected();
91  void onReadyRead();
92 
93 #ifdef HAVE_SSL
94  void onSslSocketEncrypted();
95  void onSslErrors();
96 #endif
97 
98  void onProtocolVersionMismatch(int actual, int expected);
99 
100  void onConnectionReady();
101 
102 private:
105  QVariantList _backendInfo;
107  bool _probing;
108  bool _legacy;
110 };
111 
112 #endif