Merge branch 'instanceOptim' into 'dbus-interface'

静态方法调用

See merge request kylin-desktop/kylin-nm!672
This commit is contained in:
陈学超 2022-07-22 09:53:50 +00:00
commit 5fc789dd30
12 changed files with 313 additions and 240 deletions

View File

@ -5,6 +5,7 @@ include(tab-pages/tab-pages.pri)
include(list-items/list-items.pri)
include(netdetails/netdetails.pri)
include(enterprise-wlan/enterprise-wlan.pri)
include(networkmode/networkmode.pri)
FORMS += \
$$PWD/wificonfigdialog.ui
@ -18,3 +19,6 @@ SOURCES += \
$$PWD/customstyle.cpp \
$$PWD/mainwindow.cpp \
$$PWD/wificonfigdialog.cpp
DISTFILES += \
$$PWD/networkmode/networkmode.pri

View File

@ -21,6 +21,7 @@
#include "backend/kylinipv4arping.h"
#include "backend/kylinipv6arping.h"
//#include "xatom/xatom-helper.h"
#include "networkmodeconfig.h"
#define THEME_SCHAME "org.ukui.style"
@ -454,7 +455,7 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
//配置页面
if (isActive) {
int configType = getNetworkModeConfig(m_uuid);
int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(m_uuid);
if (configType == -1) {
configPage->setConfigState(KSC_FIREWALL_PUBLIC);
} else {
@ -976,13 +977,13 @@ bool NetDetail::updateConnect()
}
if (configPage != nullptr) {
int configType = getNetworkModeConfig(m_uuid);
int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(m_uuid);
bool configPageChange = configPage->checkIsChanged(configType);
int currentConfigType = configPage->getConfigState();
// qDebug () << Q_FUNC_INFO << __LINE__<< configPageChange;
if (configPageChange) {
setNetworkModeConfig(m_uuid, m_deviceName, m_name, currentConfigType);
NetworkModeConfig::getInstance()->setNetworkModeConfig(m_uuid, m_deviceName, m_name, currentConfigType);
// qDebug () <<Q_FUNC_INFO << __LINE__ << m_uuid << m_deviceName << m_name << currentConfigType;
}
}
@ -1014,64 +1015,6 @@ bool NetDetail::checkWirelessSecurity(KySecuType secuType)
return true;
}
int NetDetail::getNetworkModeConfig(QString uuid)
{
if (uuid.isEmpty()) {
qWarning()<< /*LOG_FLAG <<*/ "uuid is empty, so can not get network mode config";
return -1;
}
QDBusInterface dbusInterface("com.ksc.defender",
"/firewall",
"com.ksc.defender.firewall",
QDBusConnection::systemBus());
QDBusReply<int> reply = dbusInterface.call("get_networkModeConfig", uuid);
if (reply.isValid()) {
return reply.value();
} else {
qWarning() << "call get_networkModeConfig failed" << reply.error().message();
}
return -1;
}
void NetDetail::setNetworkModeConfig(QString uuid, QString cardName, QString ssid, int mode)
{
QDBusInterface dbusInterface("com.ksc.defender",
"/firewall",
"com.ksc.defender.firewall",
QDBusConnection::systemBus());
QDBusReply<int> reply = dbusInterface.call("set_networkModeConfig", uuid, cardName, ssid, mode);
if (reply.isValid()) {
qDebug() << "set_networkModeConfig" << ssid << uuid << cardName << mode << ",result" << reply.value();
} else {
qWarning() << "call set_networkModeConfig" << reply.error().message();
}
}
int NetDetail::breakNetworkConnect(QString uuid, QString cardName, QString ssid)
{
QDBusInterface dbusInterface("com.ksc.defender",
"/firewall",
"com.ksc.defender.firewall",
QDBusConnection::systemBus());
QDBusReply<int> reply = dbusInterface.call("break_networkConnect", uuid, cardName, ssid);
if (reply.isValid()) {
qDebug() << "break_networkConnect" << ssid << uuid << cardName << ",result" << reply.value();
return reply.value();
} else {
qWarning() << "call break_networkConnect failed" << reply.error().message();
return -1;
}
}
bool NetDetail::eventFilter(QObject *w, QEvent *event)
{
// 回车键触发确定按钮点击事件

View File

@ -74,13 +74,6 @@ public:
NetDetail(QString interface, QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent = nullptr);
~NetDetail();
//安全中心-获取网络模式配置
int getNetworkModeConfig(QString uuid);
//安全中心-设置网络模式配置
void setNetworkModeConfig(QString uuid, QString cardName, QString ssid, int mode);
//安全中心-解除连接(用于防火墙处从正在使用的网络中删除)
int breakNetworkConnect(QString uuid, QString cardName, QString ssid);
protected:
void paintEvent(QPaintEvent *event);
void closeEvent(QCloseEvent *event);
bool eventFilter(QObject *w, QEvent *event);

View File

@ -0,0 +1,89 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "firewalldialog.h"
#define ICON_SIZE 16,16
FirewallDialog::FirewallDialog(KDialog *parent)
{
initUI();
this->setWindowIcon(QIcon::fromTheme("kylin-network"));
this->setFixedSize(480, 204);
setAttribute(Qt::WA_DeleteOnClose);
}
FirewallDialog::~FirewallDialog()
{
}
void FirewallDialog::initUI()
{
m_iconLabel = new QLabel(this);
m_contentLabel = new QLabel(this);
m_suggestLabel = new QLabel(this);
m_YesBtn = new QPushButton(this);
m_NoBtn = new QPushButton(this);
m_dialogLayout = new QVBoxLayout(this);
QWidget *contentWidget = new QWidget(this);
QGridLayout *contentLayout = new QGridLayout(contentWidget);
contentLayout->setContentsMargins(0, 0, 0, 0);
contentLayout->addWidget(m_iconLabel, 0, 0, Qt::AlignTop);
contentLayout->addWidget(m_contentLabel, 0, 1);
contentLayout->addWidget(m_suggestLabel, 1, 1);
m_iconLabel->setFixedWidth(16);
QWidget *btnWidget = new QWidget(this);
QHBoxLayout *btnLayout = new QHBoxLayout(btnWidget);
btnLayout->setContentsMargins(0, 0, 0, 0);
btnLayout->setSpacing(16);
btnLayout->addStretch();
btnLayout->addWidget(m_YesBtn);
btnLayout->addWidget(m_NoBtn);
m_dialogLayout->setContentsMargins(24, 0, 24, 24);
m_dialogLayout->setSpacing(0);
m_dialogLayout->addWidget(contentWidget);
m_dialogLayout->addStretch();
m_dialogLayout->addWidget(btnWidget);
QIcon icon = QIcon::fromTheme("dialog-info");
m_iconLabel->setPixmap(icon.pixmap(ICON_SIZE));
QFont font = m_contentLabel->font();
font.setWeight(75);
m_contentLabel->setFont(font);
//是否允许你的电脑被此网络上的其他电脑和设备发现?
m_contentLabel->setText(tr("Allow your computer to be discovered by other computers and devices on this network"));
m_contentLabel->setWordWrap(true);
//建议你在家庭和工作网络上而非公共网络上启用此功能。
m_suggestLabel->setText(tr("It is recommended that you enable this feature on your home and work networks rather than public networks."));
m_suggestLabel->setWordWrap(true);
m_YesBtn->setText(tr("Yse"));
m_NoBtn->setText(tr("No"));
this->closeButton();
this->mainWidget()->setLayout(m_dialogLayout);
connect(m_YesBtn, &QPushButton::clicked, this, &FirewallDialog::setPrivateNetMode);
connect(m_NoBtn, &QPushButton::clicked, this, &FirewallDialog::setPublicNetMode);
}

View File

@ -0,0 +1,53 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef FIREWALLDIALOG_H
#define FIREWALLDIALOG_H
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFormLayout>
#include <QLabel>
#include "kwidget.h"
#include "kdialog.h"
using namespace kdk;
class FirewallDialog : public KDialog
{
Q_OBJECT
public:
explicit FirewallDialog(KDialog *parent = nullptr);
~FirewallDialog();
private:
void initUI();
QLabel * m_iconLabel = nullptr;
QLabel * m_contentLabel = nullptr;
QLabel * m_suggestLabel = nullptr;
QVBoxLayout *m_dialogLayout = nullptr;
QPushButton *m_YesBtn = nullptr;
QPushButton *m_NoBtn = nullptr;
signals:
void setPublicNetMode();
void setPrivateNetMode();
};
#endif // FIREWALLDIALOG_H

View File

@ -0,0 +1,10 @@
INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/firewalldialog.h \
$$PWD/networkmodeconfig.h
SOURCES += \
$$PWD/firewalldialog.cpp \
$$PWD/networkmodeconfig.cpp

View File

@ -0,0 +1,90 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "networkmodeconfig.h"
#include <QDebug>
NetworkModeConfig *NetworkModeConfig::m_netModeInstance = nullptr;
NetworkModeConfig *NetworkModeConfig::getInstance()
{
if (m_netModeInstance == NULL) {
m_netModeInstance = new NetworkModeConfig();
}
return m_netModeInstance;
}
NetworkModeConfig::NetworkModeConfig(QObject *parent) : QObject(parent)
{
m_dbusInterface = new QDBusInterface("com.ksc.defender",
"/firewall",
"com.ksc.defender.firewall",
QDBusConnection::systemBus());
}
int NetworkModeConfig::getNetworkModeConfig(QString uuid)
{
if (uuid.isEmpty()) {
qWarning()<< /*LOG_FLAG <<*/ "uuid is empty, so can not get network mode config";
return -1;
}
if(!m_dbusInterface->isValid()) {
qWarning ()<< "init com.ksc.defender dbus error";
}
QDBusReply<int> reply = m_dbusInterface->call("get_networkModeConfig", uuid);
if (reply.isValid()) {
return reply.value();
} else {
qWarning() << "call get_networkModeConfig failed" << reply.error().message();
}
return -1;
}
void NetworkModeConfig::setNetworkModeConfig(QString uuid, QString cardName, QString ssid, int mode)
{
if(!m_dbusInterface->isValid()) {
qWarning ()<< "init com.ksc.defender dbus error";
}
QDBusReply<int> reply = m_dbusInterface->call("set_networkModeConfig", uuid, cardName, ssid, mode);
if (reply.isValid()) {
qDebug() << "set_networkModeConfig" << ssid << uuid << cardName << mode << ",result" << reply.value();
} else {
qWarning() << "call set_networkModeConfig" << reply.error().message();
}
}
int NetworkModeConfig::breakNetworkConnect(QString uuid, QString cardName, QString ssid)
{
if(!m_dbusInterface->isValid()) {
qWarning ()<< "init com.ksc.defender dbus error";
}
QDBusReply<int> reply = m_dbusInterface->call("break_networkConnect", uuid, cardName, ssid);
if (reply.isValid()) {
qDebug() << "break_networkConnect" << ssid << uuid << cardName << ",result" << reply.value();
return reply.value();
} else {
qWarning() << "call break_networkConnect failed" << reply.error().message();
return -1;
}
}

View File

@ -0,0 +1,46 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef NETWORKMODECONFIG_H
#define NETWORKMODECONFIG_H
#include <QObject>
#include <QDBusInterface>
#include <QDBusReply>
class NetworkModeConfig : public QObject
{
Q_OBJECT
public:
static NetworkModeConfig *getInstance();
//安全中心-获取网络模式配置
int getNetworkModeConfig(QString uuid);
//安全中心-设置网络模式配置
void setNetworkModeConfig(QString uuid, QString cardName, QString ssid, int mode);
//安全中心-解除连接(用于防火墙处从正在使用的网络中删除)
int breakNetworkConnect(QString uuid, QString cardName, QString ssid);
static NetworkModeConfig *m_netModeInstance;
private:
explicit NetworkModeConfig(QObject *parent = nullptr);
QDBusInterface *m_dbusInterface = nullptr;
};
#endif // NETWORKMODECONFIG_H

View File

@ -18,6 +18,7 @@
*
*/
#include "lanpage.h"
#include "networkmodeconfig.h"
#include <QDebug>
#include <QScrollBar>
@ -944,7 +945,7 @@ void LanPage::onConnectionStateChange(QString uuid,
deviceName = p_newItem->m_ifaceName;
ssid = p_newItem->m_connectName;
int configType = getNetworkModeConfig(uuid);
int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(uuid);
if (configType == -1) {
FirewallDialog *fireWallDiaglog = new FirewallDialog();
@ -952,22 +953,22 @@ void LanPage::onConnectionStateChange(QString uuid,
connect(fireWallDiaglog, &FirewallDialog::setPrivateNetMode, this, [=](){
fireWallDiaglog->close();
setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE);
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE);
});
connect(fireWallDiaglog, &FirewallDialog::setPublicNetMode, this, [=](){
fireWallDiaglog->close();
setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
});
connect(fireWallDiaglog, &FirewallDialog::close, this, [=](){
setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
});
fireWallDiaglog->show();
} else if (configType == KSC_FIREWALL_PUBLIC) {
setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
} else if (configType == KSC_FIREWALL_PRIVATE) {
setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE);
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE);
}
updateActivatedConnectionArea(p_newItem);
@ -984,7 +985,7 @@ void LanPage::onConnectionStateChange(QString uuid,
ssid = p_newItem->m_connectName;
updateConnectionArea(p_newItem);
updateConnectionState(m_inactiveConnectionMap, m_inactivatedLanListWidget, uuid, (ConnectState)state);
breakNetworkConnect(uuid, deviceName, ssid);
NetworkModeConfig::getInstance()->breakNetworkConnect(uuid, deviceName, ssid);
} else if (state == NetworkManager::ActiveConnection::State::Activating) {
deviceName = getConnectionDevice(uuid);
if (deviceName == m_currentDeviceName) {

View File

@ -331,130 +331,3 @@ void getDeviceEnableState(int type, QMap<QString, bool> &map)
kdr = nullptr;
return;
}
#define ICON_SIZE 16,16
FirewallDialog::FirewallDialog(KDialog *parent)
{
initUI();
this->setWindowIcon(QIcon::fromTheme("kylin-network"));
this->setFixedSize(480, 204);
setAttribute(Qt::WA_DeleteOnClose);
}
FirewallDialog::~FirewallDialog()
{
}
void FirewallDialog::initUI()
{
m_iconLabel = new QLabel(this);
m_contentLabel = new QLabel(this);
m_suggestLabel = new QLabel(this);
m_YesBtn = new QPushButton(this);
m_NoBtn = new QPushButton(this);
m_dialogLayout = new QVBoxLayout(this);
QWidget *contentWidget = new QWidget(this);
QGridLayout *contentLayout = new QGridLayout(contentWidget);
contentLayout->setContentsMargins(0, 0, 0, 0);
contentLayout->addWidget(m_iconLabel, 0, 0, Qt::AlignTop);
contentLayout->addWidget(m_contentLabel, 0, 1);
contentLayout->addWidget(m_suggestLabel, 1, 1);
m_iconLabel->setFixedWidth(16);
QWidget *btnWidget = new QWidget(this);
QHBoxLayout *btnLayout = new QHBoxLayout(btnWidget);
btnLayout->setContentsMargins(0, 0, 0, 0);
btnLayout->setSpacing(16);
btnLayout->addStretch();
btnLayout->addWidget(m_YesBtn);
btnLayout->addWidget(m_NoBtn);
m_dialogLayout->setContentsMargins(24, 0, 24, 24);
m_dialogLayout->setSpacing(0);
m_dialogLayout->addWidget(contentWidget);
m_dialogLayout->addStretch();
m_dialogLayout->addWidget(btnWidget);
QIcon icon = QIcon::fromTheme("dialog-info");
m_iconLabel->setPixmap(icon.pixmap(ICON_SIZE));
QFont font = m_contentLabel->font();
font.setWeight(75);
m_contentLabel->setFont(font);
//是否允许你的电脑被此网络上的其他电脑和设备发现?
m_contentLabel->setText(tr("Allow your computer to be discovered by other computers and devices on this network"));
m_contentLabel->setWordWrap(true);
//建议你在家庭和工作网络上而非公共网络上启用此功能。
m_suggestLabel->setText(tr("It is recommended that you enable this feature on your home and work networks rather than public networks."));
m_suggestLabel->setWordWrap(true);
m_YesBtn->setText(tr("Yse"));
m_NoBtn->setText(tr("No"));
this->closeButton();
this->mainWidget()->setLayout(m_dialogLayout);
connect(m_YesBtn, &QPushButton::clicked, this, &FirewallDialog::setPrivateNetMode);
connect(m_NoBtn, &QPushButton::clicked, this, &FirewallDialog::setPublicNetMode);
}
int TabPage::getNetworkModeConfig(QString uuid)
{
if (uuid.isEmpty()) {
qWarning()<< /*LOG_FLAG <<*/ "uuid is empty, so can not get network mode config";
return -1;
}
QDBusInterface dbusInterface("com.ksc.defender",
"/firewall",
"com.ksc.defender.firewall",
QDBusConnection::systemBus());
QDBusReply<int> reply = dbusInterface.call("get_networkModeConfig", uuid);
if (reply.isValid()) {
return reply.value();
} else {
qWarning() << "call get_networkModeConfig failed" << reply.error().message();
}
return -1;
}
void TabPage::setNetworkModeConfig(QString uuid, QString cardName, QString ssid, int mode)
{
QDBusInterface dbusInterface("com.ksc.defender",
"/firewall",
"com.ksc.defender.firewall",
QDBusConnection::systemBus());
QDBusReply<int> reply = dbusInterface.call("set_networkModeConfig", uuid, cardName, ssid, mode);
if (reply.isValid()) {
qDebug() << "set_networkModeConfig" << ssid << uuid << cardName << mode << ",result" << reply.value();
} else {
qWarning() << "call set_networkModeConfig" << reply.error().message();
}
}
int TabPage::breakNetworkConnect(QString uuid, QString cardName, QString ssid)
{
QDBusInterface dbusInterface("com.ksc.defender",
"/firewall",
"com.ksc.defender.firewall",
QDBusConnection::systemBus());
QDBusReply<int> reply = dbusInterface.call("break_networkConnect", uuid, cardName, ssid);
if (reply.isValid()) {
qDebug() << "break_networkConnect" << ssid << uuid << cardName << ",result" << reply.value();
return reply.value();
} else {
qWarning() << "call break_networkConnect failed" << reply.error().message();
return -1;
}
}

View File

@ -33,10 +33,10 @@
#include <QProcess>
#include <QDebug>
#include "kylinnetworkdeviceresource.h"
#include "firewalldialog.h"
#include "kwidget.h"
#include "kswitchbutton.h"
#include "kborderlessbutton.h"
#include "kdialog.h"
using namespace kdk;
@ -108,13 +108,6 @@ public:
}
}
//安全中心-获取网络模式配置
int getNetworkModeConfig(QString uuid);
//安全中心-设置网络模式配置
void setNetworkModeConfig(QString uuid, QString cardName, QString ssid, int mode);
//安全中心-解除连接(用于防火墙处从正在使用的网络中删除)
int breakNetworkConnect(QString uuid, QString cardName, QString ssid);
signals:
void deviceStatusChanged();
void deviceNameChanged(QString oldName, QString newName, int type);
@ -162,27 +155,4 @@ public slots:
};
class FirewallDialog : public KDialog
{
Q_OBJECT
public:
explicit FirewallDialog(KDialog *parent = nullptr);
~FirewallDialog();
private:
void initUI();
QLabel * m_iconLabel = nullptr;
QLabel * m_contentLabel = nullptr;
QLabel * m_suggestLabel = nullptr;
QVBoxLayout *m_dialogLayout = nullptr;
QPushButton *m_YesBtn = nullptr;
QPushButton *m_NoBtn = nullptr;
signals:
void setPublicNetMode();
void setPrivateNetMode();
};
#endif // TABPAGE_H

