Merge pull request #151 from listenerri/fix-hotspot

fix: not detect hotspot enabled
This commit is contained in:
listenerri 2019-03-25 09:08:42 +08:00 committed by GitHub
commit b1333a2795
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -84,6 +84,7 @@ WirelessList::WirelessList(WirelessDevice *deviceIter, QWidget *parent)
connect(m_device, &WirelessDevice::apInfoChanged, this, &WirelessList::APPropertiesChanged);
connect(m_device, &WirelessDevice::enableChanged, this, &WirelessList::onDeviceEnableChanged);
connect(m_device, &WirelessDevice::activateAccessPointFailed, this, &WirelessList::onActivateApFailed);
connect(m_device, &WirelessDevice::hotspotEnabledChanged, this, &WirelessList::onHotspotEnabledChanged);
connect(m_controlPanel, &DeviceControlWidget::enableButtonToggled, this, &WirelessList::onEnableButtonToggle);
connect(m_controlPanel, &DeviceControlWidget::requestRefresh, this, &WirelessList::requestWirelessScan);
@ -208,6 +209,11 @@ void WirelessList::updateAPList()
//if (m_networkInter->IsDeviceEnabled(m_device.dbusPath()))
if (m_device->enabled())
{
if (m_device->hotspotEnabled()) {
m_apList.clear();
m_apList.append(m_activeHotspotAP);
}
// sort ap list by strength
// std::sort(m_apList.begin(), m_apList.end(), std::greater<AccessPoint>());
// const bool wirelessActived = m_device.state() == NetworkDevice::Activated;
@ -424,6 +430,15 @@ void WirelessList::onActivateApFailed(const QString &apPath, const QString &uuid
}
}
void WirelessList::onHotspotEnabledChanged(const bool enabled)
{
// Note: the obtained hotspot info is not complete
m_activeHotspotAP = enabled ? AccessPoint(m_device->activeHotspotInfo().value("Hotspot").toObject())
: AccessPoint();
m_updateAPTimer->start();
}
AccessPoint WirelessList::accessPointBySsid(const QString &ssid)
{
if (ssid.isEmpty()) {

View File

@ -70,6 +70,7 @@ private slots:
void updateIndicatorPos();
void onActiveConnectionInfoChanged();
void onActivateApFailed(const QString &apPath, const QString &uuid);
void onHotspotEnabledChanged(const bool enabled);
private:
AccessPoint accessPointBySsid(const QString &ssid);
@ -80,6 +81,7 @@ private:
AccessPoint m_activeAP;
AccessPoint m_activatingAP;
AccessPoint m_activeHotspotAP;
QList<AccessPoint> m_apList;
QList<AccessPointWidget*> m_apwList;