netdetail connect method
This commit is contained in:
parent
a70d86ebb0
commit
325f9dd634
|
@ -92,6 +92,11 @@ Q_SIGNALS: // SIGNALS
|
||||||
void hotspotDeactivated(QString devName, QString ssid);
|
void hotspotDeactivated(QString devName, QString ssid);
|
||||||
//热点连接
|
//热点连接
|
||||||
void hotspotActivated(QString devName, QString ssid);
|
void hotspotActivated(QString devName, QString ssid);
|
||||||
|
|
||||||
|
//信号强度变化
|
||||||
|
void signalStrengthChange(QString devName, QString ssid, int strength);
|
||||||
|
//安全性变化
|
||||||
|
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -183,6 +183,9 @@ void NetDetail::loadPage()
|
||||||
securityBtn->hide();
|
securityBtn->hide();
|
||||||
} else {
|
} else {
|
||||||
securityBtn->show();
|
securityBtn->show();
|
||||||
|
if (m_name.isEmpty()) {
|
||||||
|
titleLabel->setText(tr("connect hiddin wlan"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -700,23 +703,43 @@ bool NetDetail::createWirelessConnect()
|
||||||
if (secuType == WPA_AND_WPA2_ENTERPRISE) {
|
if (secuType == WPA_AND_WPA2_ENTERPRISE) {
|
||||||
connetSetting.m_type = SAE;
|
connetSetting.m_type = SAE;
|
||||||
if (enterpriseType == TLS) {
|
if (enterpriseType == TLS) {
|
||||||
qDebug() << "add new TLS connect";
|
|
||||||
m_info.tlsInfo.devIfaceName = m_deviceName;
|
m_info.tlsInfo.devIfaceName = m_deviceName;
|
||||||
securityPage->updateTlsChange(m_info.tlsInfo);
|
securityPage->updateTlsChange(m_info.tlsInfo);
|
||||||
|
if (!m_name.isEmpty()) {
|
||||||
|
qDebug() << "add new TLS connect";
|
||||||
m_wirelessConnOpration->addTlsConnect(connetSetting, m_info.tlsInfo);
|
m_wirelessConnOpration->addTlsConnect(connetSetting, m_info.tlsInfo);
|
||||||
|
} else {
|
||||||
|
qDebug() << "addAndConnect TLS connect";
|
||||||
|
m_wirelessConnOpration->addAndActiveWirelessEnterPriseTlsConnect(m_info.tlsInfo, connetSetting, m_deviceName, true);
|
||||||
|
}
|
||||||
} else if (enterpriseType == PEAP) {
|
} else if (enterpriseType == PEAP) {
|
||||||
qDebug() << "add new PEAP connect";
|
|
||||||
securityPage->updatePeapChange(m_info.peapInfo);
|
securityPage->updatePeapChange(m_info.peapInfo);
|
||||||
|
if (!m_name.isEmpty()) {
|
||||||
|
qDebug() << "add new PEAP connect";
|
||||||
m_wirelessConnOpration->addPeapConnect(connetSetting, m_info.peapInfo);
|
m_wirelessConnOpration->addPeapConnect(connetSetting, m_info.peapInfo);
|
||||||
|
} else {
|
||||||
|
qDebug() << "addAndConnect PEAP connect";
|
||||||
|
m_wirelessConnOpration->addAndActiveWirelessEnterPrisePeapConnect(m_info.peapInfo, connetSetting, m_deviceName, true);
|
||||||
|
}
|
||||||
} else if (enterpriseType == TTLS) {
|
} else if (enterpriseType == TTLS) {
|
||||||
qDebug() << "add new TTLS connect";
|
|
||||||
securityPage->updateTtlsChange(m_info.ttlsInfo);
|
securityPage->updateTtlsChange(m_info.ttlsInfo);
|
||||||
|
if (!m_name.isEmpty()) {
|
||||||
|
qDebug() << "add new TTLS connect";
|
||||||
m_wirelessConnOpration->addTtlsConnect(connetSetting, m_info.ttlsInfo);
|
m_wirelessConnOpration->addTtlsConnect(connetSetting, m_info.ttlsInfo);
|
||||||
|
} else {
|
||||||
|
qDebug() << "addAndConnect TTLS connect";
|
||||||
|
m_wirelessConnOpration->addAndActiveWirelessEnterPriseTtlsConnect(m_info.ttlsInfo, connetSetting, m_deviceName, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "add new personal connect";
|
|
||||||
securityPage->updateSecurityChange(connetSetting);
|
securityPage->updateSecurityChange(connetSetting);
|
||||||
|
if (!m_name.isEmpty()) {
|
||||||
|
qDebug() << "add new personal connect";
|
||||||
m_wirelessConnOpration->addConnect(connetSetting);
|
m_wirelessConnOpration->addConnect(connetSetting);
|
||||||
|
} else {
|
||||||
|
qDebug() << "addAndConnect personal connect";
|
||||||
|
m_wirelessConnOpration->addAndActiveWirelessConnect(m_deviceName, connetSetting, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,8 @@ void MainWindow::initDbusConnnect()
|
||||||
|
|
||||||
connect(m_wlanWidget, &WlanPage::hotspotDeactivated, this, &MainWindow::hotspotDeactivated);
|
connect(m_wlanWidget, &WlanPage::hotspotDeactivated, this, &MainWindow::hotspotDeactivated);
|
||||||
connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated);
|
connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated);
|
||||||
|
connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange);
|
||||||
|
connect(m_wlanWidget, &WlanPage::signalStrengthChange, this, &MainWindow::signalStrengthChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,6 +62,10 @@ signals:
|
||||||
//热点断开
|
//热点断开
|
||||||
void hotspotDeactivated(QString devName, QString ssid);
|
void hotspotDeactivated(QString devName, QString ssid);
|
||||||
void hotspotActivated(QString devName, QString ssid);
|
void hotspotActivated(QString devName, QString ssid);
|
||||||
|
//信号强度变化
|
||||||
|
void signalStrengthChange(QString devName, QString ssid, int strength);
|
||||||
|
//安全性变化
|
||||||
|
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
||||||
void mainWindowVisibleChanged(const bool &visible);
|
void mainWindowVisibleChanged(const bool &visible);
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ const QString WIRED_SWITCH = "wiredswitch";
|
||||||
|
|
||||||
LanPage::LanPage(QWidget *parent) : TabPage(parent)
|
LanPage::LanPage(QWidget *parent) : TabPage(parent)
|
||||||
{
|
{
|
||||||
|
//释放问题
|
||||||
m_activeResourse = new KyActiveConnectResourse;
|
m_activeResourse = new KyActiveConnectResourse;
|
||||||
m_connectResourse = new KyConnectResourse;
|
m_connectResourse = new KyConnectResourse;
|
||||||
m_device = new KyNetworkDeviceResourse;
|
m_device = new KyNetworkDeviceResourse;
|
||||||
|
@ -41,6 +42,7 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent)
|
||||||
connect(m_device, &KyNetworkDeviceResourse::deviceAdd, this, &LanPage::onDeviceAdd);
|
connect(m_device, &KyNetworkDeviceResourse::deviceAdd, this, &LanPage::onDeviceAdd);
|
||||||
connect(m_device, &KyNetworkDeviceResourse::deviceRemove, this, &LanPage::onDeviceRemove);
|
connect(m_device, &KyNetworkDeviceResourse::deviceRemove, this, &LanPage::onDeviceRemove);
|
||||||
connect(m_device, &KyNetworkDeviceResourse::deviceNameUpdate, this, &LanPage::onDeviceNameUpdate);
|
connect(m_device, &KyNetworkDeviceResourse::deviceNameUpdate, this, &LanPage::onDeviceNameUpdate);
|
||||||
|
//为什么同一个类中要用信号槽
|
||||||
connect(this, &LanPage::deviceStatusChanged, this, &LanPage::onDeviceChanged);
|
connect(this, &LanPage::deviceStatusChanged, this, &LanPage::onDeviceChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +123,7 @@ void LanPage::onLanSwitchClicked()
|
||||||
void LanPage::removeConnectionSlot(QString path) //删除时后端会自动断开激活,将其从未激活列表中删除
|
void LanPage::removeConnectionSlot(QString path) //删除时后端会自动断开激活,将其从未激活列表中删除
|
||||||
{
|
{
|
||||||
qDebug()<<"[LanPage] Removing a connection, path:"<<path;
|
qDebug()<<"[LanPage] Removing a connection, path:"<<path;
|
||||||
|
bool isLan = false;
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
QTimer::singleShot(200, &loop, SLOT(quit()));
|
QTimer::singleShot(200, &loop, SLOT(quit()));
|
||||||
loop.exec();
|
loop.exec();
|
||||||
|
@ -132,7 +135,7 @@ void LanPage::removeConnectionSlot(QString path) //删除时后端会
|
||||||
m_inactivatedLanListWidget->removeItemWidget(iters.value());
|
m_inactivatedLanListWidget->removeItemWidget(iters.value());
|
||||||
delete(iters.value());
|
delete(iters.value());
|
||||||
m_deactiveMap.erase(iters);
|
m_deactiveMap.erase(iters);
|
||||||
|
isLan = true;
|
||||||
//for dbus
|
//for dbus
|
||||||
qDebug() << "[LanPage] because removeConnectionSlot " << item->m_ifaceName;
|
qDebug() << "[LanPage] because removeConnectionSlot " << item->m_ifaceName;
|
||||||
emit listUpdate(item->m_ifaceName);
|
emit listUpdate(item->m_ifaceName);
|
||||||
|
@ -140,10 +143,34 @@ void LanPage::removeConnectionSlot(QString path) //删除时后端会
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!isLan) {
|
||||||
|
//removeConnection不是当前设备的,可能是其他有线设备或无线设备,保险起见发送信号更新
|
||||||
|
for (int index = 0; index < devList.size(); ++index) {
|
||||||
|
if (devList.at(index) == m_deviceName) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
emit listUpdate(devList.at(index));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LanPage::addConnectionSlot(QString uuid) //新增一个有线连接,将其加入到激活列表
|
void LanPage::addConnectionSlot(QString uuid) //新增一个有线连接,将其加入到激活列表
|
||||||
{
|
{
|
||||||
|
QString devName;
|
||||||
|
NetworkManager::ConnectionSettings::ConnectionType type;
|
||||||
|
if(m_connectResourse->getInterfaceByUuid(devName, type, uuid)) {
|
||||||
|
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
||||||
|
qDebug() << "[LanPage] addConnectionSlot but type is not Wired";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "[LanPage] addConnectionSlot but uuid is invalid";
|
||||||
|
}
|
||||||
|
|
||||||
|
//for dbus
|
||||||
|
qDebug() << "[LanPage] emit listUpdate because addConnection " << devName;
|
||||||
|
emit listUpdate(devName);
|
||||||
|
|
||||||
KyConnectItem * newItem = m_connectResourse->getConnectionItemByUuid(uuid, m_deviceName);
|
KyConnectItem * newItem = m_connectResourse->getConnectionItemByUuid(uuid, m_deviceName);
|
||||||
if (newItem != nullptr) {
|
if (newItem != nullptr) {
|
||||||
if (newItem->m_itemType == NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
if (newItem->m_itemType == NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
||||||
|
@ -151,9 +178,7 @@ void LanPage::addConnectionSlot(QString uuid) //新增一个有线
|
||||||
addNewItem(newItem, m_inactivatedLanListWidget);
|
addNewItem(newItem, m_inactivatedLanListWidget);
|
||||||
m_deactiveMap.insert(newItem, m_listWidgetItem);
|
m_deactiveMap.insert(newItem, m_listWidgetItem);
|
||||||
}
|
}
|
||||||
//for dbus
|
|
||||||
qDebug() << "[LanPage] because addConnectionSlot " << newItem->m_ifaceName;
|
|
||||||
emit listUpdate(newItem->m_ifaceName);
|
|
||||||
} else {
|
} else {
|
||||||
qDebug()<<"[LanPage] GetConnectionItemByUuid is empty when add a new!";
|
qDebug()<<"[LanPage] GetConnectionItemByUuid is empty when add a new!";
|
||||||
}
|
}
|
||||||
|
@ -266,7 +291,7 @@ void LanPage::onDeviceNameUpdate(QString oldName, QString newName)
|
||||||
if (devList.contains(oldName)) {
|
if (devList.contains(oldName)) {
|
||||||
devList.removeOne(oldName);
|
devList.removeOne(oldName);
|
||||||
devList.append(newName);
|
devList.append(newName);
|
||||||
qDebug() << "LanPage emit deviceNameUpdate " << oldName << newName;
|
qDebug() << "[LanPage] emit deviceNameUpdate " << oldName << newName;
|
||||||
emit deviceNameChanged(oldName, newName);
|
emit deviceNameChanged(oldName, newName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,8 +388,18 @@ void LanPage::initList(QString m_deviceName) //程序拉起,初始化显
|
||||||
void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason)
|
void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason)
|
||||||
{
|
{
|
||||||
qDebug()<<"[LanPage] State change slot:"<<state;
|
qDebug()<<"[LanPage] State change slot:"<<state;
|
||||||
|
|
||||||
QString devName;
|
QString devName;
|
||||||
|
NetworkManager::ConnectionSettings::ConnectionType type;
|
||||||
|
|
||||||
|
if(m_connectResourse->getInterfaceByUuid(devName, type, uuid)) {
|
||||||
|
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
||||||
|
qDebug() << "[LanPage] updateLanlist but type is not Wired";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "[LanPage] updateLanlist but uuid is invalid";
|
||||||
|
}
|
||||||
|
|
||||||
if (state == NetworkManager::ActiveConnection::State::Activating) {
|
if (state == NetworkManager::ActiveConnection::State::Activating) {
|
||||||
qDebug() << "[LanPage] wiredActivating " << devName;
|
qDebug() << "[LanPage] wiredActivating " << devName;
|
||||||
emit wiredActivating(devName,uuid);
|
emit wiredActivating(devName,uuid);
|
||||||
|
|
|
@ -108,6 +108,9 @@ void WlanPage::initConnections()
|
||||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved);
|
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved);
|
||||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::listUpdate);
|
connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::listUpdate);
|
||||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::listUpdate);
|
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::listUpdate);
|
||||||
|
connect(m_resource, &KyWirelessNetResource::signalStrengthChange, this, &WlanPage::signalStrengthChange);
|
||||||
|
connect(m_resource, &KyWirelessNetResource::secuTypeChange, this, &WlanPage::secuTypeChange);
|
||||||
|
|
||||||
// connect(m_resource, &KyWirelessNetResource::wifiNetworkUpdate, this, &WlanPage::onWlanUpdated);
|
// connect(m_resource, &KyWirelessNetResource::wifiNetworkUpdate, this, &WlanPage::onWlanUpdated);
|
||||||
connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::onActivatedWlanChanged);
|
connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::onActivatedWlanChanged);
|
||||||
// connect(m_connectoperation, &KyConnectOperation::activateConnectionError, this, &WlanPage::showDesktopNotify);
|
// connect(m_connectoperation, &KyConnectOperation::activateConnectionError, this, &WlanPage::showDesktopNotify);
|
||||||
|
@ -288,8 +291,11 @@ void WlanPage::getAllWlan()
|
||||||
|
|
||||||
void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
|
void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
|
||||||
{
|
{
|
||||||
|
emit listUpdate(interface);
|
||||||
qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << Q_FUNC_INFO <<__LINE__;
|
qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << Q_FUNC_INFO <<__LINE__;
|
||||||
|
if (interface != defaultDevice) {
|
||||||
|
qDebug() << "wlan add interface not equal defaultdevice,ignore";
|
||||||
|
}
|
||||||
KyWirelessNetItem *data = new KyWirelessNetItem(item);
|
KyWirelessNetItem *data = new KyWirelessNetItem(item);
|
||||||
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, defaultDevice);
|
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, defaultDevice);
|
||||||
connect(wlanItemWidget, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
|
connect(wlanItemWidget, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
|
||||||
|
@ -306,9 +312,13 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
|
||||||
|
|
||||||
void WlanPage::onWlanRemoved(QString interface, QString ssid)
|
void WlanPage::onWlanRemoved(QString interface, QString ssid)
|
||||||
{
|
{
|
||||||
|
emit listUpdate(interface);
|
||||||
if (!m_itemsMap.contains(ssid)) { return; }
|
if (!m_itemsMap.contains(ssid)) { return; }
|
||||||
if (m_expandedItem == m_itemsMap.value(ssid)) { m_expandedItem = nullptr; }
|
if (m_expandedItem == m_itemsMap.value(ssid)) { m_expandedItem = nullptr; }
|
||||||
qDebug() << "A Wlan Removed! interface = " << interface << "; ssid = " << ssid << Q_FUNC_INFO <<__LINE__;
|
qDebug() << "A Wlan Removed! interface = " << interface << "; ssid = " << ssid << Q_FUNC_INFO <<__LINE__;
|
||||||
|
if (interface != defaultDevice) {
|
||||||
|
qDebug() << "wlan remove interface not equal defaultdevice,ignore";
|
||||||
|
}
|
||||||
int height = m_inactivatedNetListWidget->itemWidget(m_itemsMap.value(ssid))->height();
|
int height = m_inactivatedNetListWidget->itemWidget(m_itemsMap.value(ssid))->height();
|
||||||
m_inactivatedNetListWidget->takeItem(m_inactivatedNetListWidget->row(m_itemsMap.value(ssid)));
|
m_inactivatedNetListWidget->takeItem(m_inactivatedNetListWidget->row(m_itemsMap.value(ssid)));
|
||||||
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() - height - NET_LIST_SPACING);
|
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() - height - NET_LIST_SPACING);
|
||||||
|
@ -541,7 +551,7 @@ void WlanPage::requestScan()
|
||||||
void WlanPage::onHiddenWlanClicked()
|
void WlanPage::onHiddenWlanClicked()
|
||||||
{
|
{
|
||||||
qDebug() << "[wlanPage] AddHideWifi Clicked! " << Q_FUNC_INFO << __LINE__ ;
|
qDebug() << "[wlanPage] AddHideWifi Clicked! " << Q_FUNC_INFO << __LINE__ ;
|
||||||
NetDetail *netDetail = new NetDetail("", "", false, true, false);
|
NetDetail *netDetail = new NetDetail(defaultDevice, "", "", false, true, true, this);
|
||||||
netDetail->show();
|
netDetail->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,8 @@ signals:
|
||||||
void wirelessActivating(QString devName, QString ssid);
|
void wirelessActivating(QString devName, QString ssid);
|
||||||
void hotspotDeactivated(QString devName, QString ssid);
|
void hotspotDeactivated(QString devName, QString ssid);
|
||||||
void hotspotActivated(QString devName, QString ssid);
|
void hotspotActivated(QString devName, QString ssid);
|
||||||
|
void signalStrengthChange(QString devName, QString ssid, int strength);
|
||||||
|
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
||||||
void hiddenWlanClicked();
|
void hiddenWlanClicked();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
Loading…
Reference in New Issue