3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 14:49:24 +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; return NULL;
} }
static char *proxy_property_completion_value_options( static char *proxy_property_completion_value_options(const char **options,
const struct property_value_options *options, const char *text,
const char *text, int state) int state)
{ {
static int index; static int index;
static int len; static int len;
@ -200,7 +200,7 @@ static char *proxy_property_completion_value_options(
len = strlen(text); len = strlen(text);
} }
while ((opt = options[index++].value_str)) { while ((opt = options[index++])) {
if (strncmp(opt, text, len)) if (strncmp(opt, text, len))
continue; continue;

View File

@ -23,7 +23,6 @@
#include <stdio.h> #include <stdio.h>
struct proxy_interface; struct proxy_interface;
struct property_value_options;
#define IWD_ADAPTER_INTERFACE "net.connman.iwd.Adapter" #define IWD_ADAPTER_INTERFACE "net.connman.iwd.Adapter"
#define IWD_ACCESS_POINT_INTERFACE "net.connman.iwd.AccessPoint" #define IWD_ACCESS_POINT_INTERFACE "net.connman.iwd.AccessPoint"
@ -44,7 +43,7 @@ struct proxy_interface_property {
const bool is_read_write; const bool is_read_write;
bool (*append)(struct l_dbus_message_builder *builder, bool (*append)(struct l_dbus_message_builder *builder,
const char *value_str); const char *value_str);
const struct property_value_options *options; const char **options;
}; };
struct proxy_interface_type_ops { 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); device->name = l_strdup(value);
} }
static const struct property_value_options device_mode_opts[] = { static const char *device_mode_opts[] = { "ad-hoc", "ap", "station", NULL };
{ "ad-hoc", (void *) "ad-hoc" },
{ "ap", (void *) "ap" },
{ "station", (void *) "station" },
{ }
};
static const char *get_mode(const void *data) static const char *get_mode(const void *data)
{ {

View File

@ -2,7 +2,7 @@
* *
* Wireless daemon for Linux * 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -28,20 +28,23 @@
#include "properties.h" #include "properties.h"
const char *properties_on_off_opts[3] = { "on", "off", 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,
const char *value_str) const char *value_str)
{ {
bool value;
if (!builder || !value_str) if (!builder || !value_str)
return false; return false;
if (!strcmp(value_str, "on")) if (!strcmp(value_str, "on"))
return l_dbus_message_builder_append_basic(builder, 'b', value = true;
&properties_on_off_opts[0].value); 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', &value);
return l_dbus_message_builder_append_basic(builder, 'b',
&properties_on_off_opts[1].value);
return false;
} }

View File

@ -20,16 +20,7 @@
* *
*/ */
struct property_value_options { const char *properties_on_off_opts[3];
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( bool properties_builder_append_on_off_variant(
struct l_dbus_message_builder *builder, struct l_dbus_message_builder *builder,