[epiphany/gnome-3-26] Fix location of sync settings and add a migrator



commit 8c69aeacdca62134b5a2522a72ef8ff914049e90
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Wed Nov 1 14:23:05 2017 -0500

    Fix location of sync settings and add a migrator
    
    Unfortunately we have to keep the old schema around indefinitely, to
    not break migrations.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=789786

 data/org.gnome.epiphany.gschema.xml          |   89 +++++++++++++++++++++++++-
 lib/ephy-profile-utils.h                     |    2 +-
 src/profile-migrator/ephy-profile-migrator.c |   55 ++++++++++++++++
 3 files changed, 144 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index fa09bfc..176fe8a 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -271,7 +271,7 @@
                        <default>false</default>
                </key>
        </schema>
-       <schema path="/org/gnome/Epiphany/sync/" id="org.gnome.Epiphany.sync">
+       <schema path="/org/gnome/epiphany/sync/" id="org.gnome.Epiphany.sync">
                <key type="s" name="sync-user">
                        <default>''</default>
                        <summary>Currently signed in sync user</summary>
@@ -358,6 +358,93 @@
                        <description>The timestamp at which last open tabs sync was made.</description>
                </key>
        </schema>
+       <schema path="/org/gnome/Epiphany/sync/" id="org.gnome.Epiphany.sync.DEPRECATED">
+               <key type="s" name="sync-user">
+                       <default>''</default>
+                       <summary>Currently signed in sync user</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="x" name="sync-time">
+                       <default>0</default>
+                       <summary>Last sync timestamp</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="s" name="sync-device-id">
+                       <default>''</default>
+                       <summary>Sync device ID</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="s" name="sync-device-name">
+                       <default>''</default>
+                       <summary>Sync device name</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="u" name="sync-frequency">
+                       <default>30</default>
+                       <summary>The sync frequency in minutes</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="b" name="sync-with-firefox">
+                       <default>true</default>
+                       <summary>Sync data with Firefox</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="b" name="sync-bookmarks-enabled">
+                       <default>false</default>
+                       <summary>Enable bookmarks sync</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="d" name="sync-bookmarks-time">
+                       <default>0</default>
+                       <summary>Bookmarks sync timestamp</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="b" name="sync-bookmarks-initial">
+                       <default>true</default>
+                       <summary>Initial sync or normal sync</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="b" name="sync-passwords-enabled">
+                       <default>false</default>
+                       <summary>Enable passwords sync</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="d" name="sync-passwords-time">
+                       <default>0</default>
+                       <summary>Passwords sync timestamp</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="b" name="sync-passwords-initial">
+                       <default>true</default>
+                       <summary>Initial sync or normal sync</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="b" name="sync-history-enabled">
+                       <default>false</default>
+                       <summary>Enable history sync</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="d" name="sync-history-time">
+                       <default>0</default>
+                       <summary>History sync timestamp</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="b" name="sync-history-initial">
+                       <default>true</default>
+                       <summary>Initial sync or normal sync</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="b" name="sync-open-tabs-enabled">
+                       <default>false</default>
+                       <summary>Enable open tabs sync</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+               <key type="d" name="sync-open-tabs-time">
+                       <default>0</default>
+                       <summary>Open tabs sync timestamp</summary>
+                       <description>DEPRECATED: This key is deprecated and ignored. Use 
/org/gnome/epiphany/sync/ instead.</description>
+               </key>
+       </schema>
        <enum id="org.gnome.Epiphany.Permission">
                <value nick="undecided" value="-1"/>
                <value nick="deny" value="0"/>
diff --git a/lib/ephy-profile-utils.h b/lib/ephy-profile-utils.h
index 54d6487..7715d52 100644
--- a/lib/ephy-profile-utils.h
+++ b/lib/ephy-profile-utils.h
@@ -24,7 +24,7 @@
 
 G_BEGIN_DECLS
 
-#define EPHY_PROFILE_MIGRATION_VERSION 21
+#define EPHY_PROFILE_MIGRATION_VERSION 22
 #define EPHY_INSECURE_PASSWORDS_MIGRATION_VERSION 11
 #define EPHY_SETTINGS_MIGRATION_VERSION 16
 #define EPHY_FIREFOX_SYNC_PASSWORDS_MIGRATION_VERSION 19
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index a408d6a..f70b70d 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -1197,6 +1197,60 @@ out:
   g_list_free_full (passwords, g_object_unref);
 }
 
+static const char * const old_sync_settings[] = {
+    EPHY_PREFS_SYNC_USER,
+    EPHY_PREFS_SYNC_TIME,
+    EPHY_PREFS_SYNC_DEVICE_ID,
+    EPHY_PREFS_SYNC_DEVICE_NAME,
+    EPHY_PREFS_SYNC_FREQUENCY,
+    EPHY_PREFS_SYNC_WITH_FIREFOX,
+    EPHY_PREFS_SYNC_BOOKMARKS_ENABLED,
+    EPHY_PREFS_SYNC_BOOKMARKS_TIME,
+    EPHY_PREFS_SYNC_BOOKMARKS_INITIAL,
+    EPHY_PREFS_SYNC_PASSWORDS_ENABLED,
+    EPHY_PREFS_SYNC_PASSWORDS_TIME,
+    EPHY_PREFS_SYNC_PASSWORDS_INITIAL,
+    EPHY_PREFS_SYNC_HISTORY_ENABLED,
+    EPHY_PREFS_SYNC_HISTORY_TIME,
+    EPHY_PREFS_SYNC_HISTORY_INITIAL,
+    EPHY_PREFS_SYNC_OPEN_TABS_ENABLED,
+    EPHY_PREFS_SYNC_OPEN_TABS_TIME
+};
+
+static void
+migrate_sync_settings_path (void)
+{
+  GSettings *deprecated_settings = ephy_settings_get ("org.gnome.Epiphany.sync.DEPRECATED");
+
+  /* Sync settings are only used in browser mode, so no need to migrate if we
+   * are not in browser mode. */
+  if (!ephy_dot_dir_is_default ())
+    return;
+
+  for (guint i = 0; i < G_N_ELEMENTS (old_sync_settings); i++) {
+    GVariant *user_value;
+
+    /* Has the setting been changed from its default? */
+    user_value = g_settings_get_user_value (deprecated_settings, old_sync_settings[i]);
+
+    if (user_value != NULL) {
+      GVariant *value;
+
+      value = g_settings_get_value (deprecated_settings, old_sync_settings[i]);
+      g_settings_set_value (EPHY_SETTINGS_SYNC, old_sync_settings[i], value);
+
+      /* We do not want to ever run this migration again, to avoid writing old
+       * values over new ones. So be cautious and reset the old settings. */
+      g_settings_reset (deprecated_settings, old_sync_settings[i]);
+
+      g_variant_unref (value);
+      g_variant_unref (user_value);
+    }
+  }
+
+  g_settings_sync ();
+}
+
 static void
 migrate_nothing (void)
 {
@@ -1232,6 +1286,7 @@ const EphyProfileMigrator migrators[] = {
   /* 19 */ migrate_passwords_to_firefox_sync_passwords,
   /* 20 */ migrate_history_to_firefox_sync_history,
   /* 21 */ migrate_passwords_add_target_origin,
+  /* 22 */ migrate_sync_settings_path
 };
 
 static gboolean


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