diff --git a/plugins/component/NetworkMode/firewalldialog.cpp b/plugins/component/NetworkMode/firewalldialog.cpp deleted file mode 100644 index 9b78e7c2..00000000 --- a/plugins/component/NetworkMode/firewalldialog.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- 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 -#define MEDIUM_WEIGHT_VALUE 57 - -FirewallDialog::FirewallDialog(QWidget *parent): KDialog(parent) -{ - initUI(); - this->setWindowIcon(QIcon::fromTheme("kylin-network")); - this->setFixedSize(480, 204); - setAttribute(Qt::WA_DeleteOnClose); -// centerToScreen(); -} - -FirewallDialog::~FirewallDialog() -{ - -} - -void FirewallDialog::initUI() -{ - m_iconLabel = new QLabel(this); - m_contentLabel = new FixLabel(this); - m_suggestLabel = new FixLabel(this); - m_PublicBtn = new QPushButton(this); - m_PrivateBtn = new QPushButton(this); - m_dialogLayout = new QVBoxLayout(this); - - m_contentLabel->setFixedWidth(405); - m_suggestLabel->setFixedWidth(405); - - QWidget *contentWidget = new QWidget(this); - QGridLayout *contentLayout = new QGridLayout(contentWidget); - contentLayout->setHorizontalSpacing(0); - contentLayout->setContentsMargins(0, 0, 0, 0); - contentLayout->addWidget(m_iconLabel, 0, 0); - contentLayout->addWidget(m_contentLabel, 0, 1); - contentLayout->addWidget(m_suggestLabel, 1, 1); - m_iconLabel->setFixedWidth(24); - - QWidget *btnWidget = new QWidget(this); - QHBoxLayout *btnLayout = new QHBoxLayout(btnWidget); - btnLayout->setContentsMargins(0, 0, 0, 0); - btnLayout->setSpacing(16); - btnLayout->addStretch(); - btnLayout->addWidget(m_PublicBtn); - btnLayout->addWidget(m_PrivateBtn); - - m_dialogLayout->setContentsMargins(22, 16, 22, 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(MEDIUM_WEIGHT_VALUE); - m_contentLabel->setFont(font); - //是否允许此网络上的其他设备发现这台电脑? - m_contentLabel->setLabelText(tr("Allow other devices on this network to discover this computer?")); - //不建议在公共网络上开启此功能 - m_suggestLabel->setLabelText(tr("It is not recommended to enable this feature on public networks")); - - m_PublicBtn->setText(tr("Not allowed (recommended)")); - m_PrivateBtn->setText(tr("Allowed")); - - this->closeButton(); - this->mainWidget()->setLayout(m_dialogLayout); - - connect(m_PublicBtn, &QPushButton::clicked, this, &FirewallDialog::setPublicNetMode); - connect(m_PrivateBtn, &QPushButton::clicked, this, &FirewallDialog::setPrivateNetMode); -} - -void FirewallDialog::centerToScreen() -{ - QDesktopWidget* m = QApplication::desktop(); - QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos())); - int desk_x = desk_rect.width(); - int desk_y = desk_rect.height(); - int x = this->width(); - int y = this->height(); - this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top()); -} diff --git a/plugins/component/NetworkMode/firewalldialog.h b/plugins/component/NetworkMode/firewalldialog.h deleted file mode 100644 index 432c2671..00000000 --- a/plugins/component/NetworkMode/firewalldialog.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- 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 -#include -#include -#include -#include -#include -#include "kwidget.h" -#include "kdialog.h" -#include -#include "../component/FixLabel/fixlabel.h" - -using namespace kdk; - -class FirewallDialog : public KDialog -{ - Q_OBJECT -public: - FirewallDialog(QWidget *parent = nullptr); - ~FirewallDialog(); - void setUuid(QString uuid) { - m_uuid = uuid; - } - - void centerToScreen(); - -private: - void initUI(); - - QString m_uuid; - QLabel * m_iconLabel = nullptr; - FixLabel * m_contentLabel = nullptr; - FixLabel * m_suggestLabel = nullptr; - QVBoxLayout *m_dialogLayout = nullptr; - QPushButton *m_PublicBtn = nullptr; - QPushButton *m_PrivateBtn = nullptr; - -Q_SIGNALS: - void setPublicNetMode(); - void setPrivateNetMode(); - -public Q_SLOTS: - void closeMyself(QString uuid, KyConnectState status) { - if (uuid == m_uuid && status == CONNECT_STATE_DEACTIVATED) { - this->close(); - } - } -}; -#endif // FIREWALLDIALOG_H diff --git a/plugins/component/NetworkMode/networkmodeconfig.cpp b/plugins/component/NetworkMode/networkmodeconfig.cpp deleted file mode 100644 index fa19cc6c..00000000 --- a/plugins/component/NetworkMode/networkmodeconfig.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- 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 - -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 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 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 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; - } -} diff --git a/plugins/component/NetworkMode/networkmodeconfig.h b/plugins/component/NetworkMode/networkmodeconfig.h deleted file mode 100644 index c5b11b70..00000000 --- a/plugins/component/NetworkMode/networkmodeconfig.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- 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 -#include -#include - -enum network_mode { - KSC_FIREWALL_PUBLIC = 0, - KSC_FIREWALL_PRIVATE -}; - -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 diff --git a/plugins/component/Pages/netdetail.cpp b/plugins/component/Pages/netdetail.cpp index 71378ef9..220f8c21 100644 --- a/plugins/component/Pages/netdetail.cpp +++ b/plugins/component/Pages/netdetail.cpp @@ -20,7 +20,6 @@ #include "netdetail.h" //#include "../component/KylinArping/kylinipv4arping.h" //#include "../component/KylinArping/kylinipv6arping.h" -#include "../component/NetworkMode/networkmodeconfig.h" #define THEME_SCHAME "org.ukui.style" @@ -383,6 +382,7 @@ void NetDetail::initUI() stackWidget->addWidget(configPage); stackWidget->addWidget(createNetPage); + m_networkMode = NetworkModeType(getNetworkModeConfig(m_uuid)); // TabBar m_netTabBar = new NetTabBar(this); m_netTabBar->addTab(tr("Detail")); //详情 @@ -390,14 +390,14 @@ void NetDetail::initUI() m_netTabBar->addTab(tr("IPv6"));//Ipv6 if (isWlan) { m_netTabBar->addTab(tr("Security"));//安全 - if (isActive) { + if (isActive && m_networkMode != DBUS_INVAILD && m_networkMode != NO_CONFIG) { m_netTabBar->addTab(tr("Config")); //配置 m_netTabBar->setFixedWidth(WLAN_TAB_WIDTH + TAB_WIDTH); } else { m_netTabBar->setFixedWidth(WLAN_TAB_WIDTH); } } else { - if (isActive) { + if (isActive && m_networkMode != DBUS_INVAILD && m_networkMode != NO_CONFIG) { m_netTabBar->addTab(tr("Config")); //配置 m_netTabBar->setFixedWidth(LAN_TAB_WIDTH + TAB_WIDTH); } else { @@ -606,8 +606,8 @@ void NetDetail::pagePadding(QString netName, bool isWlan) } //配置页面 - if (isActive) { - configPage->setConfigState(NetworkModeConfig::getInstance()->getNetworkModeConfig(m_uuid)); + if (isActive && m_networkMode != DBUS_INVAILD && m_networkMode != NO_CONFIG) { + configPage->setConfigState(m_networkMode); } } @@ -836,14 +836,14 @@ bool NetDetail::updateConnect() } //属性页 page5 config 网络模式配置 - if (configPage != nullptr) { - int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(m_uuid); + if (m_networkMode != DBUS_INVAILD) { + int configType = getNetworkModeConfig(m_uuid); bool configPageChange = configPage->checkIsChanged(configType); int currentConfigType = configPage->getConfigState(); // qDebug () << Q_FUNC_INFO << __LINE__<< configPageChange; if (configPageChange) { - NetworkModeConfig::getInstance()->setNetworkModeConfig(m_uuid, m_deviceName, m_name, currentConfigType); + setNetworkModeConfig(m_uuid, m_deviceName, m_name, currentConfigType); // qDebug () < reply = firewallIface.call("get_networkModeConfig", uuid); + if (reply.isValid()) { + return reply.value(); + } else { + qWarning() << "[NetDetail] call get_networkModeConfig failed" << reply.error().message(); + } + return NO_CONFIG; +} + +void NetDetail::setNetworkModeConfig(QString uuid, QString cardName, QString ssid, int mode) +{ + QDBusInterface firewallIface("com.ksc.defender", + "/firewall", + "com.ksc.defender.firewall", + QDBusConnection::systemBus()); + + if(!firewallIface.isValid()) { + qWarning () << "[NetDetail] com.ksc.defender.firewall dbus is invalid"; + return; + } + + QDBusReply reply = firewallIface.call("set_networkModeConfig", uuid, cardName, ssid, mode); + if (reply.isValid()) { + qDebug() << "[NetDetail] set_networkModeConfig" << ssid << uuid << cardName << mode << ",result" << reply.value(); + } else { + qWarning() << "[NetDetail] call set_networkModeConfig" << reply.error().message(); + } +} + NetTabBar::NetTabBar(QWidget *parent) :KTabBar(KTabBarStyle::SegmentDark, parent) { diff --git a/plugins/component/Pages/netdetail.h b/plugins/component/Pages/netdetail.h index a53561cb..596cbdbc 100644 --- a/plugins/component/Pages/netdetail.h +++ b/plugins/component/Pages/netdetail.h @@ -57,6 +57,13 @@ using namespace kdk; #define TAB_HEIGHT 36 #define TAB_HEIGHT_TABLET 48 +enum NetworkModeType { + DBUS_INVAILD = -2, + NO_CONFIG = -1, + KSC_FIREWALL_PUBLIC = 0, + KSC_FIREWALL_PRIVATE +}; + class NetTabBar : public KTabBar { Q_OBJECT @@ -133,6 +140,11 @@ private: void startObjectThread(); void setNetTabToolTip(); + //安全中心-获取网络模式配置 + int getNetworkModeConfig(QString uuid); + //安全中心-设置网络模式配置 + void setNetworkModeConfig(QString uuid, QString cardName, QString ssid, int mode); + private: QStackedWidget * stackWidget; @@ -182,6 +194,7 @@ private: KyDetailInfo m_detailInfo; KyConnectSetting m_connectSetting; KyWpaPasswordInfo m_pwdInfo; + NetworkModeType m_networkMode = DBUS_INVAILD; private Q_SLOTS: void onBtnConfirmClicked(); diff --git a/plugins/component/networkmode.pri b/plugins/component/networkmode.pri deleted file mode 100644 index a8ea9f12..00000000 --- a/plugins/component/networkmode.pri +++ /dev/null @@ -1,10 +0,0 @@ -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/NetworkMode/firewalldialog.h \ - $$PWD/NetworkMode/networkmodeconfig.h - -SOURCES += \ - $$PWD/NetworkMode/firewalldialog.cpp \ - $$PWD/NetworkMode/networkmodeconfig.cpp - diff --git a/plugins/netconnect/netconnect.cpp b/plugins/netconnect/netconnect.cpp index c256ed7e..dc94f6b7 100644 --- a/plugins/netconnect/netconnect.cpp +++ b/plugins/netconnect/netconnect.cpp @@ -307,11 +307,6 @@ void NetConnect::initConnect() connect(this, &NetConnect::updateIpv4AndIpv6SettingInfo, manager, &KyNetworkManager::onUpdateIpv4AndIpv6SettingInfo); connect(this, &NetConnect::createWiredConnect, manager, &KyNetworkManager::onCreateWiredConnect); - connect(manager, &KyNetworkManager::wiredStateChange, this, [=](QString deviceName, QString uuid, KyConnectState status) { - KyConnectSetting connectSetting; - manager->getConnectIpInfo(uuid, connectSetting); - updateNetworkModeState(deviceName, connectSetting.m_connectName, uuid, status); - }); connect(manager, &KyNetworkManager::wiredStateChange, this, [=](QString deviceName, QString uuid, KyConnectState status) { Q_EMIT connectStateChanged(uuid, status); }); @@ -499,10 +494,6 @@ void NetConnect::initNetListFromDevice(QString deviceName) manager->getActiveConnectionList(deviceName, CONNECT_TYPE_WIRED, activateList); if (activateList.size() != 0) { onActiveConnectionChanged(deviceName, activateList.at(0).m_uuid, activateList.at(0).m_connStatus); - - for (KyActivateItem item : activateList) { - initActiveNetworkMode(deviceName, item); - } } } @@ -522,7 +513,7 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, KyWiredItem item) lanItem->setUuid(item.m_connectUuid); lanItem->setPath(item.m_connectPath); - //todo show detail page + //show detail page connect(lanItem, &LanItem::infoButtonClick, this, [=]{ showLanDetailPage(devName, lanItem); }); @@ -729,7 +720,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis lanItem->setUuid(connUuid); lanItem->setPath(connDbusPath); - // todo open landetail page + //open lan detail page if (!m_isSimpleMode) { connect(lanItem, &LanItem::infoButtonClick, this, [=]{ showLanDetailPage(deviceName, lanItem); @@ -998,58 +989,6 @@ void NetConnect::onDeviceRemove(QString deviceName) } } -void NetConnect::initActiveNetworkMode(QString deviceName, KyActivateItem activeItem) -{ - int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(activeItem.m_uuid); - if (configType == -1) { - NetworkModeConfig::getInstance()->setNetworkModeConfig(activeItem.m_uuid, - deviceName, - activeItem.m_connName, - KSC_FIREWALL_PUBLIC); - } else { - NetworkModeConfig::getInstance()->setNetworkModeConfig(activeItem.m_uuid, - deviceName, - activeItem.m_connName, - configType); - } -} - - -void NetConnect::updateNetworkModeState(QString deviceName, QString ssid, QString uuid, KyConnectState status) -{ - if (status == CONNECT_STATE_ACTIVATED) { - int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(uuid); - if (configType == -1) { - NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC); //默认公有配置 - FirewallDialog *fireWallDialog = new FirewallDialog(); //弹窗 供用户配置 - fireWallDialog->setUuid(uuid); - fireWallDialog->setWindowTitle(ssid); - - connect(fireWallDialog, &FirewallDialog::setPrivateNetMode, this, [=](){ - fireWallDialog->hide(); - NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE); - }); - - connect(fireWallDialog, &FirewallDialog::setPublicNetMode, this, [=](){ - fireWallDialog->hide(); - NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC); - }); - - connect(this, &NetConnect::connectStateChanged, fireWallDialog, &FirewallDialog::closeMyself); - - fireWallDialog->show(); - fireWallDialog->centerToScreen(); - - } else if (configType == KSC_FIREWALL_PUBLIC) { - NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC); - } else if (configType == KSC_FIREWALL_PRIVATE) { - NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE); - } - } else if (status == CONNECT_STATE_DEACTIVATED) { - NetworkModeConfig::getInstance()->breakNetworkConnect(uuid, deviceName, ssid); - } -} - void NetConnect::showDetailPage(QString deviceName, QString ssid) { if (deviceName.isEmpty() || ssid.isEmpty()) { diff --git a/plugins/netconnect/netconnect.h b/plugins/netconnect/netconnect.h index 4fb1861e..898ed95f 100644 --- a/plugins/netconnect/netconnect.h +++ b/plugins/netconnect/netconnect.h @@ -57,8 +57,6 @@ using namespace kdk; #include "itemframe.h" #include "../component/Divider/divider.h" #include "../component/Pages/netdetail.h" -#include "../component/NetworkMode/networkmodeconfig.h" -#include "../component/NetworkMode/firewalldialog.h" enum { DISCONNECTED, @@ -125,8 +123,6 @@ private: //显示网络属性页 void showLanDetailPage(QString deviceName, LanItem *item); - //初始化已激活网络的网络模式 - void initActiveNetworkMode(QString deviceName, KyActivateItem activeItem); protected: bool eventFilter(QObject *w,QEvent *e); @@ -198,7 +194,6 @@ private Q_SLOTS: void onDeviceAdd(QString deviceName); void onDeviceRemove(QString deviceName); - void updateNetworkModeState(QString deviceName, QString ssid, QString uuid, KyConnectState status); //for dbus void showDetailPage(QString deviceName, QString connName); diff --git a/plugins/netconnect/netconnect.pro b/plugins/netconnect/netconnect.pro index 4fce26fd..7345cf02 100644 --- a/plugins/netconnect/netconnect.pro +++ b/plugins/netconnect/netconnect.pro @@ -10,7 +10,6 @@ include(../component/fixlabel.pri) include(../component/listitemedit.pri) include(../component/pages.pri) include(../component/kylinarping.pri) -include(../component/networkmode.pri) TARGET = $$qtLibraryTarget(netconnect) DESTDIR = ../.. diff --git a/plugins/wlanconnect/wlanconnect.cpp b/plugins/wlanconnect/wlanconnect.cpp index 45e9a96a..a82eb860 100644 --- a/plugins/wlanconnect/wlanconnect.cpp +++ b/plugins/wlanconnect/wlanconnect.cpp @@ -358,7 +358,6 @@ void WlanConnect::initConnect() connect(this, &WlanConnect::setWirelessNetworkEnabled, manager, &KyNetworkManager::onSetWirelessNetworkEnabled); connect(this, &WlanConnect::deleteConnect, manager, &KyNetworkManager::onDeleteConnect); - connect(manager, &KyNetworkManager::wirelessStateChange, this, &WlanConnect::updateNetworkModeState); connect(manager, &KyNetworkManager::wirelessStateChange, this, [=](QString deviceName, QString ssid, QString uuid, KyConnectState status) { Q_EMIT connectStateChanged(uuid, status); }); @@ -707,10 +706,6 @@ void WlanConnect::initNetListFromDevice(QString deviceName) manager->getActiveConnectionList(deviceName, CONNECT_TYPE_WIRELESS, activateList); if (activateList.size() != 0) { onActiveConnectionChanged(deviceName,activateList.at(0).m_ssid, activateList.at(0).m_uuid, activateList.at(0).m_connStatus); - - for (KyActivateItem item : activateList) { - initActiveNetworkMode(deviceName, item); - } } } @@ -1079,58 +1074,6 @@ void WlanConnect::showWlanDetailPage(QString deviceName, WlanItem *item) }); } -void WlanConnect::initActiveNetworkMode(QString deviceName, KyActivateItem activeItem) -{ - int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(activeItem.m_uuid); - if (configType == -1) { - NetworkModeConfig::getInstance()->setNetworkModeConfig(activeItem.m_uuid, - deviceName, - activeItem.m_connName, - KSC_FIREWALL_PUBLIC); - } else { - NetworkModeConfig::getInstance()->setNetworkModeConfig(activeItem.m_uuid, - deviceName, - activeItem.m_connName, - configType); - } -} - -void WlanConnect::updateNetworkModeState(QString deviceName, QString ssid, QString uuid, KyConnectState status) -{ - if (status == CONNECT_STATE_ACTIVATED) { - int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(uuid); - if (configType == -1) { - NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC); //默认公有配置 - FirewallDialog *fireWallDialog = new FirewallDialog(); //弹窗 供用户配置 - fireWallDialog->setUuid(uuid); - fireWallDialog->setWindowTitle(ssid); - - connect(fireWallDialog, &FirewallDialog::setPrivateNetMode, this, [=](){ - fireWallDialog->hide(); - NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE); - }); - - connect(fireWallDialog, &FirewallDialog::setPublicNetMode, this, [=](){ - fireWallDialog->hide(); - NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC); - }); - - connect(this, &WlanConnect::connectStateChanged, fireWallDialog, &FirewallDialog::closeMyself); - - fireWallDialog->show(); - fireWallDialog->centerToScreen(); - - } else if (configType == KSC_FIREWALL_PUBLIC) { - NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC); - } else if (configType == KSC_FIREWALL_PRIVATE) { - NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE); - } - } else if (status == CONNECT_STATE_DEACTIVATED) { - NetworkModeConfig::getInstance()->breakNetworkConnect(uuid, deviceName, ssid); - } -} - - void WlanConnect::showDetailPage(QString deviceName, QString ssid) { if (deviceName.isEmpty() || ssid.isEmpty()) { @@ -1162,6 +1105,7 @@ void WlanConnect::activateWirelessConnection(QString deviceName, QString ssid) if (nullptr == item) { return; } + Q_EMIT item->itemClick(); //todo-20230228 QDBusInterface interface("com.kylin.network", "/com/kylin/network", @@ -1170,6 +1114,4 @@ void WlanConnect::activateWirelessConnection(QString deviceName, QString ssid) if(interface.isValid()) { interface.call(QStringLiteral("showKylinNM"), 1); } - - Q_EMIT item->itemClick();//todo-20230228 } diff --git a/plugins/wlanconnect/wlanconnect.h b/plugins/wlanconnect/wlanconnect.h index 44a87aac..da440095 100644 --- a/plugins/wlanconnect/wlanconnect.h +++ b/plugins/wlanconnect/wlanconnect.h @@ -57,8 +57,6 @@ using namespace kdk; #include "wlanitem.h" #include "hiddenwifi/enterprisewlanpage.h" #include "../component/Pages/netdetail.h" -#include "../component/NetworkMode/networkmodeconfig.h" -#include "../component/NetworkMode/firewalldialog.h" class WlanConnect : public QObject, Interface { @@ -126,8 +124,7 @@ private: void setOtherItemExpandedFalse(QString devName, QString ssid); //显示网络属性页 void showWlanDetailPage(QString deviceName, WlanItem *item); - //初始化已激活网络的网络模式 - void initActiveNetworkMode(QString deviceName, KyActivateItem activeItem); + protected: bool eventFilter(QObject *w,QEvent *e); @@ -213,7 +210,6 @@ private Q_SLOTS: void onWirelessConnectionUpdate(QString deviceName, QString ssid, QString uuid, QString dbusPath, KySecuType connectSecuType); void onWirelessDeviceAdd(QString deviceName); void onWirelessDeviceRemove(QString deviceName); - void updateNetworkModeState(QString deviceName, QString ssid, QString uuid, KyConnectState status); //for dbus void showDetailPage(QString deviceName, QString ssid); diff --git a/plugins/wlanconnect/wlanconnect.pro b/plugins/wlanconnect/wlanconnect.pro index 3b8d9e47..5c72d960 100644 --- a/plugins/wlanconnect/wlanconnect.pro +++ b/plugins/wlanconnect/wlanconnect.pro @@ -10,7 +10,6 @@ include(../component/fixlabel.pri) include(../component/listitemedit.pri) include(../component/pages.pri) include(../component/kylinarping.pri) -include(../component/networkmode.pri) include(hiddenwifi/hiddenwifi.pri) TARGET = $$qtLibraryTarget(wlanconnect)