mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-11 16:22:09 -04:00
core/dbus: fix arg types in calls
This commit is contained in:
@@ -60,7 +60,8 @@ func (m *Manager) Call(bus, dest, path, iface, method string, args []any) (*Call
|
|||||||
obj := conn.Object(dest, dbus.ObjectPath(path))
|
obj := conn.Object(dest, dbus.ObjectPath(path))
|
||||||
fullMethod := iface + "." + method
|
fullMethod := iface + "." + method
|
||||||
|
|
||||||
call := obj.Call(fullMethod, 0, args...)
|
convertedArgs := convertArgs(args)
|
||||||
|
call := obj.Call(fullMethod, 0, convertedArgs...)
|
||||||
if call.Err != nil {
|
if call.Err != nil {
|
||||||
return nil, fmt.Errorf("dbus call failed: %w", call.Err)
|
return nil, fmt.Errorf("dbus call failed: %w", call.Err)
|
||||||
}
|
}
|
||||||
@@ -68,6 +69,37 @@ func (m *Manager) Call(bus, dest, path, iface, method string, args []any) (*Call
|
|||||||
return &CallResult{Values: dbusutil.NormalizeSlice(call.Body)}, nil
|
return &CallResult{Values: dbusutil.NormalizeSlice(call.Body)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func convertArgs(args []any) []any {
|
||||||
|
result := make([]any, len(args))
|
||||||
|
for i, arg := range args {
|
||||||
|
result[i] = convertArg(arg)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func convertArg(arg any) any {
|
||||||
|
switch v := arg.(type) {
|
||||||
|
case float64:
|
||||||
|
if v == float64(uint32(v)) && v >= 0 && v <= float64(^uint32(0)) {
|
||||||
|
return uint32(v)
|
||||||
|
}
|
||||||
|
if v == float64(int32(v)) {
|
||||||
|
return int32(v)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
case []any:
|
||||||
|
return convertArgs(v)
|
||||||
|
case map[string]any:
|
||||||
|
result := make(map[string]any)
|
||||||
|
for k, val := range v {
|
||||||
|
result[k] = convertArg(val)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
default:
|
||||||
|
return arg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Manager) GetProperty(bus, dest, path, iface, property string) (*PropertyResult, error) {
|
func (m *Manager) GetProperty(bus, dest, path, iface, property string) (*PropertyResult, error) {
|
||||||
conn, err := m.getConn(bus)
|
conn, err := m.getConn(bus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user