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

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 "wiredsecurity.h"
0008 #include "ui_wiredsecurity.h"
0009 
0010 WiredSecurity::WiredSecurity(const NetworkManager::Security8021xSetting::Ptr &setting8021x, QWidget *parent, Qt::WindowFlags f)
0011     : SettingWidget(setting8021x, parent, f)
0012     , m_ui(new Ui::WiredSecurity)
0013     , m_8021xSetting(setting8021x)
0014 {
0015     m_ui->setupUi(this);
0016 
0017     m_8021xWidget = new Security8021x(m_8021xSetting, Security8021x::Ethernet, this);
0018     m_8021xWidget->setDisabled(true);
0019 
0020     m_ui->verticalLayout->addWidget(m_8021xWidget);
0021 
0022     connect(m_ui->use8021X, &QCheckBox::toggled, m_8021xWidget, &Security8021x::setEnabled);
0023 
0024     // Connect for setting check
0025     watchChangedSetting();
0026 
0027     KAcceleratorManager::manage(this);
0028 
0029     loadConfig(setting8021x);
0030 }
0031 
0032 WiredSecurity::~WiredSecurity()
0033 {
0034     delete m_ui;
0035 }
0036 
0037 bool WiredSecurity::enabled8021x() const
0038 {
0039     if (m_ui->use8021X->checkState() == Qt::Checked) {
0040         return true;
0041     }
0042 
0043     return false;
0044 }
0045 
0046 void WiredSecurity::loadConfig(const NetworkManager::Setting::Ptr &setting)
0047 {
0048     if (!setting->isNull()) {
0049         m_8021xWidget->setEnabled(true);
0050         m_ui->use8021X->setChecked(true);
0051     }
0052 }
0053 
0054 void WiredSecurity::loadSecrets(const NetworkManager::Setting::Ptr &setting)
0055 {
0056     NetworkManager::Security8021xSetting::Ptr securitySetting = setting.staticCast<NetworkManager::Security8021xSetting>();
0057 
0058     if (securitySetting) {
0059         m_8021xWidget->loadSecrets(securitySetting);
0060     }
0061 }
0062 
0063 QVariantMap WiredSecurity::setting() const
0064 {
0065     if (m_ui->use8021X->isChecked()) {
0066         return m_8021xWidget->setting();
0067     }
0068 
0069     return {};
0070 }
0071 
0072 #include "moc_wiredsecurity.cpp"