File indexing completed on 2024-07-21 07:58:05

0001 /*
0002     SPDX-FileCopyrightText: 2013 Lukas Tinkl <ltinkl@redhat.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #include "pppwidget.h"
0008 #include "ui_ppp.h"
0009 
0010 #include <NetworkManagerQt/PppSetting>
0011 
0012 PPPWidget::PPPWidget(const NetworkManager::Setting::Ptr &setting, QWidget *parent, Qt::WindowFlags f)
0013     : SettingWidget(setting, parent, f)
0014     , m_ui(new Ui::PPPWidget)
0015 {
0016     m_ui->setupUi(this);
0017 
0018     // Connect for setting check
0019     watchChangedSetting();
0020 
0021     KAcceleratorManager::manage(this);
0022 
0023     if (setting) {
0024         loadConfig(setting);
0025     }
0026 }
0027 
0028 PPPWidget::~PPPWidget()
0029 {
0030     delete m_ui;
0031 }
0032 
0033 void PPPWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
0034 {
0035     NetworkManager::PppSetting::Ptr pppSetting = setting.staticCast<NetworkManager::PppSetting>();
0036 
0037     m_ui->eap->setChecked(!pppSetting->refuseEap());
0038     m_ui->pap->setChecked(!pppSetting->refusePap());
0039     m_ui->chap->setChecked(!pppSetting->refuseChap());
0040     m_ui->mschap->setChecked(!pppSetting->refuseMschap());
0041     m_ui->mschapv2->setChecked(!pppSetting->refuseMschapv2());
0042 
0043     m_ui->mppe->setChecked(pppSetting->requireMppe());
0044     m_ui->mppe128->setChecked(pppSetting->requireMppe128());
0045     m_ui->mppeStateful->setChecked(pppSetting->mppeStateful());
0046 
0047     m_ui->bsdComp->setChecked(!pppSetting->noBsdComp());
0048     m_ui->deflateComp->setChecked(!pppSetting->noDeflate());
0049     m_ui->tcpComp->setChecked(!pppSetting->noVjComp());
0050 
0051     if (pppSetting->lcpEchoInterval() > 0) {
0052         m_ui->senddEcho->setChecked(true);
0053     } else {
0054         m_ui->senddEcho->setChecked(false);
0055     }
0056 }
0057 
0058 QVariantMap PPPWidget::setting() const
0059 {
0060     NetworkManager::PppSetting pppSetting;
0061 
0062     pppSetting.setRefuseEap(!m_ui->eap->isChecked());
0063     pppSetting.setRefusePap(!m_ui->pap->isChecked());
0064     pppSetting.setRefuseChap(!m_ui->chap->isChecked());
0065     pppSetting.setRefuseMschap(!m_ui->mschap->isChecked());
0066     pppSetting.setRefuseMschapv2(!m_ui->mschapv2->isChecked());
0067 
0068     pppSetting.setRequireMppe(m_ui->mppe->isChecked());
0069     pppSetting.setRequireMppe128(m_ui->mppe128->isChecked());
0070     pppSetting.setMppeStateful(m_ui->mppeStateful->isChecked());
0071 
0072     pppSetting.setNoBsdComp(!m_ui->bsdComp->isChecked());
0073     pppSetting.setNoDeflate(!m_ui->deflateComp->isChecked());
0074     pppSetting.setNoVjComp(!m_ui->tcpComp->isChecked());
0075 
0076     if (m_ui->senddEcho->isChecked()) {
0077         pppSetting.setLcpEchoFailure(5);
0078         pppSetting.setLcpEchoInterval(30);
0079     }
0080 
0081     return pppSetting.toMap();
0082 }
0083 
0084 #include "moc_pppwidget.cpp"