Skip to content

Commit 3b4bd30

Browse files
ut003640deepin-bot[bot]
authored andcommitted
fix: add configuration for whether to open the portal web page
Use local detection for the portal network and decide whether to open the portal network based on the configuration. Log: add configuration for whether to open the portal web page Influence: open portal network PMS: BUG-262229 fix: 增加是否打开portal网页的配置 使用本地检测portal网络,根据配置来决定是否打开portal网络 Log: 增加是否打开portal网页的配置 Influence: 打开portal网络
1 parent d4ca3f4 commit 3b4bd30

8 files changed

Lines changed: 114 additions & 44 deletions

File tree

config/org.deepin.dde.network.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,15 @@
100100
"enableConnectivity": {
101101
"value": true,
102102
"serial": 0,
103-
"flags": [
104-
"global"
105-
],
106-
"name": "enableConnectivity",
107-
"name[zh_CN]": "检查网络连接标记",
108-
"description[zh_CN]": "当设置为true时,使用前端检测网络连接,false,则使用NetworkManager自身的检测连接流程",
109-
"description": "ture: use dde-network-core to check connectivity",
110-
"permissions": "readwrite",
111-
"visibility": "private"
112-
},
113-
"checkPortal": {
103+
"flags":["global"],
104+
"name":"enableConnectivity",
105+
"name[zh_CN]":"检查网络连接标记",
106+
"description[zh_CN]":"当设置为true时,使用前端检测网络连接,false,则使用NetworkManager自身的检测连接流程",
107+
"description":"ture: use dde-network-core to check connectivity",
108+
"permissions":"readwrite",
109+
"visibility":"private"
110+
},
111+
"enableOpenPortal":{
114112
"value": true,
115113
"serial": 0,
116114
"flags": [

network-service-plugin/src/session/sessioncontainer.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "sessionipconfilct.h"
77
#include "constants.h"
88
#include "desktopmonitor.h"
9+
#include "settingconfig.h"
10+
#include "urlhelper.h"
911

1012
#include <QDBusConnection>
1113
#include <QDBusInterface>
@@ -79,15 +81,15 @@ void SessionContainer::leaveDesktop()
7981

8082
void SessionContainer::openPortalUrl(const QString &url)
8183
{
82-
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
83-
QString displayEnvironment = m_desktopMonitor->displayEnvironment();
84-
if (!displayEnvironment.isEmpty())
85-
env.insert("DISPLAY", displayEnvironment);
86-
87-
QProcess process;
88-
process.setProcessEnvironment(env);
89-
process.start("xdg-open", QStringList() << url);
90-
process.waitForFinished();
84+
// 如果没有配置,则无需打开网页
85+
if (!SettingConfig::instance()->enableOpenPortal()) {
86+
qCDebug(DSM) << "open portal is disabled";
87+
return;
88+
}
89+
90+
// 打开portal网页
91+
UrlHelper urlHelper(m_desktopMonitor);
92+
urlHelper.openUrl(url);
9193
}
9294

9395
void SessionContainer::onIPConflictChanged(const QString &devicePath, const QString &ip, bool conflicted)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: LGPL-3.0-or-later
4+
5+
#include "urlhelper.h"
6+
#include "desktopmonitor.h"
7+
#include "constants.h"
8+
#include "settingconfig.h"
9+
10+
#include <QProcessEnvironment>
11+
#include <QProcess>
12+
#include <QUrl>
13+
#include <QDebug>
14+
15+
using namespace network::sessionservice;
16+
17+
UrlHelper::UrlHelper(DesktopMonitor *desktopMonitor, QObject *parent)
18+
: QObject(parent)
19+
, m_desktopMonitor(desktopMonitor)
20+
{
21+
}
22+
23+
UrlHelper::~UrlHelper()
24+
{
25+
}
26+
27+
void UrlHelper::openUrl(const QString &url)
28+
{
29+
QString displayEnvironment = m_desktopMonitor->displayEnvironment();
30+
31+
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
32+
if (!displayEnvironment.isEmpty())
33+
env.insert("DISPLAY", displayEnvironment);
34+
35+
QProcess process;
36+
process.setProcessEnvironment(env);
37+
process.start("xdg-open", QStringList() << url);
38+
process.waitForFinished();
39+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: LGPL-3.0-or-later
4+
5+
#ifndef URLHELPER_H
6+
#define URLHELPER_H
7+
8+
#include <QObject>
9+
10+
#include <NetworkManagerQt/VpnConnection>
11+
12+
class QTimer;
13+
14+
namespace network {
15+
namespace sessionservice {
16+
17+
class DesktopMonitor;
18+
19+
class UrlHelper : public QObject
20+
{
21+
Q_OBJECT
22+
23+
public:
24+
explicit UrlHelper(DesktopMonitor *desktopMonitor, QObject *parent = nullptr);
25+
~UrlHelper() override;
26+
void openUrl(const QString &url);
27+
28+
private:
29+
DesktopMonitor *m_desktopMonitor;
30+
};
31+
32+
}
33+
}
34+
35+
#endif // SERVICE_H

network-service-plugin/src/utils/settingconfig.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
static Dtk::Core::DConfig *dConfig = nullptr;
1010

11+
// 当没有进行配置的时候, 则访问我们官网
12+
static const QStringList CheckUrls{
13+
"https://www.uniontech.com",
14+
};
15+
1116
SettingConfig *SettingConfig::instance()
1217
{
1318
static SettingConfig inst;
@@ -39,9 +44,9 @@ QStringList SettingConfig::networkCheckerUrls() const
3944
return m_networkUrls;
4045
}
4146

42-
bool SettingConfig::checkPortal() const
47+
bool SettingConfig::enableOpenPortal() const
4348
{
44-
return m_checkPortal;
49+
return m_enableOpenPortal;
4550
}
4651

4752
bool SettingConfig::disableNetwork() const
@@ -88,10 +93,9 @@ void SettingConfig::onValueChanged(const QString &key)
8893
emit connectivityCheckIntervalChanged(m_connectivityCheckInterval);
8994
} else if (key == QString("NetworkCheckerUrls")) {
9095
m_networkUrls = dConfig->value("NetworkCheckerUrls").toStringList();
96+
if (m_networkUrls.isEmpty())
97+
m_networkUrls = CheckUrls;
9198
emit checkUrlsChanged(m_networkUrls);
92-
} else if (key == QString("checkPortal")) {
93-
m_checkPortal = dConfig->value("checkPortal").toBool();
94-
emit checkPortalChanged(m_checkPortal);
9599
} else if (key == QString("disableFailureNotify")) {
96100
m_disableFailureNotify = dConfig->value("disableFailureNotify").toBool();
97101
emit disableFailureNotifyChanged(m_disableFailureNotify);
@@ -102,6 +106,8 @@ void SettingConfig::onValueChanged(const QString &key)
102106
m_httpRequestTimeout = dConfig->value("httpRequestTimeout").toInt();
103107
} else if (key == QString("httpConnectTimeout")) {
104108
m_httpConnectTimeout = dConfig->value("httpConnectTimeout").toInt();
109+
} else if (key == QString("enableOpenPortal")) {
110+
m_enableOpenPortal = dConfig->value("enableOpenPortal").toBool();
105111
}
106112
}
107113

@@ -110,7 +116,7 @@ SettingConfig::SettingConfig(QObject *parent)
110116
, m_reconnectIfIpConflicted(false)
111117
, m_enableConnectivity(true)
112118
, m_connectivityCheckInterval(30000)
113-
, m_checkPortal(false)
119+
, m_enableOpenPortal(false)
114120
, m_disabledNetwork(false)
115121
, m_enableAccountNetwork(false)
116122
, m_disableFailureNotify(false)
@@ -138,8 +144,8 @@ SettingConfig::SettingConfig(QObject *parent)
138144
if (keys.contains("NetworkCheckerUrls"))
139145
m_networkUrls = dConfig->value("NetworkCheckerUrls").toStringList();
140146

141-
if (keys.contains("checkPortal"))
142-
m_checkPortal = dConfig->value("checkPortal").toBool();
147+
if (keys.contains("enableOpenPortal"))
148+
m_enableOpenPortal = dConfig->value("enableOpenPortal").toBool();
143149

144150
if (keys.contains("disabledNetwork"))
145151
m_disabledNetwork = dConfig->value("disabledNetwork").toBool();
@@ -158,4 +164,6 @@ SettingConfig::SettingConfig(QObject *parent)
158164

159165
m_disableFailureNotify = dConfig->value("disableFailureNotify", false).toBool();
160166
}
167+
if (m_networkUrls.isEmpty())
168+
m_networkUrls = CheckUrls;
161169
}

