client: Optimize network property lookups

This commit is contained in:
Tim Kourt 2018-11-12 09:08:04 -08:00 committed by Denis Kenzior
parent 13c4095b77
commit b0e5b9de02
3 changed files with 20 additions and 26 deletions

View File

@ -44,35 +44,28 @@ static void check_errors_method_callback(struct l_dbus_message *message,
dbus_message_has_error(message);
}
bool network_is_connected(const char *path)
const struct proxy_interface *network_get_proxy(const char *path)
{
const struct network *network;
const struct proxy_interface *proxy =
proxy_interface_find(IWD_NETWORK_INTERFACE, path);
return proxy_interface_find(IWD_NETWORK_INTERFACE, path);
}
network = proxy_interface_get_data(proxy);
bool network_is_connected(const struct proxy_interface *network_proxy)
{
const struct network *network = proxy_interface_get_data(network_proxy);
return network->connected;
}
const char *network_get_type(const char *path)
const char *network_get_type(const struct proxy_interface *network_proxy)
{
const struct network *network;
const struct proxy_interface *proxy =
proxy_interface_find(IWD_NETWORK_INTERFACE, path);
network = proxy_interface_get_data(proxy);
const struct network *network = proxy_interface_get_data(network_proxy);
return network->type;
}
const char *network_get_name(const char *path)
const char *network_get_name(const struct proxy_interface *network_proxy)
{
const struct network *network;
const struct proxy_interface *proxy =
proxy_interface_find(IWD_NETWORK_INTERFACE, path);
network = proxy_interface_get_data(proxy);
const struct network *network = proxy_interface_get_data(network_proxy);
return network->name;
}

View File

@ -25,10 +25,11 @@ struct network_args {
const char *type;
};
bool network_is_connected(const char *path);
const char *network_get_type(const char *path);
const char *network_get_name(const char *path);
void network_connect(const struct proxy_interface *proxy);
const struct proxy_interface *network_get_proxy(const char *path);
bool network_is_connected(const struct proxy_interface *network_proxy);
const char *network_get_type(const struct proxy_interface *network_proxy);
const char *network_get_name(const struct proxy_interface *network_proxy);
void network_connect(const struct proxy_interface *network_proxy);
char *network_name_completion(const struct proxy_interface *device,
const char *text, int state);

View File

@ -341,15 +341,15 @@ static void ordered_networks_display(struct l_queue *ordered_networks)
for (is_first = true, entry = l_queue_get_entries(ordered_networks);
entry; entry = entry->next) {
struct ordered_network *network = entry->data;
const char *network_name =
network_get_name(network->network_path);
const char *network_type =
network_get_type(network->network_path);
const struct proxy_interface *network_i =
network_get_proxy(network->network_path);
const char *network_name = network_get_name(network_i);
const char *network_type = network_get_type(network_i);
if (display_signal_as_dbms)
dbms = l_strdup_printf("%d", network->signal_strength);
if (is_first && network_is_connected(network->network_path)) {
if (is_first && network_is_connected(network_i)) {
display("%s%-*s%-*s%-*s%-*s\n", MARGIN,
2, COLOR_BOLDGRAY "> " COLOR_OFF,
32, network_name, 10, network_type,