mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-03 10:32:33 +01:00
manager: Implement GetDevices method
This commit is contained in:
parent
2d6babc3f8
commit
77255dbee0
@ -27,6 +27,7 @@
|
||||
#include <ell/ell.h>
|
||||
#include "src/manager.h"
|
||||
#include "src/dbus.h"
|
||||
#include "src/wiphy.h"
|
||||
|
||||
static struct l_dbus_message *manager_set_property(struct l_dbus *dbus,
|
||||
struct l_dbus_message *message,
|
||||
@ -56,6 +57,37 @@ static struct l_dbus_message *manager_get_properties(struct l_dbus *dbus,
|
||||
return reply;
|
||||
}
|
||||
|
||||
static void append_device(struct netdev *netdev, void *user_data)
|
||||
{
|
||||
struct l_dbus_message_builder *builder = user_data;
|
||||
|
||||
l_dbus_message_builder_enter_dict(builder, "oa{sv}");
|
||||
l_dbus_message_builder_append_basic(builder, 'o',
|
||||
iwd_device_get_path(netdev));
|
||||
__iwd_device_append_properties(netdev, builder);
|
||||
l_dbus_message_builder_leave_dict(builder);
|
||||
}
|
||||
|
||||
static struct l_dbus_message *manager_get_devices(struct l_dbus *dbus,
|
||||
struct l_dbus_message *message,
|
||||
void *user_data)
|
||||
{
|
||||
struct l_dbus_message *reply;
|
||||
struct l_dbus_message_builder *builder;
|
||||
|
||||
reply = l_dbus_message_new_method_return(message);
|
||||
builder = l_dbus_message_builder_new(reply);
|
||||
|
||||
l_dbus_message_builder_enter_array(builder, "{oa{sv}}");
|
||||
__iwd_device_foreach(append_device, builder);
|
||||
l_dbus_message_builder_leave_array(builder);
|
||||
|
||||
l_dbus_message_builder_finalize(builder);
|
||||
l_dbus_message_builder_destroy(builder);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static void setup_manager_interface(struct l_dbus_interface *interface)
|
||||
{
|
||||
l_dbus_interface_method(interface, "GetProperties", 0,
|
||||
@ -65,6 +97,10 @@ static void setup_manager_interface(struct l_dbus_interface *interface)
|
||||
manager_set_property,
|
||||
"", "sv", "name", "value");
|
||||
|
||||
l_dbus_interface_method(interface, "GetDevices", 0,
|
||||
manager_get_devices,
|
||||
"a{oa{sv}}", "", "devices");
|
||||
|
||||
l_dbus_interface_signal(interface, "PropertyChanged", 0,
|
||||
"sv", "name", "value");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user