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 NETWORKSSETTINGSPAGE_H
22#define NETWORKSSETTINGSPAGE_H
23
24#include <QPixmap>
25
26#include "network.h"
27#include "settingspage.h"
28#include "clientidentity.h"
29
30#include "ui_networkssettingspage.h"
31#include "ui_networkadddlg.h"
32#include "ui_networkeditdlg.h"
33#include "ui_servereditdlg.h"
34#include "ui_saveidentitiesdlg.h"
35
36class NetworksSettingsPage : public SettingsPage
37{
38 Q_OBJECT
39
40public:
41 NetworksSettingsPage(QWidget *parent = 0);
42
43 virtual inline bool needsCoreConnection() const { return true; }
44
45 bool aboutToSave();
46
47public slots:
48 void save();
49 void load();
50
51private slots:
52 void widgetHasChanged();
53 void setWidgetStates();
54 void coreConnectionStateChanged(bool);
55 void networkConnectionStateChanged(Network::ConnectionState state);
56 void networkConnectionError(const QString &msg);
57
58 void displayNetwork(NetworkId);
59 void setItemState(NetworkId, QListWidgetItem *item = 0);
60
61 void clientNetworkAdded(NetworkId);
62 void clientNetworkRemoved(NetworkId);
63 void clientNetworkUpdated();
64
65 void clientIdentityAdded(IdentityId);
66 void clientIdentityRemoved(IdentityId);
67 void clientIdentityUpdated();
68
69#ifdef HAVE_SSL
70 void sslUpdated();
71#endif
72
73 void on_networkList_itemSelectionChanged();
74 void on_addNetwork_clicked();
75 void on_deleteNetwork_clicked();
76 void on_renameNetwork_clicked();
77 void on_editIdentities_clicked();
78
79 // void on_connectNow_clicked();
80
81 void on_serverList_itemSelectionChanged();
82 void on_addServer_clicked();
83 void on_deleteServer_clicked();
84 void on_editServer_clicked();
85 void on_upServer_clicked();
86 void on_downServer_clicked();
87
88private:
89 Ui::NetworksSettingsPage ui;
90
91 NetworkId currentId;
92 QHash<NetworkId, NetworkInfo> networkInfos;
93 bool _ignoreWidgetChanges;
94#ifdef HAVE_SSL
95 CertIdentity *_cid;
96#endif
97
98 QPixmap connectedIcon, connectingIcon, disconnectedIcon;
99
100 void reset();
101 bool testHasChanged();
102 QListWidgetItem *insertNetwork(NetworkId);
103 QListWidgetItem *insertNetwork(const NetworkInfo &info);
104 QListWidgetItem *networkItem(NetworkId) const;
105 void saveToNetworkInfo(NetworkInfo &);
106 IdentityId defaultIdentity() const;
107};
108
109
110class NetworkAddDlg : public QDialog
111{
112 Q_OBJECT
113
114public:
115 NetworkAddDlg(const QStringList &existing = QStringList(), QWidget *parent = 0);
116
117 NetworkInfo networkInfo() const;
118
119private slots:
120 void setButtonStates();
121
122private:
123 Ui::NetworkAddDlg ui;
124
125 QStringList existing;
126};
127
128
129class NetworkEditDlg : public QDialog
130{
131 Q_OBJECT
132
133public:
134 NetworkEditDlg(const QString &old, const QStringList &existing = QStringList(), QWidget *parent = 0);
135
136 QString networkName() const;
137
138private slots:
139 void on_networkEdit_textChanged(const QString &);
140
141private:
142 Ui::NetworkEditDlg ui;
143
144 QStringList existing;
145};
146
147
148class ServerEditDlg : public QDialog
149{
150 Q_OBJECT
151
152public:
153 ServerEditDlg(const Network::Server &server = Network::Server(), QWidget *parent = 0);
154
155 Network::Server serverData() const;
156
157private slots:
158 void on_host_textChanged();
159
160private:
161 Ui::ServerEditDlg ui;
162};
163
164
165class SaveNetworksDlg : public QDialog
166{
167 Q_OBJECT
168
169public:
170 SaveNetworksDlg(const QList<NetworkInfo> &toCreate, const QList<NetworkInfo> &toUpdate, const QList<NetworkId> &toRemove, QWidget *parent = 0);
171
172private slots:
173 void clientEvent();
174
175private:
176 Ui::SaveIdentitiesDlg ui;
177
178 int numevents, rcvevents;
179};
180
181
182#endif
183