NetworkManagerQt

wirelesssecuritysetting.cpp
1/*
2 SPDX-FileCopyrightText: 2012-2013 Jan Grulich <jgrulich@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "wirelesssecuritysetting.h"
8#include "wirelesssecuritysetting_p.h"
9
10#include <QDebug>
11
12#if !NM_CHECK_VERSION(1, 10, 0)
13#define NM_SETTING_WIRELESS_SECURITY_PMF "pmf"
14#endif
15
16NetworkManager::WirelessSecuritySettingPrivate::WirelessSecuritySettingPrivate()
17 : name(NM_SETTING_WIRELESS_SECURITY_SETTING_NAME)
18 , keyMgmt(NetworkManager::WirelessSecuritySetting::Unknown)
19 , wepTxKeyidx(0)
20 , authAlg(NetworkManager::WirelessSecuritySetting::None)
21 , wepKeyFlags(NetworkManager::Setting::None)
22 , wepKeyType(NetworkManager::WirelessSecuritySetting::NotSpecified)
23 , pskFlags(NetworkManager::Setting::None)
24 , leapPasswordFlags(NetworkManager::Setting::None)
25 , pmf(NetworkManager::WirelessSecuritySetting::DefaultPmf)
26{
27}
28
29NetworkManager::WirelessSecuritySetting::WirelessSecuritySetting()
30 : Setting(Setting::WirelessSecurity)
31 , d_ptr(new WirelessSecuritySettingPrivate())
32{
33}
34
35NetworkManager::WirelessSecuritySetting::WirelessSecuritySetting(const Ptr &other)
36 : Setting(other)
37 , d_ptr(new WirelessSecuritySettingPrivate())
38{
39 setKeyMgmt(other->keyMgmt());
40 setWepTxKeyindex(other->wepTxKeyindex());
41 setAuthAlg(other->authAlg());
42 setProto(other->proto());
43 setPairwise(other->pairwise());
44 setGroup(other->group());
45 setWepKey0(other->wepKey0());
46 setWepKey1(other->wepKey1());
47 setWepKey2(other->wepKey2());
48 setWepKey3(other->wepKey3());
49 setWepKeyFlags(other->wepKeyFlags());
50 setWepKeyType(other->wepKeyType());
51 setPsk(other->psk());
52 setPskFlags(other->pskFlags());
53 setLeapPassword(other->leapPassword());
54 setLeapPasswordFlags(other->leapPasswordFlags());
55 setPmf(other->pmf());
56}
57
58NetworkManager::WirelessSecuritySetting::~WirelessSecuritySetting()
59{
60 delete d_ptr;
61}
62
69
70void NetworkManager::WirelessSecuritySetting::setKeyMgmt(NetworkManager::WirelessSecuritySetting::KeyMgmt mgmt)
71{
73
74 d->keyMgmt = mgmt;
75}
76
77NetworkManager::WirelessSecuritySetting::KeyMgmt NetworkManager::WirelessSecuritySetting::keyMgmt() const
78{
79 Q_D(const WirelessSecuritySetting);
80
81 return d->keyMgmt;
82}
83
84void NetworkManager::WirelessSecuritySetting::setWepTxKeyindex(quint32 index)
85{
86 Q_D(WirelessSecuritySetting);
87
88 d->wepTxKeyidx = index;
89}
90
91quint32 NetworkManager::WirelessSecuritySetting::wepTxKeyindex() const
92{
93 Q_D(const WirelessSecuritySetting);
94
95 return d->wepTxKeyidx;
96}
97
98void NetworkManager::WirelessSecuritySetting::setAuthAlg(NetworkManager::WirelessSecuritySetting::AuthAlg alg)
99{
100 Q_D(WirelessSecuritySetting);
101
102 d->authAlg = alg;
103}
104
105NetworkManager::WirelessSecuritySetting::AuthAlg NetworkManager::WirelessSecuritySetting::authAlg() const
106{
107 Q_D(const WirelessSecuritySetting);
108
109 return d->authAlg;
110}
111
112void NetworkManager::WirelessSecuritySetting::setProto(const QList<NetworkManager::WirelessSecuritySetting::WpaProtocolVersion> &list)
113{
114 Q_D(WirelessSecuritySetting);
115
116 d->proto = list;
117}
118
119QList<NetworkManager::WirelessSecuritySetting::WpaProtocolVersion> NetworkManager::WirelessSecuritySetting::proto() const
120{
121 Q_D(const WirelessSecuritySetting);
122
123 return d->proto;
124}
125
126void NetworkManager::WirelessSecuritySetting::setPairwise(const QList<NetworkManager::WirelessSecuritySetting::WpaEncryptionCapabilities> &list)
127{
128 Q_D(WirelessSecuritySetting);
129
130 d->pairwise = list;
131}
132
133QList<NetworkManager::WirelessSecuritySetting::WpaEncryptionCapabilities> NetworkManager::WirelessSecuritySetting::pairwise() const
134{
135 Q_D(const WirelessSecuritySetting);
136
137 return d->pairwise;
138}
139
140void NetworkManager::WirelessSecuritySetting::setGroup(const QList<NetworkManager::WirelessSecuritySetting::WpaEncryptionCapabilities> &list)
141{
142 Q_D(WirelessSecuritySetting);
143
144 d->group = list;
145}
146
147QList<NetworkManager::WirelessSecuritySetting::WpaEncryptionCapabilities> NetworkManager::WirelessSecuritySetting::group() const
148{
149 Q_D(const WirelessSecuritySetting);
150
151 return d->group;
152}
153
154void NetworkManager::WirelessSecuritySetting::setLeapUsername(const QString &username)
155{
156 Q_D(WirelessSecuritySetting);
157
158 d->leapUsername = username;
159}
160
161QString NetworkManager::WirelessSecuritySetting::leapUsername() const
162{
163 Q_D(const WirelessSecuritySetting);
164
165 return d->leapUsername;
166}
167
168void NetworkManager::WirelessSecuritySetting::setWepKey0(const QString key)
169{
170 Q_D(WirelessSecuritySetting);
171
172 d->wepKey0 = key;
173}
174
175QString NetworkManager::WirelessSecuritySetting::wepKey0() const
176{
177 Q_D(const WirelessSecuritySetting);
178
179 return d->wepKey0;
180}
181
182void NetworkManager::WirelessSecuritySetting::setWepKey1(const QString key)
183{
184 Q_D(WirelessSecuritySetting);
185
186 d->wepKey1 = key;
187}
188
189QString NetworkManager::WirelessSecuritySetting::wepKey1() const
190{
191 Q_D(const WirelessSecuritySetting);
192
193 return d->wepKey1;
194}
195
196void NetworkManager::WirelessSecuritySetting::setWepKey2(const QString key)
197{
198 Q_D(WirelessSecuritySetting);
199
200 d->wepKey2 = key;
201}
202
203QString NetworkManager::WirelessSecuritySetting::wepKey2() const
204{
205 Q_D(const WirelessSecuritySetting);
206
207 return d->wepKey2;
208}
209
210void NetworkManager::WirelessSecuritySetting::setWepKey3(const QString key)
211{
212 Q_D(WirelessSecuritySetting);
213
214 d->wepKey3 = key;
215}
216
217QString NetworkManager::WirelessSecuritySetting::wepKey3() const
218{
219 Q_D(const WirelessSecuritySetting);
220
221 return d->wepKey3;
222}
223
224void NetworkManager::WirelessSecuritySetting::setWepKeyFlags(NetworkManager::Setting::SecretFlags type)
225{
226 Q_D(WirelessSecuritySetting);
227
228 d->wepKeyFlags = type;
229}
230
231NetworkManager::Setting::SecretFlags NetworkManager::WirelessSecuritySetting::wepKeyFlags() const
232{
233 Q_D(const WirelessSecuritySetting);
234
235 return d->wepKeyFlags;
236}
237
238void NetworkManager::WirelessSecuritySetting::setWepKeyType(NetworkManager::WirelessSecuritySetting::WepKeyType type)
239{
240 Q_D(WirelessSecuritySetting);
241
242 d->wepKeyType = type;
243}
244
245NetworkManager::WirelessSecuritySetting::WepKeyType NetworkManager::WirelessSecuritySetting::wepKeyType() const
246{
247 Q_D(const WirelessSecuritySetting);
248
249 return d->wepKeyType;
250}
251
252void NetworkManager::WirelessSecuritySetting::setPsk(const QString &key)
253{
254 Q_D(WirelessSecuritySetting);
255
256 d->psk = key;
257}
258
259QString NetworkManager::WirelessSecuritySetting::psk() const
260{
261 Q_D(const WirelessSecuritySetting);
262
263 return d->psk;
264}
265
266void NetworkManager::WirelessSecuritySetting::setPskFlags(NetworkManager::Setting::SecretFlags type)
267{
268 Q_D(WirelessSecuritySetting);
269
270 d->pskFlags = type;
271}
272
273NetworkManager::Setting::SecretFlags NetworkManager::WirelessSecuritySetting::pskFlags() const
274{
275 Q_D(const WirelessSecuritySetting);
276
277 return d->pskFlags;
278}
279
280void NetworkManager::WirelessSecuritySetting::setLeapPassword(const QString &password)
281{
282 Q_D(WirelessSecuritySetting);
283
284 d->leapPassword = password;
285}
286
287QString NetworkManager::WirelessSecuritySetting::leapPassword() const
288{
289 Q_D(const WirelessSecuritySetting);
290
291 return d->leapPassword;
292}
293
294void NetworkManager::WirelessSecuritySetting::setLeapPasswordFlags(NetworkManager::Setting::SecretFlags type)
295{
296 Q_D(WirelessSecuritySetting);
297
298 d->leapPasswordFlags = type;
299}
300
301NetworkManager::Setting::SecretFlags NetworkManager::WirelessSecuritySetting::leapPasswordFlags() const
302{
303 Q_D(const WirelessSecuritySetting);
304
305 return d->leapPasswordFlags;
306}
307
308void NetworkManager::WirelessSecuritySetting::setPmf(NetworkManager::WirelessSecuritySetting::Pmf pmf)
309{
310 Q_D(WirelessSecuritySetting);
311
312 d->pmf = pmf;
313}
314
315NetworkManager::WirelessSecuritySetting::Pmf NetworkManager::WirelessSecuritySetting::pmf() const
316{
317 Q_D(const WirelessSecuritySetting);
318
319 return d->pmf;
320}
321
322void NetworkManager::WirelessSecuritySetting::secretsFromMap(const QVariantMap &secrets)
323{
324 if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0))) {
325 setWepKey0(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)).toString());
326 }
327
328 if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1))) {
329 setWepKey1(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)).toString());
330 }
331
332 if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2))) {
333 setWepKey2(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)).toString());
334 }
335
336 if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3))) {
337 setWepKey3(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)).toString());
338 }
339
340 if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK))) {
341 setPsk(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK)).toString());
342 }
343
344 if (secrets.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD))) {
345 setLeapPassword(secrets.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD)).toString());
346 }
347}
348
349QVariantMap NetworkManager::WirelessSecuritySetting::secretsToMap() const
350{
351 QVariantMap secrets;
352
353 if (!wepKey0().isEmpty()) {
354 secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), wepKey0());
355 }
356
357 if (!wepKey1().isEmpty()) {
358 secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), wepKey1());
359 }
360
361 if (!wepKey2().isEmpty()) {
362 secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), wepKey2());
363 }
364
365 if (!wepKey3().isEmpty()) {
366 secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), wepKey3());
367 }
368
369 if (!psk().isEmpty()) {
370 secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK), psk());
371 }
372
373 if (!leapPassword().isEmpty()) {
374 secrets.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), leapPassword());
375 }
376
377 return secrets;
378}
379
380QStringList NetworkManager::WirelessSecuritySetting::needSecrets(bool requestNew) const
381{
382 QStringList secrets;
383
384 if (keyMgmt() == Wep) {
385 if (!wepKeyFlags().testFlag(Setting::NotRequired)) {
386 switch (wepTxKeyindex()) {
387 case 0:
388 if (wepKey0().isEmpty() || requestNew) {
389 secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
390 return secrets;
391 }
392 break;
393 case 1:
394 if (wepKey1().isEmpty() || requestNew) {
395 secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1);
396 return secrets;
397 }
398 break;
399 case 2:
400 if (wepKey2().isEmpty() || requestNew) {
401 secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2);
402 return secrets;
403 }
404 break;
405 case 3:
406 if (wepKey3().isEmpty() || requestNew) {
407 secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
408 return secrets;
409 }
410 break;
411 }
412 }
413 }
414
415 if (keyMgmt() == WpaNone || keyMgmt() == WpaPsk || keyMgmt() == SAE) {
416 if (!pskFlags().testFlag(Setting::NotRequired)) {
417 if (psk().isEmpty() || requestNew) {
418 secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK);
419 return secrets;
420 }
421 }
422 }
423
424 if (authAlg() == Leap && keyMgmt() == Ieee8021x) {
425 if (!leapPasswordFlags().testFlag(Setting::NotRequired)) {
426 if (leapPassword().isEmpty() || requestNew) {
427 secrets << QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD);
428 return secrets;
429 }
430 }
431 }
432
433 return secrets;
434}
435
437{
438 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT))) {
439 const QString key = map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT)).toString();
440 if (key == "none") {
441 setKeyMgmt(Wep);
442 } else if (key == "ieee8021x") {
443 setKeyMgmt(Ieee8021x);
444 } else if (key == "wpa-none") {
445 setKeyMgmt(WpaNone);
446 } else if (key == "wpa-psk") {
447 setKeyMgmt(WpaPsk);
448 } else if (key == "wpa-eap") {
449 setKeyMgmt(WpaEap);
450 } else if (key == "sae") {
451 setKeyMgmt(SAE);
452 } else if (key == "wpa-eap-suite-b-192") {
453 setKeyMgmt(WpaEapSuiteB192);
454 } else if (key == "owe") {
455 setKeyMgmt(OWE);
456 }
457 }
458
459 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX))) {
460 setWepTxKeyindex(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX)).toUInt());
461 }
462
463 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG))) {
464 const QString alg = map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG)).toString();
465 if (alg == "open") {
466 setAuthAlg(Open);
467 } else if (alg == "shared") {
468 setAuthAlg(Shared);
469 } else if (alg == "leap") {
470 setAuthAlg(Leap);
471 }
472 }
473
474 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PROTO))) {
475 const QStringList strList = map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PROTO)).toStringList();
477 for (const QString &str : strList) {
478 if (str == "wpa") {
479 list.push_back(Wpa);
480 } else if (str == "rsn") {
481 list.push_back(Rsn);
482 }
483 }
484 setProto(list);
485 }
486
487 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PAIRWISE))) {
488 const QStringList strList = map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PAIRWISE)).toStringList();
490 for (const QString &str : strList) {
491 if (str == "wep40") {
492 list.push_back(Wep40);
493 } else if (str == "wep104") {
494 list.push_back(Wep104);
495 } else if (str == "tkip") {
496 list.push_back(Tkip);
497 } else if (str == "ccmp") {
498 list.push_back(Ccmp);
499 }
500 }
501 setPairwise(list);
502 }
503
504 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_GROUP))) {
505 const QStringList strList = map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_GROUP)).toStringList();
507 for (const QString &str : strList) {
508 if (str == "wep40") {
509 list.push_back(Wep40);
510 } else if (str == "wep104") {
511 list.push_back(Wep104);
512 } else if (str == "tkip") {
513 list.push_back(Tkip);
514 } else if (str == "ccmp") {
515 list.push_back(Ccmp);
516 }
517 }
518 setGroup(list);
519 }
520
521 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME))) {
522 setLeapUsername(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME)).toString());
523 }
524
525 // Secrets
526 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0))) {
527 setWepKey0(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0)).toString());
528 }
529
530 // Secrets
531 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1))) {
532 setWepKey1(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1)).toString());
533 }
534
535 // Secrets
536 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2))) {
537 setWepKey2(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2)).toString());
538 }
539
540 // Secrets
541 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3))) {
542 setWepKey3(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3)).toString());
543 }
544
545 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS))) {
546 setWepKeyFlags((SecretFlags)map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS)).toInt());
547 }
548
549 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE))) {
550 setWepKeyType((WepKeyType)map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE)).toUInt());
551 }
552
553 // Secrets
554 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK))) {
555 setPsk(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK)).toString());
556 }
557
558 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS))) {
559 setPskFlags((SecretFlags)map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS)).toInt());
560 }
561
562 // Secrets
563 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD))) {
564 setLeapPassword(map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD)).toString());
565 }
566
567 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS))) {
568 setLeapPasswordFlags((SecretFlags)map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS)).toInt());
569 }
570
571 if (map.contains(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PMF))) {
572 setPmf((Pmf)map.value(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PMF)).toInt());
573 }
574}
575
577{
578 QVariantMap setting;
579
580 if (keyMgmt() == Wep) {
581 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "none");
582 } else if (keyMgmt() == Ieee8021x) {
583 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "ieee8021x");
584 } else if (keyMgmt() == WpaNone) {
585 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-none");
586 } else if (keyMgmt() == WpaPsk) {
587 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-psk");
588 } else if (keyMgmt() == WpaEap) {
589 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-eap");
590 } else if (keyMgmt() == SAE) {
591 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "sae");
592 } else if (keyMgmt() == WpaEapSuiteB192) {
593 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "wpa-eap-suite-b-192");
594 } else if (keyMgmt() == OWE) {
595 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), "owe");
596 }
597
598 if (wepTxKeyindex()) {
599 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX), wepTxKeyindex());
600 }
601
602 if (authAlg() != None) {
603 if (authAlg() == Open) {
604 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "open");
605 } else if (authAlg() == Shared) {
606 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "shared");
607 } else if (authAlg() == Leap) {
608 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), "leap");
609 }
610 }
611
612 if (!proto().isEmpty()) {
613 QStringList strList;
614 const auto protoList = proto();
615 for (const WpaProtocolVersion &version : protoList) {
616 if (version == Wpa) {
617 strList << "wpa";
618 } else if (version == Rsn) {
619 strList << "rsn";
620 }
621 }
622 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PROTO), strList);
623 }
624
625 if (!pairwise().isEmpty()) {
626 QStringList strList;
627 const auto encryptions = pairwise();
628 for (const WpaEncryptionCapabilities &capability : encryptions) {
629 if (capability == Wep40) {
630 strList << "wep40";
631 } else if (capability == Wep104) {
632 strList << "wep104";
633 } else if (capability == Tkip) {
634 strList << "tkip";
635 } else if (capability == Ccmp) {
636 strList << "ccmp";
637 }
638 }
639 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PAIRWISE), strList);
640 }
641
642 if (!group().isEmpty()) {
643 QStringList strList;
644 const auto encryptions = group();
645 for (const WpaEncryptionCapabilities &capability : encryptions) {
646 if (capability == Wep40) {
647 strList << "wep40";
648 } else if (capability == Wep104) {
649 strList << "wep104";
650 } else if (capability == Tkip) {
651 strList << "tkip";
652 } else if (capability == Ccmp) {
653 strList << "ccmp";
654 }
655 }
656 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_GROUP), strList);
657 }
658
659 if (!leapUsername().isEmpty()) {
660 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME), leapUsername());
661 }
662
663 // Secrets
664 if (!wepKey0().isEmpty()) {
665 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), wepKey0());
666 }
667
668 // Secrets
669 if (!wepKey1().isEmpty()) {
670 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), wepKey1());
671 }
672
673 // Secrets
674 if (!wepKey2().isEmpty()) {
675 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), wepKey2());
676 }
677
678 // Secrets
679 if (!wepKey3().isEmpty()) {
680 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), wepKey3());
681 }
682
683 if (wepKeyFlags()) {
684 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS), (int)wepKeyFlags());
685 }
686
687 if (wepKeyType()) {
688 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE), wepKeyType());
689 }
690
691 // Secrets
692 if (!psk().isEmpty()) {
693 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK), psk());
694 }
695
696 if (pskFlags()) {
697 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS), (int)pskFlags());
698 }
699
700 // Secrets
701 if (!leapPassword().isEmpty()) {
702 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), leapPassword());
703 }
704
705 if (leapPasswordFlags()) {
706 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS), (int)leapPasswordFlags());
707 }
708
709 if (pmf()) {
710 setting.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PMF), (int)pmf());
711 }
712
713 return setting;
714}
715
716QDebug NetworkManager::operator<<(QDebug dbg, const NetworkManager::WirelessSecuritySetting &setting)
717{
718 dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n';
719 dbg.nospace() << "initialized: " << !setting.isNull() << '\n';
720
721 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_KEY_MGMT << ": " << setting.keyMgmt() << '\n';
722 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX << ": " << setting.wepTxKeyindex() << '\n';
723 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_AUTH_ALG << ": " << setting.authAlg() << '\n';
724 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_PROTO << ": " << setting.proto() << '\n';
725 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_PAIRWISE << ": " << setting.pairwise() << '\n';
726 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_GROUP << ": " << setting.group() << '\n';
727 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME << ": " << setting.leapUsername() << '\n';
728 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY0 << ": " << setting.wepKey0() << '\n';
729 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY1 << ": " << setting.wepKey1() << '\n';
730 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY2 << ": " << setting.wepKey2() << '\n';
731 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY3 << ": " << setting.wepKey3() << '\n';
732 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS << ": " << setting.wepKeyFlags() << '\n';
733 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE << ": " << setting.wepKeyType() << '\n';
734 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_PSK << ": " << setting.psk() << '\n';
735 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS << ": " << setting.pskFlags() << '\n';
736 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD << ": " << setting.leapPassword() << '\n';
737 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS << ": " << setting.leapPasswordFlags() << '\n';
738 dbg.nospace() << NM_SETTING_WIRELESS_SECURITY_PMF << ": " << setting.pmf() << '\n';
739
740 return dbg.maybeSpace();
741}
Represents wireless security setting.
QString name() const override
Must be reimplemented, default implementationd does nothing.
void fromMap(const QVariantMap &map) override
Must be reimplemented, default implementation does nothing.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
Type type(const QSqlDatabase &db)
char * toString(const EngineQuery &query)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
This class allows querying the underlying system to discover the available network interfaces and rea...
Definition accesspoint.h:21
NETWORKMANAGERQT_EXPORT QString version()
Get the NetworkManager version.
Definition manager.cpp:966
QDebug & maybeSpace()
QDebug & nospace()
iterator insert(const_iterator before, parameter_type value)
void push_back(parameter_type value)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 11:50:42 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.