network-service-plugin/src/utils/settingconfig.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SettingConfig : public QObject
1818
int connectivityIntervalWhenLimit() const;
1919
int connectivityCheckInterval() const;
2020
QStringList networkCheckerUrls() const; // 网络检测地址,用于检测网络连通性
21-
bool checkPortal() const; // 是否检测网络认证信息
21+
bool enableOpenPortal() const; // 是否检测网络认证信息
2222
bool disableNetwork() const; // 是否禁用无线网络和蓝牙
2323
bool enableAccountNetwork() const; // 是否开启用户私有网络(工银瑞信定制)
2424
bool disableFailureNotify() const; // 当网络连接失败后,true:不弹出消息,false:弹出消息
@@ -30,7 +30,6 @@ class SettingConfig : public QObject
3030
void enableConnectivityChanged(bool);
3131
void connectivityCheckIntervalChanged(int);
3232
void checkUrlsChanged(QStringList);
33-
void checkPortalChanged(bool);
3433
void disableFailureNotifyChanged(bool);
3534
void resetWifiOSDEnableTimeoutChanged(int);
3635

@@ -46,7 +45,7 @@ private slots:
4645
int m_connectivityIntervalWhenLimit;
4746
int m_connectivityCheckInterval;
4847
QStringList m_networkUrls;
49-
bool m_checkPortal;
48+
bool m_enableOpenPortal;
5049
bool m_disabledNetwork;
5150
bool m_enableAccountNetwork;
5251
bool m_disableFailureNotify;

