aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2004-01-14 02:51:54 +0800
committerJP Rosevear <jpr@src.gnome.org>2004-01-14 02:51:54 +0800
commitf17f36a31ed398d797cf96a9029efaaf83485f43 (patch)
tree161eef5dfb4069fae3bfbf796cc9b6b4432bf065
parent39e6fc90623f50b7cd28850b8a0463d37e09a758 (diff)
downloadgsoc2013-evolution-f17f36a31ed398d797cf96a9029efaaf83485f43.tar
gsoc2013-evolution-f17f36a31ed398d797cf96a9029efaaf83485f43.tar.gz
gsoc2013-evolution-f17f36a31ed398d797cf96a9029efaaf83485f43.tar.bz2
gsoc2013-evolution-f17f36a31ed398d797cf96a9029efaaf83485f43.tar.lz
gsoc2013-evolution-f17f36a31ed398d797cf96a9029efaaf83485f43.tar.xz
gsoc2013-evolution-f17f36a31ed398d797cf96a9029efaaf83485f43.tar.zst
gsoc2013-evolution-f17f36a31ed398d797cf96a9029efaaf83485f43.zip
detect the version more completely with the new util routine (main): don't
2004-01-13 JP Rosevear <jpr@ximian.com> * main.c (attempt_upgrade): detect the version more completely with the new util routine (main): don't upgrade the config db here * e-shell.h: update proto * e-shell.c (e_shell_attempt_upgrade): take the current version as numerical params * e-config-upgrade.h: update prototypes * e-config-upgrade.c (e_config_upgrade): remove version detection and saving code (e_upgrade_detect_version): routine to do the version detection * e-config-upgrade.c: drop my-evolution upgrade code svn path=/trunk/; revision=24205
-rw-r--r--shell/ChangeLog19
-rw-r--r--shell/e-config-upgrade.c104
-rw-r--r--shell/e-config-upgrade.h4
-rw-r--r--shell/e-shell.c14
-rw-r--r--shell/e-shell.h4
-rw-r--r--shell/main.c22
6 files changed, 95 insertions, 72 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index e2b5a04071..b4a964efe5 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,22 @@
+2004-01-13 JP Rosevear <jpr@ximian.com>
+
+ * main.c (attempt_upgrade): detect the version more completely
+ with the new util routine
+ (main): don't upgrade the config db here
+
+ * e-shell.h: update proto
+
+ * e-shell.c (e_shell_attempt_upgrade): take the current version as
+ numerical params
+
+ * e-config-upgrade.h: update prototypes
+
+ * e-config-upgrade.c (e_config_upgrade): remove version detection
+ and saving code
+ (e_upgrade_detect_version): routine to do the version detection
+
+ * e-config-upgrade.c: drop my-evolution upgrade code
+
2004-01-12 JP Rosevear <jpr@ximian.com>
* Makefile.am: use our libs
diff --git a/shell/e-config-upgrade.c b/shell/e-config-upgrade.c
index cb5a08e89f..34331987ab 100644
--- a/shell/e-config-upgrade.c
+++ b/shell/e-config-upgrade.c
@@ -1777,48 +1777,12 @@ static int load_accounts_1_0(xmlDocPtr doc)
* Return value: -1 on an error.
**/
int
-e_config_upgrade(const char *edir)
+e_config_upgrade(int major, int minor, int revision)
{
- xmlNodePtr source;
xmlDocPtr config_doc = NULL;
int i;
- char *val, *tmp;
GConfClient *gconf;
int res = -1;
- struct stat st;
-
- evolution_dir = edir;
-
- /* 1. determine existing version */
- gconf = gconf_client_get_default();
- val = gconf_client_get_string(gconf, "/apps/evolution/version", NULL);
- if (val) {
- sscanf(val, "%u.%u.%u", &major, &minor, &revision);
- g_free(val);
- } else {
- char *filename = g_build_filename(evolution_dir, "config.xmldb", NULL);
-
- if (lstat(filename, &st) == 0
- && S_ISREG(st.st_mode))
- config_doc = xmlParseFile (filename);
- g_free(filename);
-
- tmp = NULL;
- if ( config_doc
- && (source = lookup_bconf_path(config_doc, "/Shell"))
- && (tmp = lookup_bconf_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);
- }
/* 2. Now perform any upgrade duties */
@@ -1872,18 +1836,6 @@ e_config_upgrade(const char *edir)
}
}
- /* 3. we're done, update our version info if its changed */
- if (major < CONF_MAJOR
- || minor < CONF_MINOR
- || revision < CONF_REVISION) {
- val = g_strdup_printf("%u.%u.%u", CONF_MAJOR, CONF_MINOR, CONF_REVISION);
- gconf_client_set_string(gconf, "/apps/evolution/version", val, NULL);
- /* TODO: should this be translatable? */
- g_message("Evolution configuration upgraded to version: %s", val);
- g_free(val);
- gconf_client_suggest_sync(gconf, NULL);
- }
-
res = 0;
error:
@@ -1893,3 +1845,57 @@ error:
return res;
}
+gboolean
+e_upgrade_detect_version (int *major, int *minor, int *revision)
+{
+ GConfClient *gconf;
+ xmlNodePtr source;
+ xmlDocPtr config_doc = NULL;
+ char *val;
+ struct stat st;
+ char *evolution_dir = g_build_filename(g_get_home_dir (), "evolution", NULL);
+ char *filename = g_build_filename(evolution_dir, "config.xmldb", NULL);
+
+
+ gconf = gconf_client_get_default();
+ val = gconf_client_get_string(gconf, "/apps/evolution/version", NULL);
+ g_object_unref (gconf);
+
+ 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 {
+ char *filename = g_build_filename(g_get_home_dir (), "evolution", "config.xmldb", NULL);
+ char *tmp;
+
+ if (lstat(filename, &st) == 0
+ && S_ISREG(st.st_mode))
+ config_doc = xmlParseFile (filename);
+ g_free(filename);
+
+ tmp = NULL;
+ if ( config_doc
+ && (source = lookup_bconf_path(config_doc, "/Shell"))
+ && (tmp = lookup_bconf_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);
+ }
+
+ return TRUE;
+}
+
diff --git a/shell/e-config-upgrade.h b/shell/e-config-upgrade.h
index c012e30526..f52801ce07 100644
--- a/shell/e-config-upgrade.h
+++ b/shell/e-config-upgrade.h
@@ -23,6 +23,8 @@
#ifndef _E_CONFIG_UPGRADE_H
#define _E_CONFIG_UPGRADE_H
-int e_config_upgrade(const char *edir);
+gboolean e_upgrade_detect_version (int *major, int *minor, int *revision);
+
+int e_config_upgrade(int major, int minor, int revision);
#endif /* _E_CONFIG_UPGRADE_H */
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 22bfb1a9b3..fdc3bc024e 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -580,18 +580,14 @@ e_shell_new (EShellStartupLineMode startup_line_mode,
* upgrade from @from_version is unsupported).
**/
gboolean
-e_shell_attempt_upgrade (EShell *shell,
- const char *from_version)
+e_shell_attempt_upgrade (EShell *shell, int major, int minor, int revision)
{
GSList *component_infos, *p;
- int major, minor, revision;
int current_major, current_minor, current_revision;
gboolean success;
g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
- g_return_val_if_fail (from_version != NULL, FALSE);
- sscanf (from_version, "%u.%u.%u", &major, &minor, &revision);
sscanf (VERSION, "%u.%u.%u", &current_major, &current_minor, &current_revision);
if (! (current_major > major
@@ -623,16 +619,16 @@ e_shell_attempt_upgrade (EShell *shell,
}
exception_text = bonobo_exception_get_text (&ev);
- g_warning ("Upgrade of component \"%s\" from version %s failed with exception %s",
- info->alias, from_version, exception_text);
+ g_warning ("Upgrade of component \"%s\" from version %d.%d.%d failed with exception %s",
+ info->alias, major, minor, revision, exception_text);
g_free (exception_text);
CORBA_exception_free (&ev);
success = FALSE;
} else {
CORBA_exception_free (&ev);
if (! component_upgraded) {
- g_warning ("Component \"%s\" could not upgrade configuration from version \"%s\"",
- info->alias, from_version);
+ g_warning ("Component \"%s\" could not upgrade configuration from version %d.%d.%d",
+ info->alias, major, minor, revision);
success = FALSE;
}
}
diff --git a/shell/e-shell.h b/shell/e-shell.h
index b8922de39d..2dcac9fc6d 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -101,7 +101,9 @@ EShell *e_shell_new (EShellStartupLineMode startup_line_m
EShellConstructResult *construct_result_return);
gboolean e_shell_attempt_upgrade (EShell *shell,
- const char *from_version);
+ int major,
+ int minor,
+ int revision);
EShellWindow *e_shell_create_window (EShell *shell,
const char *component_id,
diff --git a/shell/main.c b/shell/main.c
index 6f56f6b4e9..5d7cebf635 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -338,21 +338,21 @@ new_window_created_callback (EShell *shell,
#endif /* DEVELOPMENT_WARNING */
-
static void
attempt_upgrade (EShell *shell)
{
- GConfClient *gconf_client = gconf_client_get_default ();
- char *previous_version = gconf_client_get_string (gconf_client, "/apps/evolution/version", NULL);
+ GConfClient *gconf_client;
+ int major = 0, minor = 0, revision = 0;
+
+ if (!e_upgrade_detect_version (&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);
- if (previous_version != NULL) {
- if (! e_shell_attempt_upgrade (shell, previous_version))
- e_notice (NULL, GTK_MESSAGE_ERROR,
- _("Warning: Evolution could not upgrade all your data from version %s.\n"
- "The data hasn't been deleted, but it will not be seen by this version of Evolution.\n"),
- previous_version);
- }
+ gconf_client = gconf_client_get_default ();
gconf_client_set_string (gconf_client, "/apps/evolution/version", VERSION, NULL);
g_object_unref (gconf_client);
}
@@ -612,8 +612,6 @@ main (int argc, char **argv)
uri_list = g_slist_reverse (uri_list);
g_value_unset (&popt_context_value);
- e_config_upgrade (evolution_directory);
-
g_idle_add (idle_cb, uri_list);
bonobo_main ();