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 @@ -180,8 +180,8 @@ DccObject {
page: RowLayout {
Label {
font: DccUtils.copyFont(D.DTK.fontManager.t5, {
"bold": true
})
"weight": 700
})
text: dccObj.displayName
Layout.alignment: Qt.AlignLeft
}
Expand Down
90 changes: 90 additions & 0 deletions network-service-plugin/src/session/networkstatehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,24 @@ NetworkStateHandler::NetworkStateHandler(QObject *parent)
, m_notifyEnabled(true)
, m_dbusService(new QDBusServiceWatcher("org.freedesktop.NetworkManager", QDBusConnection::systemBus(), QDBusServiceWatcher::WatchForOwnerChange, this))
, m_replacesId(0)
, m_wifiOSDEnable(true)
, m_wifiEnabled(true)
, m_delayShowWifiOSD(new QTimer(this))
, m_resetWifiOSDEnableTimer(new QTimer(this))
{
connect(m_dbusService, &QDBusServiceWatcher::serviceRegistered, this, &NetworkStateHandler::init);
connect(m_delayShowWifiOSD, &QTimer::timeout, this, &NetworkStateHandler::delayShowWifiOSD);
connect(m_resetWifiOSDEnableTimer, &QTimer::timeout, this, &NetworkStateHandler::resetWifiOSDEnable);
connect(SettingConfig::instance(), &SettingConfig::resetWifiOSDEnableTimeoutChanged, this, &NetworkStateHandler::updateOSDTimer);
QDBusConnection::systemBus().connect("org.deepin.dde.Network1", "/org/deepin/dde/Network1", "org.deepin.dde.Network1", "DeviceEnabled", this, SLOT(onDeviceEnabled(QDBusObjectPath, bool)));
QDBusConnection::systemBus().connect("org.freedesktop.NetworkManager", "", "org.freedesktop.NetworkManager.VPN.Connection", "VpnStateChanged", this, SLOT(onVpnStateChanged(QDBusMessage)));
QDBusConnection::systemBus().connect("org.deepin.dde.AirplaneMode1", "/org/deepin/dde/AirplaneMode1", "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(onAirplaneModePropertiesChanged(QString, QVariantMap, QStringList)));
// 迁移dde-daemon/session/power1/sleep_inhibit.go ConnectHandleForSleep处理
QDBusConnection::systemBus().connect("org.deepin.dde.Daemon1", "/org/deepin/dde/Daemon1", "org.deepin.dde.Daemon1", "HandleForSleep", this, SLOT(onHandleForSleep(bool)));
QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetNameOwner");
message << "org.freedesktop.NetworkManager";
QDBusConnection::systemBus().callWithCallback(message, this, SLOT(init()));
updateOSDTimer(SettingConfig::instance()->resetWifiOSDEnableTimeout());
}

void NetworkStateHandler::init()
Expand Down Expand Up @@ -661,6 +670,87 @@ void NetworkStateHandler::onHandleForSleep(bool sleep)
}
}

void NetworkStateHandler::onAirplaneModeWifiEnabledChanged(bool enabled)
{
// 停止上次的定时器
if (m_delayShowWifiOSD->isActive()) {
m_delayShowWifiOSD->stop();
}

// 如果刚刚显示了飞行模式的OSD则直接退出不显示WIFI的OSD
if (!m_wifiOSDEnable) {
return;
}
// 等待150毫秒接收airplane.Enabled改变信号
m_wifiEnabled = enabled;
m_delayShowWifiOSD->start();
}

void NetworkStateHandler::onAirplaneModeEnabledChanged(bool enabled)
{
// 显示飞行模式OSD时不显示WIFI连接OSD,200毫秒后恢复显示WIFI的OSD
m_wifiOSDEnable = false;
if (m_delayShowWifiOSD->isActive()) {
m_delayShowWifiOSD->stop();
}
m_resetWifiOSDEnableTimer->stop();
m_resetWifiOSDEnableTimer->start();
// if enabled is true, airplane is on
if (enabled) {
showOSD("AirplaneModeOn");
} else { // if enabled is false, airplane is off
showOSD("AirplaneModeOff");
}
}

void NetworkStateHandler::onAirplaneModePropertiesChanged(const QString &, const QVariantMap &properties, const QStringList &)
{
if (properties.contains("Enabled")) {
onAirplaneModeEnabledChanged(properties.value("Enabled").value<bool>());
} else if (properties.contains("WifiEnabled")) {
onAirplaneModeWifiEnabledChanged(properties.value("WifiEnabled").value<bool>());
}
}

void NetworkStateHandler::showOSD(const QString &signal)
{
qCDebug(DSM()) << "show OSD" << signal;
QDBusMessage msg = QDBusMessage::createMethodCall("org.deepin.dde.Osd1", "/org/deepin/dde/shell/osd", "org.deepin.dde.shell.osd", "ShowOSD");
msg << signal;
QDBusConnection::sessionBus().asyncCall(msg);
}

void NetworkStateHandler::resetWifiOSDEnable()
{
qCDebug(DSM()) << "reset wifi OSD enable";
m_wifiOSDEnable = true;
}

void NetworkStateHandler::delayShowWifiOSD()
{
// 禁用WIFI网络OSD时退出
if (!m_wifiOSDEnable) {
return;
}

// if enabled is true, wifi rfkill block is true
// so wlan is off
if (m_wifiEnabled) {
Comment on lines +729 to +738
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Logic for showing WLANOn/WLANOff OSD may be inverted.

Please verify that the OSD display matches the actual WiFi state, as the current logic appears to contradict the variable naming.

showOSD("WLANOff");
} else { // if enabled is false, wifi is off
showOSD("WLANOn");
}
}

