Commit 6fa59ef0 authored by Frederic Peters's avatar Frederic Peters

migrate configuration files to XDG config directory

parent e1fa1739
......@@ -321,6 +321,67 @@ create_salut_account (void)
g_object_unref (book);
}
static void
migrate_config_to_xdg_dir (void)
{
gchar *xdg_dir, *old_dir, *xdg_filename, *old_filename;
int i;
GFile *xdg_file, *old_file;
static const gchar* filenames[] = {
"geometry.ini",
"irc-networks.xml",
"chatrooms.xml",
"contact-groups.xml",
"status-presets.xml",
"accels.txt",
NULL
};
xdg_dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
if (g_file_test (xdg_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
/* xdg config dir already exists */
g_free (xdg_dir);
return;
}
old_dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
if (!g_file_test (old_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
/* old config dir didn't exist */
g_free (xdg_dir);
g_free (old_dir);
return;
}
if (g_mkdir_with_parents (xdg_dir, (S_IRUSR | S_IWUSR | S_IXUSR)) == -1) {
DEBUG ("Failed to create configuration directory; aborting migration");
g_free (xdg_dir);
g_free (old_dir);
return;
}
for (i = 0; filenames[i]; i++) {
old_filename = g_build_filename (old_dir, filenames[i], NULL);
if (!g_file_test (old_filename, G_FILE_TEST_EXISTS)) {
g_free (old_filename);
continue;
}
xdg_filename = g_build_filename (xdg_dir, filenames[i], NULL);
old_file = g_file_new_for_path (old_filename);
xdg_file = g_file_new_for_path (xdg_filename);
if (!g_file_move (old_file, xdg_file, G_FILE_COPY_NONE,
NULL, NULL, NULL, NULL)) {
DEBUG ("Failed to migrate %s", filenames[i]);
}
g_free (old_filename);
g_free (xdg_filename);
g_object_unref (old_file);
g_object_unref (xdg_file);
}
g_free (xdg_dir);
g_free (old_dir);
}
/* The code that handles single-instance and startup notification is
* copied from gedit.
*
......@@ -637,6 +698,8 @@ main (int argc, char *argv[])
empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE);
}
migrate_config_to_xdg_dir ();
create_salut_account ();
/* Setting up UI */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment