diff --git a/src/frontend/netdetails/configpage.cpp b/src/frontend/netdetails/configpage.cpp new file mode 100644 index 00000000..cc0ff7e3 --- /dev/null +++ b/src/frontend/netdetails/configpage.cpp @@ -0,0 +1,125 @@ +/* -*- 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 "configpage.h" + +#include + +#define VERTICAL_SPACING 24 +#define KSC_FIREWALL_PUBLIC 0 +#define KSC_FIREWALL_PRIVATE 1 + +ConfigPage::ConfigPage(QWidget *parent) +{ + initUi(); + initComponent(); +} + +void ConfigPage::initUi() +{ + m_descriptionLabel = new QLabel(this); + m_publicButton = new QRadioButton(this); + m_privateButton = new QRadioButton(this); + m_publicLabel = new QLabel(this); + m_privateLabel = new QLabel(this); + m_congigBtn = new KBorderlessButton(this); + + QWidget *centerWidget = new QWidget(this); + QGridLayout *gridLayout = new QGridLayout(centerWidget); + gridLayout->setContentsMargins(0, 0, 0, 0); + gridLayout->setVerticalSpacing(VERTICAL_SPACING); + gridLayout->addWidget(m_publicButton, 0, 0, Qt::AlignTop); + gridLayout->addWidget(m_publicLabel, 0, 1); + gridLayout->addWidget(m_privateButton, 1, 0, Qt::AlignTop); + gridLayout->addWidget(m_privateLabel, 1, 1); + + m_vBoxLayout = new QVBoxLayout(this); + m_vBoxLayout->setContentsMargins(0, 0, 0, 0); + m_vBoxLayout->setSpacing(VERTICAL_SPACING); + m_vBoxLayout->addWidget(m_descriptionLabel); + m_vBoxLayout->addWidget(centerWidget); + m_vBoxLayout->addWidget(m_congigBtn); + m_vBoxLayout->addStretch(); + + //网络配置文件类型 + m_descriptionLabel->setText(tr("Network profile type")); + m_descriptionLabel->setAlignment(Qt::AlignLeft); + //公用(推荐)无法在网络上发现你的设备。在大多数情况下,在家庭、工作或公共位置连接到网络时使用此功能。 + m_publicLabel->setText(tr("Public(recommended) Your device can not be discovered on the network. In most cases, " + "use this feature when connected to a network at home, work, or a public location.")); + m_publicLabel->setWordWrap(true); + //专用 可在网络上发现你的设备。如果需要文件共享或使用通过此网络通信的应用,请选择此项。你应该了解并信任网络上的人员和设备。 + m_privateLabel->setText(tr("Private Your device can be discovered on the network. Select this if you require file " + "sharing or use applications that communicate over this network. " + "You should know and trust the people and devices on the network.")); + m_privateLabel->setWordWrap(true); + //配置防火墙和安全设置 + m_congigBtn->setText(tr("Config firewall and security settings")); + + QPalette btnPal; + QColor btnColor = palette().highlight().color(); + btnPal.setColor(QPalette::ButtonText, btnColor); + m_congigBtn->setPalette(btnPal); +} + +void ConfigPage::initComponent() +{ + connect(m_congigBtn, &KBorderlessButton::clicked, this, &ConfigPage::onConfigButtonClicked); +} + +void ConfigPage::setConfigState(int type) +{ + if (type == KSC_FIREWALL_PUBLIC) { + m_publicButton->setChecked(true); + + } else if (type == KSC_FIREWALL_PRIVATE) { + m_privateButton->setChecked(true); + } + +} + +bool ConfigPage::checkIsChanged(int type) +{ + if (type == KSC_FIREWALL_PUBLIC && m_publicButton->isChecked()) { + return false; + } else if (type == KSC_FIREWALL_PRIVATE && m_privateButton->isChecked()) { + return false; + } else { + return true; + } +} + +int ConfigPage::getConfigState() +{ + if (m_publicButton->isChecked()) { + return KSC_FIREWALL_PUBLIC; + } else if (m_privateButton->isChecked()) { + return KSC_FIREWALL_PRIVATE; + } +} + + +void ConfigPage::onConfigButtonClicked() +{ + qDebug() << "show ksc defender net protect"; + + QProcess process; + process.startDetached("/usr/sbin/ksc-defender --net-protect"); + +} diff --git a/src/frontend/netdetails/configpage.h b/src/frontend/netdetails/configpage.h new file mode 100644 index 00000000..039f4b37 --- /dev/null +++ b/src/frontend/netdetails/configpage.h @@ -0,0 +1,66 @@ +/* -*- 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 CONFIGPAGE_H +#define CONFIGPAGE_H + +#include +#include +#include +#include +#include +#include + +#include "kwidget.h" +#include "kborderlessbutton.h" + +using namespace kdk; + +class ConfigPage : public QFrame +{ + Q_OBJECT +public: + ConfigPage(QWidget *parent = nullptr); + ~ConfigPage() = default; + + void setConfigState(int type); + bool checkIsChanged(int type); + int getConfigState(); + +private: + void initUi(); + void initComponent(); + + QLabel *m_descriptionLabel = nullptr; + QRadioButton *m_publicButton = nullptr; + QRadioButton *m_privateButton = nullptr; + QLabel *m_publicLabel = nullptr; + QLabel *m_privateLabel = nullptr; + KBorderlessButton *m_congigBtn = nullptr; + QVBoxLayout *m_vBoxLayout = nullptr; + +private slots: + void onConfigButtonClicked(); + +signals: + void publicConfig(); + void privateConfig(); +}; + +#endif // CONFIGPAGE_H diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index 80993f90..ea318847 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -43,7 +43,8 @@ #define IPV4_PAGE_NUM 1 #define IPV6_PAGE_NUM 2 #define SECURITY_PAGE_NUM 3 -#define CREATE_NET_PAGE_NUM 4 +#define CONFIG_PAGE_NUM 4 +#define CREATE_NET_PAGE_NUM 5 #define PAGE_MIN_HEIGHT 40 #define LAN_TAB_WIDTH 180 #define WLAN_TAB_WIDTH 240 @@ -191,7 +192,19 @@ void NetDetail::onPaletteChanged() void NetDetail::currentRowChangeSlot(int row) { - stackWidget->setCurrentIndex(row); + if (isActive) { + if (row < 3) { + stackWidget->setCurrentIndex(row); + } else { + if(isWlan) { + stackWidget->setCurrentIndex(row); + } else { + stackWidget->setCurrentIndex(CONFIG_PAGE_NUM); + } + } + } else { + stackWidget->setCurrentIndex(row); + } } void NetDetail::paintEvent(QPaintEvent *event) @@ -238,6 +251,7 @@ void NetDetail::initUI() ipv6Page = new Ipv6Page(this); securityPage = new SecurityPage(this); createNetPage = new CreatNetPage(this); + configPage = new ConfigPage(this); this->installEventFilter(this); @@ -249,6 +263,7 @@ void NetDetail::initUI() stackWidget->addWidget(ipv4Page); stackWidget->addWidget(ipv6Page); stackWidget->addWidget(securityPage); + stackWidget->addWidget(configPage); stackWidget->addWidget(createNetPage); mainLayout->addWidget(centerWidget); @@ -269,9 +284,19 @@ void NetDetail::initUI() m_netTabBar->addTab(tr("Ipv6"));//Ipv6 if (isWlan) { m_netTabBar->addTab(tr("Security"));//安全 - m_netTabBar->setFixedWidth(WLAN_TAB_WIDTH); + if (isActive) { + m_netTabBar->addTab(tr("Config")); //配置 + m_netTabBar->setFixedWidth(WLAN_TAB_WIDTH + TAB_WIDTH); + } else { + m_netTabBar->setFixedWidth(WLAN_TAB_WIDTH); + } } else { - m_netTabBar->setFixedWidth(LAN_TAB_WIDTH); + if (isActive) { + m_netTabBar->addTab(tr("Config")); //配置 + m_netTabBar->setFixedWidth(LAN_TAB_WIDTH + TAB_WIDTH); + } else { + m_netTabBar->setFixedWidth(LAN_TAB_WIDTH); + } } pageLayout->addStretch(); @@ -427,6 +452,16 @@ void NetDetail::pagePadding(QString netName, bool isWlan) } } + //配置页面 + if (isActive) { + int configType = getNetworkModeConfig(m_uuid); + if (configType == -1) { + configPage->setConfigState(KSC_FIREWALL_PUBLIC); + } else { + configPage->setConfigState(configType); + } + } + } //获取网路详情信息 @@ -939,6 +974,19 @@ bool NetDetail::updateConnect() m_wirelessConnOpration->activateConnection(m_uuid, m_deviceName); } } + + if (configPage != nullptr) { + int configType = 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); +// qDebug () < 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 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 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) { // 回车键触发确定按钮点击事件 diff --git a/src/frontend/netdetails/netdetail.h b/src/frontend/netdetails/netdetail.h index 11a4de69..0e854477 100644 --- a/src/frontend/netdetails/netdetail.h +++ b/src/frontend/netdetails/netdetail.h @@ -44,6 +44,7 @@ #include "ipv6page.h" #include "securitypage.h" #include "creatnetpage.h" +#include "configpage.h" #include "coninfo.h" #include "tab-pages/tabpage.h" #include "kwidget.h" @@ -72,6 +73,13 @@ class NetDetail : public QWidget 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); @@ -128,6 +136,7 @@ private: Ipv6Page * ipv6Page; SecurityPage * securityPage; CreatNetPage * createNetPage; + ConfigPage * configPage; QWidget * centerWidget; QWidget * bottomWidget; diff --git a/src/frontend/netdetails/netdetails.pri b/src/frontend/netdetails/netdetails.pri index f283cd37..75657d5d 100644 --- a/src/frontend/netdetails/netdetails.pri +++ b/src/frontend/netdetails/netdetails.pri @@ -1,6 +1,7 @@ INCLUDEPATH += $$PWD HEADERS += \ + $$PWD/configpage.h \ $$PWD/coninfo.h \ $$PWD/creatnetpage.h \ $$PWD/customtabstyle.h \ @@ -13,6 +14,7 @@ HEADERS += \ $$PWD/securitypage.h SOURCES += \ + $$PWD/configpage.cpp \ $$PWD/creatnetpage.cpp \ $$PWD/customtabstyle.cpp \ $$PWD/detailpage.cpp \ diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index b2c4dd44..59b691d6 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -932,6 +932,7 @@ void LanPage::onConnectionStateChange(QString uuid, KyConnectItem *p_newItem = nullptr; QString deviceName = ""; + QString ssid = ""; if (state == NetworkManager::ActiveConnection::State::Activated) { p_newItem = m_activeResourse->getActiveConnectionByUuid(uuid); @@ -941,6 +942,34 @@ void LanPage::onConnectionStateChange(QString uuid, } deviceName = p_newItem->m_ifaceName; + ssid = p_newItem->m_connectName; + + int configType = getNetworkModeConfig(uuid); + + if (configType == -1) { + FirewallDialog *fireWallDiaglog = new FirewallDialog(); + fireWallDiaglog->setWindowTitle(p_newItem->m_connectName); + + connect(fireWallDiaglog, &FirewallDialog::setPrivateNetMode, this, [=](){ + fireWallDiaglog->close(); + setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE); + }); + + connect(fireWallDiaglog, &FirewallDialog::setPublicNetMode, this, [=](){ + fireWallDiaglog->close(); + setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC); + }); + + connect(fireWallDiaglog, &FirewallDialog::close, this, [=](){ + setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC); + }); + fireWallDiaglog->show(); + } else if (configType == KSC_FIREWALL_PUBLIC) { + setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC); + } else if (configType == KSC_FIREWALL_PRIVATE) { + setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE); + } + updateActivatedConnectionArea(p_newItem); updateConnectionState(m_activeConnectionMap, m_activatedLanListWidget, uuid, (ConnectState)state); } else if (state == NetworkManager::ActiveConnection::State::Deactivated) { @@ -952,8 +981,10 @@ void LanPage::onConnectionStateChange(QString uuid, } deviceName = p_newItem->m_ifaceName; + ssid = p_newItem->m_connectName; updateConnectionArea(p_newItem); updateConnectionState(m_inactiveConnectionMap, m_inactivatedLanListWidget, uuid, (ConnectState)state); + breakNetworkConnect(uuid, deviceName, ssid); } else if (state == NetworkManager::ActiveConnection::State::Activating) { deviceName = getConnectionDevice(uuid); if (deviceName == m_currentDeviceName) { diff --git a/src/frontend/tab-pages/tabpage.cpp b/src/frontend/tab-pages/tabpage.cpp index 73dbfbfc..99279e6f 100644 --- a/src/frontend/tab-pages/tabpage.cpp +++ b/src/frontend/tab-pages/tabpage.cpp @@ -22,6 +22,7 @@ #include #include #include +#include TabPage::TabPage(QWidget *parent) : QWidget(parent) { @@ -330,3 +331,130 @@ void getDeviceEnableState(int type, QMap &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 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 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 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; + } +} diff --git a/src/frontend/tab-pages/tabpage.h b/src/frontend/tab-pages/tabpage.h index 20dd0e55..b3a6b0d0 100644 --- a/src/frontend/tab-pages/tabpage.h +++ b/src/frontend/tab-pages/tabpage.h @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd. * @@ -23,6 +23,7 @@ #include "divider.h" #include #include +#include #include #include #include @@ -35,9 +36,15 @@ #include "kwidget.h" #include "kswitchbutton.h" #include "kborderlessbutton.h" +#include "kdialog.h" using namespace kdk; +enum network_mode { + KSC_FIREWALL_PUBLIC = 0, + KSC_FIREWALL_PRIVATE +}; + #define MAIN_LAYOUT_MARGINS 0,0,0,0 #define MAIN_LAYOUT_SPACING 0 #define TITLE_FRAME_HEIGHT 50 //TabWidget的tab和widget有间隙,和设计稿看起来一致就不能设为设计稿里的高度 @@ -101,6 +108,13 @@ 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); @@ -148,4 +162,27 @@ 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 diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index bad1da20..a72e8305 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -936,6 +936,34 @@ void WlanPage::onConnectionStateChanged(QString uuid, << "; state = " << state << "; reason = " << reason << Q_FUNC_INFO <<__LINE__; if (state == NetworkManager::ActiveConnection::State::Activated) { m_updateStrength = true; + + int configType = getNetworkModeConfig(uuid); + + if (configType == -1) { + FirewallDialog *fireWallDiaglog = new FirewallDialog(); + fireWallDiaglog->setWindowTitle(ssid); + + connect(fireWallDiaglog, &FirewallDialog::setPrivateNetMode, this, [=](){ + fireWallDiaglog->close(); + setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PRIVATE); + }); + + connect(fireWallDiaglog, &FirewallDialog::setPublicNetMode, this, [=](){ + fireWallDiaglog->close(); + setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC); + }); + + connect(fireWallDiaglog, &FirewallDialog::close, this, [=](){ + setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC); + }); + + fireWallDiaglog->show(); + } else if (configType == KSC_FIREWALL_PUBLIC) { + setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC); + } else if (configType == KSC_FIREWALL_PRIVATE) { + setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PRIVATE); + } + updateActivatedArea(uuid, ssid, devName); if (m_activateConnectionItemMap.contains(ssid)) { QListWidgetItem *p_listWidgetItem = m_activateConnectionItemMap.value(ssid); @@ -948,6 +976,7 @@ void WlanPage::onConnectionStateChanged(QString uuid, QListWidgetItem *p_listWidgetItem = m_wirelessNetItemMap.value(ssid); updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated); } + breakNetworkConnect(uuid, devName, ssid); } else if (state == NetworkManager::ActiveConnection::State::Deactivating){ m_updateStrength = false; if (m_activateConnectionItemMap.contains(ssid)) {