mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-24 03:55:23 -04:00
fix(network): fix excessive network prompting on failures, add VPN
connection statuses
This commit is contained in:
@@ -84,6 +84,8 @@ Singleton {
|
||||
property string lastConnectedVpnUuid: ""
|
||||
property string pendingVpnUuid: ""
|
||||
property var vpnBusyStartTime: 0
|
||||
property string vpnError: ""
|
||||
property string vpnErrorUuid: ""
|
||||
|
||||
property var profiles: {
|
||||
const mergedProfiles = vpnProfiles ? vpnProfiles.slice() : [];
|
||||
@@ -137,6 +139,17 @@ Singleton {
|
||||
property alias isBusy: root.vpnIsBusy
|
||||
property alias connected: root.vpnConnected
|
||||
|
||||
function vpnStateForUuid(uuid) {
|
||||
if (!uuid)
|
||||
return "";
|
||||
const match = vpnActive.find(v => v.uuid === uuid);
|
||||
return match ? (match.state || "") : "";
|
||||
}
|
||||
|
||||
function isVpnConnectingUuid(uuid) {
|
||||
return vpnStateForUuid(uuid) === "activating" || (vpnIsBusy && pendingVpnUuid === uuid);
|
||||
}
|
||||
|
||||
property string networkInfoSSID: ""
|
||||
property string networkInfoDetails: ""
|
||||
property bool networkInfoLoading: false
|
||||
@@ -372,6 +385,17 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
const incomingVpnError = state.vpnError || "";
|
||||
if (incomingVpnError && incomingVpnError !== vpnError) {
|
||||
vpnIsBusy = false;
|
||||
pendingVpnUuid = "";
|
||||
vpnBusyStartTime = 0;
|
||||
const failedName = (vpnProfiles.find(p => p.uuid === state.vpnErrorUuid)?.name) || I18n.tr("VPN");
|
||||
ToastService.showError(I18n.tr("%1: %2").arg(failedName).arg(incomingVpnError));
|
||||
}
|
||||
vpnError = incomingVpnError;
|
||||
vpnErrorUuid = state.vpnErrorUuid || "";
|
||||
|
||||
isConnecting = state.isConnecting || false;
|
||||
connectingSSID = state.connectingSSID || "";
|
||||
connectionError = state.lastError || "";
|
||||
|
||||
@@ -25,6 +25,7 @@ Singleton {
|
||||
signal importComplete(string uuid, string name)
|
||||
signal configLoaded(var config)
|
||||
signal configUpdated
|
||||
signal credentialsSet(string uuid)
|
||||
signal vpnDeleted(string uuid)
|
||||
|
||||
Component.onCompleted: {
|
||||
@@ -149,6 +150,28 @@ Singleton {
|
||||
});
|
||||
}
|
||||
|
||||
function setCredentials(uuid, username, password, save = true) {
|
||||
if (!available)
|
||||
return;
|
||||
const params = {
|
||||
uuid: uuid,
|
||||
save: save
|
||||
};
|
||||
if (username)
|
||||
params.username = username;
|
||||
if (password)
|
||||
params.password = password;
|
||||
|
||||
DMSService.sendRequest("network.vpn.setCredentials", params, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to save VPN credentials"), response.error);
|
||||
return;
|
||||
}
|
||||
ToastService.showInfo(I18n.tr("VPN credentials saved"));
|
||||
credentialsSet(uuid);
|
||||
});
|
||||
}
|
||||
|
||||
function deleteVpn(uuidOrName) {
|
||||
if (!available)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user