aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Rosevear <jpr@src.gnome.org>2004-08-02 01:58:08 +0800
committerJP Rosevear <jpr@src.gnome.org>2004-08-02 01:58:08 +0800
commit94256b9919a932ff7b5f2bde1265dd8641215ed1 (patch)
tree09f3a2fb0030dc824d07e47c68cefcc1a756aa62
parent2b14bee53e34accdce0f23d6d8ef4e5b151dd129 (diff)
downloadgsoc2013-evolution-94256b9919a932ff7b5f2bde1265dd8641215ed1.tar.gz
gsoc2013-evolution-94256b9919a932ff7b5f2bde1265dd8641215ed1.tar.zst
gsoc2013-evolution-94256b9919a932ff7b5f2bde1265dd8641215ed1.zip
added last_version item.
* apps_evolution_shell.schemas.in.in: added last_version item. * shell-errors.xml: added upgrade-remove-1-4 and upgrade-remove-1-4-confirm dialogues. * e-shell.c (remove_dir): utility to recursively delete a tree of files and folders. (e_shell_attempt_upgrade): keep track of the last upgraded version, if != current version, and < 1.5, and it exists, offer to remove ~/evolution. Confirm the offer before actually doing it. * e-shell-window-commands.c: include gnome-about. (command_help_faq): fix comment structure * e-shell.c (attempt_upgrade): moved most of this into e_shell_attempt_upgrade. (e_shell_attempt_upgrade): moved most of this into attempt_upgrade, removed rev args. It makes sense, really! (e_shell_construct): call e_shell_attempt_upgrade instead. svn path=/trunk/; revision=26788
-rw-r--r--shell/ChangeLog22
-rw-r--r--shell/apps_evolution_shell.schemas.in.in12
-rw-r--r--shell/e-shell-window-commands.c3
-rw-r--r--shell/e-shell.c258
-rw-r--r--shell/e-shell.h5
-rw-r--r--shell/shell-errors.xml25
-rw-r--r--shell/shell-errors.xml.h21
7 files changed, 260 insertions, 86 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index bc6e9c1313..318874c97a 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,25 @@
+2004-08-01 Not Zed <NotZed@Ximian.com>
+
+ * apps_evolution_shell.schemas.in.in: added last_version item.
+
+ * shell-errors.xml: added upgrade-remove-1-4 and
+ upgrade-remove-1-4-confirm dialogues.
+
+ * e-shell.c (remove_dir): utility to recursively delete a tree of
+ files and folders.
+ (e_shell_attempt_upgrade): keep track of the last upgraded
+ version, if != current version, and < 1.5, and it exists, offer to
+ remove ~/evolution. Confirm the offer before actually doing it.
+
+ * e-shell-window-commands.c: include gnome-about.
+ (command_help_faq): fix comment structure
+
+ * e-shell.c (attempt_upgrade): moved most of this into
+ e_shell_attempt_upgrade.
+ (e_shell_attempt_upgrade): moved most of this into
+ attempt_upgrade, removed rev args. It makes sense, really!
+ (e_shell_construct): call e_shell_attempt_upgrade instead.
+
2004-07-22 Not Zed <NotZed@Ximian.com>
* e-shell.c (create_window): merged this into
diff --git a/shell/apps_evolution_shell.schemas.in.in b/shell/apps_evolution_shell.schemas.in.in
index 00080ffde1..1345a58a61 100644
--- a/shell/apps_evolution_shell.schemas.in.in
+++ b/shell/apps_evolution_shell.schemas.in.in
@@ -13,6 +13,18 @@
</locale>
</schema>
+ <!-- last upgraded-from version, if still present -->
+
+ <schema>
+ <key>/schemas/apps/evolution/last_version</key>
+ <applyto>/apps/evolution/last_version</applyto>
+ <owner>evolution</owner>
+ <type>string</type>
+ <locale name="C">
+ <short>Last upgraded Evolution configuration version</short>
+ </locale>
+ </schema>
+
<!-- Development warning dialog -->
<schema>
diff --git a/shell/e-shell-window-commands.c b/shell/e-shell-window-commands.c
index 85b182a0a8..8851f35138 100644
--- a/shell/e-shell-window-commands.c
+++ b/shell/e-shell-window-commands.c
@@ -40,6 +40,7 @@
#include <libgnome/gnome-exec.h>
#include <libgnome/gnome-url.h>
#include <libgnome/gnome-i18n.h>
+#include <libgnomeui/gnome-about.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <libgnomevfs/gnome-vfs-mime-utils.h>
@@ -357,7 +358,7 @@ command_help_faq (BonoboUIComponent *uih,
EShellWindow *window,
const char *path)
{
- /* FIXME Show when we have a faq
+ /* FIXME Show when we have a faq */
/* FIXME use the error */
gnome_url_show ("http://gnome.org/projects/evolution/faq.shtml", NULL);
}
diff --git a/shell/e-shell.c b/shell/e-shell.c
index c2cdafc89b..b86f0a2198 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -24,6 +24,9 @@
#include <config.h>
#endif
+#include <sys/types.h>
+#include <dirent.h>
+
#include "e-shell.h"
#include "e-util/e-dialog-utils.h"
@@ -541,44 +544,54 @@ detect_version (GConfClient *gconf, int *major, int *minor, int *revision)
g_free (evolution_dir);
}
-static void
-attempt_upgrade (EShell *shell)
+/* calls components to perform upgrade */
+static gboolean
+attempt_upgrade (EShell *shell, int major, int minor, int revision)
{
- GConfClient *gconf_client;
- int major = 0, minor = 0, revision = 0;
- char *version_string;
+ GSList *component_infos, *p;
+ gboolean success;
+ int res;
- gconf_client = gconf_client_get_default ();
+ success = TRUE;
- detect_version (gconf_client, &major, &minor, &revision);
+ component_infos = e_component_registry_peek_list (shell->priv->component_registry);
+ for (p = component_infos; success && p != NULL; p = p->next) {
+ const EComponentInfo *info = p->data;
+ CORBA_Environment ev;
- /* if upgrading from < 1.5, we need to copy most data from ~/evolution to ~/.evolution */
- if (major == 1 && minor < 5) {
- char *path;
- long size, space;
+ CORBA_exception_init (&ev);
+
+ GNOME_Evolution_Component_upgradeFromVersion (info->iface, major, minor, revision, &ev);
+
+ if (BONOBO_EX (&ev)) {
+ char *exception_text;
+ CORBA_char *id = CORBA_exception_id(&ev);
- path = g_build_filename(g_get_home_dir(), "evolution", NULL);
- size = e_fsutils_usage(path);
- g_free(path);
- space = e_fsutils_avail(g_get_home_dir());
- if (size != -1 && space != -1 && space < size) {
- char *required = g_strdup_printf(_("%ld KB"), size);
- char *have = g_strdup_printf(_("%ld KB"), space);
+ if (strcmp (id, ex_CORBA_NO_IMPLEMENT) == 0) {
+ /* Ignore components that do not implement this version, it
+ might just mean that they don't need an upgrade path. */
+ } else if (strcmp (id, ex_GNOME_Evolution_Component_UpgradeFailed) == 0) {
+ GNOME_Evolution_Component_UpgradeFailed *ex = CORBA_exception_value(&ev);
- e_error_run(NULL, "shell:upgrade-nospace", required, have, NULL);
- g_free(required);
- g_free(have);
- _exit(0);
+ res = e_error_run(NULL, "shell:upgrade-failed", ex->what, ex->why, NULL);
+ if (res == GTK_RESPONSE_CANCEL)
+ success = FALSE;
+ } else if (strcmp (id, ex_GNOME_Evolution_Component_UnsupportedVersion) == 0) {
+ /* This is non-fatal */
+ /* DO WE CARE??? */
+ printf("Upgrade of component failed, unsupported prior version\n");
+ } else {
+ exception_text = bonobo_exception_get_text (&ev);
+ res = e_error_run(NULL, "shell:upgrade-failed", exception_text, _("Uknown system error."), NULL);
+ g_free (exception_text);
+ if (res == GTK_RESPONSE_CANCEL)
+ success = FALSE;
+ }
}
+ CORBA_exception_free (&ev);
}
- if (!e_shell_attempt_upgrade (shell, major, minor, revision))
- _exit(0);
-
- version_string = g_strdup_printf ("%s.%s", BASE_VERSION, UPGRADE_REVISION);
- gconf_client_set_string (gconf_client, "/apps/evolution/version", version_string, NULL);
- g_object_unref (gconf_client);
- g_free (version_string);
+ return success;
}
/**
@@ -624,7 +637,7 @@ e_shell_construct (EShell *shell,
/* activate all the components (peek list does this implictly) */
component = e_component_registry_peek_list (shell->priv->component_registry);
- attempt_upgrade(shell);
+ e_shell_attempt_upgrade(shell);
if (e_shell_startup_wizard_create () == FALSE) {
bonobo_object_unref (BONOBO_OBJECT (shell));
@@ -688,78 +701,161 @@ e_shell_new (EShellStartupLineMode startup_line_mode,
return new;
}
+static int
+remove_dir(const char *root, const char *path)
+{
+ DIR *dir;
+ struct dirent *d;
+ int res = -1;
+ char *new = NULL;
+ struct stat st;
+
+ dir = opendir(path);
+ if (dir == NULL)
+ return -1;
+
+ while ( (d = readdir(dir)) ) {
+ if (!strcmp(d->d_name, ".")
+ || !strcmp(d->d_name, ".."))
+ continue;
+
+ new = g_build_filename(path, d->d_name, NULL);
+ if (stat(new, &st) == -1)
+ goto fail;
+
+ /* make sure we're really removing something from evolution dir */
+ g_assert(strlen(path) >= strlen(root)
+ && strncmp(root, path, strlen(root)) == 0);
+
+ if (S_ISDIR(st.st_mode)) {
+ if (remove_dir(root, new) == -1)
+ goto fail;
+ } else {
+ if (unlink(new) == -1)
+ goto fail;
+ }
+ g_free(new);
+ new = NULL;
+ }
+
+ res = rmdir(path);
+fail:
+ g_free(new);
+ closedir(dir);
+ return res;
+}
+
/**
* e_shell_attempt_upgrade:
* @shell:
- * @from_version:
*
- * Upgrade config and components from the specified version name.
+ * Upgrade config and components from the currently installed version.
*
- * Return value: %TRUE If it works, %FALSE if it fails (it should only fail if
- * upgrade from @from_version is unsupported).
+ * Return value: %TRUE If it works. If it fails the application will exit.
**/
gboolean
-e_shell_attempt_upgrade (EShell *shell, int major, int minor, int revision)
+e_shell_attempt_upgrade (EShell *shell)
{
- GSList *component_infos, *p;
- int current_major, current_minor, current_revision;
- gboolean success;
- int res;
+ GConfClient *gconf_client;
+ int major = 0, minor = 0, revision = 0;
+ int lmajor, lminor, lrevision;
+ int cmajor, cminor, crevision;
+ char *version_string, *last_version = NULL;
+ int done_upgrade = FALSE;
+ char *oldpath;
+ struct stat st;
- g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
+ gconf_client = gconf_client_get_default();
- sscanf (BASE_VERSION, "%u.%u", &current_major, &current_minor);
+ oldpath = g_build_filename(g_get_home_dir(), "evolution", NULL);
- current_revision = atoi (UPGRADE_REVISION);
+ g_assert(sscanf(BASE_VERSION, "%u.%u", &cmajor, &cminor) == 2);
+ crevision = atoi(UPGRADE_REVISION);
- if (! (current_major > major
- || (current_major == major && current_minor > minor)
- || (current_minor == current_minor && current_revision > revision))) {
- return TRUE;
- }
+ detect_version (gconf_client, &major, &minor, &revision);
- success = TRUE;
+ if (!(cmajor > major
+ || (cmajor == major && cminor > minor)
+ || (cminor == minor && crevision > revision)))
+ goto check_old;
- component_infos = e_component_registry_peek_list (shell->priv->component_registry);
- for (p = component_infos; success && p != NULL; p = p->next) {
- const EComponentInfo *info = p->data;
- CORBA_Environment ev;
+ /* if upgrading from < 1.5, we need to copy most data from ~/evolution to ~/.evolution */
+ if (major == 1 && minor < 5) {
+ long size, space;
- CORBA_exception_init (&ev);
-
- GNOME_Evolution_Component_upgradeFromVersion (info->iface, major, minor, revision, &ev);
-
- if (BONOBO_EX (&ev)) {
- char *exception_text;
- CORBA_char *id = CORBA_exception_id(&ev);
+ size = e_fsutils_usage(oldpath);
+ space = e_fsutils_avail(g_get_home_dir());
+ if (size != -1 && space != -1 && space < size) {
+ char *required = g_strdup_printf(_("%ld KB"), size);
+ char *have = g_strdup_printf(_("%ld KB"), space);
- if (strcmp (id, ex_CORBA_NO_IMPLEMENT) == 0) {
- /* Ignore components that do not implement this version, it
- might just mean that they don't need an upgrade path. */
- } else if (strcmp (id, ex_GNOME_Evolution_Component_UpgradeFailed) == 0) {
- GNOME_Evolution_Component_UpgradeFailed *ex = CORBA_exception_value(&ev);
+ e_error_run(NULL, "shell:upgrade-nospace", required, have, NULL);
+ g_free(required);
+ g_free(have);
+ _exit(0);
+ }
+ }
- res = e_error_run(NULL, "shell:upgrade-failed", ex->what, ex->why, NULL);
- if (res == GTK_RESPONSE_CANCEL)
- success = FALSE;
- } else if (strcmp (id, ex_GNOME_Evolution_Component_UnsupportedVersion) == 0) {
- /* This is non-fatal */
- /* DO WE CARE??? */
- printf("Upgrade of component failed, unsupported prior version\n");
- } else {
- exception_text = bonobo_exception_get_text (&ev);
- res = e_error_run(NULL, "shell:upgrade-failed", exception_text, _("Uknown system error."), NULL);
- g_free (exception_text);
- if (res == GTK_RESPONSE_CANCEL)
- success = FALSE;
- }
+ if (!attempt_upgrade (shell, major, minor, revision))
+ _exit(0);
+
+ /* mark as upgraded */
+ version_string = g_strdup_printf ("%s.%s", BASE_VERSION, UPGRADE_REVISION);
+ gconf_client_set_string (gconf_client, "/apps/evolution/version", version_string, NULL);
+ done_upgrade = TRUE;
+
+check_old:
+ /* if the last upgraded version was old, check for stuff to remove */
+ if (done_upgrade
+ || (last_version = gconf_client_get_string (gconf_client, "/apps/evolution/last_version", NULL)) == NULL
+ || sscanf(last_version, "%d.%d.%d", &lmajor, &lminor, &lrevision) != 3) {
+ lmajor = major;
+ lminor = minor;
+ lrevision = revision;
+ }
+ g_free(last_version);
+
+ if (lmajor == 1 && lminor < 5
+ && stat(oldpath, &st) == 0
+ && S_ISDIR(st.st_mode)) {
+ int res;
+
+ last_version = g_strdup_printf("%u.%u.%u", lmajor, lminor, lrevision);
+ res = e_error_run(NULL, "shell:upgrade-remove-1-4", last_version, NULL);
+ g_free(last_version);
+
+ switch (res) {
+ case GTK_RESPONSE_OK: /* 'delete' */
+ if (e_error_run(NULL, "shell:upgrade-remove-1-4-confirm", NULL) == GTK_RESPONSE_OK)
+ remove_dir(oldpath, oldpath);
+ else
+ break;
+ /* falls through */
+ case GTK_RESPONSE_ACCEPT: /* 'keep' */
+ lmajor = cmajor;
+ lminor = cminor;
+ lrevision = crevision;
+ break;
+ default:
+ /* cancel - noop */
+ break;
}
- CORBA_exception_free (&ev);
+ } else {
+ /* otherwise 'last version' is now the same as current */
+ lmajor = cmajor;
+ lminor = cminor;
+ lrevision = crevision;
}
- return success;
-}
+ last_version = g_strdup_printf("%u.%u.%u", lmajor, lminor, lrevision);
+ gconf_client_set_string (gconf_client, "/apps/evolution/last_version", last_version, NULL);
+ g_free(last_version);
+ g_free(oldpath);
+ g_object_unref (gconf_client);
+
+ return TRUE;
+}
/**
* e_shell_create_window:
diff --git a/shell/e-shell.h b/shell/e-shell.h
index f9aa3855e0..62b7538089 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -99,10 +99,7 @@ EShellConstructResult e_shell_construct (EShell *shell,
EShell *e_shell_new (EShellStartupLineMode startup_line_mode,
EShellConstructResult *construct_result_return);
-gboolean e_shell_attempt_upgrade (EShell *shell,
- int major,
- int minor,
- int revision);
+gboolean e_shell_attempt_upgrade (EShell *shell);
EShellWindow *e_shell_create_window (EShell *shell,
const char *component_id,
diff --git a/shell/shell-errors.xml b/shell/shell-errors.xml
index 052a35c09d..8e7d8678c6 100644
--- a/shell/shell-errors.xml
+++ b/shell/shell-errors.xml
@@ -20,6 +20,31 @@ If you choose to continue, you may not have access to some of your old data.
<button stock="gtk-ok" label="Continue" response="GTK_RESPONSE_OK"/>
</error>
+ <error id="upgrade-remove-1-4" type="question" default="GTK_RESPONSE_CANCEL">
+ <title>Delete old data from version {0}?</title>
+ <primary>Delete old data from version {0}?</primary>
+ <secondary>The previous version of evolution stored its data in a different location.
+
+If you choose to remove this data, the entire contents of the &quot;evolution&quot; directory will be removed permanently. If you choose to keep this data, then you may manually remove the contents of &quot;evolution&quot; at your convenience.
+</secondary>
+ <button label="_Remind Me Later" response="GTK_RESPONSE_CANCEL"/>
+ <button label="_Keep Data" response="GTK_RESPONSE_ACCEPT"/>
+ <button stock="gtk-delete" response="GTK_RESPONSE_OK"/>
+ </error>
+
+ <error id="upgrade-remove-1-4-confirm" type="warning" default="GTK_RESPONSE_CANCEL">
+ <title>Really delete old data?</title>
+ <primary>Really delete old data?</primary>
+ <secondary>The entire contents of the &quot;evolution&quot; directory is about to be be permanently removed.
+
+It is suggested you manually verify that all of your mail, contact, and calendar data is present, and that this version of Evolution operates correctly before deleting this old data.
+
+Once deleted, you cannot downgrade to the previous version of Evolution without manual intervention.
+</secondary>
+ <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
+ <button stock="gtk-delete" response="GTK_RESPONSE_OK"/>
+ </error>
+
<error id="noshell" type="error">
<title>Cannot start Evolution</title>
<primary>Evolution can not start.</primary>
diff --git a/shell/shell-errors.xml.h b/shell/shell-errors.xml.h
index e71c875578..9014474843 100644
--- a/shell/shell-errors.xml.h
+++ b/shell/shell-errors.xml.h
@@ -13,6 +13,27 @@ char *s = N_("{1}\n"
"If you choose to continue, you may not have access to some of your old data.\n"
"");
char *s = N_("Continue");
+/* shell:upgrade-remove-1-4 title */
+char *s = N_("Delete old data from version {0}?");
+/* shell:upgrade-remove-1-4 primary */
+char *s = N_("Delete old data from version {0}?");
+/* shell:upgrade-remove-1-4 secondary */
+char *s = N_("The previous version of evolution stored its data in a different location.\n"
+ "\n"
+ "If you choose to remove this data, the entire contents of the \"evolution\" directory will be removed permanently. If you choose to keep this data, then you may manually remove the contents of \"evolution\" at your convenience.\n"
+ "");
+char *s = N_("Keep");
+/* shell:upgrade-remove-1-4-confirm title */
+char *s = N_("Really delete old data?");
+/* shell:upgrade-remove-1-4-confirm primary */
+char *s = N_("Really delete old data?");
+/* shell:upgrade-remove-1-4-confirm secondary */
+char *s = N_("The entire contents of the \"evolution\" directory is about to be be permanently removed.\n"
+ "\n"
+ "It is suggested you manually verify that all of your mail, contact, and calendar data is present, and that this version of Evolution operates correctly before deleting this old data.\n"
+ "\n"
+ "Once deleted, you cannot downgrade to the previous version of Evolution without manual intervention.\n"
+ "");
/* shell:noshell title */
char *s = N_("Cannot start Evolution");
/* shell:noshell primary */