Commit f4ae0cec authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Jan Grulich
Browse files

openconnect widget: Default to "anyconnect" when protocol is not set.

This matches the GNOME implementation as well as the openconnect binary's
default behavior when "--protocol" is not specified.

Connections created via nmcli, for example, can be set up without explicitly
passing "protocol" in the VPN data; this is expected to be interpreted as
the AnyConnect protocol rather than Pulse.

While here, also check NM_OPENCONNECT_KEY_REPORTED_OS's presence via
QMap::contains() rather than creating and comparing to an empty QString.

(cherry picked from commit b3a9d726)
parent c9f4c071
......@@ -190,7 +190,8 @@ void OpenconnectSettingWidget::loadConfig(const NetworkManager::Setting::Ptr &se
const NMStringMap dataMap = setting.staticCast<NetworkManager::VpnSetting>()->data();
int cmbProtocolIndex;
if (dataMap[NM_OPENCONNECT_KEY_PROTOCOL] == QLatin1String("anyconnect")) {
// No value corresponds to "anyconnect", matching GNOME and the openconnect binary itself.
if (!dataMap.contains(NM_OPENCONNECT_KEY_PROTOCOL) || dataMap[NM_OPENCONNECT_KEY_PROTOCOL] == QLatin1String("anyconnect")) {
cmbProtocolIndex = 0;
} else if (dataMap[NM_OPENCONNECT_KEY_PROTOCOL] == QLatin1String("nc")) {
cmbProtocolIndex = 1;
......@@ -201,7 +202,7 @@ void OpenconnectSettingWidget::loadConfig(const NetworkManager::Setting::Ptr &se
int cmbReportedOsIndex;
if (dataMap[NM_OPENCONNECT_KEY_REPORTED_OS] == QString()) {
if (!dataMap.contains(NM_OPENCONNECT_KEY_REPORTED_OS)) {
cmbReportedOsIndex = 0;
} else if (dataMap[NM_OPENCONNECT_KEY_REPORTED_OS] == QLatin1String("linux")) {
cmbReportedOsIndex = 1;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment