Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dcc-network/qml/PageHotspot.qml
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,14 @@ DccObject {
editDlg.config["802-11-wireless-security"]["proto"] = ['wpa', 'rsn']
editDlg.config["802-11-wireless-security"]["group"] = ['ccmp']
editDlg.config["802-11-wireless-security"]["pairwise"] = ['ccmp']
editDlg.config["802-11-wireless-security"]["psk-flags"] = 1
editDlg.config["802-11-wireless-security"]["psk-flags"] = 0
editDlg.config["802-11-wireless-security"]["key-mgmt"] = keyMgmt
break
case "sae":
editDlg.config["802-11-wireless-security"]["proto"] = ['rsn']
editDlg.config["802-11-wireless-security"]["group"] = ['ccmp']
editDlg.config["802-11-wireless-security"]["pairwise"] = ['ccmp']
editDlg.config["802-11-wireless-security"]["psk-flags"] = 1
editDlg.config["802-11-wireless-security"]["psk-flags"] = 0
editDlg.config["802-11-wireless-security"]["key-mgmt"] = keyMgmt
break
default:
Expand Down
41 changes: 40 additions & 1 deletion net-view/operation/private/nethotspotcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NetHotspotController::NetHotspotController(QObject *parent)
, m_isEnabled(false)
, m_enabledable(true)
, m_deviceEnabled(true)
, m_userActive(true)
, m_updatedTimer(new QTimer(this))
{
m_updatedTimer->setSingleShot(true);
Expand All @@ -34,6 +35,9 @@ NetHotspotController::NetHotspotController(QObject *parent)
connect(m_hotspotController, &HotspotController::itemAdded, this, &NetHotspotController::updateConfig);
connect(m_hotspotController, &HotspotController::itemRemoved, this, &NetHotspotController::updateConfig);
connect(m_hotspotController, &HotspotController::itemChanged, this, &NetHotspotController::updateConfig, Qt::QueuedConnection);
QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.login1", "/org/freedesktop/login1/user/self", "org.freedesktop.DBus.Properties", "Get");
msg << "org.freedesktop.login1.User" << "Display";
QDBusConnection::systemBus().callWithCallback(msg, this, SLOT(updateDisplay(QDBusVariant)));
}

bool NetHotspotController::isEnabled() const
Expand Down Expand Up @@ -131,7 +135,8 @@ void NetHotspotController::updateData()

void NetHotspotController::updateConfig()
{
if (m_updatedTimer->isActive()) {
// 用户不为Active状态时,获取密码需要认证
if (!m_userActive || m_updatedTimer->isActive()) {
return;
}
QList<HotspotItem *> items;
Expand Down Expand Up @@ -187,5 +192,39 @@ void NetHotspotController::updateConfig()
m_config = config;
Q_EMIT configChanged(m_config);
}

void NetHotspotController::onLoginSessionPropertiesChanged(const QString &, const QVariantMap &properties, const QStringList &)
{
if (properties.contains("Active")) {
m_userActive = properties.value("Active").toBool();
updateConfig();
}
}

void NetHotspotController::updateDisplay(const QDBusVariant &display)
{
const QDBusArgument arg = display.variant().value<QDBusArgument>();
QString id;
QDBusObjectPath path;
arg.beginStructure();
arg >> id;
arg >> path;
arg.endStructure();
if (path.path().isEmpty()) {
return;
}
QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.login1", path.path(), "org.freedesktop.DBus.Properties", "Get");
msg << "org.freedesktop.login1.Session" << "Remote";
QDBusPendingReply<QDBusVariant> remoteReply = QDBusConnection::systemBus().asyncCall(msg);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(remoteReply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [path, this](QDBusPendingCallWatcher *self) {
QDBusPendingReply<QDBusVariant> reply = *self;
if (!reply.isError() && !reply.value().variant().toBool()) {
QDBusConnection::systemBus().connect("org.freedesktop.login1", path.path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(onLoginSessionPropertiesChanged(QString, QVariantMap, QStringList)));
}
self->deleteLater();
});
}

} // namespace network
} // namespace dde
4 changes: 4 additions & 0 deletions net-view/operation/private/nethotspotcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#ifndef NETHOTSPOTCONTROLLER_H
#define NETHOTSPOTCONTROLLER_H

#include <QDBusVariant>

Check warning on line 7 in net-view/operation/private/nethotspotcontroller.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusVariant> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QObject>

Check warning on line 8 in net-view/operation/private/nethotspotcontroller.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QVariant>

Check warning on line 9 in net-view/operation/private/nethotspotcontroller.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QVariant> not found. Please note: Cppcheck does not need standard library headers to get proper results.

QT_BEGIN_NAMESPACE
class QTimer;
Expand Down Expand Up @@ -43,12 +44,15 @@
void updateEnabledable();
void updateData();
void updateConfig();
void onLoginSessionPropertiesChanged(const QString &, const QVariantMap &properties, const QStringList &);
void updateDisplay(const QDBusVariant &display);

private:
HotspotController *m_hotspotController;
bool m_isEnabled;
bool m_enabledable;
bool m_deviceEnabled;
bool m_userActive;
QVariantMap m_config;
QStringList m_shareDevice;
QStringList m_optionalDevice;
Expand Down