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

client: Eliminate property_value_options struct

property_value_options is replaced with an array of strings
that represent value options for the properties
This commit is contained in:
Tim Kourt 2019-04-10 15:58:19 -07:00 committed by Denis Kenzior
parent f1e5bc0645
commit f5674a2356
5 changed files with 18 additions and 30 deletions

View File

@ -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;

View File

@ -23,7 +23,6 @@
#include <stdio.h>
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 {

View File

@ -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)
{

View File

@ -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);
}

View File

@ -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,