diff options
author | Srinivasa Ragavan <sragavan@src.gnome.org> | 2007-04-13 02:15:50 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2007-04-13 02:15:50 +0800 |
commit | 12591b12bf768a2df582b6369e3534ea85a749e6 (patch) | |
tree | 803ce32b469906e056b98c63ca99adad82362593 | |
parent | 4a67e80dce6d56d36b935d3369e01d70fc7bdbf2 (diff) | |
download | gsoc2013-evolution-12591b12bf768a2df582b6369e3534ea85a749e6.tar.gz gsoc2013-evolution-12591b12bf768a2df582b6369e3534ea85a749e6.tar.zst gsoc2013-evolution-12591b12bf768a2df582b6369e3534ea85a749e6.zip |
Reworked Backup/restore plugin.
svn path=/trunk/; revision=33422
-rw-r--r-- | plugins/backup-restore/ChangeLog | 18 | ||||
-rw-r--r-- | plugins/backup-restore/Makefile.am | 13 | ||||
-rw-r--r-- | plugins/backup-restore/backup-restore.c | 231 | ||||
-rw-r--r-- | plugins/backup-restore/backup.c | 180 | ||||
-rw-r--r-- | plugins/backup-restore/org-gnome-backup-restore.eplug.xml | 5 | ||||
-rw-r--r-- | plugins/backup-restore/org-gnome-backup-restore.error.xml | 20 | ||||
-rw-r--r-- | plugins/backup-restore/org-gnome-backup-restore.xml | 4 |
7 files changed, 417 insertions, 54 deletions
diff --git a/plugins/backup-restore/ChangeLog b/plugins/backup-restore/ChangeLog index d9a67544ca..880fdf7d65 100644 --- a/plugins/backup-restore/ChangeLog +++ b/plugins/backup-restore/ChangeLog @@ -1,3 +1,21 @@ +2007-04-12 Srinivasa Ragavan <sragavan@novell.com> + + ** Reworked Backup/Restore plugin. It comes in File menu for + backup/restore. It also provides a option to restore, while setting up + a new account. Option added to show GUI progress for backup/restore. + + * Makefile.am: Added error file to build. + * backup-restore.c: (backup), (restore), (sanity_check), + (dialog_prompt_user), (org_gnome_backup_restore_backup), + (org_gnome_backup_restore_restore), (check_toggled), + (restore_wizard), (file_changed), (backup_restore_page), + (backup_restore_commit), (backup_restore_abort): + * backup.c: (backup), (restore), (check), (pbar_update), + (thread_start), (idle_cb), (dlg_response), (main): + * org-gnome-backup-restore.eplug.xml: + * org-gnome-backup-restore.error.xml: + * org-gnome-backup-restore.xml: + 2007-04-02 Sankar P <psankar@novell.com> * Committed on behalf of Gilles Dartiguelongue <dartigug@esiee.fr> diff --git a/plugins/backup-restore/Makefile.am b/plugins/backup-restore/Makefile.am index 0125af5c0f..251da8b1dd 100644 --- a/plugins/backup-restore/Makefile.am +++ b/plugins/backup-restore/Makefile.am @@ -11,19 +11,24 @@ INCLUDES = \ @EVO_PLUGIN_RULE@ +error_DATA = org-gnome-backup-restore.error +errordir = $(privdatadir)/errors + plugin_DATA = org-gnome-backup-restore.eplug org-gnome-backup-restore.xml plugin_LTLIBRARIES = liborg-gnome-backup-restore.la liborg_gnome_backup_restore_la_SOURCES = backup-restore.c liborg_gnome_backup_restore_la_LDFLAGS = -module -avoid-version -privlibexec_PROGRAMS = backup -backup_SOURCES = backup.c -backup_LDADD = $(SHELL_LIBS) +privlibexec_PROGRAMS = evolution-backup +evolution_backup_SOURCES = backup.c +evolution_backup_LDADD = $(SHELL_LIBS) EXTRA_DIST = \ org-gnome-backup-restore.eplug.xml \ + org-gnome-backup-restore.error.xml \ org-gnome-backup-restore.xml -BUILT_SOURCES = org-gnome-backup-restore.eplug +BUILT_SOURCES = org-gnome-backup-restore.eplug \ + org-gnome-backup-restore.error CLEANFILES = $(BUILT_SOURCES) diff --git a/plugins/backup-restore/backup-restore.c b/plugins/backup-restore/backup-restore.c index 31b69d9915..7adc48b092 100644 --- a/plugins/backup-restore/backup-restore.c +++ b/plugins/backup-restore/backup-restore.c @@ -3,27 +3,41 @@ #include <sys/wait.h> #include <gtk/gtk.h> #include <glib/gi18n.h> +#include <libgnomeui/libgnomeui.h> #include "shell/es-menu.h" +#include "mail/em-config.h" +#include "mail/em-account-editor.h" +#include "e-util/e-error.h" +#include "e-util/e-util.h" +#include "e-util/e-dialog-utils.h" void org_gnome_backup_restore_backup (EPlugin *ep, ESMenuTargetShell *target); void org_gnome_backup_restore_restore (EPlugin *ep, ESMenuTargetShell *target); +GtkWidget * backup_restore_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data); +void backup_restore_commit (EPlugin *ep, EMConfigTargetAccount *target); +void backup_restore_abort (EPlugin *ep, EMConfigTargetAccount *target); + +typedef enum _br_flags { + BR_OK = 1<<0, + BR_START = 1<<1, +}br_flags; static void backup (const char *filename, gboolean restart) { if (restart) - execl (EVOLUTION_TOOLSDIR "/backup", "backup", "--backup", "--restart", filename, NULL); + execl (EVOLUTION_TOOLSDIR "/evolution-backup", "evolution-backup", "--gui", "--backup", "--restart", filename, NULL); else - execl (EVOLUTION_TOOLSDIR "/backup", "backup", "--backup", filename, NULL); + execl (EVOLUTION_TOOLSDIR "/evolution-backup", "evolution-backup", "--gui", "--backup", filename, NULL); } static void restore (const char *filename, gboolean restart) { if (restart) - execl (EVOLUTION_TOOLSDIR "/backup", "backup", "--restore", "--restart", filename, NULL); + execl (EVOLUTION_TOOLSDIR "/evolution-backup", "evolution-backup", "--gui", "--restore", "--restart", filename, NULL); else - execl (EVOLUTION_TOOLSDIR "/backup", "backup", "--restore", filename, NULL); + execl (EVOLUTION_TOOLSDIR "/evolution-backup", "evolution-backup", "--gui", "--restore", filename, NULL); } static gboolean @@ -32,48 +46,84 @@ sanity_check (const char *filename) char *command; int result; - command = g_strdup_printf ("%s/backup --check %s", EVOLUTION_TOOLSDIR, filename); + command = g_strdup_printf ("%s/evolution-backup --check %s", EVOLUTION_TOOLSDIR, filename); result = system (command); g_free (command); - g_message ("Sanity check result %d:%d", WIFEXITED (result), WEXITSTATUS (result)); + g_message ("Sanity check result %d:%d %d", WIFEXITED (result), WEXITSTATUS (result), result); return WIFEXITED (result) && (WEXITSTATUS (result) == 0); } +static guint32 +dialog_prompt_user(GtkWindow *parent, const char *string, const char *tag, const char *arg0, ...) +{ + GtkWidget *mbox, *check = NULL; + va_list ap; + int button; + guint32 mask = 0; + + va_start(ap, arg0); + mbox = e_error_newv(parent, tag, arg0, ap); + va_end(ap); + + check = gtk_check_button_new_with_mnemonic (string); + /* We should hardcode this to true */ + gtk_toggle_button_set_active ((GtkToggleButton *)check, TRUE); + gtk_container_set_border_width((GtkContainer *)check, 12); + gtk_box_pack_start ((GtkBox *)((GtkDialog *) mbox)->vbox, check, TRUE, TRUE, 0); + gtk_widget_show (check); + + button = gtk_dialog_run ((GtkDialog *) mbox); + + if (button == GTK_RESPONSE_YES) + mask |= BR_OK; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) + mask |= BR_START; + + gtk_widget_destroy(mbox); + + return mask; +} + void org_gnome_backup_restore_backup (EPlugin *ep, ESMenuTargetShell *target) { GtkWidget *dlg; - GtkWidget *vbox, *check; + GtkWidget *vbox; int response; - - dlg = gtk_file_chooser_dialog_new (_("Select name of Evolution archive"), GTK_WINDOW (target->target.widget), - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL); + + dlg = e_file_get_save_filesel(target->target.widget, _("Select name of the Evolution archive"), NULL, GTK_FILE_CHOOSER_ACTION_SAVE); + +/* dlg = gtk_file_chooser_dialog_new (_("Select name of the Evolution archive"), GTK_WINDOW (target->target.widget), */ +/* GTK_FILE_CHOOSER_ACTION_SAVE, */ +/* GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, */ +/* GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL); */ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dlg), "evolution-backup.tar.gz"); vbox = gtk_vbox_new (FALSE, 6); gtk_widget_show (vbox); - check = gtk_check_button_new_with_mnemonic (_("_Restart Evolution after backup")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE); - gtk_widget_show (check); - - gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, TRUE, 0); - gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dlg), vbox); - response = gtk_dialog_run (GTK_DIALOG (dlg)); if (response == GTK_RESPONSE_OK) { char *filename; + guint32 mask; + char *uri = NULL; + uri = gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER (dlg)); + e_file_update_save_path(uri, TRUE); + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg)); - - backup (filename, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check))); + gtk_widget_destroy (dlg); + + mask = dialog_prompt_user (GTK_WINDOW (target->target.widget), _("_Restart Evolution after backup"), "org.gnome.backup-restore:backup-confirm", NULL); + if (mask & BR_OK) + backup (filename, (mask & BR_START) ? TRUE: FALSE); g_free (filename); + + return; } gtk_widget_destroy (dlg); @@ -83,40 +133,149 @@ void org_gnome_backup_restore_restore (EPlugin *ep, ESMenuTargetShell *target) { GtkWidget *dlg; - GtkWidget *vbox, *check; + GtkWidget *vbox; int response; - - dlg = gtk_file_chooser_dialog_new (_("Select Evolution archive to restore"), GTK_WINDOW (target->target.widget), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL); + + dlg = e_file_get_save_filesel(target->target.widget, _("Select name of the Evolution archive to restore"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN); + +/* dlg = gtk_file_chooser_dialog_new (_("Select Evolution archive to restore"), GTK_WINDOW (target->target.widget), */ +/* GTK_FILE_CHOOSER_ACTION_OPEN, */ +/* GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, */ +/* GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL); */ vbox = gtk_vbox_new (FALSE, 6); gtk_widget_show (vbox); - check = gtk_check_button_new_with_mnemonic (_("_Restart Evolution after restore")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE); - gtk_widget_show (check); - - gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, TRUE, 0); - gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dlg), vbox); - response = gtk_dialog_run (GTK_DIALOG (dlg)); if (response == GTK_RESPONSE_OK) { char *filename; + char *uri = NULL; + uri = gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER (dlg)); + e_file_update_save_path(uri, TRUE); + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg)); + gtk_widget_destroy (dlg); if (sanity_check (filename)) { - restore (filename, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check))); + guint32 mask; + + mask = dialog_prompt_user (GTK_WINDOW (target->target.widget), _("_Restart Evolution after restore"), "org.gnome.backup-restore:backup-confirm", NULL); + if (mask & BR_OK) + restore (filename, mask & BR_START); } else { - g_message ("Invalid archive"); + e_error_run (GTK_WINDOW (target->target.widget), "org.gnome.backup-restore:invalid-archive", NULL); } g_free (filename); + + return; } gtk_widget_destroy (dlg); } +static void +check_toggled (GtkToggleButton *button, GnomeDruid *druid) +{ + GtkWidget *box = g_object_get_data ((GObject *)button, "box"); + gboolean state = gtk_toggle_button_get_active ((GtkToggleButton *)button); + char *prevfile = g_object_get_data ((GObject *)druid, "restore-file"); + + gtk_widget_set_sensitive (box, state); + gnome_druid_set_show_finish (druid, state); + if (state && !prevfile) + gnome_druid_set_buttons_sensitive (druid, TRUE, FALSE, TRUE, TRUE); + else + gnome_druid_set_buttons_sensitive (druid, TRUE, TRUE, TRUE, TRUE); + + g_object_set_data ((GObject *)druid, "restore", GINT_TO_POINTER (state?1:0)); + +} + +static void +restore_wizard (GnomeDruidPage *druidpage, GnomeDruid *druid, gpointer user_data) +{ + gboolean state = GPOINTER_TO_INT(g_object_get_data((GObject *)druid, "restore")) ? TRUE:FALSE; + char *file = g_object_get_data ((GObject *)druid, "restore-file"); + + if (state) { + if (!file ||!sanity_check (file)) { + e_error_run ((GtkWindow *)druid, "org.gnome.backup-restore:invalid-archive", NULL); + } else + restore (file, TRUE); + + } +} + +static void +file_changed (GtkFileChooser *chooser, GnomeDruid *druid) +{ + char *file = NULL, *prevfile=NULL; + char *uri = NULL; + + uri = gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER (chooser)); + e_file_update_save_path(uri, TRUE); + + file = gtk_file_chooser_get_filename (chooser); + prevfile = g_object_get_data ((GObject *)druid, "restore-file"); + g_object_set_data ((GObject *)druid, "restore-file", file); + g_free (prevfile); + if (file) { + gnome_druid_set_buttons_sensitive (druid, TRUE, TRUE, TRUE, TRUE); + } else + gnome_druid_set_buttons_sensitive (druid, TRUE, FALSE, TRUE, TRUE); + +} +GtkWidget * +backup_restore_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data) +{ + GtkWidget *page; + GtkWidget *box, *hbox, *label, *cbox, *button; + + page = gnome_druid_page_standard_new_with_vals (_("Restore from backup"), NULL, NULL); + hbox = gtk_hbox_new (FALSE, 6); + label = gtk_label_new (_("You can restore Evolution from your archive. It can restore all the Mails/Calendars/Tasks/Memos/Addressbook. \nIt also restores all your personal settings, mail filters etc.")); + gtk_box_pack_start ((GtkBox *)hbox, label, FALSE, FALSE, 6); + box = gtk_vbox_new (FALSE, 6); + gtk_box_pack_start ((GtkBox *)box, hbox, FALSE, FALSE, 0); + + hbox = gtk_hbox_new (FALSE, 6); + cbox = gtk_check_button_new_with_mnemonic (_("_Restore Evolution from the backup archive")); + g_signal_connect (cbox, "toggled", G_CALLBACK (check_toggled), hook_data->parent); + gtk_box_pack_start ((GtkBox *)hbox, cbox, FALSE, FALSE, 6); + gtk_box_pack_start ((GtkBox *)box, hbox, FALSE, FALSE, 0); + + hbox = gtk_hbox_new (FALSE, 6); + g_object_set_data ((GObject *)cbox, "box", hbox); + label = gtk_label_new (_("Please select an Evolution Archive to restore:")); + gtk_box_pack_start ((GtkBox *)hbox, label, FALSE, FALSE, 12); + + button = gtk_file_chooser_button_new (_("Choose a file to restore"), GTK_FILE_CHOOSER_ACTION_OPEN); + g_signal_connect (button, "selection-changed", G_CALLBACK (file_changed), hook_data->parent); + gtk_file_chooser_button_set_width_chars ((GtkFileChooserButton *)button, 20); + gtk_box_pack_start ((GtkBox *)hbox, button, FALSE, FALSE, 0); + gtk_box_pack_start ((GtkBox *)box, hbox, FALSE, FALSE, 0); + gtk_widget_set_sensitive (hbox, FALSE); + + + gtk_container_add ((GtkContainer *) GNOME_DRUID_PAGE_STANDARD (page)->vbox, box); + gtk_widget_show_all (box); + gnome_druid_append_page (GNOME_DRUID (hook_data->parent), GNOME_DRUID_PAGE (page)); + g_object_set_data ((GObject *)hook_data->parent, "restore", GINT_TO_POINTER (FALSE)); + g_signal_connect (page, "finish", G_CALLBACK (restore_wizard), NULL); + return GTK_WIDGET (page); +} +void +backup_restore_commit (EPlugin *ep, EMConfigTargetAccount *target) +{ + /* Nothing really */ + printf("commit\n"); +} + +void +backup_restore_abort (EPlugin *ep, EMConfigTargetAccount *target) +{ + /* Nothing really */ +} diff --git a/plugins/backup-restore/backup.c b/plugins/backup-restore/backup.c index dab7bbd35a..4438e0c1c4 100644 --- a/plugins/backup-restore/backup.c +++ b/plugins/backup-restore/backup.c @@ -9,6 +9,7 @@ #include <sys/wait.h> #include <glib/gi18n.h> +#include <gtk/gtk.h> #include <libgnome/gnome-util.h> #define EVOLUTION "evolution-" BASE_VERSION @@ -20,35 +21,63 @@ #define ARCHIVE_NAME "evolution-backup.tar.gz" static gboolean backup_op = FALSE; +static char *bk_file; static gboolean restore_op = FALSE; +static char *res_file; static gboolean check_op = FALSE; +static char *chk_file; static gboolean restart_arg = FALSE; +static gboolean gui_arg = FALSE; +static int result=0; +static GtkWidget *progress_dialog; +static GtkWidget *pbar; +static char *txt = NULL; +gboolean complete = FALSE; #define d(x) x /* #define s(x) system (x) */ #define s(x) G_STMT_START { g_message (x); system (x); } G_STMT_END +#define CANCEL(x) if (x) return; + static void backup (const char *filename) { char *command; - + + CANCEL (complete); + txt = _("Shutting down Evolution"); /* FIXME Will the versioned setting always work? */ s (EVOLUTION " --force-shutdown"); + CANCEL (complete); + txt = _("Backing Evolution accounts and settings"); s ("gconftool-2 --dump " GCONF_DIR " > " GCONF_DUMP_PATH); + + CANCEL (complete); + txt = _("Backing Evolution data (Mails, Contacts, Calendar, Tasks, Memos)"); + /* FIXME stay on this file system ,other options?" */ /* FIXME compression type?" */ /* FIXME date/time stamp?" */ /* FIXME archive location?" */ - command = g_strdup_printf ("cd ~ && tar zpcf %s .evolution", filename); + command = g_strdup_printf ("cd ~ && tar zpcf %s .evolution .camel_certs", filename); s (command); g_free (command); - if (restart_arg) + txt = _("Backup complete"); + + if (restart_arg) { + + CANCEL (complete); + txt = _("Restarting Evolution"); + complete=TRUE; + s (EVOLUTION); + } + } static void @@ -57,32 +86,49 @@ restore (const char *filename) char *command; /* FIXME Will the versioned setting always work? */ + CANCEL (complete); + txt = _("Shutting down Evolution"); s (EVOLUTION " --force-shutdown"); + CANCEL (complete); + txt = _("Backup current Evolution data"); s ("mv " EVOLUTION_DIR " " EVOLUTION_DIR_BACKUP); + s ("mv ~/.camel_certs ~/.camel_certs_old"); + CANCEL (complete); + txt = _("Extracting files from the archive"); command = g_strdup_printf ("cd ~ && tar zxf %s", filename); s (command); g_free (command); + CANCEL (complete); + txt = _("Loading Evolution settings"); s ("gconftool-2 --load " GCONF_DUMP_PATH); + + CANCEL (complete); + txt = _("Removing temporary backup files"); s ("rm -rf " GCONF_DUMP_PATH); s ("rm -rf " EVOLUTION_DIR_BACKUP); - - if (restart_arg) + s ("rm -rf ~/.camel_certs_old"); + + if (restart_arg) { + CANCEL (complete); + txt = _("Restarting Evolution"); + complete=TRUE; s (EVOLUTION); + } + } static void check (const char *filename) { char *command; - int result; command = g_strdup_printf ("tar ztf %s | grep -e \"^\\.evolution/$\"", filename); result = system (command); g_free (command); - + g_message ("First result %d", result); if (result) exit (result); @@ -93,9 +139,67 @@ check (const char *filename) g_message ("Second result %d", result); - exit (result); } +static gboolean +pbar_update() +{ + if (!complete) { + gtk_progress_bar_pulse ((GtkProgressBar *)pbar); + gtk_progress_bar_set_text ((GtkProgressBar *)pbar, txt); + return TRUE; + } + + gtk_main_quit (); + return FALSE; +} + +static gpointer +thread_start (gpointer data) +{ + if (backup_op) + backup (bk_file); + else if (restore_op) + restore (res_file); + else if (check_op) + check (chk_file); + + complete = TRUE; + + return GINT_TO_POINTER(result); +} + +static gboolean +idle_cb(gpointer data) +{ + GThread *t; + + if (gui_arg) { + /* Show progress dialog */ + gtk_progress_bar_pulse ((GtkProgressBar *)pbar); + g_timeout_add (50, pbar_update, NULL); + } + + t = g_thread_create (thread_start, NULL, FALSE, NULL); + + return FALSE; +} + +static void +dlg_response (GtkWidget *dlg, gint response, gpointer data) +{ + /* We will cancel only backup/restore operations and not the check operation */ + complete = TRUE; + + /* If the response is not of delete_event then destroy the event */ + if (response != GTK_RESPONSE_NONE) + gtk_widget_destroy (dlg); + + /* We will kill just the tar operation. Rest of the them will be just a second of microseconds.*/ + s ("pkill tar"); + + gtk_main_quit (); +} int main (int argc, char **argv) { @@ -103,6 +207,7 @@ main (int argc, char **argv) GnomeProgram *program; poptContext popt_context; const char **args; + char *file = NULL, *oper = NULL; struct poptOption options[] = { { "backup", '\0', POPT_ARG_NONE, &backup_op, 0, @@ -113,9 +218,12 @@ main (int argc, char **argv) N_("Check Evolution archive"), NULL }, { "restart", '\0', POPT_ARG_NONE, &restart_arg, 0, N_("Restart Evolution"), NULL }, + { "gui", '\0', POPT_ARG_NONE, &gui_arg, 0, + N_("With GUI"), NULL }, { NULL, '\0', 0, NULL, 0, NULL, NULL } }; + gtk_init (&argc, &argv); bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); @@ -130,24 +238,72 @@ main (int argc, char **argv) popt_context = g_value_get_pointer (&popt_context_value); args = poptGetArgs (popt_context); + if (args != NULL) { const char **p; for (p = args; *p != NULL; p++) { if (backup_op) { + oper = _("Backing up to %s"); d(g_message ("Backing up to %s", (char *) *p)); - backup ((char *) *p); + bk_file = g_strdup ((char *) *p); + file = bk_file; } else if (restore_op) { + oper = _("Restoring from %s"); d(g_message ("Restoring from %s", (char *) *p)); - restore ((char *) *p); + res_file = g_strdup ((char *) *p); + file = res_file; } else if (check_op) { d(g_message ("Checking %s", (char *) *p)); - check ((char *) *p); + chk_file = g_strdup ((char *) *p); } } } + if (gui_arg) { + GtkWidget *vbox, *hbox, *label; + char *str=NULL; + + /* Backup / Restore only can have GUI. We should restrict the rest */ + progress_dialog = gtk_dialog_new_with_buttons (backup_op ? _("Evolution Backup"): _("Evolution Restore"), + NULL, + GTK_DIALOG_MODAL, + GTK_STOCK_CANCEL, + GTK_RESPONSE_REJECT, + NULL); + if (oper && file) + str = g_strdup_printf(oper, file); + + vbox = gtk_vbox_new (FALSE, 6); + if (str) { + hbox = gtk_hbox_new (FALSE, 12); + label = gtk_label_new (str); + g_free (str); + gtk_box_pack_start ((GtkBox *)hbox, label, FALSE, FALSE, 6); + gtk_box_pack_start ((GtkBox *)vbox, hbox, FALSE, FALSE, 6); + } + hbox = gtk_hbox_new (FALSE, 12); + pbar = gtk_progress_bar_new (); + gtk_box_pack_start ((GtkBox *)hbox, pbar, TRUE, TRUE, 6); + + + + gtk_box_pack_start ((GtkBox *)vbox, hbox, FALSE, FALSE, 0); + + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(progress_dialog)->vbox), vbox); + gtk_window_set_default_size ((GtkWindow *) progress_dialog,450, 120); + g_signal_connect (progress_dialog, "response", G_CALLBACK(dlg_response), NULL); + gtk_widget_show_all (progress_dialog); + } else if (check_op) { + /* For sanity we don't need gui */ + check (chk_file); + exit (result); + } + + g_idle_add (idle_cb, NULL); + gtk_main (); + g_value_unset (&popt_context_value); - return 0; + return result; } diff --git a/plugins/backup-restore/org-gnome-backup-restore.eplug.xml b/plugins/backup-restore/org-gnome-backup-restore.eplug.xml index b06ed34f67..2b294d5353 100644 --- a/plugins/backup-restore/org-gnome-backup-restore.eplug.xml +++ b/plugins/backup-restore/org-gnome-backup-restore.eplug.xml @@ -29,6 +29,11 @@ </menu> </hook> + <hook class="org.gnome.evolution.mail.config:1.0"> + <group target="account" id="org.gnome.evolution.mail.config.accountWizard" commit="backup_restore_commit" abort="backup_restore_abort"> + <item type="page" path="0.startup_page.10" factory="backup_restore_page"/> + </group> + </hook> </e-plugin> </e-plugin-list> diff --git a/plugins/backup-restore/org-gnome-backup-restore.error.xml b/plugins/backup-restore/org-gnome-backup-restore.error.xml new file mode 100644 index 0000000000..ae21cb912d --- /dev/null +++ b/plugins/backup-restore/org-gnome-backup-restore.error.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<error-list domain="org.gnome.backup-restore"> + + <error id="invalid-archive" type="warning"> + <_title>Invalid Evolution archive</_title> + <_secondary>Please select a valid archive file to restore.</_secondary> + </error> + <error id="backup-confirm" type="warning" default="GTK_RESPONSE_NO"> + <_primary>Are you sure you want to close Evolution?</_primary> + <_secondary xml:space="preserve">Evolution backup can start only when Evolution is not running. Please make sure that you save and close all your unsaved windows before proceeding. If you want Evolution to restart automatically after backup, please enable the toggle button.</_secondary> + <button stock="gtk-no" response="GTK_RESPONSE_NO"/> + <button stock="gtk-yes" response="GTK_RESPONSE_YES"/> + </error> + <error id="restore-confirm" type="warning" default="GTK_RESPONSE_NO"> + <_primary>Are you sure you want to restore Evolution from the selected archive?</_primary> + <_secondary xml:space="preserve">This will delete all your current Evolution data and settings and restore them from your backup. Evolution restore can start only when Evolution is not running. Please make sure that you close all your unsaved windows before you proceed. If you want Evolution to restart automatically restart after restore, please enable the toggle button.</_secondary> + <button stock="gtk-no" response="GTK_RESPONSE_NO"/> + <button stock="gtk-yes" response="GTK_RESPONSE_YES"/> + </error> +</error-list> diff --git a/plugins/backup-restore/org-gnome-backup-restore.xml b/plugins/backup-restore/org-gnome-backup-restore.xml index 9af58343d1..e546ce5581 100644 --- a/plugins/backup-restore/org-gnome-backup-restore.xml +++ b/plugins/backup-restore/org-gnome-backup-restore.xml @@ -1,10 +1,10 @@ <Root> <commands> - <cmd name="EPBRBackup" _label="Backup Settings..." + <cmd name="EPBRBackup" _label="_Backup Settings..." _tip="Backup and restore Evolution data and settings" pixtype="pixmap"/> - <cmd name="EPBRRestore" _label="Restore Settings..." + <cmd name="EPBRRestore" _label="R_estore Settings..." _tip="Backup and restore Evolution data and settings" pixtype="pixmap"/> |