1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 05:25:41 -05:00

network: big feature enrichment

- Dedicated view in settings
- VPN profile management
- Ethernet disconnection
- Turn prompts into floating windows
This commit is contained in:
bbedward
2025-11-29 10:00:05 -05:00
parent 9c887fbe63
commit 1d3fe81ff7
51 changed files with 9807 additions and 2500 deletions

View File

@@ -109,6 +109,7 @@ func (m *Manager) syncStateFromBackend() error {
m.state.EthernetDevice = backendState.EthernetDevice
m.state.EthernetConnected = backendState.EthernetConnected
m.state.EthernetConnectionUuid = backendState.EthernetConnectionUuid
m.state.EthernetDevices = backendState.EthernetDevices
m.state.WiFiIP = backendState.WiFiIP
m.state.WiFiDevice = backendState.WiFiDevice
m.state.WiFiConnected = backendState.WiFiConnected
@@ -155,6 +156,7 @@ func (m *Manager) snapshotState() NetworkState {
s.WiFiNetworks = append([]WiFiNetwork(nil), m.state.WiFiNetworks...)
s.WiFiDevices = append([]WiFiDevice(nil), m.state.WiFiDevices...)
s.WiredConnections = append([]WiredConnection(nil), m.state.WiredConnections...)
s.EthernetDevices = append([]EthernetDevice(nil), m.state.EthernetDevices...)
s.VPNProfiles = append([]VPNProfile(nil), m.state.VPNProfiles...)
s.VPNActive = append([]VPNActive(nil), m.state.VPNActive...)
return s
@@ -213,6 +215,9 @@ func stateChangedMeaningfully(old, new *NetworkState) bool {
if len(old.WiredConnections) != len(new.WiredConnections) {
return true
}
if len(old.EthernetDevices) != len(new.EthernetDevices) {
return true
}
for i := range old.WiFiNetworks {
oldNet := &old.WiFiNetworks[i]
@@ -242,6 +247,23 @@ func stateChangedMeaningfully(old, new *NetworkState) bool {
}
}
for i := range old.EthernetDevices {
oldDev := &old.EthernetDevices[i]
newDev := &new.EthernetDevices[i]
if oldDev.Name != newDev.Name {
return true
}
if oldDev.Connected != newDev.Connected {
return true
}
if oldDev.State != newDev.State {
return true
}
if oldDev.IP != newDev.IP {
return true
}
}
// Check VPN profiles count
if len(old.VPNProfiles) != len(new.VPNProfiles) {
return true
@@ -480,6 +502,18 @@ func (m *Manager) DisconnectEthernet() error {
return m.backend.DisconnectEthernet()
}
func (m *Manager) DisconnectEthernetDevice(device string) error {
return m.backend.DisconnectEthernetDevice(device)
}
func (m *Manager) GetEthernetDevices() []EthernetDevice {
m.stateMutex.RLock()
defer m.stateMutex.RUnlock()
devices := make([]EthernetDevice, len(m.state.EthernetDevices))
copy(devices, m.state.EthernetDevices)
return devices
}
func (m *Manager) activateConnection(uuid string) error {
return m.backend.ActivateWiredConnection(uuid)
}
@@ -508,6 +542,30 @@ func (m *Manager) ClearVPNCredentials(uuidOrName string) error {
return m.backend.ClearVPNCredentials(uuidOrName)
}
func (m *Manager) ListVPNPlugins() ([]VPNPlugin, error) {
return m.backend.ListVPNPlugins()
}
func (m *Manager) ImportVPN(filePath string, name string) (*VPNImportResult, error) {
return m.backend.ImportVPN(filePath, name)
}
func (m *Manager) GetVPNConfig(uuidOrName string) (*VPNConfig, error) {
return m.backend.GetVPNConfig(uuidOrName)
}
func (m *Manager) UpdateVPNConfig(uuid string, updates map[string]interface{}) error {
return m.backend.UpdateVPNConfig(uuid, updates)
}
func (m *Manager) DeleteVPN(uuidOrName string) error {
return m.backend.DeleteVPN(uuidOrName)
}
func (m *Manager) SetVPNCredentials(uuid, username, password string, save bool) error {
return m.backend.SetVPNCredentials(uuid, username, password, save)
}
func (m *Manager) SetWiFiAutoconnect(ssid string, autoconnect bool) error {
return m.backend.SetWiFiAutoconnect(ssid, autoconnect)
}