diff --git a/plugins/component/InfoButton/infobutton.cpp b/plugins/component/InfoButton/infobutton.cpp index 27a33f98..edb8b2db 100644 --- a/plugins/component/InfoButton/infobutton.cpp +++ b/plugins/component/InfoButton/infobutton.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #define BUTTON_SIZE 36,36 #define ICON_SIZE 16,16 diff --git a/plugins/netconnect/deviceframe.cpp b/plugins/netconnect/deviceframe.cpp index 31a3ea5a..a90e9f67 100644 --- a/plugins/netconnect/deviceframe.cpp +++ b/plugins/netconnect/deviceframe.cpp @@ -18,6 +18,7 @@ * */ #include "deviceframe.h" +#include #define LAYOUT_MARGINS 16,0,16,0 #define FRAME_HEIGHT 58 diff --git a/plugins/netconnect/lanitem.cpp b/plugins/netconnect/lanitem.cpp index 2df49237..70a845c8 100644 --- a/plugins/netconnect/lanitem.cpp +++ b/plugins/netconnect/lanitem.cpp @@ -45,11 +45,28 @@ LanItem::LanItem(bool isAcitve, QWidget *parent) statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); // statusLabel->setMinimumSize(36,36); infoLabel = new GrayInfoButton(this); + + //【更多】菜单 + m_moreButton = new QToolButton(this); + m_moreButton->setProperty("useButtonPalette", true); + m_moreButton->setPopupMode(QToolButton::InstantPopup); + m_moreButton->setAutoRaise(true); + m_moreButton->setIcon(QIcon::fromTheme("view-more-horizontal-symbolic")); + m_moreMenu = new QMenu(m_moreButton); + m_connectAction = new QAction(m_moreMenu); + m_deleteAction = new QAction(tr("Delete"), m_moreMenu); + setConnectActionText(isAcitve); + + m_moreMenu->addAction(m_connectAction); + m_moreMenu->addAction(m_deleteAction); + m_moreButton->setMenu(m_moreMenu); + mLanLyt->addWidget(iconLabel); mLanLyt->addWidget(titileLabel,Qt::AlignLeft); mLanLyt->addStretch(); mLanLyt->addWidget(statusLabel); mLanLyt->addWidget(infoLabel); + mLanLyt->addWidget(m_moreButton); loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic")); loadIcons.append(QIcon::fromTheme("ukui-loading-2-symbolic")); @@ -60,6 +77,9 @@ LanItem::LanItem(bool isAcitve, QWidget *parent) loadIcons.append(QIcon::fromTheme("ukui-loading-7-symbolic")); waitTimer = new QTimer(this); connect(waitTimer, &QTimer::timeout, this, &LanItem::updateIcon); + connect(m_connectAction, &QAction::triggered, this, &LanItem::onConnectTriggered); + connect(m_deleteAction, &QAction::triggered, this, &LanItem::onDeletetTriggered); + m_moreMenu->installEventFilter(this); } LanItem::~LanItem() @@ -67,6 +87,8 @@ LanItem::~LanItem() } + + void LanItem::updateIcon() { if (currentIconIndex > 6) { @@ -87,6 +109,40 @@ void LanItem::stopLoading(){ loading = false; } +/** + * @brief LanItem::setConnectActionText + * 【更多】菜单状态切换 连接/断开 + * @param isAcitve + */ +void LanItem::setConnectActionText(bool isAcitve) +{ + if (isAcitve) { + m_connectAction->setText(tr("Disconnect")); + } else { + m_connectAction->setText(tr("Connect")); + } +} + +void LanItem::onConnectTriggered() +{ + if (!m_connectAction) { + return; + } + if (m_connectAction->text() == tr("Connect")) { + Q_EMIT connectActionTriggered(); + } else if (m_connectAction->text() == tr("Disconnect")) { + Q_EMIT disconnectActionTriggered(); + } +} + +void LanItem::onDeletetTriggered() +{ + if (!m_deleteAction) { + return; + } + Q_EMIT deleteActionTriggered(); +} + void LanItem::paintEvent(QPaintEvent *event) { QPalette pal = qApp->palette(); @@ -107,3 +163,18 @@ void LanItem::paintEvent(QPaintEvent *event) QPushButton::paintEvent(event); } +bool LanItem::eventFilter(QObject *watched, QEvent *event) +{ + //菜单右边界与按钮右边界对齐 + if (event->type() == QEvent::Show && watched == m_moreMenu) { + int menuXPos = m_moreMenu->pos().x(); + int menuWidth = m_moreMenu->size().width(); + int btnWidth = m_moreButton->size().width(); + + QPoint pos = QPoint (menuXPos - menuWidth + btnWidth, m_moreMenu->pos().y()); + m_moreMenu->move(pos); + return true; + } + return false; +} + diff --git a/plugins/netconnect/lanitem.h b/plugins/netconnect/lanitem.h index ea1b1355..b27a9df2 100644 --- a/plugins/netconnect/lanitem.h +++ b/plugins/netconnect/lanitem.h @@ -29,12 +29,16 @@ #include #include #include +#include +#include +#include #include "fixlabel.h" //#include "infobutton.h" #include "../component/AddBtn/grayinfobutton.h" class LanItem : public QPushButton { + Q_OBJECT public: LanItem(bool isAcitve, QWidget *parent = nullptr); ~LanItem(); @@ -43,10 +47,15 @@ public: GrayInfoButton * infoLabel = nullptr; FixLabel * titileLabel = nullptr; QLabel * statusLabel = nullptr; + QToolButton* m_moreButton = nullptr; + QMenu* m_moreMenu = nullptr; + QAction* m_connectAction = nullptr; + QAction* m_deleteAction = nullptr; public: void startLoading(); void stopLoading(); + void setConnectActionText(bool isAcitve); bool loading = false; bool isAcitve = false; @@ -56,15 +65,23 @@ public: protected: void paintEvent(QPaintEvent *); + bool eventFilter(QObject *watched, QEvent *event); private: QTimer *waitTimer = nullptr; QGSettings *themeGsettings = nullptr; QList loadIcons; - int currentIconIndex=0; + int currentIconIndex=0; private slots: - void updateIcon(); + void updateIcon(); + void onConnectTriggered(); + void onDeletetTriggered(); + +Q_SIGNALS: + void connectActionTriggered(); + void disconnectActionTriggered(); + void deleteActionTriggered(); }; diff --git a/plugins/netconnect/netconnect.cpp b/plugins/netconnect/netconnect.cpp index 71bb66ee..fe8ae7b2 100644 --- a/plugins/netconnect/netconnect.cpp +++ b/plugins/netconnect/netconnect.cpp @@ -32,6 +32,9 @@ #define ITEMHEIGH 50 #define LAN_TYPE 0 #define CONTROL_CENTER_WIFI "org.ukui.control-center.wifi.switch" +#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager" +#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager" +#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager" const QString KLanSymbolic = "network-wired-connected-symbolic"; const QString NoNetSymbolic = "network-wired-disconnected-symbolic"; @@ -351,10 +354,20 @@ void NetConnect::initNet() } } +//刪除 +void NetConnect::deleteOneLan(QString ssid, int type) +{ + qDebug() << "[NetConnect]call deleteConnect" << __LINE__; + m_interface->call(QStringLiteral("deleteConnect"), type, ssid); + qDebug() << "[NetConnect]call deleteConnect respond" << __LINE__; +} + void NetConnect::runExternalApp() { - QString cmd = "nm-connection-editor"; - QProcess process(this); - process.startDetached(cmd); + if (!LaunchApp("nm-connection-editor.desktop")){ + QString cmd = "nm-connection-editor"; + QProcess process(this); + process.startDetached(cmd); + } } //激活 @@ -431,12 +444,12 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL return; } - LanItem * lanItem = new LanItem(pluginWidget); + LanItem * lanItem = new LanItem(isActived, pluginWidget); QString iconPath = KLanSymbolic; if (isActived) { lanItem->statusLabel->setText(tr("connected")); } else { - lanItem->statusLabel->setText(""); + lanItem->statusLabel->setText(tr("not connected")); } QIcon searchIcon = QIcon::fromTheme(iconPath); // if (iconPath != KLanSymbolic && iconPath != NoNetSymbolic) { @@ -459,6 +472,7 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL }); lanItem->isAcitve = isActived; + lanItem->setConnectActionText(lanItem->isAcitve); connect(lanItem, &QPushButton::clicked, this, [=] { if (lanItem->isAcitve || lanItem->loading) { @@ -468,6 +482,16 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL } }); + connect(lanItem, &LanItem::connectActionTriggered, this, [=] { + activeConnect(lanItem->uuid, devName, WIRED_TYPE); + }); + connect(lanItem, &LanItem::disconnectActionTriggered, this, [=] { + deActiveConnect(lanItem->uuid, devName, WIRED_TYPE); + }); + connect(lanItem, &LanItem::deleteActionTriggered, this, [=] { + deleteOneLan(lanItem->uuid, WIRED_TYPE); + }); + //记录到deviceFrame的itemMap中 deviceFrameMap[devName]->itemMap.insert(infoList.at(1), lanItem); qDebug()<<"insert " << infoList.at(1) << " to " << devName << " list"; @@ -722,7 +746,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis QString iconPath; iconPath = KLanSymbolic; - lanItem->statusLabel->setText(""); + lanItem->statusLabel->setText(tr("not connected")); QIcon searchIcon = QIcon::fromTheme(iconPath); // if (iconPath != KLanSymbolic && iconPath != NoNetSymbolic) { @@ -745,6 +769,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis }); lanItem->isAcitve = false; + lanItem->setConnectActionText(lanItem->isAcitve); connect(lanItem, &QPushButton::clicked, this, [=] { if (lanItem->isAcitve || lanItem->loading) { @@ -754,6 +779,16 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis } }); + connect(lanItem, &LanItem::connectActionTriggered, this, [=] { + activeConnect(lanItem->uuid, deviceName, WIRED_TYPE); + }); + connect(lanItem, &LanItem::disconnectActionTriggered, this, [=] { + deActiveConnect(lanItem->uuid, deviceName, WIRED_TYPE); + }); + connect(lanItem, &LanItem::deleteActionTriggered, this, [=] { + deleteOneLan(lanItem->uuid, WIRED_TYPE); + }); + //记录到deviceFrame的itemMap中 deviceFrameMap[deviceName]->itemMap.insert(connUuid, lanItem); int index = getInsertPos(connName, deviceName); @@ -868,7 +903,9 @@ void NetConnect::itemActiveConnectionStatusChanged(LanItem *item, int status) item->statusLabel->setMaximumSize(16777215,16777215); item->statusLabel->clear(); item->isAcitve = false; + item->statusLabel->setText(tr("not connected")); } + item->setConnectActionText(item->isAcitve); // QIcon searchIcon = QIcon::fromTheme(iconPath); // item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(24, 24)))); @@ -909,3 +946,19 @@ int NetConnect::getInsertPos(QString connName, QString deviceName) } return index; } + +bool NetConnect::LaunchApp(QString desktopFile) +{ + QDBusInterface m_appManagerDbusInterface(KYLIN_APP_MANAGER_NAME, + KYLIN_APP_MANAGER_PATH, + KYLIN_APP_MANAGER_INTERFACE, + QDBusConnection::sessionBus());//局部变量 + + if (!m_appManagerDbusInterface.isValid()) { + qWarning()<<"m_appManagerDbusInterface init error"; + return false; + } else { + QDBusReply reply =m_appManagerDbusInterface.call("LaunchApp",desktopFile); + return reply; + } +} diff --git a/plugins/netconnect/netconnect.h b/plugins/netconnect/netconnect.h index f991540f..e8858614 100644 --- a/plugins/netconnect/netconnect.h +++ b/plugins/netconnect/netconnect.h @@ -101,7 +101,7 @@ private: int getInsertPos(QString connName, QString deviceName); - void deleteOneLan(QString ssid); + void deleteOneLan(QString ssid, int type); void activeConnect(QString ssid, QString deviceName, int type); void deActiveConnect(QString ssid, QString deviceName, int type); @@ -123,6 +123,7 @@ private: //单个lan连接状态变化 void itemActiveConnectionStatusChanged(LanItem *item, int status); + bool LaunchApp(QString desktopFile); protected: bool eventFilter(QObject *w,QEvent *e); diff --git a/plugins/vpn/itemframe.cpp b/plugins/vpn/itemframe.cpp deleted file mode 100644 index 816828f7..00000000 --- a/plugins/vpn/itemframe.cpp +++ /dev/null @@ -1,63 +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 "itemframe.h" -#include - -#define LAYOUT_MARGINS 0,0,0,0 -#define MAIN_LAYOUT_MARGINS 0,0,0,0 -ItemFrame::ItemFrame(QWidget *parent) - :QFrame(parent) -{ - deviceLanLayout = new QVBoxLayout(this); - deviceLanLayout->setContentsMargins(MAIN_LAYOUT_MARGINS); - lanItemFrame = new QFrame(this); - lanItemFrame->setFrameShape(QFrame::Shape::NoFrame); - lanItemFrame->setContentsMargins(LAYOUT_MARGINS); - - lanItemLayout = new QVBoxLayout(this); - lanItemLayout->setContentsMargins(LAYOUT_MARGINS); - lanItemLayout->setSpacing(1); - addWlanWidget = new AddNetBtn(false, this); - addWlanWidget->setTextLabel(tr("Add Vpn")); - - deviceLanLayout->setSpacing(1); - setLayout(deviceLanLayout); - lanItemFrame->setLayout(lanItemLayout); - - deviceLanLayout->addWidget(lanItemFrame); - deviceLanLayout->addWidget(addWlanWidget); -} - -void ItemFrame::filletStyleChange() -{ - if (lanItemLayout->isEmpty()) { - return; - } - - for (int i = 0; i < lanItemLayout->count(); ++i) { - QLayoutItem *it = lanItemLayout->itemAt(i); - VpnItem *itemFrame = (VpnItem*)(it->widget()); - if (i != lanItemLayout->count()-1) { - itemFrame->setHalfFillet(false); - } else { - itemFrame->setHalfFillet(true); - } - } -} diff --git a/plugins/vpn/itemframe.h b/plugins/vpn/itemframe.h deleted file mode 100644 index b41153fa..00000000 --- a/plugins/vpn/itemframe.h +++ /dev/null @@ -1,47 +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 ITEMFRAME_H -#define ITEMFRAME_H -#include -#include -#include "../component/AddBtn/addnetbtn.h" -#include "vpnitem.h" - -class ItemFrame : public QFrame -{ - Q_OBJECT -public: - ItemFrame(QWidget *parent = nullptr); - //单设备整体layout - QVBoxLayout * deviceLanLayout = nullptr; - //单设备列表Frame - QFrame * lanItemFrame = nullptr; - //单设备列表layout - QVBoxLayout * lanItemLayout = nullptr; - //item列表 - QMap itemMap; -// //已激活uuid -// QString uuid = ""; - //新建无线连接 - AddNetBtn * addWlanWidget = nullptr; - void filletStyleChange(); -}; - -#endif // ITEMFRAME_H diff --git a/plugins/vpn/translations/zh_CN.qm b/plugins/vpn/translations/zh_CN.qm deleted file mode 100644 index 56074df7..00000000 Binary files a/plugins/vpn/translations/zh_CN.qm and /dev/null differ diff --git a/plugins/vpn/translations/zh_CN.ts b/plugins/vpn/translations/zh_CN.ts deleted file mode 100644 index ed7ce029..00000000 --- a/plugins/vpn/translations/zh_CN.ts +++ /dev/null @@ -1,80 +0,0 @@ - - - - - AddNetBtn - - - Add Others - - - - - Add WiredNetork - - - - - ItemFrame - - - Add Vpn - 添加VPN - - - - Vpn - - - VPN - - - - - import - - - - - Vpn - - - - - Show on Taskbar - 在任务栏显示图标 - - - - - connected - 已连接 - - - - - not connected - 未连接 - - - - VpnItem - - - Delete - 删除 - - - - - Disconnect - 断开 - - - - - Connect - 连接 - - - diff --git a/plugins/vpn/vpn.cpp b/plugins/vpn/vpn.cpp deleted file mode 100644 index f4c13273..00000000 --- a/plugins/vpn/vpn.cpp +++ /dev/null @@ -1,497 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * Copyright (C) 2019 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 "vpn.h" -#include "ui_vpn.h" - -#include -#include -#include -#include -#include - -#define ACTIVATING 1 -#define ACTIVATED 2 -#define DEACTIVATING 3 -#define DEACTIVATED 4 - -#define LABEL_RECT 17, 0, 105, 23 -#define CONTENTS_MARGINS 0, 0, 0, 0 -#define ITEM_MARGINS 16, 0, 16, 0 -#define FRAME_MIN_SIZE 550, 60 -#define FRAME_MAX_SIZE 16777215, 16777215 -#define CONTECT_FRAME_MAX_SIZE 16777215, 60 -#define HINT_TEXT_MARGINS 8, 0, 0, 0 -#define FRAME_MIN_SIZE 550, 60 -#define LABLE_MIN_WIDTH 188 -#define COMBOBOX_MIN_WIDTH 200 -#define LINE_MAX_SIZE 16777215, 1 -#define LINE_MIN_SIZE 0, 1 -#define ICON_SIZE 24,24 -#define PASSWORD_FRAME_MIN_HIGHT 60 -#define PASSWORD_FRAME_FIX_HIGHT 80 -#define PASSWORD_FRAME_MIN_SIZE 550, 60 -#define PASSWORD_FRAME_MAX_SIZE 16777215, 86 -#define PASSWORD_ITEM_MARGINS 16, 12, 16, 14 - -#define KVpnSymbolic "ukui-vpn-symbolic" - -#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager" -#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager" -#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager" - -const QString VISIBLE = "visible"; -const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.vpnicon"; - -Vpn::Vpn() : mFirstLoad(true) -{ - QTranslator* translator = new QTranslator(this); - translator->load("/usr/share/kylin-nm/vpn/" + QLocale::system().name()); - QApplication::installTranslator(translator); - - pluginName = tr("Vpn"); - pluginType = NETWORK; -} - -Vpn::~Vpn() -{ - if (!mFirstLoad) { - delete ui; - ui = nullptr; - delete m_interface; - delete m_switchGsettings; - } -} - -QString Vpn::plugini18nName(){ - return pluginName; -} - -int Vpn::pluginTypes(){ - return pluginType; -} - -QWidget *Vpn::pluginUi(){ - if (mFirstLoad) { - mFirstLoad = false; - ui = new Ui::Vpn; - pluginWidget = new QWidget; - pluginWidget->setAttribute(Qt::WA_DeleteOnClose); - ui->setupUi(pluginWidget); - - qDBusRegisterMetaType>(); - m_interface = new QDBusInterface("com.kylin.network", - "/com/kylin/vpnTool", - "com.kylin.vpnTool", - QDBusConnection::sessionBus()); - if(!m_interface->isValid()) { - qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message()); - } - - initComponent(); - initConnect(); - initNet(); - } - return pluginWidget; -} - -const QString Vpn::name() const { - - return QStringLiteral("Vpn"); -} - -bool Vpn::isShowOnHomePage() const -{ - return true; -} - -QIcon Vpn::icon() const -{ - return QIcon::fromTheme("ukui-vpn-symbolic"); -} - -bool Vpn::isEnable() const -{ - return true; -} - -void Vpn::initComponent(){ - //在任务栏上显示图标 - //显示已连接时间 - m_topFrame = new QFrame(pluginWidget); - m_topFrame->setMinimumSize(FRAME_MIN_SIZE); - m_topFrame->setMaximumSize(FRAME_MAX_SIZE); - m_topFrame->setFrameShape(QFrame::Box); - - QVBoxLayout *hotspotLyt = new QVBoxLayout(pluginWidget); - hotspotLyt->setContentsMargins(0, 0, 0, 0); - m_topFrame->setLayout(hotspotLyt); - - m_showFrame = new QFrame(m_topFrame); - m_showFrame->setFrameShape(QFrame::Shape::NoFrame); - m_showFrame->setMinimumSize(FRAME_MIN_SIZE); - m_showFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE); - QHBoxLayout *showLayout = new QHBoxLayout(m_showFrame); - m_showLabel = new QLabel(tr("Show on Taskbar"), m_showFrame); - m_showLabel->setMinimumWidth(LABLE_MIN_WIDTH); - m_showBtn = new KSwitchButton(m_showFrame); - showLayout->setContentsMargins(ITEM_MARGINS); - showLayout->addWidget(m_showLabel); - showLayout->addStretch(); - showLayout->addWidget(m_showBtn); - - m_showFrame->setLayout(showLayout); - -// m_Line = myLine(); - -// m_timeFrame = new QFrame(m_topFrame); -// m_timeFrame->setFrameShape(QFrame::Shape::NoFrame); -// m_timeFrame->setMinimumSize(FRAME_MIN_SIZE); -// m_timeFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE); -// QHBoxLayout *timeLayout = new QHBoxLayout(m_timeFrame); -// m_timeLabel = new QLabel(tr("Open"), m_timeFrame); -// m_timeLabel->setMinimumWidth(LABLE_MIN_WIDTH); -// m_timeBtn = new KSwitchButton(m_timeFrame); -// timeLayout->setContentsMargins(ITEM_MARGINS); -// timeLayout->addWidget(m_timeLabel); -// timeLayout->addStretch(); -// timeLayout->addWidget(m_timeBtn); - -// m_timeFrame->setLayout(timeLayout); - - hotspotLyt->addWidget(m_showFrame); -// hotspotLyt->addWidget(m_Line); -// hotspotLyt->addWidget(m_timeFrame); - hotspotLyt->setSpacing(0); - - //列表 - m_listFrame = new ItemFrame(pluginWidget); - - ui->verticalLayout_4->addWidget(m_topFrame); - ui->verticalLayout_3->addWidget(m_listFrame); - - connect(m_listFrame->addWlanWidget, &AddNetBtn::clicked, this, [=]() { - runExternalApp(); - }); - - if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) { - m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA); - setShowSwitchStatus(); - - connect(m_switchGsettings, &QGSettings::changed, this, [=] (const QString &key) { - if (key == VISIBLE) { - setShowSwitchStatus(); - } - }); - } else { - m_showBtn->setChecked(false); - m_showBtn->setCheckable(false); - qDebug()<<"[Vpn] org.ukui.kylin-nm.visible is not installed!"; - } - - connect(m_showBtn, &KSwitchButton::stateChanged, this, [=](bool state){ - if (m_switchGsettings != nullptr) { - m_switchGsettings->set(VISIBLE, state); - } - }); - -// connect(m_timeBtn, &KSwitchButton::stateChanged, this, [=](bool state){ -// if (m_switchGsettings != nullptr) { -// m_switchGsettings->set(VISIBLE, state); -// } -// }); - ui->pushButton->hide(); -} - -void Vpn::initConnect() -{ - connect(m_interface, SIGNAL(vpnAdd(QStringList)), this, SLOT(onVpnAdd(QStringList))); - connect(m_interface, SIGNAL(vpnRemove(QString)), this, SLOT(onVpnRemove(QString))); - connect(m_interface, SIGNAL(vpnUpdate(QStringList)), this, SLOT(onVpnUpdate(QStringList))); - connect(m_interface, SIGNAL(vpnActiveConnectionStateChanged(QString, int)), - this, SLOT(onVpnActiveConnectionStateChanged(QString, int))); -} - -//初始化列表 -void Vpn::initNet() -{ - qDebug() << "[Vpn]initNet"; - if (!m_interface->isValid()) { - return; - } - QDBusMessage result = m_interface->call(QStringLiteral("getVirtualList")); - if(result.type() == QDBusMessage::ErrorMessage) - { - qWarning() << "getVirtualList error:" << result.errorMessage(); - return; - } - auto dbusArg = result.arguments().at(0).value(); - QVector variantList; - dbusArg >> variantList; - if (variantList.size() == 0) { - qDebug() << "[Vpn]initNet list empty"; - return; - } - - for (int i = 0; i < variantList.size(); ++i) { - QStringList vpnInfo = variantList.at(i); - addOneVirtualItem(vpnInfo); - } - return; -} - -void Vpn::setShowSwitchStatus() -{ - if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) { - bool status = m_switchGsettings->get(VISIBLE).toBool(); - m_showBtn->setChecked(status); - } else { - qDebug()<<"[Vpn] org.ukui.kylin-nm.switch is not installed!"; - } -} - -void Vpn::runExternalApp(){ - QString cmd = "nm-connection-editor"; - QProcess process(this); - process.startDetached(cmd); -} - -QFrame* Vpn::myLine() -{ - QFrame *line = new QFrame(pluginWidget); - line->setMinimumSize(QSize(LINE_MIN_SIZE)); - line->setMaximumSize(QSize(LINE_MAX_SIZE)); - line->setLineWidth(0); - line->setFrameShape(QFrame::HLine); - line->setFrameShadow(QFrame::Sunken); - - return line; -} - -//刪除 -void Vpn::deleteVpn(QString uuid) -{ - m_interface->call(QStringLiteral("deleteVpn"), uuid); -} - -//激活 -void Vpn::activeConnect(QString uuid) { - m_interface->call(QStringLiteral("activateVpn"), uuid); -} - -//断开 -void Vpn::deActiveConnect(QString uuid) { - m_interface->call(QStringLiteral("deactivateVpn"), uuid); -} - - -//增加一项 -void Vpn::addOneVirtualItem(QStringList infoList) -{ - if (m_listFrame->itemMap.contains(infoList.at(1))) { - qDebug() << "[Vpn]Already exist a virtual " << infoList.at(1); - return; - } - - qDebug() << "[Vpn]addOneVitualItem" << infoList.at(0) << infoList.at(3) ; - QString connName = infoList.at(0); - QString connUuid = infoList.at(1); - QString connDbusPath = infoList.at(2); - int status = infoList.at(3).toInt(); //1-连接中 2-已连接 3-断开中 4-已断开 - VpnItem * item = new VpnItem(pluginWidget); - - QIcon searchIcon = QIcon::fromTheme(KVpnSymbolic); - item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE)))); - item->titileLabel->setText(connName); - - item->uuid = connUuid; - item->dbusPath = connDbusPath; - - if (status == 1 || status == 3) { - item->startLoading(); - } - - connect(item->infoLabel, &GrayInfoButton::clicked, this, [=]{ - QDBusInterface appManagerDbusInterface(KYLIN_APP_MANAGER_NAME, - KYLIN_APP_MANAGER_PATH, - KYLIN_APP_MANAGER_INTERFACE, - QDBusConnection::sessionBus()); - - if (!appManagerDbusInterface.isValid()) { - qWarning()<<"appManagerDbusInterface init error"; - } else { - QDBusReply reply = appManagerDbusInterface.call("LaunchApp", "nm-connection-editor.desktop"); - } - }); - - item->isAcitve = (status == 2); - item->setConnectActionText(item->isAcitve); - - if (item->isAcitve) { - item->statusLabel->setText(tr("connected")); - } else { - item->statusLabel->setText(tr("not connected")); - } - - connect(item, &QPushButton::clicked, this, [=] { - if (item->isAcitve || item->loading) { - deActiveConnect(item->uuid); - } else { - activeConnect(item->uuid); - } - }); - - connect(item, &VpnItem::connectActionTriggered, this, [=] { - activeConnect(item->uuid); - }); - connect(item, &VpnItem::disconnectActionTriggered, this, [=] { - deActiveConnect(item->uuid); - }); - connect(item, &VpnItem::deleteActionTriggered, this, [=] { - deleteVpn(item->uuid); - }); - - //记录到deviceFrame的itemMap中 - m_listFrame->itemMap.insert(connUuid, item); - int index = getInsertPos(connName); - qDebug()<<"[Vpn]addOneVirtualItem " << connName << " at pos:" << index; - m_listFrame->lanItemLayout->insertWidget(index, item); -} - -void Vpn::removeOneVirtualItem(QString dbusPath) -{ - qDebug()<<"[Vpn]vpn remove dbus path:" << dbusPath; - - QMap::iterator itemIter; - for (itemIter = m_listFrame->itemMap.begin(); itemIter != m_listFrame->itemMap.end(); itemIter++) { - if (itemIter.value()->dbusPath == dbusPath) { - qDebug()<<"[Vpn]vpn remove " << dbusPath << " find in " << itemIter.value()->titileLabel->text(); - QString key = itemIter.key(); - m_listFrame->lanItemLayout->removeWidget(itemIter.value()); - delete itemIter.value(); - m_listFrame->itemMap.remove(key); - break; - } - } -} - -//增加 -void Vpn::onVpnAdd(QStringList infoList) -{ - addOneVirtualItem(infoList); -} - -//移出 -void Vpn::onVpnRemove(QString uuid) -{ - removeOneVirtualItem(uuid); -} - -//名称变化 -void Vpn::onVpnUpdate(QStringList info) -{ - if (m_listFrame->itemMap.contains(info.at(1))) { - qDebug() << "[Vpn]" << m_listFrame->itemMap[info.at(1)]->titileLabel->text() << "change to" << info.at(0); - if (m_listFrame->itemMap[info.at(1)]->titileLabel->text() != info.at(0)) { - m_listFrame->itemMap[info.at(1)]->titileLabel->setText(info.at(0)); - } - } -} - -void Vpn::onVpnActiveConnectionStateChanged(QString uuid, int status) -{ - if (uuid.isEmpty()) { - qDebug() << "[Vpn]onActiveConnectionChanged but uuid is empty"; - return; - } - qDebug() << "[Vpn]onActiveConnectionChanged " << uuid << status; - VpnItem * item= nullptr; - - if (m_listFrame->itemMap.contains(uuid)) { - item = m_listFrame->itemMap[uuid]; - if (status == ACTIVATED) { - //为已连接则放到第一个 - m_listFrame->lanItemLayout->removeWidget(item); - m_listFrame->lanItemLayout->insertWidget(0,item); - } else if (status == DEACTIVATED) { - //为断开则重新插入 - int index = getInsertPos(item->titileLabel->text()); - qDebug() << "[Vpn]reinsert" << item->titileLabel->text() << "pos" << index << "because status changes to deactive"; - m_listFrame->lanItemLayout->removeWidget(item); - m_listFrame->lanItemLayout->insertWidget(index,item); - } - itemActiveConnectionStatusChanged(item, status); - } -} - -void Vpn::itemActiveConnectionStatusChanged(VpnItem *item, int status) -{ -// QString iconPath = NoNetSymbolic; - if (status == ACTIVATING) { - item->startLoading(); - } else if (status == ACTIVATED) { - item->stopLoading(); -// iconPath = KLanSymbolic; - item->statusLabel->clear(); - item->statusLabel->setMinimumSize(36,36); - item->statusLabel->setMaximumSize(16777215,16777215); - item->statusLabel->setText(tr("connected")); - item->isAcitve = true; - } else if (status == DEACTIVATING) { - item->startLoading(); - } else { - item->stopLoading(); - item->statusLabel->setMinimumSize(36,36); - item->statusLabel->setMaximumSize(16777215,16777215); - item->statusLabel->clear(); - item->isAcitve = false; - item->statusLabel->setText(tr("not connected")); - } - item->setConnectActionText(item->isAcitve); -} - -int Vpn::getInsertPos(QString connName) -{ - qDebug() << "[Vpn]getInsertPos" << connName; - int index = 0; - if(!m_interface->isValid()) { - index = 0; - } else { - QDBusMessage result = m_interface->call(QStringLiteral("getVirtualList")); - if(result.type() == QDBusMessage::ErrorMessage) - { - qWarning() << "getVirtualList error:" << result.errorMessage(); - return 0; - } - auto dbusArg = result.arguments().at(0).value(); - QVector variantList; - dbusArg >> variantList; - for (int i = 0; i < variantList.size(); ++i ) { - if (variantList.at(i).at(0) == connName) { - qDebug() << "pos in kylin-nm is " << i; - index = i; - break; - } - } - if (variantList.at(0).size() == 1) { - index--; - } - } - return index; -} diff --git a/plugins/vpn/vpn.h b/plugins/vpn/vpn.h deleted file mode 100644 index 941f8f4f..00000000 --- a/plugins/vpn/vpn.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * Copyright (C) 2019 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 VPN_H -#define VPN_H - -#include -#include -#include -#include -#include - -#include "interface.h" -#include "addbtn.h" -#include "imageutil.h" -#include "kwidget.h" -#include "kswitchbutton.h" -#include "itemframe.h" - -using namespace kdk; - -namespace Ui { -class Vpn; -} - -class Vpn : public QObject, CommonInterface -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface") - Q_INTERFACES(CommonInterface) - -public: - Vpn(); - ~Vpn(); - - QString plugini18nName() Q_DECL_OVERRIDE; - int pluginTypes() Q_DECL_OVERRIDE; - QWidget * pluginUi() Q_DECL_OVERRIDE; - const QString name() const Q_DECL_OVERRIDE; - bool isShowOnHomePage() const Q_DECL_OVERRIDE; - QIcon icon() const Q_DECL_OVERRIDE; - bool isEnable() const Q_DECL_OVERRIDE; - -public: - void initComponent(); - void initConnect(); - - void runExternalApp(); - -protected: -// bool eventFilter(QObject *watched, QEvent *event); - -private: - Ui::Vpn *ui; - - QString pluginName; - int pluginType; - QWidget * pluginWidget; - - QDBusInterface *m_interface = nullptr; - - QFrame *m_topFrame; - QFrame *m_showFrame; - QLabel *m_showLabel; - KSwitchButton *m_showBtn; - QFrame *m_Line; - QFrame *m_timeFrame; - QLabel *m_timeLabel; - KSwitchButton *m_timeBtn; - ItemFrame *m_listFrame; - - bool mFirstLoad; - QGSettings *m_switchGsettings; - - QFrame* myLine(); - - int getInsertPos(QString connName); - - void deleteVpn(QString uuid); - void activeConnect(QString uuid); - void deActiveConnect(QString uuid); - - //获取设备列表 - void initNet(); - //增加一项 - void addOneVirtualItem(QStringList infoList); - //减少一项 - void removeOneVirtualItem(QString uuid); - //单个lan连接状态变化 - void itemActiveConnectionStatusChanged(VpnItem *item, int status); - - - void setShowSwitchStatus(); - -private slots: - void onVpnAdd(QStringList); - void onVpnRemove(QString); - void onVpnUpdate(QStringList); - void onVpnActiveConnectionStateChanged(QString, int); - -}; - -#endif // VPN_H diff --git a/plugins/vpn/vpn.pro b/plugins/vpn/vpn.pro deleted file mode 100644 index 957517c6..00000000 --- a/plugins/vpn/vpn.pro +++ /dev/null @@ -1,50 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-06-29T13:53:10 -# -#------------------------------------------------- - -QT += widgets dbus - -TEMPLATE = lib -CONFIG += plugin \ - c++11 \ - link_pkgconfig - -include(../component/addbtn.pri) - -PKGCONFIG += gsettings-qt \ - kysdk-qtwidgets \ - -TARGET = $$qtLibraryTarget(vpn) -DESTDIR = ../.. -target.path = $$[QT_INSTALL_LIBS]/ukui-control-center -trans.files = translations/* -trans.path = /usr/share/kylin-nm/vpn/ - -INCLUDEPATH += \ - $$PROJECT_COMPONENTSOURCE \ - $$PROJECT_ROOTDIR \ - /usr/include/ukcc/interface \ - /usr/include/ukcc/widgets - -LIBS += -L$$[QT_INSTALL_LIBS] -lukcc - -SOURCES += \ - vpn.cpp \ - itemframe.cpp \ - vpnitem.cpp - -HEADERS += \ - vpn.h \ - itemframe.h \ - vpnitem.h - -FORMS += \ - vpn.ui - -INSTALLS += target \ - trans - -TRANSLATIONS += \ - translations/zh_CN.ts diff --git a/plugins/vpn/vpn.ui b/plugins/vpn/vpn.ui deleted file mode 100644 index bd1de4af..00000000 --- a/plugins/vpn/vpn.ui +++ /dev/null @@ -1,112 +0,0 @@ - - - Vpn - - - - 0 - 0 - 800 - 710 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Vpn - - - - 8 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - VPN - - - - - - - - - - - - - - - import - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - TitleLabel - QLabel -
titlelabel.h
-
-
- - -
diff --git a/plugins/vpn/vpnitem.cpp b/plugins/vpn/vpnitem.cpp deleted file mode 100644 index 28ff57eb..00000000 --- a/plugins/vpn/vpnitem.cpp +++ /dev/null @@ -1,187 +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 "vpnitem.h" -#include -#define FRAME_SPEED 150 -#define LIMIT_TIME 60*1000 -#define TOTAL_PAGE 8 -#define RADIUS 6.0 - -#define THEME_QT_SCHEMA "org.ukui.style" -#define MODE_QT_KEY "style-name" - -VpnItem::VpnItem(bool bAcitve, QWidget *parent) - : isAcitve(bAcitve), QPushButton(parent) -{ - this->setMinimumSize(550, 58); - this->setProperty("useButtonPalette", true); - this->setFlat(true); - QPalette pal = this->palette(); - QColor color = pal.color(QPalette::Button); - color.setAlphaF(0.5); - pal.setColor(QPalette::Button, color); - this->setPalette(pal); - QHBoxLayout *mLanLyt = new QHBoxLayout(this); - mLanLyt->setContentsMargins(16,0,16,0); - mLanLyt->setSpacing(16); - iconLabel = new QLabel(this); - iconLabel->setProperty("useIconHighlightEffect", 0x2); - titileLabel = new FixLabel(this); - statusLabel = new QLabel(this); - statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); - infoLabel = new GrayInfoButton(this); - - m_moreButton = new QToolButton(this); - m_moreButton->setProperty("useButtonPalette", true); - m_moreButton->setPopupMode(QToolButton::InstantPopup); - m_moreButton->setAutoRaise(true); - m_moreButton->setIcon(QIcon::fromTheme("view-more-horizontal-symbolic")); - m_moreMenu = new QMenu(m_moreButton); - m_connectAction = new QAction(m_moreMenu); - m_deleteAction = new QAction(tr("Delete"), m_moreMenu); - setConnectActionText(isAcitve); - - m_moreMenu->addAction(m_connectAction); - m_moreMenu->addAction(m_deleteAction); - m_moreButton->setMenu(m_moreMenu); - - mLanLyt->addWidget(iconLabel); - mLanLyt->addWidget(titileLabel,Qt::AlignLeft); - mLanLyt->addStretch(); - mLanLyt->addWidget(statusLabel); - mLanLyt->addWidget(infoLabel); - mLanLyt->addWidget(m_moreButton); - - loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic")); - loadIcons.append(QIcon::fromTheme("ukui-loading-2-symbolic")); - loadIcons.append(QIcon::fromTheme("ukui-loading-3-symbolic")); - loadIcons.append(QIcon::fromTheme("ukui-loading-4-symbolic")); - loadIcons.append(QIcon::fromTheme("ukui-loading-5-symbolic")); - loadIcons.append(QIcon::fromTheme("ukui-loading-6-symbolic")); - loadIcons.append(QIcon::fromTheme("ukui-loading-7-symbolic")); - - waitTimer = new QTimer(this); - connect(waitTimer, &QTimer::timeout, this, &VpnItem::updateIcon); - - connect(m_connectAction, &QAction::triggered, this, &VpnItem::onConnectTriggered); - connect(m_deleteAction, &QAction::triggered, this, &VpnItem::onDeletetTriggered); - m_moreMenu->installEventFilter(this); -} - -void VpnItem::updateIcon() -{ - if (currentIconIndex > 6) { - currentIconIndex = 0; - } - statusLabel->setPixmap(loadIcons.at(currentIconIndex).pixmap(16,16)); - currentIconIndex ++; -} - -void VpnItem::startLoading() -{ - waitTimer->start(FRAME_SPEED); - loading = true; -} - -void VpnItem::stopLoading(){ - waitTimer->stop(); - loading = false; -} - -void VpnItem::setConnectActionText(bool isAcitve) -{ - if (isAcitve) { - m_connectAction->setText(tr("Disconnect")); - } else { - m_connectAction->setText(tr("Connect")); - } -} - -void VpnItem::onConnectTriggered() -{ - if (!m_connectAction) { - return; - } - if (m_connectAction->text() == tr("Connect")) { - Q_EMIT connectActionTriggered(); - } else if (m_connectAction->text() == tr("Disconnect")) { - Q_EMIT disconnectActionTriggered(); - } -} - -void VpnItem::onDeletetTriggered() -{ - if (!m_deleteAction) { - return; - } - Q_EMIT deleteActionTriggered(); -} - -void VpnItem::paintEvent(QPaintEvent *event) -{ - QPalette pal = this->palette(); - - QPainter painter(this); - painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿 - painter.setPen(Qt::NoPen); - painter.setBrush(pal.color(QPalette::Base)); - - QRect rect = this->rect(); - -#if 0 - if (!useHalfFillet) { - painter.drawRect(rect); - } else { - QPainterPath path; -// path.addRoundedRect (rect, RADIUS, RADIUS); -// QRect temp_rect(rect.left(), rect.top(), rect.width(), rect.height()/2); -// path.addRect(temp_rect); - //设置起点 - path.moveTo(rect.topLeft().x(), rect.topLeft().y()); - path.lineTo(rect.bottomLeft().x(), rect.bottomLeft().y() - RADIUS); - //绘制圆角 圆弧以外切圆的270度位置为起点,逆时针画圆弧运行90度结束 - path.arcTo(QRect(QPoint(rect.bottomLeft().x(), rect.bottomLeft().y() - (RADIUS * 2)), QSize(RADIUS * 2, RADIUS * 2)), 180, 90); - path.lineTo(rect.bottomRight().x() - RADIUS, rect.bottomRight().y()); - //画圆弧 - path.arcTo(QRect(QPoint(rect.bottomRight().x() - (RADIUS * 2), rect.bottomRight().y() - (RADIUS * 2)), QSize(RADIUS * 2, RADIUS * 2)), 270, 90); - path.lineTo(rect.topRight()); - path.lineTo(rect.topLeft()); - painter.drawPath(path); - } -#endif - - painter.drawRect(rect); - QPushButton::paintEvent(event); -} - -bool VpnItem::eventFilter(QObject *watched, QEvent *event) -{ - //菜单右边界与按钮右边界对齐 - if (event->type() == QEvent::Show && watched == m_moreMenu) { - int menuXPos = m_moreMenu->pos().x(); - int menuWidth = m_moreMenu->size().width(); - int btnWidth = m_moreButton->size().width(); - - QPoint pos = QPoint (menuXPos - menuWidth + btnWidth, m_moreMenu->pos().y()); - m_moreMenu->move(pos); - return true; - } - return false; -} diff --git a/plugins/vpn/vpnitem.h b/plugins/vpn/vpnitem.h deleted file mode 100644 index 6947d60f..00000000 --- a/plugins/vpn/vpnitem.h +++ /dev/null @@ -1,88 +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 VPNITEM_H -#define VPNITEM_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "fixlabel.h" -#include "../component/AddBtn/grayinfobutton.h" - -class VpnItem : public QPushButton -{ - Q_OBJECT -public: - VpnItem(bool bAcitve, QWidget *parent = nullptr); -public: - QLabel * iconLabel = nullptr; - GrayInfoButton * infoLabel = nullptr; - FixLabel * titileLabel = nullptr; - QLabel * statusLabel = nullptr; - QToolButton* m_moreButton = nullptr; - QMenu* m_moreMenu = nullptr; - QAction* m_connectAction = nullptr; - QAction* m_deleteAction = nullptr; - - QString uuid = ""; - QString dbusPath = ""; - - void setHalfFillet(bool flag) {useHalfFillet = flag; repaint();} -public: - void startLoading(); - void stopLoading(); - void setConnectActionText(bool isAcitve); - - bool isAcitve = false; - bool loading = false; - -protected: - void paintEvent(QPaintEvent *event); - bool eventFilter(QObject *watched, QEvent *event); - -private: - QTimer *waitTimer = nullptr; - QGSettings *themeGsettings = nullptr; - bool useHalfFillet = false; - QList loadIcons; - int currentIconIndex=0; - -private slots: - void updateIcon(); - void onConnectTriggered(); - void onDeletetTriggered(); - -Q_SIGNALS: - void connectActionTriggered(); - void disconnectActionTriggered(); - void deleteActionTriggered(); - -}; - -#endif // VPNITEM_H diff --git a/plugins/wlanconnect/deviceframe.cpp b/plugins/wlanconnect/deviceframe.cpp index be13ca78..a7822712 100644 --- a/plugins/wlanconnect/deviceframe.cpp +++ b/plugins/wlanconnect/deviceframe.cpp @@ -19,6 +19,7 @@ */ #include "deviceframe.h" #include +#include #define LAYOUT_MARGINS 18,0,8,0 #define FRAME_HEIGHT 58 diff --git a/plugins/wlanconnect/wlanconnect.cpp b/plugins/wlanconnect/wlanconnect.cpp index 0e2402c5..907fc4a3 100644 --- a/plugins/wlanconnect/wlanconnect.cpp +++ b/plugins/wlanconnect/wlanconnect.cpp @@ -48,6 +48,10 @@ #define SIGNAL_NONE 5 #define ICON_SIZE 16,16 +#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager" +#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager" +#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager" + const QString WIRELESS_SWITCH = "wirelessswitch"; const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch"; @@ -785,9 +789,11 @@ void WlanConnect::initNetListFromDevice(QString deviceName) //高级设置 void WlanConnect::runExternalApp() { - QString cmd = "nm-connection-editor"; - QProcess process(this); - process.startDetached(cmd); + if (!LaunchApp("nm-connection-editor.desktop")){ + QString cmd = "nm-connection-editor"; + QProcess process(this); + process.startDetached(cmd); + } } //根据信号强度分级+安全性分图标 @@ -1105,3 +1111,18 @@ void WlanConnect::itemActiveConnectionStatusChanged(WlanItem *item, int status) } } +bool WlanConnect::LaunchApp(QString desktopFile) +{ + QDBusInterface m_appManagerDbusInterface(KYLIN_APP_MANAGER_NAME, + KYLIN_APP_MANAGER_PATH, + KYLIN_APP_MANAGER_INTERFACE, + QDBusConnection::sessionBus());//局部变量 + + if (!m_appManagerDbusInterface.isValid()) { + qWarning()<<"m_appManagerDbusInterface init error"; + return false; + } else { + QDBusReply reply =m_appManagerDbusInterface.call("LaunchApp",desktopFile); + return reply; + } +} diff --git a/plugins/wlanconnect/wlanconnect.h b/plugins/wlanconnect/wlanconnect.h index 38bff337..abb2c8c0 100644 --- a/plugins/wlanconnect/wlanconnect.h +++ b/plugins/wlanconnect/wlanconnect.h @@ -149,7 +149,7 @@ private: } } - + bool LaunchApp(QString desktopFile); protected: bool eventFilter(QObject *w,QEvent *e); diff --git a/plugins/wlanconnect/wlanitem.cpp b/plugins/wlanconnect/wlanitem.cpp index 539e454c..f4576426 100644 --- a/plugins/wlanconnect/wlanitem.cpp +++ b/plugins/wlanconnect/wlanitem.cpp @@ -19,6 +19,7 @@ */ #include "wlanitem.h" #include +#include #include #define FRAME_SPEED 150 #define LIMIT_TIME 60*1000 diff --git a/src/backend/dbus-interface/kyenterpricesettinginfo.cpp b/src/backend/dbus-interface/kyenterpricesettinginfo.cpp index c1cc1c0a..9ff68dd5 100644 --- a/src/backend/dbus-interface/kyenterpricesettinginfo.cpp +++ b/src/backend/dbus-interface/kyenterpricesettinginfo.cpp @@ -193,3 +193,147 @@ void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSet wifi_8021x_sett->setCaCertificate(caCerEndWithNull); return; } + +void assembleEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodLeap); + wifi_8021x_sett->setInitialized(true); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setIdentity(leapInfo.m_userName); + wifi_8021x_sett->setPassword(leapInfo.m_userPwd); + wifi_8021x_sett->setPasswordFlags(leapInfo.m_passwdFlag); + + + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + security_sett->setInitialized(true); + security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap); + return; +} + +void assembleEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPwd); + wifi_8021x_sett->setInitialized(true); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setIdentity(pwdInfo.m_userName); + wifi_8021x_sett->setPassword(pwdInfo.m_userPwd); + wifi_8021x_sett->setPasswordFlags(pwdInfo.m_passwdFlag); + + + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + security_sett->setInitialized(true); + security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap); + return; +} + +void assembleEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodFast); + wifi_8021x_sett->setInitialized(true); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setAnonymousIdentity(fastInfo.m_anonIdentity); + if (fastInfo.m_allowAutoPacFlag) { + wifi_8021x_sett->setPhase1FastProvisioning((NetworkManager::Security8021xSetting::FastProvisioning)fastInfo.m_pacProvisioning); + } else { + wifi_8021x_sett->setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioning::FastProvisioningDisabled); + } + QByteArray pacEndWithNull("file://" + fastInfo.m_pacFilePath.toUtf8() + '\0'); + wifi_8021x_sett->setPacFile(pacEndWithNull); + wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)fastInfo.m_authMethod); + wifi_8021x_sett->setIdentity(fastInfo.m_userName); + wifi_8021x_sett->setPassword(fastInfo.m_userPwd); + wifi_8021x_sett->setPasswordFlags(fastInfo.m_passwdFlag); + + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + security_sett->setInitialized(true); + security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap); + + return; +} + +void modifyEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + wifi_8021x_sett->setInitialized(true); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodLeap); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setIdentity(leapInfo.m_userName); + if(leapInfo.bChanged) + { + wifi_8021x_sett->setPassword(leapInfo.m_userPwd); + } + wifi_8021x_sett->setPasswordFlags(leapInfo.m_passwdFlag); + + QByteArray caCerEndWithNull(""); + wifi_8021x_sett->setCaCertificate(caCerEndWithNull); + + return; +} + +void modifyEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + wifi_8021x_sett->setInitialized(true); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPwd); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setIdentity(pwdInfo.m_userName); + if(pwdInfo.bChanged) + { + wifi_8021x_sett->setPassword(pwdInfo.m_userPwd); + } + wifi_8021x_sett->setPasswordFlags(pwdInfo.m_passwdFlag); + + QByteArray caCerEndWithNull(""); + wifi_8021x_sett->setCaCertificate(caCerEndWithNull); + + return; +} + +void modifyEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo) +{ + NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett + = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + wifi_8021x_sett->setInitialized(true); + + QList list; + list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodFast); + wifi_8021x_sett->setEapMethods(list); + wifi_8021x_sett->setAnonymousIdentity(fastInfo.m_anonIdentity); + if (fastInfo.m_allowAutoPacFlag) { + wifi_8021x_sett->setPhase1FastProvisioning((NetworkManager::Security8021xSetting::FastProvisioning)fastInfo.m_pacProvisioning); + } else { + wifi_8021x_sett->setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioning::FastProvisioningDisabled); + } + QByteArray pacEndWithNull("file://" + fastInfo.m_pacFilePath.toUtf8() + '\0'); + wifi_8021x_sett->setPacFile(pacEndWithNull); + + wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)fastInfo.m_authMethod); + wifi_8021x_sett->setIdentity(fastInfo.m_userName); + if(fastInfo.bChanged) + { + wifi_8021x_sett->setPassword(fastInfo.m_userPwd); + } + wifi_8021x_sett->setPasswordFlags(fastInfo.m_passwdFlag); + return; +} diff --git a/src/backend/dbus-interface/kyenterpricesettinginfo.h b/src/backend/dbus-interface/kyenterpricesettinginfo.h index f95edb49..593b504a 100644 --- a/src/backend/dbus-interface/kyenterpricesettinginfo.h +++ b/src/backend/dbus-interface/kyenterpricesettinginfo.h @@ -30,6 +30,9 @@ enum KyEapMethodType { TLS = 0, PEAP, TTLS, + LEAP, + PWD, + FAST, }; class KyEapMethodTlsInfo @@ -154,12 +157,99 @@ public: } }; +typedef enum { + KyFastProvisioningUnknown = -1, + KyFastProvisioningDisabled, + KyFastProvisioningAllowUnauthenticated, + KyFastProvisioningAllowAuthenticated, + KyFastProvisioningAllowBoth +}KyFastProvisioning; + +class KyEapMethodLeapInfo +{ +public: + QString m_userName; + QString m_userPwd; + NetworkManager::Setting::SecretFlags m_passwdFlag; + // only valid when update + bool bChanged; + + inline bool operator == (const KyEapMethodLeapInfo& info) const + { + if (this->m_userName == info.m_userName + && this->m_userPwd == info.m_userPwd + && this->m_passwdFlag == info.m_passwdFlag) { + return true; + } else { + return false; + } + } +}; + +class KyEapMethodPwdInfo +{ +public: + QString m_userName; + QString m_userPwd; + NetworkManager::Setting::SecretFlags m_passwdFlag; + // only valid when update + bool bChanged; + + inline bool operator == (const KyEapMethodPwdInfo& info) const + { + if (this->m_userName == info.m_userName + && this->m_userPwd == info.m_userPwd + && this->m_passwdFlag == info.m_passwdFlag) { + return true; + } else { + return false; + } + } +}; + +class KyEapMethodFastInfo +{ +public: + QString m_anonIdentity; + KyFastProvisioning m_pacProvisioning; + bool m_allowAutoPacFlag; + QString m_pacFilePath; + KyNoEapMethodAuth m_authMethod; + QString m_userName; + QString m_userPwd; + NetworkManager::Setting::SecretFlags m_passwdFlag; + // only valid when update + bool bChanged; + + inline bool operator == (const KyEapMethodFastInfo& info) const + { + if (this->m_anonIdentity == info.m_anonIdentity + && this->m_pacProvisioning == info.m_pacProvisioning + && this->m_allowAutoPacFlag == info.m_allowAutoPacFlag + && this->m_pacFilePath == info.m_pacFilePath + && this->m_authMethod == info.m_authMethod + && this->m_userName == info.m_userName + && this->m_userPwd == info.m_userPwd + && this->m_passwdFlag == info.m_passwdFlag) { + return true; + } else { + return false; + } + } +}; + void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo); void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo); void assembleEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo); +void assembleEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo); +void assembleEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo); +void assembleEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo); void modifyEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo); void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo); void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo); +void modifyEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo); +void modifyEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo); +void modifyEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo); #endif // KYENTERPRICESETTINGINFO_H diff --git a/src/backend/dbus-interface/kylinconnectresource.cpp b/src/backend/dbus-interface/kylinconnectresource.cpp index 7de89382..eb757490 100644 --- a/src/backend/dbus-interface/kylinconnectresource.cpp +++ b/src/backend/dbus-interface/kylinconnectresource.cpp @@ -373,6 +373,7 @@ void KyConnectResourse::getIpv4ConnectSetting( { if (NetworkManager::Ipv4Setting::Automatic == ipv4Setting->method()) { connectSetting.m_ipv4ConfigIpType = CONFIG_IP_DHCP; + connectSetting.m_ipv4Dns = ipv4Setting->dns(); return; } @@ -391,6 +392,7 @@ void KyConnectResourse::getIpv6ConnectSetting( if (NetworkManager::Ipv6Setting::Automatic == ipv6Setting->method()) { connectSetting.m_ipv6ConfigIpType = CONFIG_IP_DHCP; + connectSetting.m_ipv6Dns = ipv6Setting->dns(); return; } diff --git a/src/backend/dbus-interface/kylinconnectsetting.cpp b/src/backend/dbus-interface/kylinconnectsetting.cpp index 88aeb57d..22700aad 100644 --- a/src/backend/dbus-interface/kylinconnectsetting.cpp +++ b/src/backend/dbus-interface/kylinconnectsetting.cpp @@ -69,7 +69,7 @@ int KyConnectSetting::setIpConfigType(KyIpAddressType ipType, KyIpConfigType ipC return 0; } -void KyConnectSetting::ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay, QStringList &ipv4Dns) +void KyConnectSetting::ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay) { qDebug()<<"ipv4 address"< &ipv4DnsList) +{ + m_ipv4Dns = ipv4DnsList; +} - return ; +void KyConnectSetting::ipv6DnsConstruct(QList &ipv6DnsList) +{ + m_ipv6Dns = ipv6DnsList; } void KyConnectSetting::dumpInfo() diff --git a/src/backend/dbus-interface/kylinconnectsetting.h b/src/backend/dbus-interface/kylinconnectsetting.h index f2e967e6..c8ae8f8c 100644 --- a/src/backend/dbus-interface/kylinconnectsetting.h +++ b/src/backend/dbus-interface/kylinconnectsetting.h @@ -50,8 +50,10 @@ public: void setIfaceName(QString &ifaceName); void setConnectName(QString &connectName); int setIpConfigType(KyIpAddressType ipType, KyIpConfigType configType); - void ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay, QStringList &ipv4Dns); - void ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay, QStringList &ipv6Dns); + void ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay); + void ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay); + void ipv4DnsConstruct(QList &ipv4DnsList); + void ipv6DnsConstruct(QList &ipv6DnsList); void dumpInfo(); public: diff --git a/src/backend/dbus-interface/kywirelessconnectoperation.cpp b/src/backend/dbus-interface/kywirelessconnectoperation.cpp index 38f46afe..8cde9ded 100644 --- a/src/backend/dbus-interface/kywirelessconnectoperation.cpp +++ b/src/backend/dbus-interface/kywirelessconnectoperation.cpp @@ -297,6 +297,109 @@ void KyWirelessConnectOperation::addTtlsConnect(const KyWirelessConnectSetting & return; } +//leap +void KyWirelessConnectOperation::addLeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodLeapInfo &leapInfo) +{ + NetworkManager::WirelessNetwork::Ptr wifiNet = + checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName); + if (wifiNet.isNull()) { + QString errorMessage = "the ssid " + connSettingInfo.m_ssid + + " is not exsit in " + connSettingInfo.m_ifaceName; + qWarning() << errorMessage; + Q_EMIT createConnectionError(errorMessage); + return; + } + + NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint(); + NetworkManager::ConnectionSettings::Ptr connSetting = + assembleWirelessSettings(accessPointPtr, connSettingInfo, false); + setIpv4AndIpv6Setting(connSetting, connSettingInfo); + assembleEapMethodLeapSettings(connSetting, leapInfo); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = tr("create wireless leap connection failed: ") + watcher->error().message(); + qWarning()<createConnectionError(errorMessage); + } else { + qDebug()<<"create wireless connect complete"; + } + watcher->deleteLater(); + }); + + return; +} + +//pwd +void KyWirelessConnectOperation::addPwdConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPwdInfo &pwdInfo) +{ + NetworkManager::WirelessNetwork::Ptr wifiNet = + checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName); + if (wifiNet.isNull()) { + QString errorMessage = "the ssid " + connSettingInfo.m_ssid + + " is not exsit in " + connSettingInfo.m_ifaceName; + qWarning() << errorMessage; + Q_EMIT createConnectionError(errorMessage); + return; + } + + NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint(); + NetworkManager::ConnectionSettings::Ptr connSetting = + assembleWirelessSettings(accessPointPtr, connSettingInfo, false); + setIpv4AndIpv6Setting(connSetting, connSettingInfo); + assembleEapMethodPwdSettings(connSetting, pwdInfo); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = tr("create wireless pwd connection failed: ") + watcher->error().message(); + qWarning()<createConnectionError(errorMessage); + } else { + qDebug()<<"create wireless connect complete"; + } + watcher->deleteLater(); + }); + + return; +} + +//fast +void KyWirelessConnectOperation::addFastConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodFastInfo &fastInfo) +{ + NetworkManager::WirelessNetwork::Ptr wifiNet = + checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName); + if (wifiNet.isNull()) { + QString errorMessage = "the ssid " + connSettingInfo.m_ssid + + " is not exsit in " + connSettingInfo.m_ifaceName; + qWarning() << errorMessage; + Q_EMIT createConnectionError(errorMessage); + return; + } + + NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint(); + NetworkManager::ConnectionSettings::Ptr connSetting = + assembleWirelessSettings(accessPointPtr, connSettingInfo, false); + setIpv4AndIpv6Setting(connSetting, connSettingInfo); + assembleEapMethodFastSettings(connSetting, fastInfo); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = tr("create wireless fast connection failed: ") + watcher->error().message(); + qWarning()<createConnectionError(errorMessage); + } else { + qDebug()<<"create wireless connect complete"; + } + watcher->deleteLater(); + }); +} + void KyWirelessConnectOperation::setWirelessAutoConnect(const QString &uuid, bool bAutoConnect) { NetworkManager::Connection::Ptr connectPtr = @@ -482,6 +585,60 @@ void KyWirelessConnectOperation::updateWirelessEnterPriseTtlsConnect(const QStri return; } +void KyWirelessConnectOperation::updateWirelessEnterPriseLeapConnect(const QString &uuid, const KyEapMethodLeapInfo &leapInfo) +{ + NetworkManager::Connection::Ptr connectPtr = + NetworkManager::findConnectionByUuid(uuid); + if (nullptr == connectPtr) { + QString errorMessage = tr("it can not find connection") + uuid; + qWarning()<settings(); + + setWirelessSecuWpaXEap(connectionSettings); + modifyEapMethodLeapSettings(connectionSettings, leapInfo); + connectPtr->update(connectionSettings->toMap()); + return; +} + +void KyWirelessConnectOperation::updateWirelessEnterPrisePwdConnect(const QString &uuid, const KyEapMethodPwdInfo &pwdInfo) +{ + NetworkManager::Connection::Ptr connectPtr = + NetworkManager::findConnectionByUuid(uuid); + if (nullptr == connectPtr) { + QString errorMessage = tr("it can not find connection") + uuid; + qWarning()<settings(); + + setWirelessSecuWpaXEap(connectionSettings); + modifyEapMethodPwdSettings(connectionSettings, pwdInfo); + connectPtr->update(connectionSettings->toMap()); + return; +} + +void KyWirelessConnectOperation::updateWirelessEnterPriseFastConnect(const QString &uuid, const KyEapMethodFastInfo &fastInfo) +{ + NetworkManager::Connection::Ptr connectPtr = + NetworkManager::findConnectionByUuid(uuid); + if (nullptr == connectPtr) { + QString errorMessage = tr("it can not find connection") + uuid; + qWarning()<settings(); + + setWirelessSecuWpaXEap(connectionSettings); + modifyEapMethodFastSettings(connectionSettings, fastInfo); + connectPtr->update(connectionSettings->toMap()); + return; +} + void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & devIface,KyWirelessConnectSetting &connSettingInfo,bool isHidden) { qDebug() << "addAndActiveWirelessConnect" << connSettingInfo.m_ssid << devIface <referenceAccessPoint(); + conn_uni = accessPointPtr->uni(); + spec_object = conn_uni; + } + + auto dev = m_networkResourceInstance->findDeviceInterface(devIface); + if (dev.isNull()) { + Q_EMIT addAndActivateConnectionError("can not find device"); + return; + } + dev_uni = dev->uni(); + + NetworkManager::ConnectionSettings::Ptr settings = + assembleWirelessSettings(accessPointPtr, connSettingInfo, isHidden); + assembleEapMethodLeapSettings(settings, info); + + if(settings.isNull()) { + qDebug() << "assembleEapMethodLeapSettings failed"; + return; + } + + map_settings = settings->toMap(); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = watcher->error().message(); + qDebug() << "addAndActiveWirelessEnterPriseLeapConnect failed " << errorMessage; + Q_EMIT addAndActivateConnectionError(errorMessage); + } + watcher->deleteLater(); + }); +} + +void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePwdConnect(KyEapMethodPwdInfo &info, KyWirelessConnectSetting &connSettingInfo, QString &devIface, bool isHidden) +{ + QString conn_uni; + QString dev_uni; + QString spec_object; + NMVariantMapMap map_settings; + NetworkManager::AccessPoint::Ptr accessPointPtr = nullptr; + + if (!isHidden) { + NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface); + if (wifiNet.isNull()) { + QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface; + qWarning()<referenceAccessPoint(); + conn_uni = accessPointPtr->uni(); + spec_object = conn_uni; + } + + auto dev = m_networkResourceInstance->findDeviceInterface(devIface); + if (dev.isNull()) { + Q_EMIT addAndActivateConnectionError("can not find device"); + return; + } + dev_uni = dev->uni(); + + NetworkManager::ConnectionSettings::Ptr settings = + assembleWirelessSettings(accessPointPtr, connSettingInfo, isHidden); + assembleEapMethodPwdSettings(settings, info); + + if(settings.isNull()) { + qDebug() << "assembleEapMethodPwdSettings failed"; + return; + } + + map_settings = settings->toMap(); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = watcher->error().message(); + qDebug() << "addAndActiveWirelessEnterPrisePwdConnect failed " << errorMessage; + Q_EMIT addAndActivateConnectionError(errorMessage); + } + watcher->deleteLater(); + }); +} + +void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseFastConnect(KyEapMethodFastInfo &info, KyWirelessConnectSetting &connSettingInfo, QString &devIface, bool isHidden) +{ + QString conn_uni; + QString dev_uni; + QString spec_object; + NMVariantMapMap map_settings; + NetworkManager::AccessPoint::Ptr accessPointPtr = nullptr; + + if (!isHidden) { + NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface); + if (wifiNet.isNull()) { + QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface; + qWarning()<referenceAccessPoint(); + conn_uni = accessPointPtr->uni(); + spec_object = conn_uni; + } + + auto dev = m_networkResourceInstance->findDeviceInterface(devIface); + if (dev.isNull()) { + Q_EMIT addAndActivateConnectionError("can not find device"); + return; + } + dev_uni = dev->uni(); + + NetworkManager::ConnectionSettings::Ptr settings = + assembleWirelessSettings(accessPointPtr, connSettingInfo, isHidden); + assembleEapMethodFastSettings(settings, info); + + if(settings.isNull()) { + qDebug() << "assembleEapMethodFastSettings failed"; + return; + } + + map_settings = settings->toMap(); + + QDBusPendingCallWatcher * watcher; + watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this}; + connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) { + if (watcher->isError() || !watcher->isValid()) { + QString errorMessage = watcher->error().message(); + qDebug() << "addAndActiveWirelessEnterPriseFastConnect failed " << errorMessage; + Q_EMIT addAndActivateConnectionError(errorMessage); + } + watcher->deleteLater(); + }); +} + //无线网络开关设置 void KyWirelessConnectOperation::setWirelessEnabled(bool enabled) { @@ -1109,6 +1422,12 @@ bool KyWirelessConnectOperation::getEnterpiseEapMethod(const QString &uuid, KyEa type = PEAP; } else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls)) { type = TTLS; + } else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodLeap)) { + type = LEAP; + } else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPwd)) { + type = PWD; + } else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodFast)) { + type = FAST; } return true; diff --git a/src/backend/dbus-interface/kywirelessconnectoperation.h b/src/backend/dbus-interface/kywirelessconnectoperation.h index a6d551e0..94d91858 100644 --- a/src/backend/dbus-interface/kywirelessconnectoperation.h +++ b/src/backend/dbus-interface/kywirelessconnectoperation.h @@ -99,6 +99,12 @@ public: void addPeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPeapInfo &peapInfo); //新增TTLS连接 void addTtlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTtlsInfo &ttlsInfo); + //新增LEAP连接 + void addLeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodLeapInfo &leapInfo); + //新增PWD连接 + void addPwdConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPwdInfo &pwdInfo); + //新增FAST连接 + void addFastConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodFastInfo &fastInfo); //新增连接并激活(普通wifi) void addAndActiveWirelessConnect(QString & devIface,KyWirelessConnectSetting &connSettingInfo,bool isHidden); @@ -109,6 +115,12 @@ public: QString & devIface, bool isHidden); void addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &info, KyWirelessConnectSetting &connSettingInfo, QString & devIface, bool isHidden); + void addAndActiveWirelessEnterPriseLeapConnect(KyEapMethodLeapInfo &info, KyWirelessConnectSetting &connSettingInfo, + QString & devIface, bool isHidden); + void addAndActiveWirelessEnterPrisePwdConnect(KyEapMethodPwdInfo &info, KyWirelessConnectSetting &connSettingInfo, + QString & devIface, bool isHidden); + void addAndActiveWirelessEnterPriseFastConnect(KyEapMethodFastInfo &info, KyWirelessConnectSetting &connSettingInfo, + QString & devIface, bool isHidden); //属性页 page1 AutoConnect void setWirelessAutoConnect(const QString &uuid, bool bAutoConnect); //属性页 page2 page3 ipv6 @@ -120,6 +132,9 @@ public: void updateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsinfo); void updateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo); void updateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo); + void updateWirelessEnterPriseLeapConnect(const QString &uuid, const KyEapMethodLeapInfo &leapInfo); + void updateWirelessEnterPrisePwdConnect(const QString &uuid, const KyEapMethodPwdInfo &pwdInfo); + void updateWirelessEnterPriseFastConnect(const QString &uuid, const KyEapMethodFastInfo &fastInfo); //忘记 void deleteWirelessConnect(const QString &connectUuid); //获取密码 diff --git a/src/backend/dbus-interface/kywirelessnetresource.cpp b/src/backend/dbus-interface/kywirelessnetresource.cpp index 2ec9bcf0..bee368d8 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.cpp +++ b/src/backend/dbus-interface/kywirelessnetresource.cpp @@ -626,6 +626,119 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls return true; } +bool KyWirelessNetResource::getEnterPriseInfoLeap(QString &uuid, KyEapMethodLeapInfo &info) +{ + NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid); + if (conn.isNull()) { + qDebug()<< LOG_FLAG << "getEnterPriseInfoLeap connection missing"; + return false; + } + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + if (security_sett.isNull()) { + qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection"; + return false; + } + + if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) { + qDebug()<< LOG_FLAG << "keyMgmt not WpaEap " << security_sett->keyMgmt(); + return false; + } + + NetworkManager::Security8021xSetting::Ptr setting = + conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodLeap)) { + qDebug()<< LOG_FLAG << "don't have Security8021x connection"; + return false; + } + + info.m_userName = setting->identity(); + info.m_passwdFlag = setting->passwordFlags(); + if (!info.m_passwdFlag) { + info.m_userPwd = m_operation->get8021xPassword(conn->uuid()); + } + + return true; +} + +bool KyWirelessNetResource::getEnterPriseInfoPwd(QString &uuid, KyEapMethodPwdInfo &info) +{ + NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid); + if (conn.isNull()) { + qDebug()<< LOG_FLAG << "getEnterPriseInfoPwd connection missing"; + return false; + } + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + if (security_sett.isNull()) { + qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection"; + return false; + } + + if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) { + qDebug()<< LOG_FLAG << "keyMgmt not WpaEap " << security_sett->keyMgmt(); + return false; + } + + NetworkManager::Security8021xSetting::Ptr setting = + conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPwd)) { + qDebug()<< LOG_FLAG << "don't have Security8021x connection"; + return false; + } + + info.m_userName = setting->identity(); + info.m_passwdFlag = setting->passwordFlags(); + if (!info.m_passwdFlag) { + info.m_userPwd = m_operation->get8021xPassword(conn->uuid()); + } + + return true; +} + +bool KyWirelessNetResource::getEnterPriseInfoFast(QString &uuid, KyEapMethodFastInfo &info) +{ + NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid); + if (conn.isNull()) { + qDebug()<< LOG_FLAG << "getEnterPriseInfoFast connection missing"; + return false; + } + NetworkManager::WirelessSecuritySetting::Ptr security_sett + = conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); + if (security_sett.isNull()) { + qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection"; + return false; + } + + if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) { + qDebug()<< LOG_FLAG << "keyMgmt not WpaEap " << security_sett->keyMgmt(); + return false; + } + + NetworkManager::Security8021xSetting::Ptr setting = + conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast(); + if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodFast)) { + qDebug()<< LOG_FLAG << "don't have Security8021x connection"; + return false; + } + + info.m_anonIdentity = setting->anonymousIdentity(); + info.m_pacProvisioning = (KyFastProvisioning)setting->phase1FastProvisioning(); + info.m_pacFilePath = setting->caPath(); + if (info.m_pacFilePath.left(7) == "file://") { + info.m_pacFilePath = info.m_pacFilePath.mid(7); + } + info.m_authMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod(); + + info.m_userName = setting->identity(); + info.m_passwdFlag = setting->passwordFlags(); + if (!info.m_passwdFlag) { + info.m_userPwd = m_operation->get8021xPassword(conn->uuid()); + } + + return true; +} + void KyWirelessNetResource::onConnectionAdd(QString uuid) { qDebug() << LOG_FLAG << "onConnectionAdd " << uuid; diff --git a/src/backend/dbus-interface/kywirelessnetresource.h b/src/backend/dbus-interface/kywirelessnetresource.h index 7afe52fe..ac1e5f5b 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.h +++ b/src/backend/dbus-interface/kywirelessnetresource.h @@ -46,6 +46,9 @@ public: bool getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info); bool getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info); bool getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info); + bool getEnterPriseInfoLeap(QString &uuid, KyEapMethodLeapInfo &info); + bool getEnterPriseInfoPwd(QString &uuid, KyEapMethodPwdInfo &info); + bool getEnterPriseInfoFast(QString &uuid, KyEapMethodFastInfo &info); void getWirelessActiveConnection(NetworkManager::ActiveConnection::State state, QMap &map); bool getActiveWirelessNetItem(QString deviceName, KyWirelessNetItem &wirelessNetItem); diff --git a/src/backend/dbusadaptor.cpp b/src/backend/dbusadaptor.cpp index 0f22c845..d3325af3 100644 --- a/src/backend/dbusadaptor.cpp +++ b/src/backend/dbusadaptor.cpp @@ -147,6 +147,18 @@ void DbusAdaptor::setDeviceEnable(QString devName, bool enable) // return deviceName; //} +//删除 +void DbusAdaptor::deleteConnect(int type, QString ssid) +{ + if (type == WIRED) { + parent()->deleteWired(ssid); + } else if (type == WIRELESS) { + //待实现 + } else { + qDebug() << "[DbusAdaptor] deleteConnect type is invalid"; + } +} + //连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid void DbusAdaptor::activateConnect(int type, QString devName, QString ssid) { diff --git a/src/backend/dbusadaptor.h b/src/backend/dbusadaptor.h index 6cb0f411..500ebfa3 100644 --- a/src/backend/dbusadaptor.h +++ b/src/backend/dbusadaptor.h @@ -62,6 +62,8 @@ public Q_SLOTS: // METHODS // QString getDefaultWiredDevice(); // Q_NOREPLY void setDefaultWirelessDevice(QString deviceName); // QString getDefaultWirelessDevice(); + //刪除 根据网络名称 参数1 0:lan 1:wlan 参数2 为ssid/uuid + Q_NOREPLY void deleteConnect(int type, QString ssid); //连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid Q_NOREPLY void activateConnect(int type, QString devName, QString ssid); //断开连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid diff --git a/src/frontend/enterprise-wlan/enterprisewlandialog.cpp b/src/frontend/enterprise-wlan/enterprisewlandialog.cpp index 3a589886..332f45d1 100644 --- a/src/frontend/enterprise-wlan/enterprisewlandialog.cpp +++ b/src/frontend/enterprise-wlan/enterprisewlandialog.cpp @@ -256,7 +256,16 @@ void EnterpriseWlanDialog::onBtnConnectClicked() } else if (eapType == KyEapMethodType::TTLS) { m_securityPage->updateTtlsChange(m_info.ttlsInfo); m_connectOperation->addAndActiveWirelessEnterPriseTtlsConnect(m_info.ttlsInfo, connetSetting, m_deviceName, false); - } else { + } else if (eapType == KyEapMethodType::LEAP) { + m_securityPage->updateLeapChange(m_info.leapInfo); + m_connectOperation->addAndActiveWirelessEnterPriseLeapConnect(m_info.leapInfo, connetSetting, m_deviceName, false); + } else if (eapType == KyEapMethodType::PWD) { + m_securityPage->updatePwdChange(m_info.pwdInfo); + m_connectOperation->addAndActiveWirelessEnterPrisePwdConnect(m_info.pwdInfo, connetSetting, m_deviceName, false); + } else if (eapType == KyEapMethodType::FAST) { + m_securityPage->updateFastChange(m_info.fastInfo); + m_connectOperation->addAndActiveWirelessEnterPriseFastConnect(m_info.fastInfo, connetSetting, m_deviceName, false); + } else { qWarning() << "Connect enterprise wlan failed!(Unknown eap type)" << Q_FUNC_INFO << __LINE__; } close(); @@ -286,6 +295,24 @@ void EnterpriseWlanDialog::onEapTypeChanged(const KyEapMethodType &type) this->setFixedSize(MAIN_SIZE_NARROW); // m_centerWidget->setFixedHeight(PEAP_SCRO_HEIGHT); break; + case KyEapMethodType::LEAP: + if (!m_wirelessNetItem.m_connectUuid.isEmpty()) { + m_resource->getEnterPriseInfoLeap(m_wirelessNetItem.m_connectUuid, m_info.leapInfo); + } + this->setFixedSize(MAIN_SIZE_NARROW); + break; + case KyEapMethodType::PWD: + if (!m_wirelessNetItem.m_connectUuid.isEmpty()) { + m_resource->getEnterPriseInfoPwd(m_wirelessNetItem.m_connectUuid, m_info.pwdInfo); + } + this->setFixedSize(MAIN_SIZE_NARROW); + break; + case KyEapMethodType::FAST: + if (!m_wirelessNetItem.m_connectUuid.isEmpty()) { + m_resource->getEnterPriseInfoFast(m_wirelessNetItem.m_connectUuid, m_info.fastInfo); + } + this->setFixedSize(MAIN_SIZE_EXPAND); + break; default: break; } diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp index 19a0ff29..0a90a030 100644 --- a/src/frontend/mainwindow.cpp +++ b/src/frontend/mainwindow.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "kylinnetworkdeviceresource.h" #include "../backend/dbus-interface/kylinagentinterface.h" @@ -191,19 +192,19 @@ void MainWindow::secondaryStart() */ void MainWindow::initPlatform() { - char* projectName = kdk_system_get_projectName(); - QString strProjectName(projectName); - free(projectName); - projectName = NULL; - if(v10Sp1.compare(strProjectName,Qt::CaseInsensitive) == 0) { - unsigned int feature = kdk_system_get_productFeatures(); - if (feature == 3) { - m_isShowInCenter = true; - } - } else if (intel.compare(strProjectName,Qt::CaseInsensitive) == 0) { - m_isShowInCenter = true; - } - qDebug() << "projectName" << projectName << m_isShowInCenter; +// char* projectName = kdk_system_get_projectName(); +// QString strProjectName(projectName); +// free(projectName); +// projectName = NULL; +// if(v10Sp1.compare(strProjectName,Qt::CaseInsensitive) == 0) { +// unsigned int feature = kdk_system_get_productFeatures(); +// if (feature == 3) { +// m_isShowInCenter = true; +// } +// } else if (intel.compare(strProjectName,Qt::CaseInsensitive) == 0) { +// m_isShowInCenter = true; +// } +// qDebug() << "projectName" << projectName << m_isShowInCenter; } /** @@ -911,6 +912,12 @@ void MainWindow::getWirelessDeviceCap(QMap &map) m_wlanWidget->getWirelessDeviceCap(map); } +//有线连接删除 +void MainWindow::deleteWired(const QString &connUuid) +{ + m_lanWidget->deleteWired(connUuid); +} + //有线连接断开 void MainWindow::activateWired(const QString& devName, const QString& connUuid) { diff --git a/src/frontend/mainwindow.h b/src/frontend/mainwindow.h index d16533b8..ab30866b 100644 --- a/src/frontend/mainwindow.h +++ b/src/frontend/mainwindow.h @@ -83,6 +83,8 @@ public: void getApConnectionPath(QString &path, QString uuid); //获取热点ActivePath void getActiveConnectionPath(QString &path, QString uuid); + //删除有线连接 + void deleteWired(const QString& connUuid); //有线连接断开 void activateWired(const QString& devName, const QString& connUuid); void deactivateWired(const QString& devName, const QString& connUuid); diff --git a/src/frontend/netdetails/coninfo.h b/src/frontend/netdetails/coninfo.h index 1aef5fb4..330165e6 100644 --- a/src/frontend/netdetails/coninfo.h +++ b/src/frontend/netdetails/coninfo.h @@ -55,6 +55,19 @@ enum TtlsInnerType GTC_EAP }; +enum FastInnerType +{ + GTC_FAST = 0, + MSCHAPV2_FAST, +}; + +enum PacProvisioningInnerType +{ + ANON = 0, + AUTHEN, + BOTH, +}; + class LineEdit : public QLineEdit { Q_OBJECT @@ -91,21 +104,22 @@ public: KyIpConfigType ipv4ConfigType = CONFIG_IP_DHCP; QString strIPV4Address; QString strIPV4NetMask; - QString strIPV4FirDns; - QString strIPV4SecDns; QString strIPV4GateWay; + QList ipv4DnsList; KyIpConfigType ipv6ConfigType = CONFIG_IP_DHCP; QString strIPV6Address; int iIPV6Prefix; - QString strIPV6FirDns; - QString strIPV6SecDns; QString strIPV6GateWay; + QList ipv6DnsList; KyEapMethodType enterpriseType; KyEapMethodTlsInfo tlsInfo; KyEapMethodPeapInfo peapInfo; KyEapMethodTtlsInfo ttlsInfo; + KyEapMethodLeapInfo leapInfo; + KyEapMethodPwdInfo pwdInfo; + KyEapMethodFastInfo fastInfo; }; static void setFramePalette(QFrame *widget, QPalette &pal) { diff --git a/src/frontend/netdetails/creatnetpage.cpp b/src/frontend/netdetails/creatnetpage.cpp index 7f242c5e..33153c52 100644 --- a/src/frontend/netdetails/creatnetpage.cpp +++ b/src/frontend/netdetails/creatnetpage.cpp @@ -38,25 +38,23 @@ void CreatNetPage::initUI() ipv4addressEdit = new LineEdit(this); netMaskEdit = new LineEdit(this); gateWayEdit = new LineEdit(this); - firstDnsEdit = new LineEdit(this); - secondDnsEdit = new LineEdit(this); m_connNameLabel = new QLabel(this); m_configLabel = new QLabel(this); m_addressLabel = new QLabel(this); m_maskLabel = new QLabel(this); m_gateWayLabel = new QLabel(this); - m_dnsLabel = new QLabel(this); - m_secDnsLabel = new QLabel(this); + + // IP的正则格式限制 + QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"); + m_dnsWidget = new MultipleDnsWidget(rx, this); QLabel *nameEmptyLabel = new QLabel(this); QLabel *configEmptyLabel = new QLabel(this); QLabel *gateWayEmptyLabel = new QLabel(this); - QLabel *firstDnsEmptyLabel = new QLabel(this); nameEmptyLabel->setFixedHeight(LABEL_HEIGHT); configEmptyLabel->setFixedHeight(LABEL_HEIGHT); gateWayEmptyLabel->setFixedHeight(LABEL_HEIGHT); - firstDnsEmptyLabel->setFixedHeight(LABEL_HEIGHT); m_addressHintLabel = new QLabel(this); m_maskHintLabel = new QLabel(this); @@ -89,8 +87,6 @@ void CreatNetPage::initUI() m_addressLabel->setText(tr("Address")); m_maskLabel->setText(tr("Netmask")); m_gateWayLabel->setText(tr("Default Gateway")); - m_dnsLabel->setText(tr("Prefs DNS")); - m_secDnsLabel->setText(tr("Alternative DNS")); m_detailLayout = new QFormLayout(this); m_detailLayout->setVerticalSpacing(0); @@ -103,22 +99,14 @@ void CreatNetPage::initUI() m_detailLayout->addRow(m_maskLabel, maskWidget); m_detailLayout->addRow(m_gateWayLabel,gateWayEdit); m_detailLayout->addRow(gateWayEmptyLabel); - m_detailLayout->addRow(m_dnsLabel,firstDnsEdit); - m_detailLayout->addRow(firstDnsEmptyLabel); - m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit); + m_detailLayout->addRow(m_dnsWidget); ipv4ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)" ipv4ConfigCombox->addItem(tr("Manual"), MANUAL_CONFIG); //"手动" - - // IP的正则格式限制 - QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"); - ipv4addressEdit->setValidator(new QRegExpValidator(rx, this)); gateWayEdit->setValidator(new QRegExpValidator(rx, this)); netMaskEdit->setValidator(new QRegExpValidator(rx, this)); - firstDnsEdit->setValidator(new QRegExpValidator(rx, this)); - secondDnsEdit->setValidator(new QRegExpValidator(rx, this)); } void CreatNetPage::initComponent() { @@ -133,8 +121,6 @@ void CreatNetPage::initComponent() { connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn())); connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); - connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); - connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(onAddressTextChanged())); connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(onNetMaskTextChanged())); @@ -159,26 +145,6 @@ bool CreatNetPage::checkConnectBtnIsEnabled() qDebug() << "create ipv4 netMask empty or invalid"; return false; } - -// if (gateWayEdit->text().isEmpty() || !getTextEditState(gateWayEdit->text())) { -// qDebug() << "create ipv4 gateway empty or invalid"; -// return false; -// } - - if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) { - qDebug() << "create ipv4 dns sort invalid"; - return false; - } - - if (!getTextEditState(firstDnsEdit->text())) { - qDebug() << "create ipv4 first dns invalid"; - return false; - } - - if (!getTextEditState(secondDnsEdit->text())) { - qDebug() << "create ipv4 second dns invalid"; - return false; - } } return true; } @@ -215,15 +181,11 @@ void CreatNetPage::setLineEnabled(bool check) { ipv4addressEdit->setEnabled(check); netMaskEdit->setEnabled(check); gateWayEdit->setEnabled(check); - firstDnsEdit->setEnabled(check); - secondDnsEdit->setEnabled(check); if (!check) { ipv4addressEdit->clear(); netMaskEdit->clear(); gateWayEdit->clear(); - firstDnsEdit->clear(); - secondDnsEdit->clear(); ipv4addressEdit->setPlaceholderText(" "); netMaskEdit->setPlaceholderText(" "); @@ -260,19 +222,16 @@ void CreatNetPage::constructIpv4Info(KyConnectSetting &setting) << " netMask " << netMask << " gateWay " << gateWay; - QStringList dnsList; - dnsList.empty(); - if (!firstDnsEdit->text().isEmpty()) { - dnsList << firstDnsEdit->text(); - if (!secondDnsEdit->text().isEmpty()) { - dnsList << secondDnsEdit->text(); - } - } + QList ipv4dnsList; + ipv4dnsList.clear(); + ipv4dnsList = m_dnsWidget->getDns(); + if (ipv4ConfigCombox->currentData() == AUTO_CONFIG) { setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP); } else { setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL); - setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList); + setting.ipv4AddressConstruct(ipv4address, netMask, gateWay); + setting.ipv4DnsConstruct(ipv4dnsList); } } diff --git a/src/frontend/netdetails/creatnetpage.h b/src/frontend/netdetails/creatnetpage.h index 71ccefd7..1eb2934f 100644 --- a/src/frontend/netdetails/creatnetpage.h +++ b/src/frontend/netdetails/creatnetpage.h @@ -32,6 +32,7 @@ #include #include "coninfo.h" +#include "multiplednswidget.h" class CreatNetPage : public QFrame { @@ -57,11 +58,11 @@ private: QLabel *m_addressLabel; QLabel *m_maskLabel; QLabel *m_gateWayLabel; - QLabel *m_dnsLabel; - QLabel *m_secDnsLabel; QLabel *m_addressHintLabel; QLabel *m_maskHintLabel; + + MultipleDnsWidget *m_dnsWidget = nullptr; private: void initUI(); void initComponent(); diff --git a/src/frontend/netdetails/detailpage.cpp b/src/frontend/netdetails/detailpage.cpp index 159dbb2a..48b36a3e 100644 --- a/src/frontend/netdetails/detailpage.cpp +++ b/src/frontend/netdetails/detailpage.cpp @@ -246,9 +246,11 @@ void DetailPage::initUI() { m_ipv4Widget = new DetailWidget(qobject_cast(m_IPV4), m_listWidget); m_ipv4Widget->setKey(tr("IPv4:")); - m_IPV4Dns = new QLabel(this); + m_IPV4Dns = new FixLabel(this); + m_IPV4Dns->setFixedWidth(MAX_LABEL_WIDTH); + m_IPV4Dns->setAlignment(Qt::AlignRight | Qt::AlignVCenter); m_ipv4DnsWidget = new DetailWidget(qobject_cast(m_IPV4Dns), m_listWidget); - m_ipv4DnsWidget->setKey(tr("IPv4 DNS:")); + m_ipv4DnsWidget->setKey(tr("IPv4 Dns:")); m_IPV6 = new FixLabel(this); m_IPV6->setFixedWidth(MAX_LABEL_WIDTH); diff --git a/src/frontend/netdetails/detailpage.h b/src/frontend/netdetails/detailpage.h index 75aaa61e..208b15d1 100644 --- a/src/frontend/netdetails/detailpage.h +++ b/src/frontend/netdetails/detailpage.h @@ -91,7 +91,7 @@ public: QLabel *m_Chan; QLabel *m_BandWidth; QLabel *m_IPV4; - QLabel *m_IPV4Dns; + FixLabel *m_IPV4Dns; FixLabel *m_IPV6; QLabel *m_Mac; QLabel *m_autoConnect; diff --git a/src/frontend/netdetails/ipv4page.cpp b/src/frontend/netdetails/ipv4page.cpp index 6e2ca81c..7877b5bf 100644 --- a/src/frontend/netdetails/ipv4page.cpp +++ b/src/frontend/netdetails/ipv4page.cpp @@ -39,15 +39,11 @@ void Ipv4Page::initUI() { ipv4addressEdit = new LineEdit(this); netMaskEdit = new LineEdit(this); gateWayEdit = new LineEdit(this); - firstDnsEdit = new LineEdit(this); - secondDnsEdit = new LineEdit(this); m_configLabel = new QLabel(this); m_addressLabel = new QLabel(this); m_maskLabel = new QLabel(this); m_gateWayLabel = new QLabel(this); - m_dnsLabel = new QLabel(this); - m_secDnsLabel = new QLabel(this); m_configEmptyLabel = new QLabel(this); m_configEmptyLabel->setFixedHeight(LABEL_HEIGHT); @@ -64,16 +60,10 @@ void Ipv4Page::initUI() { m_gateWayEmptyLabel = new QLabel(this); m_gateWayEmptyLabel->setFixedHeight(LABEL_HEIGHT); - m_firstDnsEmptyLabel = new QLabel(this); - m_firstDnsEmptyLabel->setFixedHeight(LABEL_HEIGHT); - - m_configLabel->setText(tr("IPv4Config")); m_addressLabel->setText(tr("Address")); m_maskLabel->setText(tr("Netmask")); m_gateWayLabel->setText(tr("Default Gateway")); - m_dnsLabel->setText(tr("Prefs DNS")); - m_secDnsLabel->setText(tr("Alternative DNS")); m_statusLabel = new QLabel(this); m_statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); @@ -100,6 +90,10 @@ void Ipv4Page::initUI() { maskLayout->addWidget(netMaskEdit); maskLayout->addWidget(m_maskHintLabel); + // IP的正则格式限制 + QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"); + m_dnsWidget = new MultipleDnsWidget(rx, this); + m_detailLayout = new QFormLayout(this); m_detailLayout->setVerticalSpacing(0); m_detailLayout->setContentsMargins(LAYOUT_MARGINS); @@ -109,9 +103,7 @@ void Ipv4Page::initUI() { m_detailLayout->addRow(m_maskLabel,maskWidget); m_detailLayout->addRow(m_gateWayLabel,gateWayEdit); m_detailLayout->addRow(m_gateWayEmptyLabel); - m_detailLayout->addRow(m_dnsLabel,firstDnsEdit); - m_detailLayout->addRow(m_firstDnsEmptyLabel); - m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit); + m_detailLayout->addRow(m_dnsWidget); ipv4ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)" ipv4ConfigCombox->addItem(tr("Manual")); //"手动" @@ -123,15 +115,9 @@ void Ipv4Page::initUI() { // netMaskCombox->addItem("255.255.0.0"); //16 // netMaskCombox->addItem("255.0.0.0"); //8 - - // IP的正则格式限制 - QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"); - ipv4addressEdit->setValidator(new QRegExpValidator(rx, this)); gateWayEdit->setValidator(new QRegExpValidator(rx, this)); netMaskEdit->setValidator(new QRegExpValidator(rx, this)); - firstDnsEdit->setValidator(new QRegExpValidator(rx, this)); - secondDnsEdit->setValidator(new QRegExpValidator(rx, this)); initLoadingIcon(); } @@ -152,8 +138,6 @@ void Ipv4Page::initComponent() { connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); - connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); - connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); } void Ipv4Page::setIpv4Config(KyIpConfigType ipv4Config) @@ -175,14 +159,9 @@ void Ipv4Page::setNetMask(const QString &netMask) netMaskEdit->setText(netMask); } -void Ipv4Page::setIpv4FirDns(const QString &ipv4FirDns) +void Ipv4Page::setMulDns(const QList &dns) { - firstDnsEdit->setText(ipv4FirDns); -} - -void Ipv4Page::setIpv4SecDns(const QString &ipv4SecDns) -{ - secondDnsEdit->setText(ipv4SecDns); + m_dnsWidget->setDnsListText(dns); } void Ipv4Page::setGateWay(const QString &gateWay) @@ -193,6 +172,16 @@ void Ipv4Page::setGateWay(const QString &gateWay) bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting) { bool isChanged = false; + + QList ipv4DnsList; + ipv4DnsList.clear(); + ipv4DnsList = m_dnsWidget->getDns(); + if (info.ipv4DnsList != ipv4DnsList) { + qDebug() << "ipv4 dns changed"; + setting.ipv4DnsConstruct(ipv4DnsList); + isChanged = true; + } + if (ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) { if (info.ipv4ConfigType != CONFIG_IP_DHCP) { qDebug() << "ipv4ConfigType change to Auto"; @@ -200,10 +189,9 @@ bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting) QString ipv4address(""); QString netMask(""); QString gateWay(""); - QStringList dnsList; - dnsList.empty(); + qDebug() << ipv4address << netMask << gateWay; - setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList); + setting.ipv4AddressConstruct(ipv4address, netMask, gateWay); isChanged = true; } } else { @@ -215,25 +203,15 @@ bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting) qDebug() << "ipv4 netmask " << getNetMaskText(netMaskEdit->text()); if(info.strIPV4Address != ipv4addressEdit->text() || info.strIPV4NetMask != /*netMaskEdit->text()*/getNetMaskText(netMaskEdit->text()) - || info.strIPV4GateWay != gateWayEdit->text() - || info.strIPV4FirDns != firstDnsEdit->text() - || info.strIPV4SecDns != secondDnsEdit->text()) { + || info.strIPV4GateWay != gateWayEdit->text()) { qDebug() << "ipv4 info changed"; - QStringList dnsList; - dnsList.empty(); - if (!firstDnsEdit->text().isEmpty()) { - dnsList << firstDnsEdit->text(); - if (!secondDnsEdit->text().isEmpty()) { - dnsList << secondDnsEdit->text(); - } - } QString ipv4address =ipv4addressEdit->text(); QString netMask = getNetMaskText(netMaskEdit->text()); QString gateWay = gateWayEdit->text(); qDebug() << ipv4address << netMask << gateWay; - setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList); + setting.ipv4AddressConstruct(ipv4address, netMask, gateWay); setting.dumpInfo(); isChanged = true; } @@ -256,26 +234,6 @@ bool Ipv4Page::checkConnectBtnIsEnabled() qDebug() << "ipv4 netMask empty or invalid"; return false; } - -// if (gateWayEdit->text().isEmpty() || !getTextEditState(gateWayEdit->text())) { -// qDebug() << "ipv4 gateway empty or invalid"; -// return false; -// } - - if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) { - qDebug() << "ipv4 dns sort invalid"; - return false; - } - - if (!getTextEditState(firstDnsEdit->text())) { - qDebug() << "ipv4 first dns invalid"; - return false; - } - - if (!getTextEditState(secondDnsEdit->text())) { - qDebug() << "ipv4 second dns invalid"; - return false; - } } return true; } @@ -325,8 +283,6 @@ void Ipv4Page::setLineEnabled(bool check) { ipv4addressEdit->clear(); netMaskEdit->clear(); gateWayEdit->clear(); - firstDnsEdit->clear(); - secondDnsEdit->clear(); ipv4addressEdit->setPlaceholderText(" "); netMaskEdit->setPlaceholderText(" "); @@ -339,8 +295,6 @@ void Ipv4Page::setLineEnabled(bool check) { ipv4addressEdit->setEnabled(check); netMaskEdit->setEnabled(check); gateWayEdit->setEnabled(check); - firstDnsEdit->setEnabled(check); - secondDnsEdit->setEnabled(check); } void Ipv4Page::setEnableOfSaveBtn() { diff --git a/src/frontend/netdetails/ipv4page.h b/src/frontend/netdetails/ipv4page.h index 55c2be09..88af57df 100644 --- a/src/frontend/netdetails/ipv4page.h +++ b/src/frontend/netdetails/ipv4page.h @@ -33,6 +33,7 @@ //#include "kylinconnectsetting.h" #include "coninfo.h" +#include "multiplednswidget.h" class Ipv4Page : public QFrame { @@ -42,8 +43,7 @@ public: void setIpv4Config(KyIpConfigType ipv4Config); void setIpv4(const QString &ipv4); void setNetMask(const QString &netMask); - void setIpv4FirDns(const QString &ipv4FirDns); - void setIpv4SecDns(const QString &ipv4SecDns); + void setMulDns(const QList &dns); void setGateWay(const QString &gateWay); bool checkIsChanged(const ConInfo info, KyConnectSetting &setting); @@ -59,8 +59,6 @@ private: LineEdit *ipv4addressEdit; LineEdit *netMaskEdit; LineEdit *gateWayEdit; - LineEdit *firstDnsEdit; - LineEdit *secondDnsEdit; QFormLayout *m_detailLayout; QVBoxLayout *mvBoxLayout; @@ -68,14 +66,13 @@ private: QLabel *m_addressLabel; QLabel *m_maskLabel; QLabel *m_gateWayLabel; - QLabel *m_dnsLabel; - QLabel *m_secDnsLabel; QLabel *m_configEmptyLabel; QLabel *m_addressHintLabel; QLabel *m_maskHintLabel; QLabel *m_gateWayEmptyLabel; - QLabel *m_firstDnsEmptyLabel; + + MultipleDnsWidget *m_dnsWidget = nullptr; QLabel *m_statusLabel = nullptr; QList m_loadIcons; diff --git a/src/frontend/netdetails/ipv6page.cpp b/src/frontend/netdetails/ipv6page.cpp index ed34bce8..22e106bb 100644 --- a/src/frontend/netdetails/ipv6page.cpp +++ b/src/frontend/netdetails/ipv6page.cpp @@ -52,14 +52,9 @@ void Ipv6Page::setIpv6Perfix(const int &ipv6Perfix) lengthEdit->setText(QString::number(ipv6Perfix)); } -void Ipv6Page::setIpv6FirDns(const QString &ipv6FirDns) +void Ipv6Page::setMulDns(const QList &dns) { - firstDnsEdit->setText(ipv6FirDns); -} - -void Ipv6Page::setIpv6SecDns(const QString &ipv6SecDns) -{ - secondDnsEdit->setText(ipv6SecDns); + m_dnsWidget->setDnsListText(dns); } void Ipv6Page::setGateWay(const QString &gateWay) @@ -70,6 +65,16 @@ void Ipv6Page::setGateWay(const QString &gateWay) bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting) { bool isChanged = false; + + QList ipv6DnsList; + ipv6DnsList.clear(); + ipv6DnsList = m_dnsWidget->getDns(); + if (info.ipv6DnsList != ipv6DnsList) { + qDebug() << "ipv6 dns changed"; + setting.ipv6DnsConstruct(ipv6DnsList); + isChanged = true; + } + if (ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) { if (info.ipv6ConfigType != CONFIG_IP_DHCP) { qDebug() << "ipv6ConfigType change to Auto"; @@ -77,9 +82,7 @@ bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting) QString ipv6address(""); QString prefix(""); QString gateWay(""); - QStringList dnsList; - dnsList.empty(); - setting.ipv6AddressConstruct(ipv6address, prefix, gateWay, dnsList); + setting.ipv6AddressConstruct(ipv6address, prefix, gateWay); isChanged = true; } } else { @@ -88,26 +91,20 @@ bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting) setting.setIpConfigType(IPADDRESS_V6, CONFIG_IP_MANUAL); isChanged = true; } + + QList ipv6dnsList; + ipv6dnsList.clear(); + ipv6dnsList = m_dnsWidget->getDns(); if(info.strIPV6Address != ipv6AddressEdit->text() || info.iIPV6Prefix != lengthEdit->text().toInt() - || info.strIPV6GateWay != gateWayEdit->text() - || info.strIPV6FirDns != firstDnsEdit->text() - || info.strIPV6SecDns != secondDnsEdit->text()) { + || info.strIPV6GateWay != gateWayEdit->text()) { qDebug() << "ipv6 info changed"; - QStringList dnsList; - dnsList.empty(); - if (!firstDnsEdit->text().isEmpty()) { - dnsList << firstDnsEdit->text(); - if (!secondDnsEdit->text().isEmpty()) { - dnsList << secondDnsEdit->text(); - } - } QString ipv6address =ipv6AddressEdit->text(); QString prefix = lengthEdit->text(); QString gateWay = gateWayEdit->text(); - setting.ipv6AddressConstruct(ipv6address, prefix, gateWay, dnsList); + setting.ipv6AddressConstruct(ipv6address, prefix, gateWay); setting.dumpInfo(); isChanged = true; } @@ -120,15 +117,11 @@ void Ipv6Page::initUI() { ipv6AddressEdit = new LineEdit(this); lengthEdit = new LineEdit(this); gateWayEdit = new LineEdit(this); - firstDnsEdit = new LineEdit(this); - secondDnsEdit = new LineEdit(this); m_configLabel = new QLabel(this); m_addressLabel = new QLabel(this); m_subnetLabel = new QLabel(this); m_gateWayLabel = new QLabel(this); - m_dnsLabel = new QLabel(this); - m_secDnsLabel = new QLabel(this); m_configEmptyLabel = new QLabel(this); m_configEmptyLabel->setFixedHeight(LABEL_HEIGHT); @@ -145,16 +138,10 @@ void Ipv6Page::initUI() { m_subnetEmptyLabel = new QLabel(this); m_subnetEmptyLabel->setFixedHeight(LABEL_HEIGHT); - m_firstDnsEmptyLabel = new QLabel(this); - m_firstDnsEmptyLabel->setFixedHeight(LABEL_HEIGHT); - - m_configLabel->setText(tr("IPv6Config")); m_addressLabel->setText(tr("Address")); m_subnetLabel->setText(tr("Subnet prefix Length")); m_gateWayLabel->setText(tr("Default Gateway")); - m_dnsLabel->setText(tr("Prefs DNS")); - m_secDnsLabel->setText(tr("Alternative DNS")); m_statusLabel = new QLabel(this); m_statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); @@ -181,6 +168,9 @@ void Ipv6Page::initUI() { gateWayLayout->addWidget(gateWayEdit); gateWayLayout->addWidget(m_gateWayHintLabel); + QRegExp ipv6_rx("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$"); + m_dnsWidget = new MultipleDnsWidget(ipv6_rx, this); + m_detailLayout = new QFormLayout(this); m_detailLayout->setContentsMargins(0, 0, 0, 0); m_detailLayout->setVerticalSpacing(0); @@ -190,18 +180,13 @@ void Ipv6Page::initUI() { m_detailLayout->addRow(m_subnetLabel,lengthEdit); m_detailLayout->addRow(m_subnetEmptyLabel); m_detailLayout->addRow(m_gateWayLabel,gateWayWidget); - m_detailLayout->addRow(m_dnsLabel,firstDnsEdit); - m_detailLayout->addRow(m_firstDnsEmptyLabel); - m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit); + m_detailLayout->addRow(m_dnsWidget); ipv6ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)" ipv6ConfigCombox->addItem(tr("Manual")); //"手动" - QRegExp ipv6_rx("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$"); ipv6AddressEdit->setValidator(new QRegExpValidator(ipv6_rx, this)); gateWayEdit->setValidator(new QRegExpValidator(ipv6_rx, this)); - firstDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this)); - secondDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this)); QRegExp prefix_rx("\\b(?:(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\.){3}(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\b"); lengthEdit->setValidator(new QRegExpValidator(prefix_rx,this)); @@ -225,8 +210,6 @@ void Ipv6Page::initComponent() { connect(ipv6AddressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(lengthEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); - connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); - connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); } void Ipv6Page::configChanged(int index) { @@ -244,8 +227,6 @@ void Ipv6Page::setControlEnabled(bool check) ipv6AddressEdit->clear(); lengthEdit->clear(); gateWayEdit->clear(); - firstDnsEdit->clear(); - secondDnsEdit->clear(); ipv6AddressEdit->setPlaceholderText(" "); lengthEdit->setPlaceholderText(" "); @@ -258,8 +239,6 @@ void Ipv6Page::setControlEnabled(bool check) ipv6AddressEdit->setEnabled(check); lengthEdit->setEnabled(check); gateWayEdit->setEnabled(check); - firstDnsEdit->setEnabled(check); - secondDnsEdit->setEnabled(check); } void Ipv6Page::setEnableOfSaveBtn() @@ -311,26 +290,6 @@ bool Ipv6Page::checkConnectBtnIsEnabled() qDebug() << "ipv6 prefix length empty"; return false; } - -// if (gateWayEdit->text().isEmpty() || !getIpv6EditState(gateWayEdit->text())) { -// qDebug() << "ipv6 gateway empty or invalid"; -// return false; -// } - - if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) { - qDebug() << "ipv6 dns sort invalid"; - return false; - } - - if (!getIpv6EditState(firstDnsEdit->text())) { - qDebug() << "ipv6 first dns invalid"; - return false; - } - - if (!getIpv6EditState(secondDnsEdit->text())) { - qDebug() << "ipv6 second dns invalid"; - return false; - } } return true; } diff --git a/src/frontend/netdetails/ipv6page.h b/src/frontend/netdetails/ipv6page.h index a36265df..d3ec09d2 100644 --- a/src/frontend/netdetails/ipv6page.h +++ b/src/frontend/netdetails/ipv6page.h @@ -33,6 +33,7 @@ //#include "kylinconnectsetting.h" #include "coninfo.h" +#include "multiplednswidget.h" class Ipv6Page : public QFrame { @@ -42,8 +43,7 @@ public: void setIpv6Config(KyIpConfigType ipv6Config); void setIpv6(const QString &ipv4); void setIpv6Perfix(const int &ipv6Perfix); - void setIpv6FirDns(const QString &ipv6FirDns); - void setIpv6SecDns(const QString &ipv6SecDns); + void setMulDns(const QList &dns); void setGateWay(const QString &gateWay); bool checkIsChanged(const ConInfo info, KyConnectSetting &setting); @@ -59,22 +59,19 @@ public: LineEdit *ipv6AddressEdit; LineEdit *lengthEdit; LineEdit *gateWayEdit; - LineEdit *firstDnsEdit; - LineEdit *secondDnsEdit; private: QFormLayout *m_detailLayout; QLabel *m_configLabel; QLabel *m_addressLabel; QLabel *m_subnetLabel; QLabel *m_gateWayLabel; - QLabel *m_dnsLabel; - QLabel *m_secDnsLabel; QLabel *m_configEmptyLabel; QLabel *m_addressHintLabel; QLabel *m_subnetEmptyLabel; QLabel *m_gateWayHintLabel; - QLabel *m_firstDnsEmptyLabel; + + MultipleDnsWidget *m_dnsWidget = nullptr; QLabel *m_statusLabel = nullptr; QList m_loadIcons; diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index d470b264..ec5605fb 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -486,28 +486,22 @@ void NetDetail::pagePadding(QString netName, bool isWlan) detailPage->setAutoConnect(m_info.isAutoConnect); //ipv4页面填充 + ipv4Page->setIpv4Config(m_info.ipv4ConfigType); + ipv4Page->setMulDns(m_info.ipv4DnsList); if (m_info.ipv4ConfigType == CONFIG_IP_MANUAL) { Q_EMIT checkCurrentIpv4Conflict(m_info.strIPV4Address); - ipv4Page->setIpv4Config(m_info.ipv4ConfigType); ipv4Page->setIpv4(m_info.strIPV4Address); ipv4Page->setNetMask(m_info.strIPV4NetMask); - ipv4Page->setIpv4FirDns(m_info.strIPV4FirDns); - ipv4Page->setIpv4SecDns(m_info.strIPV4SecDns); ipv4Page->setGateWay(m_info.strIPV4GateWay); - } else { - ipv4Page->setIpv4Config(m_info.ipv4ConfigType); } //ipv6页面填充 + ipv6Page->setIpv6Config(m_info.ipv6ConfigType); + ipv6Page->setMulDns(m_info.ipv6DnsList); if (m_info.ipv6ConfigType == CONFIG_IP_MANUAL) { Q_EMIT checkCurrentIpv6Conflict(m_info.strIPV6Address); - ipv6Page->setIpv6Config(m_info.ipv6ConfigType); ipv6Page->setIpv6(m_info.strIPV6Address); ipv6Page->setIpv6Perfix(m_info.iIPV6Prefix); - ipv6Page->setIpv6FirDns(m_info.strIPV6FirDns); - ipv6Page->setIpv6SecDns(m_info.strIPV6SecDns); ipv6Page->setGateWay(m_info.strIPV6GateWay); - } else { - ipv6Page->setIpv6Config(m_info.ipv6ConfigType); } //安全页面 @@ -521,6 +515,12 @@ void NetDetail::pagePadding(QString netName, bool isWlan) securityPage->setPeapInfo(m_info.peapInfo); } else if (m_info.enterpriseType == TTLS) { securityPage->setTtlsInfo(m_info.ttlsInfo); + } else if (m_info.enterpriseType == LEAP) { + securityPage->setLeapInfo(m_info.leapInfo); + } else if (m_info.enterpriseType == PWD) { + securityPage->setPwdInfo(m_info.pwdInfo); + } else if (m_info.enterpriseType == FAST) { + securityPage->setFastInfo(m_info.fastInfo); } } } @@ -653,6 +653,8 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived) // conInfo.ipv4ConfigType = connetSetting.m_ipv4ConfigIpType; conInfo.ipv6ConfigType = connetSetting.m_ipv6ConfigIpType; + conInfo.ipv4DnsList = connetSetting.m_ipv4Dns; + conInfo.ipv6DnsList = connetSetting.m_ipv6Dns; conInfo.isAutoConnect = connetSetting.m_isAutoConnect; // if (connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) { @@ -682,19 +684,23 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived) conInfo.iIPV6Prefix = ipv6Page->getPerfixLength(connetSetting.m_ipv6Address.at(0).netmask().toString()); conInfo.strIPV6GateWay = connetSetting.m_ipv6Address.at(0).gateway().toString(); } + } - if (connetSetting.m_ipv6Dns.size() == 1) { - conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString(); - } else if (connetSetting.m_ipv4Dns.size() > 1) { - conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString(); - conInfo.strIPV6SecDns = connetSetting.m_ipv6Dns.at(1).toString(); + QString dnsList; + dnsList.clear(); + if (!conInfo.ipv4DnsList.isEmpty()) { + for (QHostAddress str: conInfo.ipv4DnsList) { + dnsList.append(str.toString()); + dnsList.append("; "); } + dnsList.chop(2); + conInfo.strDynamicIpv4Dns = dnsList; } if (!bActived) { conInfo.strDynamicIpv4 = conInfo.strIPV4Address.isEmpty() ? tr("Auto") : conInfo.strIPV4Address; conInfo.strDynamicIpv6 = conInfo.strIPV6Address.isEmpty() ? tr("Auto") : conInfo.strIPV6Address; - conInfo.strDynamicIpv4Dns = conInfo.strIPV4FirDns.isEmpty() ? tr("Auto") : conInfo.strIPV4FirDns; + conInfo.strDynamicIpv4Dns = conInfo.ipv4DnsList.isEmpty() ? tr("Auto") : conInfo.strDynamicIpv4Dns; } } @@ -725,8 +731,14 @@ void NetDetail::initSecuData() initTlsInfo(m_info); } else if (m_info.enterpriseType == PEAP){ initPeapInfo(m_info); - } else { + } else if (m_info.enterpriseType == TTLS){ initTtlsInfo(m_info); + } else if (m_info.enterpriseType == LEAP){ + initLeapInfo(m_info); + } else if (m_info.enterpriseType == PWD){ + initPwdInfo(m_info); + } else if (m_info.enterpriseType == FAST){ + initFastInfo(m_info); } break; default: @@ -765,6 +777,21 @@ void NetDetail::initTtlsInfo(ConInfo &conInfo) m_resource->getEnterPriseInfoTtls(m_uuid, conInfo.ttlsInfo); } +void NetDetail::initLeapInfo(ConInfo &conInfo) +{ + m_resource->getEnterPriseInfoLeap(m_uuid, conInfo.leapInfo); +} + +void NetDetail::initPwdInfo(ConInfo &conInfo) +{ + m_resource->getEnterPriseInfoPwd(m_uuid, conInfo.pwdInfo); +} + +void NetDetail::initFastInfo(ConInfo &conInfo) +{ + m_resource->getEnterPriseInfoFast(m_uuid, conInfo.fastInfo); +} + //点击了保存更改网络设置的按钮 void NetDetail::on_btnConfirm_clicked() { @@ -880,6 +907,15 @@ void NetDetail::updateWirelessEnterPriseConnect(KyEapMethodType enterpriseType) } else if (enterpriseType == TTLS) { securityPage->updateTtlsChange(m_info.ttlsInfo); m_wirelessConnOpration->updateWirelessEnterPriseTtlsConnect(m_uuid, m_info.ttlsInfo); + } else if (enterpriseType == LEAP) { + securityPage->updateLeapChange(m_info.leapInfo); + m_wirelessConnOpration->updateWirelessEnterPriseLeapConnect(m_uuid, m_info.leapInfo); + } else if (enterpriseType == PWD) { + securityPage->updatePwdChange(m_info.pwdInfo); + m_wirelessConnOpration->updateWirelessEnterPrisePwdConnect(m_uuid, m_info.pwdInfo); + } else if (enterpriseType == FAST) { + securityPage->updateFastChange(m_info.fastInfo); + m_wirelessConnOpration->updateWirelessEnterPriseFastConnect(m_uuid, m_info.fastInfo); } } @@ -985,6 +1021,33 @@ bool NetDetail::createWirelessConnect() qDebug() << "addAndConnect TTLS connect"; m_wirelessConnOpration->addAndActiveWirelessEnterPriseTtlsConnect(m_info.ttlsInfo, connetSetting, m_deviceName, true); } + } else if (enterpriseType == LEAP) { + securityPage->updateLeapChange(m_info.leapInfo); + if (!m_name.isEmpty()) { + qDebug() << "add new LEAP connect"; + m_wirelessConnOpration->addLeapConnect(connetSetting, m_info.leapInfo); + } else { + qDebug() << "addAndConnect LEAP connect"; + m_wirelessConnOpration->addAndActiveWirelessEnterPriseLeapConnect(m_info.leapInfo, connetSetting, m_deviceName, true); + } + } else if (enterpriseType == PWD) { + securityPage->updatePwdChange(m_info.pwdInfo); + if (!m_name.isEmpty()) { + qDebug() << "add new PWD connect"; + m_wirelessConnOpration->addPwdConnect(connetSetting, m_info.pwdInfo); + } else { + qDebug() << "addAndConnect PWD connect"; + m_wirelessConnOpration->addAndActiveWirelessEnterPrisePwdConnect(m_info.pwdInfo, connetSetting, m_deviceName, true); + } + } else if (enterpriseType == FAST) { + securityPage->updateFastChange(m_info.fastInfo); + if (!m_name.isEmpty()) { + qDebug() << "add new FAST connect"; + m_wirelessConnOpration->addFastConnect(connetSetting, m_info.fastInfo); + } else { + qDebug() << "addAndConnect FAST connect"; + m_wirelessConnOpration->addAndActiveWirelessEnterPriseFastConnect(m_info.fastInfo, connetSetting, m_deviceName, true); + } } } else { securityPage->updateSecurityChange(connetSetting); @@ -1282,19 +1345,10 @@ void NetDetail::getIpv4Info(QString objPath, ConInfo &conInfo) while (!dbusArg2nd.atEnd()) { uint tempMap; dbusArg2nd >> tempMap; - addressVector.append(tempMap); + QString dns(inet_ntoa(*(struct in_addr *)&tempMap)); + conInfo.ipv4DnsList << QHostAddress(dns); } dbusArg2nd.endArray(); - if (addressVector.size() == 1) { - QString dns(inet_ntoa(*(struct in_addr *)&addressVector.at(0))); - conInfo.strIPV4FirDns = dns; - } else if (addressVector.size() > 1) { - QString dns1(inet_ntoa(*(struct in_addr *)&addressVector.at(0))); - QString dns2(inet_ntoa(*(struct in_addr *)&addressVector.at(1))); - conInfo.strIPV4FirDns = dns1; - conInfo.strIPV4SecDns = dns2; - } - } else if (inner_key == "gateway") { //gateway conInfo.strIPV4GateWay = innerMap.value(inner_key).toString(); diff --git a/src/frontend/netdetails/netdetail.h b/src/frontend/netdetails/netdetail.h index 386a539d..13391dfb 100644 --- a/src/frontend/netdetails/netdetail.h +++ b/src/frontend/netdetails/netdetail.h @@ -114,6 +114,9 @@ private: void initTlsInfo(ConInfo &conInfo); void initPeapInfo(ConInfo &conInfo); void initTtlsInfo(ConInfo &conInfo); + void initLeapInfo(ConInfo &conInfo); + void initPwdInfo(ConInfo &conInfo); + void initFastInfo(ConInfo &conInfo); void updateWirelessPersonalConnect(); void updateWirelessEnterPriseConnect(KyEapMethodType enterpriseType); diff --git a/src/frontend/netdetails/netdetails.pri b/src/frontend/netdetails/netdetails.pri index 75657d5d..f06fe245 100644 --- a/src/frontend/netdetails/netdetails.pri +++ b/src/frontend/netdetails/netdetails.pri @@ -10,6 +10,7 @@ HEADERS += \ $$PWD/ipv4page.h \ $$PWD/ipv6page.h \ $$PWD/joinhiddenwifipage.h \ + $$PWD/multiplednswidget.h \ $$PWD/netdetail.h \ $$PWD/securitypage.h @@ -22,5 +23,6 @@ SOURCES += \ $$PWD/ipv4page.cpp \ $$PWD/ipv6page.cpp \ $$PWD/joinhiddenwifipage.cpp \ + $$PWD/multiplednswidget.cpp \ $$PWD/netdetail.cpp \ $$PWD/securitypage.cpp diff --git a/src/frontend/netdetails/securitypage.cpp b/src/frontend/netdetails/securitypage.cpp index f4968ec2..82fabb95 100644 --- a/src/frontend/netdetails/securitypage.cpp +++ b/src/frontend/netdetails/securitypage.cpp @@ -84,6 +84,14 @@ void SecurityPage::initUI() userPwdEdit->setUseCustomPalette(true); userPwdFlagBox = new QCheckBox(this); + //FAST + m_pacCheckBox = new QCheckBox(this); + m_pacProvisionComboBox = new QComboBox(this); + m_pacFilePathComboBox = new QComboBox(this); + m_pacProvisionLabel = new FixLabel(this); + m_pacFlagLabel = new FixLabel(this); + m_pacFileLabel = new QLabel(this); + QWidget *queryWidget = new QWidget(this); QHBoxLayout *queryLayout = new QHBoxLayout(queryWidget); queryLayout->setContentsMargins(0, 0, 0, 0); @@ -106,22 +114,22 @@ void SecurityPage::initUI() rememberLayout->addWidget(m_checkLabel); rememberLayout->addStretch(); -// mSecuLayout = new QFormLayout(this); -// mSecuLayout->setContentsMargins(0, 0, 0, 0); -// mSecuLayout->addRow(secuTypeLabel, secuTypeCombox); -// mSecuLayout->addRow(pwdLabel, pwdEdit); -// mSecuLayout->addRow(eapTypeLabel, eapTypeCombox); -// mSecuLayout->addRow(identityLable, identityEdit); -// mSecuLayout->addRow(domainLable, domainEdit); -// mSecuLayout->addRow(caCertPathLabel, caCertPathCombox); -// mSecuLayout->addRow(caNeedBox, caNeedFlagLabel); -// mSecuLayout->addRow(clientCertPathLabel, clientCertPathCombox); -// mSecuLayout->addRow(clientPrivateKeyLabel, clientPrivateKeyCombox); -// mSecuLayout->addRow(clientPrivateKeyPwdLabel,clientPrivateKeyPwdEdit); -// mSecuLayout->addRow(eapMethodLabel, eapMethodCombox); -// mSecuLayout->addRow(userNameLabel, userNameEdit); -// mSecuLayout->addRow(userPwdLabel, userPwdEdit); -// mSecuLayout->addRow(userPwdFlagBox, userPwdFlagLabel); + // mSecuLayout = new QFormLayout(this); + // mSecuLayout->setContentsMargins(0, 0, 0, 0); + // mSecuLayout->addRow(secuTypeLabel, secuTypeCombox); + // mSecuLayout->addRow(pwdLabel, pwdEdit); + // mSecuLayout->addRow(eapTypeLabel, eapTypeCombox); + // mSecuLayout->addRow(identityLable, identityEdit); + // mSecuLayout->addRow(domainLable, domainEdit); + // mSecuLayout->addRow(caCertPathLabel, caCertPathCombox); + // mSecuLayout->addRow(caNeedBox, caNeedFlagLabel); + // mSecuLayout->addRow(clientCertPathLabel, clientCertPathCombox); + // mSecuLayout->addRow(clientPrivateKeyLabel, clientPrivateKeyCombox); + // mSecuLayout->addRow(clientPrivateKeyPwdLabel,clientPrivateKeyPwdEdit); + // mSecuLayout->addRow(eapMethodLabel, eapMethodCombox); + // mSecuLayout->addRow(userNameLabel, userNameEdit); + // mSecuLayout->addRow(userPwdLabel, userPwdEdit); + // mSecuLayout->addRow(userPwdFlagBox, userPwdFlagLabel); topLayout = new QGridLayout(); topLayout->setContentsMargins(0, 0, 0, 0); @@ -135,18 +143,27 @@ void SecurityPage::initUI() // EAP认证 Label和选项框 第2行,第0列,第1列 topLayout->addWidget(eapTypeLabel, 2, 0); topLayout->addWidget(eapTypeCombox, 2, 1); - //内部认证 Label和选项框 第3行,第0列,第1列 - topLayout->addWidget(eapMethodLabel, 3, 0); - topLayout->addWidget(eapMethodCombox, 3, 1); - //用户名 Label和输入框 第4行,第0列,第1列 - topLayout->addWidget(userNameLabel, 4, 0); - topLayout->addWidget(userNameEdit, 4, 1); - //密码 Label和密码框 第5行,第0列,第1列 - topLayout->addWidget(userPwdLabel, 5, 0); - topLayout->addWidget(userPwdEdit, 5, 1); - // 匿名身份 Label和输入框 第6行,第0列,第1列 - topLayout->addWidget(identityLable, 6, 0); - topLayout->addWidget(identityEdit, 6, 1); + // EAP认证 Label和选项框 第3行,第0列,第1列 + topLayout->addWidget(m_pacProvisionLabel, 3, 0); + topLayout->addWidget(m_pacProvisionComboBox, 3, 1); + // pac CheckBox和Label 第4行,第0列,第1列 + topLayout->addWidget(m_pacCheckBox, 4, 0); + topLayout->addWidget(m_pacFlagLabel, 4, 1); + // EAP认证 Label和选项框 第5行,第0列,第1列 + topLayout->addWidget(m_pacFileLabel, 5, 0); + topLayout->addWidget(m_pacFilePathComboBox, 5, 1); + //内部认证 Label和选项框 第6行,第0列,第1列 + topLayout->addWidget(eapMethodLabel, 6, 0); + topLayout->addWidget(eapMethodCombox, 6, 1); + //用户名 Label和输入框 第7行,第0列,第1列 + topLayout->addWidget(userNameLabel, 7, 0); + topLayout->addWidget(userNameEdit, 7, 1); + //密码 Label和密码框 第8行,第0列,第1列 + topLayout->addWidget(userPwdLabel, 8, 0); + topLayout->addWidget(userPwdEdit, 8, 1); + // 匿名身份 Label和输入框 第9行,第0列,第1列 + topLayout->addWidget(identityLable, 9, 0); + topLayout->addWidget(identityEdit, 9, 1); // CA证书选项框及CheckBox布局 @@ -186,7 +203,7 @@ void SecurityPage::initUI() if (isDetailPage) { checkWidget->hide(); - topLayout->addWidget(queryWidget, 7, 1); + topLayout->addWidget(queryWidget, 10, 1); changeColumnWidthWithSecuType(); } else { queryWidget->hide(); @@ -237,6 +254,9 @@ void SecurityPage::initUI() eapTypeCombox->addItem("TLS", TLS); eapTypeCombox->addItem("PEAP", PEAP); eapTypeCombox->addItem("TTLS", TTLS); + eapTypeCombox->addItem("LEAP", LEAP); + eapTypeCombox->addItem("PWD", PWD); + eapTypeCombox->addItem("FAST", FAST); eapTypeCombox->setCurrentIndex(TLS); //TLS caCertPathCombox->addItem(tr("None"), QString(tr("None"))); //无 @@ -248,6 +268,18 @@ void SecurityPage::initUI() clientPrivateKeyCombox->addItem(tr("None"), QString(tr("None"))); //无 clientPrivateKeyCombox->addItem(tr("Choose from file..."), QString(tr("Choose from file..."))); //从文件中选择... + //FAST + m_pacCheckBox->setChecked(true); + m_pacProvisionLabel->setText(tr("PAC provisioning")); //PAC配置 + m_pacFlagLabel->setText(tr("Allow automatic PAC provisioning")); //允许自动PAC配置 + m_pacFileLabel->setText(tr("PAC file")); //PAC文件 + m_pacProvisionComboBox->addItem(tr("Anonymous"), ANON); //匿名 + m_pacProvisionComboBox->addItem(tr("Authenticated"), AUTHEN); //已认证 + m_pacProvisionComboBox->addItem(tr("Both"), BOTH); //两者兼用 + m_pacProvisionComboBox->setCurrentIndex(ANON); + m_pacFilePathComboBox->addItem(tr("None"), QString(tr("None"))); //无 + m_pacFilePathComboBox->addItem(tr("Choose from file..."), QString(tr("Choose from file..."))); //从文件中选择... + //仅为该用户存储密码 pwdOptionCombox->addItem(tr("Store passwords only for this user"), QString(tr("Store password only for this user"))); //存储所有用户的密码 @@ -273,13 +305,13 @@ void SecurityPage::initUI() void SecurityPage::initConnect() { //安全类型变化 -// connect(secuTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onSecuTypeComboxIndexChanged); + // connect(secuTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onSecuTypeComboxIndexChanged); connect(secuTypeCombox, QOverload::of(&QComboBox::currentIndexChanged), this, &SecurityPage::onSecuTypeComboxIndexChanged); connect(secuTypeCombox, QOverload::of(&QComboBox::currentIndexChanged), this, &SecurityPage::changeColumnWidthWithSecuType); //EAP方式变化 -// connect(eapTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onEapTypeComboxIndexChanged); + // connect(eapTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onEapTypeComboxIndexChanged); connect(eapTypeCombox, QOverload::of(&QComboBox::currentIndexChanged), this, &SecurityPage::onEapTypeComboxIndexChanged); connect(caNeedBox, &QCheckBox::clicked, this, &SecurityPage::onCaNeedBoxClicked); @@ -308,7 +340,13 @@ void SecurityPage::initConnect() connect(eapMethodCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn())); connect(userNameEdit, &LineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn); connect(userPwdEdit, &LineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn); + connect(m_pacCheckBox, &QCheckBox::stateChanged, this, &SecurityPage::setEnableOfSaveBtn); + connect(m_pacProvisionComboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(setEnableOfSaveBtn())); + connect(m_pacFilePathComboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(setEnableOfSaveBtn())); + connect(m_pacCheckBox, &QCheckBox::clicked, this, &SecurityPage::onPacBoxClicked); + connect(m_pacFilePathComboBox, static_cast(&QComboBox::currentIndexChanged), + this, &SecurityPage::onPacFilePathComboxIndexChanged); } void SecurityPage::setSecurity(KySecuType index) @@ -419,6 +457,71 @@ void SecurityPage::setTtlsInfo(KyEapMethodTtlsInfo &info) } } +void SecurityPage::setLeapInfo(KyEapMethodLeapInfo &info) +{ + showLeapOrPwd(); + eapTypeCombox->setCurrentIndex(LEAP); + userNameEdit->setText(info.m_userName); + userPwdEdit->setText(info.m_userPwd); + if (info.m_passwdFlag) { + userPwdFlagBox->setChecked(true); + } else { + userPwdFlagBox->setChecked(false); + } +} + +void SecurityPage::setPwdInfo(KyEapMethodPwdInfo &info) +{ + showLeapOrPwd(); + eapTypeCombox->setCurrentIndex(PWD); + userNameEdit->setText(info.m_userName); + userPwdEdit->setText(info.m_userPwd); + if (info.m_passwdFlag) { + userPwdFlagBox->setChecked(true); + } else { + userPwdFlagBox->setChecked(false); + } +} + +void SecurityPage::setFastInfo(KyEapMethodFastInfo &info) +{ + showFast(); + eapTypeCombox->setCurrentIndex(FAST); + onEapTypeComboxIndexChanged(); + + identityEdit->setText(info.m_anonIdentity); + if (info.m_pacProvisioning == KyFastProvisioningAllowUnauthenticated) { + m_pacProvisionComboBox->setCurrentIndex(ANON); + } else if (info.m_pacProvisioning == KyFastProvisioningAllowAuthenticated) { + m_pacProvisionComboBox->setCurrentIndex(AUTHEN); + } else if (info.m_pacProvisioning == KyFastProvisioningAllowBoth) { + m_pacProvisionComboBox->setCurrentIndex(BOTH); + } + + if (info.m_pacFilePath.isEmpty()) { + m_pacFilePathComboBox->setItemText(0, QString(tr("None"))); + m_pacCheckBox->setChecked(true); + m_pacFilePathComboBox->setEnabled(false); + } else { + m_pacFilePathComboBox->setItemText(0, info.m_pacFilePath); + m_pacCheckBox->setChecked(false); + m_pacFilePathComboBox->setEnabled(true); + } + + if (info.m_authMethod == KyAuthMethodGtc) { + eapMethodCombox->setCurrentIndex(GTC_FAST); + } else if (info.m_authMethod == KyAuthMethodMschapv2) { + eapMethodCombox->setCurrentIndex(MSCHAPV2_FAST); + } + userNameEdit->setText(info.m_userName); + userPwdEdit->setText(info.m_userPwd); + if (info.m_passwdFlag) { + userPwdFlagBox->setChecked(true); + } else { + userPwdFlagBox->setChecked(false); + } +} + void SecurityPage::setSecurityVisible(const bool &visible) { if (secuTypeLabel) { @@ -461,6 +564,33 @@ void SecurityPage::updateTtlsChange(KyEapMethodTtlsInfo &info) info = ttlsInfo; } +void SecurityPage::updateLeapChange(KyEapMethodLeapInfo &info) +{ + KyEapMethodLeapInfo leapInfo = assembleLeapInfo(); + if (leapInfo.m_userPwd != info.m_userPwd) { + leapInfo.bChanged = true; + } + info = leapInfo; +} + +void SecurityPage::updatePwdChange(KyEapMethodPwdInfo &info) +{ + KyEapMethodPwdInfo pwdInfo = assemblePwdInfo(); + if (pwdInfo.m_userPwd != info.m_userPwd) { + pwdInfo.bChanged = true; + } + info = pwdInfo; +} + +void SecurityPage::updateFastChange(KyEapMethodFastInfo &info) +{ + KyEapMethodFastInfo pwdInfo = assembleFastInfo(); + if (pwdInfo.m_userPwd != info.m_userPwd) { + pwdInfo.bChanged = true; + } + info = pwdInfo; +} + void SecurityPage::getSecuType(KySecuType &secuType, KyEapMethodType &enterpriseType) { secuType = (KySecuType)secuTypeCombox->currentData().toInt(); @@ -481,7 +611,7 @@ bool SecurityPage::checkIsChanged(const ConInfo info) if (info.secType == NONE) { return false; } else if (info.secType == WPA_AND_WPA2_PERSONAL || info.secType == WPA3_PERSONAL) { - return !(info.strPassword == pwdEdit->text()); + return !(info.strPassword == pwdEdit->text()); } else { if (info.enterpriseType != eapTypeCombox->currentData().toInt()) { return true; @@ -492,6 +622,12 @@ bool SecurityPage::checkIsChanged(const ConInfo info) return !(info.peapInfo == assemblePeapInfo()); } else if (info.enterpriseType == TTLS) { return !(info.ttlsInfo == assembleTtlsInfo()); + } else if (info.enterpriseType == LEAP) { + return !(info.leapInfo == assembleLeapInfo()); + } else if (info.enterpriseType == PWD) { + return !(info.pwdInfo == assemblePwdInfo()); + } else if (info.enterpriseType == FAST) { + return !(info.fastInfo == assembleFastInfo()); } } } @@ -521,6 +657,14 @@ void SecurityPage::showNone() userNameEdit->hide(); userPwdEdit->hide(); userPwdFlagLabel->hide(); + + //FAST + m_pacCheckBox->hide(); + m_pacProvisionComboBox->hide(); + m_pacFilePathComboBox->hide(); + m_pacProvisionLabel->hide(); + m_pacFlagLabel->hide(); + m_pacFileLabel->hide(); } void SecurityPage::showPsk() @@ -546,6 +690,14 @@ void SecurityPage::showPsk() userNameEdit->hide(); userPwdEdit->hide(); userPwdFlagLabel->hide(); + + //FAST + m_pacCheckBox->hide(); + m_pacProvisionComboBox->hide(); + m_pacFilePathComboBox->hide(); + m_pacProvisionLabel->hide(); + m_pacFlagLabel->hide(); + m_pacFileLabel->hide(); } void SecurityPage::showTls() @@ -570,6 +722,14 @@ void SecurityPage::showTls() userNameEdit->hide(); userPwdEdit->hide(); userPwdFlagLabel->hide(); + + //FAST + m_pacCheckBox->hide(); + m_pacProvisionComboBox->hide(); + m_pacFilePathComboBox->hide(); + m_pacProvisionLabel->hide(); + m_pacFlagLabel->hide(); + m_pacFileLabel->hide(); } void SecurityPage::showPeapOrTtls() @@ -586,6 +746,14 @@ void SecurityPage::showPeapOrTtls() identityEdit->hide(); tlsWidget->hide(); + //FAST + m_pacCheckBox->hide(); + m_pacProvisionComboBox->hide(); + m_pacFilePathComboBox->hide(); + m_pacProvisionLabel->hide(); + m_pacFlagLabel->hide(); + m_pacFileLabel->hide(); + //PEAP TTLS共有 eapMethodLabel->show(); userNameLabel->show(); @@ -598,6 +766,96 @@ void SecurityPage::showPeapOrTtls() userPwdFlagLabel->show(); } +void SecurityPage::showLeapOrPwd() +{ + pwdEdit->hide(); + eapTypeCombox->show(); + + identityEdit->hide(); + domainEdit->hide(); + caCertPathCombox->hide(); + caNeedBox->hide(); + clientCertPathCombox->hide(); + clientPrivateKeyCombox->hide(); + clientPrivateKeyPwdEdit->hide(); + + eapMethodCombox->hide(); + userNameEdit->show(); + userPwdEdit->show(); + userPwdFlagBox->show(); + + pwdLabel->hide(); + //企业wifi共有 + eapTypeLabel->show(); + //TLS + identityLable->hide(); + domainLable->hide(); + caCertPathLabel->hide(); + caNeedFlagLabel->hide(); + clientCertPathLabel->hide(); + clientPrivateKeyLabel->hide(); + clientPrivateKeyPwdLabel->hide(); + + //PEAP TTLS共有 + eapMethodLabel->hide(); + userNameLabel->show(); + userPwdLabel->show(); + userPwdFlagLabel->show(); + + //FAST + m_pacCheckBox->hide(); + m_pacProvisionComboBox->hide(); + m_pacFilePathComboBox->hide(); + m_pacProvisionLabel->hide(); + m_pacFlagLabel->hide(); + m_pacFileLabel->hide(); +} + +void SecurityPage::showFast() +{ + pwdEdit->hide(); + eapTypeCombox->show(); + + identityEdit->show(); + domainEdit->hide(); + caCertPathCombox->hide(); + caNeedBox->hide(); + clientCertPathCombox->hide(); + clientPrivateKeyCombox->hide(); + clientPrivateKeyPwdEdit->hide(); + + eapMethodCombox->show(); + userNameEdit->show(); + userPwdEdit->show(); + userPwdFlagBox->hide(); + + pwdLabel->hide(); + //企业wifi共有 + eapTypeLabel->show(); + //TLS + identityLable->show(); + domainLable->hide(); + caCertPathLabel->hide(); + caNeedFlagLabel->hide(); + clientCertPathLabel->hide(); + clientPrivateKeyLabel->hide(); + clientPrivateKeyPwdLabel->hide(); + + //PEAP TTLS共有 + eapMethodLabel->show(); + userNameLabel->show(); + userPwdLabel->show(); + userPwdFlagLabel->hide(); + + //FAST + m_pacCheckBox->show(); + m_pacProvisionComboBox->show(); + m_pacFilePathComboBox->show(); + m_pacProvisionLabel->show(); + m_pacFlagLabel->show(); + m_pacFileLabel->show(); +} + KyEapMethodTlsInfo SecurityPage::assembleTlsInfo() { KyEapMethodTlsInfo info; @@ -627,7 +885,7 @@ KyEapMethodTlsInfo SecurityPage::assembleTlsInfo() KyEapMethodPeapInfo SecurityPage::assemblePeapInfo() { KyEapMethodPeapInfo info; -// info.phase2AuthMethod = (KyNoEapMethodAuth)eapMethodCombox->currentData().toInt(); + // info.phase2AuthMethod = (KyNoEapMethodAuth)eapMethodCombox->currentData().toInt(); switch (eapMethodCombox->currentIndex()) { case 0: info.phase2AuthMethod = KyAuthMethodMschapv2; @@ -688,6 +946,60 @@ KyEapMethodTtlsInfo SecurityPage::assembleTtlsInfo() return info; } +KyEapMethodLeapInfo SecurityPage::assembleLeapInfo() +{ + KyEapMethodLeapInfo info; + info.m_userName = userNameEdit->text(); + info.m_userPwd = userPwdEdit->text(); + info.m_passwdFlag = (userPwdFlagBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None); + return info; +} + +KyEapMethodPwdInfo SecurityPage::assemblePwdInfo() +{ + KyEapMethodPwdInfo info; + info.m_userName = userNameEdit->text(); + info.m_userPwd = userPwdEdit->text(); + info.m_passwdFlag = (userPwdFlagBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None); + return info; +} + +KyEapMethodFastInfo SecurityPage::assembleFastInfo() +{ + KyEapMethodFastInfo info; + info.m_anonIdentity = identityEdit->text(); + switch (m_pacProvisionComboBox->currentIndex()) { + case ANON: + info.m_pacProvisioning = KyFastProvisioningAllowUnauthenticated; + break; + case AUTHEN: + info.m_pacProvisioning = KyFastProvisioningAllowAuthenticated; + break; + case BOTH: + info.m_pacProvisioning = KyFastProvisioningAllowBoth; + break; + default: + break; + } + info.m_allowAutoPacFlag = m_pacCheckBox->isChecked(); + info.m_pacFilePath = m_pacFilePathComboBox->currentText(); + + switch (eapMethodCombox->currentIndex()) { + case GTC_FAST: + info.m_authMethod = KyAuthMethodGtc; + break; + case MSCHAPV2_FAST: + info.m_authMethod = KyAuthMethodMschapv2; + break; + default: + break; + } + info.m_userName = userNameEdit->text(); + info.m_userPwd = userPwdEdit->text(); + info.m_passwdFlag = (userPwdFlagBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None); + return info; +} + void SecurityPage::updateSecurityChange(KyWirelessConnectSetting &setting) { qDebug() << "secuTypeCombox->currentData()" << secuTypeCombox->currentData().toInt() << pwdEdit->text(); @@ -746,7 +1058,20 @@ bool SecurityPage::checkConnectBtnIsEnabled() qDebug() << "client Private Key password is empty"; return false; } - } else if (type == PEAP || type == TTLS) { + } else if (type == PEAP || type == TTLS || type == LEAP || type == PWD) { + if(userNameEdit->text().isEmpty() || userPwdEdit->text().isEmpty()) { + qDebug() << "user name or user password is empty"; + return false; + } + } else if (type == FAST) { + if (identityEdit->text().isEmpty()) { + qDebug() << "fast anonymous identity is empty"; + return false; + } + if(!m_pacCheckBox->isChecked()) { + qDebug() << "Not allow automatic PAC provisioning "; + return false; + } if(userNameEdit->text().isEmpty() || userPwdEdit->text().isEmpty()) { qDebug() << "user name or user password is empty"; return false; @@ -805,6 +1130,18 @@ void SecurityPage::onEapTypeComboxIndexChanged() eapMethodCombox->addItem("md5(eap)", MD5_EAP); eapMethodCombox->addItem("gtc(eap)", GTC_EAP); Q_EMIT this->eapTypeChanged(TTLS); + } else if (index == LEAP) { + showLeapOrPwd(); + Q_EMIT this->eapTypeChanged(LEAP); + } else if (index == PWD) { + showLeapOrPwd(); + Q_EMIT this->eapTypeChanged(PWD); + } else if (index == FAST) { + showFast(); + eapMethodCombox->clear(); + eapMethodCombox->addItem("GTC", GTC_FAST); + eapMethodCombox->addItem("MSCHAPv2", MSCHAPV2_FAST); + Q_EMIT this->eapTypeChanged(FAST); } } @@ -818,6 +1155,16 @@ void SecurityPage::onCaNeedBoxClicked() } } +void SecurityPage::onPacBoxClicked() +{ + if (!m_pacCheckBox->isChecked()) { + m_pacProvisionComboBox->setCurrentIndex(ANON); + m_pacProvisionComboBox->setEnabled(false); + } else { + m_pacProvisionComboBox->setEnabled(true); + } +} + void SecurityPage::onCaCertPathComboxIndexChanged(QString str) { if (str.contains("Choose from file...") || str.contains("从文件选择...")) @@ -886,6 +1233,29 @@ void SecurityPage::onClientPrivateKeyComboxIndexChanged(QString str) } } +void SecurityPage::onPacFilePathComboxIndexChanged(QString str) +{ + if (str.contains("Choose from file...") || str.contains("从文件选择...")) + { + QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a PAC file"), "recent:///", + tr("PAC Files (*.pac)")); + if (!fileName.isNull()) { + QStringList nameList = fileName.split("/"); + m_pacFilePathComboBox->blockSignals(true); + m_pacFilePathComboBox->setItemText(0, fileName); + m_pacFilePathComboBox->setCurrentIndex(0); + m_pacFilePathComboBox->blockSignals(false); + } else { + m_pacFilePathComboBox->blockSignals(true); + m_pacFilePathComboBox->setItemText(0, tr("None")); + m_pacFilePathComboBox->setCurrentIndex(0); + m_pacFilePathComboBox->blockSignals(false); + } + } else { + qWarning() << "Choose file is null or unvalible"; + } +} + void SecurityPage::onPwdOptionComboxIndexChanged(QString str) { KyEapMethodTlsInfo info; diff --git a/src/frontend/netdetails/securitypage.h b/src/frontend/netdetails/securitypage.h index 0bc2b84e..82c4b407 100644 --- a/src/frontend/netdetails/securitypage.h +++ b/src/frontend/netdetails/securitypage.h @@ -31,6 +31,7 @@ #include "kylable.h" #include "kwidget.h" #include "kpasswordedit.h" +#include "detailwidget.h" using namespace kdk; @@ -45,6 +46,9 @@ public: void setTlsInfo(KyEapMethodTlsInfo &info); void setPeapInfo(KyEapMethodPeapInfo &info); void setTtlsInfo(KyEapMethodTtlsInfo &info); + void setLeapInfo(KyEapMethodLeapInfo &info); + void setPwdInfo(KyEapMethodPwdInfo &info); + void setFastInfo(KyEapMethodFastInfo &info); void setSecurityVisible(const bool &visible); bool checkIsChanged(const ConInfo info); @@ -52,6 +56,9 @@ public: void updateTlsChange(KyEapMethodTlsInfo &info); void updatePeapChange(KyEapMethodPeapInfo &info); void updateTtlsChange(KyEapMethodTtlsInfo &info); + void updateLeapChange(KyEapMethodLeapInfo &info); + void updatePwdChange(KyEapMethodPwdInfo &info); + void updateFastChange(KyEapMethodFastInfo &info); void getSecuType(KySecuType &secuType, KyEapMethodType &enterpriseType); bool getAutoConnectState(); @@ -103,6 +110,15 @@ private: KPasswordEdit *userPwdEdit = nullptr; QCheckBox *userPwdFlagBox; + //FAST + QCheckBox *m_pacCheckBox; + QComboBox *m_pacProvisionComboBox; + QComboBox *m_pacFilePathComboBox; + FixLabel *m_pacProvisionLabel; + FixLabel *m_pacFlagLabel; + QLabel *m_pacFileLabel; + QWidget *m_pacCheckWidget; + QLabel *m_emptyLabel = nullptr; QLabel *m_checkLabel = nullptr; QCheckBox *m_rememberCheckBox = nullptr; @@ -115,12 +131,17 @@ private: void showPsk(); void showTls(); void showPeapOrTtls(); + void showLeapOrPwd(); + void showFast(); void initUI(); void initConnect(); KyEapMethodTlsInfo assembleTlsInfo(); KyEapMethodPeapInfo assemblePeapInfo(); KyEapMethodTtlsInfo assembleTtlsInfo(); + KyEapMethodLeapInfo assembleLeapInfo(); + KyEapMethodPwdInfo assemblePwdInfo(); + KyEapMethodFastInfo assembleFastInfo(); bool checkConnectBtnIsEnabled(); @@ -131,12 +152,14 @@ private Q_SLOTS: void setEnableOfSaveBtn(); void onCaNeedBoxClicked(); + void onPacBoxClicked(); void onCaCertPathComboxIndexChanged(QString str); void onClientCertPathComboxIndexChanged(QString str); void onClientPrivateKeyComboxIndexChanged(QString str); void onPwdOptionComboxIndexChanged(QString str); void changeColumnWidthWithSecuType(); + void onPacFilePathComboxIndexChanged(QString str); Q_SIGNALS: void setSecuPageState(bool); diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index b8d0c94a..8d6a1a68 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -1161,6 +1161,15 @@ void LanPage::setWiredDeviceEnable(const QString& devName, bool enable) m_deviceResource->setDeviceManaged(devName, enable); } +void LanPage::deleteWired(const QString &connUuid) +{ + qDebug() << "[LanPage] deleteWired" << connUuid; + if (connUuid == nullptr) { + return; + } + m_wiredConnectOperation->deleteWiredConnect(connUuid); +} + bool LanPage::eventFilter(QObject *watched, QEvent *event) { if (watched == m_settingsLabel) { diff --git a/src/frontend/tab-pages/lanpage.h b/src/frontend/tab-pages/lanpage.h index d8ed6eba..0bae5fb5 100644 --- a/src/frontend/tab-pages/lanpage.h +++ b/src/frontend/tab-pages/lanpage.h @@ -44,6 +44,7 @@ public: //for dbus void getWiredList(QMap > &map); + void deleteWired(const QString& connUuid); void activateWired(const QString& devName, const QString& connUuid); void deactivateWired(const QString& devName, const QString& connUuid); void showDetailPage(QString devName, QString uuid); diff --git a/src/frontend/tools/infobutton.cpp b/src/frontend/tools/infobutton.cpp index 62ff0d01..8e462343 100644 --- a/src/frontend/tools/infobutton.cpp +++ b/src/frontend/tools/infobutton.cpp @@ -20,6 +20,7 @@ #include "infobutton.h" #include #include +#include #include #define BUTTON_SIZE 36,36 diff --git a/src/frontend/tools/radioitembutton.cpp b/src/frontend/tools/radioitembutton.cpp index 981e7569..6cb4b2fa 100644 --- a/src/frontend/tools/radioitembutton.cpp +++ b/src/frontend/tools/radioitembutton.cpp @@ -19,6 +19,7 @@ */ #include "radioitembutton.h" #include +#include #include #include #include diff --git a/src/frontend/tools/tools.pri b/src/frontend/tools/tools.pri index 7863428b..9c261260 100644 --- a/src/frontend/tools/tools.pri +++ b/src/frontend/tools/tools.pri @@ -3,6 +3,7 @@ INCLUDEPATH += $$PWD HEADERS += \ $$PWD/divider.h \ $$PWD/infobutton.h \ + $$PWD/listitemedit.h \ $$PWD/loadingdiv.h \ $$PWD/radioitembutton.h \ $$PWD/switchbutton.h \ @@ -12,6 +13,7 @@ HEADERS += \ SOURCES += \ $$PWD/divider.cpp \ $$PWD/infobutton.cpp \ + $$PWD/listitemedit.cpp \ $$PWD/loadingdiv.cpp \ $$PWD/radioitembutton.cpp \ $$PWD/switchbutton.cpp \ diff --git a/src/frontend/wificonfigdialog.cpp b/src/frontend/wificonfigdialog.cpp index 3207eca7..f91a524b 100644 --- a/src/frontend/wificonfigdialog.cpp +++ b/src/frontend/wificonfigdialog.cpp @@ -27,6 +27,7 @@ #include #include +#include WiFiConfigDialog::WiFiConfigDialog(QWidget *parent) : QDialog(parent),