[prev in list] [next in list] [prev in thread] [next in thread]
List: freedesktop-dbus
Subject: Re: Default value for `in` parameter
From: Robert Middleton <robert.middleton () rm5248 ! com>
Date: 2023-01-28 15:22:26
Message-ID: CAKpcJVa_SKxgHWhSgegGZUSh7dYnBg1fbQ9O0bbrdYW_PAHGZg () mail ! gmail ! com
[Download RAW message or body]
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@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`
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic