modify:1)delete invalide files.
2) update wlan item state failed. 3) the ui show failed, when wireless device is empty.
This commit is contained in:
parent
ef51c826f5
commit
801b403973
|
@ -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
|
|
@ -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
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef LANLISTITEM_H
|
||||
#define LANLISTITEM_H
|
||||
#include "listitem.h"
|
||||
#include "kylinwiredwidget.h"
|
||||
#include "kylinactiveconnectresource.h"
|
||||
|
||||
#include <QDBusInterface>
|
||||
|
|
|
@ -10,7 +10,6 @@ WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, Q
|
|||
{
|
||||
m_wlanDevice = device;
|
||||
m_wirelessNetItem = wirelessNetItem;
|
||||
m_forgetConnection = false;
|
||||
|
||||
qDebug()<<"[WlanPage] wlan list item is created." << m_wirelessNetItem.m_NetSsid;
|
||||
|
||||
|
@ -132,14 +131,14 @@ void WlanListItem::onRightButtonClicked()
|
|||
|
||||
void WlanListItem::enterEvent(QEvent *event)
|
||||
{
|
||||
qDebug()<< LOG_FLAG <<"enterEvent" << m_wirelessNetItem.m_NetSsid;
|
||||
//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;
|
||||
//qDebug()<< LOG_FLAG <<"leaveEvent"<< m_wirelessNetItem.m_NetSsid;
|
||||
m_mouseIsOut = true;
|
||||
if (m_pwdFrame && m_pwdFrame->isVisible()) {
|
||||
if (m_focusIsOut) {
|
||||
|
@ -156,12 +155,12 @@ 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;
|
||||
//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;
|
||||
//qDebug()<< LOG_FLAG <<"focusInEvent" << m_wirelessNetItem.m_NetSsid;
|
||||
m_focusIsOut = false;
|
||||
}
|
||||
}
|
||||
|
@ -477,16 +476,6 @@ void WlanListItem::updateConnectState(ConnectState state)
|
|||
{
|
||||
m_connectState = state;
|
||||
|
||||
if (m_forgetConnection) {
|
||||
/*
|
||||
* 如果是要删除链接而导致的状态变化的话,等断开连接后,删除该链接
|
||||
*/
|
||||
if (state == Deactivated) {
|
||||
m_wirelessConnectOperation->deleteWirelessConnect(m_wirelessNetItem.m_connectUuid);
|
||||
m_forgetConnection = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Deactivated == state || Activated == state) {
|
||||
m_netButton->stopLoading();
|
||||
} else {
|
||||
|
@ -501,15 +490,7 @@ void WlanListItem::onMenuTriggered(QAction *action)
|
|||
if (action->text() == tr("Disconnect") || action->text() == tr("Connect")) {
|
||||
this->onNetButtonClicked();
|
||||
} else if (action->text() == tr("Forget")) {
|
||||
/*
|
||||
*对于激活的链接,忘记密码时,需要先断开连接,然后再删除链接。
|
||||
*/
|
||||
if (Activated == m_connectState) {
|
||||
m_forgetConnection = true;
|
||||
m_wirelessConnectOperation->deActivateWirelessConnection(m_wlanDevice, m_wirelessNetItem.m_connectUuid);
|
||||
} else {
|
||||
m_wirelessConnectOperation->deleteWirelessConnect(m_wirelessNetItem.m_connectUuid);
|
||||
}
|
||||
m_wirelessConnectOperation->deleteWirelessConnect(m_wirelessNetItem.m_connectUuid);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -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::wifiEnabledChanged,[=](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++;
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -57,6 +57,7 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e)
|
|||
emit this->hiddenWlanClicked();
|
||||
} else if (w == m_settingsLabel) {
|
||||
//ZJP_TODO 打开控制面板
|
||||
qDebug() << LOG_FLAG <<"recive event show control center";
|
||||
showControlCenter();
|
||||
}
|
||||
}
|
||||
|
@ -537,6 +538,9 @@ void WlanPage::onConnectionRemove(QString deviceName, QString ssid)
|
|||
{
|
||||
qDebug() << LOG_FLAG << "one connection is removed, it's ssid " << ssid << "device name"<< deviceName;
|
||||
if (deviceName == m_currentDevice) {
|
||||
if (m_activateConnectionItemMap.contains(ssid)) {
|
||||
updateWirelessNetArea(nullptr, ssid, deviceName);
|
||||
}
|
||||
updateWlanListItem(ssid);
|
||||
}
|
||||
|
||||
|
@ -548,6 +552,8 @@ void WlanPage::onSecurityTypeChange(QString devName, QString ssid, QString secuT
|
|||
QListWidgetItem *p_listWidgetItem = nullptr;
|
||||
WlanListItem *p_wlanItem = nullptr;
|
||||
|
||||
qDebug()<< LOG_FLAG << "security type is chenged";
|
||||
|
||||
if (m_wirelessNetItemMap.contains(ssid)) {
|
||||
p_listWidgetItem = m_wirelessNetItemMap.value(ssid);
|
||||
p_wlanItem = (WlanListItem*)m_inactivatedNetListWidget->itemWidget(p_listWidgetItem);
|
||||
|
@ -626,9 +632,9 @@ void WlanPage::deleteDeviceFromCombox(QString deviceName)
|
|||
|
||||
if (m_wlanSwitchEnable) {
|
||||
if (0 == m_devList.count()) {
|
||||
m_deviceFrame->show();
|
||||
m_tipsLabel->show();
|
||||
m_deviceComboBox->hide();
|
||||
m_deviceFrame->hide();
|
||||
//m_tipsLabel->show();
|
||||
//m_deviceComboBox->hide();
|
||||
m_currentDevice = "";
|
||||
setDefaultDevice(WIRELESS, m_currentDevice);
|
||||
} else if (1 == m_devList.count()) {
|
||||
|
@ -736,7 +742,7 @@ void WlanPage::sendApStateChangeSignal(QString uuid,
|
|||
return;
|
||||
}
|
||||
|
||||
void WlanPage::wlanShowNotify(NetworkManager::ActiveConnection::State state,
|
||||
void WlanPage::wlanShowNotify(QString ssid, NetworkManager::ActiveConnection::State state,
|
||||
NetworkManager::ActiveConnection::Reason reason)
|
||||
{
|
||||
if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
||||
|
@ -775,7 +781,6 @@ void WlanPage::updateActivatedArea(QString uuid, QString ssid, QString devName)
|
|||
deleteWirelessItemFormMap(m_activateConnectionItemMap, m_activatedNetListWidget, EMPTY_SSID);
|
||||
QListWidgetItem *p_listWidgetItem = addNewItem(wirelessNetItem, m_activatedNetListWidget);
|
||||
m_activateConnectionItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem);
|
||||
updateWlanItemState(m_activatedNetListWidget, p_listWidgetItem, Activated);
|
||||
|
||||
m_activatedNetListWidget->setFixedHeight(p_listWidgetItem->sizeHint().height());
|
||||
|
||||
|
@ -795,14 +800,6 @@ void WlanPage::updateWirelessNetArea(QString uuid, QString ssid, QString devName
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
*此处更新状态是针对激活的链接忘记密码的操作。
|
||||
*/
|
||||
QListWidgetItem *p_activelistItem = m_activateConnectionItemMap.value(ssid);
|
||||
if (nullptr != p_activelistItem) {
|
||||
updateWlanItemState(m_activatedNetListWidget, p_activelistItem, Deactivated);
|
||||
}
|
||||
|
||||
deleteWirelessItemFormMap(m_activateConnectionItemMap, m_activatedNetListWidget, ssid);
|
||||
QListWidgetItem *p_activeListWidgetItem = addEmptyItem(m_activatedNetListWidget);
|
||||
m_activateConnectionItemMap.insert(EMPTY_SSID, p_activeListWidgetItem);
|
||||
|
@ -810,7 +807,6 @@ void WlanPage::updateWirelessNetArea(QString uuid, QString ssid, QString devName
|
|||
|
||||
QListWidgetItem *p_listWidgetItem = addNewItem(wirelessNetItem, m_inactivatedNetListWidget);
|
||||
m_wirelessNetItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem);
|
||||
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
|
||||
|
||||
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height()
|
||||
+ p_listWidgetItem->sizeHint().height() + NET_LIST_SPACING);
|
||||
|
@ -842,7 +838,7 @@ void WlanPage::onConnectionStateChanged(QString uuid,
|
|||
emit wlanActiveConnectionStateChanged(devName, ssid,uuid, state);
|
||||
|
||||
sendApStateChangeSignal(uuid, ssid, devName, state);
|
||||
wlanShowNotify(state, reason);
|
||||
wlanShowNotify(ssid, state, reason);
|
||||
|
||||
if (devName != m_currentDevice) {
|
||||
return;
|
||||
|
@ -852,19 +848,25 @@ void WlanPage::onConnectionStateChanged(QString uuid,
|
|||
<< "; state = " << state << "; reason = " << reason << Q_FUNC_INFO <<__LINE__;
|
||||
if (state == NetworkManager::ActiveConnection::State::Activated) {
|
||||
updateActivatedArea(uuid, ssid, devName);
|
||||
if (m_activateConnectionItemMap.contains(ssid)) {
|
||||
QListWidgetItem *p_listWidgetItem = m_activateConnectionItemMap.value(ssid);
|
||||
updateWlanItemState(m_activatedNetListWidget, p_listWidgetItem, Activated);
|
||||
}
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
||||
updateWirelessNetArea(uuid, ssid, devName);
|
||||
if (m_wirelessNetItemMap.contains(ssid)) {
|
||||
QListWidgetItem *p_listWidgetItem = m_wirelessNetItemMap.value(ssid);
|
||||
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
|
||||
}
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Deactivating){
|
||||
if (m_activateConnectionItemMap.contains(ssid)) {
|
||||
QListWidgetItem *p_listWidgetItem = m_activateConnectionItemMap.value(ssid);
|
||||
WlanListItem *p_wlanItem = (WlanListItem*)m_activatedNetListWidget->itemWidget(p_listWidgetItem);
|
||||
p_wlanItem->updateConnectState(Deactivating);
|
||||
updateWlanItemState(m_activatedNetListWidget, p_listWidgetItem, Deactivating);
|
||||
}
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Activating) {
|
||||
if (m_wirelessNetItemMap.contains(ssid)) {
|
||||
QListWidgetItem *p_listWidgetItem = m_wirelessNetItemMap.value(ssid);
|
||||
WlanListItem *p_wlanItem = (WlanListItem*)m_inactivatedNetListWidget->itemWidget(p_listWidgetItem);
|
||||
p_wlanItem->updateConnectState(Activating);
|
||||
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Activating);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -947,8 +949,12 @@ void WlanPage::onHiddenWlanClicked()
|
|||
|
||||
void WlanPage::showControlCenter()
|
||||
{
|
||||
qDebug() << LOG_FLAG <<"show control center";
|
||||
|
||||
QProcess process;
|
||||
process.startDetached("ukui-control-center --wlanconnect");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void WlanPage::onWifiEnabledChanged(bool isWifiOn)
|
||||
|
@ -1022,8 +1028,8 @@ void WlanPage::onRefreshIconTimer()
|
|||
WlanListItem *p_sortWlanItem = new WlanListItem(sortItem, m_currentDevice);
|
||||
connect(p_sortWlanItem, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
|
||||
m_inactivatedNetListWidget->insertItem(sortRow, p_sortListWidgetItem);
|
||||
p_sortWlanItem->updateConnectState(Deactivated);
|
||||
m_inactivatedNetListWidget->setItemWidget(p_sortListWidgetItem, p_sortWlanItem);
|
||||
updateWlanItemState(m_inactivatedNetListWidget, p_sortListWidgetItem, Deactivated);
|
||||
sortRow++;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ private:
|
|||
|
||||
void sendApStateChangeSignal(QString uuid, QString ssid, QString deviceName,
|
||||
NetworkManager::ActiveConnection::State state);
|
||||
void wlanShowNotify(NetworkManager::ActiveConnection::State state,
|
||||
void wlanShowNotify(QString ssid, NetworkManager::ActiveConnection::State state,
|
||||
NetworkManager::ActiveConnection::Reason reason);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue