Default value for `in` parameter

Charles Wong ymqiuyu at gmail.com
Sat Jan 28 17:26:18 UTC 2023


I'll use this way as a solution.

Thank you very much.

On Sat, Jan 28, 2023 at 11:22 PM Robert Middleton <
robert.middleton at rm5248.com> wrote:

> DBus methods are similar to C in that all defined arguments are
> required to methods.  It is possible that specific
> implementations/language bindings may allow you to have default
> values, but that is not something that I am aware of.
>
> If you have optional arguments, the best way to implement that would
> be to send a map<string,variant>(or a{sv} in dbus-speak) that lets you
> test for arguments that may or may not exist.  This mechanism is used
> by DBus itself for messages, as well as some standard services like
> the org.freedesktop.Notifications[1].
>
> -Robert Middleton
>
> [1]:
> https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html
>
> On Sat, Jan 28, 2023 at 7:01 AM Charles Wong <ymqiuyu at gmail.com> wrote:
> >
> > Hi,
> >
> > Is this the  right place to ask dbus questions?
> >
> > For example, there is a dbus config (is from
> https://gjs.guide/guides/gio/dbus.html#high-level-proxies):
> > ```xml
> > <method name="ComplexMethod">
> >     <arg type="b" direction="in" name="input"/>
> >     <arg type="u" direction="out" name="length"/>
> > </method>
> > ```
> >
> > Is it possible to set a default value to parameter `input` and mark it
> as unrequired?
> >
> > Just like in spring mvc, we can set a parameter `required=false` and set
> `default` value too:
> > `@RequestParam(required = false, defaultValue = "default value") String
> parameter`
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dbus/attachments/20230129/a7416d4e/attachment.htm>


More information about the dbus mailing list