[epiphany] profile-migrator: Delete old migrators 7,8,9



commit a9bc73b793792921100205a41c942fd99649f15f
Author: Gabriel Ivascu <gabrielivascu gnome org>
Date:   Fri Sep 22 23:32:30 2017 +0300

    profile-migrator: Delete old migrators 7,8,9

 src/profile-migrator/ephy-profile-migrator.c |  273 +-------------------------
 1 files changed, 3 insertions(+), 270 deletions(-)
---
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index cfc6e3b..62a3f19 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -61,7 +61,6 @@
 static int do_step_n = -1;
 static int migration_version = -1;
 static char *profile_dir = NULL;
-static GMainLoop *loop = NULL;
 
 /*
  * What to do to add new migration steps:
@@ -77,272 +76,6 @@ profile_dir_exists (void)
   return g_file_test (ephy_dot_dir (), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR);
 }
 
-static char *
-fix_desktop_file_and_return_new_location (const char *dir)
-{
-  GRegex *regex;
-  char *result, *old_profile_dir, *replacement, *contents, *new_contents;
-  gsize length;
-
-  old_profile_dir = g_build_filename (g_get_home_dir (),
-                                      ".gnome2",
-                                      NULL);
-  replacement = g_build_filename (g_get_user_config_dir (),
-                                  NULL);
-  regex = g_regex_new (old_profile_dir, 0, 0, NULL);
-
-  /* We want to modify both the link destination and the contents of
-   * the .desktop file itself. */
-  result = g_regex_replace (regex, dir, -1,
-                            0, replacement, 0, NULL);
-  g_file_get_contents (result, &contents, &length, NULL);
-  new_contents = g_regex_replace (regex, contents, -1, 0,
-                                  replacement, 0, NULL);
-  g_file_set_contents (result, new_contents, length, NULL);
-
-  g_free (contents);
-  g_free (new_contents);
-  g_free (old_profile_dir);
-  g_free (replacement);
-
-  g_regex_unref (regex);
-
-  return result;
-}
-
-static void
-migrate_web_app_links (void)
-{
-  GList *apps, *p;
-
-  apps = ephy_web_application_get_application_list ();
-  for (p = apps; p; p = p->next) {
-    char *desktop_file, *app_link;
-    EphyWebApplication *app = (EphyWebApplication *)p->data;
-
-    desktop_file = app->desktop_file;
-
-    /* Update the link in applications. */
-    app_link = g_build_filename (g_get_user_data_dir (), "applications", desktop_file, NULL);
-    if (g_file_test (app_link, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_SYMLINK)) {
-      /* Change the link to point to the new profile dir. */
-      GFileInfo *info;
-      const char *target;
-      GFile *file = g_file_new_for_path (app_link);
-
-      info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
-                                0, NULL, NULL);
-      if (info) {
-        char *new_target;
-
-        target = g_file_info_get_symlink_target (info);
-        new_target = fix_desktop_file_and_return_new_location (target);
-
-        /* FIXME: Updating the file info and setting it again should
-         * work, but it does not? Just delete and create the link
-         * again. */
-        g_file_delete (file, 0, 0);
-        g_object_unref (file);
-
-        file = g_file_new_for_path (app_link);
-        g_file_make_symbolic_link (file, new_target, NULL, NULL);
-
-        g_object_unref (info);
-        g_free (new_target);
-      }
-
-      g_object_unref (file);
-    }
-
-    g_free (app_link);
-  }
-
-  ephy_web_application_free_application_list (apps);
-}
-
-static void
-migrate_new_urls_table (void)
-{
-  EphySQLiteConnection *history_database;
-  char *filename;
-  GError *error = NULL;
-
-  filename = g_build_filename (ephy_dot_dir (), EPHY_HISTORY_FILE, NULL);
-  if (!g_file_test (filename, G_FILE_TEST_EXISTS))
-    return;
-
-  history_database = ephy_sqlite_connection_new (EPHY_SQLITE_CONNECTION_MODE_READWRITE);
-  ephy_sqlite_connection_open (history_database, filename, &error);
-
-  if (error) {
-    g_warning ("Failed to open history database: %s", error->message);
-    g_error_free (error);
-    g_free (filename);
-    return;
-  }
-
-  ephy_sqlite_connection_execute (history_database,
-                                  "ALTER TABLE urls "
-                                  "ADD COLUMN thumbnail_update_time INTEGER DEFAULT 0",
-                                  &error);
-  if (error) {
-    g_warning ("Failed to add new column to table in history backend: %s",
-               error->message);
-    g_error_free (error);
-    error = NULL;
-  }
-  ephy_sqlite_connection_execute (history_database,
-                                  "ALTER TABLE urls "
-                                  "ADD COLUMN hidden_from_overview INTEGER DEFAULT 0",
-                                  &error);
-  if (error) {
-    g_warning ("Failed to add new column to table in history backend: %s",
-               error->message);
-    g_error_free (error);
-    error = NULL;
-  }
-
-  g_object_unref (history_database);
-  g_free (filename);
-}
-
-/* Migrating form password data. */
-
-static int form_passwords_migrating = 0;
-
-
-static void
-password_cleared_cb (SecretService *service,
-                     GAsyncResult  *res,
-                     gpointer       userdata)
-{
-  secret_service_clear_finish (service, res, NULL);
-
-  if (g_atomic_int_dec_and_test (&form_passwords_migrating))
-    g_main_loop_quit (loop);
-}
-
-static void
-store_form_auth_data_cb (GObject      *object,
-                         GAsyncResult *res,
-                         GHashTable   *attributes)
-{
-  GError *error = NULL;
-
-  if (ephy_password_manager_store_finish (res, &error) == FALSE) {
-    g_warning ("Couldn't store a form password: %s", error->message);
-    g_error_free (error);
-    goto out;
-  }
-
-  g_atomic_int_inc (&form_passwords_migrating);
-  secret_service_clear (NULL, NULL,
-                        attributes, NULL, (GAsyncReadyCallback)password_cleared_cb,
-                        NULL);
-
- out:
-  if (g_atomic_int_dec_and_test (&form_passwords_migrating))
-    g_main_loop_quit (loop);
-
-  g_hash_table_unref (attributes);
-}
-
-static void
-load_collection_items_cb (SecretCollection *collection,
-                          GAsyncResult     *res,
-                          gpointer          data)
-{
-  SecretItem *item;
-  SecretValue *secret;
-  GList *l;
-  GHashTable *attributes, *t;
-  const char *server, *username, *username_field, *password_field, *password;
-  char *origin;
-  SoupURI *uri;
-  GError *error = NULL;
-  GList *items;
-
-  secret_collection_load_items_finish (collection, res, &error);
-
-  if (error) {
-    g_warning ("Couldn't retrieve form data: %s", error->message);
-    g_error_free (error);
-    return;
-  }
-  items = secret_collection_get_items (collection);
-
-  for (l = items; l; l = l->next) {
-    item = (SecretItem *)l->data;
-
-    attributes = secret_item_get_attributes (item);
-    server = g_hash_table_lookup (attributes, "server");
-    if (server &&
-        g_strstr_len (server, -1, "form%5Fusername") &&
-        g_strstr_len (server, -1, "form%5Fpassword")) {
-      g_atomic_int_inc (&form_passwords_migrating);
-      /* This is one of the hackish ones that need to be migrated.
-         Fetch the rest of the data and take care of it. */
-      username = g_hash_table_lookup (attributes, "user");
-      uri = soup_uri_new (server);
-      t = soup_form_decode (uri->query);
-      username_field = g_hash_table_lookup (t, USERNAME_FIELD_KEY);
-      password_field = g_hash_table_lookup (t, PASSWORD_FIELD_KEY);
-      soup_uri_set_query (uri, NULL);
-      origin = soup_uri_to_string (uri, FALSE);
-      secret_item_load_secret_sync (item, NULL, NULL);
-      secret = secret_item_get_secret (item);
-      password = secret_value_get (secret, NULL);
-      ephy_password_manager_store_raw (origin,
-                                       username,
-                                       password,
-                                       username_field,
-                                       password_field,
-                                       (GAsyncReadyCallback)store_form_auth_data_cb,
-                                       g_hash_table_ref (attributes));
-      g_free (origin);
-      secret_value_unref (secret);
-      g_hash_table_unref (t);
-      soup_uri_free (uri);
-    }
-    g_hash_table_unref (attributes);
-  }
-
-  /* And decrease here so that we finish eventually. */
-  if (g_atomic_int_dec_and_test (&form_passwords_migrating))
-    g_main_loop_quit (loop);
-
-  g_list_free_full (items, (GDestroyNotify)g_object_unref);
-}
-
-static void
-migrate_form_passwords_to_libsecret (void)
-{
-  SecretService *service;
-  GList *collections, *c;
-  GError *error = NULL;
-
-  service = secret_service_get_sync (SECRET_SERVICE_OPEN_SESSION | SECRET_SERVICE_LOAD_COLLECTIONS, NULL, 
&error);
-  if (error) {
-    g_warning ("Could not get the secret service: %s", error->message);
-    g_error_free (error);
-    return;
-  }
-
-  collections = secret_service_get_collections (service);
-
-  for (c = collections; c; c = c->next) {
-    g_atomic_int_inc (&form_passwords_migrating);
-    secret_collection_load_items ((SecretCollection *)c->data, NULL, 
(GAsyncReadyCallback)load_collection_items_cb,
-                                  NULL);
-  }
-
-  loop = g_main_loop_new (NULL, FALSE);
-  g_main_loop_run (loop);
-
-  g_list_free_full (collections, (GDestroyNotify)g_object_unref);
-  g_object_unref (service);
-}
-
 static void
 migrate_app_desktop_file_categories (void)
 {
@@ -1161,9 +894,9 @@ const EphyProfileMigrator migrators[] = {
   /*  4 */ migrate_nothing,
   /*  5 */ migrate_nothing,
   /*  6 */ migrate_nothing,
-  /*  7 */ migrate_web_app_links,
-  /*  8 */ migrate_new_urls_table,
-  /*  9 */ migrate_form_passwords_to_libsecret,
+  /*  7 */ migrate_nothing,
+  /*  8 */ migrate_nothing,
+  /*  9 */ migrate_nothing,
   /* 10 */ migrate_app_desktop_file_categories,
   /* 11 */ migrate_insecure_passwords,
   /* 12 */ migrate_bookmarks,


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