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

Protocol: add support for implementing DBus.Introspectable. #226

Merged
merged 1 commit into from
Jan 27, 2024

Conversation

tmds
Copy link
Owner

@tmds tmds commented Jan 26, 2024

Fixes #220.

@tmds
Copy link
Owner Author

tmds commented Jan 26, 2024

@jmacato @affederaffe this provides Introspectable support for the Protocol library.

As a library user, you can look at the docs/protocol.md file on how to use this.

Feel free to review the PR and provide feedback.

I'll merge this some time next week, and then you can try this out further using a NuGet package from the CI feed.
If this is working well for you, I'll make a new release to nuget.org.

@tmds
Copy link
Owner Author

tmds commented Jan 27, 2024

I'm going to merge this already. The PR comes with many tests, so it is more interesting to have it on the CI feed where you can consume it easily.

When you change to this build, this will happen: the library will handle the Peer interface, and the Introspectable interface without needing any changes. If you use a tool like D-Feet, you'll see the objects appear.

To have the interfaces show up that an IMethodHandler implements, the handler must include the following in its HandleMethodAsync:

        if (context.IsDBusIntrospectRequest)
        {
            context.ReplyIntrospectXml([ ... ]);
            return default;
        }

The argument is an ReadOnlySpan<ReadOnlyMemory<byte>> interfaceXmls which enables passing a list of UTF-8 encoded interface xmls.

There's no need to pass Peer or Introspectable, this gets handled by the library.

IMethodHandlers that implement the Properties interface, can pass IntrospectionXml.DBusProperties for that.

The library takes care of adding the child names in the response.

@tmds tmds merged commit d50bafb into main Jan 27, 2024
2 checks passed
@tmds tmds deleted the protocol_introspect branch January 31, 2024 13:21
@tmds
Copy link
Owner Author

tmds commented Jan 31, 2024

This is part of 0.16.0 which was just published to nuget.org.

@affederaffe
Copy link
Contributor

Thanks, that seems to be a good solution.
Tmds.DBus.SourceGenerator now exposes this API with ObserverFlags.None as the default.

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.

Adding default DBus interfaces on all objects
2 participants