[epiphany] profile-migrator: Remove ancient migrators



commit 2b1639434ae71df39c5318e4e6575388baab83a0
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Tue Oct 4 17:38:19 2016 -0500

    profile-migrator: Remove ancient migrators
    
    We really do not need to support migrating from Mozilla-based Epiphany
    anymore.

 src/profile-migrator/ephy-profile-migrator.c |  272 +-------------------------
 1 files changed, 4 insertions(+), 268 deletions(-)
---
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index 08890e4..96882b2 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -70,269 +70,6 @@ profile_dir_exists (void)
 }
 
 static void
-migrate_cookies (void)
-{
-  const char *cookies_file_sqlite = "cookies.sqlite";
-  const char *cookies_file_txt = "cookies.txt";
-  char *src_sqlite = NULL, *src_txt = NULL, *dest = NULL;
-
-  dest = g_build_filename (ephy_dot_dir (), cookies_file_sqlite, NULL);
-  /* If we already have a cookies.sqlite file, do nothing */
-  if (g_file_test (dest, G_FILE_TEST_EXISTS))
-    goto out;
-
-  src_sqlite = g_build_filename (ephy_dot_dir (), "mozilla",
-                                 "epiphany", cookies_file_sqlite, NULL);
-  src_txt = g_build_filename (ephy_dot_dir (), "mozilla",
-                              "epiphany", cookies_file_txt, NULL);
-
-  /* First check if we have a cookies.sqlite file in Mozilla */
-  if (g_file_test (src_sqlite, G_FILE_TEST_EXISTS)) {
-    GFile *gsrc, *gdest;
-
-    /* Copy the file */
-    gsrc = g_file_new_for_path (src_sqlite);
-    gdest = g_file_new_for_path (dest);
-
-    if (!g_file_copy (gsrc, gdest, 0, NULL, NULL, NULL, NULL))
-      g_warning (_("Failed to copy cookies file from Mozilla."));
-
-    g_object_unref (gsrc);
-    g_object_unref (gdest);
-  } else if (g_file_test (src_txt, G_FILE_TEST_EXISTS)) {
-    /* Create a SoupCookieJarSQLite with the contents of the txt file */
-    GSList *cookies, *p;
-    SoupCookieJar *txt, *sqlite;
-
-    txt = soup_cookie_jar_text_new (src_txt, TRUE);
-    sqlite = soup_cookie_jar_db_new (dest, FALSE);
-    cookies = soup_cookie_jar_all_cookies (txt);
-
-    for (p = cookies; p; p = p->next) {
-      SoupCookie *cookie = (SoupCookie *)p->data;
-      /* Cookie is stolen, so we won't free it */
-      soup_cookie_jar_add_cookie (sqlite, cookie);
-    }
-
-    g_slist_free (cookies);
-    g_object_unref (txt);
-    g_object_unref (sqlite);
-  }
-
- out:
-  g_free (src_sqlite);
-  g_free (src_txt);
-  g_free (dest);
-}
-
-/* History migration */
-
-static EphyHistoryService *history_service = NULL;
-static gboolean all_done = FALSE;
-
-typedef struct {
-  char *title;
-  char *location;
-  char *current;
-  long long int visit_count;
-  long long int last_visit;
-  long long int first_visit;
-  double zoom_level;
-  GList *visits;
-} HistoryParseData;
-
-static void
-history_parse_start_element (GMarkupParseContext *context,
-                             const char          *element_name,
-                             const char         **attribute_names,
-                             const char         **attribute_values,
-                             gpointer             user_data,
-                             GError             **error)
-{
-  HistoryParseData *parse_data = user_data;
-
-  if (g_str_equal (element_name, "node") && parse_data) {
-    /* Starting a new node, reset all values */
-    g_free (parse_data->title);
-    parse_data->title = NULL;
-
-    g_free (parse_data->location);
-    parse_data->location = NULL;
-
-    parse_data->visit_count = 0;
-    parse_data->last_visit = 0;
-    parse_data->first_visit = 0;
-    parse_data->zoom_level = 1.0;
-  } else if (g_str_equal (element_name, "property")) {
-    const char **name, **value;
-
-    for (name = attribute_names, value = attribute_values; *name; name++, value++) {
-      if (g_str_equal (*name, "id")) {
-        parse_data->current = g_strdup (*value);
-        break;
-      }
-    }
-  }
-}
-
-static void
-history_parse_text (GMarkupParseContext *context,
-                    const char          *text,
-                    gsize                text_len,
-                    gpointer             user_data,
-                    GError             **error)
-{
-  HistoryParseData *parse_data = user_data;
-
-  if (!parse_data || !parse_data->current)
-    return;
-
-  if (g_str_equal (parse_data->current, "2")) {
-    /* Title */
-    parse_data->title = g_strndup (text, text_len);
-  } else if (g_str_equal (parse_data->current, "3")) {
-    /* Location */
-    parse_data->location = g_strndup (text, text_len);
-  } else if (g_str_equal (parse_data->current, "4")) {
-    /* Visit count */
-    GString *data = g_string_new_len (text, text_len);
-    sscanf (data->str, "%lld", &parse_data->visit_count);
-    g_string_free (data, TRUE);
-  } else if (g_str_equal (parse_data->current, "5")) {
-    /* Last visit */
-    GString *data = g_string_new_len (text, text_len);
-    sscanf (data->str, "%lld", &parse_data->last_visit);
-    g_string_free (data, TRUE);
-  } else if (g_str_equal (parse_data->current, "6")) {
-    /* First visit */
-    GString *data = g_string_new_len (text, text_len);
-    sscanf (data->str, "%lld", &parse_data->first_visit);
-    g_string_free (data, TRUE);
-  } else if (g_str_equal (parse_data->current, "10")) {
-    /* Zoom level. */
-    GString *data = g_string_new_len (text, text_len);
-    sscanf (data->str, "%lf", &parse_data->zoom_level);
-    g_string_free (data, TRUE);
-  }
-
-  g_free (parse_data->current);
-  parse_data->current = NULL;
-}
-
-static void
-visit_cb (EphyHistoryService *service, gboolean success, gpointer result, gpointer user_data)
-{
-  all_done = TRUE;
-}
-
-static void
-history_parse_end_element (GMarkupParseContext *context,
-                           const char          *element_name,
-                           gpointer             user_data,
-                           GError             **error)
-{
-  HistoryParseData *parse_data = user_data;
-
-  if (g_str_equal (element_name, "node") && parse_data) {
-    /* Add one item to History */
-    EphyHistoryPageVisit *visit = ephy_history_page_visit_new (parse_data->location ? parse_data->location : 
"",
-                                                               parse_data->last_visit, 
EPHY_PAGE_VISIT_TYPED);
-    g_free (visit->url->title);
-    visit->url->title = g_strdup (parse_data->title);
-
-    if (parse_data->zoom_level != 1.0) {
-      /* Zoom levels are only stored per host in the old history, so
-       * creating a new host here is OK. */
-      g_assert (!visit->url->host);
-      visit->url->host = ephy_history_host_new (parse_data->location, parse_data->title,
-                                                parse_data->visit_count, parse_data->zoom_level);
-    }
-
-    parse_data->visits = g_list_append (parse_data->visits, visit);
-  }
-}
-
-static GMarkupParser history_parse_funcs =
-{
-  history_parse_start_element,
-  history_parse_end_element,
-  history_parse_text,
-  NULL,
-  NULL,
-};
-
-static void
-migrate_history (void)
-{
-  GFileInputStream *input;
-  GMarkupParseContext *context;
-  GError *error = NULL;
-  GFile *file;
-  char *filename;
-  char buffer[1024];
-  HistoryParseData parse_data;
-
-  gchar *temporary_file = g_build_filename (ephy_dot_dir (), EPHY_HISTORY_FILE, NULL);
-  /* Do nothing if the history file already exists. Safer than wiping
-   * it out. */
-  if (g_file_test (temporary_file, G_FILE_TEST_EXISTS)) {
-    g_warning ("Did not migrate history, the %s file already exists", EPHY_HISTORY_FILE);
-    g_free (temporary_file);
-    return;
-  }
-
-  history_service = ephy_history_service_new (temporary_file, FALSE);
-  g_free (temporary_file);
-
-  memset (&parse_data, 0, sizeof (HistoryParseData));
-  parse_data.location = NULL;
-  parse_data.title = NULL;
-  parse_data.visits = NULL;
-
-  filename = g_build_filename (ephy_dot_dir (),
-                               "ephy-history.xml",
-                               NULL);
-
-  file = g_file_new_for_path (filename);
-  g_free (filename);
-
-  input = g_file_read (file, NULL, &error);
-  g_object_unref (file);
-
-  if (error) {
-    if (error->code != G_IO_ERROR_NOT_FOUND)
-      g_warning ("Could not load history data, migration aborted: %s", error->message);
-
-    g_error_free (error);
-    return;
-  }
-
-  context = g_markup_parse_context_new (&history_parse_funcs, 0, &parse_data, NULL);
-  while (TRUE) {
-    gssize count = g_input_stream_read (G_INPUT_STREAM (input), buffer, sizeof (buffer), NULL, &error);
-    if (count <= 0)
-      break;
-
-    if (!g_markup_parse_context_parse (context, buffer, count, &error))
-      break;
-  }
-
-  g_markup_parse_context_free (context);
-  g_input_stream_close (G_INPUT_STREAM (input), NULL, NULL);
-  g_object_unref (input);
-
-  if (parse_data.visits) {
-    ephy_history_service_add_visits (history_service, parse_data.visits, NULL, 
(EphyHistoryJobCallback)visit_cb, NULL);
-    ephy_history_page_visit_list_free (parse_data.visits);
-
-    while (!all_done)
-      g_main_context_iteration (NULL, FALSE);
-  }
-
-  g_object_unref (history_service);
-}
-
-static void
 migrate_tabs_visibility (void)
 {
   gboolean always_show_tabs;
@@ -866,9 +603,8 @@ migrate_bookmarks (void)
 static void
 migrate_nothing (void)
 {
-  /* Used to replace migrators that have been removed. E.g. we used to have
-   * three password migrators that depended on NSS, but supporting ancient
-   * user profiles from almost a decade ago is not worth depending on NSS.
+  /* Used to replace migrators that have been removed. Only remove migrators
+   * that support particularly ancient versions of Epiphany.
    *
    * Note that you cannot simply remove a migrator from the migrators struct,
    * as that would mess up tracking of which migrators have been run.
@@ -876,11 +612,11 @@ migrate_nothing (void)
 }
 
 const EphyProfileMigrator migrators[] = {
-  migrate_cookies,
   migrate_nothing,
   migrate_nothing,
   migrate_nothing,
-  migrate_history,
+  migrate_nothing,
+  migrate_nothing,
   migrate_tabs_visibility,
   migrate_web_app_links,
   migrate_new_urls_table,


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