]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
support unlocking a session right before switching to it
authorMichael Terry <michael.terry@canonical.com>
Thu, 28 Jul 2011 18:49:51 +0000 (14:49 -0400)
committerMichael Terry <michael.terry@canonical.com>
Thu, 28 Jul 2011 18:49:51 +0000 (14:49 -0400)
src/display.c
src/display.h
src/seat.c

index 4adc017beefe2d452d0fb81dd93c98173f4408c0..e34b36a3d6c17f4bcdb44655c39d6c754c311a53 100644 (file)
@@ -944,6 +944,87 @@ display_stop (Display *display)
     check_stopped (display);
 }
 
+void
+display_unlock (Display *display)
+{
+    GDBusProxy *proxy;
+    GVariant *result;
+    GError *error = NULL;
+    const gchar *cookie;
+    const gchar *session_path;
+
+    cookie = session_get_cookie (display->priv->session);
+    if (!cookie)
+        return;
+
+    proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                           G_DBUS_PROXY_FLAGS_NONE,
+                                           NULL,
+                                           "org.freedesktop.ConsoleKit",
+                                           "/org/freedesktop/ConsoleKit/Manager",
+                                           "org.freedesktop.ConsoleKit.Manager", 
+                                           NULL, &error);
+    if (!proxy)
+        g_warning ("Unable to get connection to ConsoleKit: %s", error->message);
+    g_clear_error (&error);
+    if (!proxy)
+        return;
+
+    result = g_dbus_proxy_call_sync (proxy,
+                                     "GetSessionForCookie",
+                                     g_variant_new ("(s)", cookie),
+                                     G_DBUS_CALL_FLAGS_NONE,
+                                     -1,
+                                     NULL,
+                                     &error);
+    g_object_unref (proxy);
+
+    if (!result)
+        g_warning ("Error getting ConsoleKit session: %s", error->message);
+    g_clear_error (&error);
+    if (!result)
+        return;
+
+    if (!g_variant_is_of_type (result, G_VARIANT_TYPE ("(o)")))
+    {
+        g_warning ("Unexpected response from GetSessionForCookie: %s", g_variant_get_type_string (result));
+        g_variant_unref (result);
+    }
+
+    g_variant_get (result, "(&o)", &session_path);
+
+    proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                           G_DBUS_PROXY_FLAGS_NONE,
+                                           NULL,
+                                           "org.freedesktop.ConsoleKit",
+                                           session_path,
+                                           "org.freedesktop.ConsoleKit.Session", 
+                                           NULL, &error);
+    if (!proxy)
+        g_warning ("Unable to get connection to ConsoleKit session: %s", error->message);
+    g_variant_unref (result);
+    g_clear_error (&error);
+    if (!proxy)
+        return;
+
+    result = g_dbus_proxy_call_sync (proxy,
+                                     "Unlock",
+                                     NULL,
+                                     G_DBUS_CALL_FLAGS_NONE,
+                                     -1,
+                                     NULL,
+                                     &error);
+    g_object_unref (proxy);
+
+    if (!result)
+        g_warning ("Error unlocking ConsoleKit session: %s", error->message);
+    g_clear_error (&error);
+    if (!result)
+        return;
+
+    g_variant_unref (result);
+}
+
 static gboolean
 display_real_switch_to_user (Display *display, const gchar *username)
 {
index 0217e0511bad46eedb2b896837a1f56c663529ed..69e3d60cfd5cd95f0b0a74f2b8ac903849a69d22 100644 (file)
@@ -70,6 +70,8 @@ void display_set_user_session (Display *display, const gchar *session_name);
 
 gboolean display_start (Display *display);
 
+void display_unlock (Display *display);
+
 void display_stop (Display *display);
 
 G_END_DECLS
index df33449eb0c1de04490ecbe0484df9bbbf45fe03..d5093b1dfedc36a6ada90c37dadc02c743a988d1 100644 (file)
@@ -132,6 +132,7 @@ void
 seat_set_active_display (Seat *seat, Display *display)
 {
     g_return_if_fail (seat != NULL);
+    display_unlock (display);
     SEAT_GET_CLASS (seat)->set_active_display (seat, display);
 }