commit 687dcc6145edb878292562212798aba576893399
parent 6ba707fca8b424c43be318974479b461cf53625d
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date: Wed, 25 Jul 2018 12:54:43 -0700
client: add variant appender for the on/off properties
Diffstat:
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git 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
@@ -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);