Merge branch 'kylin-nm-wlan' into 'dbus-interface'

modify:1)delete invalide files.

See merge request kylin-desktop/kylin-nm!337
This commit is contained in:
ren peijia 2021-10-19 12:04:15 +00:00
commit ba40157b5f
25 changed files with 1513 additions and 2012 deletions

View File

@ -354,7 +354,7 @@ void KyConnectResourse::getConnectionSetting(QString connectUuid, KyConnectSetti
return;
}
bool KyConnectResourse::getInterfaceByUuid(QString &deviceName, NetworkManager::ConnectionSettings::ConnectionType &type, const QString connUuid)
bool KyConnectResourse::getInterfaceByUuid(QString &deviceName, const QString connUuid)
{
deviceName.clear();
NetworkManager::Connection::Ptr connectPtr =
@ -370,7 +370,7 @@ bool KyConnectResourse::getInterfaceByUuid(QString &deviceName, NetworkManager::
qWarning()<<"getInterfaceByUuid failed, connect uuid"<<connUuid;
return false;
}
type = connectPtr->settings()->connectionType();
deviceName = connectPtr->settings()->interfaceName();
qDebug() << "getInterfaceByUuid success " << deviceName;
return true;
@ -569,6 +569,25 @@ KyApConnectItem *KyConnectResourse::getApConnectItem(NetworkManager::Connection:
return apConnectItem;
}
KyApConnectItem *KyConnectResourse::getApConnectionByUuid(QString connectUuid)
{
NetworkManager::Connection::Ptr connectPtr = nullptr;
connectPtr = m_networkResourceInstance->getConnect(connectUuid);
if (nullptr == connectPtr) {
return nullptr;
}
if (NetworkManager::ConnectionSettings::ConnectionType::Wireless
!= connectPtr->settings()->connectionType()) {
return nullptr;
}
KyApConnectItem *connectItem = getApConnectItem(connectPtr);
return connectItem;
}
void KyConnectResourse::getApConnections(QList<KyApConnectItem *> &apConnectItemList)
{
int index = 0;
@ -609,7 +628,11 @@ void KyConnectResourse::getApConnections(QList<KyApConnectItem *> &apConnectItem
bool KyConnectResourse::isWiredConnection(QString uuid)
{
NetworkManager::Connection::Ptr connectPtr =
m_networkResourceInstance->getConnect(uuid);
m_networkResourceInstance->getConnect(uuid);
if (connectPtr.isNull()) {
qWarning()<<"[KyConnectResourse]"<<"can not find wired connection"<<uuid;
return false;
}
if (!connectPtr.isNull()) {
NetworkManager::ConnectionSettings::Ptr connectSettingPtr = connectPtr->settings();
@ -631,9 +654,14 @@ bool KyConnectResourse::isWiredConnection(QString uuid)
bool KyConnectResourse::isWirelessConnection(QString uuid)
{
NetworkManager::Connection::Ptr connectPtr =
m_networkResourceInstance->getConnect(uuid);
m_networkResourceInstance->getConnect(uuid);
if (connectPtr.isNull()) {
qWarning()<<"[KyConnectResourse]"<<"can not find wireless connection"<<uuid;
return false;
}
if (connectPtr->isValid()) {
NetworkManager::ConnectionSettings::Ptr connectSettingPtr = connectPtr->settings();
if (connectSettingPtr.isNull()) {
@ -654,3 +682,28 @@ bool KyConnectResourse::isActivatedConnection(QString uuid)
{
return m_networkResourceInstance->isActiveConnection(uuid);
}
bool KyConnectResourse::isApConnection(QString uuid)
{
NetworkManager::Connection::Ptr connectPtr = nullptr;
connectPtr = m_networkResourceInstance->getConnect(uuid);
if (nullptr == connectPtr) {
return false;
}
if (NetworkManager::ConnectionSettings::ConnectionType::Wireless
!= connectPtr->settings()->connectionType()) {
return false;
}
NetworkManager::ConnectionSettings::Ptr settingPtr = connectPtr->settings();
NetworkManager::WirelessSetting::Ptr wirelessSetting
= settingPtr->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
if (NetworkManager::WirelessSetting::NetworkMode::Ap
!= wirelessSetting->mode()) {
return false;
}
return true;
}

View File

@ -27,13 +27,16 @@ public:
void getVpnConnections(QList<KyVpnConnectItem *> &vpnConnectItemList);
void getBluetoothConnections(QList<KyBluetoothConnectItem *> &bluetoothConnectItemList);
void getApConnections(QList<KyApConnectItem *> &apConnectItemList);
KyApConnectItem *getApConnectionByUuid(QString connectUuid);
void getConnectionSetting(QString connectUuid, KyConnectSetting &connectSetting);
bool getInterfaceByUuid(QString &deviceName, NetworkManager::ConnectionSettings::ConnectionType &type, const QString connUuid);
bool getInterfaceByUuid(QString &deviceName, const QString connUuid);
void getConnectivity(NetworkManager::Connectivity &connectivity);
bool isWiredConnection(QString uuid);
bool isWirelessConnection(QString uuid);
bool isActivatedConnection(QString uuid);
bool isApConnection(QString uuid);
private:
KyConnectItem *getConnectionItem(NetworkManager::Connection::Ptr connectPtr);

View File

@ -55,7 +55,7 @@ KyNetworkResourceManager::KyNetworkResourceManager(QObject *parent) : QObject(pa
connect(NetworkManager::notifier(), &NetworkManager::Notifier::connectivityChanged, this, &KyNetworkResourceManager::connectivityChanged);
//todo wifi开关信号
connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessEnabledChanged, this, &KyNetworkResourceManager::wifinEnabledChanged);
connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessEnabledChanged, this, &KyNetworkResourceManager::wifiEnabledChanged);
connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessHardwareEnabledChanged, [=](){
});
@ -210,8 +210,13 @@ void KyNetworkResourceManager::addConnection(NetworkManager::Connection::Ptr con
void KyNetworkResourceManager::insertConnections()
{
for (auto const & conn : NetworkManager::listConnections())
addConnection(conn);
for (auto const & connectPtr : NetworkManager::listConnections()) {
if (connectPtr->name().isEmpty() || connectPtr->uuid().isEmpty()) {
qWarning() <<"[KyNetworkResourceManager]" << " the name of connection is empty.";
continue;
}
addConnection(connectPtr);
}
}
void KyNetworkResourceManager::removeDevice(int pos)
@ -556,8 +561,8 @@ void KyNetworkResourceManager::onActiveConnectionChanged(
NetworkManager::ActiveConnection * activeConnect =
qobject_cast<NetworkManager::ActiveConnection *>(sender());
if (activeConnect->isValid()) {
qDebug()<<"!New state change activate connect"<<activeConnect->uuid();
qDebug()<<"!New the active connect state"<<state;
qDebug()<< "[KyNetworkResourceManager]" <<"!New state change activate connect"<<activeConnect->uuid();
qDebug()<< "[KyNetworkResourceManager]" <<"!New the active connect state"<<state;
::usleep(SIGNAL_DELAY);
while(activeConnect->state() != state) {
qDebug()<<"connect real state"<<activeConnect->state() <<"change state"<<state;
@ -774,6 +779,11 @@ void KyNetworkResourceManager::onConnectionAdded(QString const & path)
qDebug() <<"[KyNetworkResourceManager]" <<"add connect "<< connectPtr->name() << connectPtr->path();
if (connectPtr->name().isEmpty() || connectPtr->uuid().isEmpty()) {
qWarning() <<"[KyNetworkResourceManager]" << "the name or uuid of connection is empty";
return;
}
if (0 > m_connections.indexOf(connectPtr)) {
addConnection(connectPtr);
emit connectionAdd(connectPtr->uuid());

View File

@ -125,7 +125,7 @@ signals:
void wifiNetworkAdded(QString, QString);
void wifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net);
void wifiNetworkDeviceDisappear();
void wifinEnabledChanged(bool);
void wifiEnabledChanged(bool);
void activeConnectionsReset();
void activeConnectionAdd(QString uuid);

View File

@ -100,7 +100,8 @@ NetworkManager::ConnectionSettings::Ptr assembleWirelessSettings(const KyWireles
KyWirelessConnectOperation::KyWirelessConnectOperation(QObject *parent) : KyConnectOperation(parent)
{
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifinEnabledChanged, this, &KyWirelessConnectOperation::wifinEnabledChanged);
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiEnabledChanged,
this, &KyWirelessConnectOperation::wifiEnabledChanged);
}
KyWirelessConnectOperation::~KyWirelessConnectOperation()
@ -695,14 +696,6 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
void KyWirelessConnectOperation::setWirelessEnabled(bool enabled)
{
NetworkManager::setWirelessEnabled(enabled);
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA);
if (gsetting->get(WIRELESS_SWITCH).toBool() != enabled) {
gsetting->set(WIRELESS_SWITCH, enabled);
}
} else {
qDebug()<<"isSchemaInstalled false";
}
}
bool KyWirelessConnectOperation::getWirelessEnabled()

View File

@ -128,7 +128,7 @@ private:
signals:
void wifinEnabledChanged(bool);
void wifiEnabledChanged(bool);
void addAndActivateConnectionError(QString errorMessage);
private:

View File

@ -123,7 +123,7 @@ void KyWirelessNetResource::getWirelessActiveConnection(NetworkManager::ActiveCo
qDebug() << "getWirelessActiveConnection " << activeConnectionPtr->uuid();
QString ssid;
QString ifaceName = getDeviceIFace(activeConnectionPtr,ssid);
QString ifaceName = getDeviceIFace(activeConnectionPtr, ssid);
if(ifaceName.isEmpty() || ssid.isNull()) {
continue;
}
@ -138,6 +138,69 @@ void KyWirelessNetResource::getWirelessActiveConnection(NetworkManager::ActiveCo
return;
}
QString KyWirelessNetResource::getActiveConnectSsidByDevice(QString deviceName)
{
QString ssid = "";
NetworkManager::ActiveConnection::List activeConnectionList;
activeConnectionList.clear();
activeConnectionList = m_networkResourceInstance->getActiveConnectList();
if (activeConnectionList.isEmpty()) {
return ssid;
}
NetworkManager::ActiveConnection::Ptr activeConnectionPtr = nullptr;
for (int index; index < activeConnectionList.size(); index++) {
activeConnectionPtr = activeConnectionList.at(index);
if (activeConnectionPtr.isNull()) {
continue;
}
if (NetworkManager::ConnectionSettings::ConnectionType::Wireless != activeConnectionPtr->type()) {
continue;
}
if (NetworkManager::ActiveConnection::State::Activated != activeConnectionPtr->state()) {
continue;
}
NetworkManager::Connection::Ptr connectPtr = activeConnectionPtr->connection();
NetworkManager::ConnectionSettings::Ptr settingPtr = connectPtr->settings();
if (deviceName != settingPtr->interfaceName()) {
continue;
}
NetworkManager::WirelessSetting::Ptr wirelessSettingPtr =
settingPtr->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
ssid = wirelessSettingPtr->ssid();
}
return ssid;
}
bool KyWirelessNetResource::getActiveWirelessNetItem(QString deviceName, KyWirelessNetItem &wirelessNetItem)
{
if (!m_WifiNetworkList.contains(deviceName)) {
qDebug() << "getWifiNetwork fail,not contain " << deviceName;
return false;
}
QString ssid = getActiveConnectSsidByDevice(deviceName);
if (ssid.isEmpty()) {
return false;
}
for (int index = 0; index < m_WifiNetworkList[deviceName].size(); index ++){
if (m_WifiNetworkList[deviceName].at(index).m_NetSsid == ssid) {
wirelessNetItem = m_WifiNetworkList[deviceName].at(index);
qDebug() << "getWifiNetwork success";
return true;
}
}
return false;
}
QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection::Ptr actConn,
QString &wirelessNetResourcessid)
{
@ -164,23 +227,38 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection::
return sett->interfaceName();
}
void KyWirelessNetResource::getSsidByUuid(const QString uuid, QString &ssid, QString &devName)
void KyWirelessNetResource::getSsidByUuid(const QString uuid, QString &ssid)
{
ssid.clear();
devName.clear();
NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(uuid);
if (connectPtr.isNull()) {
return;
}
NetworkManager::WirelessSetting::Ptr wireless_sett
= connectPtr->settings()->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
if (wireless_sett.isNull()) {
qDebug() << "don't have WirelessSetting connection";
return;
}
ssid = wireless_sett->ssid();
devName = connectPtr->settings()->interfaceName();
qDebug() << "getSsidByUuid success " << ssid;
return;
}
void KyWirelessNetResource::getDeviceByUuid(const QString uuid, QString &deviceName)
{
deviceName.clear();
NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(uuid);
if (connectPtr.isNull()) {
return;
}
deviceName = connectPtr->settings()->interfaceName();
return;
}

View File

@ -29,8 +29,11 @@ public:
bool getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info);
void getWirelessActiveConnection(NetworkManager::ActiveConnection::State state, QMap<QString, QStringList> &map);
bool getActiveWirelessNetItem(QString deviceName, KyWirelessNetItem &wirelessNetItem);
void getSsidByUuid(const QString uuid, QString &ssid, QString &devName);
QString getActiveConnectSsidByDevice(QString deviceName);
void getSsidByUuid(const QString uuid, QString &ssid);
void getDeviceByUuid(const QString uuid, QString &deviceName);
private:

View File

@ -5,7 +5,7 @@
#define MAIN_SIZE_EXPAND 400,500
#define MAIN_SIZE_NARROW 400,400
EnterpriseWlanDialog::EnterpriseWlanDialog(KyWirelessNetItem *data, QString device, QWidget *parent) : QDialog(parent)
EnterpriseWlanDialog::EnterpriseWlanDialog(KyWirelessNetItem &wirelessNetItem, QString device, QWidget *parent) : QDialog(parent)
{
//设置窗口无边框,阴影
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
@ -19,7 +19,7 @@ EnterpriseWlanDialog::EnterpriseWlanDialog(KyWirelessNetItem *data, QString devi
#endif
this->setAttribute(Qt::WA_DeleteOnClose);
m_data = data;
m_wirelessNetItem = wirelessNetItem;
m_deviceName = device;
m_connectOperation = new KyWirelessConnectOperation();
m_resource = new KyWirelessNetResource();
@ -72,11 +72,8 @@ void EnterpriseWlanDialog::initUI()
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_ssidLabel->setText(m_wirelessNetItem.m_NetSsid);
m_ssidLayout->addWidget(m_ssidTitleLabel);
m_ssidLayout->addStretch();
m_ssidLayout->addWidget(m_ssidLabel);
@ -130,9 +127,9 @@ void EnterpriseWlanDialog::initConnections()
void EnterpriseWlanDialog::initData()
{
if (m_data && m_data->m_isConfigured) {
if (m_wirelessNetItem.m_isConfigured) {
KyEapMethodType type;
m_connectOperation->getEnterpiseEapMethod(m_data->m_connectUuid, type);
m_connectOperation->getEnterpiseEapMethod(m_wirelessNetItem.m_connectUuid, type);
if (type) {
onEapTypeChanged(type);
} else {
@ -143,20 +140,18 @@ void EnterpriseWlanDialog::initData()
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__;
qDebug() << "Clicked connectBtn, will connect enterprise WLAN, ssid = "
<< m_wirelessNetItem.m_NetSsid << "." << Q_FUNC_INFO << __LINE__;
KySecuType secuType;
KyEapMethodType eapType;
m_securityPage->getSecuType(secuType, eapType);
KyWirelessConnectSetting connetSetting;
connetSetting.setConnectName(m_data->m_NetSsid);
connetSetting.setConnectName(m_wirelessNetItem.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_ssid = m_wirelessNetItem.m_NetSsid;
connetSetting.m_secretFlag = 0;
connetSetting.dumpInfo();
@ -177,22 +172,22 @@ 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);
if (!m_wirelessNetItem.m_connectUuid.isEmpty()) {
m_resource->getEnterPriseInfoTls(m_wirelessNetItem.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);
if (m_wirelessNetItem.m_connectUuid.isEmpty()) {
m_resource->getEnterPriseInfoPeap(m_wirelessNetItem.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);
if (!m_wirelessNetItem.m_connectUuid.isEmpty()) {
m_resource->getEnterPriseInfoTtls(m_wirelessNetItem.m_connectUuid, m_info.ttlsInfo);
m_securityPage->setTtlsInfo(m_info.ttlsInfo);
}
this->setFixedSize(MAIN_SIZE_NARROW);

View File

@ -10,7 +10,7 @@ class EnterpriseWlanDialog : public QDialog
{
Q_OBJECT
public:
EnterpriseWlanDialog(KyWirelessNetItem *data, QString device, QWidget *parent = nullptr);
EnterpriseWlanDialog(KyWirelessNetItem &wirelessNetItem, QString device, QWidget *parent = nullptr);
~EnterpriseWlanDialog();
private:
@ -20,7 +20,7 @@ private:
void initData();
private:
KyWirelessNetItem *m_data = nullptr;
KyWirelessNetItem m_wirelessNetItem;
ConInfo m_info;
QString m_deviceName;
KyWirelessConnectOperation *m_connectOperation = nullptr;

View File

@ -11,14 +11,10 @@ FORMS += \
HEADERS += \
$$PWD/customstyle.h \
$$PWD/kylinwiredwidget.h \
$$PWD/mainwindow.h \
$$PWD/nmdemo.h \
$$PWD/wificonfigdialog.h
SOURCES += \
$$PWD/customstyle.cpp \
$$PWD/kylinwiredwidget.cpp \
$$PWD/mainwindow.cpp \
$$PWD/nmdemo.cpp \
$$PWD/wificonfigdialog.cpp

View File

@ -1,206 +0,0 @@
#include "kylinwiredwidget.h"
KyWiredWidget::KyWiredWidget(QWidget *parent):QWidget(parent)
{
m_activeConnectResource = new KyActiveConnectResourse();
m_connectResource = new KyConnectResourse();
m_deviceResource = new KyNetworkDeviceResourse();
connect(m_activeConnectResource, &KyActiveConnectResourse::activeConnectRemove,
this, &KyWiredWidget::removeActiveConnection);
connect(m_activeConnectResource, &KyActiveConnectResourse::stateChangeReason,
this, &KyWiredWidget::activeConnectStateChange);
connect(m_connectResource, &KyConnectResourse::connectionAdd, this, &KyWiredWidget::addConnection);
connect(m_connectResource, &KyConnectResourse::connectionRemove, this, &KyWiredWidget::removeConnection);
connect(m_connectResource, &KyConnectResourse::connectionUpdate, this, &KyWiredWidget::updateConnection);
connect(m_deviceResource, &KyNetworkDeviceResourse::carrierChanage,this, &KyWiredWidget::wiredDeviceCarrierChange);
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateWidgetList()));
}
KyWiredWidget::~KyWiredWidget()
{
delete m_activeConnectResource;
delete m_connectResource;
delete m_deviceResource;
}
void KyWiredWidget::constructWiredActiveConnectList()
{
qDebug()<<"constructWiredActiveConnectList";
QList<KyConnectItem *> wiredActiveConnect;
m_activeConnectResource->getActiveConnectionList("enp2s0",
NetworkManager::ConnectionSettings::ConnectionType::Wired,
wiredActiveConnect);
// if (wiredActiveConnect.isEmpty()) {
// LanListItem *activeWiredForm = new LanListItem(this, nullptr);
// activeWiredForm->constructActiveConnectionEmptyItem();
// m_wiredActiveFormlist<<activeWiredForm;
// } else {
// for (int index = 0; index < wiredActiveConnect.size(); ++index) {
// resize(width(), height() + H_NORMAL_ITEM * index);
// LanListItem *activeWiredForm = new LanListItem(this, wiredActiveConnect.at(index));
// activeWiredForm->constructActiveConnectionItem(index);
// m_wiredActiveFormlist<<activeWiredForm;
// }
// }
return;
}
void KyWiredWidget::setType(WIDGETTYPE type)
{
m_type = type;
}
void KyWiredWidget::constructWiredConnectList()
{
qDebug()<<"constructWiredConnectList.....";
QList<KyConnectItem *> wiredConnections;
m_connectResource->getConnectionList("enp2s0",
NetworkManager::ConnectionSettings::ConnectionType::Wired,
wiredConnections);
// if (!wiredConnections.isEmpty()) {
// for (int index = 0; index < wiredConnections.size(); ++index) {
// resize(W_LIST_WIDGET, height() + H_NORMAL_ITEM);
// OneLancForm *wiredForm = new OneLancForm(this, wiredConnections.at(index));
// wiredForm->constructConnectionItem(index);
// m_wiredFormlist<<wiredForm;
// }
// }
return;
}
void KyWiredWidget::updateWiredActiveConnection()
{
qDebug()<<"updateWiredActiveConnection......";
while (!m_wiredActiveFormlist.empty()) {
LanListItem *wiredActiveForm = m_wiredActiveFormlist.at(0);
m_wiredActiveFormlist.removeAt(0);
delete wiredActiveForm;
wiredActiveForm = nullptr;
}
constructWiredActiveConnectList();
}
void KyWiredWidget::updateWiredConnection()
{
qDebug()<<"updateWiredConnection........";
while (!m_wiredFormlist.empty()) {
LanListItem *wiredForm = m_wiredFormlist.at(0);
m_wiredFormlist.removeAt(0);
delete wiredForm;
wiredForm = nullptr;
}
constructWiredConnectList();
}
void KyWiredWidget::updateWidgetList()
{
m_timer->stop();
if (ACTIVECONNECTION == m_type) {
updateWiredActiveConnection();
} else {
updateWiredConnection();
}
return;
}
void KyWiredWidget::removeActiveConnection(QString connectUuid)
{
m_timer->start(300);
return;
}
void KyWiredWidget::activeConnectStateChange(QString connectUuid,
NetworkManager::ActiveConnection::State state,
NetworkManager::ActiveConnection::Reason reason)
{
qDebug()<<"active connection"<<connectUuid
<<"state"<<state <<"change reason"<<reason;
if (NetworkManager::ActiveConnection::State::Activated == state) {
m_timer->start(300);
}
return;
}
void KyWiredWidget::addConnection(QString connectUuid)
{
qDebug()<<"add connection "<<connectUuid;
if (CONNECTION == m_type) {
updateWiredConnection();
}
return;
}
void KyWiredWidget::updateConnection(QString connectUuid)
{
qDebug() << "update connection" << connectUuid;
if (CONNECTION == m_type) {
updateWiredConnection();
} else {
updateWiredActiveConnection();
}
return;
}
void KyWiredWidget::removeConnection(QString path)
{
qDebug()<<"remove connection"<< path;
if (CONNECTION == m_type) {
updateWiredConnection();
}
return;
}
void KyWiredWidget::wiredDeviceCarrierChange(QString deviceName, bool pluged)
{
qDebug()<<"device"<< deviceName << "carrier state"<< pluged;
return;
}
void KyWiredWidget::updateDeviceRefreshRate(QString deviceName, int ms)
{
m_deviceResource->setDeviceRefreshRate(deviceName, ms);
return;
}
#if 0
void KyWiredWidget::updateNetworkSpeed(KyConnectItem *wiredItem)
{
qulonglong txBytes = wiredItem->m_upSpeed;
qulonglong rxBytes = wiredItem->m_downSpeed;
m_deviceResource->DeviceSpeed(wiredItem->m_ifaceName, wiredItem);
if (wiredItem->m_upSpeed > txBytes) {
txBytes = wiredItem->m_upSpeed - txBytes;
} else {
txBytes = 0;
}
if (wiredItem->m_downSpeed > rxBytes) {
rxBytes = wiredItem->m_downSpeed - rxBytes;
} else {
rxBytes = 0;
}
emit updateSpeed(rxBytes, txBytes);
return;
}
#endif

View File

@ -1,65 +0,0 @@
#ifndef KYLINWIREDWIDGET_H
#define KYLINWIREDWIDGET_H
#include <QWidget>
#include "backend/dbus-interface/kylinactiveconnectresource.h"
#include "backend/dbus-interface/kylinconnectresource.h"
#include "backend/dbus-interface/kylinnetworkdeviceresource.h"
#include "backend/dbus-interface/kylinconnectitem.h"
#include "lanlistitem.h"
#include "mainwindow.h"
class LanListItem;
typedef enum{
ACTIVECONNECTION,
CONNECTION,
}WIDGETTYPE;
class KyWiredWidget : public QWidget
{
Q_OBJECT
public:
explicit KyWiredWidget(QWidget *parent = nullptr);
~KyWiredWidget();
void setType(WIDGETTYPE type);
void constructWiredConnectList();
void constructWiredActiveConnectList();
void updateDeviceRefreshRate(QString deviceName, int ms);
void updateNetworkSpeed(KyConnectItem *wiredItem);
private:
void updateWiredActiveConnection();
void updateWiredConnection();
signals:
void updateSpeed(qulonglong rx, qulonglong tx);
public slots:
void removeActiveConnection(QString connectUuid);
void activeConnectStateChange(QString uuid,
NetworkManager::ActiveConnection::State state,
NetworkManager::ActiveConnection::Reason reason);
void addConnection(QString connectUuid);
void updateConnection(QString connectUuid);
void removeConnection(QString path);
void wiredDeviceCarrierChange(QString deviceName, bool pluged);
void updateWidgetList();
private:
WIDGETTYPE m_type;
QTimer *m_timer;
KyActiveConnectResourse *m_activeConnectResource = nullptr;
KyConnectResourse *m_connectResource = nullptr;
KyNetworkDeviceResourse *m_deviceResource = nullptr;
QList<LanListItem*> m_wiredActiveFormlist;
QList<LanListItem*> m_wiredFormlist;
};
#endif // KYLINWIREDWIDGET_H

View File

@ -1,7 +1,6 @@
#ifndef LANLISTITEM_H
#define LANLISTITEM_H
#include "listitem.h"
#include "kylinwiredwidget.h"
#include "kylinactiveconnectresource.h"
#include <QDBusInterface>

View File

@ -13,6 +13,7 @@
ListItem::ListItem(QWidget *parent) : QFrame(parent)
{
m_connectState = UnknownState;
isDetailShow = false;
initUI();
initConnection();
@ -47,6 +48,11 @@ void ListItem::setActive(const bool &isActive)
m_isActive = isActive;
}
void ListItem::setConnectState(ConnectState state)
{
m_connectState = state;
}
void ListItem::showDesktopNotify(const QString &message)
{
QDBusInterface iface("org.freedesktop.Notifications",
@ -67,6 +73,7 @@ void ListItem::showDesktopNotify(const QString &message)
void ListItem::mousePressEvent(QMouseEvent *event)
{
qDebug()<<"[WlanListItem]"<<"mousePressEvent";
if (event->button() == Qt::LeftButton) {
onNetButtonClicked();
} else if (event->button() == Qt::RightButton) {

View File

@ -9,6 +9,14 @@
#include "infobutton.h"
#include "netdetails/netdetail.h"
typedef enum{
UnknownState = 0, /**< The active connection is in an unknown state */
Activating, /**< The connection is activating */
Activated, /**< The connection is activated */
Deactivating, /**< The connection is being torn down and cleaned up */
Deactivated /**< The connection is no longer active */
}ConnectState;
class ListItem : public QFrame
{
Q_OBJECT
@ -17,6 +25,7 @@ public:
~ListItem();
void setName(const QString &name);
void setActive(const bool &isActive);
void setConnectState(ConnectState state);
static void showDesktopNotify(const QString &message);
protected:
@ -35,6 +44,7 @@ protected:
InfoButton * m_infoButton = nullptr;
bool m_isActive = false;
ConnectState m_connectState;
public:
QVBoxLayout * m_mainLayout = nullptr;

View File

@ -2,23 +2,34 @@
#include <QResizeEvent>
#include "enterprisewlandialog.h"
WlanListItem::WlanListItem(KyWirelessNetResource *resource, KyWirelessNetItem *data, QString device, QWidget *parent) : ListItem(parent)
#define EMPTY_SSID "EMPTY_SSID"
#define LOG_FLAG "[WlanListItem]"
#define WAIT_US 10*1000
WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, QWidget *parent) : ListItem(parent)
{
m_data = data;
m_resource = resource;
m_wlanDevice = device;
m_connoperation = new KyWirelessConnectOperation(this);
m_connectResource = new KyActiveConnectResourse();
m_wirelessNetItem = wirelessNetItem;
qDebug()<<"[WlanPage] wlan list item is created." << m_wirelessNetItem.m_NetSsid;
initWlanUI();
setExpanded(false);
initWlanConnection();
connect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked);
m_menu = new QMenu();//右键菜单
connect(m_menu, &QMenu::triggered, this, &WlanListItem::onMenuTriggered);
m_wirelessConnectOperation = new KyWirelessConnectOperation(this);
}
WlanListItem::WlanListItem(QWidget *parent) : ListItem(parent)
{
m_wirelessNetItem.m_NetSsid = EMPTY_SSID;
qDebug()<<"[WlanPage] wlan list item is created." << m_wirelessNetItem.m_NetSsid;
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-none-symbolic"));
const QString name = tr("Not connected");
setExpanded(false);
@ -29,24 +40,24 @@ WlanListItem::WlanListItem(QWidget *parent) : ListItem(parent)
WlanListItem::~WlanListItem()
{
disconnect(m_resource, &KyWirelessNetResource::secuTypeChange, this, &WlanListItem::onSecurityChanged);
disconnect(m_resource, &KyWirelessNetResource::connectionAdd, this, &WlanListItem::onConnectionAdd);
disconnect(m_resource, &KyWirelessNetResource::connectionRemove, this, &WlanListItem::onConnectionRemove);
disconnect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked);
qDebug()<<"[WlanPage] wlan list item is deleted." << m_wirelessNetItem.m_NetSsid;
}
QString WlanListItem::getSsid()
{
return m_wirelessNetItem.m_NetSsid;
}
void WlanListItem::setWlanSignal(const int &signal)
{
if (!m_data){
return;
}
m_data->m_signalStrength = signal;
m_wirelessNetItem.m_signalStrength = signal;
refreshIcon();
}
void WlanListItem::setWlanState(const int &state)
{
// m_data->m_state = state; //ZJP_TODO 后端接口待补全
// m_wirelessNetItem.m_state = state; //ZJP_TODO 后端接口待补全
refreshIcon();
}
@ -56,87 +67,112 @@ void WlanListItem::setExpanded(const bool &expanded)
this->setFixedHeight(NORMAL_HEIGHT);
return;
}
this->setFixedHeight(expanded ? EXPANDED_HEIGHT : NORMAL_HEIGHT);
// m_pwdFrame->setVisible(false);
// m_autoConnectFrame->setVisible(false);
emit this->itemHeightChanged(m_data->m_NetSsid);
if (!expanded) {
m_pwdFrame->setVisible(expanded);
m_autoConnectFrame->setVisible(expanded);
if (expanded) {
m_pwdLineEdit->setFocus();
setFixedHeight(EXPANDED_HEIGHT);
} else {
setFixedHeight(NORMAL_HEIGHT);
QPalette pal = qApp->palette();
pal.setColor(QPalette::Window, qApp->palette().base().color());
this->setPalette(pal);
}
}
void WlanListItem::setWlanItemPwdVisible(const bool &expanded)
{
m_pwdFrame->setVisible(expanded);
m_autoConnectFrame->setVisible(expanded);
}
emit this->itemHeightChanged(expanded, m_wirelessNetItem.m_NetSsid);
QString WlanListItem::getSsid()
{
if (!m_data) {
return QString();
} else {
return m_data->m_NetSsid;
}
return;
}
void WlanListItem::resizeEvent(QResizeEvent *event)
{
this->blockSignals(true);
if (this->height() == EXPANDED_HEIGHT) {
this->setExpanded(true);
} else {
this->setExpanded(false);
}
this->blockSignals(false);
return ListItem::resizeEvent(event);
}
void WlanListItem::onRightButtonClicked()
{
qDebug()<< LOG_FLAG <<"onRightButtonClicked";
if (!m_menu) {
return;
}
m_menu->clear();
if (!this->m_data) {
if (Activated == m_connectState) {
m_menu->addAction(new QAction(tr("Disconnect"), this));
} else if (Deactivated == m_connectState) {
m_menu->addAction(new QAction(tr("Connect"), this));
} else {
return;
}
if (this->m_isActive) {
m_menu->addAction(new QAction(tr("Disconnect"), this));
} else {
m_menu->addAction(new QAction(tr("Connect"), this));
}
if (m_data->m_isConfigured)
if (m_wirelessNetItem.m_isConfigured) {
m_menu->addAction(new QAction(tr("Forget"), this));
}
m_menu->move(cursor().pos());
m_menu->show();
return;
}
void WlanListItem::enterEvent(QEvent *event)
{
if (m_data) {
return ListItem::enterEvent(event);
} else {
return QFrame::enterEvent(event);
}
//qDebug()<< LOG_FLAG <<"enterEvent" << m_wirelessNetItem.m_NetSsid;
m_mouseIsOut = false;
return ListItem::enterEvent(event);
}
void WlanListItem::leaveEvent(QEvent *event)
{
//qDebug()<< LOG_FLAG <<"leaveEvent"<< m_wirelessNetItem.m_NetSsid;
m_mouseIsOut = true;
if (m_pwdFrame && m_pwdFrame->isVisible()) {
if (m_focusIsOut) {
setExpanded(false);
}
return QFrame::leaveEvent(event);
}
return ListItem::leaveEvent(event);
}
bool WlanListItem::eventFilter(QObject *watched, QEvent *event)
{
if (watched == m_pwdLineEdit) {
if (event->type() == QEvent::FocusOut) {
m_focusIsOut = true;
//qDebug()<< LOG_FLAG <<"focusOutEvent" << m_wirelessNetItem.m_NetSsid;
if (m_mouseIsOut) {
setExpanded(false);
}
} else if (event->type() == QEvent::FocusIn) {
//qDebug()<< LOG_FLAG <<"focusInEvent" << m_wirelessNetItem.m_NetSsid;
m_focusIsOut = false;
}
}
return QFrame::eventFilter(watched, event);
}
void WlanListItem::initWlanUI()
{
m_hasPwd = (m_data->m_secuType.isEmpty() || m_data->m_secuType == "") ? false : true;
m_hasPwd = (m_wirelessNetItem.m_secuType.isEmpty() || m_wirelessNetItem.m_secuType == "") ? false : true;
//设置显示的Wlan名称
this->setName((m_data->m_connName != "") ? m_data->m_connName : m_data->m_NetSsid);
this->setName((m_wirelessNetItem.m_connName != "") ? m_wirelessNetItem.m_connName : m_wirelessNetItem.m_NetSsid);
//刷新左侧按钮图标
refreshIcon();
@ -153,63 +189,60 @@ void WlanListItem::initWlanUI()
m_pwdFrameLyt->setContentsMargins(FRAME_CONTENT_MARGINS);
m_pwdFrameLyt->setSpacing(FRAME_SPACING);
m_pwdFrame->setLayout(m_pwdFrameLyt);
{
m_pwdLineEdit = new QLineEdit(m_pwdFrame);
connect(m_pwdLineEdit, &QLineEdit::textChanged, this, &WlanListItem::onPwdEditorTextChanged);
m_pwdLineEdit->setFixedHeight(PWD_AREA_HEIGHT);
m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Password);
m_pwdLineEdit->setTextMargins(PWD_CONTENT_MARGINS);
m_pwdLineEditLyt = new QHBoxLayout(m_pwdLineEdit);
m_pwdLineEditLyt->setContentsMargins(PWD_LAYOUT_MARGINS);
m_pwdLineEdit->setLayout(m_pwdLineEditLyt);
m_showPwdButton = new QPushButton(m_pwdLineEdit);
m_showPwdButton->setFixedSize(SHOW_PWD_BUTTON_SIZE);
m_showPwdButton->setAutoFillBackground(false);
m_showPwdButton->setIcon(QIcon(":/res/h/hide-pwd.png"));
m_showPwdButton->setCursor(Qt::PointingHandCursor);
connect(m_showPwdButton, &QPushButton::clicked, this, &WlanListItem::onShowPwdButtonClicked);
m_pwdLineEditLyt->addStretch();
m_pwdLineEditLyt->addWidget(m_showPwdButton);
}
m_pwdLineEdit = new QLineEdit(m_pwdFrame);
m_pwdLineEdit->installEventFilter(this);
connect(m_pwdLineEdit, &QLineEdit::textChanged, this, &WlanListItem::onPwdEditorTextChanged);
m_pwdLineEdit->setFixedHeight(PWD_AREA_HEIGHT);
m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Password);
m_pwdLineEdit->setTextMargins(PWD_CONTENT_MARGINS);
m_pwdFrameLyt->addWidget(m_pwdLineEdit);
m_pwdLineEditLyt = new QHBoxLayout(m_pwdLineEdit);
m_pwdLineEditLyt->setContentsMargins(PWD_LAYOUT_MARGINS);
m_pwdLineEdit->setLayout(m_pwdLineEditLyt);
m_showPwdButton = new QPushButton(m_pwdLineEdit);
m_showPwdButton->setFixedSize(SHOW_PWD_BUTTON_SIZE);
m_showPwdButton->setAutoFillBackground(false);
m_showPwdButton->setIcon(QIcon(":/res/h/hide-pwd.png"));
m_showPwdButton->setCursor(Qt::PointingHandCursor);
connect(m_showPwdButton, &QPushButton::clicked, this, &WlanListItem::onShowPwdButtonClicked);
m_pwdLineEditLyt->addStretch();
m_pwdLineEditLyt->addWidget(m_showPwdButton);
m_connectButton = new QPushButton(m_pwdFrame);
m_connectButton->setFixedSize(CONNECT_BUTTON_WIDTH, PWD_AREA_HEIGHT);
m_connectButton->setText(tr("Connect"));
m_connectButton->setEnabled(false);
connect(m_connectButton, &QPushButton::clicked, this, &WlanListItem::onConnectButtonClicked);
m_pwdFrameLyt->addWidget(m_pwdLineEdit);
m_pwdFrameLyt->addWidget(m_connectButton);
//自动连接选择区域UI
m_autoConnectFrame = new QFrame(this);
m_autoConnectFrameLyt = new QHBoxLayout(m_autoConnectFrame);
m_autoConnectFrameLyt->setContentsMargins(FRAME_CONTENT_MARGINS);
m_autoConnectFrameLyt->setSpacing(FRAME_SPACING);
m_autoConnectFrame->setLayout(m_autoConnectFrameLyt);
m_autoConnectCheckBox = new QCheckBox(m_autoConnectFrame);
m_autoConnectCheckBox->setChecked(true);
m_autoConnectCheckBox->setFixedSize(SHOW_PWD_BUTTON_SIZE);
m_autoConnectFrameLyt->addWidget(m_autoConnectCheckBox);
m_autoConnectLabel = new QLabel(m_autoConnectFrame);
m_autoConnectLabel->setText(tr("Auto Connect"));
m_autoConnectFrameLyt->addWidget(m_autoConnectCheckBox);
m_autoConnectFrameLyt->addWidget(m_autoConnectLabel);
m_autoConnectFrameLyt->addStretch();
m_mainLayout->addWidget(m_pwdFrame);
m_mainLayout->addWidget(m_autoConnectFrame);
m_pwdFrame->hide();
m_autoConnectFrame->hide();
}
void WlanListItem::initWlanConnection()
{
connect(m_resource, &KyWirelessNetResource::secuTypeChange, this, &WlanListItem::onSecurityChanged);
connect(m_resource, &KyWirelessNetResource::connectionAdd, this, &WlanListItem::onConnectionAdd);
connect(m_resource, &KyWirelessNetResource::connectionRemove, this, &WlanListItem::onConnectionRemove);
connect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked);
connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanListItem::onWlanStatusChange);
connect(m_netButton, &RadioItemButton::animationStoped, this, &WlanListItem::refreshIcon);
}
void WlanListItem::refreshIcon()
{
#define FULL_SIGNAL 5
@ -218,45 +251,54 @@ void WlanListItem::refreshIcon()
#define OK_SIGNAL 2
#define LOW_SIGNAL 1
#define STEP 25
// if (m_data->m_state) //ZJP_TODO 连接中、已连接、未连接的处理,要单独写逻辑,后端接口待补全
if (!m_hasPwd) {
//ZJP_TODO 无加密 注意信号格数计算方式,可能需要修改
switch (m_data->m_signalStrength / STEP + 1) {
switch (m_wirelessNetItem.m_signalStrength / STEP + 1) {
case FULL_SIGNAL:
case EXCELLENT_SIGNAL:
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic", QIcon(":/res/w/wifi-full.png")));
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic",
QIcon(":/res/w/wifi-full.png")));
break;
case GOOD_SIGNAL:
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-good-symbolic", QIcon(":/res/w/wifi-high.png")));
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-good-symbolic",
QIcon(":/res/w/wifi-high.png")));
break;
case OK_SIGNAL:
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-ok", QIcon(":/res/w/wifi-medium.png")));
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-ok",
QIcon(":/res/w/wifi-medium.png")));
break;
case LOW_SIGNAL:
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-low", QIcon(":/res/w/wifi-low.png")));
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-low",
QIcon(":/res/w/wifi-low.png")));
break;
default:
qDebug() << "Set wlan(without passwd) icon failed, signal = " << m_data->m_signalStrength << Q_FUNC_INFO << __LINE__;
qDebug() << "Set wlan(without passwd) icon failed, signal = "
<< m_wirelessNetItem.m_signalStrength << Q_FUNC_INFO << __LINE__;
break;
}
} else {
//ZJP_TODO 有加密
switch (m_data->m_signalStrength / STEP + 1) {
switch (m_wirelessNetItem.m_signalStrength / STEP + 1) {
case FULL_SIGNAL:
case EXCELLENT_SIGNAL:
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-excellent-secure-symbolic", QIcon(":/res/w/wifi-full-pwd.png")));
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-excellent-secure-symbolic",
QIcon(":/res/w/wifi-full-pwd.png")));
break;
case GOOD_SIGNAL:
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-good-secure-symbolic", QIcon(":/res/w/wifi-high-pwd.png")));
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-good-secure-symbolic",
QIcon(":/res/w/wifi-high-pwd.png")));
break;
case OK_SIGNAL:
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-ok-secure-symbolic", QIcon(":/res/w/wifi-medium-pwd.png")));
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-ok-secure-symbolic",
QIcon(":/res/w/wifi-medium-pwd.png")));
break;
case LOW_SIGNAL:
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-low-secure-symbolic", QIcon(":/res/w/wifi-low-pwd.png")));
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-low-secure-symbolic",
QIcon(":/res/w/wifi-low-pwd.png")));
break;
default:
qDebug() << "Set wlan(with passwd) icon failed, signal = " << m_data->m_signalStrength << Q_FUNC_INFO << __LINE__;
qDebug() << "Set wlan(with passwd) icon failed, signal = "
<< m_wirelessNetItem.m_signalStrength << Q_FUNC_INFO << __LINE__;
break;
}
}
@ -269,89 +311,93 @@ void WlanListItem::onInfoButtonClicked()
qDebug() << "has show the detail page,and do not show again" << Q_FUNC_INFO << __LINE__;
return;
}
if(m_data){
qDebug()<<"Net active or not:"<<m_isActive;
qDebug() << "On wlan info button clicked! ssid = " << m_data->m_NetSsid << "; name = " << m_data->m_connName << "." <<Q_FUNC_INFO << __LINE__;
NetDetail *netDetail = new NetDetail(m_wlanDevice, m_data->m_NetSsid, m_data->m_connectUuid, m_isActive, true, !m_data->m_isConfigured, this);
connect(netDetail, &NetDetail::detailPageClose, this, &WlanListItem::onDetailShow);
netDetail->show();
emit this->detailShow(true);
}
else{
qDebug() << "On wlan info button clicked! But there is no wlan connect " ;
qDebug() << LOG_FLAG << "Net active or not:"<< m_connectState;
qDebug() << LOG_FLAG << "On wlan info button clicked! ssid = "
<< m_wirelessNetItem.m_NetSsid << "; name = "
<< m_wirelessNetItem.m_connName << "." <<Q_FUNC_INFO << __LINE__;
bool isActive = false;
if (Activated == m_connectState) {
isActive = true;
}
NetDetail *netDetail = new NetDetail(m_wlanDevice, m_wirelessNetItem.m_NetSsid,
m_wirelessNetItem.m_connectUuid, isActive, true,
!m_wirelessNetItem.m_isConfigured, this);
connect(netDetail, &NetDetail::detailPageClose, this, &WlanListItem::onDetailShow);
netDetail->show();
emit this->detailShow(true);
}
void WlanListItem::onNetButtonClicked()
{
if(!m_data){
qDebug() << "On wlan clicked! But there is no wlan connect!" << Q_FUNC_INFO << __LINE__;
qDebug() << LOG_FLAG << "onNetButtonClicked";
if (m_wirelessNetItem.m_NetSsid == EMPTY_SSID) {
return;
}
if ((m_state == NetworkManager::ActiveConnection::State::Activating || m_state == NetworkManager::ActiveConnection::State::Deactivating)) {
qDebug() << "On wlan clicked! But there is nothing to do because it is already activating/deactivating!" << Q_FUNC_INFO << __LINE__;
if ((Activating == m_connectState || Deactivating == m_connectState)) {
qDebug() << LOG_FLAG << "On wlan clicked! But there is nothing to do because it is already activating/deactivating!"
<< Q_FUNC_INFO << __LINE__;
return;
}
//执行连接或断开
if (m_isActive) {
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__;
if (Activated == m_connectState) {
m_wirelessConnectOperation->deActivateWirelessConnection(m_wlanDevice, m_wirelessNetItem.m_connectUuid);
qDebug()<<"[WlanListItem] Clicked on connected wifi, it will be inactivated. ssid = "
<< m_wirelessNetItem.m_NetSsid << Q_FUNC_INFO << __LINE__;
return;
}
//有配置的wifi直接连接
if (m_data->m_isConfigured) {
// this->onConnectButtonClicked();
m_connoperation->activeWirelessConnect(m_wlanDevice, m_data->m_connectUuid);//初始化没有uuid只有激活一次才有uuid
qDebug() << "Has configuration, will be activated. ssid = " << m_data->m_NetSsid << m_wlanDevice << m_data->m_connectUuid << Q_FUNC_INFO << __LINE__;
//有配置或者无密码的wifi直接连接
if (m_wirelessNetItem.m_isConfigured || m_hasPwd == false) {
m_wirelessConnectOperation->activeWirelessConnect(m_wlanDevice, m_wirelessNetItem.m_connectUuid);
qDebug()<<"[WlanListItem] Has configuration, will be activated. ssid = "
<< m_wirelessNetItem.m_NetSsid << Q_FUNC_INFO << __LINE__;
return;
}
if (!this->m_connectButton->isVisible() && m_data->m_secuType != "") {
if (m_data->m_secuType.contains("802.1x", Qt::CaseInsensitive)) {
EnterpriseWlanDialog *enterpriseWlanDialog = new EnterpriseWlanDialog(m_data, m_wlanDevice, this);
if (!this->m_connectButton->isVisible() && m_wirelessNetItem.m_secuType != "") {
if (m_wirelessNetItem.m_secuType.contains("802.1x", Qt::CaseInsensitive)) {
EnterpriseWlanDialog *enterpriseWlanDialog = new EnterpriseWlanDialog(m_wirelessNetItem, m_wlanDevice, this);
enterpriseWlanDialog->show();
} else {
this->setExpanded(true);
}
} else { //无密码的情况
} else {
onConnectButtonClicked();
}
return;
}
//void WlanListItem::onNameLableClicked()
//{
// m_mainLayout = new QVBoxLayout(this);
// m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
// m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
// this->setLayout(m_mainLayout);
// m_itemFrame = new QFrame(this);
// m_hItemLayout = new QHBoxLayout(m_itemFrame);
// m_hItemLayout->setContentsMargins(ITEM_FRAME_MARGINS);
// m_hItemLayout->setSpacing(ITEM_FRAME_SPACING);
// m_lineEdit = new QLineEdit(m_itemFrame);
// m_hItemLayout->addWidget(m_lineEdit);
// m_hItemLayout->addStretch();
// m_mainLayout->addWidget(m_itemFrame);
//}
void WlanListItem::onSecurityChanged(QString interface, QString ssid, QString securityType)
void WlanListItem::updateWirelessNetSecurity(QString ssid, QString securityType)
{
if (ssid != m_data->m_NetSsid) {
if (ssid != m_wirelessNetItem.m_NetSsid) {
return;
}
qDebug() << "Security changed! ssid = " << m_data->m_NetSsid << "; security = " << m_data->m_secuType << "." <<Q_FUNC_INFO << __LINE__;
m_data->m_secuType = securityType;
bool newSecu = (m_data->m_secuType.isEmpty() || m_data->m_secuType == "") ? false : true;
qDebug() << LOG_FLAG << "Security changed! ssid = " << m_wirelessNetItem.m_NetSsid
<< "; security = " << m_wirelessNetItem.m_secuType << "." <<Q_FUNC_INFO << __LINE__;
m_wirelessNetItem.m_secuType = securityType;
bool newSecu = (m_wirelessNetItem.m_secuType.isEmpty() || m_wirelessNetItem.m_secuType == "") ? false : true;
if (m_hasPwd^newSecu) {
m_hasPwd = newSecu;
refreshIcon();
}
return;
}
void WlanListItem::updateWirelessNetItem(KyWirelessNetItem &wirelessNetItem)
{
m_wirelessNetItem = wirelessNetItem;
return;
}
void WlanListItem::onPwdEditorTextChanged()
@ -359,18 +405,23 @@ void WlanListItem::onPwdEditorTextChanged()
if (!m_pwdLineEdit || !m_connectButton) {
return;
}
if (m_pwdLineEdit->text().length() < PWD_LENGTH_LIMIT) {
m_connectButton->setEnabled(false);
} else {
m_connectButton->setEnabled(true);
}
return;
}
void WlanListItem::onShowPwdButtonClicked()
{
qDebug()<< LOG_FLAG << "onShowPwdButtonClicked";
if (!m_pwdLineEdit) {
return;
}
if (m_pwdLineEdit->echoMode() == QLineEdit::EchoMode::Password) {
m_showPwdButton->setIcon(QIcon(":/res/h/show-pwd.png"));
m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Normal);
@ -378,74 +429,60 @@ void WlanListItem::onShowPwdButtonClicked()
m_showPwdButton->setIcon(QIcon(":/res/h/hide-pwd.png"));
m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Password);
}
return;
}
void WlanListItem::onConnectButtonClicked()
{
if (m_data->m_secuType.isEmpty() || m_data->m_secuType == "") {
qDebug() << "connect to no password wifi" << Q_FUNC_INFO << __LINE__;
} else if ((!m_connectButton->isEnabled()&&m_connectButton->isVisible()) || !m_data) {
qDebug()<< LOG_FLAG << "onConnectButtonClicked";
if (!m_connectButton->isEnabled()) {
return;
}
if ((m_state == NetworkManager::ActiveConnection::State::Activating || m_state == NetworkManager::ActiveConnection::State::Deactivating)) {
qDebug() << "On wlan clicked! But there is nothing to do because it is already activating/deactivating!" << Q_FUNC_INFO << __LINE__;
if ((Activating == m_connectState || Deactivating == m_connectState)) {
qDebug() << LOG_FLAG << "On wlan clicked! But there is nothing to do because it is already activating/deactivating!"
<< Q_FUNC_INFO << __LINE__;
return;
}
KyWirelessConnectSetting settings;
settings.m_connectName = m_data->m_NetSsid;
settings.m_ssid = m_data->m_NetSsid;
settings.m_connectName = m_wirelessNetItem.m_NetSsid;
settings.m_ssid = m_wirelessNetItem.m_NetSsid;
settings.isAutoConnect = m_autoConnectCheckBox->isChecked();
settings.m_psk = m_pwdLineEdit->text();
if (m_data->m_secuType.isEmpty() || m_data->m_secuType == "") {
qDebug() << "connect to no password wifi" << Q_FUNC_INFO << __LINE__;
settings.m_psk = m_pwdLineEdit->text();
if (m_wirelessNetItem.m_secuType.isEmpty() || m_wirelessNetItem.m_secuType == "") {
settings.m_type = WpaNone;
} else if (m_data->m_secuType.contains("WPA1") || m_data->m_secuType.contains("WPA2")) {
} else if (m_wirelessNetItem.m_secuType.contains("WPA1") || m_wirelessNetItem.m_secuType.contains("WPA2")) {
settings.m_type = WpaPsk;
} else if (m_data->m_secuType.contains("WPA3")) {
} else if (m_wirelessNetItem.m_secuType.contains("WPA3")) {
settings.m_type = SAE;
}
qDebug() << "On button connect clicked, will connect wlan. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO <<__LINE__;
emit this->connectButtonClicked(settings, false);
qDebug() << "[WlanListItem] On button connect clicked, will connect wlan. ssid = "
<< m_wirelessNetItem.m_NetSsid << Q_FUNC_INFO <<__LINE__;
m_wirelessConnectOperation->addAndActiveWirelessConnect(m_wlanDevice, settings, false);
setExpanded(false);
return;
}
void WlanListItem::onConnectionAdd(QString deviceName, QString ssid)
ConnectState WlanListItem::getConnectionState()
{
if (!m_data) {
return;
}
if (ssid == m_data->m_NetSsid && deviceName == m_wlanDevice) {
m_resource->getWifiNetwork(deviceName, ssid, *m_data);
}
return m_connectState;
}
void WlanListItem::onConnectionRemove(QString deviceName, QString ssid)
void WlanListItem::updateConnectState(ConnectState state)
{
if (!m_data) {
return;
}
if (ssid == m_data->m_NetSsid && deviceName == m_wlanDevice) {
m_resource->getWifiNetwork(deviceName, ssid, *m_data);
}
}
m_connectState = state;
void WlanListItem::onWlanStatusChange(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason)
{
QString ssid, devName;
m_resource->getSsidByUuid(uuid, ssid, devName);
//有可能配置被删了获取不到ssid,所以也可以按uuid判断解决连接中点忘记网络图标还在loading的问题
if (m_data->m_NetSsid == ssid || m_data->m_connectUuid == uuid) {
qDebug() << "[WlanPage] State changed to :" << state << Q_FUNC_INFO <<__LINE__;
m_state = state;
if ((state == NetworkManager::ActiveConnection::State::Activating || state == NetworkManager::ActiveConnection::State::Deactivating)
&& devName == m_wlanDevice) {
m_netButton->startLoading();
} else {
m_netButton->stopLoading();
}
if (Deactivated == state || Activated == state) {
m_netButton->stopLoading();
} else {
m_netButton->startLoading();
}
return;
}
void WlanListItem::onMenuTriggered(QAction *action)
@ -453,7 +490,9 @@ void WlanListItem::onMenuTriggered(QAction *action)
if (action->text() == tr("Disconnect") || action->text() == tr("Connect")) {
this->onNetButtonClicked();
} else if (action->text() == tr("Forget")) {
m_connoperation->deleteWirelessConnect(m_data->m_connectUuid);
m_wirelessConnectOperation->deleteWirelessConnect(m_wirelessNetItem.m_connectUuid);
}
return;
}

View File

@ -22,37 +22,41 @@ class WlanListItem : public ListItem
{
Q_OBJECT
public:
WlanListItem(KyWirelessNetResource *resource, KyWirelessNetItem *data, QString device, QWidget *parent = nullptr);
WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, QWidget *parent = nullptr);
WlanListItem(QWidget *parent = nullptr);
~WlanListItem();
public:
QString getSsid();
void setWlanSignal(const int &signal);
void setWlanState(const int &state);
void setExpanded(const bool &expanded);
void setWlanItemPwdVisible(const bool &expanded);
QString getSsid();
KyWirelessNetItem *m_data = nullptr;
ConnectState getConnectionState();
void updateConnectState(ConnectState state);
void updateWirelessNetSecurity(QString ssid, QString securityType);
void updateWirelessNetItem(KyWirelessNetItem &wirelessNetItem);
protected:
void resizeEvent(QResizeEvent *event);
void onRightButtonClicked();
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
bool eventFilter(QObject *watched, QEvent *event);
signals:
void itemHeightChanged(const QString &ssid);
void connectButtonClicked(KyWirelessConnectSetting &connSettingInfo, const bool &isHidden);
void itemHeightChanged(const bool isExpanded, const QString &ssid);
private:
void initWlanUI();
void initWlanConnection();
void refreshIcon();
private:
KyWirelessNetResource *m_resource = nullptr;
KyWirelessNetItem m_wirelessNetItem;
KyWirelessConnectOperation *m_wirelessConnectOperation = nullptr;
KyWirelessConnectOperation *m_connoperation = nullptr;
KyActiveConnectResourse *m_connectResource = nullptr;
bool m_hasPwd = true;
QString m_wlanDevice;
@ -63,7 +67,6 @@ private:
QLineEdit * m_pwdLineEdit = nullptr;
QHBoxLayout *m_pwdLineEditLyt = nullptr;
QPushButton *m_showPwdButton = nullptr;
QPushButton *m_connectButton = nullptr;
//自动连接选择区域UI
@ -74,28 +77,19 @@ private:
QMenu *m_menu = nullptr;
NetworkManager::ActiveConnection::State m_state;
bool m_focusIsOut = true;
bool m_mouseIsOut = true;
bool m_forgetConnection = false;
// QVBoxLayout * m_mainLayout = nullptr;
// QFrame * m_itemFrame = nullptr;
// QHBoxLayout * m_hItemLayout = nullptr;
// QLineEdit * m_lineEdit = nullptr;
protected slots:
void onInfoButtonClicked();
private slots:
// void onInfoButtonClicked();
void onNetButtonClicked();
// void onNameLableClicked();
void onSecurityChanged(QString interface, QString ssid, QString securityType);
void onPwdEditorTextChanged();
void onShowPwdButtonClicked();
void onConnectButtonClicked();
void onConnectionAdd(QString deviceName, QString ssid);
void onConnectionRemove(QString deviceName, QString ssid);
void onWlanStatusChange(QString uuid,
NetworkManager::ActiveConnection::State state,
NetworkManager::ActiveConnection::Reason reason);
void onMenuTriggered(QAction *action);
};

View File

@ -320,7 +320,7 @@ void MainWindow::resetWindowTheme()
void MainWindow::showControlCenter()
{
QProcess process;
if (m_lanWidget->m_isLanConnected == false && m_wlanWidget->m_wlanIsConnected == true){
if (!m_lanWidget->lanIsConnected() && m_wlanWidget->wlanIsConnected()){
process.startDetached("ukui-control-center --wlanconnect");
} else {
process.startDetached("ukui-control-center --wiredconnect");
@ -365,12 +365,12 @@ void MainWindow::onThemeChanged(const QString &key)
void MainWindow::onRefreshTrayIcon()
{
//更新托盘图标显示
if (m_lanWidget->m_isLanConnected == true){
if (m_lanWidget->lanIsConnected()) {
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
} else if (m_wlanWidget->m_wlanIsConnected == true && m_lanWidget->m_isLanConnected == false){
} else if (m_wlanWidget->wlanIsConnected()){
m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic"));
} else if (m_wlanWidget->m_wlanIsConnected == false && m_lanWidget->m_isLanConnected == false){
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-disconnected-symbolic"));
} else {
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
}
}
@ -525,12 +525,12 @@ void MainWindow::deactivateWired(const QString& devName, const QString& connUuid
//无线连接断开
void MainWindow::activateWireless(const QString& devName, const QString& ssid)
{
m_wlanWidget->activateWireless(devName, ssid);
m_wlanWidget->activateWirelessConnection(devName, ssid);
}
void MainWindow::deactivateWireless(const QString& devName, const QString& ssid)
{
m_wlanWidget->deactivateWireless(devName, ssid);
m_wlanWidget->deactivateWirelessConnection(devName, ssid);
}
void MainWindow::rescan()

View File

@ -1,615 +0,0 @@
#include "nmdemo.h"
#include <QTime>
#include <QTimeZone>
QString enumToQstring(NetworkManager::ActiveConnection::State state)
{
switch (state) {
case NetworkManager::ActiveConnection::State::Unknown:
return "Unknown";
break;
case NetworkManager::ActiveConnection::State::Activating:
return "Activating";
break;
case NetworkManager::ActiveConnection::State::Activated:
return "Activated";
break;
case NetworkManager::ActiveConnection::State::Deactivating:
return "Deactivating";
break;
case NetworkManager::ActiveConnection::State::Deactivated:
return "Deactivated";
break;
default:
return "";
break;
}
}
NmDemo::NmDemo(QWidget *parent) : QDialog(parent)
{
this->setFixedSize(510,810);
//init ptr
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
m_wco = new KyWirelessConnectOperation(this);
m_wnr = new KyWirelessNetResource(this);
m_acr = new KyActiveConnectResourse(this);
m_cr = new KyConnectResourse(this);
m_timer = new QTimer(this);
initUi();
appendDebugLog("init...");
initConnect();
initTimer();
appendDebugLog("init finish...");
getWifiList();
if (m_wco->getWirelessEnabled())
{
wlansStatus->setText("WLAN:ENABLE");
} else {
wlansStatus->setText("WLAN:DISABLE");
}
}
NmDemo::~NmDemo()
{
m_networkResourceInstance = nullptr;
}
void NmDemo::initUi()
{
refreshButton = new QPushButton(this);
refreshButton->setText("Refresh");
connectButton = new QPushButton(this);
connectButton->setText("Connect");
disConnectButton = new QPushButton(this);
disConnectButton->setText("DisConn");
modifyButton = new QPushButton(this);
modifyButton->setText("Modify");
enableButton = new QPushButton(this);
enableButton->setText("Enable");
disableButton = new QPushButton(this);
disableButton->setText("Disable");
addButton = new QPushButton(this);
addButton->setText("Add");
wifiList = new QTextEdit(this);
debugLog = new QTextEdit(this);
ssidText = new QLineEdit(this);
ifaceNameText = new QLineEdit(this);
pwdText = new QLineEdit(this);
wlansStatus = new QLabel(this);
ssidLabel = new QLabel(this);
ssidLabel->setText("SSID");
ifaceLabel = new QLabel(this);
ifaceLabel->setText("IfaceName");
pwdLabel = new QLabel(this);
pwdLabel->setText("password");
actConnection = new QLabel(this);
refreshButton->setGeometry( 5, 5, 80, 30);
connectButton->setGeometry(105, 5, 80, 30);
disConnectButton->setGeometry(205, 5, 80, 30);
addButton->setGeometry(305, 5 ,80 ,30);
modifyButton->setGeometry(5, 55, 80, 30);
enableButton->setGeometry(105, 55, 80, 30);
disableButton->setGeometry(205, 55, 80, 30);
wlansStatus->setGeometry(305, 55, 180, 30);
ssidLabel->setGeometry(5, 105, 80, 30);
ssidText->setGeometry(100, 105, 100, 30);
pwdLabel->setGeometry(250, 105, 80, 30);
pwdText->setGeometry(345, 105, 150, 30);
actConnection->setGeometry(250, 145, 245, 30);
ifaceLabel->setGeometry(5, 145, 80, 30);
ifaceNameText->setGeometry(100, 145, 100, 30);
wifiList->setGeometry(5, 200, 500,300);
wifiList->setReadOnly(true);
debugLog->setGeometry(5, 510, 500,300);
debugLog->setReadOnly(true);
}
void NmDemo::initConnect()
{
connect(m_wco, &KyWirelessConnectOperation::wifinEnabledChanged,[=](bool status){
QString temp;
temp.sprintf("wifinEnabledChanged %d",status);
appendDebugLog(temp);
if (status)
{
wlansStatus->setText("WLAN:ENABLE");
} else {
wlansStatus->setText("WLAN:DISABLE");
}
});
//ui button
connect(refreshButton, &QPushButton::clicked, [=](){
// appendDebugLog("init refreshButton clicked...");
// m_wco->requestWirelessScan();
getWifiList();
});
connect(connectButton, &QPushButton::clicked, this, &NmDemo::onConnectClicked);
connect(disConnectButton, &QPushButton::clicked, this, &NmDemo::onDisConnectClicked);
connect(modifyButton, &QPushButton::clicked, this, &NmDemo::onModifyClicked);
connect(enableButton, &QPushButton::clicked, this, &NmDemo::onEnableClick);
connect(disableButton, &QPushButton::clicked, this, &NmDemo::onDisableClick);
connect(addButton, &QPushButton::clicked, this, &NmDemo::onAddClick);
//连接变化
connect(m_wco, &KyWirelessConnectOperation::createConnectionError, this, &NmDemo::onWcoSignals);
connect(m_wco, &KyWirelessConnectOperation::updateConnectionError, this, &NmDemo::onWcoSignals);
connect(m_wco, &KyWirelessConnectOperation::deleteConnectionError, this, &NmDemo::onWcoSignals);
connect(m_wco, &KyWirelessConnectOperation::activateConnectionError, this, &NmDemo::onWcoSignals);
connect(m_wco, &KyWirelessConnectOperation::deactivateConnectionError, this, &NmDemo::onWcoSignals);
connect(m_wco, &KyWirelessConnectOperation::addAndActivateConnectionError, this, &NmDemo::onWcoSignals);
//列表变化
connect(m_wnr, &KyWirelessNetResource::bssidChange, this ,&NmDemo::onBssidChange);
connect(m_wnr, &KyWirelessNetResource::secuTypeChange, this ,&NmDemo::onSecuTypeChange);
connect(m_wnr, &KyWirelessNetResource::signalStrengthChange, this ,&NmDemo::onSignalStrengthChange);
connect(m_wnr, &KyWirelessNetResource::connectionRemove, this ,&NmDemo::onConnectionRemove);
connect(m_wnr, &KyWirelessNetResource::connectionAdd, this ,&NmDemo::onConnectionAdd);
connect(m_wnr, &KyWirelessNetResource::wifiNetworkUpdate, this ,&NmDemo::onWifiNetworkUpdate);
connect(m_wnr, &KyWirelessNetResource::wifiNetworkAdd, this ,&NmDemo::onWifiNetworkAdd);
connect(m_wnr, &KyWirelessNetResource::wifiNetworkRemove, this ,&NmDemo::onWifiNetworkRemove);
connect(m_acr, &KyActiveConnectResourse::stateChangeReason, this, [this](QString uuid,
NetworkManager::ActiveConnection::State state,
NetworkManager::ActiveConnection::Reason reason){
appendDebugLog(QString("%1 %2 %3").arg(uuid).arg(state).arg(reason));
});
}
void NmDemo::initTimer()
{
//30s扫描一次wifi
m_timer->setTimerType(Qt::PreciseTimer);
QObject::connect(m_timer, &QTimer::timeout, [=](){
m_wco->requestWirelessScan();
getWifiList();
});
m_timer->start(30*1000);
}
void NmDemo::onWcoSignals(QString errorMessage)
{
appendDebugLog(errorMessage);
}
void NmDemo::onBssidChange(QString devIface, QString ssid, QString bssid)
{
appendDebugLog(ssid + " belongs to " + devIface + " bssid change to " + bssid);
}
void NmDemo::onSecuTypeChange(QString devIface, QString ssid, QString secuType)
{
appendDebugLog(ssid + " belongs to " + devIface + " security change to " + secuType);
}
void NmDemo::onSignalStrengthChange(QString devIface , QString ssid, int signal)
{
appendDebugLog(ssid + " belongs to " + devIface + " SignalStrength change to " + QString::number(signal));
}
void NmDemo::onConnectionRemove(QString devIface, QString ssid)
{
appendDebugLog("onConnectionRemove..." + devIface + " " + ssid);
getWifiList();
}
void NmDemo::onConnectionAdd(QString devIface, QString ssid)
{
appendDebugLog("onConnectionAdd..." + devIface + " " + ssid);
getWifiList();
}
void NmDemo::onWifiNetworkAdd(QString devIface, KyWirelessNetItem& item)
{
appendDebugLog("onWifiNetworkAdd..." + devIface + " " + item.m_NetSsid);
getWifiList();
}
void NmDemo::onWifiNetworkRemove(QString devIface, QString ssid)
{
appendDebugLog("onWifiNetworkRemove..." + devIface + " " + ssid);
getWifiList();
}
void NmDemo::onWifiNetworkUpdate()
{
appendDebugLog("onWifiNetworkUpdate...");
getWifiList();
}
void NmDemo::onConnectClicked()
{
appendDebugLog("onConnectClicked...");
QString ssid = ssidText->text();
QString devIface = ifaceNameText->text();
QString pwd = pwdText->text();
QString uuid;
bool isNew = true;
bool isHidden = true;
bool isEnterPirse = false;
appendDebugLog("about to connect " + ssid + " " + devIface + " " + pwd);
QList<KyWirelessNetItem> list;
m_wnr->getDeviceWifiNetwork(devIface, list);
appendDebugLog("agetDeviceWifiNetwork " + devIface + " size: " + QString::number(list.size()));
QList<KyWirelessNetItem>::iterator iter = list.begin();
while (iter != list.end())
{
if (iter->m_NetSsid == ssid)
{
isHidden = false;
QString secuType = iter->m_secuType;
qDebug() << secuType;
if (secuType.indexOf("802.1X") >= 0)
{
isEnterPirse = true;
}
if (iter->m_isConfigured == true)
{
isNew = false;
uuid = iter->m_connectUuid;
}
}
iter++;
}
if (isEnterPirse)
{
if(!isNew)
{
KyEapMethodPeapInfo a;
a.phase2AuthMethod = KyAuthMethodMschapv2;
a.userName = "steve";
a.userPWD = "testing";
appendDebugLog("modifyEnterPriseInfoPeap");
appendDebugLog("activeWirelessConnect...");
m_wco->activeWirelessConnect(devIface,uuid);
return;
} else {
KyEapMethodPeapInfo c;
c.m_passwdFlag = NetworkManager::Setting::SecretFlagType::None;
c.phase2AuthMethod = KyAuthMethodMschapv2;
c.userName = "steve";
c.userPWD = "testing";
KyWirelessConnectSetting a;
a.m_connectName = ssid;
a.m_ssid = ssid;
a.isAutoConnect = true;
a.m_type = WpaEap;
appendDebugLog("addAndActiveWirelessEnterPriseTtlsConnect...");
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect";
// m_wco->addAndActiveWirelessEnterPriseTtlsConnect(c, devIface, isHidden, true, 0);
m_wco->addAndActiveWirelessEnterPrisePeapConnect(c, a, devIface, false);
return;
}
}
if (isNew)
{
appendDebugLog("addAndActiveWirelessConnect...");
KyWirelessConnectSetting a;
a.m_connectName = ssid;
a.m_ssid = ssid;
a.isAutoConnect = true;
a.m_psk = pwd;
a.m_type = WpaNone;
m_wco->addAndActiveWirelessConnect(devIface,a, isHidden);
} else {
// NetworkManager::Setting::SecretFlags c;
// m_wco->getConnSecretFlags(uuid, c);
// appendDebugLog(QString("%1").arg(c));
appendDebugLog("activeWirelessConnect...");
m_wco->activeWirelessConnect(devIface,uuid);
}
}
void NmDemo::onDisConnectClicked()
{
appendDebugLog("onDisConnectClicked...");
QString ssid = ssidText->text();
QString devIface = ifaceNameText->text();
QString uuid;
bool isFind = false;
QList<KyWirelessNetItem> list;
m_wnr->getDeviceWifiNetwork(devIface, list);
QList<KyWirelessNetItem>::iterator iter = list.begin();
while (iter != list.end())
{
if (iter->m_NetSsid == ssid)
{
if (iter->m_isConfigured == true)
{
isFind = true;
uuid = iter->m_connectUuid;
break;
}
}
iter++;
}
if (!isFind)
{
return;
}
appendDebugLog("deActiveWirelessConnect " + ssid);
m_wco->deActivateWirelessConnection(ssid, uuid);
}
void NmDemo::onModifyClicked()
{
appendDebugLog("onModifyClicked...");
QString ssid = ssidText->text();
QString devIface = ifaceNameText->text();
QString uuid;
bool isFind = false;
QList<KyWirelessNetItem> list;
m_wnr->getDeviceWifiNetwork(devIface, list);
QList<KyWirelessNetItem>::iterator iter = list.begin();
while (iter != list.end())
{
if (iter->m_NetSsid == ssid)
{
if (iter->m_isConfigured == true)
{
isFind = true;
uuid = iter->m_connectUuid;
break;
}
}
iter++;
}
if (!isFind)
{
return;
}
// KyEapMethodTtlsInfo info;
// m_wco->updateWirelessEnterPriseTtlsConnect(uuid, info);
// QString psk = m_wco->getPsk(uuid);
// appendDebugLog(ssid +" getPsk is " + psk);
// return;
appendDebugLog("getConnectKeyMgmt" + QString::number(m_wco->getConnectKeyMgmt(uuid)));
KyWirelessConnectSetting wcs;
wcs.m_type = WpaPsk;
wcs.m_psk = "123456zsx";
m_wco->updateWirelessPersonalConnect(uuid, wcs ,true);
appendDebugLog("getConnectKeyMgmt" + QString::number(m_wco->getConnectKeyMgmt(uuid)));
return;
m_wco->setWirelessAutoConnect(uuid, false);
return;
KyConnectSetting sett;
showIpv4Ipv6DnsInfo(uuid, sett);
sett.m_ipv4ConfigIpType = CONFIG_IP_MANUAL;
sett.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL);
sett.m_ipv4Address.clear();
QStringList ipv4DnsList;
ipv4DnsList << "1.1.1.1";
QString a("192.168.1.17"),b("255.255.255.0"),c("192.168.1.0");
sett.ipv4AddressConstruct(a, b, c, ipv4DnsList);
// sett.setIpConfigType(IPADDRESS_V6, CONFIG_IP_MANUAL);
// QStringList ipv6DnsList;
// ipv6DnsList << "1.1.1.1";
// QString d("1.1.1.1"),e("1.1.1.1"),f("1.1.1.1");
// sett.ipv6AddressConstruct(d, e, f, ipv6DnsList);
m_wco->updateIpv4AndIpv6SettingInfo(uuid, sett);
showIpv4Ipv6DnsInfo(uuid, sett);
}
void NmDemo::showIpv4Ipv6DnsInfo(const QString &uuid, KyConnectSetting &settInfo)
{
m_cr->getConnectionSetting(uuid, settInfo);
appendDebugLog("connect setting info:");
appendDebugLog("connect name " + settInfo.m_connectName);
appendDebugLog("iface name " + settInfo.m_ifaceName);
appendDebugLog("ipv4 type " + QString::number(settInfo.m_ipv4ConfigIpType));
for (int index = 0 ; index < settInfo.m_ipv4Address.size(); index++) {
appendDebugLog("ipv4 address " + settInfo.m_ipv4Address.at(index).ip().toString());
appendDebugLog("ipv4 gate way " + settInfo.m_ipv4Address.at(index).gateway().toString());
appendDebugLog("ipv4 net mask " + settInfo.m_ipv4Address.at(index).netmask().toString());
}
for (int index = 0; index < settInfo.m_ipv4Dns.size(); ++index) {
appendDebugLog("ipv4 dns " + settInfo.m_ipv4Dns.at(index).toString());
}
appendDebugLog("ipv6 type " + QString::number(settInfo.m_ipv6ConfigIpType));
for (int index = 0 ; index < settInfo.m_ipv6Address.size(); index++) {
appendDebugLog("ipv6 address " + settInfo.m_ipv6Address.at(index).ip().toString());
appendDebugLog("ipv6 gate way " + settInfo.m_ipv6Address.at(index).gateway().toString());
appendDebugLog("ipv6 net mask " + settInfo.m_ipv6Address.at(index).netmask().toString());
}
for (int index = 0; index < settInfo.m_ipv6Dns.size(); ++index) {
appendDebugLog("ipv6 dns " + settInfo.m_ipv6Dns.at(index).toString());
}
QString ipv4,ipv6;
QList<QHostAddress> ipv4Dns,ipv6Dns;
ipv4Dns.clear();
ipv6Dns.clear();
m_acr->getActiveConnectIpInfo(uuid, ipv4, ipv6);
appendDebugLog("Dynamic ipv4 address " + ipv4);
appendDebugLog("Dynamic ipv6 address " + ipv6);
m_acr->getActiveConnectDnsInfo(uuid, ipv4Dns, ipv6Dns);
appendDebugLog(QString::number(ipv4Dns.size()) + QString::number(ipv6Dns.size()));
for (int index = 0 ; index < ipv4Dns.size(); index++) {
appendDebugLog("Dynamic ipv4 dns " + ipv4Dns.at(index).toString());
}
for (int index = 0 ; index < ipv6Dns.size(); index++) {
appendDebugLog("Dynamic ipv6 dns " + ipv6Dns.at(index).toString());
}
}
void NmDemo::onEnableClick()
{
appendDebugLog("onEanbleClick...");
m_wco->setWirelessEnabled(true);
}
void NmDemo::onDisableClick()
{
appendDebugLog("onDisableClick...");
m_wco->setWirelessEnabled(false);
}
void NmDemo::onAddClick()
{
appendDebugLog("onAddClick...");
KyWirelessConnectSetting sett;
sett.m_connectName = "test";
sett.m_ssid = "test";
sett.isAutoConnect = false;
sett.m_psk = "";
sett.m_type = WpaEap;
// //ipv4
sett.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP);
// QString ipv4Address("192.168.1.17"), ipv4NetMask("255.255.255.0"), ipv4GateWay("192.168.1.0");
// QStringList list;
// list << "127.17.50.100";
// sett.ipv4AddressConstruct(ipv4Address, ipv4NetMask, ipv4GateWay, list);
// m_wco->addConnect(sett);
KyEapMethodPeapInfo peap;
peap.phase2AuthMethod = KyAuthMethodMschapv2;
peap.userName = "steve";
peap.userPWD = "testing";
m_wco->addPeapConnect(sett,peap);
}
void NmDemo::appendDebugLog(QString log)
{
QTimeZone timeZone(QString::fromLatin1(QTimeZone::systemTimeZoneId()).toLatin1());
QDateTime tzNow = QDateTime::currentDateTime().toTimeZone(timeZone);
QString time= tzNow.toString("hh:mm:ss AP");
debugLog->append(time + "===="+ log);
qDebug() << log;
}
void NmDemo::onActiveConnectionAdd(NetworkManager::ActiveConnection::Ptr conn)
{
if (conn->type() != NetworkManager::ConnectionSettings::ConnectionType::Wireless)
{
return;
}
appendDebugLog(conn->id()+ " " + enumToQstring(conn->state()));
actConnection->setText(conn->id()+ " " + enumToQstring(conn->state()));
}
void NmDemo::onActiveConnectionUpdate(NetworkManager::ActiveConnection * conn)
{
if (conn->type() != NetworkManager::ConnectionSettings::ConnectionType::Wireless)
{
return;
}
appendDebugLog(conn->id()+ " " + enumToQstring(conn->state()));
actConnection->setText(conn->id()+ " " + enumToQstring(conn->state()));
}
void NmDemo::onActiveConnectionRemove(NetworkManager::ActiveConnection * conn)
{
if (conn->type() != NetworkManager::ConnectionSettings::ConnectionType::Wireless)
{
return;
}
appendDebugLog(conn->id()+ " " + enumToQstring(conn->state()));
actConnection->setText(conn->id()+ " " + enumToQstring(conn->state()));
}
void NmDemo::onActiveConnectionsReset()
{
appendDebugLog("onActiveConnectionsReset");
}
void NmDemo::getWifiList()
{
qDebug() << "getWifiList";
wifiList->clear();
QMap<QString,QStringList> actMap;
m_wnr->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap);
appendDebugLog("getWirelessActiveConnection Activated " +QString::number(actMap.size()));
QMap<QString,QStringList>::iterator iter1 = actMap.begin();
while (iter1 != actMap.end())
{
wifiList->append(iter1.key());
for (int i = 0; i < iter1->size(); i++)
{
wifiList->append("Activated" + iter1->at(i));
}
wifiList->append("====================================");
iter1++;
}
m_wnr->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activating, actMap);
appendDebugLog("getWirelessActiveConnection Activating " +QString::number(actMap.size()));
QMap<QString,QStringList>::iterator iter2 = actMap.begin();
while (iter2 != actMap.end())
{
wifiList->append(iter2.key());
for (int i = 0; i < iter2->size(); i++)
{
wifiList->append("Activating" + iter2->at(i));
}
wifiList->append("====================================");
iter2++;
}
m_wnr->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Deactivating, actMap);
appendDebugLog("getWirelessActiveConnection Deactivating " +QString::number(actMap.size()));
m_wnr->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Deactivated, actMap);
appendDebugLog("getWirelessActiveConnection Deactivated " +QString::number(actMap.size()));
QMap<QString, QList<KyWirelessNetItem> > map;
if (!m_wnr->getAllDeviceWifiNetwork(map))
{
return;
}
QMap<QString, QList<KyWirelessNetItem> >::iterator iter = map.begin();
while (iter != map.end())
{
qDebug() << iter.key() << iter.value().size();
for (int i = 0; i < iter.value().size(); i++)
{
qDebug() << iter.value().at(i).m_NetSsid;
wifiList->append("SSID: " + iter.value().at(i).m_NetSsid + " Configed: " + QString::number(iter.value().at(i).m_isConfigured));
wifiList->append("frequency: " + QString::number(iter.value().at(i).m_frequency));
wifiList->append("signalStrength: " + QString::number(iter.value().at(i).m_signalStrength));
QString security = iter.value().at(i).m_secuType;
if (security.isEmpty())
{
security = "NONE";
}
wifiList->append("security: " + security);
wifiList->append("MAC: " + iter.value().at(i).m_bssid);
wifiList->append("====================================");
}
iter++;
}
}

View File

@ -1,93 +0,0 @@
#ifndef NMDEMO_H
#define NMDEMO_H
#include <QDialog>
#include <QPushButton>
#include <QTextEdit>
#include <QTimer>
#include <QLineEdit>
#include <QLabel>
#include "backend/dbus-interface/kylinnetworkresourcemanager.h"
#include "backend/dbus-interface/kywirelessconnectoperation.h"
#include "backend/dbus-interface/kywirelessnetresource.h"
#include "backend/dbus-interface/kylinactiveconnectresource.h"
#include "backend/dbus-interface/kylinconnectresource.h"
#include "backend/dbus-interface/kylinactiveconnectresource.h"
class NmDemo : public QDialog
{
Q_OBJECT
public:
QPushButton *refreshButton;
QPushButton *connectButton;
QPushButton *disConnectButton;
QPushButton *modifyButton;
QPushButton *enableButton;
QPushButton *disableButton;
QPushButton *addButton;
QTextEdit *wifiList;
QTextEdit *debugLog;
QLabel *ssidLabel;
QLabel *ifaceLabel;
QLabel *wlansStatus;
QLabel *pwdLabel;
QLabel *actConnection;
QLineEdit *ssidText;
QLineEdit *ifaceNameText;
QLineEdit *pwdText;
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
KyWirelessConnectOperation *m_wco;
KyWirelessNetResource *m_wnr;
KyActiveConnectResourse *m_acr;
KyConnectResourse *m_cr;
private:
QTimer *m_timer;
public:
explicit NmDemo(QWidget *parent = nullptr);
~NmDemo();
private:
void initUi();
void initConnect();
void initTimer();
void appendDebugLog(QString);
void getWifiList();
void showIpv4Ipv6DnsInfo(const QString &uuid, KyConnectSetting &sett);
public slots:
void onWcoSignals(QString);
void onBssidChange(QString, QString, QString);
void onSecuTypeChange(QString, QString, QString);
void onSignalStrengthChange(QString, QString, int);
void onConnectionRemove(QString, QString);
void onConnectionAdd(QString, QString);
void onWifiNetworkAdd(QString, KyWirelessNetItem&);
void onWifiNetworkRemove(QString, QString);
void onWifiNetworkUpdate();
void onConnectClicked();
void onDisConnectClicked();
void onModifyClicked();
void onEnableClick();
void onDisableClick();
void onAddClick();
void onActiveConnectionAdd(NetworkManager::ActiveConnection::Ptr conn);
void onActiveConnectionUpdate(NetworkManager::ActiveConnection * conn);
void onActiveConnectionRemove(NetworkManager::ActiveConnection * conn);
void onActiveConnectionsReset();
signals:
};
#endif // NMDEMO_H

View File

@ -474,6 +474,7 @@ void LanPage::addDeviceForCombox(QString deviceName)
//2、有多快网卡但是没有使能
m_deviceFrame->hide();
m_currentDeviceName = deviceName;
setDefaultDevice(WIRED, m_currentDeviceName);
} else if (2 == m_enableDeviceList.count()) {
//3、现在有且只有一块网卡并已使能
//4、有多快网卡且使能了其中一块
@ -512,7 +513,6 @@ void LanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type devic
addDeviceForCombox(deviceName);
if (m_currentDeviceName == deviceName) {
setDefaultDevice(WIRED, m_currentDeviceName);
initLanArea();
}
@ -788,16 +788,13 @@ void LanPage::onUpdateLanlist(QString uuid,
if (state == NetworkManager::ActiveConnection::State::Activated) {
updateActivatedConnectionArea(uuid);
m_isLanConnected = true;
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
updateConnectionArea(uuid);
m_isLanConnected = false;
} else if (state == NetworkManager::ActiveConnection::State::Activating
|| state == NetworkManager::ActiveConnection::State::Deactivating) {
QString devName = m_activeResourse->getDeviceOfActivateConnect(uuid);
if (devName.isEmpty()) {
NetworkManager::ConnectionSettings::ConnectionType type;
m_connectResourse->getInterfaceByUuid(devName, type, uuid);
m_connectResourse->getInterfaceByUuid(devName, uuid);
}
emit lanActiveConnectionStateChanged(devName, uuid, state);
}
@ -1086,3 +1083,16 @@ void LanPage::showDetailPage(QString devName, QString uuid)
p_item = nullptr;
}
bool LanPage::lanIsConnected()
{
if (m_activeMap.isEmpty()) {
return false;
} else {
KyConnectItem *p_connectItem = m_activeMap.firstKey();
if (p_connectItem->m_connectUuid == INVALID_CONNECT_UUID) {
return false;
}
}
return true;
}

View File

@ -23,7 +23,6 @@ class LanPage : public TabPage
public:
explicit LanPage(QWidget *parent = nullptr);
~LanPage();
bool m_isLanConnected = false;
//for dbus
void getWiredList(QMap<QString, QVector<QStringList> > &map);
@ -32,6 +31,8 @@ public:
void showDetailPage(QString devName, QString uuid);
void setWiredDeviceEnable(const QString& devName, bool enable);
bool lanIsConnected();
protected:
bool eventFilter(QObject *watched, QEvent *event);

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,6 @@ class WlanPage : public TabPage
public:
explicit WlanPage(QWidget *parent = nullptr);
~WlanPage() = default;
bool m_wlanIsConnected = false;
//for dbus
void getWirelessList(QMap<QString, QVector<QStringList> > &map);
@ -36,14 +35,17 @@ public:
void deactiveWirelessAp(const QString apName, const QString uuid);
//获取热点
void getStoredApInfo(QStringList &list);
void getApInfoBySsid(QString devName, QString ssid, QStringList &list);
void activateWireless(const QString& devName, const QString& ssid);
void deactivateWireless(const QString& devName, const QString& ssid);
//无线总开关
void setWirelessSwitchEnable(bool enable);
void activateWirelessConnection(const QString& devName, const QString& ssid);
void deactivateWirelessConnection(const QString& devName, const QString& ssid);
void showDetailPage(QString devName, QString uuid);
bool wlanIsConnected();
void getApInfoBySsid(QString devName, QString ssid, QStringList &list);
//无线总开关
void setWirelessSwitchEnable(bool enable);
void getWirelessDeviceCap(QMap<QString, int> &map);
signals:
@ -60,82 +62,108 @@ signals:
public slots:
void onMainWindowVisibleChanged(const bool &visible);
void onSecurityTypeChange(QString devName, QString ssid, QString secuType);
void requestScan();
private slots:
void onWlanAdded(QString interface, KyWirelessNetItem &item);
void onWlanRemoved(QString interface, QString ssid);
void onConnectionAdd(QString deviceName, QString ssid);
void onConnectionRemove(QString deviceName, QString ssid);
void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType);
void onDeviceRemove(QString deviceName);
void onDeviceNameUpdate(QString oldName, QString newName);
void onConnectionStateChanged(QString uuid,
NetworkManager::ActiveConnection::State state,
NetworkManager::ActiveConnection::Reason reason);
void onItemHeightChanged(const bool isExpanded, const QString &ssid);
void onWlanSwitchClicked();
void onWlanSwithGsettingsChanged(const QString &key);
void onDeviceComboxIndexChanged(int currentIndex);
void onHiddenWlanClicked();
void showControlCenter();
void onWifiEnabledChanged(bool isWifiOn);
void onRefreshIconTimer();
protected:
bool eventFilter(QObject *watched, QEvent *event);
private:
void initWlanUI();
void initConnections();
int getIndexByStrength(QString interface, QString ssid);
void updateByStrength();
QString m_activedssid;
QString m_disconnectuuid;
int m_disconnecting;
bool m_disconnectingflag = false;
//定时触发扫描的定时器
void initTimer();
QTimer * m_scanTimer = nullptr;
QTimer * m_refreshIconTimer = nullptr;
void initWlanUI();
void initConnections();
void initDevice();//初始化默认设备
void initDeviceCombox();
void initWlanSwitchState();
void initWlanArea();
void getActiveWlan();
void appendActiveWlan(const QString &uuid, int &height);
void getAllWlan();
QListWidgetItem *addEmptyItem(QListWidget *wirelessListWidget);
QListWidgetItem *addNewItem(KyWirelessNetItem &wirelessNetItem,
QListWidget *wirelessListWidget);
QListWidgetItem *insertNewItem(KyWirelessNetItem &wirelessNetItem,
QListWidget *wirelessListWidget,
int row);
void clearWirelessNetItemMap(QMap<QString, QListWidgetItem*> &wirelessNetItem,
QListWidget *wirelessListWidget);
void deleteWirelessItemFormMap(QMap<QString, QListWidgetItem*> &wirelessNetItemMap,
QListWidget *wirelessListWidget, QString ssid);
void updateWlanItemState(QListWidget *p_wirelessListWidget,
QListWidgetItem *p_listWidgetItem,
ConnectState state);
void updateWlanListItem(QString ssid);
void constructWirelessNetArea();
void constructActivateConnectionArea();
void updateActivatedArea(QString uuid, QString ssid, QString devName);
void updateWirelessNetArea(QString uuid, QString ssid, QString devName);
void addDeviceToCombox(QString deviceName);
void deleteDeviceFromCombox(QString deviceName);
void updateDeviceForCombox(QString oldDeviceName, QString newDeviceName);
void sendApStateChangeSignal(QString uuid, QString ssid, QString deviceName,
NetworkManager::ActiveConnection::State state);
void wlanShowNotify(QString ssid, NetworkManager::ActiveConnection::State state,
NetworkManager::ActiveConnection::Reason reason);
private:
QMap<QString, QListWidgetItem*> m_wirelessNetItemMap;
QMap<QString, QListWidgetItem*> m_activateConnectionItemMap;
QMap<QString, QPair<QListWidgetItem*, WlanListItem*>> m_itemsMap;
QListWidgetItem *m_expandedItem = nullptr;
WlanListItem *m_wlanExpandedItem = nullptr;
QFrame * m_inactivatedWlanListAreaCentralWidget = nullptr;
QVBoxLayout * m_inactivatedWlanListAreaLayout = nullptr;
QFrame * m_hiddenWlanWidget = nullptr;
QHBoxLayout * m_hiddenWlanLayout = nullptr;
QListWidget * m_activatedNetListWidget = nullptr;
QLabel * m_hiddenWlanLabel = nullptr;
QString m_activatedWlanSSid;
QString m_activatedWlanUuid;
QStringList m_devList;
QListWidget * m_activatedNetListWidget = nullptr;
KyWirelessNetResource *m_resource = nullptr;
KyActiveConnectResourse *m_connectResource = nullptr;
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
QStringList m_devList;
QString m_currentDevice;
KyWirelessNetResource *m_wirelessNetResource = nullptr;
KyActiveConnectResourse *m_activatedConnectResource = nullptr;
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
KyWirelessConnectOperation * m_wirelessConnectOpreation = nullptr;
KyConnectOperation *m_connectoperation = nullptr;
KyConnectResourse * m_apConnectResource = nullptr;
KyConnectResourse * m_connectResource = nullptr;
QGSettings *m_switchGsettings = nullptr;
bool m_wlanSwitchEnable = true;
private slots:
void onWlanAdded(QString interface, KyWirelessNetItem &item);
void onWlanRemoved(QString interface, QString ssid);
void onWlanUpdated();
void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType);
void onDeviceRemove(QString deviceName);
void onDeviceNameUpdate(QString oldName, QString newName);
void onActivatedWlanChanged(QString uuid,
NetworkManager::ActiveConnection::State state,
NetworkManager::ActiveConnection::Reason reason);
void onItemHeightChanged(const QString &ssid);
void onConnectButtonClicked(KyWirelessConnectSetting &connSettingInfo, const bool &isHidden);
void onWlanSwitchClicked();
void onWlanSwitchStatusChanged(const bool &checked);
void onDeviceComboxIndexChanged(int currentIndex);
void onHiddenWlanClicked();
void showControlCenter();
void onWifiEnabledChanged(bool isWifiOn);
void onActiveFailed(QString errorMessage);
// void onRefreshIconTimer();
// void onsignalStrengthChange(QString, QString, int);
QTimer *m_scanTimer = nullptr;
QTimer *m_refreshIconTimer = nullptr;
};
#endif // WLANPAGE_H