1 /***************************************************************************
2 * Copyright (C) 2005-2016 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
21 #ifndef NETWORKSSETTINGSPAGE_H
22 #define NETWORKSSETTINGSPAGE_H
27 #include "settingspage.h"
28 #include "clientidentity.h"
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"
36 class NetworksSettingsPage : public SettingsPage
41 NetworksSettingsPage(QWidget *parent = 0);
43 virtual inline bool needsCoreConnection() const { return true; }
52 void widgetHasChanged();
53 void setWidgetStates();
54 void coreConnectionStateChanged(bool);
55 void networkConnectionStateChanged(Network::ConnectionState state);
56 void networkConnectionError(const QString &msg);
58 void displayNetwork(NetworkId);
59 void setItemState(NetworkId, QListWidgetItem *item = 0);
62 * Update the capability-dependent settings according to what the server supports
64 * For example, this updates the SASL text for when the server advertises support. This should
65 * only be called on the currently displayed network.
67 * @param[in] id NetworkId referencing network used to update settings user interface.
69 void setNetworkCapStates(NetworkId id);
71 void clientNetworkAdded(NetworkId);
72 void clientNetworkRemoved(NetworkId);
73 void clientNetworkUpdated();
75 void clientIdentityAdded(IdentityId);
76 void clientIdentityRemoved(IdentityId);
77 void clientIdentityUpdated();
80 * Update the settings user interface according to capabilities advertised by the IRC server
82 void clientNetworkCapsUpdated();
88 void on_networkList_itemSelectionChanged();
89 void on_addNetwork_clicked();
90 void on_deleteNetwork_clicked();
91 void on_renameNetwork_clicked();
92 void on_editIdentities_clicked();
94 // void on_connectNow_clicked();
96 void on_serverList_itemSelectionChanged();
97 void on_addServer_clicked();
98 void on_deleteServer_clicked();
99 void on_editServer_clicked();
100 void on_upServer_clicked();
101 void on_downServer_clicked();
104 * Event handler for SASL status Details button
106 void on_saslStatusDetails_clicked();
110 * Status of capability support
112 enum CapSupportStatus {
113 Unknown, ///< Old core, or otherwise unknown, can't make assumptions
114 Disconnected, ///< Disconnected from network, can't determine
115 MaybeUnsupported, ///< Server does not advertise support at this moment
116 MaybeSupported ///< Server advertises support at this moment
118 // Keep in mind networks can add, change, and remove capabilities at any time.
120 Ui::NetworksSettingsPage ui;
123 QHash<NetworkId, NetworkInfo> networkInfos;
124 bool _ignoreWidgetChanges;
129 QIcon connectedIcon, connectingIcon, disconnectedIcon;
132 QIcon infoIcon, warningIcon;
134 CapSupportStatus _saslStatusSelected; /// Status of SASL support for currently-selected network
137 bool testHasChanged();
138 QListWidgetItem *insertNetwork(NetworkId);
139 QListWidgetItem *insertNetwork(const NetworkInfo &info);
140 QListWidgetItem *networkItem(NetworkId) const;
141 void saveToNetworkInfo(NetworkInfo &);
142 IdentityId defaultIdentity() const;
145 * Update the SASL settings interface according to the given SASL state
147 * @param[in] saslStatus Current status of SASL support.
149 void setSASLStatus(const CapSupportStatus saslStatus);
153 class NetworkAddDlg : public QDialog
158 NetworkAddDlg(const QStringList &existing = QStringList(), QWidget *parent = 0);
160 NetworkInfo networkInfo() const;
163 void setButtonStates();
166 * Update the default server port according to isChecked
168 * Connect with useSSL->toggled() in order to keep the port number in sync. This only modifies
169 * the port if it's not been changed from defaults.
171 * @param isChecked If true and port unchanged, set port to 6697, else set port to 6667.
173 void updateSslPort(bool isChecked);
176 Ui::NetworkAddDlg ui;
178 QStringList existing;
182 class NetworkEditDlg : public QDialog
187 NetworkEditDlg(const QString &old, const QStringList &existing = QStringList(), QWidget *parent = 0);
189 QString networkName() const;
192 void on_networkEdit_textChanged(const QString &);
195 Ui::NetworkEditDlg ui;
197 QStringList existing;
201 class ServerEditDlg : public QDialog
206 ServerEditDlg(const Network::Server &server = Network::Server(), QWidget *parent = 0);
208 Network::Server serverData() const;
211 void on_host_textChanged();
214 * Update the default server port according to isChecked
216 * Connect with useSSL->toggled() in order to keep the port number in sync. This only modifies
217 * the port if it's not been changed from defaults.
219 * @param isChecked If true and port unchanged, set port to 6697, else set port to 6667.
221 void updateSslPort(bool isChecked);
224 Ui::ServerEditDlg ui;
228 class SaveNetworksDlg : public QDialog
233 SaveNetworksDlg(const QList<NetworkInfo> &toCreate, const QList<NetworkInfo> &toUpdate, const QList<NetworkId> &toRemove, QWidget *parent = 0);
239 Ui::SaveIdentitiesDlg ui;
241 int numevents, rcvevents;