[gnome-initial-setup] Add a new copy worker



commit 215f3ea1e1c0188f4f91290ade90f5e6d88fc86b
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Aug 20 01:01:18 2012 -0400

    Add a new copy worker
    
    This will be an autostart app that will copy files to the new profile.

 .gitignore                                         |    2 +
 data/Makefile.am                                   |    3 +
 data/gnome-initial-setup-copy-worker.desktop.in.in |    8 ++
 gnome-initial-setup/Makefile.am                    |    4 +-
 .../gnome-initial-setup-copy-worker.c              |   74 ++++++++++++++++++++
 5 files changed, 90 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 90dd5d0..d197c6e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,9 +51,11 @@ gnome-initial-setup-*.tar.xz
 
 gnome-initial-setup/setup_resources.c
 gnome-initial-setup/gnome-initial-setup
+gnome-initial-setup/gnome-initial-setup-copy-worker
 
 gnome-initial-setup/pages/location/timedated.c
 gnome-initial-setup/pages/location/timedated.h
 gnome-initial-setup/pages/language/languages/list-languages
 
 gnome-initial-setup.desktop
+gnome-initial-setup-copy-worker.desktop
\ No newline at end of file
diff --git a/data/Makefile.am b/data/Makefile.am
index dd1c369..7ae31f8 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -42,9 +42,12 @@ EXTRA_DIST =						\
 CLEANFILES =						\
 	gnome-initial-setup.desktop.in			\
 	gnome-initial-setup.desktop			\
+	gnome-initial-setup-copy-worker.desktop.in	\
+	gnome-initial-setup-copy-worker.desktop		\
 	$(NULL)
 
 autostartdir = $(sysconfdir)/xdg/autostart
 autostart_DATA =					\
 	welcome-tour.desktop				\
+	gnome-initial-setup-copy-worker.desktop		\
 	$(NULL)
diff --git a/data/gnome-initial-setup-copy-worker.desktop.in.in b/data/gnome-initial-setup-copy-worker.desktop.in.in
new file mode 100644
index 0000000..22e3ac6
--- /dev/null
+++ b/data/gnome-initial-setup-copy-worker.desktop.in.in
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Name=GNOME Initial Setup Copy Worker
+Type=Application
+Exec= LIBEXECDIR@/gnome-initial-setup-copy-worker
+OnlyShowIn=GNOME;
+NoDisplay=true
+X-GNOME-AutoRestart=false
+X-GNOME-Autostart-Phase=Initialization
diff --git a/gnome-initial-setup/Makefile.am b/gnome-initial-setup/Makefile.am
index 5422c6b..b022856 100644
--- a/gnome-initial-setup/Makefile.am
+++ b/gnome-initial-setup/Makefile.am
@@ -13,7 +13,7 @@ AM_CPPFLAGS = \
 
 LIBS = $(INITIAL_SETUP_LIBS) -lm
 
-libexec_PROGRAMS = gnome-initial-setup
+libexec_PROGRAMS = gnome-initial-setup gnome-initial-setup-copy-worker
 
 BUILT_SOURCES =
 
@@ -51,6 +51,8 @@ gnome_initial_setup_LDADD =	\
 	pages/goa/libgisgoa.la \
 	pages/summary/libgissummary.la
 
+gnome_initial_setup_copy_worker_SOURCES =		\
+	gnome-initial-setup-copy-worker.c
 
 EXTRA_DIST = \
 	$(UI_FILES) \
diff --git a/gnome-initial-setup/gnome-initial-setup-copy-worker.c b/gnome-initial-setup/gnome-initial-setup-copy-worker.c
new file mode 100644
index 0000000..efde1b6
--- /dev/null
+++ b/gnome-initial-setup/gnome-initial-setup-copy-worker.c
@@ -0,0 +1,74 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/* Copies settings installed from gnome-initial-setup and
+ * sticks them in the user's profile */
+
+#include <gio/gio.h>
+
+#define SKELETON_DIR "/dev/shm/gnome-initial-setup/skeleton"
+
+static gboolean
+move_file_from_tmpfs (GFile *src_base,
+                      const gchar *dir,
+                      const gchar *path)
+{
+  GFile *dest_dir = g_file_new_for_path (dir);
+  GFile *dest = g_file_get_child (dest_dir, path);
+  gchar *basename = g_file_get_basename (dest);
+  GFile *src = g_file_get_child (src_base, basename);
+
+  GError *error = NULL;
+
+  if (!g_file_move (src, dest, G_FILE_COPY_NONE,
+                    NULL, NULL, NULL, &error)) {
+    g_warning ("Unable to move %s to %s: %s",
+               g_file_get_path (src),
+               g_file_get_path (dest),
+               error->message);
+    goto out;
+  }
+
+ out:
+  g_object_unref (dest_dir);
+  g_object_unref (dest);
+  g_object_unref (src);
+  g_free (basename);
+
+  if (error != NULL) {
+    g_error_free (error);
+    return FALSE;
+  } else {
+    return TRUE;
+  }
+}
+
+int
+main (int    argc,
+      char **argv)
+{
+  GFile *src;
+  int ret = 0;
+
+  g_type_init ();
+
+  src = g_file_new_for_path (SKELETON_DIR);
+
+  if (g_file_query_exists (src, NULL))
+    goto out;
+
+  ret = 1;
+
+#define MOVE(d, x)                                                      \
+  if (!move_file_from_tmpfs (src, g_get_user_##d##_dir (), x))          \
+    goto out;
+
+  MOVE (config, "dconf/user")
+  MOVE (config, "goa-1.0/accounts.conf")
+  MOVE (data, "keyrings/Default.keyring")
+
+  ret = 0;
+
+ out:
+  g_object_unref (src);
+  return ret;
+}



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