Changeset View
Changeset View
Standalone View
Standalone View
vpn/l2tp/l2tpwidget.cpp
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | Copyright 2013 Jan Grulich <jgrulich@redhat.com> | 2 | Copyright 2013 Jan Grulich <jgrulich@redhat.com> | ||
3 | Copyright 2020 Douglas Kosovic <doug@uq.edu.au> | ||||
3 | 4 | | |||
4 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either | ||
7 | version 2.1 of the License, or (at your option) version 3, or any | 8 | version 2.1 of the License, or (at your option) version 3, or any | ||
8 | later version accepted by the membership of KDE e.V. (or its | 9 | later version accepted by the membership of KDE e.V. (or its | ||
9 | successor approved by the membership of KDE e.V.), which shall | 10 | successor approved by the membership of KDE e.V.), which shall | ||
10 | act as a proxy defined in Section 6 of version 3 of the license. | 11 | act as a proxy defined in Section 6 of version 3 of the license. | ||
Show All 23 Lines | 33 | L2tpWidget::L2tpWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget* parent, Qt::WindowFlags f) | |||
34 | , m_ui(new Ui::L2tpWidget) | 35 | , m_ui(new Ui::L2tpWidget) | ||
35 | , m_setting(setting) | 36 | , m_setting(setting) | ||
36 | { | 37 | { | ||
37 | qDBusRegisterMetaType<NMStringMap>(); | 38 | qDBusRegisterMetaType<NMStringMap>(); | ||
38 | 39 | | |||
39 | m_ui->setupUi(this); | 40 | m_ui->setupUi(this); | ||
40 | 41 | | |||
41 | m_ui->password->setPasswordOptionsEnabled(true); | 42 | m_ui->password->setPasswordOptionsEnabled(true); | ||
43 | m_ui->userKeyPassword->setPasswordOptionsEnabled(true); | ||||
44 | m_ui->userKeyPassword->setPasswordNotRequiredEnabled(true); | ||||
42 | 45 | | |||
46 | // use requesters' urlSelected signals to set other requester's startDirs to save clicking | ||||
47 | // around the filesystem, also if it is a .p12 file, set the other URLs to that .p12 file. | ||||
48 | QList<const KUrlRequester *> requesters; | ||||
49 | requesters << m_ui->userCA << m_ui->userCert << m_ui->userKey; | ||||
50 | for (const KUrlRequester *requester : requesters) { | ||||
51 | connect(requester, &KUrlRequester::urlSelected, this, &L2tpWidget::updateStartDirUrl); | ||||
52 | } | ||||
53 | | ||||
54 | if (L2tpIpsecWidget::hasIpsecDaemon()) { | ||||
43 | connect(m_ui->btnIPSecSettings, &QPushButton::clicked, this, &L2tpWidget::showIpsec); | 55 | connect(m_ui->btnIPSecSettings, &QPushButton::clicked, this, &L2tpWidget::showIpsec); | ||
56 | } else { | ||||
57 | m_ui->btnIPSecSettings->setDisabled(true); | ||||
58 | } | ||||
44 | connect(m_ui->btnPPPSettings, &QPushButton::clicked, this, &L2tpWidget::showPpp); | 59 | connect(m_ui->btnPPPSettings, &QPushButton::clicked, this, &L2tpWidget::showPpp); | ||
45 | 60 | | |||
46 | // Connect for setting check | 61 | // Connect for setting check | ||
47 | watchChangedSetting(); | 62 | watchChangedSetting(); | ||
48 | 63 | | |||
49 | // Connect for validity check | 64 | // Connect for validity check | ||
50 | connect(m_ui->gateway, &QLineEdit::textChanged, this, &L2tpWidget::slotWidgetChanged); | 65 | connect(m_ui->gateway, &QLineEdit::textChanged, this, &L2tpWidget::slotWidgetChanged); | ||
51 | connect(m_ui->cbUseCertificate, &QCheckBox::stateChanged, this, &L2tpWidget::certStateChanged); | | |||
52 | 66 | | |||
53 | KAcceleratorManager::manage(this); | 67 | KAcceleratorManager::manage(this); | ||
54 | 68 | | |||
55 | if (setting && !setting->isNull()) { | 69 | if (setting && !setting->isNull()) { | ||
56 | loadConfig(setting); | 70 | loadConfig(setting); | ||
57 | } | 71 | } | ||
58 | } | 72 | } | ||
59 | 73 | | |||
60 | L2tpWidget::~L2tpWidget() | 74 | L2tpWidget::~L2tpWidget() | ||
61 | { | 75 | { | ||
62 | m_tmpIpsecSetting.clear(); | 76 | m_tmpIpsecSetting.clear(); | ||
63 | m_tmpPppSetting.clear(); | 77 | m_tmpPppSetting.clear(); | ||
64 | delete m_ui; | 78 | delete m_ui; | ||
65 | } | 79 | } | ||
66 | 80 | | |||
67 | void L2tpWidget::loadConfig(const NetworkManager::Setting::Ptr &setting) | 81 | void L2tpWidget::loadConfig(const NetworkManager::Setting::Ptr &setting) | ||
68 | { | 82 | { | ||
69 | Q_UNUSED(setting); | 83 | Q_UNUSED(setting); | ||
70 | 84 | | |||
71 | const NMStringMap data = m_setting->data(); | 85 | const NMStringMap dataMap = m_setting->data(); | ||
72 | 86 | | |||
73 | if (data.contains(NM_L2TP_KEY_GATEWAY)) { | 87 | m_ui->gateway->setText(dataMap[NM_L2TP_KEY_GATEWAY]); | ||
74 | m_ui->gateway->setText(data.value(NM_L2TP_KEY_GATEWAY)); | | |||
75 | } | | |||
76 | 88 | | |||
77 | if (data.contains(NM_L2TP_KEY_USER)) { | 89 | if (dataMap[NM_L2TP_KEY_USER_AUTH_TYPE].isEmpty() || dataMap[NM_L2TP_KEY_USER_AUTH_TYPE] == QLatin1String(NM_L2TP_AUTHTYPE_PASSWORD)) { | ||
78 | m_ui->username->setText(data.value(NM_L2TP_KEY_USER)); | 90 | m_ui->cmbAuthType->setCurrentIndex(AuthType::Password); | ||
79 | } | 91 | m_ui->stackedWidget->setCurrentIndex(AuthType::Password); | ||
92 | m_ui->username->setText(dataMap[NM_L2TP_KEY_USER]); | ||||
80 | 93 | | |||
81 | const NetworkManager::Setting::SecretFlags userPassType = static_cast<NetworkManager::Setting::SecretFlags>(data.value(NM_L2TP_KEY_PASSWORD"-flags").toInt()); | 94 | const NetworkManager::Setting::SecretFlags userPassType = static_cast<NetworkManager::Setting::SecretFlags>(dataMap[NM_L2TP_KEY_PASSWORD"-flags"].toInt()); | ||
82 | if (userPassType.testFlag(NetworkManager::Setting::None)) { | 95 | if (userPassType.testFlag(NetworkManager::Setting::None)) { | ||
83 | m_ui->password->setPasswordOption(PasswordField::StoreForAllUsers); | 96 | m_ui->password->setPasswordOption(PasswordField::StoreForAllUsers); | ||
84 | } else if (userPassType.testFlag(NetworkManager::Setting::AgentOwned)) { | 97 | } else if (userPassType.testFlag(NetworkManager::Setting::AgentOwned)) { | ||
85 | m_ui->password->setPasswordOption(PasswordField::StoreForUser); | 98 | m_ui->password->setPasswordOption(PasswordField::StoreForUser); | ||
86 | } else { | 99 | } else { | ||
87 | m_ui->password->setPasswordOption(PasswordField::AlwaysAsk); | 100 | m_ui->password->setPasswordOption(PasswordField::AlwaysAsk); | ||
88 | } | 101 | } | ||
89 | 102 | | |||
90 | if (data.contains(NM_L2TP_KEY_DOMAIN)) { | 103 | m_ui->domain->setText(dataMap[NM_L2TP_KEY_DOMAIN]); | ||
91 | m_ui->domain->setText(data.value(NM_L2TP_KEY_DOMAIN)); | | |||
92 | } | | |||
93 | 104 | | |||
94 | if (data.contains(NM_L2TP_KEY_CERT_CA)) { | 105 | } else { // NM_L2TP_AUTHTYPE_TLS | ||
95 | m_ui->urCACertificate->setText(data.value(NM_L2TP_KEY_CERT_CA)); | 106 | m_ui->cmbAuthType->setCurrentIndex(AuthType::TLS); | ||
107 | m_ui->stackedWidget->setCurrentIndex(AuthType::TLS); | ||||
108 | | ||||
109 | m_ui->userCA->setUrl(QUrl::fromLocalFile(dataMap[NM_L2TP_KEY_USER_CA])); | ||||
110 | m_ui->userCert->setUrl(QUrl::fromLocalFile(dataMap[NM_L2TP_KEY_USER_CERT])); | ||||
111 | m_ui->userKey->setUrl(QUrl::fromLocalFile(dataMap[NM_L2TP_KEY_USER_KEY])); | ||||
112 | | ||||
113 | const NetworkManager::Setting::SecretFlags userKeyPassType = static_cast<NetworkManager::Setting::SecretFlags>(dataMap[NM_L2TP_KEY_USER_CERTPASS"-flags"].toInt()); | ||||
114 | if (userKeyPassType.testFlag(NetworkManager::Setting::None)) { | ||||
115 | m_ui->userKeyPassword->setPasswordOption(PasswordField::StoreForAllUsers); | ||||
116 | } else if (userKeyPassType.testFlag(NetworkManager::Setting::AgentOwned)) { | ||||
117 | m_ui->userKeyPassword->setPasswordOption(PasswordField::StoreForUser); | ||||
118 | } else if (userKeyPassType.testFlag(NetworkManager::Setting::NotSaved)) { | ||||
119 | m_ui->userKeyPassword->setPasswordOption(PasswordField::AlwaysAsk); | ||||
120 | } else if (userKeyPassType.testFlag(NetworkManager::Setting::NotRequired)) { | ||||
121 | m_ui->userKeyPassword->setPasswordOption(PasswordField::NotRequired); | ||||
96 | } | 122 | } | ||
97 | | ||||
98 | if (data.contains(NM_L2TP_KEY_CERT_PUB)) { | | |||
99 | m_ui->urCertificate->setText(data.value(NM_L2TP_KEY_CERT_PUB)); | | |||
100 | } | | |||
101 | | ||||
102 | if (data.contains(NM_L2TP_KEY_CERT_KEY)) { | | |||
103 | m_ui->urPrivateKey->setText(data.value(NM_L2TP_KEY_CERT_KEY)); | | |||
104 | } | | |||
105 | | ||||
106 | if (data.value(NM_L2TP_KEY_USE_CERT) == QLatin1String("yes")) { | | |||
107 | m_ui->cbUseCertificate->setChecked(true); | | |||
108 | } | 123 | } | ||
109 | 124 | | |||
110 | loadSecrets(setting); | 125 | loadSecrets(setting); | ||
111 | } | 126 | } | ||
112 | 127 | | |||
113 | void L2tpWidget::loadSecrets(const NetworkManager::Setting::Ptr &setting) | 128 | void L2tpWidget::loadSecrets(const NetworkManager::Setting::Ptr &setting) | ||
114 | { | 129 | { | ||
115 | NetworkManager::VpnSetting::Ptr vpnSetting = setting.staticCast<NetworkManager::VpnSetting>(); | 130 | NetworkManager::VpnSetting::Ptr vpnSetting = setting.staticCast<NetworkManager::VpnSetting>(); | ||
116 | 131 | | |||
117 | if (vpnSetting) { | 132 | if (vpnSetting) { | ||
133 | const QString authType = m_setting->data().value(NM_L2TP_KEY_USER_AUTH_TYPE); | ||||
118 | const NMStringMap secrets = vpnSetting->secrets(); | 134 | const NMStringMap secrets = vpnSetting->secrets(); | ||
119 | const QString userPassword = secrets.value(NM_L2TP_KEY_PASSWORD); | 135 | | ||
120 | if (!userPassword.isEmpty()) { | 136 | if (authType == QLatin1String(NM_L2TP_AUTHTYPE_TLS)) { | ||
121 | m_ui->password->setText(userPassword); | 137 | m_ui->userKeyPassword->setText(secrets.value(NM_L2TP_KEY_USER_CERTPASS)); | ||
138 | } else { // NM_L2TP_AUTHTYPE_PASSWORD | ||||
139 | m_ui->password->setText(secrets.value(NM_L2TP_KEY_PASSWORD)); | ||||
122 | } | 140 | } | ||
123 | } | 141 | } | ||
124 | } | 142 | } | ||
125 | 143 | | |||
126 | QVariantMap L2tpWidget::setting() const | 144 | QVariantMap L2tpWidget::setting() const | ||
127 | { | 145 | { | ||
128 | NetworkManager::VpnSetting setting; | 146 | NetworkManager::VpnSetting setting; | ||
129 | setting.setServiceType(QLatin1String(NM_DBUS_SERVICE_L2TP)); | 147 | setting.setServiceType(QLatin1String(NM_DBUS_SERVICE_L2TP)); | ||
130 | NMStringMap data; | 148 | NMStringMap data; | ||
149 | NMStringMap secrets; | ||||
150 | | ||||
131 | if (!m_tmpIpsecSetting.isNull()) { | 151 | if (!m_tmpIpsecSetting.isNull()) { | ||
132 | data = m_tmpIpsecSetting->data(); | 152 | data = m_tmpIpsecSetting->data(); | ||
153 | secrets = m_tmpIpsecSetting->secrets(); | ||||
133 | } else { | 154 | } else { | ||
134 | // retrieve the settings if the dialog has not been opened | 155 | // retrieve the settings if the dialog has not been opened | ||
135 | QScopedPointer<L2tpIpsecWidget> ipsec(new L2tpIpsecWidget(m_setting, nullptr)); | 156 | QScopedPointer<L2tpIpsecWidget> ipsec(new L2tpIpsecWidget(m_setting, nullptr)); | ||
136 | data = ipsec->setting(); | 157 | data = ipsec->setting(); | ||
158 | secrets = ipsec->secrets(); | ||||
137 | } | 159 | } | ||
138 | 160 | | |||
139 | if (!m_tmpPppSetting.isNull()) { | 161 | if (!m_tmpPppSetting.isNull()) { | ||
140 | data.unite(m_tmpPppSetting->data()); | 162 | data.unite(m_tmpPppSetting->data()); | ||
141 | } else { | 163 | } else { | ||
164 | const bool need_peer_eap = m_ui->cmbAuthType->currentIndex() != AuthType::Password; | ||||
165 | | ||||
142 | // retrieve the settings if the dialog has not been opened | 166 | // retrieve the settings if the dialog has not been opened | ||
143 | QScopedPointer<L2tpPPPWidget> ppp(new L2tpPPPWidget(m_setting, nullptr)); | 167 | QScopedPointer<L2tpPPPWidget> ppp(new L2tpPPPWidget(m_setting, nullptr, need_peer_eap)); | ||
144 | data.unite(ppp->setting()); | 168 | data.unite(ppp->setting()); | ||
145 | } | 169 | } | ||
146 | 170 | | |||
147 | NMStringMap secrets; | | |||
148 | | ||||
149 | if (!m_ui->gateway->text().isEmpty()) { | 171 | if (!m_ui->gateway->text().isEmpty()) { | ||
150 | data.insert(NM_L2TP_KEY_GATEWAY, m_ui->gateway->text()); | 172 | data.insert(NM_L2TP_KEY_GATEWAY, m_ui->gateway->text()); | ||
151 | } | 173 | } | ||
152 | 174 | | |||
153 | if (m_ui->cbUseCertificate->isChecked()) { | 175 | if (m_ui->cmbAuthType->currentIndex() == AuthType::Password) { | ||
154 | data.insert(NM_L2TP_KEY_USE_CERT, "yes"); | | |||
155 | | ||||
156 | if (!m_ui->urCACertificate->text().isEmpty()) { | | |||
157 | data.insert(NM_L2TP_KEY_CERT_CA, m_ui->urCACertificate->text()); | | |||
158 | } | | |||
159 | | ||||
160 | if (!m_ui->urCertificate->text().isEmpty()) { | | |||
161 | data.insert(NM_L2TP_KEY_CERT_PUB, m_ui->urCertificate->text()); | | |||
162 | } | | |||
163 | | ||||
164 | if (!m_ui->urPrivateKey->text().isEmpty()) { | | |||
165 | data.insert(NM_L2TP_KEY_CERT_KEY, m_ui->urPrivateKey->text()); | | |||
166 | } | | |||
167 | | ||||
168 | data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotRequired)); | | |||
169 | | ||||
170 | } else { | | |||
171 | | ||||
172 | if (!m_ui->username->text().isEmpty()) { | 176 | if (!m_ui->username->text().isEmpty()) { | ||
173 | data.insert(NM_L2TP_KEY_USER, m_ui->username->text()); | 177 | data.insert(NM_L2TP_KEY_USER, m_ui->username->text()); | ||
174 | } | 178 | } | ||
175 | 179 | | |||
176 | if (m_ui->password->isEnabled() && !m_ui->password->text().isEmpty()) { | 180 | if (!m_ui->password->text().isEmpty()) { | ||
177 | secrets.insert(NM_L2TP_KEY_PASSWORD, m_ui->password->text()); | 181 | secrets.insert(NM_L2TP_KEY_PASSWORD, m_ui->password->text()); | ||
182 | } else { | ||||
183 | secrets.remove(NM_L2TP_KEY_PASSWORD); | ||||
178 | } | 184 | } | ||
179 | 185 | | |||
180 | switch (m_ui->password->passwordOption()) { | 186 | switch (m_ui->password->passwordOption()) { | ||
181 | case PasswordField::StoreForAllUsers: | 187 | case PasswordField::StoreForAllUsers: | ||
182 | data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::None)); | 188 | data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::None)); | ||
183 | break; | 189 | break; | ||
184 | case PasswordField::StoreForUser: | 190 | case PasswordField::StoreForUser: | ||
185 | data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::AgentOwned)); | 191 | data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::AgentOwned)); | ||
186 | break; | 192 | break; | ||
187 | default: | 193 | default: | ||
188 | data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotSaved)); | 194 | data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotSaved)); | ||
189 | }; | 195 | }; | ||
190 | 196 | | |||
191 | if (!m_ui->domain->text().isEmpty()) { | 197 | if (!m_ui->domain->text().isEmpty()) { | ||
192 | data.insert(NM_L2TP_KEY_DOMAIN, m_ui->domain->text()); | 198 | data.insert(NM_L2TP_KEY_DOMAIN, m_ui->domain->text()); | ||
193 | } | 199 | } | ||
200 | | ||||
201 | } else { // EnumAuthType::TLS | ||||
202 | | ||||
203 | data.insert(NM_L2TP_KEY_USER_AUTH_TYPE, NM_L2TP_AUTHTYPE_TLS); | ||||
204 | | ||||
205 | data.insert(NM_L2TP_KEY_USER_CA, m_ui->userCA->url().toLocalFile()); | ||||
206 | data.insert(NM_L2TP_KEY_USER_CERT, m_ui->userCert->url().toLocalFile()); | ||||
207 | data.insert(NM_L2TP_KEY_USER_KEY, m_ui->userKey->url().toLocalFile()); | ||||
208 | | ||||
209 | // key password | ||||
210 | if (!m_ui->userKeyPassword->text().isEmpty()) { | ||||
211 | secrets.insert(NM_L2TP_KEY_USER_CERTPASS, m_ui->userKeyPassword->text()); | ||||
212 | } else { | ||||
213 | secrets.remove(NM_L2TP_KEY_USER_CERTPASS); | ||||
214 | } | ||||
215 | | ||||
216 | switch (m_ui->userKeyPassword->passwordOption()) { | ||||
217 | case PasswordField::StoreForAllUsers: | ||||
218 | data.insert(NM_L2TP_KEY_USER_CERTPASS"-flags", QString::number(NetworkManager::Setting::None)); | ||||
219 | break; | ||||
220 | case PasswordField::StoreForUser: | ||||
221 | data.insert(NM_L2TP_KEY_USER_CERTPASS"-flags", QString::number(NetworkManager::Setting::AgentOwned)); | ||||
222 | break; | ||||
223 | case PasswordField::AlwaysAsk: | ||||
224 | data.insert(NM_L2TP_KEY_USER_CERTPASS"-flags", QString::number(NetworkManager::Setting::NotSaved)); | ||||
225 | break; | ||||
226 | case PasswordField::NotRequired: | ||||
227 | data.insert(NM_L2TP_KEY_USER_CERTPASS"-flags", QString::number(NetworkManager::Setting::NotRequired)); | ||||
228 | break; | ||||
229 | }; | ||||
194 | } | 230 | } | ||
195 | 231 | | |||
196 | setting.setData(data); | 232 | setting.setData(data); | ||
197 | setting.setSecrets(secrets); | 233 | setting.setSecrets(secrets); | ||
198 | return setting.toMap(); | 234 | return setting.toMap(); | ||
199 | } | 235 | } | ||
200 | 236 | | |||
201 | 237 | void L2tpWidget::updateStartDirUrl(const QUrl &url) | |||
202 | void L2tpWidget::userPasswordTypeChanged(int index) | | |||
203 | { | 238 | { | ||
204 | m_ui->password->setEnabled(index == SettingWidget::EnumPasswordStorageType::Store); | 239 | QList<KUrlRequester *> requesters; | ||
240 | requesters << m_ui->userCA << m_ui->userCert << m_ui->userKey; | ||||
241 | bool isP12 = url.toString().endsWith(QLatin1String(".p12")); | ||||
242 | | ||||
243 | for (KUrlRequester *requester : requesters) { | ||||
244 | requester->setStartDir(url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash)); | ||||
245 | if (isP12) { | ||||
246 | requester->setUrl(url); | ||||
247 | } | ||||
248 | } | ||||
205 | } | 249 | } | ||
206 | 250 | | |||
207 | void L2tpWidget::showIpsec() | 251 | void L2tpWidget::showIpsec() | ||
208 | { | 252 | { | ||
209 | QPointer<L2tpIpsecWidget> ipsec; | 253 | QPointer<L2tpIpsecWidget> ipsec; | ||
210 | if (m_tmpIpsecSetting.isNull()) { | 254 | if (m_tmpIpsecSetting.isNull()) { | ||
211 | ipsec = new L2tpIpsecWidget(m_setting, this); | 255 | ipsec = new L2tpIpsecWidget(m_setting, this); | ||
212 | } else { | 256 | } else { | ||
Show All 17 Lines | 269 | connect(ipsec.data(), &L2tpIpsecWidget::finished, | |||
230 | }); | 274 | }); | ||
231 | ipsec->setModal(true); | 275 | ipsec->setModal(true); | ||
232 | ipsec->show(); | 276 | ipsec->show(); | ||
233 | } | 277 | } | ||
234 | 278 | | |||
235 | void L2tpWidget::showPpp() | 279 | void L2tpWidget::showPpp() | ||
236 | { | 280 | { | ||
237 | QPointer<L2tpPPPWidget> ipsec; | 281 | QPointer<L2tpPPPWidget> ipsec; | ||
282 | bool need_peer_eap = m_ui->cmbAuthType->currentIndex() != AuthType::Password; | ||||
238 | if (m_tmpPppSetting.isNull()) { | 283 | if (m_tmpPppSetting.isNull()) { | ||
239 | ipsec = new L2tpPPPWidget(m_setting, this); | 284 | ipsec = new L2tpPPPWidget(m_setting, this, need_peer_eap); | ||
240 | } else { | 285 | } else { | ||
241 | ipsec = new L2tpPPPWidget(m_tmpPppSetting, this); | 286 | ipsec = new L2tpPPPWidget(m_tmpPppSetting, this, need_peer_eap); | ||
242 | } | 287 | } | ||
243 | connect(ipsec.data(), &L2tpPPPWidget::accepted, | 288 | connect(ipsec.data(), &L2tpPPPWidget::accepted, | ||
244 | [ipsec, this] () { | 289 | [ipsec, this] () { | ||
245 | NMStringMap ipsecData = ipsec->setting(); | 290 | NMStringMap ipsecData = ipsec->setting(); | ||
246 | if (!ipsecData.isEmpty()) { | 291 | if (!ipsecData.isEmpty()) { | ||
247 | if (m_tmpPppSetting.isNull()) { | 292 | if (m_tmpPppSetting.isNull()) { | ||
248 | m_tmpPppSetting = NetworkManager::VpnSetting::Ptr(new NetworkManager::VpnSetting); | 293 | m_tmpPppSetting = NetworkManager::VpnSetting::Ptr(new NetworkManager::VpnSetting); | ||
249 | } | 294 | } | ||
Show All 9 Lines | |||||
259 | ipsec->setModal(true); | 304 | ipsec->setModal(true); | ||
260 | ipsec->show(); | 305 | ipsec->show(); | ||
261 | } | 306 | } | ||
262 | 307 | | |||
263 | bool L2tpWidget::isValid() const | 308 | bool L2tpWidget::isValid() const | ||
264 | { | 309 | { | ||
265 | return !m_ui->gateway->text().isEmpty(); | 310 | return !m_ui->gateway->text().isEmpty(); | ||
266 | } | 311 | } | ||
267 | | ||||
268 | void L2tpWidget::certStateChanged() | | |||
269 | { | | |||
270 | if (m_ui->cbUseCertificate->isChecked()) { | | |||
271 | m_ui->urCACertificate->setEnabled(true); | | |||
272 | m_ui->urCertificate->setEnabled(true); | | |||
273 | m_ui->urPrivateKey->setEnabled(true); | | |||
274 | m_ui->username->setEnabled(false); | | |||
275 | m_ui->password->setEnabled(false); | | |||
276 | m_ui->domain->setEnabled(false); | | |||
277 | } else { | | |||
278 | m_ui->urCACertificate->setEnabled(false); | | |||
279 | m_ui->urCertificate->setEnabled(false); | | |||
280 | m_ui->urPrivateKey->setEnabled(false); | | |||
281 | m_ui->username->setEnabled(true); | | |||
282 | m_ui->password->setEnabled(true); | | |||
283 | m_ui->domain->setEnabled(true); | | |||
284 | } | | |||
285 | } | |