[Evolution-hackers] startup order for upgrade




There are a bunch of bugs aggravated/harder to fix because of the
migration startup order, e.g. 53084, 52965, and no doubt others.

This patch changes the shell so the upgrade is part of the same code
that does the wizard startup, so things can be done in a more logical
order.

Anyway, before i do more work (a lot of stuff is still required in the
mailer for this change to have any effect), does this break anything
else?

 Michael

Index: shell/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/shell/ChangeLog,v
retrieving revision 1.1375
diff -u -3 -r1.1375 ChangeLog
--- shell/ChangeLog	15 Jan 2004 17:07:58 -0000	1.1375
+++ shell/ChangeLog	21 Jan 2004 06:33:09 -0000
@@ -1,3 +1,11 @@
+2004-01-21  Not Zed  <NotZed Ximian com>
+
+	* e-shell.c (attempt_upgrade, detect_version, e_shell_construct):
+	attempt the upgrade before trying to startup the wizard.
+
+	* main.c (detect_version, attempt_upgrade): move to e-shell.c
+	(idle_cb): remove call to attempt_upgrade.
+
 2004-01-15  JP Rosevear <jpr ximian com>
 
 	* e-config-upgrade.c: remove calendar and task keys for upgrade,
Index: shell/e-shell.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell.c,v
retrieving revision 1.234
diff -u -3 -r1.234 e-shell.c
--- shell/e-shell.c	13 Jan 2004 18:51:54 -0000	1.234
+++ shell/e-shell.c	21 Jan 2004 06:33:13 -0000
@@ -27,6 +27,7 @@
 #include "e-shell.h"
 
 #include "e-util/e-dialog-utils.h"
+#include "e-util/e-bconf-map.h"
 
 #include "e-shell-constants.h"
 #include "e-shell-offline-handler.h"
@@ -461,6 +462,77 @@
 	shell->priv = priv;
 }
 
+static gboolean
+detect_version (GConfClient *gconf, int *major, int *minor, int *revision)
+{
+	char *val, *evolution_dir, *filename;
+	struct stat st;
+	
+	evolution_dir = g_build_filename (g_get_home_dir (), "evolution", NULL);
+	filename = g_build_filename (evolution_dir, "config.xmldb", NULL);
+	
+	val = gconf_client_get_string(gconf, "/apps/evolution/version", NULL);	
+	if (val) {
+		/* Since 1.4.0 We've been keeping the version key in gconf */
+		sscanf(val, "%u.%u.%u", major, minor, revision);
+		g_free(val);
+	} else if (lstat (filename, &st) != 0 || !S_ISDIR (st.st_mode)) {
+		/* If ~/evolution does not exit or is not a directory it must be a new installation */
+		*major = 0;
+		*minor = 0;
+		*revision = 0;
+	} else {
+		xmlDocPtr config_doc = NULL;
+		xmlNodePtr source;
+		char *tmp;
+		
+		if (lstat(filename, &st) == 0
+		    && S_ISREG(st.st_mode))
+			config_doc = xmlParseFile (filename);
+
+		tmp = NULL;
+		if (config_doc
+		    && (source = e_bconf_get_path (config_doc, "/Shell"))
+		    && (tmp = e_bconf_get_value (source, "upgrade_from_1_0_to_1_2_performed"))
+		    && tmp[0] == '1' ) {
+			*major = 1;
+			*minor = 2;
+			*revision = 0;
+		} else {
+			*major = 1;
+			*minor = 0;
+			*revision = 0;
+		}
+		if (tmp)
+			xmlFree(tmp);
+		if (config_doc)
+			xmlFreeDoc (config_doc);		
+	}
+
+	g_free (evolution_dir);
+	g_free (filename);
+
+	return TRUE;
+}
+
+static void
+attempt_upgrade (EShell *shell)
+{
+	GConfClient *gconf_client;
+	int major = 0, minor = 0, revision = 0;
+
+	gconf_client = gconf_client_get_default ();
+
+	if (!detect_version (gconf_client, &major, &minor, &revision)
+	    || !e_shell_attempt_upgrade (shell, major, minor, revision)) 
+		e_notice (NULL, GTK_MESSAGE_ERROR,
+			  _("Warning: Evolution could not upgrade all your data from version %d.%d.%d.\n"
+			    "The data hasn't been deleted, but it will not be seen by this version of Evolution.\n"),
+			  major, minor, revision);
+
+	gconf_client_set_string (gconf_client, "/apps/evolution/version", VERSION, NULL);
+	g_object_unref (gconf_client);
+}
 
 /**
  * e_shell_construct:
@@ -505,7 +577,9 @@
 	
 	if (splash)
 		gtk_widget_destroy (splash);
-	
+
+	attempt_upgrade(shell);
+
 	if (e_shell_startup_wizard_create () == FALSE) {
 		bonobo_object_unref (BONOBO_OBJECT (shell));
 		exit (0);
Index: shell/main.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/main.c,v
retrieving revision 1.141
diff -u -3 -r1.141 main.c
--- shell/main.c	15 Jan 2004 16:02:40 -0000	1.141
+++ shell/main.c	21 Jan 2004 06:33:15 -0000
@@ -344,79 +344,6 @@
 
 #endif /* DEVELOPMENT_WARNING */
 
