NetworkManagerQt

pppsetting.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 "pppsetting.h"
8#include "pppsetting_p.h"
9
10#include <QDebug>
11
12NetworkManager::PppSettingPrivate::PppSettingPrivate()
13 : name(NM_SETTING_PPP_SETTING_NAME)
14 , noauth(true)
15 , refuseEap(false)
16 , refusePap(false)
17 , refuseChap(false)
18 , refuseMschap(false)
19 , refuseMschapv2(false)
20 , nobsdcomp(false)
21 , nodeflate(false)
22 , noVjComp(false)
23 , requireMppe(false)
24 , requireMppe128(false)
25 , mppeStateful(false)
26 , crtscts(false)
27 , baud(0)
28 , mru(0)
29 , mtu(0)
30 , lcpEchoFailure(0)
31 , lcpEchoInterval(0)
32{
33}
34
35NetworkManager::PppSetting::PppSetting()
36 : Setting(Setting::Ppp)
37 , d_ptr(new PppSettingPrivate())
38{
39}
40
41NetworkManager::PppSetting::PppSetting(const Ptr &other)
42 : Setting(other)
43 , d_ptr(new PppSettingPrivate())
44{
45 setNoAuth(other->noAuth());
46 setRefuseEap(other->refuseEap());
47 setRefusePap(other->refusePap());
48 setRefuseChap(other->refuseChap());
49 setRefuseMschap(other->refuseMschap());
50 setRefuseMschapv2(other->refuseMschapv2());
51 setNoBsdComp(other->noBsdComp());
52 setNoDeflate(other->noDeflate());
53 setNoVjComp(other->noVjComp());
54 setRequireMppe(other->requireMppe());
55 setRequireMppe128(other->requireMppe128());
56 setMppeStateful(other->mppeStateful());
57 setCRtsCts(other->cRtsCts());
58 setBaud(other->baud());
59 setMru(other->mru());
60 setMtu(other->mtu());
61 setLcpEchoFailure(other->lcpEchoFailure());
62 setLcpEchoInterval(other->lcpEchoInterval());
63}
64
65NetworkManager::PppSetting::~PppSetting()
66{
67 delete d_ptr;
68}
69
71{
72 Q_D(const PppSetting);
73
74 return d->name;
75}
76
77void NetworkManager::PppSetting::setNoAuth(bool require)
78{
80
81 d->noauth = require;
82}
83
84bool NetworkManager::PppSetting::noAuth() const
85{
86 Q_D(const PppSetting);
87
88 return d->noauth;
89}
90
91void NetworkManager::PppSetting::setRefuseEap(bool refuse)
92{
93 Q_D(PppSetting);
94
95 d->refuseEap = refuse;
96}
97
98bool NetworkManager::PppSetting::refuseEap() const
99{
100 Q_D(const PppSetting);
101
102 return d->refuseEap;
103}
104
105void NetworkManager::PppSetting::setRefusePap(bool refuse)
106{
107 Q_D(PppSetting);
108
109 d->refusePap = refuse;
110}
111
112bool NetworkManager::PppSetting::refusePap() const
113{
114 Q_D(const PppSetting);
115
116 return d->refusePap;
117}
118
119void NetworkManager::PppSetting::setRefuseChap(bool refuse)
120{
121 Q_D(PppSetting);
122
123 d->refuseChap = refuse;
124}
125
126bool NetworkManager::PppSetting::refuseChap() const
127{
128 Q_D(const PppSetting);
129
130 return d->refuseChap;
131}
132
133void NetworkManager::PppSetting::setRefuseMschap(bool refuse)
134{
135 Q_D(PppSetting);
136
137 d->refuseMschap = refuse;
138}
139
140bool NetworkManager::PppSetting::refuseMschap() const
141{
142 Q_D(const PppSetting);
143
144 return d->refuseMschap;
145}
146
147void NetworkManager::PppSetting::setRefuseMschapv2(bool refuse)
148{
149 Q_D(PppSetting);
150
151 d->refuseMschapv2 = refuse;
152}
153
154bool NetworkManager::PppSetting::refuseMschapv2() const
155{
156 Q_D(const PppSetting);
157
158 return d->refuseMschapv2;
159}
160
161void NetworkManager::PppSetting::setNoBsdComp(bool require)
162{
163 Q_D(PppSetting);
164
165 d->nobsdcomp = require;
166}
167
168bool NetworkManager::PppSetting::noBsdComp() const
169{
170 Q_D(const PppSetting);
171
172 return d->nobsdcomp;
173}
174
175void NetworkManager::PppSetting::setNoDeflate(bool require)
176{
177 Q_D(PppSetting);
178
179 d->nodeflate = require;
180}
181
182bool NetworkManager::PppSetting::noDeflate() const
183{
184 Q_D(const PppSetting);
185
186 return d->nodeflate;
187}
188
189void NetworkManager::PppSetting::setNoVjComp(bool require)
190{
191 Q_D(PppSetting);
192
193 d->noVjComp = require;
194}
195
196bool NetworkManager::PppSetting::noVjComp() const
197{
198 Q_D(const PppSetting);
199
200 return d->noVjComp;
201}
202
203void NetworkManager::PppSetting::setRequireMppe(bool require)
204{
205 Q_D(PppSetting);
206
207 d->requireMppe = require;
208}
209
210bool NetworkManager::PppSetting::requireMppe() const
211{
212 Q_D(const PppSetting);
213
214 return d->requireMppe;
215}
216
217void NetworkManager::PppSetting::setRequireMppe128(bool require)
218{
219 Q_D(PppSetting);
220
221 d->requireMppe128 = require;
222}
223
224bool NetworkManager::PppSetting::requireMppe128() const
225{
226 Q_D(const PppSetting);
227
228 return d->requireMppe128;
229}
230
231void NetworkManager::PppSetting::setMppeStateful(bool used)
232{
233 Q_D(PppSetting);
234
235 d->mppeStateful = used;
236}
237
238bool NetworkManager::PppSetting::mppeStateful() const
239{
240 Q_D(const PppSetting);
241
242 return d->mppeStateful;
243}
244
245void NetworkManager::PppSetting::setCRtsCts(bool control)
246{
247 Q_D(PppSetting);
248
249 d->crtscts = control;
250}
251
252bool NetworkManager::PppSetting::cRtsCts() const
253{
254 Q_D(const PppSetting);
255
256 return d->crtscts;
257}
258
259void NetworkManager::PppSetting::setBaud(quint32 baud)
260{
261 Q_D(PppSetting);
262
263 d->baud = baud;
264}
265
266quint32 NetworkManager::PppSetting::baud() const
267{
268 Q_D(const PppSetting);
269
270 return d->baud;
271}
272
273void NetworkManager::PppSetting::setMru(quint32 mru)
274{
275 Q_D(PppSetting);
276
277 d->mru = mru;
278}
279
280quint32 NetworkManager::PppSetting::mru() const
281{
282 Q_D(const PppSetting);
283
284 return d->mru;
285}
286
287void NetworkManager::PppSetting::setMtu(quint32 mtu)
288{
289 Q_D(PppSetting);
290
291 d->mtu = mtu;
292}
293
294quint32 NetworkManager::PppSetting::mtu() const
295{
296 Q_D(const PppSetting);
297
298 return d->mtu;
299}
300
301void NetworkManager::PppSetting::setLcpEchoFailure(quint32 number)
302{
303 Q_D(PppSetting);
304
305 d->lcpEchoFailure = number;
306}
307
308quint32 NetworkManager::PppSetting::lcpEchoFailure() const
309{
310 Q_D(const PppSetting);
311
312 return d->lcpEchoFailure;
313}
314
315void NetworkManager::PppSetting::setLcpEchoInterval(quint32 interval)
316{
317 Q_D(PppSetting);
318
319 d->lcpEchoInterval = interval;
320}
321
322quint32 NetworkManager::PppSetting::lcpEchoInterval() const
323{
324 Q_D(const PppSetting);
325
326 return d->lcpEchoInterval;
327}
328
329void NetworkManager::PppSetting::fromMap(const QVariantMap &setting)
330{
331 if (setting.contains(QLatin1String(NM_SETTING_PPP_NOAUTH))) {
332 setNoAuth(setting.value(QLatin1String(NM_SETTING_PPP_NOAUTH)).toBool());
333 }
334
335 if (setting.contains(QLatin1String(NM_SETTING_PPP_REFUSE_EAP))) {
336 setRefuseEap(setting.value(QLatin1String(NM_SETTING_PPP_REFUSE_EAP)).toBool());
337 }
338
339 if (setting.contains(QLatin1String(NM_SETTING_PPP_REFUSE_PAP))) {
340 setRefusePap(setting.value(QLatin1String(NM_SETTING_PPP_REFUSE_PAP)).toBool());
341 }
342
343 if (setting.contains(QLatin1String(NM_SETTING_PPP_REFUSE_CHAP))) {
344 setRefuseChap(setting.value(QLatin1String(NM_SETTING_PPP_REFUSE_CHAP)).toBool());
345 }
346
347 if (setting.contains(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAP))) {
348 setRefuseMschap(setting.value(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAP)).toBool());
349 }
350
351 if (setting.contains(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAPV2))) {
352 setRefuseMschapv2(setting.value(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAPV2)).toBool());
353 }
354
355 if (setting.contains(QLatin1String(NM_SETTING_PPP_NOBSDCOMP))) {
356 setNoBsdComp(setting.value(QLatin1String(NM_SETTING_PPP_NOBSDCOMP)).toBool());
357 }
358
359 if (setting.contains(QLatin1String(NM_SETTING_PPP_NODEFLATE))) {
360 setNoDeflate(setting.value(QLatin1String(NM_SETTING_PPP_NODEFLATE)).toBool());
361 }
362
363 if (setting.contains(QLatin1String(NM_SETTING_PPP_NO_VJ_COMP))) {
364 setNoVjComp(setting.value(QLatin1String(NM_SETTING_PPP_NO_VJ_COMP)).toBool());
365 }
366
367 if (setting.contains(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE))) {
368 setRequireMppe(setting.value(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE)).toBool());
369 }
370
371 if (setting.contains(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE_128))) {
372 setRequireMppe128(setting.value(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE_128)).toBool());
373 }
374
375 if (setting.contains(QLatin1String(NM_SETTING_PPP_MPPE_STATEFUL))) {
376 setMppeStateful(setting.value(QLatin1String(NM_SETTING_PPP_MPPE_STATEFUL)).toBool());
377 }
378
379 if (setting.contains(QLatin1String(NM_SETTING_PPP_CRTSCTS))) {
380 setCRtsCts(setting.value(QLatin1String(NM_SETTING_PPP_CRTSCTS)).toBool());
381 }
382
383 if (setting.contains(QLatin1String(NM_SETTING_PPP_BAUD))) {
384 setBaud(setting.value(QLatin1String(NM_SETTING_PPP_BAUD)).toUInt());
385 }
386
387 if (setting.contains(QLatin1String(NM_SETTING_PPP_MRU))) {
388 setMru(setting.value(QLatin1String(NM_SETTING_PPP_MRU)).toUInt());
389 }
390
391 if (setting.contains(QLatin1String(NM_SETTING_PPP_MTU))) {
392 setMtu(setting.value(QLatin1String(NM_SETTING_PPP_MTU)).toUInt());
393 }
394
395 if (setting.contains(QLatin1String(NM_SETTING_PPP_LCP_ECHO_FAILURE))) {
396 setLcpEchoFailure(setting.value(QLatin1String(NM_SETTING_PPP_LCP_ECHO_FAILURE)).toUInt());
397 }
398
399 if (setting.contains(QLatin1String(NM_SETTING_PPP_LCP_ECHO_INTERVAL))) {
400 setLcpEchoInterval(setting.value(QLatin1String(NM_SETTING_PPP_LCP_ECHO_INTERVAL)).toUInt());
401 }
402}
403
405{
406 QVariantMap setting;
407
408 if (!noAuth()) {
409 setting.insert(QLatin1String(NM_SETTING_PPP_NOAUTH), noAuth());
410 }
411
412 if (refuseEap()) {
413 setting.insert(QLatin1String(NM_SETTING_PPP_REFUSE_EAP), refuseEap());
414 }
415
416 if (refusePap()) {
417 setting.insert(QLatin1String(NM_SETTING_PPP_REFUSE_PAP), refusePap());
418 }
419
420 if (refuseChap()) {
421 setting.insert(QLatin1String(NM_SETTING_PPP_REFUSE_CHAP), refuseChap());
422 }
423
424 if (refuseMschap()) {
425 setting.insert(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAP), refuseMschap());
426 }
427
428 if (refuseMschapv2()) {
429 setting.insert(QLatin1String(NM_SETTING_PPP_REFUSE_MSCHAPV2), refuseMschapv2());
430 }
431
432 if (noBsdComp()) {
433 setting.insert(QLatin1String(NM_SETTING_PPP_NOBSDCOMP), noBsdComp());
434 }
435
436 if (noDeflate()) {
437 setting.insert(QLatin1String(NM_SETTING_PPP_NODEFLATE), noDeflate());
438 }
439
440 if (noVjComp()) {
441 setting.insert(QLatin1String(NM_SETTING_PPP_NO_VJ_COMP), noVjComp());
442 }
443
444 if (requireMppe()) {
445 setting.insert(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE), requireMppe());
446 }
447
448 if (requireMppe128()) {
449 setting.insert(QLatin1String(NM_SETTING_PPP_REQUIRE_MPPE_128), requireMppe128());
450 }
451
452 if (mppeStateful()) {
453 setting.insert(QLatin1String(NM_SETTING_PPP_MPPE_STATEFUL), mppeStateful());
454 }
455
456 if (cRtsCts()) {
457 setting.insert(QLatin1String(NM_SETTING_PPP_CRTSCTS), cRtsCts());
458 }
459
460 if (baud()) {
461 setting.insert(QLatin1String(NM_SETTING_PPP_BAUD), baud());
462 }
463
464 if (mru()) {
465 setting.insert(QLatin1String(NM_SETTING_PPP_MRU), mru());
466 }
467
468 if (mtu()) {
469 setting.insert(QLatin1String(NM_SETTING_PPP_MTU), mtu());
470 }
471
472 if (lcpEchoFailure()) {
473 setting.insert(QLatin1String(NM_SETTING_PPP_LCP_ECHO_FAILURE), lcpEchoFailure());
474 }
475
476 if (lcpEchoInterval()) {
477 setting.insert(QLatin1String(NM_SETTING_PPP_LCP_ECHO_INTERVAL), lcpEchoInterval());
478 }
479
480 return setting;
481}
482
483QDebug NetworkManager::operator<<(QDebug dbg, const NetworkManager::PppSetting &setting)
484{
485 dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n';
486 dbg.nospace() << "initialized: " << !setting.isNull() << '\n';
487
488 dbg.nospace() << NM_SETTING_PPP_NOAUTH << ": " << setting.noAuth() << '\n';
489 dbg.nospace() << NM_SETTING_PPP_REFUSE_EAP << ": " << setting.refuseEap() << '\n';
490 dbg.nospace() << NM_SETTING_PPP_REFUSE_PAP << ": " << setting.refusePap() << '\n';
491 dbg.nospace() << NM_SETTING_PPP_REFUSE_CHAP << ": " << setting.refuseChap() << '\n';
492 dbg.nospace() << NM_SETTING_PPP_REFUSE_MSCHAP << ": " << setting.refuseMschap() << '\n';
493 dbg.nospace() << NM_SETTING_PPP_REFUSE_MSCHAPV2 << ": " << setting.refuseMschapv2() << '\n';
494 dbg.nospace() << NM_SETTING_PPP_NOBSDCOMP << ": " << setting.noBsdComp() << '\n';
495 dbg.nospace() << NM_SETTING_PPP_NODEFLATE << ": " << setting.noDeflate() << '\n';
496 dbg.nospace() << NM_SETTING_PPP_NO_VJ_COMP << ": " << setting.noVjComp() << '\n';
497 dbg.nospace() << NM_SETTING_PPP_REQUIRE_MPPE << ": " << setting.requireMppe() << '\n';
498 dbg.nospace() << NM_SETTING_PPP_REQUIRE_MPPE_128 << ": " << setting.requireMppe128() << '\n';
499 dbg.nospace() << NM_SETTING_PPP_MPPE_STATEFUL << ": " << setting.mppeStateful() << '\n';
500 dbg.nospace() << NM_SETTING_PPP_CRTSCTS << ": " << setting.cRtsCts() << '\n';
501 dbg.nospace() << NM_SETTING_PPP_BAUD << ": " << setting.baud() << '\n';
502 dbg.nospace() << NM_SETTING_PPP_MRU << ": " << setting.mru() << '\n';
503 dbg.nospace() << NM_SETTING_PPP_MTU << ": " << setting.mtu() << '\n';
504 dbg.nospace() << NM_SETTING_PPP_LCP_ECHO_FAILURE << ": " << setting.lcpEchoFailure() << '\n';
505 dbg.nospace() << NM_SETTING_PPP_LCP_ECHO_INTERVAL << ": " << setting.lcpEchoInterval() << '\n';
506
507 return dbg.maybeSpace();
508}
Represents ppp setting.
Definition pppsetting.h:23
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
QString name() const override
Must be reimplemented, default implementationd does nothing.
KIOCORE_EXPORT QString number(KIO::filesize_t size)
QDebug & maybeSpace()
QDebug & nospace()
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:01:06 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.