@@ -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+
217222QString 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
19531971void 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
19942013void 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+
29112986void 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