diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-11-11 07:26:25 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-11-11 07:26:25 +0800 |
commit | 12fab9c6a622398e40515ab8c8e8f2efd790fcd8 (patch) | |
tree | 6ef059d078d91767f2397bb7550dd6f9601fff43 /mail/e-mail-migrate.c | |
parent | 9a5f4e7ab9180b6904fb3effb97aec1279568656 (diff) | |
download | gsoc2013-evolution-12fab9c6a622398e40515ab8c8e8f2efd790fcd8.tar.gz gsoc2013-evolution-12fab9c6a622398e40515ab8c8e8f2efd790fcd8.tar.zst gsoc2013-evolution-12fab9c6a622398e40515ab8c8e8f2efd790fcd8.zip |
Remove SQLite mail summary migration.
It's been three years and it's standing in the way of our transition to
keyfile-based accounts. Users brave enough to jump to version 3.4 from
2.22 or older will just have to re-generate their mail caches.
Diffstat (limited to 'mail/e-mail-migrate.c')
-rw-r--r-- | mail/e-mail-migrate.c | 352 |
1 files changed, 1 insertions, 351 deletions
diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c index 59605e24a4..f3ce503012 100644 --- a/mail/e-mail-migrate.c +++ b/mail/e-mail-migrate.c @@ -70,16 +70,6 @@ #define d(x) x -typedef struct _MigrateStateInfo MigrateStateInfo; - -struct _MigrateStateInfo { - gchar *label_name; - gdouble progress; -}; - -static gboolean -update_states_in_main_thread (MigrateStateInfo *info); - /* 1.4 upgrade functions */ #define EM_TYPE_MIGRATE_SESSION \ @@ -119,100 +109,9 @@ em_migrate_session_new (const gchar *user_data_dir) "user-data-dir", user_data_dir, NULL); } -static GtkWidget *window; -static GtkLabel *label; static GtkProgressBar *progress; static void -em_migrate_setup_progress_dialog (const gchar *title, - const gchar *desc) -{ - GtkWidget *vbox, *hbox, *w; - gchar *markup; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title ((GtkWindow *) window, _("Migrating...")); - gtk_window_set_modal ((GtkWindow *) window, TRUE); - gtk_container_set_border_width ((GtkContainer *) window, 6); - - vbox = gtk_vbox_new (FALSE, 6); - gtk_widget_show (vbox); - gtk_container_add ((GtkContainer *) window, vbox); - - w = gtk_label_new (desc); - - gtk_label_set_line_wrap ((GtkLabel *) w, TRUE); - gtk_widget_show (w); - gtk_box_pack_start ((GtkBox *) vbox, w, TRUE, TRUE, 0); - - hbox = gtk_hbox_new (FALSE, 6); - gtk_widget_show (hbox); - gtk_box_pack_start ((GtkBox *) vbox, hbox, TRUE, TRUE, 0); - - label = (GtkLabel *) gtk_label_new (""); - gtk_widget_show ((GtkWidget *) label); - gtk_box_pack_start ((GtkBox *) hbox, (GtkWidget *) label, TRUE, TRUE, 0); - - progress = (GtkProgressBar *) gtk_progress_bar_new (); - gtk_widget_show ((GtkWidget *) progress); - gtk_box_pack_start ((GtkBox *) hbox, (GtkWidget *) progress, TRUE, TRUE, 0); - - /* Prepare the message */ - vbox = gtk_vbox_new (FALSE, 12); - gtk_widget_show (vbox); - gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); - - w = gtk_label_new (NULL); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); - markup = g_strconcat ( - "<big><b>", - title ? title : _("Migration"), - "</b></big>", NULL); - gtk_label_set_markup (GTK_LABEL (w), markup); - gtk_box_pack_start (GTK_BOX (vbox), w, TRUE, TRUE, 0); - g_free (markup); - - w = gtk_label_new (desc); - gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); - gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), w, TRUE, TRUE, 0); - - /* Progress bar */ - w = gtk_vbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (vbox), w, TRUE, TRUE, 0); - - label = GTK_LABEL (gtk_label_new ("")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); - gtk_label_set_line_wrap (label, TRUE); - gtk_widget_show (GTK_WIDGET (label)); - gtk_box_pack_start (GTK_BOX (w), GTK_WIDGET (label), TRUE, TRUE, 0); - - progress = GTK_PROGRESS_BAR (gtk_progress_bar_new ()); - gtk_widget_show (GTK_WIDGET (progress)); - gtk_box_pack_start (GTK_BOX (w), GTK_WIDGET (progress), TRUE, TRUE, 0); - - gtk_container_add (GTK_CONTAINER (window), hbox); - gtk_widget_show_all (hbox); - gtk_widget_show (window); -} - -static void -em_migrate_close_progress_dialog (void) -{ - gtk_widget_destroy ((GtkWidget *) window); -} - -static void -em_migrate_set_folder_name (const gchar *folder_name) -{ - gchar *text; - - text = g_strdup_printf (_("Migrating '%s':"), folder_name); - gtk_label_set_text (label, text); - g_free (text); -} - -static void em_migrate_set_progress (double percent) { gchar text[5]; @@ -566,253 +465,6 @@ em_update_sa_junk_setting_2_23 (void) g_object_unref (client); } -#ifndef G_OS_WIN32 - -static gboolean -update_states_in_main_thread (MigrateStateInfo *info) -{ - g_return_val_if_fail (info != NULL, FALSE); - g_return_val_if_fail (info->label_name != NULL, FALSE); - - em_migrate_set_progress (info->progress); - em_migrate_set_folder_name (info->label_name); - - /* XXX Why is this necessary? */ - while (gtk_events_pending ()) - gtk_main_iteration (); - - return FALSE; -} - -static void -migrate_state_info_free (MigrateStateInfo *info) -{ - g_free (info->label_name); - g_slice_free (MigrateStateInfo, info); -} - -static void -migrate_folders (CamelStore *store, - gboolean is_local, - CamelFolderInfo *fi, - const gchar *acc, - gboolean *done, - gint *nth_folder, - gint total_folders) -{ - CamelFolder *folder; - - while (fi) { - MigrateStateInfo *info; - - *nth_folder = *nth_folder + 1; - - info = g_slice_new0 (MigrateStateInfo); - info->label_name = g_strdup_printf ( - "%s/%s", acc, fi->full_name); - info->progress = (gdouble) (*nth_folder) / total_folders; - - g_idle_add_full ( - G_PRIORITY_LOW, (GSourceFunc) - update_states_in_main_thread, info, - (GDestroyNotify) migrate_state_info_free); - - if (is_local) - folder = camel_store_get_folder_sync ( - store, fi->full_name, - CAMEL_STORE_IS_MIGRATING, NULL, NULL); - else - folder = camel_store_get_folder_sync ( - store, fi->full_name, 0, NULL, NULL); - - if (folder != NULL) - camel_folder_summary_migrate_infos (folder->summary); - migrate_folders ( - store, is_local, fi->child, - acc, done, nth_folder, total_folders); - fi = fi->next; - } - - if ((*nth_folder) == (total_folders - 1)) - *done = TRUE; -} - -#endif /* G_OS_WIN32 */ - -/* This could be in CamelStore.ch */ -static void -count_folders (CamelFolderInfo *fi, - gint *count) -{ - while (fi) { - *count = *count + 1; - count_folders (fi->child, count); - fi = fi->next; - } -} - -static CamelStore * -setup_local_store (EShellBackend *shell_backend, - EMMigrateSession *session) -{ - CamelSettings *settings; - CamelService *service; - const gchar *data_dir; - gchar *path; - - service = camel_session_add_service ( - CAMEL_SESSION (session), "local", "mbox", - CAMEL_PROVIDER_STORE, NULL); - - settings = camel_service_get_settings (service); - data_dir = e_shell_backend_get_data_dir (shell_backend); - - path = g_build_filename (data_dir, "local", NULL); - g_object_set (settings, "path", path, NULL); - g_free (path); - - return CAMEL_STORE (service); -} - -#ifndef G_OS_WIN32 - -struct migrate_folders_to_db_structure { - gchar *account_name; - CamelStore *store; - CamelFolderInfo *info; - gboolean done; - gboolean is_local_store; -}; - -static void -migrate_folders_to_db_thread (struct migrate_folders_to_db_structure *migrate_dbs) -{ - gint num_of_folders = 0, nth_folder = 0; - count_folders (migrate_dbs->info, &num_of_folders); - migrate_folders ( - migrate_dbs->store, migrate_dbs->is_local_store, - migrate_dbs->info, migrate_dbs->account_name, - &(migrate_dbs->done), &nth_folder, num_of_folders); -} - -static void -migrate_to_db (EShellBackend *shell_backend) -{ - EMMigrateSession *session; - EAccountList *accounts; - EMailBackend *mail_backend; - EMailSession *mail_session; - EIterator *iter; - gint i = 0, len; - CamelStore *store = NULL; - CamelSettings *settings; - CamelFolderInfo *info; - const gchar *data_dir; - const gchar *path; - - if (!(accounts = e_get_account_list ())) - return; - - mail_backend = E_MAIL_BACKEND (shell_backend); - mail_session = e_mail_backend_get_session (mail_backend); - data_dir = e_shell_backend_get_data_dir (shell_backend); - - /* Initialize the mail stores early so we can add a new one. */ - e_mail_store_init (mail_session, data_dir); - - iter = e_list_get_iterator ((EList *) accounts); - len = e_list_length ((EList *) accounts); - - session = em_migrate_session_new (data_dir); - camel_session_set_online ((CamelSession *) session, FALSE); - em_migrate_setup_progress_dialog ( - _("Migrating Folders"), - _("The summary format of the Evolution mailbox " - "folders has been moved to SQLite since Evolution 2.24.\n\nPlease be " - "patient while Evolution migrates your folders...")); - - em_migrate_set_progress ((gdouble) i / (len + 1)); - store = setup_local_store (shell_backend, session); - - settings = camel_service_get_settings (CAMEL_SERVICE (store)); - path = camel_local_settings_get_path (CAMEL_LOCAL_SETTINGS (settings)); - - info = camel_store_get_folder_info_sync ( - store, NULL, - CAMEL_STORE_FOLDER_INFO_RECURSIVE | - CAMEL_STORE_FOLDER_INFO_FAST | - CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, - NULL, NULL); - if (info) { - struct migrate_folders_to_db_structure migrate_dbs; - - if (path != NULL && g_str_has_suffix (path, ".evolution/mail/local")) - migrate_dbs.is_local_store = TRUE; - else - migrate_dbs.is_local_store = FALSE; - migrate_dbs.account_name = _("On This Computer"); - migrate_dbs.info = info; - migrate_dbs.store = store; - migrate_dbs.done = FALSE; - - g_thread_create ( - (GThreadFunc) migrate_folders_to_db_thread, - &migrate_dbs, TRUE, NULL); - while (!migrate_dbs.done) - g_main_context_iteration (NULL, TRUE); - } - i++; - em_migrate_set_progress ((gdouble) i / (len + 1)); - - while (e_iterator_is_valid (iter)) { - EAccount *account = (EAccount *) e_iterator_get (iter); - EAccountService *service; - - service = account->source; - em_migrate_set_progress ((gdouble) i / (len + 1)); - if (account->enabled - && service->url != NULL && service->url[0] - && strncmp (service->url, "mbox:", 5) != 0) { - - store = e_mail_store_add_by_account ( - mail_session, account); - - info = camel_store_get_folder_info_sync ( - store, NULL, - CAMEL_STORE_FOLDER_INFO_RECURSIVE | - CAMEL_STORE_FOLDER_INFO_FAST | - CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, - NULL, NULL); - if (info) { - struct migrate_folders_to_db_structure migrate_dbs; - - migrate_dbs.account_name = account->name; - migrate_dbs.info = info; - migrate_dbs.store = store; - migrate_dbs.done = FALSE; - - g_thread_create ( - (GThreadFunc) - migrate_folders_to_db_thread, - &migrate_dbs, TRUE, NULL); - while (!migrate_dbs.done) - g_main_context_iteration (NULL, TRUE); - } else - printf("%s:%s: failed to get folder infos \n", G_STRLOC, G_STRFUNC); - } - i++; - e_iterator_next (iter); - - } - - g_object_unref (iter); - em_migrate_close_progress_dialog (); - - g_object_unref (session); -} - -#endif - static gboolean mbox_to_maildir_migration_needed (EShellBackend *shell_backend) { @@ -1539,10 +1191,8 @@ e_mail_migrate (EShellBackend *shell_backend, if (major < 2 || (major == 2 && minor < 22)) em_update_message_notify_settings_2_21 (); - if (major < 2 || (major == 2 && minor < 24)) { + if (major < 2 || (major == 2 && minor < 24)) em_update_sa_junk_setting_2_23 (); - migrate_to_db (shell_backend); - } #else if (major < 2 || (major == 2 && minor < 24)) g_warning ( |