-static gboolean
-detect_version (GConfClient *gconf, int *major, int *minor, int *revision)
-{
-	char *val, *evolution_dir, *filename;
-	struct stat st;
-	
-	evolution_dir = g_build_filename (g_get_home_dir (), "evolution", NULL);
-	filename = g_build_filename (evolution_dir, "config.xmldb", NULL);
-	
-	val = gconf_client_get_string(gconf, "/apps/evolution/version", NULL);	
-	if (val) {
-		/* Since 1.4.0 We've been keeping the version key in gconf */
-		sscanf(val, "%u.%u.%u", major, minor, revision);
-		g_free(val);
-	} else if (lstat (filename, &st) != 0 || !S_ISDIR (st.st_mode)) {
-		/* If ~/evolution does not exit or is not a directory it must be a new installation */
-		*major = 0;
-		*minor = 0;
-		*revision = 0;
-	} else {
-		xmlDocPtr config_doc = NULL;
-		xmlNodePtr source;
-		char *tmp;
-		
-		if (lstat(filename, &st) == 0
-		    && S_ISREG(st.st_mode))
-			config_doc = xmlParseFile (filename);
-
-		tmp = NULL;
-		if (config_doc
-		    && (source = e_bconf_get_path (config_doc, "/Shell"))
-		    && (tmp = e_bconf_get_value (source, "upgrade_from_1_0_to_1_2_performed"))
-		    && tmp[0] == '1' ) {
-			*major = 1;
-			*minor = 2;
-			*revision = 0;
-		} else {
-			*major = 1;
-			*minor = 0;
-			*revision = 0;
-		}
-		if (tmp)
-			xmlFree(tmp);
-		if (config_doc)
-			xmlFreeDoc (config_doc);		
-	}
-
-	g_free (evolution_dir);
-	g_free (filename);
-
-	return TRUE;
-}
-
-static void
-attempt_upgrade (EShell *shell)
-{
-	GConfClient *gconf_client;
-	int major = 0, minor = 0, revision = 0;
-
-	gconf_client = gconf_client_get_default ();
-
-	if (!detect_version (gconf_client, &major, &minor, &revision)
-	    || !e_shell_attempt_upgrade (shell, major, minor, revision)) 
-		e_notice (NULL, GTK_MESSAGE_ERROR,
-			  _("Warning: Evolution could not upgrade all your data from version %d.%d.%d.\n"
-			    "The data hasn't been deleted, but it will not be seen by this version of Evolution.\n"),
-			  major, minor, revision);
-
-	gconf_client_set_string (gconf_client, "/apps/evolution/version", VERSION, NULL);
-	g_object_unref (gconf_client);
-}
-
-
 /* This is for doing stuff that requires the GTK+ loop to be running already.  */
 
 static gint
@@ -483,9 +410,6 @@
 
 	}
 
-	if (shell != NULL)
-		attempt_upgrade (shell);
-
 	have_evolution_uri = FALSE;
 
 	if (shell != NULL) {


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