Skip to content

Instantly share code, notes, and snippets.

@ijanos
Created October 22, 2013 12:04
Show Gist options
  • Save ijanos/7099420 to your computer and use it in GitHub Desktop.
Save ijanos/7099420 to your computer and use it in GitHub Desktop.
for _, intro := range introspectPath("/com/github/guelfey/Demo") {
fmt.Println(intro.path, intro.introspectableXML)
conn.Export(introspect.Introspectable(intro.introspectableXML), dbus.ObjectPath(intro.path), "org.freedesktop.DBus.Introspectable")
}
package main
import "fmt"
import "strings"
type introspectHelp struct {
introspectableXML string
path string
}
func createNode(name string) string {
nodeXML := `<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<node name="%v"/>
</node>`
return fmt.Sprintf(nodeXML, name)
}
func introspectPath(path string) []introspectHelp {
current := []string{}
elements := strings.Split(path, "/")
ret := []introspectHelp{}
for _, element := range elements[1:len(elements)] {
ret = append(ret, introspectHelp{createNode(element), "/" + strings.Join(current, "/")})
current = append(current, element)
}
return ret
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment