-
Notifications
You must be signed in to change notification settings - Fork 243
Closed
Labels
Description
package main
import (
"fmt"
"os"
"github.com/godbus/dbus/v5"
"github.com/godbus/dbus/v5/introspect"
"github.com/godbus/dbus/v5/prop"
)
// Type definition of ObjectPath is: type ObjectPath string
func main() {
conn, err := dbus.SessionBus()
if err != nil {
panic(err)
}
replyP, errP := conn.RequestName("a.b", dbus.NameFlagDoNotQueue)
if errP != nil {
panic(errP)
}
if replyP != dbus.RequestNameReplyPrimaryOwner {
fmt.Fprintln(os.Stderr, "name already taken")
os.Exit(1)
}
propsSpec := map[string]map[string]*prop.Prop{
"a.b.Test": {
"Something": {
Value: []dbus.ObjectPath{}, // PROBLEM
// Value: []string{}, // OK
Writable: false,
},
},
}
props, err := prop.Export(conn, "/a/b", propsSpec)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "export propsSpec failed: %v\n", err)
os.Exit(1)
}
var introZ = &introspect.Node{
Name: "/a/b",
Interfaces: []introspect.Interface{
introspect.IntrospectData, prop.IntrospectData,
{
Name: "a.b.Test",
Properties: props.Introspection("a.b.Test"),
},
},
}
// Change dbus property
// props.SetMust("a.b.Test", "Something", []string{"a", "b"}) // OK
// Change dbus property
props.SetMust("a.b.Test", "Something",
[]dbus.ObjectPath{dbus.ObjectPath("a"), dbus.ObjectPath("b")}) // PROBLEM
conn.Export(introspect.NewIntrospectable(&introspect.Node{
Name: "/a/b",
}), "/a/b", "org.freedesktop.DBus.Introspectable")
conn.Export(introspect.NewIntrospectable(introZ), "/a/b",
"org.freedesktop.DBus.Introspectable")
fmt.Printf("Listening on %s / %s ...\n", "a.b...", "/a/b...")
select {} // Don't exit program
}
Reactions are currently unavailable