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

station: Update GetOrderedNetworks API implementation

The Station interface GetOrderedNetworks signature now matches the API
documentation.  Device.GetOrderedNetworks still uses the legacy
signature.
This commit is contained in:
Denis Kenzior 2018-09-08 10:34:52 -05:00
parent 854ce2b062
commit 0a42f63d42
3 changed files with 33 additions and 11 deletions

View File

@ -112,7 +112,7 @@ static struct l_dbus_message *device_get_networks(struct l_dbus *dbus,
if (!device->powered || !device->station)
return dbus_error_not_available(message);
return station_dbus_get_networks(dbus, message, station);
return station_build_get_networks_reply(station, message, true);
}
static bool device_property_get_name(struct l_dbus *dbus,

View File

@ -1843,11 +1843,11 @@ struct l_dbus_message *station_dbus_disconnect(struct l_dbus *dbus,
return NULL;
}
struct l_dbus_message *station_dbus_get_networks(struct l_dbus *dbus,
struct l_dbus_message *station_build_get_networks_reply(
struct station *station,
struct l_dbus_message *message,
void *user_data)
bool legacy)
{
struct station *station = user_data;
struct l_dbus_message *reply;
struct l_dbus_message_builder *builder;
struct l_queue *sorted = station->networks_sorted;
@ -1856,22 +1856,35 @@ struct l_dbus_message *station_dbus_get_networks(struct l_dbus *dbus,
reply = l_dbus_message_new_method_return(message);
builder = l_dbus_message_builder_new(reply);
l_dbus_message_builder_enter_array(builder, "(osns)");
if (legacy)
l_dbus_message_builder_enter_array(builder, "(osns)");
else
l_dbus_message_builder_enter_array(builder, "(on)");
for (entry = l_queue_get_entries(sorted); entry; entry = entry->next) {
const struct network *network = entry->data;
enum security security = network_get_security(network);
int16_t signal_strength = network_get_signal_strength(network);
l_dbus_message_builder_enter_struct(builder, "osns");
if (legacy)
l_dbus_message_builder_enter_struct(builder, "osns");
else
l_dbus_message_builder_enter_struct(builder, "on");
l_dbus_message_builder_append_basic(builder, 'o',
network_get_path(network));
l_dbus_message_builder_append_basic(builder, 's',
if (legacy)
l_dbus_message_builder_append_basic(builder, 's',
network_get_ssid(network));
l_dbus_message_builder_append_basic(builder, 'n',
&signal_strength);
l_dbus_message_builder_append_basic(builder, 's',
if (legacy)
l_dbus_message_builder_append_basic(builder, 's',
security_to_str(security));
l_dbus_message_builder_leave_struct(builder);
}
@ -1883,6 +1896,14 @@ struct l_dbus_message *station_dbus_get_networks(struct l_dbus *dbus,
return reply;
}
static struct l_dbus_message *station_dbus_get_networks(struct l_dbus *dbus,
struct l_dbus_message *message,
void *user_data)
{
struct station *station = user_data;
return station_build_get_networks_reply(station, message, false);
}
static void station_dbus_scan_triggered(int err, void *user_data)
{
struct station *station = user_data;
@ -2259,7 +2280,7 @@ static void station_setup_interface(struct l_dbus_interface *interface)
l_dbus_interface_method(interface, "Disconnect", 0,
station_dbus_disconnect, "", "");
l_dbus_interface_method(interface, "GetOrderedNetworks", 0,
station_dbus_get_networks, "a(osns)", "",
station_dbus_get_networks, "a(on)", "",
"networks");
l_dbus_interface_method(interface, "Scan", 0,
station_dbus_scan, "", "");

View File

@ -102,9 +102,10 @@ void station_ap_directed_roam(struct station *station,
struct l_dbus_message *station_dbus_disconnect(struct l_dbus *dbus,
struct l_dbus_message *message,
void *user_data);
struct l_dbus_message *station_dbus_get_networks(struct l_dbus *dbus,
struct l_dbus_message *station_build_get_networks_reply(
struct station *station,
struct l_dbus_message *message,
void *user_data);
bool legacy);
struct l_dbus_message *station_dbus_scan(struct l_dbus *dbus,
struct l_dbus_message *message,
void *user_data);