diff options
author | Eric Koegel <eric.koegel@gmail.com> | 2016-01-25 11:58:03 +0300 |
---|---|---|
committer | Eric Koegel <eric.koegel@gmail.com> | 2016-01-25 11:58:03 +0300 |
commit | 3ccb5e38e59f570ec0f3dd6bf6e67fd82f5944a0 (patch) | |
tree | 475232ba78dc3fa14a5b838d67d26a2e8a80b440 /src/console-kit.c | |
parent | 3402fbafacf167d8b29d0b59f8b297b0e5731c29 (diff) | |
download | lightdm-3ccb5e38e59f570ec0f3dd6bf6e67fd82f5944a0.tar.gz |
Add XDG_RUNTIME_DIR from ConsoleKit2
Diffstat (limited to 'src/console-kit.c')
-rw-r--r-- | src/console-kit.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/console-kit.c b/src/console-kit.c index 41ffbc49..ac514cc2 100644 --- a/src/console-kit.c +++ b/src/console-kit.c @@ -260,3 +260,53 @@ ck_close_session (const gchar *cookie) if (!is_closed) g_warning ("ConsoleKit.Manager.CloseSession() returned false"); } + +gchar * +ck_get_xdg_runtime_dir (const gchar *cookie) +{ + GDBusConnection *bus; + gchar *session_path; + gchar *runtime_dir = NULL; + GError *error = NULL; + + g_return_if_fail (cookie != NULL); + + g_debug ("Getting XDG_RUNTIME_DIR from ConsoleKit for session %s", cookie); + + bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); + if (error) + g_warning ("Failed to get system bus: %s", error->message); + g_clear_error (&error); + if (!bus) + return NULL; + + session_path = get_ck_session (bus, cookie); + if (session_path) + { + GVariant *result; + + result = g_dbus_connection_call_sync (bus, + "org.freedesktop.ConsoleKit", + session_path, + "org.freedesktop.ConsoleKit.Session", + "GetXDGRuntimeDir", + g_variant_new ("()"), + G_VARIANT_TYPE ("(s)"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (error) + g_warning ("Error getting XDG_RUNTIME_DIR from ConsoleKit: %s", error->message); + g_clear_error (&error); + if (!result) + return NULL; + + g_variant_get (result, "(s)", &runtime_dir); + g_variant_unref (result); + g_debug ("ConsoleKit XDG_RUNTIME_DIR is %s", runtime_dir); + } + + g_object_unref (bus); + return runtime_dir; +} |