mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-29 05:39:24 +01:00
client: Device basic ops
This commit is contained in:
parent
723040305c
commit
2b4cb5d586
@ -28,6 +28,7 @@
|
||||
|
||||
#include "command.h"
|
||||
#include "dbus-proxy.h"
|
||||
#include "display.h"
|
||||
|
||||
struct device {
|
||||
bool powered;
|
||||
@ -35,8 +36,11 @@ struct device {
|
||||
char *address;
|
||||
char *name;
|
||||
char *state;
|
||||
struct l_queue *ordered_networks;
|
||||
const struct proxy_interface *adapter;
|
||||
const struct proxy_interface *connected_network;
|
||||
const struct proxy_interface *properties;
|
||||
const struct proxy_interface *wsc;
|
||||
};
|
||||
|
||||
static const void *get_name(const void *data)
|
||||
@ -159,9 +163,77 @@ static const struct proxy_interface_property device_properties[] = {
|
||||
{ }
|
||||
};
|
||||
|
||||
static void ordered_networks_destroy(void *data)
|
||||
{
|
||||
}
|
||||
|
||||
static void *device_create(void)
|
||||
{
|
||||
return l_new(struct device, 1);
|
||||
}
|
||||
|
||||
static void device_destroy(void *data)
|
||||
{
|
||||
struct device *device = data;
|
||||
|
||||
l_free(device->address);
|
||||
l_free(device->name);
|
||||
l_free(device->state);
|
||||
|
||||
l_queue_destroy(device->ordered_networks, ordered_networks_destroy);
|
||||
|
||||
device->adapter = NULL;
|
||||
device->connected_network = NULL;
|
||||
device->properties = NULL;
|
||||
device->wsc = NULL;
|
||||
|
||||
l_free(device);
|
||||
}
|
||||
|
||||
static bool device_bind_interface(const struct proxy_interface *proxy,
|
||||
const struct proxy_interface *dependency)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool device_unbind_interface(const struct proxy_interface *proxy,
|
||||
const struct proxy_interface *dependency)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static void display_device_inline(const char *margin, const void *data)
|
||||
{
|
||||
const struct device *device = data;
|
||||
|
||||
display("%s%-*s%-*s%-*s%-*s%-*s\n", margin,
|
||||
20, device->name ? : "",
|
||||
20, device->address ? : "",
|
||||
15, device->state ? : "",
|
||||
10, proxy_interface_get_identity_str(device->adapter) ? : "-",
|
||||
8, device->scanning ? "scanning" : "");
|
||||
}
|
||||
|
||||
static const char *device_identity(void *data)
|
||||
{
|
||||
const struct device *device = data;
|
||||
|
||||
return device->name;
|
||||
}
|
||||
|
||||
static const struct proxy_interface_type_ops device_ops = {
|
||||
.create = device_create,
|
||||
.destroy = device_destroy,
|
||||
.bind_interface = device_bind_interface,
|
||||
.unbind_interface = device_unbind_interface,
|
||||
.identity = device_identity,
|
||||
.display = display_device_inline,
|
||||
};
|
||||
|
||||
static struct proxy_interface_type device_interface_type = {
|
||||
.interface = IWD_DEVICE_INTERFACE,
|
||||
.properties = device_properties,
|
||||
.ops = &device_ops,
|
||||
};
|
||||
|
||||
static struct command_family device_command_family = {
|
||||
|
Loading…
Reference in New Issue
Block a user