aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-11-22 02:59:30 +0800
committerMilan Crha <mcrha@redhat.com>2012-11-22 02:59:30 +0800
commit5c8be9044726f7b6d6701091839d9e426263a8e2 (patch)
tree8d21e923e70125f02f05769e993e89b8ae8b1570 /modules
parentabdefcaa26ca7116bfc5b7aaa9ee2f04de533ecb (diff)
downloadgsoc2013-evolution-5c8be9044726f7b6d6701091839d9e426263a8e2.tar
gsoc2013-evolution-5c8be9044726f7b6d6701091839d9e426263a8e2.tar.gz
gsoc2013-evolution-5c8be9044726f7b6d6701091839d9e426263a8e2.tar.bz2
gsoc2013-evolution-5c8be9044726f7b6d6701091839d9e426263a8e2.tar.lz
gsoc2013-evolution-5c8be9044726f7b6d6701091839d9e426263a8e2.tar.xz
gsoc2013-evolution-5c8be9044726f7b6d6701091839d9e426263a8e2.tar.zst
gsoc2013-evolution-5c8be9044726f7b6d6701091839d9e426263a8e2.zip
Bug #680201 - Backup restore doesn't migrate accounts from GConf
Diffstat (limited to 'modules')
-rw-r--r--modules/backup-restore/Makefile.am1
-rw-r--r--modules/backup-restore/evolution-backup-tool.c71
2 files changed, 62 insertions, 10 deletions
diff --git a/modules/backup-restore/Makefile.am b/modules/backup-restore/Makefile.am
index 4d23edf7f2..7d952e795e 100644
--- a/modules/backup-restore/Makefile.am
+++ b/modules/backup-restore/Makefile.am
@@ -53,6 +53,7 @@ evolution_backup_CPPFLAGS = \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-DDATADIR=\""$(datadir)"\" \
-DLIBDIR=\""$(libdir)"\" \
+ -DDBUS_SERVICES_DIR=\"'${datadir}'/dbus-1/services\" \
$(EVOLUTION_DATA_SERVER_CFLAGS) \
$(GNOME_PLATFORM_CFLAGS) \
$(NULL)
diff --git a/modules/backup-restore/evolution-backup-tool.c b/modules/backup-restore/evolution-backup-tool.c
index bc6ee2723b..f02680f328 100644
--- a/modules/backup-restore/evolution-backup-tool.c
+++ b/modules/backup-restore/evolution-backup-tool.c
@@ -53,6 +53,7 @@
#define EVOLUTION "evolution"
#define EVOLUTION_DIR "$DATADIR/"
#define EVOLUTION_DIR_FILE EVOLUTION ".dir"
+#define DBUS_SOURCE_REGISTRY_SERVICE_FILE "$DBUSDATADIR/org.gnome.evolution.dataserver.Sources.service"
#define ANCIENT_GCONF_DUMP_FILE "backup-restore-gconf.xml"
@@ -178,6 +179,7 @@ replace_variables (const gchar *str)
repl ("$CONFIGDIR", e_get_user_config_dir ());
repl ("$STRIPDATADIR", strip_datadir);
repl ("$STRIPCONFIGDIR", strip_configdir);
+ repl ("$DBUSDATADIR", DBUS_SERVICES_DIR);
#undef repl
@@ -445,6 +447,46 @@ get_dir_level (const gchar *dir)
return res;
}
+static gchar *
+get_source_manager_reload_command (void)
+{
+ GString *tmp;
+ gchar *command;
+
+ tmp = replace_variables (DBUS_SOURCE_REGISTRY_SERVICE_FILE);
+ if (tmp) {
+ GKeyFile *key_file;
+ gchar *str = NULL;
+
+ key_file = g_key_file_new ();
+ if (g_key_file_load_from_file (key_file, tmp->str, G_KEY_FILE_NONE, NULL)) {
+ str = g_key_file_get_string (key_file, "D-BUS Service", "Name", NULL);
+ }
+ g_key_file_free (key_file);
+
+ if (str && *str) {
+ g_string_assign (tmp, str);
+ } else {
+ g_string_free (tmp, TRUE);
+ tmp = NULL;
+ }
+
+ g_free (str);
+ }
+
+ if (!tmp)
+ tmp = g_string_new ("org.gnome.evolution.dataserver.Sources0");
+
+ command = g_strdup_printf ("gdbus call --session --dest %s "
+ "--object-path /org/gnome/evolution/dataserver/SourceManager "
+ "--method org.gnome.evolution.dataserver.SourceManager.Reload",
+ tmp->str);
+
+ g_string_free (tmp, TRUE);
+
+ return command;
+}
+
static void
restore (const gchar *filename,
GCancellable *cancellable)
@@ -578,6 +620,10 @@ restore (const gchar *filename,
EVOLUTION_DIR ANCIENT_GCONF_DUMP_FILE,
EVOUSERDATADIR_MAGIC, e_get_user_data_dir ());
run_cmd ("gconftool-2 --load " EVOLUTION_DIR ANCIENT_GCONF_DUMP_FILE);
+
+ /* give a chance to GConf to save what was loaded into a disk */
+ g_usleep (G_USEC_PER_SEC * 5);
+
/* do not forget to convert GConf keys into GSettings */
run_cmd ("gsettings-data-convert");
run_cmd ("rm " EVOLUTION_DIR ANCIENT_GCONF_DUMP_FILE);
@@ -613,6 +659,9 @@ restore (const gchar *filename,
run_cmd (command);
g_free (command);
+ /* give a chance to GConf to save what was loaded into a disk */
+ g_usleep (G_USEC_PER_SEC * 5);
+
/* do not forget to convert GConf keys into GSettings */
run_cmd ("gsettings-data-convert");
@@ -640,16 +689,13 @@ restore (const gchar *filename,
txt = _("Reloading registry service");
- /* This runs migration routines on the newly-restored data.
- *
- * XXX Hard-coding the whole command like this is not ideal
- * because the "SourcesX" interface name will occasionally
- * change and I guarantee we'll forget to update this. */
- run_cmd (
- "gdbus call --session "
- "--dest org.gnome.evolution.dataserver.Sources0 "
- "--object-path /org/gnome/evolution/dataserver/SourceManager "
- "--method org.gnome.evolution.dataserver.SourceManager.Reload");
+ /* wait few seconds, till changes settle */
+ g_usleep (G_USEC_PER_SEC * 5);
+
+ command = get_source_manager_reload_command ();
+ /* This runs migration routines on the newly-restored data. */
+ run_cmd (command);
+ g_free (command);
end:
if (restart_arg) {
@@ -657,6 +703,11 @@ end:
return;
txt = _("Restarting Evolution");
+
+ /* wait 5 seconds before restarting evolution, thus any
+ changes being done are updated in source registry too */
+ g_usleep (G_USEC_PER_SEC * 5);
+
run_evolution_no_wait ();
}
}