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

global-shortcuts: Signal arguments are outputs #917

Merged

Conversation

aleixpol
Copy link
Contributor

I'm a bit surprised that the different tooling didn't complain about this, is this something that should be supported?

@GeorgesStavracas
Copy link
Member

I don't think this is correct. Out arguments mean the application is handing out values to the D-Bus methods / signals, which is not the case here.

@jadahl
Copy link
Collaborator

jadahl commented Nov 26, 2022

I don't think this is correct. Out arguments mean the application is handing out values to the D-Bus methods / signals, which is not the case here.

Out means it's the service that provides and client that receives. See for example org.freedesktop.impl.portal.Settings.SettingChanged .

But I believe the "direction" part could be removed completely, and I think it'll default to out.

@aleixpol
Copy link
Contributor Author

I don't think this is correct. Out arguments mean the application is handing out values to the D-Bus methods / signals, which is not the case here.

Out means it's the service that provides and client that receives. See for example org.freedesktop.impl.portal.Settings.SettingChanged .

But I believe the "direction" part could be removed completely, and I think it'll default to out.

That's correct. If you prefer I can remove it too.

@jadahl
Copy link
Collaborator

jadahl commented Nov 26, 2022

That's correct. If you prefer I can remove it too.

Personally I have no preference, and both ways exist already in the other XML files.

@aleixpol
Copy link
Contributor Author

Okay, then I suggest we merge this.

FYI, did this when implementing mumble's support as a client implementation of the portal.
mumble-voip/mumble#5976

@jadahl
Copy link
Collaborator

jadahl commented Nov 27, 2022

Okay, then I suggest we merge this.

Alright.

@jadahl jadahl merged commit d4bba6a into flatpak:main Nov 27, 2022
Copy link
Collaborator

@smcv smcv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The D-Bus Specification says:

The direction element on may be omitted, in which case it defaults to "in" for method calls and "out" for signals. Signals only allow "out" so while direction may be specified, it's pointless.

which implies that changing them to be explicitly out is valid; but if you look at the introspect.dtd provided in the dbus source code, technically the default for validating XML parsers is in... so really it's anyone's guess.

The "direction" of a signal argument is meaningless anyway: signals are a single message from sender to recipient(s), so there is no need to partition arguments into "this goes in the method call" and "this goes in the method reply" like we do for method calls.

In practice I would expect all D-Bus implementations to be able to cope with a signal with no direction specified, and I would expect that explicitly specifying the direction is more likely to break someone.

One place where this might genuinely matter is for QtDBus' type annotations.

If I was designing D-Bus introspection today and I was forced to use XML, I'd probably use something like <method><in><arg/>...</in><out><arg/>...</out></method> vs. <signal><arg/>...</signal>; but we're about 20 years too late for that change, so no. Then again, if you were designing Qt's dialect of D-Bus introspection today, you'd probably put the Qt annotations inside the <arg> (which was a new spec feature in 2016), rather than putting them one level up from where they should be and using argument numbering...

<arg type="s" name="shortcut_id" direction="out"/>
<arg type="t" name="timestamp" direction="out"/>
<arg type="a{sv}" name="options" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="QVariantMap"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? You've given it 4 out arguments, and I infer from your other contributions of this annotation that they're using 0-based indexing, so I'd expect the annotation to be .Out3 now?

(If I'm reading correctly, this was also an attempt at a silent bug-fix for Qt consumers because the annotation used to apply to a nonexistent 5th argument (In4 in 0-based indexing), and was changed to point to the 4th argument?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aleixpol, can you open a PR changing In3 to Out3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#923

Good catch!

I was thinking it could make sense to run qtdbusxmltocpp in the CI to make sure it's all sound. Do you think it would be useful?

It would also need fixing some of the files that at the moment are not entirely working with it just yet.

@aleixpol aleixpol deleted the work/apol/globalshortcuts-signal-direction branch December 2, 2022 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants