From c04f1b57aa89e80931e9483c4e9b7089dc938018 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 16 Feb 2016 16:51:23 +1000 Subject: [PATCH] device: switch active profile over to return an index only Returning the object path makes it harder for the client to identify which object is the active one. A simple index into the devices array is easier to handle. Note: another approach was to have an IsActive property on the profile directly. This would require updating all properties when the active profile is changed, it's simpler to just have one index. Signed-off-by: Peter Hutterer --- src/ratbagd-device.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ratbagd-device.c b/src/ratbagd-device.c index 7297ceb1..25f0d33c 100644 --- a/src/ratbagd-device.c +++ b/src/ratbagd-device.c @@ -205,12 +205,12 @@ static int ratbagd_device_get_active_profile(sd_bus *bus, if (!ratbagd_profile_is_active(profile)) continue; - return sd_bus_message_append(reply, "o", - ratbagd_profile_get_path(profile)); + return sd_bus_message_append(reply, "u", i); } - /* Eww, we want 'maybe' types here! */ - return sd_bus_message_append(reply, "o", "/"); + fprintf(stderr, "Unable to find active profile for %s\n", + device->name); + return sd_bus_message_append(reply, "u", 0); } static int ratbagd_device_get_profile_by_index(sd_bus_message *m, @@ -240,7 +240,7 @@ const sd_bus_vtable ratbagd_device_vtable[] = { SD_BUS_PROPERTY("Description", "s", ratbagd_device_get_description, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Svg", "s", ratbagd_device_get_svg, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Profiles", "ao", ratbagd_device_get_profiles, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("ActiveProfile", "o", ratbagd_device_get_active_profile, 0, 0), + SD_BUS_PROPERTY("ActiveProfile", "u", ratbagd_device_get_active_profile, 0, 0), SD_BUS_METHOD("GetProfileByIndex", "u", "o", ratbagd_device_get_profile_by_index, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_VTABLE_END, };