src/configsetting.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -18,7 +18,6 @@ ConfigSetting::ConfigSetting(QObject *parent)
1818
, m_alwaysFromNM(true)
1919
, m_loadServiceFromNM(false)
2020
, m_enableConnectivity(false)
21-
, m_checkPortal(false)
2221
, m_supportCertifiedEscape(false)
2322
, m_showUnAuthorizeSwitch(true)
2423
, m_connectivityCheckInterval(30000)
@@ -67,9 +66,6 @@ void ConfigSetting::onValueChanged(const QString &key)
6766
} else if (key == QString("enableConnectivity")) {
6867
m_enableConnectivity = dConfig->value("enableConnectivity").toBool();
6968
emit enableConnectivityChanged(m_enableConnectivity);
70-
} else if (key == QString("checkPortal")) {
71-
m_checkPortal = dConfig->value("checkPortal").toBool();
72-
emit checkPortalChanged(m_checkPortal);
7369
} else if (key == QString("ConnectivityCheckInterval")) {
7470
m_connectivityCheckInterval = dConfig->value("ConnectivityCheckInterval").toInt() * 1000;
7571
emit connectivityCheckIntervalChanged(m_connectivityCheckInterval);
@@ -135,11 +131,6 @@ bool ConfigSetting::enableConnectivity() const
135131
return m_enableConnectivity;
136132
}
137133

138-
bool ConfigSetting::checkPortal() const
139-
{
140-
return m_checkPortal;
141-
}
142-
143134
bool ConfigSetting::supportCertifiedEscape() const
144135
{
145136
return m_supportCertifiedEscape;

src/configsetting.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -21,7 +21,6 @@ class ConfigSetting : public QObject
2121

2222
QStringList networkCheckerUrls() const; // 网络检测地址,用于检测网络连通性
2323
bool enableConnectivity() const; // 是否开启或者禁用前端检测网络连通性的功能
24-
bool checkPortal() const; // 是否检测网络认证信息
2524
bool supportCertifiedEscape() const; // 默认是否支持是否回退到未经授权的网络
2625
bool showUnAuthorizeSwitch() const; // 是否显示回退到未经授权的网络的开关
2726
int connectivityCheckInterval() const; // 网络连通性检测时间间隔
@@ -61,7 +60,6 @@ private slots:
6160
bool m_alwaysFromNM;
6261
bool m_loadServiceFromNM;
6362
bool m_enableConnectivity;
64-
bool m_checkPortal;
6563
bool m_supportCertifiedEscape;
6664
bool m_showUnAuthorizeSwitch;
6765
int m_connectivityCheckInterval;

0 commit comments

Comments
 (0)