diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c index 607632e4..671bce02 100644 --- a/client/dbus-proxy.c +++ b/client/dbus-proxy.c @@ -187,9 +187,9 @@ done: return NULL; } -static char *proxy_property_completion_value_options( - const struct property_value_options *options, - const char *text, int state) +static char *proxy_property_completion_value_options(const char **options, + const char *text, + int state) { static int index; static int len; @@ -200,7 +200,7 @@ static char *proxy_property_completion_value_options( len = strlen(text); } - while ((opt = options[index++].value_str)) { + while ((opt = options[index++])) { if (strncmp(opt, text, len)) continue; diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h index 8772b64f..09614352 100644 --- a/client/dbus-proxy.h +++ b/client/dbus-proxy.h @@ -23,7 +23,6 @@ #include struct proxy_interface; -struct property_value_options; #define IWD_ADAPTER_INTERFACE "net.connman.iwd.Adapter" #define IWD_ACCESS_POINT_INTERFACE "net.connman.iwd.AccessPoint" @@ -44,7 +43,7 @@ struct proxy_interface_property { const bool is_read_write; bool (*append)(struct l_dbus_message_builder *builder, const char *value_str); - const struct property_value_options *options; + const char **options; }; struct proxy_interface_type_ops { diff --git a/client/device.c b/client/device.c index a89ec915..ebf35335 100644 --- a/client/device.c +++ b/client/device.c @@ -85,12 +85,7 @@ static void update_name(void *data, struct l_dbus_message_iter *variant) device->name = l_strdup(value); } -static const struct property_value_options device_mode_opts[] = { - { "ad-hoc", (void *) "ad-hoc" }, - { "ap", (void *) "ap" }, - { "station", (void *) "station" }, - { } -}; +static const char *device_mode_opts[] = { "ad-hoc", "ap", "station", NULL }; static const char *get_mode(const void *data) { diff --git a/client/properties.c b/client/properties.c index 9595b141..65737b3c 100644 --- a/client/properties.c +++ b/client/properties.c @@ -2,7 +2,7 @@ * * Wireless daemon for Linux * - * Copyright (C) 2018 Intel Corporation. All rights reserved. + * Copyright (C) 2018-2019 Intel Corporation. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,20 +28,23 @@ #include "properties.h" +const char *properties_on_off_opts[3] = { "on", "off", NULL }; + bool properties_builder_append_on_off_variant( struct l_dbus_message_builder *builder, const char *value_str) { + bool value; + 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); + value = true; + else if (!strcmp(value_str, "off")) + value = false; + else + return false; - if (!strcmp(value_str, "off")) - return l_dbus_message_builder_append_basic(builder, 'b', - &properties_on_off_opts[1].value); - - return false; + return l_dbus_message_builder_append_basic(builder, 'b', &value); } diff --git a/client/properties.h b/client/properties.h index 8cc1aba2..935dcfc0 100644 --- a/client/properties.h +++ b/client/properties.h @@ -20,16 +20,7 @@ * */ -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 }, - { } -}; +const char *properties_on_off_opts[3]; bool properties_builder_append_on_off_variant( struct l_dbus_message_builder *builder,