예제 #1
0
func recurseObjects(bus *dbus.Conn, service, prefix string) ([]string, error) {
	var s string

	err := bus.Object(service, dbus.ObjectPath(prefix)).Call("org.freedesktop.DBus.Introspectable.Introspect", 0).Store(&s)
	if err != nil {
		return nil, err
	}

	var n introspect.Node
	err = xml.Unmarshal([]byte(s), &n)
	if err != nil {
		return nil, err
	}

	names := make([]string, 0, 100)
	if len(n.Interfaces) > 1 {
		names = append(names, prefix)
	}

	for _, child := range n.Children {
		childPath := path.Join(prefix, child.Name)
		items, err := recurseObjects(bus, service, childPath)
		if err != nil {
			return nil, err
		}
		names = append(names, items...)
	}

	return names, nil
}
예제 #2
0
func traverseDbusObjects(bus *dbus.Conn, dbusService, dbusPath string, fn func(path string, node *introspect.Node)) {
	var xmldata string
	var node introspect.Node

	var o = bus.Object(dbusService, dbus.ObjectPath(dbusPath))
	err := o.Call("org.freedesktop.DBus.Introspectable.Introspect", 0).Store(&xmldata)

	if err != nil {
		log.Printf("Error getting introspect from [%s, %s]: %s", dbusService, dbusPath, err)
	}

	err = xml.NewDecoder(strings.NewReader(xmldata)).Decode(&node)
	if err != nil {
		log.Printf("Error decoding introspect from [%s, %s]: %s", dbusService, dbusPath, err)
	}
	// log.Printf("Introspect: %+v", node)

	if node.Name != "" && len(node.Interfaces) > 0 {
		fn(dbusPath, &node)
	}

	for _, child := range node.Children {
		traverseDbusObjects(bus, dbusService, dbusPath+"/"+child.Name, fn)
	}
}
예제 #3
0
파일: prompt.go 프로젝트: Safe3/fw-daemon
func newPrompter(conn *dbus.Conn) *prompter {
	p := new(prompter)
	p.cond = sync.NewCond(&p.lock)
	p.dbusObj = conn.Object("com.subgraph.FirewallPrompt", "/com/subgraph/FirewallPrompt")
	p.policyMap = make(map[string]*Policy)
	go p.promptLoop()
	return p
}
예제 #4
0
파일: mpris.go 프로젝트: emersion/go-mpris
func New(conn *dbus.Conn, name string) *Player {
	obj := conn.Object(name, dbusObjectPath).(*dbus.Object)

	return &Player{
		&base{obj},
		&player{obj},
	}
}
예제 #5
0
// SendNotification is same as Notifier.SendNotification
// Provided for convenience.
func SendNotification(conn *dbus.Conn, note Notification) (uint32, error) {
	obj := conn.Object(dbusNotificationsInterface, objectPath)
	call := obj.Call(notify, 0,
		note.AppName,
		note.ReplacesID,
		note.AppIcon,
		note.Summary,
		note.Body,
		note.Actions,
		note.Hints,
		note.ExpireTimeout)
	if call.Err != nil {
		return 0, call.Err
	}
	var ret uint32
	err := call.Store(&ret)
	if err != nil {
		log.Printf("error getting uint32 ret value: %v", err)
		return ret, err
	}
	return ret, nil
}
예제 #6
0
파일: job.go 프로젝트: amoghe/go-upstart
// dbusPath returns the dbus path of the job object.
func (j *job) dbusPath(conn *dbus.Conn) (dbus.ObjectPath, error) {

	var jobpath dbus.ObjectPath

	// get the job path
	err := conn.
		Object(upstartServiceDBusPath, upstartManagerObject).
		Call("com.ubuntu.Upstart0_6.GetJobByName", 0, j.Name).
		Store(&jobpath)
	if err != nil {
		return jobpath, err
	}

	return jobpath, nil
}
예제 #7
0
파일: dbus.go 프로젝트: Clarifai/kubernetes
func systemdObject(conn *dbus.Conn) dbus.BusObject {
	return conn.Object("org.freedesktop.systemd1", dbus.ObjectPath("/org/freedesktop/systemd1"))
}
예제 #8
0
파일: dbus.go 프로젝트: sarifsystems/sarif
func NewNotificationObject(conn *dbus.Conn) *NotificationObject {
	return &NotificationObject{
		conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications"),
	}
}
예제 #9
0
func NewCollection(conn *dbus.Conn, path dbus.ObjectPath) *Collection {
	return &Collection{
		conn: conn,
		dbus: conn.Object(DBusServiceName, path),
	}
}
예제 #10
0
func NewLogindObject(conn *dbus.Conn) *LogindObject {
	return &LogindObject{
		conn.Object("org.freedesktop.login1", "/org/freedesktop/login1"),
	}
}
예제 #11
0
파일: item.go 프로젝트: 99designs/aws-vault
func NewItem(conn *dbus.Conn, path dbus.ObjectPath) *Item {
	return &Item{
		conn: conn,
		dbus: conn.Object(DBusServiceName, path),
	}
}
예제 #12
0
func NewSession(conn *dbus.Conn, path dbus.ObjectPath) *Session {
	return &Session{
		conn: conn,
		dbus: conn.Object(DBusServiceName, path),
	}
}