netdetail connect method

This commit is contained in:
jzxc95 2021-09-13 15:56:15 +08:00
parent a70d86ebb0
commit 325f9dd634
7 changed files with 97 additions and 16 deletions

View File

@ -92,6 +92,11 @@ Q_SIGNALS: // SIGNALS
void hotspotDeactivated(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

View File

@ -183,6 +183,9 @@ void NetDetail::loadPage()
securityBtn->hide();
} else {
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) {
connetSetting.m_type = SAE;
if (enterpriseType == TLS) {
qDebug() << "add new TLS connect";
m_info.tlsInfo.devIfaceName = m_deviceName;
securityPage->updateTlsChange(m_info.tlsInfo);
if (!m_name.isEmpty()) {
qDebug() << "add new TLS connect";
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) {
qDebug() << "add new PEAP connect";
securityPage->updatePeapChange(m_info.peapInfo);
if (!m_name.isEmpty()) {
qDebug() << "add new PEAP connect";
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) {
qDebug() << "add new TTLS connect";
securityPage->updateTtlsChange(m_info.ttlsInfo);
if (!m_name.isEmpty()) {
qDebug() << "add new TTLS connect";
m_wirelessConnOpration->addTtlsConnect(connetSetting, m_info.ttlsInfo);
} else {
qDebug() << "addAndConnect TTLS connect";
m_wirelessConnOpration->addAndActiveWirelessEnterPriseTtlsConnect(m_info.ttlsInfo, connetSetting, m_deviceName, true);
}
}
} else {
qDebug() << "add new personal connect";
securityPage->updateSecurityChange(connetSetting);
if (!m_name.isEmpty()) {
qDebug() << "add new personal connect";
m_wirelessConnOpration->addConnect(connetSetting);
} else {
qDebug() << "addAndConnect personal connect";
m_wirelessConnOpration->addAndActiveWirelessConnect(m_deviceName, connetSetting, true);
}
}
return true;
}

View File

@ -161,6 +161,8 @@ void MainWindow::initDbusConnnect()
connect(m_wlanWidget, &WlanPage::hotspotDeactivated, this, &MainWindow::hotspotDeactivated);
connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated);
connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange);
connect(m_wlanWidget, &WlanPage::signalStrengthChange, this, &MainWindow::signalStrengthChange);
}
/**

View File

@ -62,6 +62,10 @@ signals:
//热点断开
void hotspotDeactivated(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);
public slots:

View File

@ -19,6 +19,7 @@ const QString WIRED_SWITCH = "wiredswitch";
LanPage::LanPage(QWidget *parent) : TabPage(parent)
{
//释放问题
m_activeResourse = new KyActiveConnectResourse;
m_connectResourse = new KyConnectResourse;
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::deviceRemove, this, &LanPage::onDeviceRemove);
connect(m_device, &KyNetworkDeviceResourse::deviceNameUpdate, this, &LanPage::onDeviceNameUpdate);
//为什么同一个类中要用信号槽
connect(this, &LanPage::deviceStatusChanged, this, &LanPage::onDeviceChanged);
}
@ -121,6 +123,7 @@ void LanPage::onLanSwitchClicked()
void LanPage::removeConnectionSlot(QString path) //删除时后端会自动断开激活,将其从未激活列表中删除
{
qDebug()<<"[LanPage] Removing a connection, path:"<<path;
bool isLan = false;
QEventLoop loop;
QTimer::singleShot(200, &loop, SLOT(quit()));
loop.exec();
@ -132,7 +135,7 @@ void LanPage::removeConnectionSlot(QString path) //删除时后端会
m_inactivatedLanListWidget->removeItemWidget(iters.value());
delete(iters.value());
m_deactiveMap.erase(iters);
isLan = true;
//for dbus
qDebug() << "[LanPage] because removeConnectionSlot " << item->m_ifaceName;
emit listUpdate(item->m_ifaceName);
@ -140,10 +143,34 @@ void LanPage::removeConnectionSlot(QString path) //删除时后端会
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) //新增一个有线连接,将其加入到激活列表
{
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);
if (newItem != nullptr) {
if (newItem->m_itemType == NetworkManager::ConnectionSettings::ConnectionType::Wired) {
@ -151,9 +178,7 @@ void LanPage::addConnectionSlot(QString uuid) //新增一个有线
addNewItem(newItem, m_inactivatedLanListWidget);
m_deactiveMap.insert(newItem, m_listWidgetItem);
}
//for dbus
qDebug() << "[LanPage] because addConnectionSlot " << newItem->m_ifaceName;
emit listUpdate(newItem->m_ifaceName);
} else {
qDebug()<<"[LanPage] GetConnectionItemByUuid is empty when add a new!";
}
@ -266,7 +291,7 @@ void LanPage::onDeviceNameUpdate(QString oldName, QString newName)
if (devList.contains(oldName)) {
devList.removeOne(oldName);
devList.append(newName);
qDebug() << "LanPage emit deviceNameUpdate " << oldName << newName;
qDebug() << "[LanPage] emit deviceNameUpdate " << 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)
{
qDebug()<<"[LanPage] State change slot:"<<state;
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) {
qDebug() << "[LanPage] wiredActivating " << devName;
emit wiredActivating(devName,uuid);

View File

@ -108,6 +108,9 @@ void WlanPage::initConnections()
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved);
connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, 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_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::onActivatedWlanChanged);
// connect(m_connectoperation, &KyConnectOperation::activateConnectionError, this, &WlanPage::showDesktopNotify);
@ -288,8 +291,11 @@ void WlanPage::getAllWlan()
void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
{
emit listUpdate(interface);
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);
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, defaultDevice);
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)
{
emit listUpdate(interface);
if (!m_itemsMap.contains(ssid)) { return; }
if (m_expandedItem == m_itemsMap.value(ssid)) { m_expandedItem = nullptr; }
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();
m_inactivatedNetListWidget->takeItem(m_inactivatedNetListWidget->row(m_itemsMap.value(ssid)));
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() - height - NET_LIST_SPACING);
@ -541,7 +551,7 @@ void WlanPage::requestScan()
void WlanPage::onHiddenWlanClicked()
{
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();
}

View File

@ -39,6 +39,8 @@ signals:
void wirelessActivating(QString devName, QString ssid);
void hotspotDeactivated(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();
public slots: