putting it all together: core is now capable to connect to ircservers using a proxy...
[quassel.git] / src / qtui / settingspages / identitiessettingspage.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) any later version.                                   *
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 IDENTITIESSETTINGSPAGE_H
22 #define IDENTITIESSETTINGSPAGE_H
23
24 #include "clientidentity.h"
25 #include "settingspage.h"
26
27 #include "ui_identitiessettingspage.h"
28 #include "ui_createidentitydlg.h"
29 #include "ui_saveidentitiesdlg.h"
30 #include "ui_nickeditdlg.h"
31
32 #include <QSslCertificate>
33 #include <QSslKey>
34
35 class QAbstractItemModel;
36
37 class IdentitiesSettingsPage : public SettingsPage {
38   Q_OBJECT
39
40 public:
41   IdentitiesSettingsPage(QWidget *parent = 0);
42
43   bool aboutToSave();
44
45 public slots:
46   void save();
47   void load();
48
49 protected:
50   virtual bool eventFilter(QObject *watched, QEvent *event);
51
52 private slots:
53   void coreConnectionStateChanged(bool);
54   void clientIdentityCreated(IdentityId);
55   void clientIdentityUpdated();
56   void clientIdentityRemoved(IdentityId);
57
58   void on_identityList_currentIndexChanged(int index);
59
60   void on_addIdentity_clicked();
61   void on_deleteIdentity_clicked();
62   void on_renameIdentity_clicked();
63
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   void on_continueUnsecured_clicked();
71   void on_clearOrLoadKeyButton_clicked();
72   void on_clearOrLoadCertButton_clicked();
73   void widgetHasChanged();
74   void setWidgetStates();
75
76   void sslDragEnterEvent(QDragEnterEvent *event);
77   void sslDropEvent(QDropEvent *event, bool isCert);
78
79 private:
80   Ui::IdentitiesSettingsPage ui;
81
82   QHash<IdentityId, CertIdentity *> identities;
83   IdentityId currentId;
84
85   QList<IdentityId> changedIdentities;  // for setting the widget changed state
86   QList<IdentityId> deletedIdentities;
87
88   bool _editSsl;
89
90   void insertIdentity(CertIdentity *identity);
91   void removeIdentity(Identity *identity);
92   void renameIdentity(IdentityId id, const QString &newName);
93   void displayIdentity(CertIdentity *, bool dontsave = false);
94   void saveToIdentity(CertIdentity *);
95
96   QSslKey keyByFilename(const QString &filename);
97   void showKeyState(const QSslKey &key);
98   QSslCertificate certByFilename(const QString &filename);
99   void showCertState(const QSslCertificate &cert);
100
101   bool testHasChanged();
102 };
103
104 class CreateIdentityDlg : public QDialog {
105   Q_OBJECT
106
107 public:
108   CreateIdentityDlg(QAbstractItemModel *model, QWidget *parent = 0);
109
110   QString identityName() const;
111   IdentityId duplicateId() const;
112
113 private slots:
114   void on_identityName_textChanged(const QString &text);
115
116 private:
117   Ui::CreateIdentityDlg ui;
118 };
119
120 class SaveIdentitiesDlg : public QDialog {
121   Q_OBJECT
122
123 public:
124   SaveIdentitiesDlg(const QList<CertIdentity *> &toCreate, const QList<CertIdentity *> &toUpdate, const QList<IdentityId> &toRemove, QWidget *parent = 0);
125
126 private slots:
127   void clientEvent();
128
129 private:
130   Ui::SaveIdentitiesDlg ui;
131
132   int numevents, rcvevents;
133 };
134
135 class NickEditDlg : public QDialog {
136   Q_OBJECT
137
138 public:
139   NickEditDlg(const QString &oldnick, const QStringList &existing = QStringList(), QWidget *parent = 0);
140
141   QString nick() const;
142
143 private slots:
144   void on_nickEdit_textChanged(const QString &);
145
146 private:
147   Ui::NickEditDlg ui;
148
149   QString oldNick;
150   QStringList existing;
151
152 };
153
154 #endif