1 /***************************************************************************
2 * Copyright (C) 2005-2018 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; }
50 void bufferList_Open(NetworkId);
53 void widgetHasChanged();
54 void setWidgetStates();
55 void coreConnectionStateChanged(bool);
56 void networkConnectionStateChanged(Network::ConnectionState state);
57 void networkConnectionError(const QString &msg);
59 void displayNetwork(NetworkId);
60 void setItemState(NetworkId, QListWidgetItem *item = 0);
63 * Update the capability-dependent settings according to what the server supports
65 * For example, this updates the SASL text for when the server advertises support. This should
66 * only be called on the currently displayed network.
68 * @param[in] id NetworkId referencing network used to update settings user interface.
70 void setNetworkCapStates(NetworkId id);
72 void clientNetworkAdded(NetworkId);
73 void clientNetworkRemoved(NetworkId);
74 void clientNetworkUpdated();
76 void clientIdentityAdded(IdentityId);
77 void clientIdentityRemoved(IdentityId);
78 void clientIdentityUpdated();
81 * Update the settings user interface according to capabilities advertised by the IRC server
83 void clientNetworkCapsUpdated();
89 void on_networkList_itemSelectionChanged();
90 void on_addNetwork_clicked();
91 void on_deleteNetwork_clicked();
92 void on_renameNetwork_clicked();
93 void on_editIdentities_clicked();
95 // void on_connectNow_clicked();
97 void on_serverList_itemSelectionChanged();
98 void on_addServer_clicked();
99 void on_deleteServer_clicked();
100 void on_editServer_clicked();
101 void on_upServer_clicked();
102 void on_downServer_clicked();
105 * Event handler for SASL status Details button
107 void on_saslStatusDetails_clicked();
111 * Status of capability support
113 enum CapSupportStatus {
114 Unknown, ///< Old core, or otherwise unknown, can't make assumptions
115 Disconnected, ///< Disconnected from network, can't determine
116 MaybeUnsupported, ///< Server does not advertise support at this moment
117 MaybeSupported ///< Server advertises support at this moment
119 // Keep in mind networks can add, change, and remove capabilities at any time.
121 Ui::NetworksSettingsPage ui;
124 QHash<NetworkId, NetworkInfo> networkInfos;
125 bool _ignoreWidgetChanges;
130 QIcon connectedIcon, connectingIcon, disconnectedIcon;
133 QIcon infoIcon, warningIcon;
135 CapSupportStatus _saslStatusSelected; /// Status of SASL support for currently-selected network
138 bool testHasChanged();
139 QListWidgetItem *insertNetwork(NetworkId);
140 QListWidgetItem *insertNetwork(const NetworkInfo &info);
141 QListWidgetItem *networkItem(NetworkId) const;
142 void saveToNetworkInfo(NetworkInfo &);
143 IdentityId defaultIdentity() const;
146 * Update the SASL settings interface according to the given SASL state
148 * @param[in] saslStatus Current status of SASL support.
150 void setSASLStatus(const CapSupportStatus saslStatus);
154 class NetworkAddDlg : public QDialog
159 NetworkAddDlg(const QStringList &existing = QStringList(), QWidget *parent = 0);
161 NetworkInfo networkInfo() const;
164 void setButtonStates();
167 * Update the default server port according to isChecked
169 * Connect with useSSL->toggled() in order to keep the port number in sync. This only modifies
170 * the port if it's not been changed from defaults.
172 * @param isChecked If true and port unchanged, set port to 6697, else set port to 6667.
174 void updateSslPort(bool isChecked);
177 Ui::NetworkAddDlg ui;
179 QStringList existing;
183 class NetworkEditDlg : public QDialog
188 NetworkEditDlg(const QString &old, const QStringList &existing = QStringList(), QWidget *parent = 0);
190 QString networkName() const;
193 void on_networkEdit_textChanged(const QString &);
196 Ui::NetworkEditDlg ui;
198 QStringList existing;
202 class ServerEditDlg : public QDialog
207 ServerEditDlg(const Network::Server &server = Network::Server(), QWidget *parent = 0);
209 Network::Server serverData() const;
212 void on_host_textChanged();
215 * Update the default server port according to isChecked
217 * Connect with useSSL->toggled() in order to keep the port number in sync. This only modifies
218 * the port if it's not been changed from defaults.
220 * @param isChecked If true and port unchanged, set port to 6697, else set port to 6667.
222 void updateSslPort(bool isChecked);
225 Ui::ServerEditDlg ui;
229 class SaveNetworksDlg : public QDialog
234 SaveNetworksDlg(const QList<NetworkInfo> &toCreate, const QList<NetworkInfo> &toUpdate, const QList<NetworkId> &toRemove, QWidget *parent = 0);
240 Ui::SaveIdentitiesDlg ui;
242 int numevents, rcvevents;