summaryrefslogtreecommitdiff
path: root/vendor/src/github.com/godbus/dbus/introspect/call.go
blob: 4aca2ea63e695058794a697facb4897f5599062d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package introspect

import (
	"encoding/xml"
	"github.com/godbus/dbus"
	"strings"
)

// Call calls org.freedesktop.Introspectable.Introspect on a remote object
// and returns the introspection data.
func Call(o *dbus.Object) (*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
}