Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add helper method to parse PropertiesChanged #201

Open
maltegrosse opened this issue Apr 23, 2020 · 2 comments
Open

Feature Request: Add helper method to parse PropertiesChanged #201

maltegrosse opened this issue Apr 23, 2020 · 2 comments

Comments

@maltegrosse
Copy link

Hi, wouldnt it be helpful to have a helper method to parse the properties changed signal?

PropertiesChanged(s interface_name, {sv} changed_properties, as invalidated_properties):
interface_name: name of the interface on which the properties are defined
changed_properties: changed properties with new values
invalidated_properties: changed properties but the new values are not send with them

something like:

func (d *dbusBase) parsePropertiesChanged(v *dbus.Signal) (interfaceName string, changedProperties map[string]dbus.Variant, invalidatedProperties []string, err error) {
	if len(v.Body )!= 3{
		err = errors.New("error by parsing property changed signal")
		return
	}
	interfaceName, ok := v.Body[0].(string)
	if !ok {
		err = errors.New("error by parsing interface name")
		return
	}
	changedProperties, ok = v.Body[1].(map[string]dbus.Variant)
	if !ok {
		err = errors.New("error by parsing changed properties map name")
		return
	}
	invalidatedProperties, ok = v.Body[2].([]string)
	if !ok {
		err = errors.New("error by parsing invalidated properties")
		return
	}
	return
}
@jsouthworth
Copy link
Member

Sounds like a good addition. If you would like to contribute this, please open a PR so we can discuss further.

damianmyers2 pushed a commit to damianmyers2/dbus that referenced this issue Jun 17, 2023
Introducing a new type PropertiesChanged that conforms to the
PropertiesChanged signal body fields. The Signal type will now
have a func that parsed the Signal body and return the new type.
Included some supporting functionality for PropertiesChanged to
check for and get changed properties.

Addresses godbus#201
@damianmyers2
Copy link

Saw this issue while working on another project, seemed like a fun thing to tackle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants