internal refactoring: ripping identity editor and identitory settingspage apart
[quassel.git] / src / qtui / settingspages / identityeditwidget.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 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  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, 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
34 class IdentityEditWidget : public QWidget {
35   Q_OBJECT
36
37 public:
38   IdentityEditWidget(QWidget *parent = 0);
39
40   enum SslState {
41     NoSsl,
42     UnsecureSsl,
43     AllowSsl
44   };
45
46   void displayIdentity(CertIdentity *id, CertIdentity *saveId = 0);
47   void saveToIdentity(CertIdentity *id);
48
49 public slots:
50   void setSslState(SslState state);
51
52 protected:
53 #ifdef HAVE_SSL
54   virtual bool eventFilter(QObject *watched, QEvent *event);
55 #endif
56
57 signals:
58   void requestEditSsl();
59   void widgetHasChanged();
60
61 private slots:
62   void on_addNick_clicked();
63   void on_deleteNick_clicked();
64   void on_renameNick_clicked();
65   void on_nickUp_clicked();
66   void on_nickDown_clicked();
67
68 #ifdef HAVE_SSL
69   void on_clearOrLoadKeyButton_clicked();
70   void on_clearOrLoadCertButton_clicked();
71 #endif
72   void setWidgetStates();
73
74 #ifdef HAVE_SSL
75   void sslDragEnterEvent(QDragEnterEvent *event);
76   void sslDropEvent(QDropEvent *event, bool isCert);
77 #endif
78
79 private:
80   Ui::IdentityEditWidget ui;
81   bool _editSsl;
82
83 #ifdef HAVE_SSL
84   QSslKey keyByFilename(const QString &filename);
85   void showKeyState(const QSslKey &key);
86   QSslCertificate certByFilename(const QString &filename);
87   void showCertState(const QSslCertificate &cert);
88 #endif
89
90   bool testHasChanged();
91 };
92
93 class NickEditDlg : public QDialog {
94   Q_OBJECT
95
96 public:
97   NickEditDlg(const QString &oldnick, const QStringList &existing = QStringList(), QWidget *parent = 0);
98
99   QString nick() const;
100
101 private slots:
102   void on_nickEdit_textChanged(const QString &);
103
104 private:
105   Ui::NickEditDlg ui;
106
107   QString oldNick;
108   QStringList existing;
109
110 };
111
112 #endif //IDENTITYEDITWIDGET_H