void NetworkStateHandler::updateOSDTimer(int interval)
{
if (interval < 60) { // 确保interval不会导致负数
interval = 60;
}
m_delayShowWifiOSD->setInterval(interval - 50);
m_resetWifiOSDEnableTimer->setInterval(interval);
}

static QString getMobileConnectedNotifyIcon(ModemDevice::Capabilities mobileNetworkType)
{
switch (mobileNetworkType) {
Expand Down
12 changes: 12 additions & 0 deletions network-service-plugin/src/session/networkstatehandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

#include <NetworkManagerQt/Device>

#include <QDBusMessage>

Check warning on line 9 in network-service-plugin/src/session/networkstatehandler.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 10 in network-service-plugin/src/session/networkstatehandler.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 11 in network-service-plugin/src/session/networkstatehandler.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 <QTimer>

Check warning on line 12 in network-service-plugin/src/session/networkstatehandler.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

namespace network {
namespace sessionservice {
Expand Down Expand Up @@ -101,6 +102,13 @@
void notify(const QString &icon, const QString &summary, const QString &body);
void onNotify(uint replacesId);
void onHandleForSleep(bool sleep);
void onAirplaneModeWifiEnabledChanged(bool enabled);
void onAirplaneModeEnabledChanged(bool enabled);
void onAirplaneModePropertiesChanged(const QString &, const QVariantMap &properties, const QStringList &);
void showOSD(const QString &signal);
void resetWifiOSDEnable();
void delayShowWifiOSD();
void updateOSDTimer(int interval);

protected:
bool isVirtualDeviceIfc(NetworkManager::Device::Ptr dev);
Expand Down Expand Up @@ -130,6 +138,10 @@
QMap<QString, DeviceStateInfo> m_devices;
QMap<QString, ActiveConnectionInfo> m_activeConnections;
uint m_replacesId;
bool m_wifiOSDEnable;
bool m_wifiEnabled;
QTimer *m_delayShowWifiOSD;
QTimer *m_resetWifiOSDEnableTimer;
};
} // namespace sessionservice
} // namespace network
Expand Down
12 changes: 12 additions & 0 deletions network-service-plugin/src/utils/settingconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ bool SettingConfig::disableFailureNotify() const
return m_disableFailureNotify;
}

int SettingConfig::resetWifiOSDEnableTimeout() const
{
return m_resetWifiOSDEnableTimeout;
}

void SettingConfig::onValueChanged(const QString &key)
{
if (key == "reconnectIfIpConflicted") {
Expand All @@ -73,6 +78,9 @@ void SettingConfig::onValueChanged(const QString &key)
} else if (key == QString("disableFailureNotify")) {
m_disableFailureNotify = dConfig->value("disableFailureNotify").toBool();
emit disableFailureNotifyChanged(m_disableFailureNotify);
} else if (key == QString("resetWifiOSDEnableTimeout")) {
m_resetWifiOSDEnableTimeout = dConfig->value("resetWifiOSDEnableTimeout").toInt();
emit resetWifiOSDEnableTimeoutChanged(m_resetWifiOSDEnableTimeout);
}
}

Expand All @@ -85,6 +93,7 @@ SettingConfig::SettingConfig(QObject *parent)
, m_disabledNetwork(false)
, m_enableAccountNetwork(false)
, m_disableFailureNotify(false)
, m_resetWifiOSDEnableTimeout(300)
{
if (!dConfig)
dConfig = Dtk::Core::DConfig::create("org.deepin.dde.network", "org.deepin.dde.network");
Expand Down Expand Up @@ -114,6 +123,9 @@ SettingConfig::SettingConfig(QObject *parent)
if (keys.contains("enableAccountNetwork"))
m_enableAccountNetwork = dConfig->value("enableAccountNetwork").toBool();

if (keys.contains("resetWifiOSDEnableTimeout"))
m_resetWifiOSDEnableTimeout = dConfig->value("resetWifiOSDEnableTimeout").toInt();

m_disableFailureNotify = dConfig->value("disableFailureNotify", false).toBool();
}
}
3 changes: 3 additions & 0 deletions network-service-plugin/src/utils/settingconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
bool disableNetwork() const; // 是否禁用无线网络和蓝牙
bool enableAccountNetwork() const; // 是否开启用户私有网络(工银瑞信定制)
bool disableFailureNotify() const; // 当网络连接失败后,true:不弹出消息,false:弹出消息
int resetWifiOSDEnableTimeout() const; // 重新显示网络连接OSD超时

signals:
void enableConnectivityChanged(bool);
void connectivityCheckIntervalChanged(int);
void checkUrlsChanged(QStringList);
void checkPortalChanged(bool);
void disableFailureNotifyChanged(bool);
void resetWifiOSDEnableTimeoutChanged(int);

private slots:

Check warning on line 34 in network-service-plugin/src/utils/settingconfig.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If slots is a macro then please configure it.
void onValueChanged(const QString &key);

private:
Expand All @@ -44,6 +46,7 @@
bool m_disabledNetwork;
bool m_enableAccountNetwork;
bool m_disableFailureNotify;
int m_resetWifiOSDEnableTimeout;
};

#endif // SERVICE_H