From 5ab3eee820e97d632aa9401cbd2d25dc828ee1f0 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Tue, 12 Feb 2008 22:30:05 -0500 Subject: ck_seat_get_active_session shouldn't return a null ssid Da bus no likey nulls for object paths. Return false and set error if there is no active session. --- src/ck-seat.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/ck-seat.c') diff --git a/src/ck-seat.c b/src/ck-seat.c index bc39010..8d93693 100644 --- a/src/ck-seat.c +++ b/src/ck-seat.c @@ -124,17 +124,37 @@ ck_seat_get_active_session (CkSeat *seat, char **ssid, GError **error) { + gboolean ret; + char *session_id; + g_return_val_if_fail (CK_IS_SEAT (seat), FALSE); + g_debug ("CkSeat: get active session"); + session_id = NULL; + ret = FALSE; if (seat->priv->active_session != NULL) { - ck_session_get_id (seat->priv->active_session, ssid, NULL); + gboolean res; + res = ck_session_get_id (seat->priv->active_session, &session_id, NULL); + if (res) { + ret = TRUE; + } + } else { + g_debug ("CkSeat: seat has no active session"); + } + + if (! ret) { + g_set_error (error, + CK_SEAT_ERROR, + CK_SEAT_ERROR_GENERAL, + "%s", "Seat has no active session"); } else { if (ssid != NULL) { - *ssid = NULL; + *ssid = g_strdup (session_id); } } - return TRUE; + g_free (session_id); + return ret; } typedef struct -- cgit