"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/modules/backup-restore/evolution-backup-tool.c" between
evolution-3.40.2.tar.xz and evolution-3.40.3.tar.xz

About: Evolution is a personal information management application that provides integrated mail, calendaring and address book functionality (GNOME desktop).

evolution-backup-tool.c  (evolution-3.40.2.tar.xz):evolution-backup-tool.c  (evolution-3.40.3.tar.xz)
skipping to change at line 48 skipping to change at line 48
#include "e-util/e-util.h" #include "e-util/e-util.h"
#define EVOUSERDATADIR_MAGIC "#EVO_USERDATADIR#" #define EVOUSERDATADIR_MAGIC "#EVO_USERDATADIR#"
#define EVOLUTION "evolution" #define EVOLUTION "evolution"
#define EVOLUTION_DIR "$DATADIR/" #define EVOLUTION_DIR "$DATADIR/"
#define EVOLUTION_DIR_FILE EVOLUTION ".dir" #define EVOLUTION_DIR_FILE EVOLUTION ".dir"
#define ANCIENT_GCONF_DUMP_FILE "backup-restore-gconf.xml" #define ANCIENT_GCONF_DUMP_FILE "backup-restore-gconf.xml"
#define DCONF_DUMP_FILE_EDS "backup-restore-dconf-eds.ini" #define ANCIENT_DCONF_DUMP_FILE_EDS "backup-restore-dconf-eds.ini"
#define DCONF_DUMP_FILE_EVO "backup-restore-dconf-evo.ini" #define ANCIENT_DCONF_DUMP_FILE_EVO "backup-restore-dconf-evo.ini"
#define DCONF_PATH_EDS "/org/gnome/evolution-data-server/" #define ANCIENT_DCONF_PATH_EDS "/org/gnome/evolution-data-server/"
#define DCONF_PATH_EVO "/org/gnome/evolution/" #define ANCIENT_DCONF_PATH_EVO "/org/gnome/evolution/"
#define GSETTINGS_DUMP_FILE "backup-restore-gsettings.ini"
#define KEY_FILE_GROUP "Evolution Backup" #define KEY_FILE_GROUP "Evolution Backup"
static gboolean backup_op = FALSE; static gboolean backup_op = FALSE;
static gchar *bk_file = NULL; static gchar *bk_file = NULL;
static gboolean restore_op = FALSE; static gboolean restore_op = FALSE;
static gchar *res_file = NULL; static gchar *res_file = NULL;
static gboolean check_op = FALSE; static gboolean check_op = FALSE;
static gchar *chk_file = NULL; static gchar *chk_file = NULL;
static gboolean restart_arg = FALSE; static gboolean restart_arg = FALSE;
skipping to change at line 280 skipping to change at line 282
if (!filename) if (!filename)
return FALSE; return FALSE;
len = strlen (filename); len = strlen (filename);
if (len < 3) if (len < 3)
return FALSE; return FALSE;
return g_ascii_strcasecmp (filename + len - 3, ".xz") == 0; return g_ascii_strcasecmp (filename + len - 3, ".xz") == 0;
} }
typedef gboolean (* SettingsFunc) (GSettings *settings,
GSettingsSchema *schema,
const gchar *group,
const gchar *key,
GKeyFile *keyfile);
static gboolean
settings_foreach_schema_traverse (GSettings *settings,
SettingsFunc func,
GKeyFile *keyfile)
{
GSettingsSchema *schema = NULL;
const gchar *group;
gchar *schema_id = NULL, *path = NULL, *group_tmp = NULL;
gchar **strv;
gint ii;
gboolean need_sync = FALSE;
g_object_get (G_OBJECT (settings),
"settings-schema", &schema,
"schema-id", &schema_id,
"path", &path,
NULL);
if (!g_settings_schema_get_path (schema)) {
group_tmp = g_strconcat (schema_id, ":", path, NULL);
group = group_tmp;
} else {
group = schema_id;
}
strv = g_settings_schema_list_keys (schema);
for (ii = 0; strv && strv[ii]; ii++) {
need_sync = func (settings, schema, group, strv[ii], keyfile) ||
need_sync;
}
g_strfreev (strv);
strv = g_settings_schema_list_children (schema);
for (ii = 0; strv && strv[ii]; ii++) {
GSettings *child;
child = g_settings_get_child (settings, strv[ii]);
if (child) {
if (settings_foreach_schema_traverse (child, func, keyfil
e))
g_settings_sync ();
g_object_unref (child);
}
}
g_strfreev (strv);
g_settings_schema_unref (schema);
g_free (group_tmp);
g_free (schema_id);
g_free (path);
return need_sync;
}
static gboolean
settings_foreach_schema (SettingsFunc func,
GKeyFile *keyfile,
GError **error)
{
GSettingsSchemaSource *schema_source;
gchar **non_relocatable = NULL, **relocatable = NULL;
gint ii;
schema_source = g_settings_schema_source_get_default ();
if (!schema_source) {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "No GSettings
schema found");
return FALSE;
}
g_settings_schema_source_list_schemas (schema_source, TRUE, &non_relocata
ble, &relocatable);
for (ii = 0; non_relocatable && non_relocatable[ii]; ii++) {
if (g_str_has_prefix (non_relocatable[ii], "org.gnome.evolution")
) {
GSettings *settings;
settings = g_settings_new (non_relocatable[ii]);
if (settings_foreach_schema_traverse (settings, func, key
file))
g_settings_sync ();
g_object_unref (settings);
}
}
g_strfreev (non_relocatable);
g_strfreev (relocatable);
return TRUE;
}
static gboolean
backup_settings_foreach_cb (GSettings *settings,
GSettingsSchema *schema,
const gchar *group,
const gchar *key,
GKeyFile *keyfile)
{
GVariant *variant;
variant = g_settings_get_user_value (settings, key);
if (variant) {
gchar *tmp;
tmp = g_variant_print (variant, TRUE);
g_key_file_set_string (keyfile, group, key, tmp);
g_free (tmp);
g_variant_unref (variant);
}
return FALSE;
}
static gboolean
backup_settings (const gchar *to_filename,
GError **error)
{
GKeyFile *keyfile;
GString *filename;
gboolean success;
filename = replace_variables (to_filename, TRUE);
if (!filename) {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Failed to con
struct file name");
return FALSE;
}
keyfile = g_key_file_new ();
if (!settings_foreach_schema (backup_settings_foreach_cb, keyfile, error)
) {
g_string_free (filename, TRUE);
g_key_file_free (keyfile);
return FALSE;
}
success = g_key_file_save_to_file (keyfile, filename->str, error);
g_string_free (filename, TRUE);
g_key_file_free (keyfile);
return success;
}
static gboolean
restore_settings_foreach_cb (GSettings *settings,
GSettingsSchema *schema,
const gchar *group,
const gchar *key,
GKeyFile *keyfile)
{
gchar *value;
if (!g_settings_is_writable (settings, key))
return FALSE;
value = g_key_file_get_string (keyfile, group, key, NULL);
if (value) {
GVariant *variant;
variant = g_variant_parse (NULL, value, NULL, NULL, NULL);
if (variant) {
GSettingsSchemaKey *schema_key;
schema_key = g_settings_schema_get_key (schema, key);
if (g_settings_schema_key_range_check (schema_key, varian
t))
g_settings_set_value (settings, key, variant);
g_settings_schema_key_unref (schema_key);
g_variant_unref (variant);
}
g_free (value);
} else {
g_settings_reset (settings, key);
}
return TRUE;
}
static gboolean
restore_settings (const gchar *from_filename,
GError **error)
{
GKeyFile *keyfile;
GString *filename;
gboolean success;
filename = replace_variables (from_filename, TRUE);
if (!filename) {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Failed to con
struct file name");
return FALSE;
}
keyfile = g_key_file_new ();
if (!g_key_file_load_from_file (keyfile, filename->str, G_KEY_FILE_NONE,
error)) {
g_string_free (filename, TRUE);
g_key_file_free (keyfile);
return FALSE;
}
success = settings_foreach_schema (restore_settings_foreach_cb, keyfile,
error);
g_string_free (filename, TRUE);
g_key_file_free (keyfile);
return success;
}
static void static void
backup (const gchar *filename, backup (const gchar *filename,
GCancellable *cancellable) GCancellable *cancellable)
{ {
gchar *command; gchar *command;
gchar *quotedfname; gchar *quotedfname;
gboolean use_xz; gboolean use_xz;
GError *error = NULL;
g_return_if_fail (filename && *filename); g_return_if_fail (filename && *filename);
if (g_cancellable_is_cancelled (cancellable)) if (g_cancellable_is_cancelled (cancellable))
return; return;
txt = _("Shutting down Evolution"); txt = _("Shutting down Evolution");
/* FIXME Will the versioned setting always work? */ /* FIXME Will the versioned setting always work? */
run_cmd (EVOLUTION " --quit"); run_cmd (EVOLUTION " --quit");
run_cmd ("rm $CONFIGDIR/.running"); run_cmd ("rm $CONFIGDIR/.running");
if (g_cancellable_is_cancelled (cancellable)) if (g_cancellable_is_cancelled (cancellable))
return; return;
txt = _("Backing Evolution accounts and settings"); txt = _("Backing Evolution accounts and settings");
run_cmd ("dconf dump " DCONF_PATH_EDS " >" EVOLUTION_DIR DCONF_DUMP_FILE_ if (!backup_settings (EVOLUTION_DIR GSETTINGS_DUMP_FILE, &error)) {
EDS); g_warning ("Failed to backup settings: %s", error ? error->messag
run_cmd ("dconf dump " DCONF_PATH_EVO " >" EVOLUTION_DIR DCONF_DUMP_FILE_ e : "Unknown error");
EVO); g_clear_error (&error);
}
replace_in_file (
EVOLUTION_DIR DCONF_DUMP_FILE_EDS,
e_get_user_data_dir (), EVOUSERDATADIR_MAGIC);
replace_in_file ( replace_in_file (
EVOLUTION_DIR DCONF_DUMP_FILE_EVO, EVOLUTION_DIR GSETTINGS_DUMP_FILE,
e_get_user_data_dir (), EVOUSERDATADIR_MAGIC); e_get_user_data_dir (), EVOUSERDATADIR_MAGIC);
write_dir_file (); write_dir_file ();
if (g_cancellable_is_cancelled (cancellable)) if (g_cancellable_is_cancelled (cancellable))
return; return;
txt = _("Backing Evolution data (Mails, Contacts, Calendar, Tasks, Memos) "); txt = _("Backing Evolution data (Mails, Contacts, Calendar, Tasks, Memos) ");
quotedfname = g_shell_quote (filename); quotedfname = g_shell_quote (filename);
skipping to change at line 680 skipping to change at line 901
EVOUSERDATADIR_MAGIC, e_get_user_data_dir ()); EVOUSERDATADIR_MAGIC, e_get_user_data_dir ());
run_cmd ("gconftool-2 --load " EVOLUTION_DIR ANCIENT_GCON F_DUMP_FILE); run_cmd ("gconftool-2 --load " EVOLUTION_DIR ANCIENT_GCON F_DUMP_FILE);
/* give a chance to GConf to save what was loaded into a disk */ /* give a chance to GConf to save what was loaded into a disk */
g_usleep (G_USEC_PER_SEC * 5); g_usleep (G_USEC_PER_SEC * 5);
/* do not forget to convert GConf keys into GSettings */ /* do not forget to convert GConf keys into GSettings */
run_cmd ("gsettings-data-convert"); run_cmd ("gsettings-data-convert");
run_cmd ("rm " EVOLUTION_DIR ANCIENT_GCONF_DUMP_FILE); run_cmd ("rm " EVOLUTION_DIR ANCIENT_GCONF_DUMP_FILE);
} else { } else {
replace_in_file ( if (file)
EVOLUTION_DIR DCONF_DUMP_FILE_EDS, g_string_free (file, TRUE);
EVOUSERDATADIR_MAGIC, e_get_user_data_dir ());
run_cmd ("cat " EVOLUTION_DIR DCONF_DUMP_FILE_EDS " | dco
nf load " DCONF_PATH_EDS);
run_cmd ("rm " EVOLUTION_DIR DCONF_DUMP_FILE_EDS);
replace_in_file ( file = replace_variables (EVOLUTION_DIR ANCIENT_DCONF_DUM
EVOLUTION_DIR DCONF_DUMP_FILE_EVO, P_FILE_EDS, TRUE);
EVOUSERDATADIR_MAGIC, e_get_user_data_dir ());
run_cmd ("cat " EVOLUTION_DIR DCONF_DUMP_FILE_EVO " | dco if (file && g_file_test (file->str, G_FILE_TEST_EXISTS))
nf load " DCONF_PATH_EVO); {
run_cmd ("rm " EVOLUTION_DIR DCONF_DUMP_FILE_EVO); replace_in_file (
EVOLUTION_DIR ANCIENT_DCONF_DUMP_FILE_EDS
,
EVOUSERDATADIR_MAGIC, e_get_user_data_dir
());
run_cmd ("cat " EVOLUTION_DIR ANCIENT_DCONF_DUMP_
FILE_EDS " | dconf load " ANCIENT_DCONF_PATH_EDS);
run_cmd ("rm " EVOLUTION_DIR ANCIENT_DCONF_DUMP_F
ILE_EDS);
replace_in_file (
EVOLUTION_DIR ANCIENT_DCONF_DUMP_FILE_EVO
,
EVOUSERDATADIR_MAGIC, e_get_user_data_dir
());
run_cmd ("cat " EVOLUTION_DIR ANCIENT_DCONF_DUMP_
FILE_EVO " | dconf load " ANCIENT_DCONF_PATH_EVO);
run_cmd ("rm " EVOLUTION_DIR ANCIENT_DCONF_DUMP_F
ILE_EVO);
} else {
GError *error = NULL;
if (!restore_settings (EVOLUTION_DIR GSETTINGS_DU
MP_FILE, &error)) {
g_warning ("Failed to restore settings: %
s", error ? error->message : "Unknown error");
g_clear_error (&error);
}
run_cmd ("rm " EVOLUTION_DIR GSETTINGS_DUMP_FILE)
;
}
} }
g_string_free (file, TRUE); if (file)
g_string_free (file, TRUE);
} else { } else {
gchar *gconf_dump_file; gchar *gconf_dump_file;
unset_eds_migrated_flag (); unset_eds_migrated_flag ();
/* ... old format in ~/.evolution */ /* ... old format in ~/.evolution */
gconf_dump_file = g_build_filename ( gconf_dump_file = g_build_filename (
"$HOME", ".evolution", ANCIENT_GCONF_DUMP_FILE, NULL); "$HOME", ".evolution", ANCIENT_GCONF_DUMP_FILE, NULL);
replace_in_file ( replace_in_file (
 End of changes. 9 change blocks. 
26 lines changed or deleted 285 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)