ssl: Remove fallback code for missing SSL support
[quassel.git] / src / qtui / settingspages / identitiessettingspage.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2020 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 "clientidentity.h"
24 #include "identityeditwidget.h"
25 #include "settingspage.h"
26
27 #include "ui_createidentitydlg.h"
28 #include "ui_identitiessettingspage.h"
29 #include "ui_saveidentitiesdlg.h"
30
31 class QAbstractItemModel;
32
33 class IdentitiesSettingsPage : public SettingsPage
34 {
35     Q_OBJECT
36
37 public:
38     IdentitiesSettingsPage(QWidget* parent = nullptr);
39
40     inline bool needsCoreConnection() const override { return true; }
41
42     bool aboutToSave() override;
43
44 public slots:
45     void save() final override;
46     void load() final override;
47
48 private slots:
49     void coreConnectionStateChanged(bool);
50     void clientIdentityCreated(IdentityId);
51     void clientIdentityUpdated();
52     void clientIdentityRemoved(IdentityId);
53
54     void on_identityList_currentIndexChanged(int index);
55
56     void on_addIdentity_clicked();
57     void on_deleteIdentity_clicked();
58     void on_renameIdentity_clicked();
59
60     void continueUnsecured();
61     void widgetHasChanged();
62     void setWidgetStates();
63
64 private:
65     Ui::IdentitiesSettingsPage ui;
66
67     QHash<IdentityId, CertIdentity*> identities;
68     IdentityId currentId;
69
70     QList<IdentityId> changedIdentities;  // for setting the widget changed state
71     QList<IdentityId> deletedIdentities;
72
73     bool _editSsl{false};
74
75     void insertIdentity(CertIdentity* identity);
76     void removeIdentity(Identity* identity);
77     void renameIdentity(IdentityId id, const QString& newName);
78
79     QSslKey keyByFilename(const QString& filename);
80     void showKeyState(const QSslKey& key);
81     QSslCertificate certByFilename(const QString& filename);
82     void showCertState(const QSslCertificate& cert);
83
84     bool testHasChanged();
85 };
86
87 // ==============================
88 //  Various Dialogs
89 // ==============================
90 class CreateIdentityDlg : public QDialog
91 {
92     Q_OBJECT
93
94 public:
95     CreateIdentityDlg(QAbstractItemModel* model, QWidget* parent = nullptr);
96
97     QString identityName() const;
98     IdentityId duplicateId() const;
99
100 private slots:
101     void on_identityName_textChanged(const QString& text);
102
103 private:
104     Ui::CreateIdentityDlg ui;
105 };
106
107 class SaveIdentitiesDlg : public QDialog
108 {
109     Q_OBJECT
110
111 public:
112     SaveIdentitiesDlg(const QList<CertIdentity*>& toCreate,
113                       const QList<CertIdentity*>& toUpdate,
114                       const QList<IdentityId>& toRemove,
115                       QWidget* parent = nullptr);
116
117 private slots:
118     void clientEvent();
119
120 private:
121     Ui::SaveIdentitiesDlg ui;
122
123     int numevents, rcvevents;
124 };