mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 06:19:34 +01:00
client: update station to use display_table_row
This includes updating diagnostics too, otherwise the output becomes really nasty.
This commit is contained in:
parent
e1d485029b
commit
35dd2c0821
@ -69,12 +69,13 @@ static bool display_bitrate_100kbps(struct l_dbus_message_iter *variant,
|
|||||||
int name_column_width, int value_column_width)
|
int name_column_width, int value_column_width)
|
||||||
{
|
{
|
||||||
uint32_t rate;
|
uint32_t rate;
|
||||||
|
char str[50];
|
||||||
|
|
||||||
if (!l_dbus_message_iter_get_variant(variant, "u", &rate))
|
if (!l_dbus_message_iter_get_variant(variant, "u", &rate))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
display("%s%-*s%-*u Kbit/s\n", margin, name_column_width, key,
|
sprintf(str, "%u Kbit/s", rate * 100);
|
||||||
value_column_width, rate * 100);
|
display_table_row(margin, 3, 8, "", name_column_width, key, value_column_width, str);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -110,6 +111,7 @@ void diagnostic_display(struct l_dbus_message_iter *dict,
|
|||||||
uint32_t u_value;
|
uint32_t u_value;
|
||||||
int16_t n_value;
|
int16_t n_value;
|
||||||
uint8_t y_value;
|
uint8_t y_value;
|
||||||
|
int bytes;
|
||||||
|
|
||||||
map = find_mapping(key, diagnostic_mapping);
|
map = find_mapping(key, diagnostic_mapping);
|
||||||
if (!map)
|
if (!map)
|
||||||
@ -132,9 +134,7 @@ void diagnostic_display(struct l_dbus_message_iter *dict,
|
|||||||
&s_value))
|
&s_value))
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
|
|
||||||
sprintf(display_text, "%s%-*s%-*s", margin,
|
bytes = sprintf(display_text, "%s", s_value);
|
||||||
name_column_width, key,
|
|
||||||
value_column_width, s_value);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
@ -142,9 +142,7 @@ void diagnostic_display(struct l_dbus_message_iter *dict,
|
|||||||
&u_value))
|
&u_value))
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
|
|
||||||
sprintf(display_text, "%s%-*s%-*u", margin,
|
bytes = sprintf(display_text, "%u", u_value);
|
||||||
name_column_width, key,
|
|
||||||
value_column_width, u_value);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
@ -152,9 +150,7 @@ void diagnostic_display(struct l_dbus_message_iter *dict,
|
|||||||
&n_value))
|
&n_value))
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
|
|
||||||
sprintf(display_text, "%s%-*s%-*i", margin,
|
bytes = sprintf(display_text, "%i", n_value);
|
||||||
name_column_width, key,
|
|
||||||
value_column_width, n_value);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'y':
|
case 'y':
|
||||||
@ -162,21 +158,19 @@ void diagnostic_display(struct l_dbus_message_iter *dict,
|
|||||||
&y_value))
|
&y_value))
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
|
|
||||||
sprintf(display_text, "%s%-*s%-*u", margin,
|
bytes = sprintf(display_text, "%u", y_value);
|
||||||
name_column_width, key,
|
|
||||||
value_column_width, y_value);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
display("type %c not handled", map->type);
|
display("type %c not handled\n", map->type);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map->units)
|
if (map->units)
|
||||||
display("%s %s\n", display_text,
|
sprintf(display_text + bytes, " %s", map->units);
|
||||||
(const char *)map->units);
|
|
||||||
else
|
display_table_row(margin, 3, 8, "", name_column_width,
|
||||||
display("%s\n", display_text);
|
key, value_column_width, display_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -186,8 +186,7 @@ static void display_addresses(const char *device_name)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
have_address = true;
|
have_address = true;
|
||||||
display("%s%*s %-*s%-*s\n", MARGIN, 8, "", 20,
|
display_table_row(MARGIN, 3, 8, "", 20, "IPv4 address", 47, addrstr);
|
||||||
"IPv4 address", 47, addrstr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,8 +199,7 @@ static void display_addresses(const char *device_name)
|
|||||||
if (r < 0 || r == 1)
|
if (r < 0 || r == 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
display("%s%*s %-*s%-*s\n", MARGIN, 8, "", 20,
|
display_table_row(MARGIN, 3, 8, "", 20, "No IP addresses", 47, "Is DHCP client configured?");
|
||||||
"No IP addresses", 47, "Is DHCP client configured?");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -215,9 +213,9 @@ static void display_station(const char *device_name,
|
|||||||
l_free(caption);
|
l_free(caption);
|
||||||
|
|
||||||
if (station->connected_network) {
|
if (station->connected_network) {
|
||||||
display("%s%*s %-*s%-*s\n", MARGIN, 8, "", 20,
|
display_table_row(MARGIN, 3, 8, "", 20, "Connected network",
|
||||||
"Connected network", 47,
|
47, network_get_name(station->connected_network));
|
||||||
network_get_name(station->connected_network));
|
|
||||||
display_addresses(device_name);
|
display_addresses(device_name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -246,10 +244,8 @@ static void display_station_inline(const char *margin, const void *data)
|
|||||||
if (!identity)
|
if (!identity)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
display("%s%-*s%-*s%-*s\n", margin,
|
display_table_row(margin, 3, 20, identity, 15, station->state ? : "",
|
||||||
20, identity,
|
8, station->scanning ? "scanning" : "");
|
||||||
15, station->state ? : "",
|
|
||||||
8, station->scanning ? "scanning" : "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum cmd_status cmd_list(const char *device_name, char **argv, int argc)
|
static enum cmd_status cmd_list(const char *device_name, char **argv, int argc)
|
||||||
@ -258,7 +254,8 @@ static enum cmd_status cmd_list(const char *device_name, char **argv, int argc)
|
|||||||
struct l_queue *match =
|
struct l_queue *match =
|
||||||
proxy_interface_find_all(IWD_STATION_INTERFACE, NULL, NULL);
|
proxy_interface_find_all(IWD_STATION_INTERFACE, NULL, NULL);
|
||||||
|
|
||||||
display_table_header("Devices in Station Mode", MARGIN "%-*s%-*s%-*s",
|
display_table_header("Devices in Station Mode",
|
||||||
|
MARGIN "%-*s %-*s %-*s",
|
||||||
20, "Name", 15, "State", 8, "Scanning");
|
20, "Name", 15, "State", 8, "Scanning");
|
||||||
|
|
||||||
if (!match) {
|
if (!match) {
|
||||||
@ -416,7 +413,7 @@ static void ordered_networks_display(struct l_queue *ordered_networks)
|
|||||||
char *dbms = NULL;
|
char *dbms = NULL;
|
||||||
const struct l_queue_entry *entry;
|
const struct l_queue_entry *entry;
|
||||||
|
|
||||||
display_table_header("Available networks", "%s%-*s%-*s%-*s%*s",
|
display_table_header("Available networks", "%s%-*s %-*s %-*s %*s",
|
||||||
MARGIN, 2, "", 32, "Network name",
|
MARGIN, 2, "", 32, "Network name",
|
||||||
18, "Security", 6, "Signal");
|
18, "Security", 6, "Signal");
|
||||||
|
|
||||||
@ -441,11 +438,11 @@ static void ordered_networks_display(struct l_queue *ordered_networks)
|
|||||||
if (display_signal_as_dbms)
|
if (display_signal_as_dbms)
|
||||||
dbms = l_strdup_printf("%d", network->signal_strength);
|
dbms = l_strdup_printf("%d", network->signal_strength);
|
||||||
|
|
||||||
display("%s%-*s%-*s%-*s%-*s\n", MARGIN, 2,
|
display_table_row(MARGIN, 4, 2,
|
||||||
network_is_connected(network_i) ?
|
network_is_connected(network_i) ?
|
||||||
COLOR_BOLDGRAY "> " COLOR_OFF : "",
|
COLOR_BOLDGRAY "> " COLOR_OFF: "",
|
||||||
32, network_name, 18, network_type,
|
32, network_name, 18, network_type, 6,
|
||||||
6, display_signal_as_dbms ? dbms :
|
display_signal_as_dbms ? dbms :
|
||||||
dbms_tostars(network->signal_strength));
|
dbms_tostars(network->signal_strength));
|
||||||
|
|
||||||
if (display_signal_as_dbms) {
|
if (display_signal_as_dbms) {
|
||||||
@ -556,7 +553,7 @@ static void hidden_access_points_display(struct l_queue *access_points)
|
|||||||
{
|
{
|
||||||
const struct l_queue_entry *entry;
|
const struct l_queue_entry *entry;
|
||||||
|
|
||||||
display_table_header("Available hidden APs", MARGIN "%-*s%-*s%*s",
|
display_table_header("Available hidden APs", MARGIN "%-*s %-*s %*s",
|
||||||
20, "Address", 10, "Security", 6, "Signal");
|
20, "Address", 10, "Security", 6, "Signal");
|
||||||
|
|
||||||
if (l_queue_isempty(access_points)) {
|
if (l_queue_isempty(access_points)) {
|
||||||
@ -574,9 +571,8 @@ static void hidden_access_points_display(struct l_queue *access_points)
|
|||||||
if (display_signal_as_dbms)
|
if (display_signal_as_dbms)
|
||||||
dbms = l_strdup_printf("%d", ap->signal_strength);
|
dbms = l_strdup_printf("%d", ap->signal_strength);
|
||||||
|
|
||||||
display(MARGIN "%-*s%-*s%-*s\n",
|
display_table_row(MARGIN, 3, 20, ap->address, 10, ap->type, 6,
|
||||||
20, ap->address, 10, ap->type,
|
dbms ? : dbms_tostars(ap->signal_strength));
|
||||||
6, dbms ? : dbms_tostars(ap->signal_strength));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
display_table_footer();
|
display_table_footer();
|
||||||
@ -676,7 +672,7 @@ static void get_diagnostics_callback(struct l_dbus_message *message,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
diagnostic_display(&iter, " ", 20, 20);
|
diagnostic_display(&iter, MARGIN, 20, 47);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
/* Finish the table started by cmd_show */
|
/* Finish the table started by cmd_show */
|
||||||
|
Loading…
Reference in New Issue
Block a user