-
-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Is your feature request related to a problem? Please describe.
There is currently no way to access message metadata (header flags and fields) in the high-level API. Some use cases require access to this (any service implementation with privileged operations using caller identity for authorization, such as via polkit), and others should have it to conform to D-Bus best practices (such as utilizing the "allow interactive authorization" flag).
Describe the solution you'd like
I'd love to see some optional keyword-only arguments for things like message headers and flags in methods and signal callbacks. Since the library already parses method signatures to get the D-Bus type signature, I think having specific checks for defined keyword-only arguments (i.e., after a *) that would add this metadata would be useful.
I think the most useful field is probably SENDER, so having a dedicated argument just for it would be useful, and given how the other fields are mostly used to determine where the message is routed in the high-level API, there may not need to be another argument to get the full list of header fields.
Basically, what I would like is to be able to write a method like this and have it get the information:
@method
def Foo(self, bar: 's', baz: 'i', *, sender: str, flags: MessageFlag) -> '': ...Additional context
Because it would only consider keyword-only args, which are not supported by D-Bus, this feature wouldn't prevent someone from having a sender or flags positional argument that is exposed to D-Bus. I think that is necessary for this to be something automatic. Because of this, it might also be useful to have an argument to the method decorator to change the default keywords for this metadata "injection", but I don't think it's strictly necessary.