mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
net: updates to accomodate iwd + other backends
This commit is contained in:
@@ -76,7 +76,7 @@ Rectangle {
|
|||||||
DankButtonGroup {
|
DankButtonGroup {
|
||||||
id: preferenceControls
|
id: preferenceControls
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
visible: DMSService.apiVersion >= 5
|
visible: DMSService.apiVersion >= 5 && NetworkService.backend !== "iwd"
|
||||||
|
|
||||||
model: ["Ethernet", "WiFi"]
|
model: ["Ethernet", "WiFi"]
|
||||||
currentIndex: currentPreferenceIndex
|
currentIndex: currentPreferenceIndex
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ Singleton {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property bool networkAvailable: false
|
property bool networkAvailable: false
|
||||||
|
property string backend: ""
|
||||||
|
|
||||||
property string networkStatus: "disconnected"
|
property string networkStatus: "disconnected"
|
||||||
property string primaryConnection: ""
|
property string primaryConnection: ""
|
||||||
@@ -109,7 +110,7 @@ Singleton {
|
|||||||
|
|
||||||
function onNetworkStateUpdate(data) {
|
function onNetworkStateUpdate(data) {
|
||||||
const networksCount = data.wifiNetworks?.length ?? "null"
|
const networksCount = data.wifiNetworks?.length ?? "null"
|
||||||
console.log("NetworkManagerService: Subscription update received, networks:", networksCount)
|
console.log("DMSNetworkService: Subscription update received, networks:", networksCount)
|
||||||
updateState(data)
|
updateState(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,8 +149,6 @@ Singleton {
|
|||||||
|
|
||||||
networkAvailable = DMSService.capabilities.includes("network")
|
networkAvailable = DMSService.capabilities.includes("network")
|
||||||
|
|
||||||
console.log("NetworkManagerService: Network available:", networkAvailable)
|
|
||||||
|
|
||||||
if (networkAvailable && !stateInitialized) {
|
if (networkAvailable && !stateInitialized) {
|
||||||
stateInitialized = true
|
stateInitialized = true
|
||||||
getState()
|
getState()
|
||||||
@@ -191,7 +190,6 @@ Singleton {
|
|||||||
if (response.result) {
|
if (response.result) {
|
||||||
updateState(response.result)
|
updateState(response.result)
|
||||||
if (!initialStateFetched && response.result.wifiEnabled && (!response.result.wifiNetworks || response.result.wifiNetworks.length === 0)) {
|
if (!initialStateFetched && response.result.wifiEnabled && (!response.result.wifiNetworks || response.result.wifiNetworks.length === 0)) {
|
||||||
console.log("NetworkManagerService: Initial state has no networks, triggering scan")
|
|
||||||
initialStateFetched = true
|
initialStateFetched = true
|
||||||
Qt.callLater(() => scanWifi())
|
Qt.callLater(() => scanWifi())
|
||||||
}
|
}
|
||||||
@@ -203,6 +201,7 @@ Singleton {
|
|||||||
const previousConnecting = isConnecting
|
const previousConnecting = isConnecting
|
||||||
const previousConnectingSSID = connectingSSID
|
const previousConnectingSSID = connectingSSID
|
||||||
|
|
||||||
|
backend = state.backend || ""
|
||||||
networkStatus = state.networkStatus || "disconnected"
|
networkStatus = state.networkStatus || "disconnected"
|
||||||
primaryConnection = state.primaryConnection || ""
|
primaryConnection = state.primaryConnection || ""
|
||||||
|
|
||||||
@@ -254,7 +253,7 @@ Singleton {
|
|||||||
if (pendingConnectionSSID) {
|
if (pendingConnectionSSID) {
|
||||||
if (wifiConnected && currentWifiSSID === pendingConnectionSSID && wifiIP) {
|
if (wifiConnected && currentWifiSSID === pendingConnectionSSID && wifiIP) {
|
||||||
const elapsed = Date.now() - pendingConnectionStartTime
|
const elapsed = Date.now() - pendingConnectionStartTime
|
||||||
console.info("NetworkManagerService: Successfully connected to", pendingConnectionSSID, "in", elapsed, "ms")
|
console.info("DMSNetworkService: Successfully connected to", pendingConnectionSSID, "in", elapsed, "ms")
|
||||||
ToastService.showInfo(`Connected to ${pendingConnectionSSID}`)
|
ToastService.showInfo(`Connected to ${pendingConnectionSSID}`)
|
||||||
|
|
||||||
if (userPreference === "wifi" || userPreference === "auto") {
|
if (userPreference === "wifi" || userPreference === "auto") {
|
||||||
@@ -264,16 +263,21 @@ Singleton {
|
|||||||
pendingConnectionSSID = ""
|
pendingConnectionSSID = ""
|
||||||
connectionStatus = "connected"
|
connectionStatus = "connected"
|
||||||
} else if (previousConnecting && !isConnecting && !wifiConnected) {
|
} else if (previousConnecting && !isConnecting && !wifiConnected) {
|
||||||
const elapsed = Date.now() - pendingConnectionStartTime
|
const isCancellationError = connectionError === "user-canceled"
|
||||||
|
const isBadCredentials = connectionError === "bad-credentials"
|
||||||
|
|
||||||
if (elapsed < 5000) {
|
if (isCancellationError) {
|
||||||
console.log("NetworkManagerService: Quick connection failure, likely authentication error")
|
connectionStatus = "cancelled"
|
||||||
|
pendingConnectionSSID = ""
|
||||||
|
} else if (isBadCredentials) {
|
||||||
|
const failedSSID = pendingConnectionSSID
|
||||||
connectionStatus = "invalid_password"
|
connectionStatus = "invalid_password"
|
||||||
|
pendingConnectionSSID = ""
|
||||||
|
Qt.callLater(() => {
|
||||||
|
connectToWifi(failedSSID)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
console.log("NetworkManagerService: Connection failed for", pendingConnectionSSID)
|
if (connectionError) {
|
||||||
if (connectionError === "connection-failed") {
|
|
||||||
ToastService.showError(I18n.tr("Connection failed. Check password and try again."))
|
|
||||||
} else if (connectionError) {
|
|
||||||
ToastService.showError(I18n.tr("Failed to connect to ") + pendingConnectionSSID)
|
ToastService.showError(I18n.tr("Failed to connect to ") + pendingConnectionSSID)
|
||||||
}
|
}
|
||||||
connectionStatus = "failed"
|
connectionStatus = "failed"
|
||||||
@@ -315,14 +319,12 @@ Singleton {
|
|||||||
function scanWifi() {
|
function scanWifi() {
|
||||||
if (!networkAvailable || isScanning || !wifiEnabled) return
|
if (!networkAvailable || isScanning || !wifiEnabled) return
|
||||||
|
|
||||||
console.log("NetworkManagerService: Starting WiFi scan...")
|
|
||||||
isScanning = true
|
isScanning = true
|
||||||
DMSService.sendRequest("network.wifi.scan", null, response => {
|
DMSService.sendRequest("network.wifi.scan", null, response => {
|
||||||
isScanning = false
|
isScanning = false
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
console.warn("NetworkManagerService: WiFi scan failed:", response.error)
|
console.warn("DMSNetworkService: WiFi scan failed:", response.error)
|
||||||
} else {
|
} else {
|
||||||
console.info("NetworkManagerService: Scan completed")
|
|
||||||
Qt.callLater(() => getState())
|
Qt.callLater(() => getState())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -362,15 +364,15 @@ Singleton {
|
|||||||
|
|
||||||
DMSService.sendRequest("network.wifi.connect", params, response => {
|
DMSService.sendRequest("network.wifi.connect", params, response => {
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
console.log("NetworkManagerService: Connection request failed:", response.error)
|
if (connectionStatus === "cancelled") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
connectionError = response.error
|
connectionError = response.error
|
||||||
lastConnectionError = response.error
|
lastConnectionError = response.error
|
||||||
pendingConnectionSSID = ""
|
pendingConnectionSSID = ""
|
||||||
connectionStatus = "failed"
|
connectionStatus = "failed"
|
||||||
ToastService.showError(I18n.tr("Failed to start connection to ") + ssid)
|
ToastService.showError(I18n.tr("Failed to start connection to ") + ssid)
|
||||||
} else {
|
|
||||||
console.log("NetworkManagerService: Connection request sent for", ssid)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -390,7 +392,12 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submitCredentials(token, secrets, save) {
|
function submitCredentials(token, secrets, save) {
|
||||||
if (!networkAvailable || DMSService.apiVersion < 7) return
|
console.log("submitCredentials: networkAvailable=" + networkAvailable + " apiVersion=" + DMSService.apiVersion)
|
||||||
|
|
||||||
|
if (!networkAvailable || DMSService.apiVersion < 7) {
|
||||||
|
console.warn("submitCredentials: Aborting - networkAvailable=" + networkAvailable + " apiVersion=" + DMSService.apiVersion)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
token: token,
|
token: token,
|
||||||
@@ -398,13 +405,11 @@ Singleton {
|
|||||||
save: save || false
|
save: save || false
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("NetworkManagerService: Submitting credentials for token", token)
|
|
||||||
|
|
||||||
credentialsRequested = false
|
credentialsRequested = false
|
||||||
|
|
||||||
DMSService.sendRequest("network.credentials.submit", params, response => {
|
DMSService.sendRequest("network.credentials.submit", params, response => {
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
console.warn("NetworkManagerService: Failed to submit credentials:", response.error)
|
console.warn("DMSNetworkService: Failed to submit credentials:", response.error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -413,19 +418,16 @@ Singleton {
|
|||||||
if (!networkAvailable || DMSService.apiVersion < 7) return
|
if (!networkAvailable || DMSService.apiVersion < 7) return
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
token: token,
|
token: token
|
||||||
cancel: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("NetworkManagerService: Cancelling credentials for token", token)
|
|
||||||
|
|
||||||
credentialsRequested = false
|
credentialsRequested = false
|
||||||
pendingConnectionSSID = ""
|
pendingConnectionSSID = ""
|
||||||
connectionStatus = "cancelled"
|
connectionStatus = "cancelled"
|
||||||
|
|
||||||
DMSService.sendRequest("network.credentials.submit", params, response => {
|
DMSService.sendRequest("network.credentials.cancel", params, response => {
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
console.warn("NetworkManagerService: Failed to cancel credentials:", response.error)
|
console.warn("DMSNetworkService: Failed to cancel credentials:", response.error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -271,6 +271,7 @@ Singleton {
|
|||||||
|
|
||||||
function sendRequest(method, params, callback) {
|
function sendRequest(method, params, callback) {
|
||||||
if (!isConnected) {
|
if (!isConnected) {
|
||||||
|
console.warn("DMSService.sendRequest: Not connected, method:", method)
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback({
|
callback({
|
||||||
"error": "not connected to DMS socket"
|
"error": "not connected to DMS socket"
|
||||||
@@ -294,6 +295,7 @@ Singleton {
|
|||||||
pendingRequests[id] = callback
|
pendingRequests[id] = callback
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("DMSService.sendRequest: Sending request id=" + id + " method=" + method)
|
||||||
requestSocket.send(request)
|
requestSocket.send(request)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ Singleton {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property bool networkAvailable: activeService !== null
|
property bool networkAvailable: activeService !== null
|
||||||
|
property string backend: activeService?.backend ?? ""
|
||||||
property string networkStatus: activeService?.networkStatus ?? "disconnected"
|
property string networkStatus: activeService?.networkStatus ?? "disconnected"
|
||||||
property string primaryConnection: activeService?.primaryConnection ?? ""
|
property string primaryConnection: activeService?.primaryConnection ?? ""
|
||||||
|
|
||||||
@@ -97,16 +98,16 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: NetworkManagerService
|
target: DMSNetworkService
|
||||||
|
|
||||||
function onNetworkAvailableChanged() {
|
function onNetworkAvailableChanged() {
|
||||||
if (!activeService && NetworkManagerService.networkAvailable) {
|
if (!activeService && DMSNetworkService.networkAvailable) {
|
||||||
console.info("NetworkService: Network capability detected, using NetworkManagerService")
|
console.info("NetworkService: Network capability detected, using DMSNetworkService")
|
||||||
activeService = NetworkManagerService
|
activeService = DMSNetworkService
|
||||||
usingLegacy = false
|
usingLegacy = false
|
||||||
console.info("NetworkService: Switched to NetworkManagerService, networkAvailable:", networkAvailable)
|
console.info("NetworkService: Switched to DMSNetworkService, networkAvailable:", networkAvailable)
|
||||||
connectSignals()
|
connectSignals()
|
||||||
} else if (!activeService && !NetworkManagerService.networkAvailable && socketPath && socketPath.length > 0) {
|
} else if (!activeService && !DMSNetworkService.networkAvailable && socketPath && socketPath.length > 0) {
|
||||||
console.info("NetworkService: Network capability not available in DMS, using LegacyNetworkService")
|
console.info("NetworkService: Network capability not available in DMS, using LegacyNetworkService")
|
||||||
useLegacyService()
|
useLegacyService()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -734,7 +734,7 @@
|
|||||||
{
|
{
|
||||||
"term": "Configuration activated",
|
"term": "Configuration activated",
|
||||||
"context": "Configuration activated",
|
"context": "Configuration activated",
|
||||||
"reference": "Services/NetworkManagerService.qml:308",
|
"reference": "Services/DMSNetworkService.qml:308",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -782,7 +782,7 @@
|
|||||||
{
|
{
|
||||||
"term": "Connection failed. Check password and try again.",
|
"term": "Connection failed. Check password and try again.",
|
||||||
"context": "Connection failed. Check password and try again.",
|
"context": "Connection failed. Check password and try again.",
|
||||||
"reference": "Services/NetworkManagerService.qml:275",
|
"reference": "Services/DMSNetworkService.qml:275",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1028,7 +1028,7 @@
|
|||||||
{
|
{
|
||||||
"term": "Disconnected from WiFi",
|
"term": "Disconnected from WiFi",
|
||||||
"context": "Disconnected from WiFi",
|
"context": "Disconnected from WiFi",
|
||||||
"reference": "Services/NetworkManagerService.qml:385",
|
"reference": "Services/DMSNetworkService.qml:385",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1292,25 +1292,25 @@
|
|||||||
{
|
{
|
||||||
"term": "Failed to activate configuration",
|
"term": "Failed to activate configuration",
|
||||||
"context": "Failed to activate configuration",
|
"context": "Failed to activate configuration",
|
||||||
"reference": "Services/NetworkManagerService.qml:304",
|
"reference": "Services/DMSNetworkService.qml:304",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"term": "Failed to connect to ",
|
"term": "Failed to connect to ",
|
||||||
"context": "Failed to connect to ",
|
"context": "Failed to connect to ",
|
||||||
"reference": "Services/NetworkManagerService.qml:277",
|
"reference": "Services/DMSNetworkService.qml:277",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"term": "Failed to disconnect WiFi",
|
"term": "Failed to disconnect WiFi",
|
||||||
"context": "Failed to disconnect WiFi",
|
"context": "Failed to disconnect WiFi",
|
||||||
"reference": "Services/NetworkManagerService.qml:383",
|
"reference": "Services/DMSNetworkService.qml:383",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"term": "Failed to enable WiFi",
|
"term": "Failed to enable WiFi",
|
||||||
"context": "Failed to enable WiFi",
|
"context": "Failed to enable WiFi",
|
||||||
"reference": "Services/NetworkManagerService.qml:484",
|
"reference": "Services/DMSNetworkService.qml:484",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1334,7 +1334,7 @@
|
|||||||
{
|
{
|
||||||
"term": "Failed to start connection to ",
|
"term": "Failed to start connection to ",
|
||||||
"context": "Failed to start connection to ",
|
"context": "Failed to start connection to ",
|
||||||
"reference": "Services/NetworkManagerService.qml:371",
|
"reference": "Services/DMSNetworkService.qml:371",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1424,7 +1424,7 @@
|
|||||||
{
|
{
|
||||||
"term": "Forgot network ",
|
"term": "Forgot network ",
|
||||||
"context": "Forgot network ",
|
"context": "Forgot network ",
|
||||||
"reference": "Services/NetworkManagerService.qml:441",
|
"reference": "Services/DMSNetworkService.qml:441",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -3500,13 +3500,13 @@
|
|||||||
{
|
{
|
||||||
"term": "WiFi disabled",
|
"term": "WiFi disabled",
|
||||||
"context": "WiFi disabled",
|
"context": "WiFi disabled",
|
||||||
"reference": "Services/NetworkManagerService.qml:474",
|
"reference": "Services/DMSNetworkService.qml:474",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"term": "WiFi enabled",
|
"term": "WiFi enabled",
|
||||||
"context": "WiFi enabled",
|
"context": "WiFi enabled",
|
||||||
"reference": "Services/NetworkManagerService.qml:474, Services/NetworkManagerService.qml:486",
|
"reference": "Services/DMSNetworkService.qml:474, Services/DMSNetworkService.qml:486",
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user