mirror of https://github.com/subgraph/fw-daemon
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
581 B
28 lines
581 B
9 years ago
|
package introspect
|
||
|
|
||
|
import (
|
||
|
"encoding/xml"
|
||
9 years ago
|
"github.com/godbus/dbus"
|
||
9 years ago
|
"strings"
|
||
|
)
|
||
|
|
||
|
// Call calls org.freedesktop.Introspectable.Introspect on a remote object
|
||
|
// and returns the introspection data.
|
||
|
func Call(o dbus.BusObject) (*Node, error) {
|
||
|
var xmldata string
|
||
|
var node Node
|
||
|
|
||
|
err := o.Call("org.freedesktop.DBus.Introspectable.Introspect", 0).Store(&xmldata)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
err = xml.NewDecoder(strings.NewReader(xmldata)).Decode(&node)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
if node.Name == "" {
|
||
|
node.Name = string(o.Path())
|
||
|
}
|
||
|
return &node, nil
|
||
|
}
|