Skip to content

Commit 78424ce

Browse files
ut003640deepin-bot[bot]
authored andcommitted
feat: add portal authentication prompt to taskbar
according to user feedback, the direct web page opening method affects the experience. Changed to a prompt method; users click the prompt to open the web page automatically. Log: optimize portal authentication policy Influence: portal prompt method PMS: TASK-36815 feat: 任务栏增加portal认证提示 根据客户的反馈,直接打开网页的方式影响体验,修改为提示的方式,用户点击提示自动打开网页 Log: portal认证策略优化 Influence: portal提示方式
1 parent 3b4bd30 commit 78424ce

18 files changed

Lines changed: 434 additions & 27 deletions

config/org.deepin.dde.network.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@
108108
"permissions":"readwrite",
109109
"visibility":"private"
110110
},
111-
"enableOpenPortal":{
112-
"value": true,
111+
"portalProcessMode":{
112+
"value": "promp",
113113
"serial": 0,
114114
"flags": [
115115
"global"

net-view/operation/netitem.cpp

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

@@ -88,6 +88,7 @@ GETFUN(int, NetDeviceItem, pathIndex)
8888
GETFUN(const QString &, NetTipsItem, linkActivatedText)
8989
GETFUN(bool, NetTipsItem, tipsLinkEnabled)
9090
// 有线设备
91+
GETFUN(const QString &, NetWiredItem, portalUrl)
9192

9293
// 无线设备
9394
GETFUN(bool, NetWirelessDeviceItem, apMode)
@@ -110,6 +111,7 @@ GETFUN(int, NetWirelessItem, strength)
110111
GETFUN(int, NetWirelessItem, strengthLevel)
111112
GETFUN(bool, NetWirelessItem, isSecure)
112113
GETFUN(bool, NetWirelessItem, hasConnection)
114+
GETFUN(const QString &, NetWirelessItem, portalUrl)
113115

114116
QString NetWiredControlItem::name() const
115117
{

net-view/operation/netitem.h

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

@@ -204,8 +204,13 @@ class NetConnectionItem : public NetItem
204204
class NetWiredItem : public NetConnectionItem
205205
{
206206
Q_OBJECT
207+
public:
208+
const QString & portalUrl() const;
207209
protected:
208210
using NetConnectionItem::NetConnectionItem;
211+
212+
Q_SIGNALS:
213+
void portalUrlChanged(const QString &url);
209214
};
210215

211216
class NetWiredDisabledItem : public NetItem
@@ -234,20 +239,23 @@ class NetWirelessItem : public NetConnectionItem
234239
Q_PROPERTY(int strengthLevel READ strengthLevel NOTIFY strengthLevelChanged)
235240
Q_PROPERTY(bool secure READ isSecure NOTIFY secureChanged)
236241
Q_PROPERTY(bool hasConnection READ hasConnection NOTIFY hasConnectionChanged)
242+
Q_PROPERTY(QString portalUrl READ portalUrl NOTIFY portalUrlChanged)
237243

238244
public:
239245
uint flags() const;
240246
int strength() const;
241247
int strengthLevel() const;
242248
bool isSecure() const;
243249
bool hasConnection() const;
250+
const QString & portalUrl() const;
244251

245252
Q_SIGNALS:
246253
void flagsChanged(uint flags);
247254
void strengthChanged(int strength);
248255
void strengthLevelChanged(int strengthLevel);
249256
void secureChanged(bool secure);
250257
void hasConnectionChanged(bool hasConnection);
258+
void portalUrlChanged(const QString &url);
251259

252260
protected:
253261
using NetConnectionItem::NetConnectionItem;

net-view/operation/netmanager.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ void NetManager::setEnabled(bool enabled)
6868
d->setEnabled(enabled);
6969
}
7070

71+
NetType::NetManagerFlags NetManager::flags() const
72+
{
73+
Q_D(const NetManager);
74+
return d->flags();
75+
}
76+
7177
NetItem *NetManager::root() const
7278
{
7379
Q_D(const NetManager);
@@ -273,6 +279,11 @@ void NetManagerPrivate::init(NetType::NetManagerFlags flags)
273279
}
274280
}
275281

282+
NetType::NetManagerFlags NetManagerPrivate::flags() const
283+
{
284+
return m_managerThread->flags();
285+
}
286+
276287
bool NetManagerPrivate::netCheckAvailable()
277288
{
278289
return m_managerThread->NetCheckAvailable();
@@ -545,7 +556,13 @@ void NetManagerPrivate::onItemRemoved(const QString &id)
545556
void NetManagerPrivate::onDataChanged(int dataType, const QString &id, const QVariant &value)
546557
{
547558
switch (dataType) {
559+
case NetManagerThreadPrivate::portalUrlChanged: {
560+
updatePortalUrl(id, value.toString());
561+
m_lastShowPortalItemId = id;
562+
} break;
548563
case NetManagerThreadPrivate::primaryConnectionTypeChanged: {
564+
// 在主链接发生变化之前,清空之前连接的portal的连接
565+
updatePortalUrl(m_lastShowPortalItemId, "");
549566
updatePrimaryConnectionType(NetManager::ConnectionType(value.toInt()));
550567
} break;
551568
case NetManagerThreadPrivate::AirplaneModeEnabledChanged: {
@@ -1035,6 +1052,27 @@ void NetManagerPrivate::updatePrimaryConnectionType(NetManager::ConnectionType t
10351052
// }
10361053
}
10371054

1055+
void NetManagerPrivate::updatePortalUrl(const QString &id, const QString &url)
1056+
{
1057+
NetItemPrivate *item = findItem(id);
1058+
if (!item)
1059+
return;
1060+
1061+
switch (item->itemType()) {
1062+
case NetType::WiredItem: {
1063+
// 有线网络
1064+
NetWiredItemPrivate *wiredItem = NetItemPrivate::toItem<NetWiredItemPrivate>(item);
1065+
wiredItem->updateportalUrl(url);
1066+
} break;
1067+
case NetType::WirelessItem: {
1068+
// 无线网络
1069+
NetWirelessItemPrivate *wirelessItem = NetItemPrivate::toItem<NetWirelessItemPrivate>(item);
1070+
wirelessItem->updateportalUrl(url);
1071+
} break;
1072+
default: break;
1073+
}
1074+
}
1075+
10381076
void NetManagerPrivate::addItem(NetItemPrivate *item, NetItemPrivate *parentItem)
10391077
{
10401078
NetItemPrivate *oldItem = findItem(item->id());

net-view/operation/netmanager.h

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

@@ -34,6 +34,7 @@ class NetManager : public QObject
3434
void setAutoScanInterval(int ms); // 设置自动扫描无线网间隔,0为不扫描
3535
void setAutoScanEnabled(bool enabled); // 设置自动扫描,网络面板关闭时禁用
3636
void setEnabled(bool enabled); // 禁用时不发通知,不请求交互
37+
NetType::NetManagerFlags flags() const;
3738

3839
// const bool isGreeterMode() const;
3940
NetItem *root() const;

net-view/operation/private/netitemprivate.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ NetConnectionItemPrivate::NetConnectionItemPrivate()
244244
}
245245
// 有线连接
246246
GETFUN(NetType::NetItemType, NetWiredItem, itemType, NetType::NetItemType::WiredItem)
247+
GETFUN(const QString &, NetWiredItem, portalUrl, m_portalUrl)
248+
UPDATEFUN(NetWiredItem, const QString &, portalUrl)
247249
// 我的网络
248250
GETFUN(NetType::NetItemType, NetWirelessMineItem, itemType, NetType::NetItemType::WirelessMineItem)
249251
// 其他网络
@@ -270,6 +272,8 @@ UPDATEFUN(NetWirelessItem, uint, flags)
270272
// UPDATEFUN(NetWirelessItem, int, strength)
271273
UPDATEFUN(NetWirelessItem, bool, secure)
272274
UPDATEFUN(NetWirelessItem, bool, hasConnection)
275+
GETFUN(const QString &, NetWirelessItem, portalUrl, m_portalUrl)
276+
UPDATEFUN(NetWirelessItem, const QString &, portalUrl)
273277

274278
void NetWirelessItemPrivate::updatestrength(int strength)
275279
{

net-view/operation/private/netitemprivate.h

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

@@ -170,9 +170,14 @@ class NetWiredItemPrivate : public NetConnectionItemPrivate
170170
{
171171
public:
172172
NetType::NetItemType itemType() const override;
173+
const QString & portalUrl() const;
174+
void updateportalUrl(const QString &url);
173175

174176
protected:
175177
using NetConnectionItemPrivate::NetConnectionItemPrivate;
178+
179+
private:
180+
QString m_portalUrl;
176181
};
177182

178183
class NetWirelessMineItemPrivate : public NetItemPrivate
@@ -223,6 +228,8 @@ class NetWirelessItemPrivate : public NetConnectionItemPrivate
223228
void updatestrength(int strength);
224229
void updatesecure(bool secure);
225230
void updatehasConnection(bool hasConnection);
231+
const QString & portalUrl() const;
232+
void updateportalUrl(const QString &url);
226233

227234
protected:
228235
explicit NetWirelessItemPrivate();
@@ -233,6 +240,7 @@ class NetWirelessItemPrivate : public NetConnectionItemPrivate
233240
int m_strengthLevel;
234241
bool m_secure;
235242
bool m_hasConnection;
243+
QString m_portalUrl;
236244

237245
friend class NetItemPrivate;
238246
};

net-view/operation/private/netmanager_p.h

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

@@ -38,6 +38,7 @@ class NetManagerPrivate : public QObject
3838
void setEnabled(bool enabled);
3939
void setServerKey(const QString &serverKey);
4040
void init(NetType::NetManagerFlags flags);
41+
NetType::NetManagerFlags flags() const;
4142
bool netCheckAvailable();
4243
QString wpaEapAuthen() const; // 企业网EAP认证方式
4344
QString wpaEapAuthmethod() const; // 企业网内部认证方式
@@ -71,6 +72,7 @@ protected Q_SLOTS:
7172
void updateControlEnabled(int type);
7273
void updateAirplaneMode(bool enabled);
7374
void updatePrimaryConnectionType(NetManager::ConnectionType type);
75+
void updatePortalUrl(const QString &id, const QString &url);
7476

7577
void addItem(NetItemPrivate *item, NetItemPrivate *parentItem = nullptr);
7678
void removeItem(NetItemPrivate *item);
@@ -91,6 +93,7 @@ protected Q_SLOTS:
9193
QMap<QString, NetItemPrivate *> m_dataMap;
9294
PasswordRequest *m_passwordRequestData;
9395
QString m_showInputId;
96+
QString m_lastShowPortalItemId;
9497

9598
int m_deviceCount[DeviceItemCount];
9699
bool m_supportWireless;

net-view/operation/private/netmanagerthreadprivate.cpp

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ void NetManagerThreadPrivate::init(NetType::NetManagerFlags flags)
214214
QMetaObject::invokeMethod(this, &NetManagerThreadPrivate::doInit, Qt::QueuedConnection);
215215
}
216216

217+
NetType::NetManagerFlags NetManagerThreadPrivate::flags() const
218+
{
219+
return m_flags;
220+
}
221+
217222
QString NetManagerThreadPrivate::wpaEapAuthen() const
218223
{
219224
return ConfigSetting::instance()->wpaEapAuthen();
@@ -500,6 +505,17 @@ void NetManagerThreadPrivate::doInit()
500505
QDBusConnection::systemBus().connect("com.deepin.defender.netcheck", "/com/deepin/defender/netcheck", "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(onNetCheckPropertiesChanged(QString, QVariantMap, QStringList)));
501506
QDBusConnection::systemBus().connect("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "PrepareForSleep", this, SLOT(onPrepareForSleep(bool)));
502507

508+
509+
// 只有配置为promp和openandpromp的情况下,才会给出提示
510+
if (ConfigSetting::instance()->supportPortalPromp()) {
511+
QDBusConnection::systemBus().connect("org.deepin.dde.Network1",
512+
"/org/deepin/service/SystemNetwork",
513+
"org.deepin.service.SystemNetwork",
514+
"PortalDetected",
515+
this,
516+
SLOT(onPortalDetected(const QString &)));
517+
}
518+
503519
// 优先网络
504520
auto updadePrimaryConnectionType = [this] {
505521
Q_EMIT dataChanged(DataChanged::primaryConnectionTypeChanged, "", NetworkManager::primaryConnectionType());
@@ -1948,6 +1964,8 @@ void NetManagerThreadPrivate::onDeviceAdded(QList<NetworkDeviceBase *> devices)
19481964
}
19491965
updateDSLEnabledable();
19501966
updateSupportWireless();
1967+
1968+
checkPoratal();
19511969
}
19521970

19531971
void NetManagerThreadPrivate::onDeviceRemoved(QList<NetworkDeviceBase *> devices)
@@ -1989,6 +2007,7 @@ void NetManagerThreadPrivate::onConnectionAdded(const QList<WiredConnection *> &
19892007
if (!dev)
19902008
return;
19912009
addConnection(dev, conns);
2010+
checkPoratal();
19922011
}
19932012

19942013
void NetManagerThreadPrivate::onConnectionRemoved(const QList<WiredConnection *> &conns)
@@ -2908,6 +2927,62 @@ void NetManagerThreadPrivate::onPrepareForSleep(bool state)
29082927
m_isSleeping = state;
29092928
}
29102929

2930+
void NetManagerThreadPrivate::onPortalDetected(const QString &portalUrl)
2931+
{
2932+
NetworkManager::ActiveConnection::Ptr primaryActiveConnection = NetworkManager::primaryConnection();
2933+
if (primaryActiveConnection.isNull())
2934+
return;
2935+
2936+
dde::network::NetworkDeviceBase *networkDevice = nullptr;
2937+
NetworkManager::Connection::Ptr primaryConnection = primaryActiveConnection->connection();
2938+
for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) {
2939+
NetworkManager::ActiveConnection::Ptr deviceActiveConnection = device->activeConnection();
2940+
if (deviceActiveConnection.isNull())
2941+
continue;
2942+
if (deviceActiveConnection->connection() == primaryConnection) {
2943+
QList<NetworkDeviceBase *> devices = dde::network::NetworkController::instance()->devices();
2944+
for (NetworkDeviceBase *dev : devices) {
2945+
if (dev->path() == device->uni()) {
2946+
networkDevice = dev;
2947+
break;
2948+
}
2949+
}
2950+
if (networkDevice)
2951+
break;
2952+
}
2953+
}
2954+
if (!networkDevice) {
2955+
qCWarning(DNC) << "can't found the device,connection" << primaryConnection->name();
2956+
return;
2957+
}
2958+
qCDebug(DNC) << "portal changed:" << portalUrl << "device" << networkDevice->interface();
2959+
if (networkDevice->deviceType() == dde::network::DeviceType::Wired) {
2960+
// 找到有线网络对应的那个连接
2961+
NetworkManager::WiredSetting::Ptr wiredSetting = primaryConnection->settings()->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>();
2962+
if (!wiredSetting)
2963+
return;
2964+
2965+
// 找到有线连接对应的连接
2966+
dde::network::WiredDevice *wiredDevice = static_cast<dde::network::WiredDevice *>(networkDevice);
2967+
Q_EMIT dataChanged(DataChanged::portalUrlChanged, QString("%1:%2").arg(wiredDevice->path()).arg(primaryConnection->path()), portalUrl);
2968+
} else if (networkDevice->deviceType() == dde::network::DeviceType::Wireless) {
2969+
// 找到无线设备对应的那个无线网络
2970+
NetworkManager::WirelessSetting::Ptr wirelessSetting = primaryConnection->settings()->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
2971+
if (!wirelessSetting)
2972+
return;
2973+
2974+
dde::network::WirelessDevice *wirelessDevice = static_cast<dde::network::WirelessDevice *>(networkDevice);
2975+
// 找到无线连接对应那个网络
2976+
for (dde::network::AccessPoints *ap : wirelessDevice->accessPointItems()) {
2977+
if (ap->ssid() != wirelessSetting->ssid())
2978+
continue;
2979+
2980+
Q_EMIT dataChanged(DataChanged::portalUrlChanged, apID(ap), portalUrl);
2981+
break;
2982+
}
2983+
}
2984+
}
2985+
29112986
void NetManagerThreadPrivate::addDevice(NetDeviceItemPrivate *deviceItem, NetworkDeviceBase *dev)
29122987
{
29132988
deviceItem->updatepathIndex(dev->path().mid(dev->path().lastIndexOf('/') + 1).toInt());
@@ -3143,5 +3218,16 @@ NetType::NetDeviceStatus NetManagerThreadPrivate::deviceStatus(NetworkDeviceBase
31433218
return NetType::NetDeviceStatus::DS_Unknown;
31443219
}
31453220

3221+
void NetManagerThreadPrivate::checkPoratal()
3222+
{
3223+
// 只有配置为promp和openandpromp的情况下,才会给出提示
3224+
if (!ConfigSetting::instance()->supportPortalPromp())
3225+
return;
3226+
3227+
// 获取portal网页
3228+
QDBusInterface dbusInter("org.deepin.dde.Network1", "/org/deepin/service/SystemNetwork", "org.deepin.service.SystemNetwork", QDBusConnection::systemBus());
3229+
onPortalDetected(dbusInter.property("PortalUrl").toString());
3230+
}
3231+
31463232
} // namespace network
31473233
} // namespace dde

0 commit comments

Comments
 (0)