1 /***************************************************************************
2 * Copyright (C) 2005-2020 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 #include "networkssettingspage.h"
25 #include <QHeaderView>
26 #include <QMessageBox>
33 #include "presetnetworks.h"
34 #include "settingspagedlg.h"
36 #include "widgethelpers.h"
41 #include "settingspages/identitiessettingspage.h"
43 NetworksSettingsPage::NetworksSettingsPage(QWidget* parent)
44 : SettingsPage(tr("IRC"), tr("Networks"), parent)
48 // hide SASL options for older cores
49 if (!Client::isCoreFeatureEnabled(Quassel::Feature::SaslAuthentication))
51 if (!Client::isCoreFeatureEnabled(Quassel::Feature::SaslExternal))
52 ui.saslExtInfo->hide();
55 ui.renameNetwork->setIcon(icon::get("edit-rename"));
56 ui.addNetwork->setIcon(icon::get("list-add"));
57 ui.deleteNetwork->setIcon(icon::get("edit-delete"));
58 ui.addServer->setIcon(icon::get("list-add"));
59 ui.deleteServer->setIcon(icon::get("edit-delete"));
60 ui.editServer->setIcon(icon::get("configure"));
61 ui.upServer->setIcon(icon::get("go-up"));
62 ui.downServer->setIcon(icon::get("go-down"));
63 ui.editIdentities->setIcon(icon::get("configure"));
65 connectedIcon = icon::get("network-connect");
66 connectingIcon = icon::get("network-wired"); // FIXME network-connecting
67 disconnectedIcon = icon::get("network-disconnect");
70 infoIcon = icon::get({"emblem-information", "dialog-information"});
71 successIcon = icon::get({"emblem-success", "dialog-information"});
72 unavailableIcon = icon::get({"emblem-unavailable", "dialog-warning"});
73 questionIcon = icon::get({"emblem-question", "dialog-question", "dialog-information"});
75 foreach (int mib, QTextCodec::availableMibs()) {
76 QByteArray codec = QTextCodec::codecForMib(mib)->name();
77 ui.sendEncoding->addItem(codec);
78 ui.recvEncoding->addItem(codec);
79 ui.serverEncoding->addItem(codec);
81 ui.sendEncoding->model()->sort(0);
82 ui.recvEncoding->model()->sort(0);
83 ui.serverEncoding->model()->sort(0);
85 setEnabled(Client::isConnected()); // need a core connection!
88 connectToWidgetsChangedSignals({ui.identityList, ui.performEdit, ui.sasl,
89 ui.saslAccount, ui.saslPassword, ui.autoIdentify,
90 ui.autoIdentifyService, ui.autoIdentifyPassword, ui.useCustomEncodings,
91 ui.sendEncoding, ui.recvEncoding, ui.serverEncoding,
92 ui.autoReconnect, ui.reconnectInterval, ui.reconnectRetries,
93 ui.unlimitedRetries, ui.rejoinOnReconnect, ui.useCustomMessageRate,
94 ui.messageRateBurstSize, ui.messageRateDelay, ui.unlimitedMessageRate},
96 &NetworksSettingsPage::widgetHasChanged);
98 connect(Client::instance(), &Client::coreConnectionStateChanged, this, &NetworksSettingsPage::coreConnectionStateChanged);
99 connect(Client::instance(), &Client::networkCreated, this, &NetworksSettingsPage::clientNetworkAdded);
100 connect(Client::instance(), &Client::networkRemoved, this, &NetworksSettingsPage::clientNetworkRemoved);
101 connect(Client::instance(), &Client::identityCreated, this, &NetworksSettingsPage::clientIdentityAdded);
102 connect(Client::instance(), &Client::identityRemoved, this, &NetworksSettingsPage::clientIdentityRemoved);
104 foreach (IdentityId id, Client::identityIds()) {
105 clientIdentityAdded(id);
109 void NetworksSettingsPage::save()
113 saveToNetworkInfo(networkInfos[currentId]);
115 QList<NetworkInfo> toCreate, toUpdate;
116 QList<NetworkId> toRemove;
117 QHash<NetworkId, NetworkInfo>::iterator i = networkInfos.begin();
118 while (i != networkInfos.end()) {
119 NetworkId id = (*i).networkId;
122 // if(id == currentId) currentId = 0;
123 // QList<QListWidgetItem *> items = ui.networkList->findItems((*i).networkName, Qt::MatchExactly);
124 // if(items.count()) {
125 // Q_ASSERT(items[0]->data(Qt::UserRole).value<NetworkId>() == id);
128 // i = networkInfos.erase(i);
132 if ((*i) != Client::network((*i).networkId)->networkInfo()) {
138 foreach (NetworkId id, Client::networkIds()) {
139 if (!networkInfos.contains(id))
142 SaveNetworksDlg dlg(toCreate, toUpdate, toRemove, this);
143 int ret = dlg.exec();
144 if (ret == QDialog::Rejected) {
145 // canceled -> reload everything to be safe
148 setChangedState(false);
152 void NetworksSettingsPage::load()
156 // Handle UI dependent on core feature flags here
157 if (Client::isCoreFeatureEnabled(Quassel::Feature::CustomRateLimits)) {
158 // Custom rate limiting supported, allow toggling
159 ui.useCustomMessageRate->setEnabled(true);
160 // Reset tooltip to default.
161 ui.useCustomMessageRate->setToolTip(QString("%1").arg(tr("<p>Override default message rate limiting.</p>"
162 "<p><b>Setting limits too low may get you disconnected"
163 " from the server!</b></p>")));
164 // If changed, update the message below!
167 // Custom rate limiting not supported, disallow toggling
168 ui.useCustomMessageRate->setEnabled(false);
169 // Split up the message to allow re-using translations:
170 // [Original tool-tip]
171 // [Bold 'does not support feature' message]
172 // [Specific version needed and feature details]
173 ui.useCustomMessageRate->setToolTip(QString("%1<br/><b>%2</b><br/>%3")
174 .arg(tr("<p>Override default message rate limiting.</p>"
175 "<p><b>Setting limits too low may get you disconnected"
176 " from the server!</b></p>"),
177 tr("Your Quassel core does not support this feature"),
178 tr("You need a Quassel core v0.13.0 or newer in order to "
179 "modify message rate limits.")));
182 if (!Client::isConnected() || Client::isCoreFeatureEnabled(Quassel::Feature::SkipIrcCaps)) {
183 // Either disconnected or IRCv3 capability skippping supported, enable configuration and
184 // hide warning. Don't show the warning needlessly when disconnected.
185 ui.enableCapsConfigWidget->setEnabled(true);
186 ui.enableCapsStatusLabel->setText(tr("These features require support from the network"));
187 ui.enableCapsStatusIcon->setPixmap(infoIcon.pixmap(16));
190 // Core does not IRCv3 capability skipping, show warning and disable configuration
191 ui.enableCapsConfigWidget->setEnabled(false);
192 ui.enableCapsStatusLabel->setText(tr("Your Quassel core is too old to configure IRCv3 features"));
193 ui.enableCapsStatusIcon->setPixmap(unavailableIcon.pixmap(16));
196 // Hide the SASL EXTERNAL notice until a network's shown. Stops it from showing while loading
197 // backlog from the core.
200 // Reset network capability status in case no valid networks get selected (a rare situation)
201 resetNetworkCapStates();
203 foreach (NetworkId netid, Client::networkIds()) {
204 clientNetworkAdded(netid);
206 ui.networkList->setCurrentRow(0);
208 setChangedState(false);
211 void NetworksSettingsPage::reset()
214 ui.networkList->clear();
215 networkInfos.clear();
218 bool NetworksSettingsPage::aboutToSave()
221 saveToNetworkInfo(networkInfos[currentId]);
223 foreach (NetworkInfo info, networkInfos.values()) {
224 if (!info.serverList.count())
229 QString error(tr("<b>The following problems need to be corrected before your changes can be applied:</b><ul>"));
230 if (errors.contains(1))
231 error += tr("<li>All networks need at least one server defined</li>");
232 error += tr("</ul>");
233 QMessageBox::warning(this, tr("Invalid Network Settings"), error);
237 void NetworksSettingsPage::widgetHasChanged()
239 if (_ignoreWidgetChanges)
241 bool changed = testHasChanged();
242 if (changed != hasChanged())
243 setChangedState(changed);
246 bool NetworksSettingsPage::testHasChanged()
248 if (currentId != 0) {
249 saveToNetworkInfo(networkInfos[currentId]);
251 if (Client::networkIds().count() != networkInfos.count())
253 foreach (NetworkId id, networkInfos.keys()) {
256 if (Client::network(id)->networkInfo() != networkInfos[id])
262 void NetworksSettingsPage::setWidgetStates()
265 if (ui.networkList->selectedItems().count()) {
266 ui.detailsBox->setEnabled(true);
267 ui.renameNetwork->setEnabled(true);
268 ui.deleteNetwork->setEnabled(true);
270 /* button disabled for now
271 NetworkId id = ui.networkList->selectedItems()[0]->data(Qt::UserRole).value<NetworkId>();
272 const Network *net = id > 0 ? Client::network(id) : 0;
273 ui.connectNow->setEnabled(net);
274 // && (Client::network(id)->connectionState() == Network::Initialized
275 // || Client::network(id)->connectionState() == Network::Disconnected));
277 if(net->connectionState() == Network::Disconnected) {
278 ui.connectNow->setIcon(connectedIcon);
279 ui.connectNow->setText(tr("Connect"));
281 ui.connectNow->setIcon(disconnectedIcon);
282 ui.connectNow->setText(tr("Disconnect"));
285 ui.connectNow->setIcon(QIcon());
286 ui.connectNow->setText(tr("Apply first!"));
290 ui.renameNetwork->setEnabled(false);
291 ui.deleteNetwork->setEnabled(false);
292 // ui.connectNow->setEnabled(false);
293 ui.detailsBox->setEnabled(false);
296 if (ui.serverList->selectedItems().count()) {
297 ui.editServer->setEnabled(true);
298 ui.deleteServer->setEnabled(true);
299 ui.upServer->setEnabled(ui.serverList->currentRow() > 0);
300 ui.downServer->setEnabled(ui.serverList->currentRow() < ui.serverList->count() - 1);
303 ui.editServer->setEnabled(false);
304 ui.deleteServer->setEnabled(false);
305 ui.upServer->setEnabled(false);
306 ui.downServer->setEnabled(false);
310 void NetworksSettingsPage::setItemState(NetworkId id, QListWidgetItem* item)
312 if (!item && !(item = networkItem(id)))
314 const Network* net = Client::network(id);
315 if (!net || net->isInitialized())
316 item->setFlags(item->flags() | Qt::ItemIsEnabled);
318 item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
319 if (net && net->connectionState() == Network::Initialized) {
320 item->setIcon(connectedIcon);
322 else if (net && net->connectionState() != Network::Disconnected) {
323 item->setIcon(connectingIcon);
326 item->setIcon(disconnectedIcon);
330 // check if we already have another net of this name in the list, and replace it
331 QList<QListWidgetItem*> items = ui.networkList->findItems(net->networkName(), Qt::MatchExactly);
333 foreach (QListWidgetItem* i, items) {
334 NetworkId oldid = i->data(Qt::UserRole).value<NetworkId>();
336 continue; // only locally created nets should be replaced
337 if (oldid == currentId) {
340 ui.networkList->clearSelection();
342 int row = ui.networkList->row(i);
344 QListWidgetItem* olditem = ui.networkList->takeItem(row);
348 networkInfos.remove(oldid);
352 item->setText(net->networkName());
354 item->setSelected(true);
358 void NetworksSettingsPage::resetNetworkCapStates()
360 // Set the status to a blank (invalid) network ID, reseting all UI
361 setNetworkCapStates(NetworkId());
364 void NetworksSettingsPage::setNetworkCapStates(NetworkId id)
366 const Network* net = Client::network(id);
367 if (net && Client::isCoreFeatureEnabled(Quassel::Feature::CapNegotiation)) {
368 // Capability negotiation is supported, network exists.
369 // Check if the network is connected. Don't use net->isConnected() as that won't be true
370 // during capability negotiation when capabilities are added and removed.
371 if (net->connectionState() != Network::Disconnected) {
372 // Network exists and is connected, check available capabilities...
374 if (net->saslMaybeSupports(IrcCap::SaslMech::PLAIN)) {
375 setSASLStatus(CapSupportStatus::MaybeSupported);
378 setSASLStatus(CapSupportStatus::MaybeUnsupported);
381 // Add additional capability-dependent interface updates here
384 // Network is disconnected
386 setSASLStatus(CapSupportStatus::Disconnected);
388 // Add additional capability-dependent interface updates here
392 // Capability negotiation is not supported and/or network doesn't exist.
393 // Don't assume anything and reset all capability-dependent interface elements to neutral.
395 setSASLStatus(CapSupportStatus::Unknown);
397 // Add additional capability-dependent interface updates here
401 void NetworksSettingsPage::coreConnectionStateChanged(bool state)
403 this->setEnabled(state);
413 void NetworksSettingsPage::clientIdentityAdded(IdentityId id)
415 const Identity* identity = Client::identity(id);
416 connect(identity, &SyncableObject::updatedRemotely, this, &NetworksSettingsPage::clientIdentityUpdated);
418 QString name = identity->identityName();
419 for (int j = 0; j < ui.identityList->count(); j++) {
420 if ((j > 0 || ui.identityList->itemData(0).toInt() != 1) && name.localeAwareCompare(ui.identityList->itemText(j)) < 0) {
421 ui.identityList->insertItem(j, name, id.toInt());
427 ui.identityList->insertItem(ui.identityList->count(), name, id.toInt());
431 void NetworksSettingsPage::clientIdentityUpdated()
433 const auto* identity = qobject_cast<const Identity*>(sender());
435 qWarning() << "NetworksSettingsPage: Invalid identity to update!";
438 int row = ui.identityList->findData(identity->id().toInt());
440 qWarning() << "NetworksSettingsPage: Invalid identity to update!";
443 if (ui.identityList->itemText(row) != identity->identityName()) {
444 ui.identityList->setItemText(row, identity->identityName());
448 void NetworksSettingsPage::clientIdentityRemoved(IdentityId id)
450 IdentityId defaultId = defaultIdentity();
452 saveToNetworkInfo(networkInfos[currentId]);
453 foreach (NetworkInfo info, networkInfos.values()) {
454 if (info.identity == id) {
455 if (info.networkId == currentId)
456 ui.identityList->setCurrentIndex(0);
457 info.identity = defaultId;
458 networkInfos[info.networkId] = info;
459 if (info.networkId > 0)
460 Client::updateNetwork(info);
463 ui.identityList->removeItem(ui.identityList->findData(id.toInt()));
467 QListWidgetItem* NetworksSettingsPage::networkItem(NetworkId id) const
469 for (int i = 0; i < ui.networkList->count(); i++) {
470 QListWidgetItem* item = ui.networkList->item(i);
471 if (item->data(Qt::UserRole).value<NetworkId>() == id)
477 void NetworksSettingsPage::clientNetworkAdded(NetworkId id)
480 // connect(Client::network(id), &Network::updatedRemotely, this, &NetworksSettingsPage::clientNetworkUpdated);
481 connect(Client::network(id), &Network::configChanged, this, &NetworksSettingsPage::clientNetworkUpdated);
483 connect(Client::network(id), &Network::connectionStateSet, this, &NetworksSettingsPage::networkConnectionStateChanged);
484 connect(Client::network(id), &Network::connectionError, this, &NetworksSettingsPage::networkConnectionError);
486 // Handle capability changes in case a server dis/connects with the settings window open.
487 connect(Client::network(id), &Network::capAdded, this, &NetworksSettingsPage::clientNetworkCapsUpdated);
488 connect(Client::network(id), &Network::capRemoved, this, &NetworksSettingsPage::clientNetworkCapsUpdated);
491 void NetworksSettingsPage::clientNetworkUpdated()
493 const auto* net = qobject_cast<const Network*>(sender());
495 qWarning() << "Update request for unknown network received!";
498 networkInfos[net->networkId()] = net->networkInfo();
499 setItemState(net->networkId());
500 if (net->networkId() == currentId)
501 displayNetwork(net->networkId());
506 void NetworksSettingsPage::clientNetworkRemoved(NetworkId id)
508 if (!networkInfos.contains(id))
512 NetworkInfo info = networkInfos.take(id);
513 QList<QListWidgetItem*> items = ui.networkList->findItems(info.networkName, Qt::MatchExactly);
514 foreach (QListWidgetItem* item, items) {
515 if (item->data(Qt::UserRole).value<NetworkId>() == id)
516 delete ui.networkList->takeItem(ui.networkList->row(item));
522 void NetworksSettingsPage::networkConnectionStateChanged(Network::ConnectionState state)
525 const auto* net = qobject_cast<const Network*>(sender());
529 if(net->networkId() == currentId) {
530 ui.connectNow->setEnabled(state == Network::Initialized || state == Network::Disconnected);
533 setItemState(net->networkId());
534 if (net->networkId() == currentId) {
535 // Network is currently shown. Update the capability-dependent UI in case capabilities have
537 setNetworkCapStates(currentId);
542 void NetworksSettingsPage::networkConnectionError(const QString&) {}
544 QListWidgetItem* NetworksSettingsPage::insertNetwork(NetworkId id)
546 NetworkInfo info = Client::network(id)->networkInfo();
547 networkInfos[id] = info;
548 return insertNetwork(info);
551 QListWidgetItem* NetworksSettingsPage::insertNetwork(const NetworkInfo& info)
553 QListWidgetItem* item = nullptr;
554 QList<QListWidgetItem*> items = ui.networkList->findItems(info.networkName, Qt::MatchExactly);
556 item = new QListWidgetItem(disconnectedIcon, info.networkName, ui.networkList);
558 // we overwrite an existing net if it a) has the same name and b) has a negative ID meaning we created it locally before
559 // -> then we can be sure that this is the core-side replacement for the net we created
560 foreach (QListWidgetItem* i, items) {
561 NetworkId id = i->data(Qt::UserRole).value<NetworkId>();
568 item = new QListWidgetItem(disconnectedIcon, info.networkName, ui.networkList);
570 item->setData(Qt::UserRole, QVariant::fromValue(info.networkId));
571 setItemState(info.networkId, item);
576 // Called when selecting 'Configure' from the buffer list
577 void NetworksSettingsPage::bufferList_Open(NetworkId netId)
579 QListWidgetItem* item = networkItem(netId);
580 ui.networkList->setCurrentItem(item, QItemSelectionModel::SelectCurrent);
583 void NetworksSettingsPage::displayNetwork(NetworkId id)
585 _ignoreWidgetChanges = true;
587 NetworkInfo info = networkInfos[id];
589 // this is only needed when the core supports SASL EXTERNAL
590 if (Client::isCoreFeatureEnabled(Quassel::Feature::SaslExternal)) {
592 disconnect(_cid, &CertIdentity::sslSettingsUpdated, this, &NetworksSettingsPage::sslUpdated);
595 _cid = new CertIdentity(*Client::identity(info.identity), this);
596 _cid->enableEditSsl(true);
597 connect(_cid, &CertIdentity::sslSettingsUpdated, this, &NetworksSettingsPage::sslUpdated);
600 ui.identityList->setCurrentIndex(ui.identityList->findData(info.identity.toInt()));
601 ui.serverList->clear();
602 foreach (Network::Server server, info.serverList) {
603 QListWidgetItem* item = new QListWidgetItem(QString("%1:%2").arg(server.host).arg(server.port));
605 item->setIcon(icon::get("document-encrypt"));
606 ui.serverList->addItem(item);
609 // ui.randomServer->setChecked(info.useRandomServer);
610 // Update the capability-dependent UI in case capabilities have changed.
611 setNetworkCapStates(id);
612 ui.performEdit->setPlainText(info.perform.join("\n"));
613 ui.autoIdentify->setChecked(info.useAutoIdentify);
614 ui.autoIdentifyService->setText(info.autoIdentifyService);
615 ui.autoIdentifyPassword->setText(info.autoIdentifyPassword);
616 ui.sasl->setChecked(info.useSasl);
617 ui.saslAccount->setText(info.saslAccount);
618 ui.saslPassword->setText(info.saslPassword);
619 if (info.codecForEncoding.isEmpty()) {
620 ui.sendEncoding->setCurrentIndex(ui.sendEncoding->findText(Network::defaultCodecForEncoding()));
621 ui.recvEncoding->setCurrentIndex(ui.recvEncoding->findText(Network::defaultCodecForDecoding()));
622 ui.serverEncoding->setCurrentIndex(ui.serverEncoding->findText(Network::defaultCodecForServer()));
623 ui.useCustomEncodings->setChecked(false);
626 ui.sendEncoding->setCurrentIndex(ui.sendEncoding->findText(info.codecForEncoding));
627 ui.recvEncoding->setCurrentIndex(ui.recvEncoding->findText(info.codecForDecoding));
628 ui.serverEncoding->setCurrentIndex(ui.serverEncoding->findText(info.codecForServer));
629 ui.useCustomEncodings->setChecked(true);
631 ui.autoReconnect->setChecked(info.useAutoReconnect);
632 ui.reconnectInterval->setValue(info.autoReconnectInterval);
633 ui.reconnectRetries->setValue(info.autoReconnectRetries);
634 ui.unlimitedRetries->setChecked(info.unlimitedReconnectRetries);
635 ui.rejoinOnReconnect->setChecked(info.rejoinChannels);
636 // Custom rate limiting
637 ui.unlimitedMessageRate->setChecked(info.unlimitedMessageRate);
638 // Set 'ui.useCustomMessageRate' after 'ui.unlimitedMessageRate' so if the latter is
639 // disabled, 'ui.messageRateDelayFrame' will remain disabled.
640 ui.useCustomMessageRate->setChecked(info.useCustomMessageRate);
641 ui.messageRateBurstSize->setValue(info.messageRateBurstSize);
642 // Convert milliseconds (integer) into seconds (double)
643 ui.messageRateDelay->setValue(info.messageRateDelay / 1000.0f);
646 // just clear widgets
648 disconnect(_cid, &CertIdentity::sslSettingsUpdated, this, &NetworksSettingsPage::sslUpdated);
651 ui.identityList->setCurrentIndex(-1);
652 ui.serverList->clear();
653 ui.performEdit->clear();
654 ui.autoIdentifyService->clear();
655 ui.autoIdentifyPassword->clear();
656 ui.saslAccount->clear();
657 ui.saslPassword->clear();
660 _ignoreWidgetChanges = false;
664 void NetworksSettingsPage::saveToNetworkInfo(NetworkInfo& info)
666 info.identity = ui.identityList->itemData(ui.identityList->currentIndex()).toInt();
667 // info.useRandomServer = ui.randomServer->isChecked();
668 info.perform = ui.performEdit->toPlainText().split("\n");
669 info.useAutoIdentify = ui.autoIdentify->isChecked();
670 info.autoIdentifyService = ui.autoIdentifyService->text();
671 info.autoIdentifyPassword = ui.autoIdentifyPassword->text();
672 info.useSasl = ui.sasl->isChecked();
673 info.saslAccount = ui.saslAccount->text();
674 info.saslPassword = ui.saslPassword->text();
675 if (!ui.useCustomEncodings->isChecked()) {
676 info.codecForEncoding.clear();
677 info.codecForDecoding.clear();
678 info.codecForServer.clear();
681 info.codecForEncoding = ui.sendEncoding->currentText().toLatin1();
682 info.codecForDecoding = ui.recvEncoding->currentText().toLatin1();
683 info.codecForServer = ui.serverEncoding->currentText().toLatin1();
685 info.useAutoReconnect = ui.autoReconnect->isChecked();
686 info.autoReconnectInterval = ui.reconnectInterval->value();
687 info.autoReconnectRetries = ui.reconnectRetries->value();
688 info.unlimitedReconnectRetries = ui.unlimitedRetries->isChecked();
689 info.rejoinChannels = ui.rejoinOnReconnect->isChecked();
690 // Custom rate limiting
691 info.useCustomMessageRate = ui.useCustomMessageRate->isChecked();
692 info.messageRateBurstSize = ui.messageRateBurstSize->value();
693 // Convert seconds (double) into milliseconds (integer)
694 info.messageRateDelay = static_cast<quint32>((ui.messageRateDelay->value() * 1000));
695 info.unlimitedMessageRate = ui.unlimitedMessageRate->isChecked();
698 void NetworksSettingsPage::clientNetworkCapsUpdated()
700 // Grab the updated network
701 const auto* net = qobject_cast<const Network*>(sender());
703 qWarning() << "Update request for unknown network received!";
706 if (net->networkId() == currentId) {
707 // Network is currently shown. Update the capability-dependent UI in case capabilities have
709 setNetworkCapStates(currentId);
713 void NetworksSettingsPage::setSASLStatus(const CapSupportStatus saslStatus)
715 if (_saslStatusSelected != saslStatus) {
716 // Update the cached copy of SASL status used with the Details dialog
717 _saslStatusSelected = saslStatus;
719 // Update the user interface
720 switch (saslStatus) {
721 case CapSupportStatus::Unknown:
722 // There's no capability negotiation or network doesn't exist. Don't assume
724 ui.saslStatusLabel->setText(QString("<i>%1</i>").arg(tr("Could not check if supported by network")));
725 ui.saslStatusIcon->setPixmap(questionIcon.pixmap(16));
727 case CapSupportStatus::Disconnected:
728 // Disconnected from network, no way to check.
729 ui.saslStatusLabel->setText(QString("<i>%1</i>").arg(tr("Cannot check if supported when disconnected")));
730 ui.saslStatusIcon->setPixmap(questionIcon.pixmap(16));
732 case CapSupportStatus::MaybeUnsupported:
733 // The network doesn't advertise support for SASL PLAIN. Here be dragons.
734 ui.saslStatusLabel->setText(QString("<i>%1</i>").arg(tr("Not currently supported by network")));
735 ui.saslStatusIcon->setPixmap(unavailableIcon.pixmap(16));
737 case CapSupportStatus::MaybeSupported:
738 // The network advertises support for SASL PLAIN. Encourage using it!
739 // Unfortunately we don't know for sure if it's desired or functional.
740 ui.saslStatusLabel->setText(QString("<i>%1</i>").arg(tr("Supported by network")));
741 ui.saslStatusIcon->setPixmap(successIcon.pixmap(16));
747 void NetworksSettingsPage::sslUpdated()
749 if (_cid && !_cid->sslKey().isNull()) {
750 ui.saslContents->setDisabled(true);
751 ui.saslExtInfo->setHidden(false);
754 ui.saslContents->setDisabled(false);
755 // Directly re-enabling causes the widgets to ignore the parent "Use SASL Authentication"
756 // state to indicate whether or not it's disabled. To workaround this, keep track of
757 // whether or not "Use SASL Authentication" is enabled, then quickly uncheck/recheck the
759 if (!ui.sasl->isChecked()) {
760 // SASL is not enabled, uncheck/recheck the group box to re-disable saslContents.
761 // Leaving saslContents disabled doesn't work as that prevents it from re-enabling if
762 // sasl is later checked.
763 ui.sasl->setChecked(true);
764 ui.sasl->setChecked(false);
766 ui.saslExtInfo->setHidden(true);
770 /*** Network list ***/
772 void NetworksSettingsPage::on_networkList_itemSelectionChanged()
774 if (currentId != 0) {
775 saveToNetworkInfo(networkInfos[currentId]);
777 if (ui.networkList->selectedItems().count()) {
778 NetworkId id = ui.networkList->selectedItems()[0]->data(Qt::UserRole).value<NetworkId>();
781 ui.serverList->setCurrentRow(0);
789 void NetworksSettingsPage::on_addNetwork_clicked()
791 QStringList existing;
792 for (int i = 0; i < ui.networkList->count(); i++)
793 existing << ui.networkList->item(i)->text();
794 NetworkAddDlg dlg(existing, this);
795 if (dlg.exec() == QDialog::Accepted) {
796 NetworkInfo info = dlg.networkInfo();
797 if (info.networkName.isEmpty())
798 return; // sanity check
801 for (id = 1; id <= networkInfos.count(); id++) {
803 if (!networkInfos.keys().contains(-id.toInt()))
808 info.identity = defaultIdentity();
809 networkInfos[id] = info;
810 QListWidgetItem* item = insertNetwork(info);
811 ui.networkList->setCurrentItem(item);
816 void NetworksSettingsPage::on_deleteNetwork_clicked()
818 if (ui.networkList->selectedItems().count()) {
819 NetworkId netid = ui.networkList->selectedItems()[0]->data(Qt::UserRole).value<NetworkId>();
821 = QMessageBox::question(this,
822 tr("Delete Network?"),
823 tr("Do you really want to delete the network \"%1\" and all related settings, including the backlog?")
824 .arg(networkInfos[netid].networkName),
825 QMessageBox::Yes | QMessageBox::No,
827 if (ret == QMessageBox::Yes) {
829 networkInfos.remove(netid);
830 delete ui.networkList->takeItem(ui.networkList->row(ui.networkList->selectedItems()[0]));
831 ui.networkList->setCurrentRow(qMin(ui.networkList->currentRow() + 1, ui.networkList->count() - 1));
838 void NetworksSettingsPage::on_renameNetwork_clicked()
840 if (!ui.networkList->selectedItems().count())
842 QString old = ui.networkList->selectedItems()[0]->text();
843 QStringList existing;
844 for (int i = 0; i < ui.networkList->count(); i++)
845 existing << ui.networkList->item(i)->text();
846 NetworkEditDlg dlg(old, existing, this);
847 if (dlg.exec() == QDialog::Accepted) {
848 ui.networkList->selectedItems()[0]->setText(dlg.networkName());
849 NetworkId netid = ui.networkList->selectedItems()[0]->data(Qt::UserRole).value<NetworkId>();
850 networkInfos[netid].networkName = dlg.networkName();
856 void NetworksSettingsPage::on_connectNow_clicked() {
857 if(!ui.networkList->selectedItems().count()) return;
858 NetworkId id = ui.networkList->selectedItems()[0]->data(Qt::UserRole).value<NetworkId>();
859 const Network *net = Client::network(id);
861 if(net->connectionState() == Network::Disconnected) net->requestConnect();
862 else net->requestDisconnect();
866 /*** Server list ***/
868 void NetworksSettingsPage::on_serverList_itemSelectionChanged()
873 void NetworksSettingsPage::on_addServer_clicked()
877 ServerEditDlg dlg(Network::Server(), this);
878 if (dlg.exec() == QDialog::Accepted) {
879 networkInfos[currentId].serverList.append(dlg.serverData());
880 displayNetwork(currentId);
881 ui.serverList->setCurrentRow(ui.serverList->count() - 1);
886 void NetworksSettingsPage::on_editServer_clicked()
890 int cur = ui.serverList->currentRow();
891 ServerEditDlg dlg(networkInfos[currentId].serverList[cur], this);
892 if (dlg.exec() == QDialog::Accepted) {
893 networkInfos[currentId].serverList[cur] = dlg.serverData();
894 displayNetwork(currentId);
895 ui.serverList->setCurrentRow(cur);
900 void NetworksSettingsPage::on_deleteServer_clicked()
904 int cur = ui.serverList->currentRow();
905 networkInfos[currentId].serverList.removeAt(cur);
906 displayNetwork(currentId);
907 ui.serverList->setCurrentRow(qMin(cur, ui.serverList->count() - 1));
911 void NetworksSettingsPage::on_upServer_clicked()
913 int cur = ui.serverList->currentRow();
914 Network::Server server = networkInfos[currentId].serverList.takeAt(cur);
915 networkInfos[currentId].serverList.insert(cur - 1, server);
916 displayNetwork(currentId);
917 ui.serverList->setCurrentRow(cur - 1);
921 void NetworksSettingsPage::on_downServer_clicked()
923 int cur = ui.serverList->currentRow();
924 Network::Server server = networkInfos[currentId].serverList.takeAt(cur);
925 networkInfos[currentId].serverList.insert(cur + 1, server);
926 displayNetwork(currentId);
927 ui.serverList->setCurrentRow(cur + 1);
931 void NetworksSettingsPage::on_editIdentities_clicked()
933 SettingsPageDlg dlg(new IdentitiesSettingsPage(this), this);
937 void NetworksSettingsPage::on_saslStatusDetails_clicked()
939 if (ui.networkList->selectedItems().count()) {
940 NetworkId netid = ui.networkList->selectedItems()[0]->data(Qt::UserRole).value<NetworkId>();
941 QString& netName = networkInfos[netid].networkName;
943 // If these strings are visible, one of the status messages wasn't detected below.
944 QString saslStatusHeader = "[header unintentionally left blank]";
945 QString saslStatusExplanation = "[explanation unintentionally left blank]";
947 // If true, show a warning icon instead of an information icon
948 bool useWarningIcon = false;
950 // Determine which explanation to show
951 switch (_saslStatusSelected) {
952 case CapSupportStatus::Unknown:
953 saslStatusHeader = tr("Could not check if SASL supported by network");
954 saslStatusExplanation = tr("Quassel could not check if \"%1\" supports SASL. This may "
955 "be due to unsaved changes or an older Quassel core. You "
956 "can still try using SASL.")
959 case CapSupportStatus::Disconnected:
960 saslStatusHeader = tr("Cannot check if SASL supported when disconnected");
961 saslStatusExplanation = tr("Quassel cannot check if \"%1\" supports SASL when "
962 "disconnected. Connect to the network, or try using SASL "
966 case CapSupportStatus::MaybeUnsupported:
967 saslStatusHeader = tr("SASL not currently supported by network");
968 saslStatusExplanation = tr("The network \"%1\" does not currently support SASL. "
969 "However, support might be added later on.")
971 useWarningIcon = true;
973 case CapSupportStatus::MaybeSupported:
974 saslStatusHeader = tr("SASL supported by network");
975 saslStatusExplanation = tr("The network \"%1\" supports SASL. In most cases, you "
976 "should use SASL instead of NickServ identification.")
981 // Process this in advance for reusability below
982 const QString saslStatusMsgTitle = tr("SASL support for \"%1\"").arg(netName);
983 const QString saslStatusMsgText = QString("<p><b>%1</b></p></br><p>%2</p></br><p><i>%3</i></p>")
984 .arg(saslStatusHeader,
985 saslStatusExplanation,
986 tr("SASL is a standardized way to log in and identify yourself to "
989 if (useWarningIcon) {
990 // Show as a warning dialog box
991 QMessageBox::warning(this, saslStatusMsgTitle, saslStatusMsgText);
994 // Show as an information dialog box
995 QMessageBox::information(this, saslStatusMsgTitle, saslStatusMsgText);
1000 void NetworksSettingsPage::on_enableCapsStatusDetails_clicked()
1002 if (!Client::isConnected() || Client::isCoreFeatureEnabled(Quassel::Feature::SkipIrcCaps)) {
1003 // Either disconnected or IRCv3 capability skippping supported
1005 // Try to get a list of currently enabled features
1006 QStringList sortedCapsEnabled;
1007 // Check if a network is selected
1008 if (ui.networkList->selectedItems().count()) {
1009 // Get the underlying Network from the selected network
1010 NetworkId netid = ui.networkList->selectedItems()[0]->data(Qt::UserRole).value<NetworkId>();
1011 const Network* net = Client::network(netid);
1012 if (net && Client::isCoreFeatureEnabled(Quassel::Feature::CapNegotiation)) {
1013 // Capability negotiation is supported, network exists.
1014 // If the network is disconnected, the list of enabled capabilities will be empty,
1015 // no need to check for that specifically.
1016 // Sorting isn't required, but it looks nicer.
1017 sortedCapsEnabled = net->capsEnabled();
1018 sortedCapsEnabled.sort();
1022 // Try to explain IRCv3 network features in a friendly way, including showing the currently
1023 // enabled features if available
1024 auto messageText = QString("<p>%1</p></br><p>%2</p>")
1025 .arg(tr("Quassel makes use of newer IRC features when supported by the IRC network."
1026 " If desired, you can disable unwanted or problematic features here."),
1027 tr("The <a href=\"https://ircv3.net/irc/\">IRCv3 website</a> provides more "
1028 "technical details on the IRCv3 capabilities powering these features."));
1030 if (!sortedCapsEnabled.isEmpty()) {
1031 // Format the capabilities within <code></code> blocks
1032 auto formattedCaps = QString("<code>%1</code>")
1033 .arg(sortedCapsEnabled.join("</code>, <code>"));
1035 // Add the currently enabled capabilities to the list
1036 // This creates a new QString, but this code is not performance-critical.
1037 messageText = messageText.append(QString("<p><i>%1</i></p>").arg(
1038 tr("Currently enabled IRCv3 capabilities for this "
1039 "network: %1").arg(formattedCaps)));
1042 QMessageBox::information(this, tr("Configuring network features"), messageText);
1045 // Core does not IRCv3 capability skipping, show warning
1046 QMessageBox::warning(this, tr("Configuring network features unsupported"),
1047 QString("<p><b>%1</b></p></br><p>%2</p>")
1048 .arg(tr("Your Quassel core is too old to configure IRCv3 network features"),
1049 tr("You need a Quassel core v0.14.0 or newer to control what network "
1050 "features Quassel will use.")));
1054 void NetworksSettingsPage::on_enableCapsAdvanced_clicked()
1059 CapsEditDlg dlg(networkInfos[currentId].skipCapsToString(), this);
1060 if (dlg.exec() == QDialog::Accepted) {
1061 networkInfos[currentId].skipCapsFromString(dlg.skipCapsString());
1062 displayNetwork(currentId);
1067 IdentityId NetworksSettingsPage::defaultIdentity() const
1069 IdentityId defaultId = 0;
1070 QList<IdentityId> ids = Client::identityIds();
1071 foreach (IdentityId id, ids) {
1072 if (defaultId == 0 || id < defaultId)
1078 /**************************************************************************
1080 *************************************************************************/
1082 NetworkAddDlg::NetworkAddDlg(QStringList exist, QWidget* parent)
1084 , existing(std::move(exist))
1087 ui.useSSL->setIcon(icon::get("document-encrypt"));
1089 // Whenever useSSL is toggled, update the port number if not changed from the default
1090 connect(ui.useSSL, &QAbstractButton::toggled, this, &NetworkAddDlg::updateSslPort);
1091 // Do NOT call updateSslPort when loading settings, otherwise port settings may be overriden.
1092 // If useSSL is later changed to be checked by default, change port's default value, too.
1094 if (Client::isCoreFeatureEnabled(Quassel::Feature::VerifyServerSSL)) {
1095 // Synchronize requiring SSL with the use SSL checkbox
1096 ui.sslVerify->setEnabled(ui.useSSL->isChecked());
1097 connect(ui.useSSL, &QAbstractButton::toggled, ui.sslVerify, &QWidget::setEnabled);
1100 // Core isn't new enough to allow requiring SSL; disable checkbox and uncheck
1101 ui.sslVerify->setEnabled(false);
1102 ui.sslVerify->setChecked(false);
1103 // Split up the message to allow re-using translations:
1104 // [Original tool-tip]
1105 // [Bold 'does not support feature' message]
1106 // [Specific version needed and feature details]
1107 ui.sslVerify->setToolTip(QString("%1<br/><b>%2</b><br/>%3")
1108 .arg(ui.sslVerify->toolTip(),
1109 tr("Your Quassel core does not support this feature"),
1110 tr("You need a Quassel core v0.13.0 or newer in order to "
1111 "verify connection security.")));
1114 // read preset networks
1115 QStringList networks = PresetNetworks::names();
1116 foreach (QString s, existing)
1117 networks.removeAll(s);
1118 if (networks.count())
1119 ui.presetList->addItems(networks);
1121 ui.useManual->setChecked(true);
1122 ui.usePreset->setEnabled(false);
1124 connect(ui.networkName, &QLineEdit::textChanged, this, &NetworkAddDlg::setButtonStates);
1125 connect(ui.serverAddress, &QLineEdit::textChanged, this, &NetworkAddDlg::setButtonStates);
1126 connect(ui.usePreset, &QRadioButton::toggled, this, &NetworkAddDlg::setButtonStates);
1127 connect(ui.useManual, &QRadioButton::toggled, this, &NetworkAddDlg::setButtonStates);
1131 NetworkInfo NetworkAddDlg::networkInfo() const
1133 if (ui.useManual->isChecked()) {
1135 info.networkName = ui.networkName->text().trimmed();
1136 info.serverList << Network::Server(ui.serverAddress->text().trimmed(),
1138 ui.serverPassword->text(),
1139 ui.useSSL->isChecked(),
1140 ui.sslVerify->isChecked());
1144 return PresetNetworks::networkInfo(ui.presetList->currentText());
1147 void NetworkAddDlg::setButtonStates()
1150 if (ui.usePreset->isChecked() && ui.presetList->count())
1152 else if (ui.useManual->isChecked()) {
1153 ok = !ui.networkName->text().trimmed().isEmpty() && !existing.contains(ui.networkName->text().trimmed())
1154 && !ui.serverAddress->text().isEmpty();
1156 ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
1159 void NetworkAddDlg::updateSslPort(bool isChecked)
1161 // "Use encrypted connection" was toggled, check the state...
1162 if (isChecked && ui.port->value() == Network::PORT_PLAINTEXT) {
1163 // Had been using the plain-text port, use the SSL default
1164 ui.port->setValue(Network::PORT_SSL);
1166 else if (!isChecked && ui.port->value() == Network::PORT_SSL) {
1167 // Had been using the SSL port, use the plain-text default
1168 ui.port->setValue(Network::PORT_PLAINTEXT);
1172 /**************************************************************************
1174 *************************************************************************/
1176 NetworkEditDlg::NetworkEditDlg(const QString& old, QStringList exist, QWidget* parent)
1178 , existing(std::move(exist))
1182 if (old.isEmpty()) {
1184 setWindowTitle(tr("Add Network"));
1185 on_networkEdit_textChanged(""); // disable ok button
1188 ui.networkEdit->setText(old);
1191 QString NetworkEditDlg::networkName() const
1193 return ui.networkEdit->text().trimmed();
1196 void NetworkEditDlg::on_networkEdit_textChanged(const QString& text)
1198 ui.buttonBox->button(QDialogButtonBox::Ok)->setDisabled(text.isEmpty() || existing.contains(text.trimmed()));
1201 /**************************************************************************
1203 *************************************************************************/
1204 ServerEditDlg::ServerEditDlg(const Network::Server& server, QWidget* parent)
1208 ui.useSSL->setIcon(icon::get("document-encrypt"));
1209 ui.host->setText(server.host);
1210 ui.host->setFocus();
1211 ui.port->setValue(server.port);
1212 ui.password->setText(server.password);
1213 ui.useSSL->setChecked(server.useSsl);
1214 ui.sslVerify->setChecked(server.sslVerify);
1215 ui.sslVersion->setCurrentIndex(server.sslVersion);
1216 ui.useProxy->setChecked(server.useProxy);
1217 ui.proxyType->setCurrentIndex(server.proxyType == QNetworkProxy::Socks5Proxy ? 0 : 1);
1218 ui.proxyHost->setText(server.proxyHost);
1219 ui.proxyPort->setValue(server.proxyPort);
1220 ui.proxyUsername->setText(server.proxyUser);
1221 ui.proxyPassword->setText(server.proxyPass);
1223 // This is a dirty hack to display the core->IRC SSL protocol dropdown
1224 // only if the core won't use autonegotiation to determine the best
1225 // protocol. When autonegotiation was introduced, it would have been
1226 // a good idea to use the CoreFeatures enum to accomplish this.
1227 // However, since multiple versions have been released since then, that
1228 // is no longer possible. Instead, we rely on the fact that the
1229 // Datastream protocol was introduced in the same version (0.10) as SSL
1230 // autonegotiation. Because of that, we can display the dropdown only
1231 // if the Legacy protocol is in use. If any other RemotePeer protocol
1232 // is in use, that means a newer protocol is in use and therefore the
1233 // core will use autonegotiation.
1234 if (Client::coreConnection()->peer()->protocol() != Protocol::LegacyProtocol) {
1236 ui.sslVersion->hide();
1239 // Whenever useSSL is toggled, update the port number if not changed from the default
1240 connect(ui.useSSL, &QAbstractButton::toggled, this, &ServerEditDlg::updateSslPort);
1241 // Do NOT call updateSslPort when loading settings, otherwise port settings may be overriden.
1242 // If useSSL is later changed to be checked by default, change port's default value, too.
1244 if (Client::isCoreFeatureEnabled(Quassel::Feature::VerifyServerSSL)) {
1245 // Synchronize requiring SSL with the use SSL checkbox
1246 ui.sslVerify->setEnabled(ui.useSSL->isChecked());
1247 connect(ui.useSSL, &QAbstractButton::toggled, ui.sslVerify, &QWidget::setEnabled);
1250 // Core isn't new enough to allow requiring SSL; disable checkbox and uncheck
1251 ui.sslVerify->setEnabled(false);
1252 ui.sslVerify->setChecked(false);
1253 // Split up the message to allow re-using translations:
1254 // [Original tool-tip]
1255 // [Bold 'does not support feature' message]
1256 // [Specific version needed and feature details]
1257 ui.sslVerify->setToolTip(QString("%1<br/><b>%2</b><br/>%3")
1258 .arg(ui.sslVerify->toolTip(),
1259 tr("Your Quassel core does not support this feature"),
1260 tr("You need a Quassel core v0.13.0 or newer in order to "
1261 "verify connection security.")));
1264 on_host_textChanged();
1267 Network::Server ServerEditDlg::serverData() const
1269 Network::Server server(ui.host->text().trimmed(), ui.port->value(), ui.password->text(), ui.useSSL->isChecked(), ui.sslVerify->isChecked());
1270 server.sslVersion = ui.sslVersion->currentIndex();
1271 server.useProxy = ui.useProxy->isChecked();
1272 server.proxyType = ui.proxyType->currentIndex() == 0 ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy;
1273 server.proxyHost = ui.proxyHost->text();
1274 server.proxyPort = ui.proxyPort->value();
1275 server.proxyUser = ui.proxyUsername->text();
1276 server.proxyPass = ui.proxyPassword->text();
1280 void ServerEditDlg::on_host_textChanged()
1282 ui.buttonBox->button(QDialogButtonBox::Ok)->setDisabled(ui.host->text().trimmed().isEmpty());
1285 void ServerEditDlg::updateSslPort(bool isChecked)
1287 // "Use encrypted connection" was toggled, check the state...
1288 if (isChecked && ui.port->value() == Network::PORT_PLAINTEXT) {
1289 // Had been using the plain-text port, use the SSL default
1290 ui.port->setValue(Network::PORT_SSL);
1292 else if (!isChecked && ui.port->value() == Network::PORT_SSL) {
1293 // Had been using the SSL port, use the plain-text default
1294 ui.port->setValue(Network::PORT_PLAINTEXT);
1298 /**************************************************************************
1300 *************************************************************************/
1302 CapsEditDlg::CapsEditDlg(const QString& oldSkipCapsString, QWidget* parent)
1304 , oldSkipCapsString(oldSkipCapsString)
1308 // Connect to the reset button to reset the text
1309 // This provides an explicit way to "get back to defaults" in case someone changes settings to
1311 QPushButton* defaultsButton = ui.buttonBox->button(QDialogButtonBox::RestoreDefaults);
1312 connect(defaultsButton, &QPushButton::clicked, this, &CapsEditDlg::defaultSkipCaps);
1314 if (oldSkipCapsString.isEmpty()) {
1315 // Disable Reset button
1316 on_skipCapsEdit_textChanged("");
1319 ui.skipCapsEdit->setText(oldSkipCapsString);
1324 QString CapsEditDlg::skipCapsString() const
1326 return ui.skipCapsEdit->text();
1329 void CapsEditDlg::defaultSkipCaps()
1331 ui.skipCapsEdit->setText("");
1334 void CapsEditDlg::on_skipCapsEdit_textChanged(const QString& text)
1336 ui.buttonBox->button(QDialogButtonBox::RestoreDefaults)->setDisabled(text.isEmpty());
1339 /**************************************************************************
1341 *************************************************************************/
1343 SaveNetworksDlg::SaveNetworksDlg(const QList<NetworkInfo>& toCreate,
1344 const QList<NetworkInfo>& toUpdate,
1345 const QList<NetworkId>& toRemove,
1351 numevents = toCreate.count() + toUpdate.count() + toRemove.count();
1354 ui.progressBar->setMaximum(numevents);
1355 ui.progressBar->setValue(0);
1357 connect(Client::instance(), &Client::networkCreated, this, &SaveNetworksDlg::clientEvent);
1358 connect(Client::instance(), &Client::networkRemoved, this, &SaveNetworksDlg::clientEvent);
1360 foreach (NetworkId id, toRemove) {
1361 Client::removeNetwork(id);
1363 foreach (NetworkInfo info, toCreate) {
1364 Client::createNetwork(info);
1366 foreach (NetworkInfo info, toUpdate) {
1367 const Network* net = Client::network(info.networkId);
1369 qWarning() << "Invalid client network!";
1373 // FIXME this only checks for one changed item rather than all!
1374 connect(net, &SyncableObject::updatedRemotely, this, &SaveNetworksDlg::clientEvent);
1375 Client::updateNetwork(info);
1379 qWarning() << "Sync dialog called without stuff to change!";
1384 void SaveNetworksDlg::clientEvent()
1386 ui.progressBar->setValue(++rcvevents);
1387 if (rcvevents >= numevents)