diff --git a/client/properties.c b/client/properties.c index ff96e6cd..02be6216 100644 --- a/client/properties.c +++ b/client/properties.c @@ -28,6 +28,24 @@ #include "properties.h" +bool properties_builder_append_on_off_variant( + struct l_dbus_message_builder *builder, + const char *value_str) +{ + if (!builder || !value_str) + return false; + + if (!strcmp(value_str, "on")) + return l_dbus_message_builder_append_basic(builder, 'b', + &properties_on_off_opts[0].value); + + if (!strcmp(value_str, "off")) + return l_dbus_message_builder_append_basic(builder, 'b', + &properties_on_off_opts[1].value); + + return false; +} + bool properties_parse_args(char *args, char **name, char **value) { char **arg_arr; diff --git a/client/properties.h b/client/properties.h index 24b2d52d..79e50856 100644 --- a/client/properties.h +++ b/client/properties.h @@ -20,4 +20,19 @@ * */ +struct property_value_options { + const char *value_str; + const void *value; +}; + +static const struct property_value_options properties_on_off_opts[] = { + { "on", (void *) true }, + { "off", (void *) false }, + { } +}; + +bool properties_builder_append_on_off_variant( + struct l_dbus_message_builder *builder, + const char *value_str); + bool properties_parse_args(char *args, char **name, char **value);