[gdm/wip/initial-setup] Add code to initiate autologin



commit 01a75e303614ca12ec25d84bc7c93cdb97f93be5
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue May 17 15:21:29 2011 -0400

    Add code to initiate autologin
    
    This has not been tested in situ yet, it is just copied from
    what gdm-simple-greeter does.

 gui/initial-setup/gdm-initial-setup.c |   65 +++++++++++++++++++++++++++++++--
 1 files changed, 62 insertions(+), 3 deletions(-)
---
diff --git a/gui/initial-setup/gdm-initial-setup.c b/gui/initial-setup/gdm-initial-setup.c
index fa0493c..b9a09da 100644
--- a/gui/initial-setup/gdm-initial-setup.c
+++ b/gui/initial-setup/gdm-initial-setup.c
@@ -1188,9 +1188,6 @@ queue_set_timezone (SetupData *setup)
 static void
 update_timezone (SetupData *setup)
 {
-        GtkWidget *widget;
-        GtkTreeIter iter;
-        GtkTreeModel *model;
         GString *str;
         gchar *location;
         gchar *timezone;
@@ -1392,6 +1389,64 @@ prepare_assistant (SetupData *setup)
         prepare_location_page (setup);
 }
 
+static void
+copy_account_data (SetupData *setup)
+{
+        /* FIXME: here is where we copy all the things we just
+         * configured, from the current users home dir to the
+         * account that was created in the first step
+         */
+}
+
+static void
+begin_autologin (SetupData *setup)
+{
+        const gchar *address;
+        GDBusConnection *connection;
+        GError *error;
+        const gchar *username;
+        GVariant *ret;
+
+        address = g_getenv ("GDM_GREETER_DBUS_ADDRESS");
+        if (address == NULL) {
+                g_warning ("GDM_GREETER_DBUS_ADDRESS not set; not initiating autologin");
+                return;
+        }
+
+        error = NULL;
+        connection = g_dbus_connection_new_for_address_sync (address,
+                                                             G_DBUS_CONNECTION_FLAGS_NONE,
+                                                             NULL,
+                                                             NULL,
+                                                             &error);
+        if (connection == NULL) {
+                g_warning ("Failed to create D-Bus connection for address '%s' (%s); not initiating autologin", address, error->message);
+                g_error_free (error);
+                return;
+        }
+
+        username = act_user_get_user_name (setup->act_user);
+
+        ret = g_dbus_connection_call_sync (connection,
+                                           "/org/gnome/DisplayManager/GreeterServer",
+                                           "/",
+                                           "org.gnome.DisplayManager.GreeterServer",
+                                           "BeginAutoLogin",
+                                           g_variant_new ("(s)", username),
+                                           NULL, /* no reply checking */
+                                           G_DBUS_CALL_FLAGS_NONE,
+                                           -1,
+                                           NULL,
+                                           &error);
+        if (ret == NULL) {
+                g_warning ("Calling org.gnome.DisplayManager.GreeterServer.BeginAutoLogin failed: %s", error->message);
+                g_error_free (error);
+                return;
+        }
+
+        g_variant_unref (ret);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -1423,5 +1478,9 @@ main (int argc, char *argv[])
 
         g_settings_sync ();
 
+        copy_account_data (setup);
+
+        begin_autologin (setup);
+
         return 0;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]