Пример #1
0
func getProperty(obj *dbus.Object, iface string, prop string) dbus.Variant {
	result := dbus.Variant{}
	err := obj.Call(getPropertyMethod, 0, iface, prop).Store(&result)
	if err != nil {
		log.Println("Warning: could not get dbus property:", iface, prop, err)
		return dbus.Variant{}
	}
	return result
}
Пример #2
0
func (a *AccountService) SetUserProperty(user *dbus.Object, propName string, propValue interface{}) error {
	methodName := a.propMethodMap[propName]
	if methodName == "" {
		return ErrInvalidProperty
	}

	if call := user.Call(fmt.Sprintf("org.freedesktop.Accounts.User.%v", methodName), 0, propValue); call.Err != nil {
		return call.Err
	}
	return nil
}
Пример #3
0
func (a *AccountService) GetUserProperty(user *dbus.Object, propName string) (interface{}, error) {
	methodName := a.propMethodMap[propName]
	if methodName == "" {
		return nil, ErrInvalidProperty
	}

	propValue, err := user.GetProperty(fmt.Sprintf("org.freedesktop.Accounts.User.%v", propName))
	if err != nil {
		return nil, err
	}
	return propValue, nil
}
Пример #4
0
// 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
}
Пример #5
0
func setProperty(obj *dbus.Object, iface string, prop string, val interface{}) {
	call := obj.Call(setPropertyMethod, 0, prop, val)
	if call.Err != nil {
		log.Println("Warning: could not set dbus property:", iface, prop, call.Err)
	}
}