Skip to content

Commit 7c82309

Browse files
committed
fix: Record the last proxy method
Record the last proxy method pms: BUG-307643
1 parent 43f2106 commit 7c82309

File tree

9 files changed

+48
-37
lines changed

9 files changed

+48
-37
lines changed

dcc-network/qml/PageSystemProxy.qml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,23 @@ DccObject {
2424
autoUrlAlert = false
2525
// methodChanged()
2626
}
27+
function resetData() {
28+
root.method = root.item.method
29+
autoUrl.config = root.item.autoProxy
30+
http.config = root.item.manualProxy.http
31+
https.config = root.item.manualProxy.https
32+
ftp.config = root.item.manualProxy.ftp
33+
socks.config = root.item.manualProxy.socks
34+
ignoreHosts.config = root.item.manualProxy.ignoreHosts
35+
}
2736

2837
visible: item
2938
displayName: qsTr("System Proxy")
3039
description: qsTr("Set up proxy servers")
3140
icon: "dcc_system_agent"
32-
page: DccSettingsView {}
41+
page: DccSettingsView {
42+
Component.onCompleted: root.resetData()
43+
}
3344

3445
DccObject {
3546
name: "body"
@@ -48,7 +59,7 @@ DccObject {
4859
enabled: item.enabledable
4960
onClicked: {
5061
if (checked) {
51-
root.method = NetType.Auto
62+
root.method = item.lastMethod
5263
} else {
5364
root.method = NetType.None
5465
dccData.exec(NetManager.SetConnectInfo, item.id, {
@@ -263,15 +274,7 @@ DccObject {
263274
spacing: 0
264275
text: dccObj.displayName
265276
Layout.alignment: Qt.AlignRight
266-
onClicked: {
267-
method = root.item.method
268-
autoUrl.config = root.item.autoProxy
269-
http.config = root.item.manualProxy.http
270-
https.config = root.item.manualProxy.https
271-
ftp.config = root.item.manualProxy.ftp
272-
socks.config = root.item.manualProxy.socks
273-
ignoreHosts.config = root.item.manualProxy.ignoreHosts
274-
}
277+
onClicked: root.resetData()
275278
}
276279
}
277280
DccObject {

net-view/operation/netitem.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ QString NetVPNTipsItem::name() const
105105
// VPN
106106

107107
// 系统代理
108+
GETFUN(NetType::ProxyMethod, NetSystemProxyControlItem, lastMethod)
108109
GETFUN(NetType::ProxyMethod, NetSystemProxyControlItem, method)
109110
GETFUN(const QString &, NetSystemProxyControlItem, autoProxy)
110111
GETFUN(const QVariantMap &, NetSystemProxyControlItem, manualProxy)

net-view/operation/netitem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,18 @@ class NetVPNTipsItem : public NetTipsItem
311311
class NetSystemProxyControlItem : public NetControlItem
312312
{
313313
Q_OBJECT
314+
Q_PROPERTY(NetType::ProxyMethod lastMethod READ lastMethod NOTIFY lastMethodChanged)
314315
Q_PROPERTY(NetType::ProxyMethod method READ method NOTIFY methodChanged)
315316
Q_PROPERTY(QString autoProxy READ autoProxy NOTIFY autoProxyChanged)
316317
Q_PROPERTY(QVariantMap manualProxy READ manualProxy NOTIFY manualProxyChanged)
317318
public:
319+
NetType::ProxyMethod lastMethod() const;
318320
NetType::ProxyMethod method() const;
319321
const QString &autoProxy() const;
320322
const QVariantMap &manualProxy() const;
321323

322324
Q_SIGNALS:
325+
void lastMethodChanged(NetType::ProxyMethod method);
323326
void methodChanged(NetType::ProxyMethod method);
324327
void autoProxyChanged(const QString &autoProxy);
325328
void manualProxyChanged(const QVariantMap &manualProxy);

net-view/operation/netmanager.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -593,14 +593,7 @@ void NetManagerPrivate::onDataChanged(int dataType, const QString &id, const QVa
593593
NetType::NetDeviceStatus deviceStatus = value.value<NetType::NetDeviceStatus>();
594594
if (item->status() != NetType::NetDeviceStatus::DS_IpConflicted && deviceStatus == NetType::NetDeviceStatus::DS_IpConflicted) {
595595
// 如果IP冲突,需要发送横幅通知
596-
m_managerThread->sendNotify((item->itemType() & NET_WIRED ? "notification-network-wired-local" : "notification-network-wireless-local"),
597-
tr("IP conflict"),
598-
tr("Network"),
599-
"dde-control-center",
600-
-1,
601-
{},
602-
{},
603-
3000);
596+
m_managerThread->sendNotify((item->itemType() & NET_WIRED ? "notification-network-wired-local" : "notification-network-wireless-local"), tr("IP conflict"), tr("Network"), "dde-control-center", -1, {}, {}, 3000);
604597
}
605598
item->updatestatus(deviceStatus);
606599
}
@@ -662,6 +655,11 @@ void NetManagerPrivate::onDataChanged(int dataType, const QString &id, const QVa
662655
if (item)
663656
item->updatemethod(value.value<NetType::ProxyMethod>());
664657
} break;
658+
case NetManagerThreadPrivate::ProxyLastMethodChanged: {
659+
NetSystemProxyControlItemPrivate *item = NetItemPrivate::toItem<NetSystemProxyControlItemPrivate>(findItem(id));
660+
if (item)
661+
item->updatelastMethod(value.value<NetType::ProxyMethod>());
662+
} break;
665663
case NetManagerThreadPrivate::SystemAutoProxyChanged: {
666664
NetSystemProxyControlItemPrivate *item = NetItemPrivate::toItem<NetSystemProxyControlItemPrivate>(findItem(id));
667665
if (item)

net-view/operation/private/netitemprivate.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,12 @@ NetVPNControlItemPrivate::NetVPNControlItemPrivate()
293293
}
294294
// 系统代理
295295
GETFUN(NetType::NetItemType, NetSystemProxyControlItem, itemType, NetType::NetItemType::SystemProxyControlItem)
296+
GETFUN(NetType::ProxyMethod, NetSystemProxyControlItem, lastMethod, m_lastMethod)
296297
GETFUN(NetType::ProxyMethod, NetSystemProxyControlItem, method, m_method)
297298
GETFUN(const QString &, NetSystemProxyControlItem, autoProxy, m_autoProxy)
298299
GETFUN(const QVariantMap &, NetSystemProxyControlItem, manualProxy, m_manualProxy)
299300
UPDATEFUN(NetSystemProxyControlItem, NetType::ProxyMethod, method)
301+
UPDATEFUN(NetSystemProxyControlItem, NetType::ProxyMethod, lastMethod)
300302
UPDATEFUN(NetSystemProxyControlItem, const QString &, autoProxy)
301303
UPDATEFUN(NetSystemProxyControlItem, const QVariantMap &, manualProxy)
302304

net-view/operation/private/netitemprivate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,11 @@ class NetSystemProxyControlItemPrivate : public NetControlItemPrivate
259259
{
260260
public:
261261
NetType::NetItemType itemType() const override;
262+
NetType::ProxyMethod lastMethod() const;
262263
NetType::ProxyMethod method() const;
263264
const QString &autoProxy() const;
264265
const QVariantMap &manualProxy() const;
266+
void updatelastMethod(NetType::ProxyMethod method);
265267
void updatemethod(NetType::ProxyMethod method);
266268
void updateautoProxy(const QString &autoProxy);
267269
void updatemanualProxy(const QVariantMap &manualProxy);
@@ -270,6 +272,7 @@ class NetSystemProxyControlItemPrivate : public NetControlItemPrivate
270272
using NetControlItemPrivate::NetControlItemPrivate;
271273

272274
private:
275+
NetType::ProxyMethod m_lastMethod;
273276
NetType::ProxyMethod m_method;
274277
QString m_autoProxy;
275278
QVariantMap m_manualProxy;

net-view/operation/private/netmanagerthreadprivate.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ void NetManagerThreadPrivate::sendNotify(const QString &appIcon, const QString &
334334
}
335335

336336
// clang-format on
337+
337338
void NetManagerThreadPrivate::onNetCheckPropertiesChanged(QString, QVariantMap properties, QStringList)
338339
{
339340
if (properties.contains("Availabled")) {
@@ -450,6 +451,8 @@ void NetManagerThreadPrivate::doInit()
450451
NetSystemProxyControlItemPrivate *item = NetItemNew(SystemProxyControlItem, "NetSystemProxyControlItem");
451452
item->updatename("SystemProxy");
452453
item->updateenabled(method == ProxyMethod::Auto || method == ProxyMethod::Manual);
454+
item->updatelastMethod(NetType::ProxyMethod(ConfigWatcher::instance()->proxyMethod()));
455+
item->updatemethod(NetType::ProxyMethod(method));
453456
// item->updateenabledable(networkController->proxyController()->systemProxyExist());
454457
item->item()->moveToThread(m_parentThread);
455458
Q_EMIT itemAdded("Root", item);
@@ -462,6 +465,7 @@ void NetManagerThreadPrivate::doInit()
462465
connect(networkController->proxyController(), &ProxyController::proxyChanged, this, &NetManagerThreadPrivate::onSystemManualProxyChanged);
463466
connect(networkController->proxyController(), &ProxyController::proxyAuthChanged, this, &NetManagerThreadPrivate::onSystemManualProxyChanged);
464467
connect(networkController->proxyController(), &ProxyController::proxyIgnoreHostsChanged, this, &NetManagerThreadPrivate::onSystemManualProxyChanged);
468+
connect(ConfigWatcher::instance(), &ConfigWatcher::lastProxyMethodChanged, this, &NetManagerThreadPrivate::onLastProxyMethodChanged);
465469
}
466470
// 应用代理
467471
if (m_flags.testFlags(NetType::NetManagerFlag::Net_AppProxy)) {
@@ -486,12 +490,7 @@ void NetManagerThreadPrivate::doInit()
486490
m_netCheckAvailable = false;
487491
getNetCheckAvailableFromDBus();
488492

489-
QDBusConnection::systemBus().connect("com.deepin.defender.netcheck",
490-
"/com/deepin/defender/netcheck",
491-
"org.freedesktop.DBus.Properties",
492-
"PropertiesChanged",
493-
this,
494-
SLOT(onNetCheckPropertiesChanged(QString, QVariantMap, QStringList)));
493+
QDBusConnection::systemBus().connect("com.deepin.defender.netcheck", "/com/deepin/defender/netcheck", "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(onNetCheckPropertiesChanged(QString, QVariantMap, QStringList)));
495494

496495
QDBusConnection::systemBus().connect("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "PrepareForSleep", this, SLOT(onPrepareForSleep(bool)));
497496

@@ -524,12 +523,8 @@ void NetManagerThreadPrivate::doInit()
524523
m_airplaneModeEnabled = false;
525524
getAirplaneModeEnabled();
526525
connect(ConfigSetting::instance(), &ConfigSetting::enableAirplaneModeChanged, this, &NetManagerThreadPrivate::getAirplaneModeEnabled);
527-
QDBusConnection::systemBus().connect("org.deepin.dde.AirplaneMode1",
528-
"/org/deepin/dde/AirplaneMode1",
529-
"org.freedesktop.DBus.Properties",
530-
"PropertiesChanged",
531-
this,
532-
SLOT(onAirplaneModeEnabledPropertiesChanged(QString, QVariantMap, QStringList)));
526+
QDBusConnection::systemBus()
527+
.connect("org.deepin.dde.AirplaneMode1", "/org/deepin/dde/AirplaneMode1", "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(onAirplaneModeEnabledPropertiesChanged(QString, QVariantMap, QStringList)));
533528
}
534529
// DSL
535530
if (m_flags.testFlags(NetType::NetManagerFlag::Net_DSL)) {
@@ -1007,8 +1002,7 @@ void NetManagerThreadPrivate::doGetConnectInfo(const QString &id, NetType::NetIt
10071002
WiredDevice *netDevice = qobject_cast<WiredDevice *>(device);
10081003
for (auto &&conn : netDevice->items()) {
10091004
if (conn->connection() && conn->connection()->path() == ids.at(1)) {
1010-
qCInfo(DNC) << "ConnectInfo wired, device name: " << netDevice->deviceName() << "connection name: " << conn->connection()->id()
1011-
<< "connection uuid: " << conn->connection()->uuid();
1005+
qCInfo(DNC) << "ConnectInfo wired, device name: " << netDevice->deviceName() << "connection name: " << conn->connection()->id() << "connection uuid: " << conn->connection()->uuid();
10121006
auto connection = findConnectionByUuid(conn->connection()->uuid());
10131007
if (!connection) {
10141008
qCWarning(DNC) << "Can not find connection by uuid, uuid: " << conn->connection()->uuid();
@@ -2132,6 +2126,11 @@ void NetManagerThreadPrivate::onSystemProxyExistChanged(bool exist)
21322126
Q_EMIT dataChanged(DataChanged::DeviceAvailableChanged, "NetSystemProxyControlItem", exist);
21332127
}
21342128

2129+
void NetManagerThreadPrivate::onLastProxyMethodChanged(const ProxyMethod &method)
2130+
{
2131+
Q_EMIT dataChanged(DataChanged::ProxyLastMethodChanged, "NetSystemProxyControlItem", QVariant::fromValue(NetType::ProxyMethod(method)));
2132+
}
2133+
21352134
void NetManagerThreadPrivate::onSystemProxyMethodChanged(const ProxyMethod &method)
21362135
{
21372136
Q_EMIT dataChanged(DataChanged::EnabledChanged, "NetSystemProxyControlItem", (method == ProxyMethod::Auto || method == ProxyMethod::Manual));
@@ -2522,8 +2521,7 @@ void NetManagerThreadPrivate::updateHiddenNetworkConfig(WirelessDevice *wireless
25222521

25232522
// 隐藏网络配置错误时提示重连
25242523
if ((wSetting) && wSetting->hidden()) {
2525-
NetworkManager::WirelessSecuritySetting::Ptr const wsSetting =
2526-
connSettings->setting(NetworkManager::Setting::SettingType::WirelessSecurity).staticCast<NetworkManager::WirelessSecuritySetting>();
2524+
NetworkManager::WirelessSecuritySetting::Ptr const wsSetting = connSettings->setting(NetworkManager::Setting::SettingType::WirelessSecurity).staticCast<NetworkManager::WirelessSecuritySetting>();
25272525
if ((wsSetting) && NetworkManager::WirelessSecuritySetting::KeyMgmt::Unknown == wsSetting->keyMgmt()) {
25282526
for (auto *ap : wireless->accessPointItems()) {
25292527
if (ap->ssid() == wSetting->ssid() && ap->secured() && ap->strength() > 0) {

net-view/operation/private/netmanagerthreadprivate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class NetManagerThreadPrivate : public QObject
8383
DetailsChanged,
8484
IndexChanged,
8585
ProxyMethodChanged,
86+
ProxyLastMethodChanged,
8687
SystemAutoProxyChanged,
8788
SystemManualProxyChanged,
8889
AppProxyChanged,
@@ -208,6 +209,7 @@ protected Q_SLOTS:
208209
void onVPNConnectionChanged();
209210
// 系统代理
210211
void onSystemProxyExistChanged(bool exist);
212+
void onLastProxyMethodChanged(const ProxyMethod &method);
211213
void onSystemProxyMethodChanged(const ProxyMethod &method);
212214
void onSystemAutoProxyChanged(const QString &url);
213215
void onSystemManualProxyChanged();

network-service-plugin/accountnetwork/session/accountnetwork/activeaccoutnetwork.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ void ActiveAccountNetwork::onStateChanged(NetworkManager::ActiveConnection::Stat
361361
break;
362362
}
363363
}
364-
365-
onConnectionStateChanged(device, activeConnection);
364+
if (!device.isNull()) {
365+
onConnectionStateChanged(device, activeConnection);
366+
}
366367
}

0 commit comments

Comments
 (0)