~ci-train-bot/lightdm/lightdm-ubuntu-zesty-1679

« back to all changes in this revision

Viewing changes to src/console-kit.c

  • Committer: Eric Koegel
  • Date: 2016-01-25 08:58:03 UTC
  • mto: This revision was merged to the branch mainline in revision 2272.
  • Revision ID: eric.koegel@gmail.com-20160125085803-s564zivui7usk0yp
Add XDG_RUNTIME_DIR from ConsoleKit2

Show diffs side-by-side

added added

removed removed

Lines of Context:
260
260
    if (!is_closed)
261
261
        g_warning ("ConsoleKit.Manager.CloseSession() returned false");
262
262
}
 
263
 
 
264
gchar *
 
265
ck_get_xdg_runtime_dir (const gchar *cookie)
 
266
{
 
267
    GDBusConnection *bus;
 
268
    gchar *session_path;
 
269
    gchar *runtime_dir = NULL;
 
270
    GError *error = NULL;
 
271
 
 
272
    g_return_if_fail (cookie != NULL);
 
273
 
 
274
    g_debug ("Getting XDG_RUNTIME_DIR from ConsoleKit for session %s", cookie);
 
275
 
 
276
    bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
 
277
    if (error)
 
278
        g_warning ("Failed to get system bus: %s", error->message);
 
279
    g_clear_error (&error);
 
280
    if (!bus)
 
281
        return NULL;
 
282
 
 
283
    session_path = get_ck_session (bus, cookie);
 
284
    if (session_path)
 
285
    {
 
286
        GVariant *result;
 
287
 
 
288
        result = g_dbus_connection_call_sync (bus,
 
289
                                              "org.freedesktop.ConsoleKit",
 
290
                                              session_path,
 
291
                                              "org.freedesktop.ConsoleKit.Session",
 
292
                                              "GetXDGRuntimeDir",
 
293
                                              g_variant_new ("()"),
 
294
                                              G_VARIANT_TYPE ("(s)"),
 
295
                                              G_DBUS_CALL_FLAGS_NONE,
 
296
                                              -1,
 
297
                                              NULL,
 
298
                                              &error);
 
299
        if (error)
 
300
            g_warning ("Error getting XDG_RUNTIME_DIR from ConsoleKit: %s", error->message);
 
301
        g_clear_error (&error);
 
302
        if (!result)
 
303
            return NULL;
 
304
 
 
305
        g_variant_get (result, "(s)", &runtime_dir);
 
306
        g_variant_unref (result);
 
307
        g_debug ("ConsoleKit XDG_RUNTIME_DIR is %s", runtime_dir);
 
308
    }
 
309
 
 
310
    g_object_unref (bus);
 
311
    return runtime_dir;
 
312
}