aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-component.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-11-06 06:07:31 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-11-06 06:07:31 +0800
commit20a1f88f75f89e2f041bf700b8d8efca08bcfc32 (patch)
tree281fb7b85ae06a0f8e45c0f53f70c9f6fb5d69ab /mail/mail-component.c
parent189d7b0fc6f3fe05e69ce67c9239bab0bff4ec63 (diff)
downloadgsoc2013-evolution-20a1f88f75f89e2f041bf700b8d8efca08bcfc32.tar.gz
gsoc2013-evolution-20a1f88f75f89e2f041bf700b8d8efca08bcfc32.tar.zst
gsoc2013-evolution-20a1f88f75f89e2f041bf700b8d8efca08bcfc32.zip
New source files to migrate from the old mail directory to the new mail
2003-11-05 Jeffrey Stedfast <fejj@ximian.com> * em-migrate.[c,h]: New source files to migrate from the old mail directory to the new mail directory. * mail-component.c (mail_component_init): Changed to use ~/.evolution and added code to migrate the old mail folders over if ~/.evolution/mail does not yet exist. svn path=/trunk/; revision=23193
Diffstat (limited to 'mail/mail-component.c')
-rw-r--r--mail/mail-component.c87
1 files changed, 39 insertions, 48 deletions
diff --git a/mail/mail-component.c b/mail/mail-component.c
index 20e956cebd..afb769564b 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -25,6 +25,7 @@
#include <config.h>
#endif
+#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -52,6 +53,7 @@
#include "em-popup.h"
#include "em-utils.h"
+#include "em-migrate.h"
#include <gtk/gtklabel.h>
@@ -62,6 +64,7 @@
#include <gal/e-table/e-tree-memory.h>
#include <camel/camel.h>
+#include <camel/camel-file-utils.h>
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-widget.h>
@@ -926,7 +929,7 @@ impl_createControls (PortableServer_Servant servant,
GtkWidget *view_widget;
BonoboControl *sidebar_control;
BonoboControl *view_control;
-
+
browser = e_storage_browser_new (priv->storage_set, "/", create_view_callback, NULL);
tree_widget = e_storage_browser_peek_tree_widget (browser);
@@ -977,67 +980,55 @@ mail_component_init (MailComponent *component)
{
MailComponentPrivate *priv;
EAccountList *accounts;
-
+ struct stat st;
+ char *mail_dir;
+
priv = g_new0 (MailComponentPrivate, 1);
component->priv = priv;
-
- /* EPFIXME: Move to a private directory. */
- /* EPFIXME: Create the directory. */
- priv->base_directory = g_build_filename (g_get_home_dir (), "evolution", NULL);
-
+
+ priv->base_directory = g_build_filename (g_get_home_dir (), ".evolution", NULL);
+ if (camel_mkdir (priv->base_directory, 0777) == -1 && errno != EEXIST)
+ abort ();
+
/* EPFIXME: Turn into an object? */
mail_session_init (priv->base_directory);
-
+
priv->async_event = mail_async_event_new();
priv->storages_hash = g_hash_table_new (NULL, NULL);
-
+
priv->folder_type_registry = e_folder_type_registry_new ();
priv->storage_set = e_storage_set_new (priv->folder_type_registry);
-
-#if 0 /* EPFIXME TODO somehow */
- for (i = 0; i < sizeof (standard_folders) / sizeof (standard_folders[0]); i++)
- *standard_folders[i].uri = g_strdup_printf ("file://%s/local/%s", evolution_dir, standard_folders[i].name);
-#endif
+
+ /* migrate evolution 1.x folders to 2.0's location/format */
+ mail_dir = g_strdup_printf ("%s/mail", priv->base_directory);
+ if (stat (mail_dir, &st) == -1) {
+ CamelException ex;
+
+ camel_exception_init (&ex);
+ if (em_migrate (component, &ex) == -1) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
+ _("Some of your mail folders were unable to be migrated:\n%s"),
+ camel_exception_get_description (&ex));
+
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
+ gtk_widget_show (dialog);
+
+ camel_exception_clear (&ex);
+ }
+ }
+ g_free (mail_dir);
+
setup_local_store (component);
-
+
accounts = mail_config_get_accounts ();
load_accounts(component, accounts);
-
-#if 0
- /* EPFIXME? */
- mail_local_storage_startup (shell_client, evolution_dir);
- mail_importer_init (shell_client);
-
- for (i = 0; i < sizeof (standard_folders) / sizeof (standard_folders[0]); i++) {
- mail_msg_wait (mail_get_folder (*standard_folders[i].uri, CAMEL_STORE_FOLDER_CREATE,
- got_folder, standard_folders[i].folder, mail_thread_new));
- }
-#endif
/* mail_autoreceive_setup (); EPFIXME keep it off for testing */
-
+
setup_search_context (component);
-
-#if 0
- /* EPFIXME this shouldn't be here. */
- if (mail_config_is_corrupt ()) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
- _("Some of your mail settings seem corrupt, "
- "please check that everything is in order."));
- g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
- gtk_widget_show (dialog);
- }
-#endif
-
-#if 0
- /* EPFIXME if we nuke the summary this is not necessary anymore. */
-
- /* Everything should be ready now */
- evolution_folder_info_notify_ready ();
-#endif
-
+
/* EPFIXME not sure about this. */
go_online (component);
}