aboutsummaryrefslogtreecommitdiffstats
path: root/shell/main.c
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2004-01-15 23:56:11 +0800
committerJP Rosevear <jpr@src.gnome.org>2004-01-15 23:56:11 +0800
commitbabacb9101cf739612cb8079f3dd936a53c5d63e (patch)
treeb80b00b503dbcd6bd14304d76bc351d5e083942f /shell/main.c
parentfbd28cca81f1f67342d94d956003ac09aa7f5b25 (diff)
downloadgsoc2013-evolution-babacb9101cf739612cb8079f3dd936a53c5d63e.tar
gsoc2013-evolution-babacb9101cf739612cb8079f3dd936a53c5d63e.tar.gz
gsoc2013-evolution-babacb9101cf739612cb8079f3dd936a53c5d63e.tar.bz2
gsoc2013-evolution-babacb9101cf739612cb8079f3dd936a53c5d63e.tar.lz
gsoc2013-evolution-babacb9101cf739612cb8079f3dd936a53c5d63e.tar.xz
gsoc2013-evolution-babacb9101cf739612cb8079f3dd936a53c5d63e.tar.zst
gsoc2013-evolution-babacb9101cf739612cb8079f3dd936a53c5d63e.zip
move version detection here
2004-01-15 JP Rosevear <jpr@ximian.com> * main.c (detect_version): move version detection here * e-config-upgrade.c: remove it from here; clean out all the mailer and bonobo conf conversion stuff, its been moved to the mailer and e-util * e-config-upgrade.h: remove proto svn path=/trunk/; revision=24242
Diffstat (limited to 'shell/main.c')
-rw-r--r--shell/main.c64
1 files changed, 61 insertions, 3 deletions
diff --git a/shell/main.c b/shell/main.c
index 5d7cebf635..6fc007c6e8 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -24,6 +24,7 @@
#include "e-util/e-dialog-utils.h"
#include "e-util/e-gtk-utils.h"
+#include "e-util/e-bconf-map.h"
#include "e-icon-factory.h"
#include "e-shell-constants.h"
@@ -31,6 +32,10 @@
#include "e-shell.h"
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
#include <gconf/gconf-client.h>
#include <gtk/gtkalignment.h>
@@ -338,21 +343,74 @@ new_window_created_callback (EShell *shell,
#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;
- if (!e_upgrade_detect_version (&major, &minor, &revision)
+ 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 = gconf_client_get_default ();
gconf_client_set_string (gconf_client, "/apps/evolution/version", VERSION, NULL);
g_object_unref (gconf_client);
}