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
5 changes: 5 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ Files: dss-network-plugin/50-dss-network-plugin.rules src/dde-network-core.pc.in
Copyright: UnionTech Software Technology Co., Ltd.
License: LGPL-3.0-or-later

# policy
Files: src/misc/*.policy
Copyright: UnionTech Software Technology Co., Ltd.
License: LGPL-3.0-or-later

# sh
Files: *.sh
Copyright: UnionTech Software Technology Co., Ltd.
Expand Down
7 changes: 7 additions & 0 deletions dcc-network/operation/dccnetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

#include <NetworkManagerQt/GenericTypes>

#include <QClipboard>

Check warning on line 13 in dcc-network/operation/dccnetwork.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 14 in dcc-network/operation/dccnetwork.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 15 in dcc-network/operation/dccnetwork.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 16 in dcc-network/operation/dccnetwork.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 17 in dcc-network/operation/dccnetwork.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 18 in dcc-network/operation/dccnetwork.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 19 in dcc-network/operation/dccnetwork.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QHostAddress> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QThread>
#include <QtQml/QQmlEngine>

Expand Down Expand Up @@ -182,6 +184,11 @@
return m_manager->netCheckAvailable();
}

bool DccNetwork::resolvedAvailable() const
{
return QDBusConnection::systemBus().interface()->isServiceRegistered("org.freedesktop.resolve1");
}

QVariantMap DccNetwork::toMap(QMap<QString, QString> map)
{
QVariantMap retMap;
Expand Down
3 changes: 3 additions & 0 deletions dcc-network/operation/dccnetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ class DccNetwork : public QObject
Q_OBJECT
Q_PROPERTY(NetManager* manager READ manager NOTIFY managerChanged)
Q_PROPERTY(NetItem* root READ root NOTIFY rootChanged)
Q_PROPERTY(bool resolvedAvailable READ resolvedAvailable NOTIFY resolvedAvailableChanged)

public:
explicit DccNetwork(QObject *parent = nullptr);
~DccNetwork() override;
NetItem *root() const;
bool resolvedAvailable() const;
Q_INVOKABLE static bool CheckPasswordValid(const QString &key, const QString &password);

NetManager *manager() const { return m_manager; }
Expand All @@ -42,6 +44,7 @@ public Q_SLOTS:

void managerChanged(NetManager *manager);
void rootChanged();
void resolvedAvailableChanged();

protected Q_SLOTS:
void init();
Expand Down
16 changes: 15 additions & 1 deletion dcc-network/qml/PageVPNSettings.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick 2.15
import QtQuick.Layouts 1.15
Expand Down Expand Up @@ -132,6 +132,7 @@ DccObject {
type: NetType.VPNControlItem
parentName: root.parentUrl + "/body"
weight: 1000
resolvedAvailable: dccData ? dccData.resolvedAvailable : false
onEditClicked: modified = true
}
SectionIPv6 {
Expand All @@ -140,8 +141,21 @@ DccObject {
parentName: root.parentUrl + "/body"
visible: vpnType & (NetUtils.VpnTypeEnum["openvpn"] | NetUtils.VpnTypeEnum["openconnect"])
weight: 1100
resolvedAvailable: dccData ? dccData.resolvedAvailable : false
onEditClicked: modified = true
}
Connections {
target: sectionIPv4
function onDnsPriorityChanged(priority) {
sectionIPv6.setDnsPriority(priority)
}
}
Connections {
target: sectionIPv6
function onDnsPriorityChanged(priority) {
sectionIPv4.setDnsPriority(priority)
}
}
SectionDNS {
id: sectionDNS
parentName: root.parentUrl + "/body"
Expand Down
69 changes: 65 additions & 4 deletions dcc-network/qml/SectionIPv4.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ DccObject {

property string errorKey: ""
property string errorMsg: ""
property bool neverDefault: false
property bool resolvedAvailable: false
signal editClicked
signal dnsPriorityChanged(int priority)

function setConfig(c) {
errorKey = ""
Expand All @@ -33,6 +36,7 @@ DccObject {
} else {
root.config = c
method = root.config.method
neverDefault = root.config && root.config["never-default"] === true
resetAddressData()
}
}
Expand Down Expand Up @@ -141,6 +145,11 @@ DccObject {
addressDataChanged()
editClicked()
}
function setDnsPriority(dp) {
root.config["dns-priority"] = dp
ipv4DnsMode.dnsPriority = dp
root.editClicked()
}

name: "ipv4Title"
displayName: qsTr("IPv4")
Expand Down Expand Up @@ -245,17 +254,69 @@ DccObject {
weight: root.weight + 90
visible: type === NetType.VPNControlItem
displayName: qsTr("Only applied in corresponding resources")
description: qsTr("When enabled, only traffic to the target network is routed through the VPN. Other traffic continues to use the local network connection.")
canSearch: false
pageType: DccObject.Item
page: D.CheckBox {
text: dccObj.displayName
checked: root.config && root.config.hasOwnProperty("never-default") ? root.config["never-default"] : false
backgroundType: DccObject.Normal
pageType: DccObject.Editor
page: D.Switch {
checked: root.neverDefault
onClicked: {
root.neverDefault = checked
root.config["never-default"] = checked
root.editClicked()
}
}
}

DccObject {
id: ipv4DnsMode
property int dnsPriority: 0
readonly property int dnsModeIndex: dnsPriority === 100 ? 1 : dnsPriority === -100 ? 2 : 0
readonly property int dnsPriorityFromConfig: root.config && root.config["dns-priority"] !== undefined ? root.config["dns-priority"] : 0
name: "ipv4DnsMode"
parentName: root.parentName
weight: root.weight + 95
visible: type === NetType.VPNControlItem && root.neverDefault && root.resolvedAvailable
displayName: qsTr("VPN DNS Mode")
description: {
switch (dnsPriority) {
case 100: return qsTr("The system uses both local DNS and VPN DNS for resolution, and prefers the result returned first.")
case -100: return qsTr("Prefer VPN DNS. All DNS queries are sent through the VPN connection.")
default: return qsTr("Do not specify how VPN DNS is used. Keep the current system DNS resolution policy.")
}
}
canSearch: false
backgroundType: DccObject.Normal
pageType: DccObject.Editor
page: ComboBox {
flat: true
textRole: "text"
valueRole: "value"
currentIndex: ipv4DnsMode.dnsModeIndex

model: [
{ value: 0, text: qsTr("Not Set") },
{ value: 100, text: qsTr("Secondary") },
{ value: -100, text: qsTr("Preferred") }
]
onActivated: {
root.config["dns-priority"] = currentValue
ipv4DnsMode.dnsPriority = currentValue
root.editClicked()
root.dnsPriorityChanged(currentValue)
}
Component.onCompleted: {
ipv4DnsMode.dnsPriority = ipv4DnsMode.dnsPriorityFromConfig
}
Connections {
target: root
function onConfigChanged() {
ipv4DnsMode.dnsPriority = ipv4DnsMode.dnsPriorityFromConfig
}
}
}
}

DccRepeater {
model: root.addressData
delegate: DccObject {
Expand Down
69 changes: 65 additions & 4 deletions dcc-network/qml/SectionIPv6.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ DccObject {

property string errorKey: ""
property string errorMsg: ""
property bool neverDefault: false
property bool resolvedAvailable: false

signal editClicked
signal dnsPriorityChanged(int priority)

function setDnsPriority(dp) {
root.config["dns-priority"] = dp
ipv6DnsMode.dnsPriority = dp
root.editClicked()
}

function setConfig(c) {
errorKey = ""
Expand All @@ -35,6 +45,7 @@ DccObject {
} else {
root.config = c
method = root.config.method
neverDefault = root.config && root.config["never-default"] === true
addressData = (root.config && root.config.hasOwnProperty("address-data")) ? root.config["address-data"] : []
gateway = []
gateway[0] = (root.config && root.config.hasOwnProperty("gateway")) ? root.config["gateway"] : ""
Expand Down Expand Up @@ -246,17 +257,67 @@ DccObject {
weight: root.weight + 90
visible: root.visible && type === NetType.VPNControlItem
displayName: qsTr("Only applied in corresponding resources")
description: qsTr("When enabled, only traffic to the target network is routed through the VPN. Other traffic continues to use the local network connection.")
canSearch: false
pageType: DccObject.Item
page: D.CheckBox {
text: dccObj.displayName
checked: root.config.hasOwnProperty("never-default") ? root.config["never-default"] : false
backgroundType: DccObject.Normal
pageType: DccObject.Editor
page: D.Switch {
checked: root.neverDefault
onClicked: {
root.neverDefault = checked
root.config["never-default"] = checked
root.editClicked()
}
}
}
DccObject {
id: ipv6DnsMode
property int dnsPriority: 0
readonly property int dnsModeIndex: dnsPriority === 100 ? 1 : dnsPriority === -100 ? 2 : 0
readonly property int dnsPriorityFromConfig: root.config && root.config["dns-priority"] !== undefined ? root.config["dns-priority"] : 0
name: "ipv6DnsMode"
parentName: root.parentName
weight: root.weight + 95
visible: root.visible && root.neverDefault && root.resolvedAvailable
displayName: qsTr("VPN DNS Mode")
description: {
switch (dnsPriority) {
case 100: return qsTr("The system uses both local DNS and VPN DNS for resolution, and prefers the result returned first.")
case -100: return qsTr("Prefer VPN DNS. All DNS queries are sent through the VPN connection.")
default: return qsTr("Do not specify how VPN DNS is used. Keep the current system DNS resolution policy.")
}
}
canSearch: false
backgroundType: DccObject.Normal
pageType: DccObject.Editor
page: ComboBox {
flat: true
textRole: "text"
valueRole: "value"
currentIndex: ipv6DnsMode.dnsModeIndex

model: [
{ value: 0, text: qsTr("Not Set") },
{ value: 100, text: qsTr("Secondary") },
{ value: -100, text: qsTr("Preferred") }
]
onActivated: {
root.config["dns-priority"] = currentValue
ipv6DnsMode.dnsPriority = currentValue
root.editClicked()
root.dnsPriorityChanged(currentValue)
}
Component.onCompleted: {
ipv6DnsMode.dnsPriority = ipv6DnsMode.dnsPriorityFromConfig
}
Connections {
target: root
function onConfigChanged() {
ipv6DnsMode.dnsPriority = ipv6DnsMode.dnsPriorityFromConfig
}
}
}
}
DccRepeater {
model: root.addressData
delegate: DccObject {
Expand Down
64 changes: 64 additions & 0 deletions dcc-network/translations/network_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,38 @@
<source>Only one gateway is allowed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>When enabled, only traffic to the target network is routed through the VPN. Other traffic continues to use the local network connection.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>VPN DNS Mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The system uses both local DNS and VPN DNS for resolution, and prefers the result returned first.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prefer VPN DNS. All DNS queries are sent through the VPN connection.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do not specify how VPN DNS is used. Keep the current system DNS resolution policy.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Not Set</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Secondary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Preferred</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SectionIPv6</name>
Expand Down Expand Up @@ -766,6 +798,38 @@
<source>Only one gateway is allowed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>When enabled, only traffic to the target network is routed through the VPN. Other traffic continues to use the local network connection.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>VPN DNS Mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The system uses both local DNS and VPN DNS for resolution, and prefers the result returned first.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Prefer VPN DNS. All DNS queries are sent through the VPN connection.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do not specify how VPN DNS is used. Keep the current system DNS resolution policy.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Not Set</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Secondary</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Preferred</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SectionPPP</name>
Expand Down
Loading
Loading