diff options
Diffstat (limited to 'plugins/power/gsd-power-manager.c')
-rw-r--r-- | plugins/power/gsd-power-manager.c | 61 |
1 files changed, 47 insertions, 14 deletions
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c index 0263e9f6..dbdb6ab3 100644 --- a/plugins/power/gsd-power-manager.c +++ b/plugins/power/gsd-power-manager.c @@ -1186,10 +1186,48 @@ action_hibernate (GsdPowerManager *manager) "Error calling Hibernate"); } + +static void +light_claimed_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + GsdPowerManager *manager = user_data; + g_autoptr(GError) error = NULL; + g_autoptr(GVariant) result = NULL; + + result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), + res, + &error); + if (result == NULL) { + g_warning ("Claiming light sensor failed: %s", error->message); + return; + } + iio_proxy_changed (manager); +} + + +static void +light_released_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + g_autoptr(GError) error = NULL; + g_autoptr(GVariant) result = NULL; + + result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), + res, + &error); + if (result == NULL) { + g_warning ("Release of light sensors failed: %s", error->message); + return; + } +} + + static void iio_proxy_claim_light (GsdPowerManager *manager, gboolean active) { - GError *error = NULL; if (manager->iio_proxy == NULL) return; if (!manager->backlight) @@ -1211,19 +1249,14 @@ iio_proxy_claim_light (GsdPowerManager *manager, gboolean active) g_signal_connect (manager->iio_proxy, "g-properties-changed", G_CALLBACK (iio_proxy_changed_cb), manager); - if (!g_dbus_proxy_call_sync (manager->iio_proxy, - active ? "ClaimLight" : "ReleaseLight", - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - &error)) { - g_warning ("Call to iio-proxy failed: %s", error->message); - g_error_free (error); - } - - if (active) - iio_proxy_changed (manager); + g_dbus_proxy_call (manager->iio_proxy, + active ? "ClaimLight" : "ReleaseLight", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + manager->cancellable, + active ? light_claimed_cb : light_released_cb, + manager); } static void |