mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-23 20:54:14 +01:00
client: display device properties
This commit is contained in:
parent
4740dc8445
commit
5b94af5aab
@ -44,6 +44,36 @@ static struct l_dbus *dbus;
|
||||
static struct l_queue *proxy_interfaces;
|
||||
static struct l_queue *proxy_interface_types;
|
||||
|
||||
void proxy_properties_display(const struct proxy_interface *proxy,
|
||||
const char *caption, const char *margin,
|
||||
int name_column_width, int value_column_width)
|
||||
{
|
||||
const void *data;
|
||||
const struct proxy_interface_property *properties;
|
||||
size_t i;
|
||||
|
||||
if (!proxy->type->properties)
|
||||
return;
|
||||
|
||||
display_table_header(caption, "%s%-*s %-*s%-*s", margin,
|
||||
8, "Settable",
|
||||
name_column_width, "Property",
|
||||
value_column_width, "Value");
|
||||
|
||||
data = proxy_interface_get_data(proxy);
|
||||
properties = proxy->type->properties;
|
||||
|
||||
for (i = 0; properties[i].name; i++) {
|
||||
if (!properties[i].tostr)
|
||||
continue;
|
||||
|
||||
display("%s%*s %-*s%-*s\n", margin,
|
||||
8, properties[i].is_read_write ? " " CHECK : "",
|
||||
name_column_width, properties[i].name,
|
||||
value_column_width, properties[i].tostr(data) ? : "");
|
||||
}
|
||||
}
|
||||
|
||||
static const void *proxy_interface_property_tostr(
|
||||
const struct proxy_interface *proxy,
|
||||
const char *name)
|
||||
|
@ -70,6 +70,10 @@ bool proxy_interface_method_call(const struct proxy_interface *proxy,
|
||||
const char *name, const char *signature,
|
||||
l_dbus_message_func_t callback, ...);
|
||||
|
||||
void proxy_properties_display(const struct proxy_interface *proxy,
|
||||
const char *caption, const char *margin,
|
||||
int name_column_width, int value_column_width);
|
||||
|
||||
char *proxy_property_str_completion(const struct proxy_interface_type *type,
|
||||
proxy_property_match_func_t function,
|
||||
const char *property_name,
|
||||
|
@ -44,8 +44,29 @@ struct device {
|
||||
const struct proxy_interface *wsc;
|
||||
};
|
||||
|
||||
static void display_device(const struct device *device)
|
||||
static void display_device(const struct proxy_interface *proxy)
|
||||
{
|
||||
const struct device *device = proxy_interface_get_data(proxy);
|
||||
char *caption = l_strdup_printf("%s: %s", "Device", device->name);
|
||||
|
||||
proxy_properties_display(proxy, caption, MARGIN, 20, 47);
|
||||
|
||||
l_free(caption);
|
||||
|
||||
if (device->connected_network) {
|
||||
display("%s%*s %-*s%-*s\n", MARGIN, 8, "",
|
||||
20, "Connected network",
|
||||
47, proxy_interface_get_identity_str(
|
||||
device->connected_network) ? : "");
|
||||
}
|
||||
|
||||
if (device->adapter) {
|
||||
display("%s%*s %-*s%-*s\n", MARGIN, 8, "", 20, "Adapter", 47,
|
||||
proxy_interface_get_identity_str(
|
||||
device->adapter) ? : "");
|
||||
}
|
||||
|
||||
display_table_footer();
|
||||
}
|
||||
|
||||
static const char *get_name(const void *data)
|
||||
@ -407,16 +428,13 @@ static const struct proxy_interface *get_device_proxy_by_name(
|
||||
|
||||
static enum cmd_status cmd_show(const char *device_name, char *args)
|
||||
{
|
||||
struct device *device;
|
||||
const struct proxy_interface *proxy =
|
||||
get_device_proxy_by_name(device_name);
|
||||
|
||||
if (!proxy)
|
||||
return CMD_STATUS_INVALID_ARGS;
|
||||
|
||||
device = proxy_interface_get_data(proxy);
|
||||
|
||||
display_device(device);
|
||||
display_device(proxy);
|
||||
|
||||
return CMD_STATUS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user