1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-04 21:02:06 -04:00

core/dbus: support Normalize for more dbus types

This commit is contained in:
bbedward
2026-01-28 13:28:13 -05:00
parent eda59b348c
commit 757054e140
3 changed files with 37 additions and 8 deletions

View File

@@ -65,7 +65,7 @@ func (m *Manager) Call(bus, dest, path, iface, method string, args []any) (*Call
return nil, fmt.Errorf("dbus call failed: %w", call.Err)
}
return &CallResult{Values: call.Body}, nil
return &CallResult{Values: dbusutil.NormalizeSlice(call.Body)}, nil
}
func (m *Manager) GetProperty(bus, dest, path, iface, property string) (*PropertyResult, error) {

View File

@@ -49,12 +49,38 @@ func Normalize(v any) any {
result[k] = Normalize(vv.Value())
}
return result
case map[string]any:
result := make(map[string]any)
for k, vv := range val {
result[k] = Normalize(vv)
}
return result
case map[dbus.ObjectPath]map[string]map[string]dbus.Variant:
result := make(map[string]any)
for path, ifaces := range val {
ifaceMap := make(map[string]any)
for ifaceName, props := range ifaces {
propMap := make(map[string]any)
for propName, propVal := range props {
propMap[propName] = Normalize(propVal.Value())
}
ifaceMap[ifaceName] = propMap
}
result[string(path)] = ifaceMap
}
return result
case []any:
result := make([]any, len(val))
for i, item := range val {
result[i] = Normalize(item)
}
return result
case []dbus.Variant:
result := make([]any, len(val))
for i, item := range val {
result[i] = Normalize(item.Value())
}
return result
default:
return v
}