Created
October 22, 2013 12:04
-
-
Save ijanos/7099420 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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