X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fqtui%2Fsettingspages%2Fnetworkssettingspage.cpp;h=6bb068d2ba6b7eab2578fbe2ed4bea9e4423adee;hb=e7ca039bcfdef8e22946b4402643ce107e89709c;hp=7976cca4a06b5f45360e49bcf20a053bcc785311;hpb=0d418069762066b4640250efd5ba8d68bf0af178;p=quassel.git diff --git a/src/qtui/settingspages/networkssettingspage.cpp b/src/qtui/settingspages/networkssettingspage.cpp index 7976cca4..6bb068d2 100644 --- a/src/qtui/settingspages/networkssettingspage.cpp +++ b/src/qtui/settingspages/networkssettingspage.cpp @@ -32,6 +32,9 @@ #include "settingspagedlg.h" #include "util.h" +// IRCv3 capabilities +#include "irccap.h" + #include "settingspages/identitiessettingspage.h" NetworksSettingsPage::NetworksSettingsPage(QWidget *parent) @@ -43,9 +46,9 @@ NetworksSettingsPage::NetworksSettingsPage(QWidget *parent) ui.setupUi(this); // hide SASL options for older cores - if (!(Client::coreFeatures() & Quassel::SaslAuthentication)) + if (!Client::isCoreFeatureEnabled(Quassel::Feature::SaslAuthentication)) ui.sasl->hide(); - if (!(Client::coreFeatures() & Quassel::SaslExternal)) + if (!Client::isCoreFeatureEnabled(Quassel::Feature::SaslExternal)) ui.saslExtInfo->hide(); #ifndef HAVE_SSL ui.saslExtInfo->hide(); @@ -68,6 +71,10 @@ NetworksSettingsPage::NetworksSettingsPage(QWidget *parent) connectingIcon = QIcon::fromTheme("network-wired"); // FIXME network-connecting disconnectedIcon = QIcon::fromTheme("network-disconnect"); + // Status icons + infoIcon = QIcon::fromTheme("dialog-information"); + warningIcon = QIcon::fromTheme("dialog-warning"); + foreach(int mib, QTextCodec::availableMibs()) { QByteArray codec = QTextCodec::codecForMib(mib)->name(); ui.sendEncoding->addItem(codec); @@ -89,12 +96,12 @@ NetworksSettingsPage::NetworksSettingsPage(QWidget *parent) connect(ui.identityList, SIGNAL(currentIndexChanged(int)), this, SLOT(widgetHasChanged())); //connect(ui.randomServer, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.performEdit, SIGNAL(textChanged()), this, SLOT(widgetHasChanged())); - connect(ui.autoIdentify, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); - connect(ui.autoIdentifyService, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); - connect(ui.autoIdentifyPassword, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); connect(ui.sasl, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.saslAccount, SIGNAL(textEdited(QString)), this, SLOT(widgetHasChanged())); connect(ui.saslPassword, SIGNAL(textEdited(QString)), this, SLOT(widgetHasChanged())); + connect(ui.autoIdentify, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); + connect(ui.autoIdentifyService, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); + connect(ui.autoIdentifyPassword, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); connect(ui.useCustomEncodings, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.sendEncoding, SIGNAL(currentIndexChanged(int)), this, SLOT(widgetHasChanged())); connect(ui.recvEncoding, SIGNAL(currentIndexChanged(int)), this, SLOT(widgetHasChanged())); @@ -104,6 +111,15 @@ NetworksSettingsPage::NetworksSettingsPage(QWidget *parent) connect(ui.reconnectRetries, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged())); connect(ui.unlimitedRetries, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.rejoinOnReconnect, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); + + // Core features can change during a reconnect. Always connect these here, delaying testing for + // the core feature flag in load(). + connect(ui.useCustomMessageRate, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); + connect(ui.messageRateBurstSize, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged())); + connect(ui.messageRateDelay, SIGNAL(valueChanged(double)), this, SLOT(widgetHasChanged())); + connect(ui.unlimitedMessageRate, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); + + // Add additional widgets here //connect(ui., SIGNAL(), this, SLOT(widgetHasChanged())); //connect(ui., SIGNAL(), this, SLOT(widgetHasChanged())); @@ -158,10 +174,44 @@ void NetworksSettingsPage::save() void NetworksSettingsPage::load() { reset(); + + // Handle UI dependent on core feature flags here + if (Client::isCoreFeatureEnabled(Quassel::Feature::CustomRateLimits)) { + // Custom rate limiting supported, allow toggling + ui.useCustomMessageRate->setEnabled(true); + // Reset tooltip to default. + ui.useCustomMessageRate->setToolTip(QString("%1").arg( + tr("
Override default message rate limiting.
" + "Setting limits too low may get you disconnected" + " from the server!
"))); + // If changed, update the message below! + } else { + // Custom rate limiting not supported, disallow toggling + ui.useCustomMessageRate->setEnabled(false); + // Split up the message to allow re-using translations: + // [Original tool-tip] + // [Bold 'does not support feature' message] + // [Specific version needed and feature details] + ui.useCustomMessageRate->setToolTip(QString("%1Override default message rate limiting.
" + "Setting limits too low may get you disconnected" + " from the server!
"), + tr("Your Quassel core does not support this feature"), + tr("You need a Quassel core v0.13.0 or newer in order to " + "modify message rate limits."))); + } + +#ifdef HAVE_SSL + // Hide the SASL EXTERNAL notice until a network's shown. Stops it from showing while loading + // backlog from the core. + sslUpdated(); +#endif + foreach(NetworkId netid, Client::networkIds()) { clientNetworkAdded(netid); } ui.networkList->setCurrentRow(0); + setChangedState(false); } @@ -305,6 +355,41 @@ void NetworksSettingsPage::setItemState(NetworkId id, QListWidgetItem *item) } +void NetworksSettingsPage::setNetworkCapStates(NetworkId id) +{ + const Network *net = Client::network(id); + if (Client::isCoreFeatureEnabled(Quassel::Feature::CapNegotiation) && net) { + // Capability negotiation is supported, network exists. + // Check if the network is connected. Don't use net->isConnected() as that won't be true + // during capability negotiation when capabilities are added and removed. + if (net->connectionState() != Network::Disconnected) { + // Network exists and is connected, check available capabilities... + // [SASL] + if (net->saslMaybeSupports(IrcCap::SaslMech::PLAIN)) { + setSASLStatus(CapSupportStatus::MaybeSupported); + } else { + setSASLStatus(CapSupportStatus::MaybeUnsupported); + } + + // Add additional capability-dependent interface updates here + } else { + // Network is disconnected + // [SASL] + setSASLStatus(CapSupportStatus::Disconnected); + + // Add additional capability-dependent interface updates here + } + } else { + // Capability negotiation is not supported and/or network doesn't exist. + // Don't assume anything and reset all capability-dependent interface elements to neutral. + // [SASL] + setSASLStatus(CapSupportStatus::Unknown); + + // Add additional capability-dependent interface updates here + } +} + + void NetworksSettingsPage::coreConnectionStateChanged(bool state) { this->setEnabled(state); @@ -391,6 +476,10 @@ void NetworksSettingsPage::clientNetworkAdded(NetworkId id) connect(Client::network(id), SIGNAL(connectionStateSet(Network::ConnectionState)), this, SLOT(networkConnectionStateChanged(Network::ConnectionState))); connect(Client::network(id), SIGNAL(connectionError(const QString &)), this, SLOT(networkConnectionError(const QString &))); + + // Handle capability changes in case a server dis/connects with the settings window open. + connect(Client::network(id), SIGNAL(capAdded(const QString &)), this, SLOT(clientNetworkCapsUpdated())); + connect(Client::network(id), SIGNAL(capRemoved(const QString &)), this, SLOT(clientNetworkCapsUpdated())); } @@ -435,6 +524,11 @@ void NetworksSettingsPage::networkConnectionStateChanged(Network::ConnectionStat } */ setItemState(net->networkId()); + if (net->networkId() == currentId) { + // Network is currently shown. Update the capability-dependent UI in case capabilities have + // changed. + setNetworkCapStates(currentId); + } setWidgetStates(); } @@ -481,7 +575,7 @@ void NetworksSettingsPage::displayNetwork(NetworkId id) #ifdef HAVE_SSL // this is only needed when the core supports SASL EXTERNAL - if (Client::coreFeatures() & Quassel::SaslExternal) { + if (Client::isCoreFeatureEnabled(Quassel::Feature::SaslExternal)) { if (_cid) { disconnect(_cid, SIGNAL(sslSettingsUpdated()), this, SLOT(sslUpdated())); delete _cid; @@ -502,6 +596,8 @@ void NetworksSettingsPage::displayNetwork(NetworkId id) } //setItemState(id); //ui.randomServer->setChecked(info.useRandomServer); + // Update the capability-dependent UI in case capabilities have changed. + setNetworkCapStates(id); ui.performEdit->setPlainText(info.perform.join("\n")); ui.autoIdentify->setChecked(info.useAutoIdentify); ui.autoIdentifyService->setText(info.autoIdentifyService); @@ -526,6 +622,14 @@ void NetworksSettingsPage::displayNetwork(NetworkId id) ui.reconnectRetries->setValue(info.autoReconnectRetries); ui.unlimitedRetries->setChecked(info.unlimitedReconnectRetries); ui.rejoinOnReconnect->setChecked(info.rejoinChannels); + // Custom rate limiting + ui.unlimitedMessageRate->setChecked(info.unlimitedMessageRate); + // Set 'ui.useCustomMessageRate' after 'ui.unlimitedMessageRate' so if the latter is + // disabled, 'ui.messageRateDelayFrame' will remain disabled. + ui.useCustomMessageRate->setChecked(info.useCustomMessageRate); + ui.messageRateBurstSize->setValue(info.messageRateBurstSize); + // Convert milliseconds (integer) into seconds (double) + ui.messageRateDelay->setValue(info.messageRateDelay / 1000.0f); } else { // just clear widgets @@ -575,6 +679,66 @@ void NetworksSettingsPage::saveToNetworkInfo(NetworkInfo &info) info.autoReconnectRetries = ui.reconnectRetries->value(); info.unlimitedReconnectRetries = ui.unlimitedRetries->isChecked(); info.rejoinChannels = ui.rejoinOnReconnect->isChecked(); + // Custom rate limiting + info.useCustomMessageRate = ui.useCustomMessageRate->isChecked(); + info.messageRateBurstSize = ui.messageRateBurstSize->value(); + // Convert seconds (double) into milliseconds (integer) + info.messageRateDelay = static_cast%1
%2
%3
" + ).arg(saslStatusHeader, + saslStatusExplanation, + tr("SASL is a standardized way to log in and identify yourself to " + "IRC servers.")); + + if (useWarningIcon) { + // Show as a warning dialog box + QMessageBox::warning(this, saslStatusMsgTitle, saslStatusMsgText); + } else { + // Show as an information dialog box + QMessageBox::information(this, saslStatusMsgTitle, saslStatusMsgText); + } + } +} + + IdentityId NetworksSettingsPage::defaultIdentity() const { IdentityId defaultId = 0; @@ -791,7 +1021,7 @@ NetworkAddDlg::NetworkAddDlg(const QStringList &exist, QWidget *parent) : QDialo // Do NOT call updateSslPort when loading settings, otherwise port settings may be overriden. // If useSSL is later changed to be checked by default, change port's default value, too. - if (Client::coreFeatures() & Quassel::VerifyServerSSL) { + if (Client::isCoreFeatureEnabled(Quassel::Feature::VerifyServerSSL)) { // Synchronize requiring SSL with the use SSL checkbox ui.sslVerify->setEnabled(ui.useSSL->isChecked()); connect(ui.useSSL, SIGNAL(toggled(bool)), ui.sslVerify, SLOT(setEnabled(bool))); @@ -938,7 +1168,7 @@ ServerEditDlg::ServerEditDlg(const Network::Server &server, QWidget *parent) : Q // Do NOT call updateSslPort when loading settings, otherwise port settings may be overriden. // If useSSL is later changed to be checked by default, change port's default value, too. - if (Client::coreFeatures() & Quassel::VerifyServerSSL) { + if (Client::isCoreFeatureEnabled(Quassel::Feature::VerifyServerSSL)) { // Synchronize requiring SSL with the use SSL checkbox ui.sslVerify->setEnabled(ui.useSSL->isChecked()); connect(ui.useSSL, SIGNAL(toggled(bool)), ui.sslVerify, SLOT(setEnabled(bool)));