dbus: Update to the new ell D-Bus APIs
This commit is contained in:
parent
ad7bbbb920
commit
e2de4423db
|
@ -30,34 +30,6 @@
|
||||||
#include "src/wiphy.h"
|
#include "src/wiphy.h"
|
||||||
#include "src/agent.h"
|
#include "src/agent.h"
|
||||||
|
|
||||||
static struct l_dbus_message *manager_set_property(struct l_dbus *dbus,
|
|
||||||
struct l_dbus_message *message,
|
|
||||||
void *user_data)
|
|
||||||
{
|
|
||||||
const char *property;
|
|
||||||
struct l_dbus_message_iter variant;
|
|
||||||
|
|
||||||
if (!l_dbus_message_get_arguments(message, "sv", &property, &variant))
|
|
||||||
return l_dbus_message_new_error(message,
|
|
||||||
"org.test.InvalidArguments",
|
|
||||||
"Invalid arguments");
|
|
||||||
|
|
||||||
return l_dbus_message_new_error(message, "org.test.InvalidArguments",
|
|
||||||
"Unknown Property %s", property);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct l_dbus_message *manager_get_properties(struct l_dbus *dbus,
|
|
||||||
struct l_dbus_message *message,
|
|
||||||
void *user_data)
|
|
||||||
{
|
|
||||||
struct l_dbus_message *reply;
|
|
||||||
|
|
||||||
reply = l_dbus_message_new_method_return(message);
|
|
||||||
l_dbus_message_set_arguments(reply, "a{sv}", 0);
|
|
||||||
|
|
||||||
return reply;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void append_device(struct netdev *netdev, void *user_data)
|
static void append_device(struct netdev *netdev, void *user_data)
|
||||||
{
|
{
|
||||||
struct l_dbus_message_builder *builder = user_data;
|
struct l_dbus_message_builder *builder = user_data;
|
||||||
|
@ -91,19 +63,10 @@ static struct l_dbus_message *manager_get_devices(struct l_dbus *dbus,
|
||||||
|
|
||||||
static void setup_manager_interface(struct l_dbus_interface *interface)
|
static void setup_manager_interface(struct l_dbus_interface *interface)
|
||||||
{
|
{
|
||||||
l_dbus_interface_method(interface, "GetProperties", 0,
|
|
||||||
manager_get_properties,
|
|
||||||
"a{sv}", "", "properties");
|
|
||||||
l_dbus_interface_method(interface, "SetProperty", 0,
|
|
||||||
manager_set_property,
|
|
||||||
"", "sv", "name", "value");
|
|
||||||
|
|
||||||
l_dbus_interface_method(interface, "GetDevices", 0,
|
l_dbus_interface_method(interface, "GetDevices", 0,
|
||||||
manager_get_devices,
|
manager_get_devices,
|
||||||
"a{oa{sv}}", "", "devices");
|
"a{oa{sv}}", "", "devices");
|
||||||
|
|
||||||
l_dbus_interface_signal(interface, "PropertyChanged", 0,
|
|
||||||
"sv", "name", "value");
|
|
||||||
l_dbus_interface_signal(interface, "DeviceAdded", 0,
|
l_dbus_interface_signal(interface, "DeviceAdded", 0,
|
||||||
"oa{sv}", "path", "properties");
|
"oa{sv}", "path", "properties");
|
||||||
l_dbus_interface_signal(interface, "DeviceRemoved", 0,
|
l_dbus_interface_signal(interface, "DeviceRemoved", 0,
|
||||||
|
@ -116,21 +79,30 @@ bool manager_init(struct l_dbus *dbus)
|
||||||
{
|
{
|
||||||
agent_init();
|
agent_init();
|
||||||
|
|
||||||
if (!l_dbus_register_interface(dbus, IWD_MANAGER_PATH,
|
if (!l_dbus_register_interface(dbus, IWD_MANAGER_INTERFACE,
|
||||||
IWD_MANAGER_INTERFACE,
|
setup_manager_interface,
|
||||||
setup_manager_interface, NULL, NULL)) {
|
NULL, true)) {
|
||||||
l_info("Unable to register %s interface",
|
l_info("Unable to register %s interface",
|
||||||
IWD_MANAGER_INTERFACE);
|
IWD_MANAGER_INTERFACE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!l_dbus_object_add_interface(dbus, IWD_MANAGER_PATH,
|
||||||
|
IWD_MANAGER_INTERFACE, NULL)) {
|
||||||
|
l_info("Unable to register manager object on '%s'",
|
||||||
|
IWD_MANAGER_PATH);
|
||||||
|
l_dbus_unregister_interface(dbus, IWD_MANAGER_INTERFACE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool manager_exit(struct l_dbus *dbus)
|
bool manager_exit(struct l_dbus *dbus)
|
||||||
{
|
{
|
||||||
l_dbus_unregister_interface(dbus, IWD_MANAGER_PATH,
|
|
||||||
IWD_MANAGER_INTERFACE);
|
l_dbus_unregister_object(dbus, IWD_MANAGER_PATH);
|
||||||
|
l_dbus_unregister_interface(dbus, IWD_MANAGER_INTERFACE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
113
src/wiphy.c
113
src/wiphy.c
|
@ -499,19 +499,25 @@ static struct l_dbus_message *network_connect(struct l_dbus *dbus,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool network_property_get_name(struct l_dbus *dbus,
|
||||||
|
struct l_dbus_message *message,
|
||||||
|
struct l_dbus_message_builder *builder,
|
||||||
|
void *user_data)
|
||||||
|
{
|
||||||
|
struct network *network = user_data;
|
||||||
|
|
||||||
|
l_dbus_message_builder_append_basic(builder, 's', network->ssid);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void setup_network_interface(struct l_dbus_interface *interface)
|
static void setup_network_interface(struct l_dbus_interface *interface)
|
||||||
{
|
{
|
||||||
l_dbus_interface_method(interface, "GetProperties", 0,
|
|
||||||
network_get_properties,
|
|
||||||
"a{sv}", "", "properties");
|
|
||||||
l_dbus_interface_method(interface, "Connect", 0,
|
l_dbus_interface_method(interface, "Connect", 0,
|
||||||
network_connect,
|
network_connect,
|
||||||
"", "");
|
"", "");
|
||||||
|
|
||||||
l_dbus_interface_signal(interface, "PropertyChanged", 0,
|
l_dbus_interface_property(interface, "Name", 0, "s",
|
||||||
"sv", "name", "value");
|
network_property_get_name, NULL);
|
||||||
|
|
||||||
l_dbus_interface_ro_property(interface, "Name", "s");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void network_emit_added(struct network *network)
|
static void network_emit_added(struct network *network)
|
||||||
|
@ -580,8 +586,7 @@ static void network_free(void *data)
|
||||||
l_settings_free(network->settings);
|
l_settings_free(network->settings);
|
||||||
|
|
||||||
dbus = dbus_get_bus();
|
dbus = dbus_get_bus();
|
||||||
l_dbus_unregister_interface(dbus, network->object_path,
|
l_dbus_unregister_object(dbus, network->object_path);
|
||||||
IWD_NETWORK_INTERFACE);
|
|
||||||
network_emit_removed(network);
|
network_emit_removed(network);
|
||||||
|
|
||||||
l_free(network->object_path);
|
l_free(network->object_path);
|
||||||
|
@ -675,41 +680,6 @@ static void device_emit_removed(struct netdev *netdev)
|
||||||
l_dbus_send(dbus, signal);
|
l_dbus_send(dbus, signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct l_dbus_message *device_set_property(struct l_dbus *dbus,
|
|
||||||
struct l_dbus_message *message,
|
|
||||||
void *user_data)
|
|
||||||
{
|
|
||||||
const char *property;
|
|
||||||
struct l_dbus_message_iter variant;
|
|
||||||
|
|
||||||
if (!l_dbus_message_get_arguments(message, "sv", &property, &variant))
|
|
||||||
return l_dbus_message_new_error(message,
|
|
||||||
"org.test.InvalidArguments",
|
|
||||||
"Invalid arguments");
|
|
||||||
|
|
||||||
return l_dbus_message_new_error(message, "org.test.InvalidArguments",
|
|
||||||
"Unknown Property %s", property);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct l_dbus_message *device_get_properties(struct l_dbus *dbus,
|
|
||||||
struct l_dbus_message *message,
|
|
||||||
void *user_data)
|
|
||||||
{
|
|
||||||
struct netdev *netdev = 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);
|
|
||||||
|
|
||||||
__iwd_device_append_properties(netdev, builder);
|
|
||||||
l_dbus_message_builder_finalize(builder);
|
|
||||||
l_dbus_message_builder_destroy(builder);
|
|
||||||
|
|
||||||
return reply;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void device_scan_triggered(int err, void *user_data)
|
static void device_scan_triggered(int err, void *user_data)
|
||||||
{
|
{
|
||||||
struct netdev *netdev = user_data;
|
struct netdev *netdev = user_data;
|
||||||
|
@ -839,14 +809,19 @@ static struct l_dbus_message *device_disconnect(struct l_dbus *dbus,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool device_property_get_name(struct l_dbus *dbus,
|
||||||
|
struct l_dbus_message *message,
|
||||||
|
struct l_dbus_message_builder *builder,
|
||||||
|
void *user_data)
|
||||||
|
{
|
||||||
|
struct netdev *netdev = user_data;
|
||||||
|
|
||||||
|
l_dbus_message_builder_append_basic(builder, 's', netdev->name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void setup_device_interface(struct l_dbus_interface *interface)
|
static void setup_device_interface(struct l_dbus_interface *interface)
|
||||||
{
|
{
|
||||||
l_dbus_interface_method(interface, "GetProperties", 0,
|
|
||||||
device_get_properties,
|
|
||||||
"a{sv}", "", "properties");
|
|
||||||
l_dbus_interface_method(interface, "SetProperty", 0,
|
|
||||||
device_set_property,
|
|
||||||
"", "sv", "name", "value");
|
|
||||||
l_dbus_interface_method(interface, "Scan", 0,
|
l_dbus_interface_method(interface, "Scan", 0,
|
||||||
device_scan, "", "");
|
device_scan, "", "");
|
||||||
l_dbus_interface_method(interface, "GetNetworks", 0,
|
l_dbus_interface_method(interface, "GetNetworks", 0,
|
||||||
|
@ -855,14 +830,13 @@ static void setup_device_interface(struct l_dbus_interface *interface)
|
||||||
l_dbus_interface_method(interface, "Disconnect", 0,
|
l_dbus_interface_method(interface, "Disconnect", 0,
|
||||||
device_disconnect, "", "");
|
device_disconnect, "", "");
|
||||||
|
|
||||||
l_dbus_interface_signal(interface, "PropertyChanged", 0,
|
|
||||||
"sv", "name", "value");
|
|
||||||
l_dbus_interface_signal(interface, "NetworkAdded", 0,
|
l_dbus_interface_signal(interface, "NetworkAdded", 0,
|
||||||
"oa{sv}", "path", "properties");
|
"oa{sv}", "path", "properties");
|
||||||
l_dbus_interface_signal(interface, "NetworkRemoved", 0,
|
l_dbus_interface_signal(interface, "NetworkRemoved", 0,
|
||||||
"o", "path");
|
"o", "path");
|
||||||
|
|
||||||
l_dbus_interface_ro_property(interface, "Name", "s");
|
l_dbus_interface_property(interface, "Name", 0, "s",
|
||||||
|
device_property_get_name, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool bss_match(const void *a, const void *b)
|
static bool bss_match(const void *a, const void *b)
|
||||||
|
@ -889,8 +863,7 @@ static void netdev_free(void *data)
|
||||||
__netdev_watch_call_removed(netdev);
|
__netdev_watch_call_removed(netdev);
|
||||||
|
|
||||||
dbus = dbus_get_bus();
|
dbus = dbus_get_bus();
|
||||||
l_dbus_unregister_interface(dbus, iwd_device_get_path(netdev),
|
l_dbus_unregister_object(dbus, iwd_device_get_path(netdev));
|
||||||
IWD_DEVICE_INTERFACE);
|
|
||||||
|
|
||||||
device_emit_removed(netdev);
|
device_emit_removed(netdev);
|
||||||
|
|
||||||
|
@ -1730,11 +1703,9 @@ static void process_bss(struct netdev *netdev, struct scan_bss *bss)
|
||||||
l_debug("Added new Network \"%s\" security %s", network->ssid,
|
l_debug("Added new Network \"%s\" security %s", network->ssid,
|
||||||
scan_ssid_security_to_str(ssid_security));
|
scan_ssid_security_to_str(ssid_security));
|
||||||
|
|
||||||
if (!l_dbus_register_interface(dbus_get_bus(),
|
if (!l_dbus_object_add_interface(dbus_get_bus(),
|
||||||
network->object_path,
|
network->object_path,
|
||||||
IWD_NETWORK_INTERFACE,
|
IWD_NETWORK_INTERFACE, network))
|
||||||
setup_network_interface,
|
|
||||||
network, NULL))
|
|
||||||
l_info("Unable to register %s interface",
|
l_info("Unable to register %s interface",
|
||||||
IWD_NETWORK_INTERFACE);
|
IWD_NETWORK_INTERFACE);
|
||||||
else
|
else
|
||||||
|
@ -1913,11 +1884,9 @@ static void interface_dump_callback(struct l_genl_msg *msg, void *user_data)
|
||||||
|
|
||||||
l_queue_push_head(wiphy->netdev_list, netdev);
|
l_queue_push_head(wiphy->netdev_list, netdev);
|
||||||
|
|
||||||
if (!l_dbus_register_interface(dbus,
|
if (!l_dbus_object_add_interface(dbus,
|
||||||
iwd_device_get_path(netdev),
|
iwd_device_get_path(netdev),
|
||||||
IWD_DEVICE_INTERFACE,
|
IWD_DEVICE_INTERFACE, netdev))
|
||||||
setup_device_interface,
|
|
||||||
netdev, NULL))
|
|
||||||
l_info("Unable to register %s interface",
|
l_info("Unable to register %s interface",
|
||||||
IWD_DEVICE_INTERFACE);
|
IWD_DEVICE_INTERFACE);
|
||||||
else {
|
else {
|
||||||
|
@ -2357,6 +2326,21 @@ bool wiphy_init(struct l_genl_family *in)
|
||||||
l_queue_destroy(wiphy_list, NULL);
|
l_queue_destroy(wiphy_list, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!l_dbus_register_interface(dbus_get_bus(),
|
||||||
|
IWD_NETWORK_INTERFACE,
|
||||||
|
setup_network_interface,
|
||||||
|
NULL, true))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!l_dbus_register_interface(dbus_get_bus(),
|
||||||
|
IWD_DEVICE_INTERFACE,
|
||||||
|
setup_device_interface,
|
||||||
|
NULL, true)) {
|
||||||
|
l_dbus_unregister_interface(dbus_get_bus(),
|
||||||
|
IWD_NETWORK_INTERFACE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nl80211 = in;
|
nl80211 = in;
|
||||||
|
|
||||||
if (!l_genl_family_register(nl80211, "config", wiphy_config_notify,
|
if (!l_genl_family_register(nl80211, "config", wiphy_config_notify,
|
||||||
|
@ -2407,6 +2391,9 @@ bool wiphy_exit(void)
|
||||||
|
|
||||||
nl80211 = NULL;
|
nl80211 = NULL;
|
||||||
|
|
||||||
|
l_dbus_unregister_interface(dbus_get_bus(), IWD_DEVICE_INTERFACE);
|
||||||
|
l_dbus_unregister_interface(dbus_get_bus(), IWD_NETWORK_INTERFACE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
src/wsc.c
19
src/wsc.c
|
@ -302,10 +302,9 @@ static void netdev_appeared(struct netdev *netdev, void *userdata)
|
||||||
wsc = l_new(struct wsc, 1);
|
wsc = l_new(struct wsc, 1);
|
||||||
wsc->netdev = netdev;
|
wsc->netdev = netdev;
|
||||||
|
|
||||||
if (!l_dbus_register_interface(dbus, iwd_device_get_path(netdev),
|
if (!l_dbus_object_add_interface(dbus, iwd_device_get_path(netdev),
|
||||||
IWD_WSC_INTERFACE,
|
IWD_WSC_INTERFACE,
|
||||||
setup_wsc_interface,
|
wsc)) {
|
||||||
wsc, wsc_free)) {
|
|
||||||
wsc_free(wsc);
|
wsc_free(wsc);
|
||||||
l_info("Unable to register %s interface", IWD_WSC_INTERFACE);
|
l_info("Unable to register %s interface", IWD_WSC_INTERFACE);
|
||||||
}
|
}
|
||||||
|
@ -313,15 +312,15 @@ static void netdev_appeared(struct netdev *netdev, void *userdata)
|
||||||
|
|
||||||
static void netdev_disappeared(struct netdev *netdev, void *userdata)
|
static void netdev_disappeared(struct netdev *netdev, void *userdata)
|
||||||
{
|
{
|
||||||
struct l_dbus *dbus = dbus_get_bus();
|
|
||||||
|
|
||||||
if (!l_dbus_unregister_interface(dbus, iwd_device_get_path(netdev),
|
|
||||||
IWD_WSC_INTERFACE))
|
|
||||||
l_info("Unable to unregister %s interface", IWD_WSC_INTERFACE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wsc_init(struct l_genl_family *in)
|
bool wsc_init(struct l_genl_family *in)
|
||||||
{
|
{
|
||||||
|
if (!l_dbus_register_interface(dbus_get_bus(), IWD_WSC_INTERFACE,
|
||||||
|
setup_wsc_interface,
|
||||||
|
wsc_free, false))
|
||||||
|
return false;
|
||||||
|
|
||||||
netdev_watch = netdev_watch_add(netdev_appeared, netdev_disappeared,
|
netdev_watch = netdev_watch_add(netdev_appeared, netdev_disappeared,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
if (!netdev_watch)
|
if (!netdev_watch)
|
||||||
|
@ -338,6 +337,8 @@ bool wsc_exit()
|
||||||
if (!nl80211)
|
if (!nl80211)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
l_dbus_unregister_interface(dbus_get_bus(), IWD_WSC_INTERFACE);
|
||||||
|
|
||||||
netdev_watch_remove(netdev_watch);
|
netdev_watch_remove(netdev_watch);
|
||||||
nl80211 = 0;
|
nl80211 = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue