1/***************************************************************************
2 * Copyright (C) 2005-2014 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 IDENTITYEDITWIDGET_H
22#define IDENTITYEDITWIDGET_H
23
24#include "ui_identityeditwidget.h"
25#include "ui_nickeditdlg.h"
26
27#ifdef HAVE_SSL
28#include <QSslCertificate>
29#include <QSslKey>
30#endif
31
32#include "clientidentity.h"
33
34class IdentityEditWidget : public QWidget
35{
36 Q_OBJECT
37
38public:
39 IdentityEditWidget(QWidget *parent = 0);
40
41 enum SslState {
42 NoSsl,
43 UnsecureSsl,
44 AllowSsl
45 };
46
47 void displayIdentity(CertIdentity *id, CertIdentity *saveId = 0);
48 void saveToIdentity(CertIdentity *id);
49
50public slots:
51 void setSslState(SslState state);
52 void showAdvanced(bool advanced);
53
54protected:
55#ifdef HAVE_SSL
56 virtual bool eventFilter(QObject *watched, QEvent *event);
57#endif
58
59signals:
60 void requestEditSsl();
61 void widgetHasChanged();
62
63private slots:
64 void on_addNick_clicked();
65 void on_deleteNick_clicked();
66 void on_renameNick_clicked();
67 void on_nickUp_clicked();
68 void on_nickDown_clicked();
69
70#ifdef HAVE_SSL
71 void on_clearOrLoadKeyButton_clicked();
72 void on_clearOrLoadCertButton_clicked();
73#endif
74 void setWidgetStates();
75
76#ifdef HAVE_SSL
77 void sslDragEnterEvent(QDragEnterEvent *event);
78 void sslDropEvent(QDropEvent *event, bool isCert);
79#endif
80
81private:
82 Ui::IdentityEditWidget ui;
83 bool _editSsl;
84
85#ifdef HAVE_SSL
86 QSslKey keyByFilename(const QString &filename);
87 void showKeyState(const QSslKey &key);
88 QSslCertificate certByFilename(const QString &filename);
89 void showCertState(const QSslCertificate &cert);
90#endif
91
92 bool testHasChanged();
93};
94
95
96class NickEditDlg : public QDialog
97{
98 Q_OBJECT
99
100public:
101 NickEditDlg(const QString &oldnick, const QStringList &existing = QStringList(), QWidget *parent = 0);
102
103 QString nick() const;
104
105private slots:
106 void on_nickEdit_textChanged(const QString &);
107
108private:
109 Ui::NickEditDlg ui;
110
111 QString oldNick;
112 QStringList existing;
113};
114
115
116#endif //IDENTITYEDITWIDGET_H
117