diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-05-27 20:37:17 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-05-27 20:37:17 +0800 |
commit | cc3a98fc1ad5bb87aa7335f3de404ee7feee1541 (patch) | |
tree | 763785c47096a6aba1ca6c03115b5e862c9f49ad /mail/e-mail-shell-migrate.c | |
parent | 10f8406b09318b1a3e4fe9d08d41a60239f9f3a6 (diff) | |
parent | e4afd3f9fb962ea1295a0657ec9f83a427829171 (diff) | |
download | gsoc2013-evolution-cc3a98fc1ad5bb87aa7335f3de404ee7feee1541.tar.gz gsoc2013-evolution-cc3a98fc1ad5bb87aa7335f3de404ee7feee1541.tar.zst gsoc2013-evolution-cc3a98fc1ad5bb87aa7335f3de404ee7feee1541.zip |
Merge branch 'master' into kill-bonobo
Conflicts:
a11y/widgets/ea-combo-button.c
a11y/widgets/ea-combo-button.h
addressbook/gui/component/addressbook-component.c
addressbook/gui/component/addressbook-component.h
addressbook/gui/component/addressbook-view.c
addressbook/gui/component/addressbook-view.h
addressbook/gui/component/component-factory.c
addressbook/gui/widgets/e-addressbook-view.c
addressbook/gui/widgets/eab-contact-display.c
addressbook/gui/widgets/eab-gui-util.h
addressbook/gui/widgets/eab-menu.c
addressbook/gui/widgets/eab-menu.h
addressbook/gui/widgets/eab-popup-control.c
addressbook/gui/widgets/eab-popup-control.h
addressbook/gui/widgets/eab-popup.c
addressbook/gui/widgets/eab-popup.h
calendar/gui/cal-search-bar.c
calendar/gui/calendar-commands.c
calendar/gui/calendar-component.c
calendar/gui/comp-editor-factory.c
calendar/gui/comp-editor-factory.h
calendar/gui/control-factory.c
calendar/gui/dialogs/comp-editor.c
calendar/gui/e-cal-component-memo-preview.c
calendar/gui/e-cal-component-memo-preview.h
calendar/gui/e-calendar-table.c
calendar/gui/e-memo-table.c
calendar/gui/e-memos.c
calendar/gui/e-tasks.c
calendar/gui/gnome-cal.c
calendar/gui/gnome-cal.h
calendar/gui/itip-bonobo-control.c
calendar/gui/itip-bonobo-control.h
calendar/gui/main.c
calendar/gui/memos-component.c
calendar/gui/memos-control.c
calendar/gui/memos-control.h
calendar/gui/migration.c
calendar/gui/migration.h
calendar/gui/tasks-component.c
calendar/gui/tasks-control.c
calendar/importers/main.c
composer/Makefile.am
composer/e-composer-header-table.c
composer/e-composer-header.c
composer/e-composer-header.h
composer/e-composer-name-header.c
composer/e-composer-private.c
composer/e-composer-text-header.c
composer/e-msg-composer.c
composer/e-msg-composer.h
e-util/e-corba-utils.h
e-util/e-logger.c
e-util/e-logger.h
e-util/e-util-labels.c
e-util/e-util-labels.h
em-format/em-format.c
mail/Makefile.am
mail/e-mail-shell-migrate.c
mail/em-account-editor.c
mail/em-account-editor.h
mail/em-composer-prefs.c
mail/em-composer-utils.c
mail/em-composer-utils.h
mail/em-folder-browser.c
mail/em-folder-tree-model.c
mail/em-folder-tree.c
mail/em-folder-tree.h
mail/em-folder-utils.c
mail/em-folder-utils.h
mail/em-folder-view.c
mail/em-format-html-display.c
mail/em-format-html.c
mail/em-mailer-prefs.c
mail/em-mailer-prefs.h
mail/em-message-browser.c
mail/em-message-browser.h
mail/em-network-prefs.h
mail/em-popup.c
mail/em-utils.c
mail/importers/Makefile.am
mail/mail-component-factory.c
mail/mail-component.c
mail/mail-config-factory.c
mail/mail-config-factory.h
mail/mail-config.c
mail/mail-dialogs.glade
mail/mail-types.h
plugins/calendar-weather/calendar-weather.c
plugins/mail-account-disable/mail-account-disable.c
plugins/select-one-source/select-one-source.c
po/POTFILES.in
shell/e-component-registry.c
shell/e-component-registry.h
shell/e-component-view.c
shell/e-component-view.h
shell/e-corba-config-page.c
shell/e-corba-config-page.h
shell/e-shell-constants.h
shell/e-shell-settings-dialog.c
shell/e-shell-settings-dialog.h
shell/e-shell-window-commands.c
shell/e-shell-window.c
shell/e-shell.h
shell/e-sidebar.c
shell/e-sidebar.h
shell/e-user-creatable-items-handler.c
shell/e-user-creatable-items-handler.h
shell/es-menu.c
shell/es-menu.h
shell/evolution-component.h
shell/evolution-config-control.c
shell/evolution-config-control.h
shell/evolution-listener.c
shell/evolution-listener.h
shell/evolution-shell-component-utils.c
shell/evolution-shell-component-utils.h
shell/importer/evolution-importer-client.c
shell/importer/evolution-importer-client.h
shell/importer/evolution-importer-listener.c
shell/importer/evolution-importer-listener.h
shell/importer/evolution-importer.c
shell/importer/evolution-importer.h
shell/importer/evolution-intelligent-importer.c
shell/importer/evolution-intelligent-importer.h
shell/importer/intelligent.c
shell/main.c
shell/test/evolution-test-component.c
shell/test/evolution-test-component.h
widgets/menus/gal-view-instance.c
widgets/menus/gal-view-menus.c
widgets/menus/gal-view-menus.h
widgets/misc/Makefile.am
widgets/misc/e-activity-handler.c
widgets/misc/e-activity-handler.h
widgets/misc/e-charset-picker.c
widgets/misc/e-combo-button.c
widgets/misc/e-combo-button.h
widgets/misc/e-config-page.h
widgets/misc/e-dropdown-button.c
widgets/misc/e-dropdown-button.h
widgets/misc/e-filter-bar.c
widgets/misc/e-info-label.c
widgets/misc/e-info-label.h
widgets/misc/e-multi-config-dialog.c
widgets/misc/e-multi-config-dialog.h
widgets/misc/e-search-bar.c
widgets/misc/e-search-bar.h
widgets/misc/e-task-bar.c
widgets/misc/e-task-bar.h
widgets/misc/e-task-widget.c
widgets/misc/e-task-widget.h
widgets/misc/test-dropdown-button.c
widgets/misc/test-error.c
widgets/misc/test-info-label.c
widgets/table/e-table-example-1.c
Diffstat (limited to 'mail/e-mail-shell-migrate.c')
-rw-r--r-- | mail/e-mail-shell-migrate.c | 158 |
1 files changed, 137 insertions, 21 deletions
diff --git a/mail/e-mail-shell-migrate.c b/mail/e-mail-shell-migrate.c index 9a31f67820..6202224b0c 100644 --- a/mail/e-mail-shell-migrate.c +++ b/mail/e-mail-shell-migrate.c @@ -52,6 +52,7 @@ #include <libxml/xmlmemory.h> #include <e-util/e-util.h> +#include <libedataserver/e-xml-utils.h> #include <libedataserver/e-data-server-util.h> #include <e-util/e-xml-utils.h> @@ -354,7 +355,7 @@ parse_lsub (const char *lsub, char *dir_sep) static int comp; static regex_t pat; regmatch_t match[3]; - char *m = "^\\* LSUB \\([^)]*\\) \"?([^\" ]+)\"? \"?(.*)\"?$"; + const gchar *m = "^\\* LSUB \\([^)]*\\) \"?([^\" ]+)\"? \"?(.*)\"?$"; if (!comp) { if (regcomp (&pat, m, REG_EXTENDED|REG_ICASE) == -1) { @@ -947,8 +948,8 @@ static e_gconf_map_list_t gconf_remap_list[] = { }; static struct { - char *label; - char *colour; + const gchar *label; + const gchar *colour; } label_default[5] = { { N_("Important"), "#EF2929" }, /* red */ { N_("Work"), "#F57900" }, /* orange */ @@ -1095,9 +1096,10 @@ static GtkLabel *label; static GtkProgressBar *progress; static void -em_migrate_setup_progress_dialog (const char *desc) +em_migrate_setup_progress_dialog (const char *title, const char *desc) { GtkWidget *vbox, *hbox, *w; + gchar *markup; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title ((GtkWindow *) window, _("Migrating...")); @@ -1126,6 +1128,39 @@ em_migrate_setup_progress_dialog (const char *desc) gtk_widget_show ((GtkWidget *) progress); gtk_box_pack_start_defaults ((GtkBox *) hbox, (GtkWidget *) progress); + /* 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); } @@ -1259,7 +1294,7 @@ get_local_et_expanded (const char *dirname) static char * get_local_store_uri (const char *dirname, char **namep, int *indexp) { - char *protocol, *name, *metadata, *tmp; + gchar *name, *protocol, *metadata, *tmp; int index; struct stat st; xmlNodePtr node; @@ -1270,8 +1305,8 @@ get_local_store_uri (const char *dirname, char **namep, int *indexp) /* in 1.4, any errors are treated as defaults, this function cannot fail */ /* defaults */ - name = "mbox"; - protocol = "mbox"; + name = (gchar *) "mbox"; + protocol = (gchar *) "mbox"; index = TRUE; if (stat (metadata, &st) == -1 || !S_ISREG (st.st_mode)) @@ -1532,7 +1567,7 @@ em_migrate_folder(EMMigrateSession *session, const char *dirname, const char *fu /* Manually copy local mbox files, its much faster */ if (!strncmp (uri, "mbox:", 5)) { - static char *meta_ext[] = { ".summary", ".ibex.index", ".ibex.index.data" }; + static const gchar *meta_ext[] = { ".summary", ".ibex.index", ".ibex.index.data" }; size_t slen, dlen; FILE *fp; char *p; @@ -1778,9 +1813,11 @@ em_migrate_local_folders_1_4 (EMMigrateSession *session, GError **error) return FALSE; } - em_migrate_setup_progress_dialog (_("The location and hierarchy of the Evolution mailbox " - "folders has changed since Evolution 1.x.\n\nPlease be " - "patient while Evolution migrates your folders...")); + em_migrate_setup_progress_dialog ( + _("Migrating Folders"), + _("The location and hierarchy of the Evolution mailbox " + "folders has changed since Evolution 1.x.\n\nPlease be " + "patient while Evolution migrates your folders...")); while (success && (dent = readdir (dir))) { char *full_path; @@ -2762,20 +2799,53 @@ em_update_sa_junk_setting_2_23 (void) g_object_unref (client); } +static gboolean +update_progress_in_main_thread (double *progress) +{ + em_migrate_set_progress (*progress); + return FALSE; +} static void -migrate_folders(CamelStore *store, CamelFolderInfo *fi, const char *acc, CamelException *ex) +migrate_folders(CamelStore *store, gboolean is_local, CamelFolderInfo *fi, const char *acc, CamelException *ex, gboolean *done, int *nth_folder, int total_folders) { CamelFolder *folder; while (fi) { - char *tmp = g_strdup_printf ("%s/%s", acc, fi->full_name); + double progress; + char *tmp; + + *nth_folder = *nth_folder + 1; + + tmp = g_strdup_printf ("%s/%s", acc, fi->full_name); em_migrate_set_folder_name (tmp); g_free (tmp); - folder = camel_store_get_folder (store, fi->full_name, 0, ex); + + progress = (double) (*nth_folder) / total_folders; + g_idle_add ((GSourceFunc) update_progress_in_main_thread, &progress); + + if (is_local) + folder = camel_store_get_folder (store, fi->full_name, CAMEL_STORE_IS_MIGRATING, ex); + else + folder = camel_store_get_folder (store, fi->full_name, 0, ex); + if (folder != NULL) camel_folder_summary_migrate_infos (folder->summary); - migrate_folders(store, fi->child, acc, ex); + migrate_folders(store, is_local, fi->child, acc, ex, done, nth_folder, total_folders); + fi = fi->next; + } + + if ((*nth_folder) == (total_folders - 1)) + *done = TRUE; +} + +/* This could be in CamelStore.ch */ +static void +count_folders (CamelFolderInfo *fi, int *count) +{ + while (fi) { + *count = *count + 1; + count_folders (fi->child, count); fi = fi->next; } } @@ -2799,8 +2869,27 @@ setup_local_store (EShellBackend *shell_backend, g_free(tmp); return store; +} + +struct migrate_folders_to_db_structure { + char *account_name; + CamelException ex; + 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) +{ + int 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->ex), &(migrate_dbs->done), + &nth_folder, num_of_folders); } + static void migrate_to_db (EShellBackend *shell_backend) { @@ -2821,15 +2910,32 @@ migrate_to_db (EShellBackend *shell_backend) data_dir = e_shell_backend_get_data_dir (shell_backend); session = (EMMigrateSession *) em_migrate_session_new (data_dir); camel_session_set_online ((CamelSession *) session, FALSE); - em_migrate_setup_progress_dialog (_("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_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 ( (double)i/(len+1)); store = setup_local_store (shell_backend, session); info = camel_store_get_folder_info (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST|CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, NULL); if (info) { - migrate_folders(store, info, _("On This Computer"), NULL); + GThread *thread; + struct migrate_folders_to_db_structure migrate_dbs; + + if (g_str_has_suffix (((CamelService *)store)->url->path, ".evolution/mail/local")) + migrate_dbs.is_local_store = TRUE; + else + migrate_dbs.is_local_store = FALSE; + camel_exception_init (&migrate_dbs.ex); + migrate_dbs.account_name = _("On This Computer"); + migrate_dbs.info = info; + migrate_dbs.store = store; + migrate_dbs.done = FALSE; + + thread = 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 ( (double)i/(len+1)); @@ -2859,8 +2965,18 @@ migrate_to_db (EShellBackend *shell_backend) store = (CamelStore *) camel_session_get_service (CAMEL_SESSION (session), service->url, CAMEL_PROVIDER_STORE, &ex); info = camel_store_get_folder_info (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST|CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, &ex); if (info) { - migrate_folders(store, info, account->name, &ex); - + GThread *thread; + struct migrate_folders_to_db_structure migrate_dbs; + + migrate_dbs.ex = ex; + migrate_dbs.account_name = account->name; + migrate_dbs.info = info; + migrate_dbs.store = store; + migrate_dbs.done = FALSE; + + thread = 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); camel_exception_clear(&ex); |