[gdm/wip/initial-setup2] initial-setup: Implement account data copying



commit a17f9d131c981b9a7c2f2f12837bb28d7cca211d
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Apr 16 04:52:57 2012 +0200

    initial-setup: Implement account data copying

 gui/initial-setup/README              |    3 ---
 gui/initial-setup/gdm-initial-setup.c |   29 ++++++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/gui/initial-setup/README b/gui/initial-setup/README
index 466681c..d5276e3 100644
--- a/gui/initial-setup/README
+++ b/gui/initial-setup/README
@@ -57,9 +57,6 @@ user account.
 TODO
 ----
 
-- Copying the settings from the gdm-initial-setup account to the newly
-  created user account is not implemented
-
 - Automatic detection of location/timezone (using geoclue) is not
   implemented
 
diff --git a/gui/initial-setup/gdm-initial-setup.c b/gui/initial-setup/gdm-initial-setup.c
index 7c81996..1336980 100644
--- a/gui/initial-setup/gdm-initial-setup.c
+++ b/gui/initial-setup/gdm-initial-setup.c
@@ -1666,12 +1666,39 @@ prepare_online_page (SetupData *setup)
 static void
 copy_account_data (SetupData *setup)
 {
+        const gchar *username, *to, *from;
+        gchar *argv[12];
+        GError *error = NULL;
+
         /* 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
          */
         g_debug ("Copying account data");
         g_settings_sync ();
+
+        username = act_user_get_user_name (setup->act_user);
+
+        from = g_build_filename (g_get_home_dir (), ".config", "dconf", "user", NULL);
+        to = g_build_filename (act_user_get_home_dir (setup->act_user), ".config", "dconf", "user", NULL);
+
+        argv[0] = "/usr/bin/pkexec";
+        argv[1] = "install";
+        argv[2] = "-D";
+        argv[3] = "--owner";
+        argv[4] = (gchar *)username;
+        argv[5] = "--group";
+        argv[6] = (gchar *)username;
+        argv[7] = "--mode";
+        argv[8] = "644";
+        argv[9] = (gchar *)from;
+        argv[10] = (gchar *)to;
+        argv[11] = NULL;
+
+        if (!g_spawn_sync (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, NULL, &error)) {
+                g_warning ("Failed to copy account data: %s", error->message);
+                g_error_free (error);
+        }
 }
 
 static void
@@ -1746,7 +1773,7 @@ prepare_cb (GtkAssistant *assi, GtkWidget *page, SetupData *setup)
 
         save_account_data (setup);
 
-        if (page == WID("summary_page"))
+        if (page == WID("summary-page"))
                 copy_account_data (setup);
 }
 



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