Add back the SSL protocol selection dialog box for old cores.
[quassel.git] / src / qtui / settingspages / networkssettingspage.cpp
index 011328d..f422ebb 100644 (file)
@@ -869,12 +869,30 @@ ServerEditDlg::ServerEditDlg(const Network::Server &server, QWidget *parent) : Q
     ui.port->setValue(server.port);
     ui.password->setText(server.password);
     ui.useSSL->setChecked(server.useSsl);
+    ui.sslVersion->setCurrentIndex(server.sslVersion);
     ui.useProxy->setChecked(server.useProxy);
     ui.proxyType->setCurrentIndex(server.proxyType == QNetworkProxy::Socks5Proxy ? 0 : 1);
     ui.proxyHost->setText(server.proxyHost);
     ui.proxyPort->setValue(server.proxyPort);
     ui.proxyUsername->setText(server.proxyUser);
     ui.proxyPassword->setText(server.proxyPass);
+
+    // This is a dirty hack to display the core->IRC SSL protocol dropdown
+    // only if the core won't use autonegotiation to determine the best
+    // protocol.  When autonegotiation was introduced, it would have been
+    // a good idea to use the CoreFeatures enum to accomplish this.
+    // However, since multiple versions have been released since then, that
+    // is no longer possible.  Instead, we rely on the fact that the
+    // Datastream protocol was introduced in the same version (0.10) as SSL
+    // autonegotiation.  Because of that, we can display the dropdown only
+    // if the Legacy protocol is in use.  If any other RemotePeer protocol
+    // is in use, that means a newer protocol is in use and therefore the
+    // core will use autonegotiation.
+    if (Client::coreConnection()->peer()->protocol() != Protocol::LegacyProtocol) {
+        ui.label_3->hide();
+        ui.sslVersion->hide();
+    }
+
     on_host_textChanged();
 }
 
@@ -882,6 +900,7 @@ ServerEditDlg::ServerEditDlg(const Network::Server &server, QWidget *parent) : Q
 Network::Server ServerEditDlg::serverData() const
 {
     Network::Server server(ui.host->text().trimmed(), ui.port->value(), ui.password->text(), ui.useSSL->isChecked());
+    server.sslVersion = ui.sslVersion->currentIndex();
     server.useProxy = ui.useProxy->isChecked();
     server.proxyType = ui.proxyType->currentIndex() == 0 ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy;
     server.proxyHost = ui.proxyHost->text();