View File

@ -19,6 +19,7 @@
*/
#include "wlanpage.h"
#include "kywirelessnetitem.h"
#include "networkmodeconfig.h"
#include <QEvent>
#include <QDateTime>
#include <QDebug>
@ -937,7 +938,7 @@ void WlanPage::onConnectionStateChanged(QString uuid,
if (state == NetworkManager::ActiveConnection::State::Activated) {
m_updateStrength = true;
int configType = getNetworkModeConfig(uuid);
int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(uuid);
if (configType == -1) {
FirewallDialog *fireWallDiaglog = new FirewallDialog();
@ -945,23 +946,23 @@ void WlanPage::onConnectionStateChanged(QString uuid,
connect(fireWallDiaglog, &FirewallDialog::setPrivateNetMode, this, [=](){
fireWallDiaglog->close();
setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PRIVATE);
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PRIVATE);
});
connect(fireWallDiaglog, &FirewallDialog::setPublicNetMode, this, [=](){
fireWallDiaglog->close();
setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC);
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC);
});
connect(fireWallDiaglog, &FirewallDialog::close, this, [=](){
setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC);
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC);
});
fireWallDiaglog->show();
} else if (configType == KSC_FIREWALL_PUBLIC) {
setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC);
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC);
} else if (configType == KSC_FIREWALL_PRIVATE) {
setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PRIVATE);
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PRIVATE);
}
updateActivatedArea(uuid, ssid, devName);
@ -976,7 +977,7 @@ void WlanPage::onConnectionStateChanged(QString uuid,
QListWidgetItem *p_listWidgetItem = m_wirelessNetItemMap.value(ssid);
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
}
breakNetworkConnect(uuid, devName, ssid);
NetworkModeConfig::getInstance()->breakNetworkConnect(uuid, devName, ssid);
} else if (state == NetworkManager::ActiveConnection::State::Deactivating){
m_updateStrength = false;
if (m_activateConnectionItemMap.contains(ssid)) {