diff options
author | Eric Koegel <eric.koegel@gmail.com> | 2015-03-31 19:34:38 +0300 |
---|---|---|
committer | Eric Koegel <eric.koegel@gmail.com> | 2015-04-13 11:41:19 +0300 |
commit | bdf3571ebec8a470282be9fd32572fd046c8c994 (patch) | |
tree | b26a8c1c83b19d5d76e9b5065c7cabdd01fd1e48 /src/ck-session.c | |
parent | 7361cb986ac123d6cdc50b265f2517522c187d1b (diff) | |
download | ConsoleKit2-bdf3571ebec8a470282be9fd32572fd046c8c994.tar.gz |
More GDBus work
Now we can start the daemon, call ck-launch-session and get info
about it from ck-list-sessions.
Diffstat (limited to 'src/ck-session.c')
-rw-r--r-- | src/ck-session.c | 97 |
1 files changed, 60 insertions, 37 deletions
diff --git a/src/ck-session.c b/src/ck-session.c index 1d8bfe1..526fa8b 100644 --- a/src/ck-session.c +++ b/src/ck-session.c @@ -65,11 +65,6 @@ struct CkSessionPrivate GDBusProxy *bus_proxy; }; -enum { - ACTIVATE, - LAST_SIGNAL -}; - /* Private properties not exported over D-BUS */ enum { PROP_0, @@ -78,8 +73,6 @@ enum { PROP_LOGIN_SESSION_ID, }; -static guint signals [LAST_SIGNAL] = { 0, }; - static void ck_session_class_init (CkSessionClass *klass); static void ck_session_init (CkSession *session); static void ck_session_iface_init (ConsoleKitSessionIface *iface); @@ -277,6 +270,23 @@ session_set_idle_hint_internal (CkSession *session, return TRUE; } +static gboolean +dbus_get_idle_since_hint (ConsoleKitSession *cksession, + GDBusMethodInvocation *context) +{ + CkSession *session = CK_SESSION(cksession); + char *date_str; + + g_return_val_if_fail (CK_IS_SESSION (cksession), FALSE); + + date_str = g_time_val_to_iso8601 (&session->priv->idle_since_hint); + + console_kit_session_complete_get_idle_since_hint (cksession, context, date_str); + + g_free (date_str); + return TRUE; +} + /* Example: dbus-send --system --dest=org.freedesktop.ConsoleKit \ @@ -359,25 +369,10 @@ ck_session_set_active (CkSession *session, } static gboolean -activate (CkSession *session, - GDBusMethodInvocation *context) +dbus_is_active (ConsoleKitSession *cksession, + GDBusMethodInvocation *context) { - gboolean res; - - g_return_val_if_fail (CK_IS_SESSION (session), FALSE); - - res = FALSE; - g_signal_emit (session, signals [ACTIVATE], 0, context, &res); - if (! res) { - /* if the signal is not handled then either: - a) aren't attached to seat - b) seat doesn't support activation changes */ - g_debug ("Activate signal not handled"); - - throw_error (context, CK_SESSION_ERROR_GENERAL, _("Unable to activate session")); - return FALSE; - } - + console_kit_session_complete_is_active (cksession, context, console_kit_session_get_active (cksession)); return TRUE; } @@ -385,7 +380,8 @@ static gboolean dbus_activate (ConsoleKitSession *cksession, GDBusMethodInvocation *context) { - ck_session_set_active (CK_SESSION (cksession), TRUE, NULL); + console_kit_session_set_active (cksession, TRUE); + console_kit_session_emit_active_changed (cksession, TRUE); console_kit_session_complete_activate (cksession, context); return TRUE; @@ -519,6 +515,20 @@ ck_session_set_x11_display_device (CkSession *session, return TRUE; } +static gboolean +dbus_get_remote_host_name (ConsoleKitSession *cksession, + GDBusMethodInvocation *context) +{ + const gchar *remote_host_name = console_kit_session_get_remote_host_name (cksession); + + if (remote_host_name == NULL) { + remote_host_name = ""; + } + + console_kit_session_complete_get_remote_host_name (cksession, context, remote_host_name); + return TRUE; +} + gboolean ck_session_set_remote_host_name (CkSession *session, const char *remote_host_name, @@ -535,6 +545,17 @@ ck_session_set_remote_host_name (CkSession *session, return TRUE; } +static gboolean +dbus_get_creation_time (ConsoleKitSession *cksession, + GDBusMethodInvocation *context) +{ + CkSession *session = CK_SESSION(cksession); + g_return_val_if_fail (CK_IS_SESSION (cksession), FALSE); + + console_kit_session_complete_get_creation_time (cksession, context, g_time_val_to_iso8601 (&session->priv->creation_time)); + return TRUE; +} + gboolean ck_session_get_creation_time (CkSession *session, char **iso8601_datetime, @@ -549,6 +570,14 @@ ck_session_get_creation_time (CkSession *session, return TRUE; } +static gboolean +dbus_is_local (ConsoleKitSession *cksession, + GDBusMethodInvocation *context) +{ + console_kit_session_complete_is_local (cksession, context, console_kit_session_get_is_local (cksession)); + return TRUE; +} + gboolean ck_session_set_is_local (CkSession *session, gboolean is_local, @@ -789,17 +818,6 @@ ck_session_class_init (CkSessionClass *klass) object_class->set_property = ck_session_set_property; object_class->finalize = ck_session_finalize; - signals [ACTIVATE] = - g_signal_new ("activate", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CkSessionClass, activate), - NULL, - NULL, - ck_marshal_BOOLEAN__POINTER, - G_TYPE_BOOLEAN, - 1, G_TYPE_POINTER); - /* Install private properties we're not exporting over D-BUS */ g_object_class_install_property (object_class, PROP_ID, @@ -847,6 +865,11 @@ ck_session_iface_init (ConsoleKitSessionIface *iface) iface->handle_get_x11_display_device = dbus_get_x11_display_device; iface->handle_get_display_device = dbus_get_display_device; iface->handle_get_x11_display = dbus_get_x11_display; + iface->handle_is_active = dbus_is_active; + iface->handle_get_creation_time = dbus_get_creation_time; + iface->handle_get_remote_host_name = dbus_get_remote_host_name; + iface->handle_get_idle_since_hint = dbus_get_idle_since_hint; + iface->handle_is_local = dbus_is_local; } static void |