diff options
Diffstat (limited to 'shell/e-setup.c')
-rw-r--r-- | shell/e-setup.c | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/shell/e-setup.c b/shell/e-setup.c index ee39f0d398..d9fc75f1dd 100644 --- a/shell/e-setup.c +++ b/shell/e-setup.c @@ -46,7 +46,7 @@ check_dir_recur (const char *evolution_directory, DIR *def; GList *newfiles = NULL; struct dirent *current; - + def = opendir (current_directory); if (def == NULL) return NULL; @@ -55,22 +55,22 @@ check_dir_recur (const char *evolution_directory, while (current != NULL) { struct stat buf; char *fullname, *fulldefaultname; - - fullname = g_concat_dir_and_file (evolution_directory, - current->d_name); - fulldefaultname = g_concat_dir_and_file (current_directory, - current->d_name); - if (current->d_name[0] == '.' && - (current->d_name[1] == '\0' || + if (current->d_name[0] == '.' && + (current->d_name[1] == '\0' || (current->d_name[1] == '.' && current->d_name[2] == '\0'))) { current = readdir (def); continue; } + fullname = g_concat_dir_and_file (evolution_directory, + current->d_name); + fulldefaultname = g_concat_dir_and_file (current_directory, + current->d_name); + if (stat (fullname, &buf) == -1) { char *name; - + name = g_strdup (fulldefaultname); newfiles = g_list_append (newfiles, name); } else { @@ -80,7 +80,7 @@ check_dir_recur (const char *evolution_directory, fulldefaultname)); } } - + g_free (fulldefaultname); g_free (fullname); current = readdir (def); @@ -103,27 +103,31 @@ check_evolution_directory (const char *evolution_directory) defaultdir = g_strdup (EVOLUTION_DATADIR "/evolution/default_user"); newfiles = g_list_concat (NULL, check_dir_recur (evolution_directory, defaultdir)); - - if (newfiles == NULL) - return TRUE; + + if (newfiles == NULL) { + retval = TRUE; + goto out; + } dialog = gnome_dialog_new (_("Evolution installation"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); - + label1 = gtk_label_new (_("This new version of Evolution needs to install additional files\ninto your personal Evolution directory")); label2 = gtk_label_new (_("Please click \"OK\" to install the files, or \"Cancel\" to exit.")); - + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label1, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label2, TRUE, TRUE, 0); - + gtk_widget_show (label1); gtk_widget_show (label2); result = gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); - if (result != 0) - return FALSE; + if (result != 0) { + retval = FALSE; + goto out; + } retval = TRUE; for (l = newfiles; l; l = l->next) { @@ -136,34 +140,34 @@ check_evolution_directory (const char *evolution_directory) evolution_directory, "/", shortpath, NULL); - + if (system (command) != 0) { retval = FALSE; } else { retval = (retval && TRUE); } - + g_free (command); - - g_free (l->data); } - g_list_free (newfiles); - g_free (defaultdir); - - if (retval == FALSE) { + if (retval == FALSE) e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, _("Could not update files correctly")); - return FALSE; - } else { + else e_notice (NULL, GNOME_MESSAGE_BOX_INFO, _("Evolution files successfully installed.")); - return TRUE; - } - return TRUE; + out: + + for (l = newfiles; l; l = l->next) + g_free (l->data); + + g_list_free (newfiles); + g_free (defaultdir); + + return retval; } - + static gboolean copy_default_stuff (const char *evolution_directory) |