mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Merge pull request #2651 from Mathew-D/v5
fix(vpn): Fixed the async connection issue in the VPN service
This commit is contained in:
@@ -36,6 +36,7 @@ namespace {
|
|||||||
constexpr std::uint32_t k_nmDeviceTypeWifi = 2;
|
constexpr std::uint32_t k_nmDeviceTypeWifi = 2;
|
||||||
|
|
||||||
// NMActiveConnectionState
|
// NMActiveConnectionState
|
||||||
|
constexpr std::uint32_t k_nmActiveConnectionStateActivating = 1;
|
||||||
constexpr std::uint32_t k_nmActiveConnectionStateActivated = 2;
|
constexpr std::uint32_t k_nmActiveConnectionStateActivated = 2;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -320,12 +321,13 @@ bool NetworkService::activateVpnConnection(const VpnConnectionInfo& vpn) {
|
|||||||
m_nm->callMethodAsync("ActivateConnection")
|
m_nm->callMethodAsync("ActivateConnection")
|
||||||
.onInterface(k_nmInterface)
|
.onInterface(k_nmInterface)
|
||||||
.withArguments(sdbus::ObjectPath{vpnPath}, sdbus::ObjectPath{"/"}, sdbus::ObjectPath{"/"})
|
.withArguments(sdbus::ObjectPath{vpnPath}, sdbus::ObjectPath{"/"}, sdbus::ObjectPath{"/"})
|
||||||
.uponReplyInvoke([vpnName, vpnPath](std::optional<sdbus::Error> err, sdbus::ObjectPath activePath) {
|
.uponReplyInvoke([this, vpnName, vpnPath](std::optional<sdbus::Error> err, sdbus::ObjectPath activePath) {
|
||||||
if (err.has_value()) {
|
if (err.has_value()) {
|
||||||
kLog.warn("ActivateConnection(vpn) failed name={} path={}: {}", vpnName, vpnPath, err->what());
|
kLog.warn("ActivateConnection(vpn) failed name={} path={}: {}", vpnName, vpnPath, err->what());
|
||||||
} else {
|
} else {
|
||||||
kLog.info("activating vpn name={} active={}", vpnName, std::string(activePath));
|
kLog.info("activating vpn name={} active={}", vpnName, std::string(activePath));
|
||||||
}
|
}
|
||||||
|
refresh();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
} catch (const sdbus::Error& e) {
|
} catch (const sdbus::Error& e) {
|
||||||
@@ -658,7 +660,7 @@ void NetworkService::refreshVpnConnections() {
|
|||||||
try {
|
try {
|
||||||
auto active = sdbus::createProxy(m_bus.connection(), k_nmBusName, activePath);
|
auto active = sdbus::createProxy(m_bus.connection(), k_nmBusName, activePath);
|
||||||
const auto state = getPropertyOr<std::uint32_t>(*active, k_nmActiveConnectionInterface, "State", 0U);
|
const auto state = getPropertyOr<std::uint32_t>(*active, k_nmActiveConnectionInterface, "State", 0U);
|
||||||
if (state != k_nmActiveConnectionStateActivated) {
|
if (state != k_nmActiveConnectionStateActivating && state != k_nmActiveConnectionStateActivated) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto profilePath = getPropertyOr<sdbus::ObjectPath>(*active, k_nmActiveConnectionInterface,
|
const auto profilePath = getPropertyOr<sdbus::ObjectPath>(*active, k_nmActiveConnectionInterface,
|
||||||
|
|||||||
Reference in New Issue
Block a user