3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 21:22:37 +01:00

client: Device properties

This commit is contained in:
Tim Kourt 2017-04-14 15:42:16 -07:00 committed by Denis Kenzior
parent 9eccb29ef3
commit 723040305c

View File

@ -29,8 +29,139 @@
#include "command.h"
#include "dbus-proxy.h"
struct device {
bool powered;
bool scanning;
char *address;
char *name;
char *state;
const struct proxy_interface *adapter;
const struct proxy_interface *connected_network;
};
static const void *get_name(const void *data)
{
const struct device *device = data;
return device->name;
}
static void set_name(void *data, const void *value)
{
struct device *device = data;
l_free(device->name);
if (value)
device->name = l_strdup(value);
}
static const void *get_address(const void *data)
{
const struct device *device = data;
return device->address;
}
static void set_address(void *data, const void *value)
{
struct device *device = data;
l_free(device->address);
if (value)
device->address = l_strdup(value);
}
static const void *get_state(const void *data)
{
const struct device *device = data;
return device->state;
}
static void set_state(void *data, const void *value)
{
struct device *device = data;
l_free(device->state);
if (value)
device->state = l_strdup(value);
}
static void set_connected_network(void *data, const void *value)
{
struct device *device = data;
const char *path = value;
device->connected_network = proxy_interface_find(IWD_NETWORK_INTERFACE,
path);
}
static const void *get_powered(const void *data)
{
const struct device *device = data;
void *ptr;
l_put_u8(device->powered, &ptr);
return ptr;
}
static void set_powered(void *data, const void *value)
{
struct device *device = data;
if (value)
device->powered = l_get_u8(&value);
else
device->powered = false;
}
static const void *get_scanning(const void *data)
{
const struct device *device = data;
void *ptr;
l_put_u8(device->scanning, &ptr);
return ptr;
}
static void set_scanning(void *data, const void *value)
{
struct device *device = data;
if (value)
device->scanning = l_get_u8(&value);
else
device->scanning = false;
}
static void set_adapter(void *data, const void *value)
{
struct device *device = data;
const char *path = value;
device->adapter = proxy_interface_find(IWD_ADAPTER_INTERFACE, path);
}
static const struct proxy_interface_property device_properties[] = {
{ "Name", "s", set_name, get_name },
{ "Powered", "b", set_powered, get_powered, true },
{ "Adapter", "o", set_adapter },
{ "Address", "s", set_address, get_address },
{ "Scanning", "b", set_scanning, get_scanning },
{ "State", "s", set_state, get_state },
{ "ConnectedNetwork",
"o", set_connected_network },
{ }
};
static struct proxy_interface_type device_interface_type = {
.interface = IWD_DEVICE_INTERFACE,
.properties = device_properties,
};
static struct command_family device_command_family = {