[epiphany/wip/sync] profile-migrator: Migrate passwords to Firefox Sync passwords



commit 8a51d1a0d9876d2529dff1467781b540bb8676c5
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date:   Wed May 3 22:42:42 2017 +0300

    profile-migrator: Migrate passwords to Firefox Sync passwords

 lib/ephy-profile-utils.h                     |    2 +-
 src/profile-migrator/ephy-profile-migrator.c |   35 ++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/lib/ephy-profile-utils.h b/lib/ephy-profile-utils.h
index dd8943d..fd78c18 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 17
+#define EPHY_PROFILE_MIGRATION_VERSION 18
 #define EPHY_INSECURE_PASSWORDS_MIGRATION_VERSION 11
 #define EPHY_SETTINGS_MIGRATION_VERSION 16
 
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index 42a65c3..14a0f73 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -975,6 +975,40 @@ migrate_search_engines (void)
 }
 
 static void
+migrate_passwords_to_firefox_sync_passwords_cb (GSList   *records,
+                                                gpointer  user_data)
+{
+  EphyPasswordManager *manager = EPHY_PASSWORD_MANAGER (user_data);
+
+  ephy_password_manager_forget_all (manager);
+
+  for (GSList *l = records; l && l->data; l = l->next) {
+    ephy_password_manager_save (manager,
+                                ephy_password_record_get_hostname (l->data),
+                                ephy_password_record_get_username (l->data),
+                                ephy_password_record_get_password (l->data),
+                                ephy_password_record_get_username_field (l->data),
+                                ephy_password_record_get_password_field (l->data),
+                                TRUE);
+  }
+
+  g_slist_free_full (records, g_object_unref);
+}
+
+static void
+migrate_passwords_to_firefox_sync_passwords (void)
+{
+  EphyPasswordManager *manager = ephy_password_manager_new ();
+
+  ephy_password_manager_query (manager,
+                               NULL, NULL, NULL, NULL,
+                               migrate_passwords_to_firefox_sync_passwords_cb,
+                               manager);
+
+  g_object_unref (manager);
+}
+
+static void
 migrate_nothing (void)
 {
   /* Used to replace migrators that have been removed. Only remove migrators
@@ -1005,6 +1039,7 @@ const EphyProfileMigrator migrators[] = {
   /* 15 */ migrate_permissions,
   /* 16 */ migrate_settings,
   /* 17 */ migrate_search_engines,
+  /* 18 */ migrate_passwords_to_firefox_sync_passwords,
 };
 
 static gboolean


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