3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 02:19:26 +01:00

client: Add 'Yes', 'No' property type support

This property type will be used for the argument completion among
the properties that require Yes or No value.
This commit is contained in:
Tim Kourt 2019-04-10 15:58:20 -07:00 committed by Denis Kenzior
parent f5674a2356
commit bb33c5db8c
2 changed files with 25 additions and 0 deletions

View File

@ -29,6 +29,7 @@
#include "properties.h" #include "properties.h"
const char *properties_on_off_opts[3] = { "on", "off", NULL }; const char *properties_on_off_opts[3] = { "on", "off", NULL };
const char *properties_yes_no_opts[3] = { "yes", "no", NULL };
bool properties_builder_append_on_off_variant( bool properties_builder_append_on_off_variant(
struct l_dbus_message_builder *builder, struct l_dbus_message_builder *builder,
@ -48,3 +49,22 @@ bool properties_builder_append_on_off_variant(
return l_dbus_message_builder_append_basic(builder, 'b', &value); return l_dbus_message_builder_append_basic(builder, 'b', &value);
} }
bool properties_builder_append_yes_no_variant(
struct l_dbus_message_builder *builder,
const char *value_str)
{
bool value;
if (!builder || !value_str)
return false;
if (!strcmp(value_str, "yes"))
value = true;
else if (!strcmp(value_str, "no"))
value = false;
else
return false;
return l_dbus_message_builder_append_basic(builder, 'b', &value);
}

View File

@ -21,7 +21,12 @@
*/ */
const char *properties_on_off_opts[3]; const char *properties_on_off_opts[3];
const char *properties_yes_no_opts[3];
bool properties_builder_append_on_off_variant( bool properties_builder_append_on_off_variant(
struct l_dbus_message_builder *builder, struct l_dbus_message_builder *builder,
const char *value_str); const char *value_str);
bool properties_builder_append_yes_no_variant(
struct l_dbus_message_builder *builder,
const char *value_str);