mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
monitor ap list change signal
Change-Id: I2c00672bb4bdb7fa4380d29a87ee9543d92f04ca
This commit is contained in:
parent
d6861fdfb2
commit
a44c4f8f92
@ -1,15 +1,12 @@
|
||||
#include "accesspoint.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
|
||||
AccessPoint::AccessPoint(const QJsonObject &apInfo)
|
||||
: QObject(nullptr)
|
||||
{
|
||||
m_strength = apInfo.value("Strength").toInt();
|
||||
m_secured = apInfo.value("Secured").toBool();
|
||||
m_securedInEap = apInfo.value("SecuredInEap").toBool();
|
||||
m_path = apInfo.value("Path").toString();
|
||||
m_ssid = apInfo.value("Ssid").toString();
|
||||
loadApInfo(apInfo);
|
||||
}
|
||||
|
||||
AccessPoint::AccessPoint(const AccessPoint &ap)
|
||||
@ -18,6 +15,13 @@ AccessPoint::AccessPoint(const AccessPoint &ap)
|
||||
*this = ap;
|
||||
}
|
||||
|
||||
AccessPoint::AccessPoint(const QString &info)
|
||||
{
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(info.toUtf8());
|
||||
Q_ASSERT(doc.isObject());
|
||||
loadApInfo(doc.object());
|
||||
}
|
||||
|
||||
bool AccessPoint::operator==(const AccessPoint &ap) const
|
||||
{
|
||||
return m_ssid == ap.m_ssid;
|
||||
@ -53,3 +57,12 @@ bool AccessPoint::secured() const
|
||||
{
|
||||
return m_secured;
|
||||
}
|
||||
|
||||
void AccessPoint::loadApInfo(const QJsonObject &apInfo)
|
||||
{
|
||||
m_strength = apInfo.value("Strength").toInt();
|
||||
m_secured = apInfo.value("Secured").toBool();
|
||||
m_securedInEap = apInfo.value("SecuredInEap").toBool();
|
||||
m_path = apInfo.value("Path").toString();
|
||||
m_ssid = apInfo.value("Ssid").toString();
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ class AccessPoint : public QObject
|
||||
public:
|
||||
explicit AccessPoint(const QJsonObject &apInfo);
|
||||
AccessPoint(const AccessPoint &ap);
|
||||
AccessPoint(const QString &info);
|
||||
bool operator==(const AccessPoint &ap) const;
|
||||
bool operator>(const AccessPoint &ap) const;
|
||||
AccessPoint &operator=(const AccessPoint &ap);
|
||||
@ -19,6 +20,9 @@ public:
|
||||
int strength() const;
|
||||
bool secured() const;
|
||||
|
||||
private:
|
||||
void loadApInfo(const QJsonObject &apInfo);
|
||||
|
||||
private:
|
||||
int m_strength;
|
||||
bool m_secured;
|
||||
|
@ -37,6 +37,8 @@ WirelessApplet::WirelessApplet(const QString &devicePath, QWidget *parent)
|
||||
|
||||
QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
|
||||
|
||||
connect(m_networkInter, &DBusNetwork::AccessPointAdded, this, &WirelessApplet::APAdded);
|
||||
connect(m_networkInter, &DBusNetwork::AccessPointRemoved, this, &WirelessApplet::APRemoved);
|
||||
connect(m_networkInter, &DBusNetwork::AccessPointPropertiesChanged, this, &WirelessApplet::APPropertiesChanged);
|
||||
|
||||
connect(m_controlPanel, &DeviceControlWidget::deviceEnableChanged, this, &WirelessApplet::deviceEnableChanged);
|
||||
@ -50,6 +52,28 @@ void WirelessApplet::init()
|
||||
loadAPList();
|
||||
}
|
||||
|
||||
void WirelessApplet::APAdded(const QString &devPath, const QString &info)
|
||||
{
|
||||
if (devPath != m_devicePath)
|
||||
return;
|
||||
|
||||
AccessPoint ap(info);
|
||||
if (m_apList.contains(ap))
|
||||
return;
|
||||
|
||||
m_apList.append(ap);
|
||||
m_updateAPTimer->start();
|
||||
}
|
||||
|
||||
void WirelessApplet::APRemoved(const QString &devPath, const QString &info)
|
||||
{
|
||||
if (devPath != m_devicePath)
|
||||
return;
|
||||
|
||||
m_apList.removeOne(AccessPoint(info));
|
||||
m_updateAPTimer->start();
|
||||
}
|
||||
|
||||
void WirelessApplet::setDeviceInfo()
|
||||
{
|
||||
// set device enable state
|
||||
|
@ -23,6 +23,8 @@ private:
|
||||
|
||||
private slots:
|
||||
void init();
|
||||
void APAdded(const QString &devPath, const QString &info);
|
||||
void APRemoved(const QString &devPath, const QString &info);
|
||||
void APPropertiesChanged(const QString &devPath, const QString &info);
|
||||
void updateAPList();
|
||||
void deviceEnableChanged(const bool enable);
|
||||
|
Loading…
x
Reference in New Issue
Block a user