[epiphany] ephy-profile-utils: split profile migration from EphyShell



commit 8c65eb746306499465f23057dbd4dea484c953aa
Author: Xan Lopez <xan igalia com>
Date:   Mon May 7 20:27:05 2012 +0200

    ephy-profile-utils: split profile migration from EphyShell
    
    Call it directly from main, since we want it to happen before the file
    helpers initialization.

 lib/ephy-profile-utils.c |   17 +++++++++++++++++
 lib/ephy-profile-utils.h |    2 ++
 src/ephy-main.c          |    4 ++++
 src/ephy-shell.c         |   20 --------------------
 4 files changed, 23 insertions(+), 20 deletions(-)
---
diff --git a/lib/ephy-profile-utils.c b/lib/ephy-profile-utils.c
index fe66b3b..a9edd72 100644
--- a/lib/ephy-profile-utils.c
+++ b/lib/ephy-profile-utils.c
@@ -186,3 +186,20 @@ _ephy_profile_utils_query_form_auth_data (const char *uri,
   soup_uri_free (key);
   g_free (key_str);
 }
+
+void
+ephy_profile_utils_do_migration ()
+{
+  GError *error = NULL;
+  char *argv[1] = { "ephy-profile-migrator" };
+  char *envp[1] = { "EPHY_LOG_MODULES=ephy-profile" };
+
+  g_spawn_sync (NULL, argv, envp, G_SPAWN_SEARCH_PATH,
+                NULL, NULL, NULL, NULL,
+                NULL, &error);
+    
+  if (error) {
+    LOG ("Failed to run migrator: %s", error->message);
+    g_error_free (error);
+  }
+}
diff --git a/lib/ephy-profile-utils.h b/lib/ephy-profile-utils.h
index 57837c6..353a560 100644
--- a/lib/ephy-profile-utils.h
+++ b/lib/ephy-profile-utils.h
@@ -32,6 +32,8 @@ int ephy_profile_utils_get_migration_version (void);
 
 gboolean ephy_profile_utils_set_migration_version (int version);
 
+void ephy_profile_utils_do_migration (void);
+
 void _ephy_profile_utils_store_form_auth_data (const char *uri,
                                                const char *form_username,
                                                const char *form_password,
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 5b3dad0..a9b71dd 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -387,6 +387,10 @@ main (int argc,
   /* Work-around Flash Player crash */
   g_setenv ("XLIB_SKIP_ARGB_VISUALS", "1", FALSE);
 
+  /* TODO: we want to migrate each WebApp profile too. */
+  if (!private_instance && !application_mode)
+    ephy_profile_utils_do_migration ();
+
   /* Start our services */
   if (!ephy_file_helpers_init (profile_directory,
                                private_instance || application_mode,
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 1823642..c8f3c27 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -37,7 +37,6 @@
 #include "ephy-lockdown.h"
 #include "ephy-prefs.h"
 #include "ephy-private.h"
-#include "ephy-profile-utils.h"
 #include "ephy-session.h"
 #include "ephy-settings.h"
 #include "ephy-type-builtins.h"
@@ -264,27 +263,8 @@ ephy_shell_startup (GApplication* application)
   G_APPLICATION_CLASS (ephy_shell_parent_class)->startup (application);
 
   /* We're not remoting; start our services */
-  /* Migrate profile if we are not running a private instance */
-  /* TODO: we want to migrate each WebApp profile too */
   mode = ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (application));
 
-  if (mode == EPHY_EMBED_SHELL_MODE_BROWSER) {
-    if (ephy_profile_utils_get_migration_version () < EPHY_PROFILE_MIGRATION_VERSION) {
-      GError *error = NULL;
-      char *argv[1] = { "ephy-profile-migrator" };
-      char *envp[1] = { "EPHY_LOG_MODULES=ephy-profile" };
-        
-      g_spawn_sync (NULL, argv, envp, G_SPAWN_SEARCH_PATH,
-                    NULL, NULL, NULL, NULL,
-                    NULL, &error);
-
-      if (error) {
-        LOG ("Failed to run migrator: %s", error->message);
-        g_error_free (error);
-      }
-    }
-  }
-
   if (mode != EPHY_EMBED_SHELL_MODE_APPLICATION) {
     GtkBuilder *builder;
 



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