Merge branch 'kylin-nm-new' into kylin-nm-lan-switch
This commit is contained in:
commit
ee8485915d
|
@ -17,6 +17,7 @@ Build-Depends: debhelper (>=9),
|
|||
libqt5svg5-dev,
|
||||
libkf5networkmanagerqt-dev (>= 5.36.0),
|
||||
libnm-dev,
|
||||
libcap-dev,
|
||||
Standards-Version: 4.5.0
|
||||
Rules-Requires-Root: no
|
||||
Homepage: https://github.com/ukui/kylin-nm
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
PROGRAM=$(dpkg-divert --truename /usr/bin/kylin-network-manager)
|
||||
|
||||
if setcap cap_net_raw+ep $PROGRAM; then
|
||||
chmod u-s $PROGRAM
|
||||
fi
|
||||
|
||||
echo "kylin nm set cap success"
|
||||
|
||||
exit 0
|
||||
|
|
@ -7,8 +7,6 @@ SUBDIRS = \
|
|||
src \
|
||||
|
||||
TRANSLATIONS += \
|
||||
translations/kylin-nm_zh_CN.ts \
|
||||
translations/kylin-nm_zh_CN.ts \
|
||||
translations/kylin-nm_tr.ts \
|
||||
translations/kylin-nm_bo.ts
|
||||
|
||||
QT += widgets
|
||||
translations/kylin-nm_bo.ts
|
||||
|
|
|
@ -8,6 +8,7 @@ HEADERS += \
|
|||
$$PWD/ksimplenm.h \
|
||||
$$PWD/kylin-dbus-interface.h \
|
||||
$$PWD/kylin-network-interface.h \
|
||||
$$PWD/kylinarping.h \
|
||||
$$PWD/kylinipv4arping.h \
|
||||
$$PWD/kylinipv6arping.h \
|
||||
$$PWD/sysdbusregister.h \
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
#ifndef KYLINARPING_H
|
||||
#define KYLINARPING_H
|
||||
|
||||
#include <sys/capability.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <QDebug>
|
||||
|
||||
static cap_flag_value_t cap_raw = CAP_CLEAR;
|
||||
static const cap_value_t caps[] = { CAP_NET_RAW };
|
||||
|
||||
static void limit_capabilities()
|
||||
{
|
||||
cap_t cap_p;
|
||||
|
||||
cap_p = cap_get_proc();
|
||||
if (!cap_p) {
|
||||
qWarning()<<"cap_get_proc failed.";
|
||||
}
|
||||
|
||||
cap_get_flag(cap_p, CAP_NET_RAW, CAP_PERMITTED, &cap_raw);
|
||||
|
||||
if (cap_raw != CAP_CLEAR) {
|
||||
if (cap_clear(cap_p) < 0) {
|
||||
qWarning()<<"cap clear failed"<<errno;
|
||||
}
|
||||
|
||||
cap_set_flag(cap_p, CAP_PERMITTED, 1, caps, CAP_SET);
|
||||
|
||||
if (cap_set_proc(cap_p) < 0) {
|
||||
qWarning()<<"cap set proc failed" << errno;
|
||||
}
|
||||
}
|
||||
|
||||
if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
|
||||
qWarning()<<"pr set keepcaps 1 failed"<<errno;
|
||||
}
|
||||
|
||||
if (setuid(getuid()) < 0) {
|
||||
qWarning()<<"set uid failed"<< errno;
|
||||
}
|
||||
|
||||
if (prctl(PR_SET_KEEPCAPS, 0) < 0) {
|
||||
qWarning()<<"pr set keepcaps 0 failed" << errno;
|
||||
}
|
||||
|
||||
cap_free(cap_p);
|
||||
}
|
||||
|
||||
static int modify_capability_raw(int on)
|
||||
{
|
||||
cap_t cap_p;
|
||||
|
||||
if (cap_raw != CAP_SET) {
|
||||
qWarning()<<"modify on"<<on;
|
||||
return on ? -1 : 0;
|
||||
}
|
||||
|
||||
cap_p = cap_get_proc();
|
||||
if (!cap_p) {
|
||||
qWarning()<<"modify cap raw get proc failed"<<errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
cap_set_flag(cap_p, CAP_EFFECTIVE, 1, caps, on ? CAP_SET : CAP_CLEAR);
|
||||
|
||||
if (cap_set_proc(cap_p) < 0) {
|
||||
qWarning()<<"modify cap raw set proc failed"<<errno;
|
||||
}
|
||||
|
||||
cap_free(cap_p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void drop_capabilities(void)
|
||||
{
|
||||
#if 0
|
||||
cap_t cap_p = cap_init();
|
||||
|
||||
if (!cap_p) {
|
||||
qWarning()<<"cap init failed"<<errno;
|
||||
}
|
||||
|
||||
if (cap_set_proc(cap_p) < 0) {
|
||||
qWarning()<<"drop cap set cap failed" << errno;
|
||||
}
|
||||
|
||||
cap_free(cap_p);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int enable_capability_raw()
|
||||
{
|
||||
return modify_capability_raw(1);
|
||||
}
|
||||
|
||||
static inline int disable_capability_raw()
|
||||
{
|
||||
return modify_capability_raw(0);
|
||||
}
|
||||
|
||||
#endif // KYLINARPING_H
|
|
@ -375,13 +375,17 @@ void KyIpv4Arping::findBroadcastAddress()
|
|||
|
||||
int KyIpv4Arping::ipv4ConflictCheck()
|
||||
{
|
||||
limit_capabilities();
|
||||
|
||||
int ret = checkDevice();
|
||||
if (ret < 0) {
|
||||
qWarning()<<"[KyIpv4Arping]"<<"the device is invalid" << m_ifaceName;
|
||||
return -1;
|
||||
}
|
||||
|
||||
enable_capability_raw();
|
||||
m_ipv4Socket = socket(PF_PACKET, SOCK_DGRAM, 0);
|
||||
disable_capability_raw();
|
||||
if (m_ipv4Socket < 0) {
|
||||
qWarning()<<"[KyIpv4Arping]" << "create ipv4 socket failed, errno" << errno;
|
||||
return -1;
|
||||
|
@ -419,6 +423,8 @@ int KyIpv4Arping::ipv4ConflictCheck()
|
|||
|
||||
findBroadcastAddress();
|
||||
|
||||
drop_capabilities();
|
||||
|
||||
ret = ipv4EventLoop();
|
||||
close(m_ipv4Socket);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <sys/signalfd.h>
|
||||
#include <sys/timerfd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "kylinarping.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <sys/times.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include "kylinarping.h"
|
||||
|
||||
KyIpv6Arping::KyIpv6Arping(QString ifaceName, QString ipAddress, int retryCount, int timeout, QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
@ -310,7 +311,11 @@ int KyIpv6Arping::ipv6ConflictCheck()
|
|||
struct icmp6_filter filter;
|
||||
int retry = 0;
|
||||
|
||||
limit_capabilities();
|
||||
|
||||
enable_capability_raw();
|
||||
m_ipv6Socket = socket (PF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
|
||||
disable_capability_raw();
|
||||
if (m_ipv6Socket < 0) {
|
||||
qDebug()<<"[KyIpv6Arping]" <<"create ipv6 socket failed:";
|
||||
return -1;
|
||||
|
@ -321,6 +326,8 @@ int KyIpv6Arping::ipv6ConflictCheck()
|
|||
/* set ICMPv6 filter */
|
||||
ICMP6_FILTER_SETBLOCKALL (&filter);
|
||||
ICMP6_FILTER_SETPASS (ND_NEIGHBOR_ADVERT, &filter);
|
||||
|
||||
enable_capability_raw();
|
||||
setsockopt (m_ipv6Socket, IPPROTO_ICMPV6, ICMP6_FILTER, &filter, sizeof (filter));
|
||||
|
||||
int soDontRoute = 1;
|
||||
|
@ -339,6 +346,10 @@ int KyIpv6Arping::ipv6ConflictCheck()
|
|||
setsockopt(m_ipv6Socket, IPPROTO_IPV6, IPV6_RECVHOPLIMIT,
|
||||
&recvHopLimit, sizeof (recvHopLimit));
|
||||
|
||||
disable_capability_raw();
|
||||
|
||||
drop_capabilities();
|
||||
|
||||
/* resolves target's IPv6 address */
|
||||
int ret = getIpv6ByName(&tgt);
|
||||
if (ret < 0) {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
INCLUDEPATH += $$PWD
|
||||
|
||||
FORMS += \
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/enterprisewlandialog.h \
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/enterprisewlandialog.cpp \
|
|
@ -0,0 +1,205 @@
|
|||
#include "enterprisewlandialog.h"
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include "xatom-helper.h"
|
||||
#define MAIN_SIZE_EXPAND 400,500
|
||||
#define MAIN_SIZE_NARROW 400,400
|
||||
|
||||
EnterpriseWlanDialog::EnterpriseWlanDialog(KyWirelessNetItem *data, QString device, QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
//设置窗口无边框,阴影
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||
MotifWmHints window_hints;
|
||||
window_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
||||
window_hints.functions = MWM_FUNC_ALL;
|
||||
window_hints.decorations = MWM_DECOR_BORDER;
|
||||
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), window_hints);
|
||||
#else
|
||||
this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
|
||||
#endif
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
m_data = data;
|
||||
m_deviceName = device;
|
||||
m_connectOperation = new KyWirelessConnectOperation();
|
||||
m_resource = new KyWirelessNetResource();
|
||||
|
||||
initUI();
|
||||
initData();
|
||||
centerToScreen();
|
||||
}
|
||||
|
||||
EnterpriseWlanDialog::~EnterpriseWlanDialog() {
|
||||
if (m_securityPage) {
|
||||
delete m_securityPage;
|
||||
m_securityPage = nullptr;
|
||||
}
|
||||
if (m_connectOperation) {
|
||||
delete m_connectOperation;
|
||||
m_connectOperation = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void EnterpriseWlanDialog::initUI()
|
||||
{
|
||||
#define MAIN_LAYOUT_MARGINS 8,8,8,8
|
||||
#define SSID_LAYOUT_MARGINS 8,8,8,0
|
||||
#define MAIN_LAYOUT_SPACING 0
|
||||
#define BUTTON_SPACING 8
|
||||
#define CLOSE_BUTTON_SIZE 24,24
|
||||
|
||||
m_mainLayout = new QVBoxLayout(this);
|
||||
this->setLayout(m_mainLayout);
|
||||
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
|
||||
|
||||
m_titleLayout = new QHBoxLayout();
|
||||
m_titleLabel = new QLabel(this);
|
||||
m_titleLabel->setText(tr("Connect Enterprise WLAN"));
|
||||
m_closeBtn = new QPushButton(this);
|
||||
m_closeBtn->setFixedSize(CLOSE_BUTTON_SIZE);
|
||||
m_closeBtn->setToolTip(tr("Close"));
|
||||
m_closeBtn->setProperty("isWindowButton", 0x02);
|
||||
m_closeBtn->setProperty("useIconHighlightEffect", 0x08);
|
||||
m_closeBtn->setFlat(true);
|
||||
m_closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
|
||||
m_titleLayout->addWidget(m_titleLabel);
|
||||
m_titleLayout->addStretch();
|
||||
m_titleLayout->addWidget(m_closeBtn);
|
||||
|
||||
m_ssidLayout = new QHBoxLayout();
|
||||
m_ssidLayout->setContentsMargins(SSID_LAYOUT_MARGINS);
|
||||
m_ssidTitleLabel = new QLabel(this);
|
||||
m_ssidTitleLabel->setText("SSID");
|
||||
m_ssidLabel = new QLabel(this);
|
||||
if (m_data) {
|
||||
m_ssidLabel->setText(m_data->m_NetSsid);
|
||||
} else {
|
||||
qWarning() << "Get SSID failed because of null pointer!" << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
m_ssidLayout->addWidget(m_ssidTitleLabel);
|
||||
m_ssidLayout->addStretch();
|
||||
m_ssidLayout->addWidget(m_ssidLabel);
|
||||
|
||||
m_securityPage = new SecurityPage(this);
|
||||
m_securityPage->setSecurity(KySecuType::WPA_AND_WPA2_ENTERPRISE);
|
||||
m_securityPage->setSecurityVisible(false);
|
||||
|
||||
m_btnLayout = new QHBoxLayout();
|
||||
m_btnLayout->setSpacing(BUTTON_SPACING);
|
||||
m_cancelBtn = new QPushButton(this);
|
||||
m_connectBtn = new QPushButton(this);
|
||||
m_cancelBtn->setText(tr("Cancel"));
|
||||
m_connectBtn->setText(tr("Connect"));
|
||||
m_connectBtn->setEnabled(false);
|
||||
m_btnLayout->addStretch();
|
||||
m_btnLayout->addWidget(m_cancelBtn);
|
||||
m_btnLayout->addWidget(m_connectBtn);
|
||||
|
||||
m_mainLayout->addLayout(m_titleLayout);
|
||||
m_mainLayout->addLayout(m_ssidLayout);
|
||||
m_mainLayout->addWidget(m_securityPage);
|
||||
m_mainLayout->addLayout(m_btnLayout);
|
||||
m_mainLayout->addStretch();
|
||||
|
||||
this->setFixedSize(MAIN_SIZE_EXPAND);
|
||||
initConnections();
|
||||
}
|
||||
|
||||
void EnterpriseWlanDialog::centerToScreen()
|
||||
{
|
||||
QDesktopWidget* m = QApplication::desktop();
|
||||
QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
|
||||
int desk_x = desk_rect.width();
|
||||
int desk_y = desk_rect.height();
|
||||
int x = this->width();
|
||||
int y = this->height();
|
||||
this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
|
||||
}
|
||||
|
||||
void EnterpriseWlanDialog::initConnections()
|
||||
{
|
||||
connect(m_closeBtn, &QPushButton::clicked, this, &EnterpriseWlanDialog::close);
|
||||
connect(m_cancelBtn, &QPushButton::clicked, this, &EnterpriseWlanDialog::close);
|
||||
connect(m_connectBtn, &QPushButton::clicked, this, &EnterpriseWlanDialog::onBtnConnectClicked);
|
||||
connect(m_securityPage, &SecurityPage::eapTypeChanged, this, &EnterpriseWlanDialog::onEapTypeChanged);
|
||||
connect(m_securityPage, &SecurityPage::setSecuPageState, this, [ = ](bool status) {
|
||||
m_connectBtn->setEnabled(status);
|
||||
});
|
||||
}
|
||||
|
||||
void EnterpriseWlanDialog::initData()
|
||||
{
|
||||
if (m_data && m_data->m_isConfigured) {
|
||||
KyEapMethodType type;
|
||||
m_connectOperation->getEnterpiseEapMethod(m_data->m_connectUuid, type);
|
||||
if (type) {
|
||||
onEapTypeChanged(type);
|
||||
} else {
|
||||
qWarning() << "Get eap type failed!" << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EnterpriseWlanDialog::onBtnConnectClicked()
|
||||
{
|
||||
if (!m_data) {
|
||||
qWarning() << "Connect enterprise WLAN failed because of null pointer m_data!" << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
qDebug() << "Clicked connectBtn, will connect enterprise WLAN, ssid = " << m_data->m_NetSsid << "." << Q_FUNC_INFO << __LINE__;
|
||||
KySecuType secuType;
|
||||
KyEapMethodType eapType;
|
||||
m_securityPage->getSecuType(secuType, eapType);
|
||||
|
||||
KyWirelessConnectSetting connetSetting;
|
||||
connetSetting.setConnectName(m_data->m_NetSsid);
|
||||
connetSetting.setIfaceName(m_deviceName);
|
||||
connetSetting.isAutoConnect = true; //ZJP_TODO 自动连接选项
|
||||
connetSetting.m_type = KyKeyMgmt::WpaEap;
|
||||
connetSetting.m_ssid = m_data->m_NetSsid;
|
||||
connetSetting.m_secretFlag = 0;
|
||||
connetSetting.dumpInfo();
|
||||
|
||||
if (eapType == KyEapMethodType::TLS) {
|
||||
m_info.tlsInfo.devIfaceName = m_deviceName;
|
||||
m_securityPage->updateTlsChange(m_info.tlsInfo);
|
||||
m_connectOperation->addAndActiveWirelessEnterPriseTlsConnect(m_info.tlsInfo, connetSetting, m_deviceName, true);
|
||||
} else if (eapType == KyEapMethodType::PEAP) {
|
||||
m_securityPage->updatePeapChange(m_info.peapInfo);
|
||||
m_connectOperation->addAndActiveWirelessEnterPrisePeapConnect(m_info.peapInfo, connetSetting, m_deviceName, true);
|
||||
} else if (eapType == KyEapMethodType::TTLS) {
|
||||
m_securityPage->updateTtlsChange(m_info.ttlsInfo);
|
||||
m_connectOperation->addAndActiveWirelessEnterPriseTtlsConnect(m_info.ttlsInfo, connetSetting, m_deviceName, true);
|
||||
} else {
|
||||
qWarning() << "Connect enterprise wlan failed!(Unknown eap type)" << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
}
|
||||
|
||||
void EnterpriseWlanDialog::onEapTypeChanged(const KyEapMethodType &type)
|
||||
{
|
||||
switch (type) {
|
||||
case KyEapMethodType::TLS:
|
||||
if (m_data && !m_data->m_connectUuid.isEmpty()) {
|
||||
m_resource->getEnterPriseInfoTls(m_data->m_connectUuid, m_info.tlsInfo);
|
||||
m_securityPage->setTlsInfo(m_info.tlsInfo);
|
||||
}
|
||||
this->setFixedSize(MAIN_SIZE_EXPAND);
|
||||
break;
|
||||
case KyEapMethodType::PEAP:
|
||||
if (m_data && !m_data->m_connectUuid.isEmpty()) {
|
||||
m_resource->getEnterPriseInfoPeap(m_data->m_connectUuid, m_info.peapInfo);
|
||||
m_securityPage->setPeapInfo(m_info.peapInfo);
|
||||
}
|
||||
this->setFixedSize(MAIN_SIZE_NARROW);
|
||||
break;
|
||||
case KyEapMethodType::TTLS:
|
||||
if (m_data && !m_data->m_connectUuid.isEmpty()) {
|
||||
m_resource->getEnterPriseInfoTtls(m_data->m_connectUuid, m_info.ttlsInfo);
|
||||
m_securityPage->setTtlsInfo(m_info.ttlsInfo);
|
||||
}
|
||||
this->setFixedSize(MAIN_SIZE_NARROW);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
#ifndef ENTERPRISEWLANDIALOG_H
|
||||
#define ENTERPRISEWLANDIALOG_H
|
||||
#include <QDialog>
|
||||
#include <QPushButton>
|
||||
#include "securitypage.h"
|
||||
#include "kywirelessnetitem.h"
|
||||
#include "coninfo.h"
|
||||
|
||||
class EnterpriseWlanDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EnterpriseWlanDialog(KyWirelessNetItem *data, QString device, QWidget *parent = nullptr);
|
||||
~EnterpriseWlanDialog();
|
||||
|
||||
private:
|
||||
void initUI(); //初始化UI界面
|
||||
void centerToScreen();
|
||||
void initConnections();
|
||||
void initData();
|
||||
|
||||
private:
|
||||
KyWirelessNetItem *m_data = nullptr;
|
||||
ConInfo m_info;
|
||||
QString m_deviceName;
|
||||
KyWirelessConnectOperation *m_connectOperation = nullptr;
|
||||
KyWirelessNetResource *m_resource = nullptr;
|
||||
|
||||
/* 弹窗布局
|
||||
* Connect Enterprise WLAN············X
|
||||
* SSID··························[SSID]
|
||||
* -----------SecurityPage-------------
|
||||
* | |
|
||||
* ------------------------------------
|
||||
* ····················CANCEL···CONNECT
|
||||
*/
|
||||
QVBoxLayout *m_mainLayout = nullptr;
|
||||
|
||||
QHBoxLayout *m_titleLayout = nullptr;
|
||||
QLabel *m_titleLabel = nullptr;
|
||||
QPushButton *m_closeBtn = nullptr;
|
||||
|
||||
QHBoxLayout *m_ssidLayout = nullptr;
|
||||
QLabel *m_ssidTitleLabel = nullptr;
|
||||
QLabel *m_ssidLabel = nullptr;
|
||||
|
||||
SecurityPage *m_securityPage = nullptr;
|
||||
|
||||
QHBoxLayout *m_btnLayout = nullptr;
|
||||
QPushButton *m_cancelBtn = nullptr;
|
||||
QPushButton *m_connectBtn = nullptr;
|
||||
|
||||
private slots:
|
||||
void onBtnConnectClicked();
|
||||
void onEapTypeChanged(const KyEapMethodType &type);
|
||||
};
|
||||
|
||||
#endif // ENTERPRISEWLANDIALOG_H
|
|
@ -4,7 +4,8 @@ include(wireless-security/wireless-security.pri)
|
|||
include(xatom/xatom.pri)
|
||||
include(tab-pages/tab-pages.pri)
|
||||
include(list-items/list-items.pri)
|
||||
include(netdetails.pri)
|
||||
include(netdetails/netdetails.pri)
|
||||
include(enterprise-wlan/enterprise-wlan.pri)
|
||||
|
||||
FORMS += \
|
||||
$$PWD/confform.ui \
|
||||
|
|
|
@ -23,7 +23,6 @@ public:
|
|||
KyNetworkDeviceResourse *m_deviceResource = nullptr;
|
||||
|
||||
QString deviceName = "";
|
||||
void refreshIcon();
|
||||
|
||||
protected:
|
||||
void setIcon(bool isOn);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "wlanlistitem.h"
|
||||
#include <QResizeEvent>
|
||||
#include "enterprisewlandialog.h"
|
||||
|
||||
WlanListItem::WlanListItem(KyWirelessNetResource *resource, KyWirelessNetItem *data, QString device, QWidget *parent) : ListItem(parent)
|
||||
{
|
||||
|
@ -36,6 +37,9 @@ WlanListItem::~WlanListItem()
|
|||
|
||||
void WlanListItem::setWlanSignal(const int &signal)
|
||||
{
|
||||
if (!m_data){
|
||||
return;
|
||||
}
|
||||
m_data->m_signalStrength = signal;
|
||||
refreshIcon();
|
||||
}
|
||||
|
@ -266,18 +270,23 @@ void WlanListItem::onNetButtonClicked()
|
|||
|
||||
//执行连接或断开
|
||||
if (m_isActive) {
|
||||
m_connoperation->deActivateWirelessConnection(m_wlanDevice,m_data->m_connectUuid);
|
||||
m_connoperation->deActivateWirelessConnection(m_wlanDevice, m_data->m_connectUuid);
|
||||
qDebug()<<"Clicked on connected wifi, it will be inactivated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__;
|
||||
return;
|
||||
}
|
||||
//有配置或者无密码的wifi直接连接
|
||||
if (m_data->m_isConfigured || m_hasPwd == false) {
|
||||
m_connoperation->activeWirelessConnect(m_wlanDevice,m_data->m_connectUuid);
|
||||
m_connoperation->activeWirelessConnect(m_wlanDevice, m_data->m_connectUuid);
|
||||
qDebug()<<"Has configuration, will be activated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__;
|
||||
return;
|
||||
}
|
||||
if (!this->m_connectButton->isVisible() && m_data->m_secuType != "") {
|
||||
this->setExpanded(true);
|
||||
if (m_data->m_secuType.contains("802.1x", Qt::CaseInsensitive)) {
|
||||
EnterpriseWlanDialog *enterpriseWlanDialog = new EnterpriseWlanDialog(m_data, m_wlanDevice, this);
|
||||
enterpriseWlanDialog->show();
|
||||
} else {
|
||||
this->setExpanded(true);
|
||||
}
|
||||
} else {
|
||||
onConnectButtonClicked();
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
HEADERS += \
|
||||
$$PWD/netdetails/coninfo.h \
|
||||
$$PWD/netdetails/creatnetpage.h \
|
||||
$$PWD/netdetails/customtabstyle.h \
|
||||
$$PWD/netdetails/detailpage.h \
|
||||
$$PWD/netdetails/ipv4page.h \
|
||||
$$PWD/netdetails/ipv6page.h \
|
||||
$$PWD/netdetails/netdetail.h \
|
||||
$$PWD/netdetails/securitypage.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/netdetails/creatnetpage.cpp \
|
||||
$$PWD/netdetails/customtabstyle.cpp \
|
||||
$$PWD/netdetails/detailpage.cpp \
|
||||
$$PWD/netdetails/ipv4page.cpp \
|
||||
$$PWD/netdetails/ipv6page.cpp \
|
||||
$$PWD/netdetails/netdetail.cpp \
|
||||
$$PWD/netdetails/securitypage.cpp
|
|
@ -1,6 +1,7 @@
|
|||
#include "netdetail.h"
|
||||
#include "backend/kylinipv4arping.h"
|
||||
#include "backend/kylinipv6arping.h"
|
||||
#include "xatom/xatom-helper.h"
|
||||
|
||||
#define WINDOW_WIDTH 540
|
||||
#define WINDOW_HEIGHT 574
|
||||
|
@ -17,7 +18,25 @@
|
|||
#define CREATE_NET_PAGE_NUM 4
|
||||
#define PAGE_MIN_HEIGHT 40
|
||||
|
||||
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
||||
//extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
||||
|
||||
void NetDetail::showDesktopNotify(const QString &message)
|
||||
{
|
||||
QDBusInterface iface("org.freedesktop.Notifications",
|
||||
"/org/freedesktop/Notifications",
|
||||
"org.freedesktop.Notifications",
|
||||
QDBusConnection::sessionBus());
|
||||
QList<QVariant> args;
|
||||
args<<(tr("Kylin NM"))
|
||||
<<((unsigned int) 0)
|
||||
<<QString("/usr/share/icons/ukui-icon-theme-default/24x24/devices/gnome-dev-ethernet.png")
|
||||
<<tr("kylin network desktop message") //显示的是什么类型的信息
|
||||
<<message //显示的具体信息
|
||||
<<QStringList()
|
||||
<<QVariantMap()
|
||||
<<(int)-1;
|
||||
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
|
||||
}
|
||||
|
||||
NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent)
|
||||
:m_deviceName(interface),
|
||||
|
@ -28,8 +47,19 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv
|
|||
isCreateNet(isCreateNet),
|
||||
QDialog(parent)
|
||||
{
|
||||
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint );
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
//设置窗口无边框,阴影
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||
MotifWmHints window_hints;
|
||||
window_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
||||
window_hints.functions = MWM_FUNC_ALL;
|
||||
window_hints.decorations = MWM_DECOR_BORDER;
|
||||
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), window_hints);
|
||||
#else
|
||||
this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
|
||||
#endif
|
||||
// this->setProperty("useStyleWindowManager", false); //禁用拖动
|
||||
// setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint );
|
||||
// setAttribute(Qt::WA_TranslucentBackground);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setFixedSize(WINDOW_WIDTH,WINDOW_HEIGHT);
|
||||
centerToScreen();
|
||||
|
@ -62,6 +92,11 @@ NetDetail::~NetDetail()
|
|||
|
||||
}
|
||||
|
||||
void NetDetail::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
return QDialog::paintEvent(event);
|
||||
}
|
||||
|
||||
void NetDetail::centerToScreen()
|
||||
{
|
||||
QDesktopWidget* m = QApplication::desktop();
|
||||
|
@ -554,6 +589,7 @@ void NetDetail::setConfirmEnable()
|
|||
|
||||
bool NetDetail::checkIpv4Conflict(QString ipv4Address)
|
||||
{
|
||||
showDesktopNotify(tr("start check ipv4 address conflict"));
|
||||
bool isConflict = false;
|
||||
KyIpv4Arping* ipv4Arping = new KyIpv4Arping(m_deviceName, ipv4Address);
|
||||
|
||||
|
@ -570,6 +606,7 @@ bool NetDetail::checkIpv4Conflict(QString ipv4Address)
|
|||
|
||||
bool NetDetail::checkIpv6Conflict(QString ipv6address)
|
||||
{
|
||||
showDesktopNotify(tr("start check ipv6 address conflict"));
|
||||
bool isConflict = false;
|
||||
KyIpv6Arping* ipv46rping = new KyIpv6Arping(m_deviceName, ipv6address);
|
||||
|
||||
|
@ -607,50 +644,6 @@ void NetDetail::updateWirelessEnterPriseConnect(KyEapMethodType enterpriseType)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void NetDetail::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
QPainterPath rectPath;
|
||||
rectPath.addRoundedRect(this->rect().adjusted(12, 12, -12, -12), 12, 12);
|
||||
|
||||
// 画一个黑底
|
||||
QPixmap pixmap(this->rect().size());
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter pixmapPainter(&pixmap);
|
||||
pixmapPainter.setRenderHint(QPainter::Antialiasing);
|
||||
pixmapPainter.setPen(Qt::transparent);
|
||||
pixmapPainter.setBrush(Qt::black);
|
||||
pixmapPainter.setOpacity(0.65);
|
||||
pixmapPainter.drawPath(rectPath);
|
||||
pixmapPainter.end();
|
||||
|
||||
// 模糊这个黑底
|
||||
QImage img = pixmap.toImage();
|
||||
qt_blurImage(img, 10, false, false);
|
||||
|
||||
// 挖掉中心
|
||||
pixmap = QPixmap::fromImage(img);
|
||||
QPainter pixmapPainter2(&pixmap);
|
||||
pixmapPainter2.setRenderHint(QPainter::Antialiasing);
|
||||
pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear);
|
||||
pixmapPainter2.setPen(Qt::transparent);
|
||||
pixmapPainter2.setBrush(Qt::transparent);
|
||||
pixmapPainter2.drawPath(rectPath);
|
||||
|
||||
// 绘制阴影
|
||||
p.drawPixmap(this->rect(), pixmap, pixmap.rect());
|
||||
|
||||
// 绘制一个背景
|
||||
p.save();
|
||||
p.fillPath(rectPath, palette().color(QPalette::Base));
|
||||
p.restore();
|
||||
}
|
||||
|
||||
bool NetDetail::createWiredConnect()
|
||||
{
|
||||
KyWirelessConnectSetting connetSetting;
|
||||
|
@ -659,7 +652,7 @@ bool NetDetail::createWiredConnect()
|
|||
if (connetSetting.m_ipv4ConfigIpType != CONFIG_IP_DHCP) {
|
||||
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
||||
qDebug() << "ipv4 conflict";
|
||||
//todo desktop notify
|
||||
showDesktopNotify(tr("ipv4 address conflict!"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -682,7 +675,9 @@ bool NetDetail::createWirelessConnect()
|
|||
}
|
||||
qDebug() << "isAutoConnect" << connetSetting.isAutoConnect;
|
||||
connetSetting.m_ssid = ssid;
|
||||
connetSetting.m_secretFlag = NetworkManager::Setting::None;
|
||||
// connetSetting.m_secretFlag = NetworkManager::Setting::None;
|
||||
//由于X.h的None与此处的None有歧义,此处直接使用值
|
||||
connetSetting.m_secretFlag = 0;
|
||||
|
||||
//ipv4 & ipv6
|
||||
bool ipv4Change = ipv4Page->checkIsChanged(m_info, connetSetting);
|
||||
|
@ -694,7 +689,7 @@ bool NetDetail::createWirelessConnect()
|
|||
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
||||
qDebug() << "ipv4 conflict";
|
||||
//todo desktop notify
|
||||
showDesktopNotify(tr("ipv4 address conflict!"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -702,7 +697,7 @@ bool NetDetail::createWirelessConnect()
|
|||
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
|
||||
qDebug() << "ipv6 conflict";
|
||||
//todo desktop notify
|
||||
showDesktopNotify(tr("ipv6 address conflict!"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -711,7 +706,7 @@ bool NetDetail::createWirelessConnect()
|
|||
KyEapMethodType enterpriseType;
|
||||
securityPage->getSecuType(secuType, enterpriseType);
|
||||
if (secuType == WPA_AND_WPA2_ENTERPRISE) {
|
||||
connetSetting.m_type = SAE;
|
||||
connetSetting.m_type = WpaEap;
|
||||
if (enterpriseType == TLS) {
|
||||
m_info.tlsInfo.devIfaceName = m_deviceName;
|
||||
securityPage->updateTlsChange(m_info.tlsInfo);
|
||||
|
@ -772,7 +767,7 @@ bool NetDetail::updateConnect()
|
|||
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
||||
qDebug() << "ipv4 conflict";
|
||||
//todo desktop notify
|
||||
showDesktopNotify(tr("ipv4 address conflict!"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -780,7 +775,7 @@ bool NetDetail::updateConnect()
|
|||
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
|
||||
qDebug() << "ipv6 conflict";
|
||||
//todo desktop notify
|
||||
showDesktopNotify(tr("ipv6 address conflict!"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@ private:
|
|||
bool createWiredConnect();
|
||||
bool createWirelessConnect();
|
||||
bool updateConnect();
|
||||
|
||||
void showDesktopNotify(const QString &message);
|
||||
private:
|
||||
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
|
||||
KyConnectOperation* m_connectOperation = nullptr;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/coninfo.h \
|
||||
$$PWD/creatnetpage.h \
|
||||
$$PWD/customtabstyle.h \
|
||||
$$PWD/detailpage.h \
|
||||
$$PWD/ipv4page.h \
|
||||
$$PWD/ipv6page.h \
|
||||
$$PWD/netdetail.h \
|
||||
$$PWD/securitypage.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/creatnetpage.cpp \
|
||||
$$PWD/customtabstyle.cpp \
|
||||
$$PWD/detailpage.cpp \
|
||||
$$PWD/ipv4page.cpp \
|
||||
$$PWD/ipv6page.cpp \
|
||||
$$PWD/netdetail.cpp \
|
||||
$$PWD/securitypage.cpp
|
|
@ -288,6 +288,20 @@ void SecurityPage::setTtlsInfo(KyEapMethodTtlsInfo &info)
|
|||
}
|
||||
}
|
||||
|
||||
void SecurityPage::setSecurityVisible(const bool &visible)
|
||||
{
|
||||
if (secuTypeLabel) {
|
||||
secuTypeLabel->setVisible(visible);
|
||||
} else {
|
||||
qWarning() << "Set visible of secuTypeLabel failed because of null pointer" << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
if (secuTypeCombox) {
|
||||
secuTypeCombox->setVisible(visible);
|
||||
} else {
|
||||
qWarning() << "Set visible of secuTypeCombox failed because of null pointer" << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityPage::updateTlsChange(KyEapMethodTlsInfo &info)
|
||||
{
|
||||
KyEapMethodTlsInfo tlsInfo = assembleTlsInfo();
|
||||
|
@ -630,12 +644,14 @@ void SecurityPage::onEapTypeComboxIndexChanged()
|
|||
int index = eapTypeCombox->currentData().toInt();
|
||||
if (index == TLS) {
|
||||
showTls();
|
||||
emit this->eapTypeChanged(TLS);
|
||||
} else if (index == PEAP) {
|
||||
showPeapOrTtls();
|
||||
eapMethodCombox->clear();
|
||||
eapMethodCombox->addItem("MSCHAPv2", KyAuthMethodMschapv2);
|
||||
eapMethodCombox->addItem("MD5", KyAuthMethodMd5);
|
||||
eapMethodCombox->addItem("GTC", KyAuthMethodGtc);
|
||||
emit this->eapTypeChanged(PEAP);
|
||||
} else if (index == TTLS) {
|
||||
showPeapOrTtls();
|
||||
eapMethodCombox->clear();
|
||||
|
@ -646,6 +662,7 @@ void SecurityPage::onEapTypeComboxIndexChanged()
|
|||
eapMethodCombox->addItem("chap", CHAP);
|
||||
eapMethodCombox->addItem("md5(eap)", MD5_EAP);
|
||||
eapMethodCombox->addItem("gtc(eap)", GTC_EAP);
|
||||
emit this->eapTypeChanged(TTLS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
void setTlsInfo(KyEapMethodTlsInfo &info);
|
||||
void setPeapInfo(KyEapMethodPeapInfo &info);
|
||||
void setTtlsInfo(KyEapMethodTtlsInfo &info);
|
||||
void setSecurityVisible(const bool &visible);
|
||||
|
||||
bool checkIsChanged(const ConInfo info);
|
||||
void updateSecurityChange(KyWirelessConnectSetting &setting);
|
||||
|
@ -107,6 +108,7 @@ private slots:
|
|||
|
||||
signals:
|
||||
void setSecuPageState(bool);
|
||||
void eapTypeChanged(const KyEapMethodType &type);
|
||||
};
|
||||
|
||||
#endif // SECURITYWIDGET_H
|
||||
|
|
|
@ -94,15 +94,15 @@ void MainWindow::secondaryStart()
|
|||
*/
|
||||
void MainWindow::initWindowProperties()
|
||||
{
|
||||
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
this->setWindowTitle(tr("kylin-nm"));
|
||||
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")));
|
||||
//绘制毛玻璃特效
|
||||
this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT);
|
||||
QPainterPath path;
|
||||
auto rect = this->rect();
|
||||
path.addRoundedRect(rect, 6, 6);
|
||||
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
|
||||
// //绘制毛玻璃特效
|
||||
// this->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
// QPainterPath path;
|
||||
// auto rect = this->rect();
|
||||
// path.addRoundedRect(rect, 6, 6);
|
||||
// KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -270,7 +270,7 @@ void MainWindow::initWindowTheme()
|
|||
const QByteArray style_id(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(style_id)) {
|
||||
m_styleGsettings = new QGSettings(style_id);
|
||||
resetWindowTheme();
|
||||
// resetWindowTheme();
|
||||
connect(m_styleGsettings, &QGSettings::changed, this, &MainWindow::onThemeChanged);
|
||||
} else {
|
||||
qWarning() << "Gsettings interface \"org.ukui.style\" is not exist!" << Q_FUNC_INFO << __LINE__;
|
||||
|
@ -292,7 +292,7 @@ void MainWindow::resetWindowTheme()
|
|||
return;
|
||||
}
|
||||
app->setStyle(new CustomStyle("ukui-light"));
|
||||
qDebug() << "Has set color theme to ukui-light." << Q_FUNC_INFO << __LINE__;
|
||||
qDebug() << "Has set color theme to " << currentTheme << Q_FUNC_INFO << __LINE__;
|
||||
emit qApp->paletteChanged(qApp->palette());
|
||||
return;
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ void MainWindow::resetWindowTheme()
|
|||
void MainWindow::showControlCenter()
|
||||
{
|
||||
QProcess process;
|
||||
if (m_lanWidget->m_isLanConnected == false && m_wlanWidget->wlanIsConnected == true){
|
||||
if (m_lanWidget->m_isLanConnected == false && m_wlanWidget->m_wlanIsConnected == true){
|
||||
process.startDetached("ukui-control-center --wlanconnect");
|
||||
} else {
|
||||
process.startDetached("ukui-control-center --wiredconnect");
|
||||
|
@ -338,7 +338,8 @@ void MainWindow::onThemeChanged(const QString &key)
|
|||
{
|
||||
if (key == COLOR_THEME) {
|
||||
qDebug() << "Received signal of theme changed, will reset theme." << Q_FUNC_INFO << __LINE__;
|
||||
resetWindowTheme();
|
||||
// resetWindowTheme();
|
||||
emit qApp->paletteChanged(qApp->palette());
|
||||
} else {
|
||||
qDebug() << "Received signal of theme changed, key=" << key << " will do nothing." << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
|
@ -349,9 +350,9 @@ void MainWindow::onRefreshTrayIcon()
|
|||
//更新托盘图标显示
|
||||
if (m_lanWidget->m_isLanConnected == true){
|
||||
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
|
||||
} else if (m_wlanWidget->wlanIsConnected == true && m_lanWidget->m_isLanConnected == false){
|
||||
} else if (m_wlanWidget->m_wlanIsConnected == true && m_lanWidget->m_isLanConnected == false){
|
||||
m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic"));
|
||||
} else if (m_wlanWidget->wlanIsConnected == false && m_lanWidget->m_isLanConnected == false){
|
||||
} else if (m_wlanWidget->m_wlanIsConnected == false && m_lanWidget->m_isLanConnected == false){
|
||||
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -604,6 +604,12 @@ void LanPage::onDeviceComboxIndexChanged(int currentIndex)
|
|||
initLanArea();
|
||||
}
|
||||
|
||||
void LanPage::onShowControlCenter()
|
||||
{
|
||||
QProcess process;
|
||||
process.startDetached("ukui-control-center --wiredconnect");
|
||||
}
|
||||
|
||||
void LanPage::initUI()
|
||||
{
|
||||
m_titleLabel->setText(tr("LAN"));
|
||||
|
@ -635,6 +641,7 @@ void LanPage::initUI()
|
|||
// m_inactivatedLanListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //用了listwidget的滚动条
|
||||
|
||||
inactiveLanListLayout->addWidget(m_inactivatedLanListWidget);
|
||||
m_settingsLabel->installEventFilter(this);
|
||||
// emit this->lanConnectChanged();
|
||||
}
|
||||
|
||||
|
@ -686,7 +693,6 @@ void LanPage::updateActivatedConnectionArea(QString uuid)
|
|||
qDebug()<<"[LanPage]update active connection item"<<p_newItem->m_connectName;
|
||||
QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_activatedLanListWidget);
|
||||
m_activeMap.insert(p_newItem, p_listWidgetItem);
|
||||
|
||||
} else {
|
||||
//释放内存
|
||||
delete p_newItem;
|
||||
|
@ -715,6 +721,7 @@ void LanPage::updateConnectionArea(QString uuid)
|
|||
addEmptyConnectItem(m_activeMap, m_activatedLanListWidget);
|
||||
}
|
||||
|
||||
|
||||
if (connectionItemIsExist(m_deactiveMap, uuid)) {
|
||||
delete p_newItem;
|
||||
p_newItem = nullptr;
|
||||
|
@ -811,7 +818,7 @@ void LanPage::updateConnectionProperty(KyConnectItem *p_connectItem)
|
|||
KyConnectItem *p_item = iter.key();
|
||||
if (p_item->m_connectUuid == p_connectItem->m_connectUuid) {
|
||||
if (p_connectItem->m_ifaceName != ""
|
||||
&& m_currentDeviceName != p_connectItem->m_ifaceName) { //当前未激活连接的设备改变
|
||||
&& m_currentDeviceName != p_connectItem->m_ifaceName) {
|
||||
LanListItem *p_lanItem = (LanListItem *)m_inactivatedLanListWidget->itemWidget(iter.value());
|
||||
|
||||
m_inactivatedLanListWidget->removeItemWidget(iter.value());
|
||||
|
@ -826,7 +833,7 @@ void LanPage::updateConnectionProperty(KyConnectItem *p_connectItem)
|
|||
p_item = nullptr;
|
||||
} else {
|
||||
if (p_connectItem->m_connectName != p_item->m_connectName
|
||||
|| p_connectItem->m_connectPath != p_item->m_connectPath) { //当前未激活连接的其他数据改变(除了激活状态外)
|
||||
|| p_connectItem->m_connectPath != p_item->m_connectPath) {
|
||||
LanListItem *p_lanItem = (LanListItem *)m_inactivatedLanListWidget->itemWidget(iter.value());
|
||||
|
||||
m_inactivatedLanListWidget->removeItemWidget(iter.value());
|
||||
|
@ -912,7 +919,7 @@ void LanPage::onUpdateConnection(QString uuid)
|
|||
p_newItem = m_activeResourse->getActiveConnectionByUuid(uuid);
|
||||
if (nullptr == p_newItem) {
|
||||
qWarning()<<"[LanPage] get item failed, when update activate connection."
|
||||
<<"connection uuid"<<uuid;
|
||||
<<"connection uuid" << uuid;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -952,10 +959,21 @@ void LanPage::setWiredDeviceEnable(const QString& devName, bool enable)
|
|||
initDeviceCombox();
|
||||
}
|
||||
|
||||
bool LanPage::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == m_settingsLabel) {
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
onShowControlCenter();
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void LanPage::activateWired(const QString& devName, const QString& connUuid)
|
||||
{
|
||||
qDebug() << "[LanPage] activateWired" << devName << connUuid;
|
||||
m_wiredConnectOperation->activateConnection(connUuid, devName);
|
||||
emit this->lanConnectChanged();
|
||||
}
|
||||
|
||||
void LanPage::deactivateWired(const QString& devName, const QString& connUuid)
|
||||
|
@ -991,3 +1009,4 @@ void LanPage::showDetailPage(QString devName, QString uuid)
|
|||
delete p_item;
|
||||
p_item = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@ public:
|
|||
void showDetailPage(QString devName, QString uuid);
|
||||
void setWiredDeviceEnable(const QString& devName, bool enable);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
void initDeviceState();
|
||||
void initUI();
|
||||
|
@ -91,6 +94,8 @@ private slots:
|
|||
|
||||
void onDeviceComboxIndexChanged(int currentIndex);
|
||||
|
||||
void onShowControlCenter();
|
||||
|
||||
private:
|
||||
QListWidget * m_activatedLanListWidget = nullptr;
|
||||
QListWidget * m_inactivatedLanListWidget = nullptr;
|
||||
|
|
|
@ -62,7 +62,7 @@ void TabPage::initUI()
|
|||
m_activatedNetDivider = new Divider(this);
|
||||
|
||||
m_inactivatedNetFrame = new QFrame(this);
|
||||
// m_inactivatedNetFrame->setMinimumHeight(INACTIVE_AREA_MIN_HEIGHT);
|
||||
m_inactivatedNetFrame->setMinimumHeight(INACTIVE_AREA_MIN_HEIGHT);
|
||||
m_inactivatedNetLayout = new QVBoxLayout(m_inactivatedNetFrame);
|
||||
m_inactivatedNetLayout->setContentsMargins(NET_LAYOUT_MARGINS);
|
||||
m_inactivatedNetLayout->setSpacing(NET_LAYOUT_SPACING);
|
||||
|
@ -81,6 +81,7 @@ void TabPage::initUI()
|
|||
m_settingsLayout = new QHBoxLayout(m_settingsFrame);
|
||||
m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS);
|
||||
m_settingsLabel = new QLabel(m_settingsFrame);
|
||||
m_settingsLabel->setCursor(Qt::PointingHandCursor);
|
||||
m_settingsLabel->setText(tr("Settings"));
|
||||
m_settingsLayout->addWidget(m_settingsLabel);
|
||||
m_settingsFrame->setLayout(m_settingsLayout);
|
||||
|
|
|
@ -35,7 +35,6 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
|
|||
connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::deactivateConnectionError, this, &WlanPage::deactivateFailed);
|
||||
|
||||
connect(this, &WlanPage::hiddenWlanClicked, this, &WlanPage::onHiddenWlanClicked);
|
||||
connect(this, &WlanPage::settingsClicked, this, &WlanPage::showControlCenter);
|
||||
connect(m_wirelessConnectOpreation, &KyWirelessConnectOperation::wifinEnabledChanged, this, &WlanPage::onWifiEnabledChanged);
|
||||
}
|
||||
|
||||
|
@ -52,7 +51,7 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e)
|
|||
emit this->hiddenWlanClicked();
|
||||
} else if (w == m_settingsLabel) {
|
||||
//ZJP_TODO 打开控制面板
|
||||
emit this->settingsClicked();
|
||||
showControlCenter();
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(w,e);
|
||||
|
@ -111,7 +110,14 @@ void WlanPage::initWlanUI()
|
|||
void WlanPage::initConnections()
|
||||
{
|
||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::onWlanAdded);
|
||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, [=](QString interface, KyWirelessNetItem &item){
|
||||
//for dbus
|
||||
QStringList info;
|
||||
info <<item.m_NetSsid<<QString::number(item.m_signalStrength)<<item.m_secuType;
|
||||
emit wlanAdd(interface, info);
|
||||
});
|
||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved);
|
||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::wlanRemove);
|
||||
connect(m_resource, &KyWirelessNetResource::signalStrengthChange, this, &WlanPage::signalStrengthChange);
|
||||
connect(m_resource, &KyWirelessNetResource::secuTypeChange, this, &WlanPage::secuTypeChange);
|
||||
|
||||
|
@ -143,7 +149,9 @@ void WlanPage::initConnections()
|
|||
void WlanPage::initTimer()
|
||||
{
|
||||
m_scanTimer = new QTimer(this);
|
||||
m_refreshIconTimer = new QTimer(this);
|
||||
connect(m_scanTimer, &QTimer::timeout, this, &WlanPage::requestScan);
|
||||
connect(m_refreshIconTimer, &QTimer::timeout, this, &WlanPage::onRefreshIconTimer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,6 +189,9 @@ void WlanPage::initDeviceCombox()
|
|||
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &WlanPage::onDeviceComboxIndexChanged);
|
||||
if (m_devList.length() <= 1) {
|
||||
m_deviceFrame->hide();
|
||||
foreach (QString device, m_devList) {
|
||||
m_deviceComboBox->addItem(device, device);
|
||||
}
|
||||
} else {
|
||||
m_deviceFrame->show();
|
||||
foreach (QString device, m_devList) {
|
||||
|
@ -279,14 +290,14 @@ void WlanPage::getAllWlan()
|
|||
if (itemData.m_NetSsid == this->m_activatedWlanSSid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KyWirelessNetItem *data = new KyWirelessNetItem(itemData);
|
||||
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, m_defaultDevice);
|
||||
QListWidgetItem *wlanItem = new QListWidgetItem(m_inactivatedNetListWidget);
|
||||
qDebug() << itemData.m_NetSsid << itemData.m_isConfigured;
|
||||
connect(wlanItemWidget, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
|
||||
connect(wlanItemWidget, &WlanListItem::connectButtonClicked, this, &WlanPage::onConnectButtonClicked);
|
||||
m_itemsMap.insert(data->m_NetSsid, wlanItem);
|
||||
QPair<QListWidgetItem*,WlanListItem*> pair (wlanItem, wlanItemWidget);
|
||||
m_itemsMap.insert(data->m_NetSsid, pair);
|
||||
wlanItem->setSizeHint(QSize(m_inactivatedNetListWidget->width(), wlanItemWidget->height()));
|
||||
m_inactivatedNetListWidget->addItem(wlanItem);
|
||||
m_inactivatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget);
|
||||
|
@ -302,10 +313,6 @@ void WlanPage::getAllWlan()
|
|||
|
||||
void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
|
||||
{
|
||||
//for dbus
|
||||
QStringList info;
|
||||
info <<item.m_NetSsid<<QString::number(item.m_signalStrength)<<item.m_secuType;
|
||||
emit wlanAdd(interface, info);
|
||||
qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << Q_FUNC_INFO <<__LINE__;
|
||||
if (interface != m_defaultDevice) {
|
||||
qDebug() << "wlan add interface not equal defaultdevice,ignore";
|
||||
|
@ -321,21 +328,20 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
|
|||
m_inactivatedNetListWidget->addItem(wlanItem); //ZJP_TODO 目前会添加到列表尾部
|
||||
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() + wlanItemWidget->height() + NET_LIST_SPACING);
|
||||
m_inactivatedWlanListAreaCentralWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_hiddenWlanLabel->height());
|
||||
|
||||
m_itemsMap.insert(data->m_NetSsid, wlanItem);
|
||||
QPair<QListWidgetItem*,WlanListItem*> pair (wlanItem, wlanItemWidget);
|
||||
m_itemsMap.insert(data->m_NetSsid, pair);
|
||||
}
|
||||
|
||||
void WlanPage::onWlanRemoved(QString interface, QString ssid)
|
||||
{
|
||||
emit wlanRemove(interface, ssid);
|
||||
if (!m_itemsMap.contains(ssid)) { return; }
|
||||
if (m_expandedItem == m_itemsMap.value(ssid)) { m_expandedItem = nullptr; }
|
||||
if (m_expandedItem == (m_itemsMap.value(ssid)).first) { m_expandedItem = nullptr; }
|
||||
qDebug() << "A Wlan Removed! interface = " << interface << "; ssid = " << ssid << Q_FUNC_INFO <<__LINE__;
|
||||
if (interface != m_defaultDevice) {
|
||||
qDebug() << "wlan remove interface not equal defaultdevice,ignore";
|
||||
}
|
||||
int height = m_inactivatedNetListWidget->itemWidget(m_itemsMap.value(ssid))->height();
|
||||
m_inactivatedNetListWidget->takeItem(m_inactivatedNetListWidget->row(m_itemsMap.value(ssid)));
|
||||
int height = m_inactivatedNetListWidget->itemWidget((m_itemsMap.value(ssid)).first)->height();
|
||||
m_inactivatedNetListWidget->takeItem(m_inactivatedNetListWidget->row((m_itemsMap.value(ssid)).first));
|
||||
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() - height - NET_LIST_SPACING);
|
||||
m_inactivatedWlanListAreaCentralWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_hiddenWlanLabel->height());
|
||||
m_itemsMap.remove(ssid);
|
||||
|
@ -444,11 +450,11 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
|
|||
}
|
||||
}
|
||||
if(NetworkManager::ActiveConnection::State::Activated == state){
|
||||
wlanIsConnected = true;
|
||||
qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
|
||||
m_wlanIsConnected = true;
|
||||
qDebug() << "[wlanpage] wlanIsConnected status : " << m_wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
|
||||
} else {
|
||||
wlanIsConnected = false;
|
||||
qDebug() << "[wlanpage] wlanIsConnected status : " << wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
|
||||
m_wlanIsConnected = false;
|
||||
qDebug() << "[wlanpage] wlanIsConnected status : " << m_wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
|
||||
}
|
||||
|
||||
//弹窗显示wifi连接状况
|
||||
|
@ -552,7 +558,7 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
|
|||
void WlanPage::onItemHeightChanged(const QString &ssid)
|
||||
{
|
||||
if (!m_itemsMap.contains(ssid)) { return; }
|
||||
QListWidgetItem *item = m_itemsMap.value(ssid);
|
||||
QListWidgetItem *item = (m_itemsMap.value(ssid)).first;
|
||||
|
||||
if (m_expandedItem && m_expandedItem != item) {
|
||||
QSize size(m_inactivatedNetListWidget->itemWidget(m_expandedItem)->size().width(), NORMAL_HEIGHT);
|
||||
|
@ -644,9 +650,9 @@ void WlanPage::onWifiEnabledChanged(bool isWifiOn)
|
|||
qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__;
|
||||
return;
|
||||
}
|
||||
if(m_netSwitch->getSwitchStatus() == isWifiOn){
|
||||
if (m_netSwitch->getSwitchStatus() == isWifiOn) {
|
||||
return;
|
||||
}else{
|
||||
} else {
|
||||
//m_wirelessConnectOpreation->setWirelessEnabled(isWifiOn);
|
||||
m_netSwitch->setSwitchStatus(isWifiOn);
|
||||
//外部命令导致连接状态发生变化,通知主界面刷新图标
|
||||
|
@ -654,6 +660,28 @@ void WlanPage::onWifiEnabledChanged(bool isWifiOn)
|
|||
}
|
||||
}
|
||||
|
||||
void WlanPage::onRefreshIconTimer()
|
||||
{
|
||||
//wifi页面打开时,每隔5s主动获取wifi信号强度对图标进行更新
|
||||
qDebug() << "refresh wifi icon" << Q_FUNC_INFO << __LINE__;
|
||||
QList<KyWirelessNetItem> wlanList;
|
||||
if (!m_resource->getDeviceWifiNetwork(m_defaultDevice, wlanList)) {
|
||||
return;
|
||||
}
|
||||
foreach (auto itemData, wlanList) {
|
||||
qDebug() << "pair" << itemData.m_NetSsid << m_itemsMap.value(itemData.m_NetSsid) << "refresh wifi icon secsess"<< Q_FUNC_INFO << __LINE__;
|
||||
WlanListItem *wlanListItem = nullptr;
|
||||
wlanListItem = (m_itemsMap.value(itemData.m_NetSsid)).second;
|
||||
if (wlanListItem) {
|
||||
qDebug() << "refresh wifi icon secsess"<< Q_FUNC_INFO << __LINE__;
|
||||
wlanListItem->setWlanSignal(itemData.m_signalStrength);
|
||||
} else {
|
||||
qWarning() << "Set wifi signal failed because of null pointer wlanListItem!" << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//for dbus
|
||||
void WlanPage::getWirelessList(QMap<QString, QVector<QStringList> > &map)
|
||||
{
|
||||
|
@ -798,9 +826,12 @@ void WlanPage::onMainWindowVisibleChanged(const bool &visible)
|
|||
}
|
||||
//若页面打开,开始扫描倒计时,若关闭,停止扫描倒计时
|
||||
if (visible) {
|
||||
qWarning() << "start refresh Timer" << Q_FUNC_INFO << __LINE__;
|
||||
m_scanTimer->start(20 * 1000);
|
||||
m_refreshIconTimer->start(5*1000);
|
||||
} else {
|
||||
m_scanTimer->stop();
|
||||
m_refreshIconTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,13 +18,15 @@
|
|||
#define MORE_TEXT_MARGINS 16,0,0,0
|
||||
#define SCROLLAREA_HEIGHT 200
|
||||
|
||||
class WlanListItem;
|
||||
|
||||
class WlanPage : public TabPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WlanPage(QWidget *parent = nullptr);
|
||||
~WlanPage() = default;
|
||||
bool wlanIsConnected = false;
|
||||
bool m_wlanIsConnected = false;
|
||||
|
||||
//for dbus
|
||||
void getWirelessList(QMap<QString, QVector<QStringList> > &map);
|
||||
|
@ -48,7 +50,6 @@ signals:
|
|||
void signalStrengthChange(QString devName, QString ssid, int strength);
|
||||
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
||||
void hiddenWlanClicked();
|
||||
void settingsClicked();
|
||||
void wlanConnectChanged();
|
||||
|
||||
public slots:
|
||||
|
@ -68,6 +69,7 @@ private:
|
|||
//定时触发扫描的定时器
|
||||
void initTimer();
|
||||
QTimer * m_scanTimer = nullptr;
|
||||
QTimer * m_refreshIconTimer = nullptr;
|
||||
|
||||
void initDevice();//初始化默认设备
|
||||
void initDeviceCombox();
|
||||
|
@ -75,7 +77,8 @@ private:
|
|||
void getActiveWlan();
|
||||
void appendActiveWlan(const QString &uuid, int &height);
|
||||
void getAllWlan();
|
||||
QMap<QString, QListWidgetItem*> m_itemsMap;
|
||||
|
||||
QMap<QString, QPair<QListWidgetItem*, WlanListItem*>> m_itemsMap;
|
||||
QListWidgetItem *m_expandedItem = nullptr;
|
||||
QFrame * m_inactivatedWlanListAreaCentralWidget = nullptr;
|
||||
QVBoxLayout * m_inactivatedWlanListAreaLayout = nullptr;
|
||||
|
@ -118,6 +121,7 @@ private slots:
|
|||
void onHiddenWlanClicked();
|
||||
void showControlCenter();
|
||||
void onWifiEnabledChanged(bool isWifiOn);
|
||||
void onRefreshIconTimer();
|
||||
};
|
||||
|
||||
#endif // WLANPAGE_H
|
||||
|
|
|
@ -8,7 +8,7 @@ Icon=gnome-dev-ethernet
|
|||
Comment=Beautiful Network Config Applet
|
||||
Comment[zh_CN]=麒麟网络设置工具,提供查看和简单设置功能,拥有美观的界面和舒适的操作.
|
||||
Keywords=applet;nm;network;network-manager;
|
||||
Exec=/usr/bin/kylin-nm
|
||||
Exec=/usr/bin/kylin-network-manager
|
||||
StartupNotify=false
|
||||
Terminal=false
|
||||
Type=Application
|
||||
|
|
|
@ -8,16 +8,13 @@ QT += core gui x11extras dbus KWindowSystem svg concurrent network
|
|||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = kylin-nm
|
||||
TARGET = kylin-network-manager
|
||||
TEMPLATE = app
|
||||
LANGUAGE = C++
|
||||
|
||||
CONFIG += c++14
|
||||
CONFIG += qt warn_on
|
||||
CONFIG += c++14 qt warn_on link_pkgconfig
|
||||
#CONFIG += release
|
||||
CONFIG += link_pkgconfig
|
||||
|
||||
PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0 gsettings-qt
|
||||
PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0 gsettings-qt libcap
|
||||
|
||||
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
|
||||
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue