From 70a6a65a5607ab0003c25bd64a4338baa47d1dd5 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 25 Sep 2001 20:16:14 +0000 Subject: Throw up a warning dialog if we suspect the config database is corrupt. 2001-09-25 Jeffrey Stedfast * component-factory.c (owner_set_cb): Throw up a warning dialog if we suspect the config database is corrupt. * mail-config.c (config_read): If the account name is NULL, then we have a corrupt config database most likely - so generate a fake account name and set the corrupt but to TRUE. (mail_config_is_corrupt): New function to find out if the config is suspected of being corrupted. svn path=/trunk/; revision=13116 --- mail/ChangeLog | 18 +++++++++++++++--- mail/component-factory.c | 18 +++++++++++++++++- mail/mail-config.c | 25 ++++++++++++++++++++----- mail/mail-config.h | 1 + 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 12b080bb2f..37bbec983f 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,11 +1,23 @@ +2001-09-25 Jeffrey Stedfast + + * component-factory.c (owner_set_cb): Throw up a warning dialog if + we suspect the config database is corrupt. + + * mail-config.c (config_read): If the account name is NULL, then + we have a corrupt config database most likely - so generate a fake + account name and set the corrupt but to TRUE. + (mail_config_is_corrupt): New function to find out if the config + is suspected of being corrupted. + 2001-09-25 Iain Holmes - * mail-config.c (impl_GNOME_Evolution_MailConfig_addAccount): Check - if the transport is NULL. + * mail-config.c (impl_GNOME_Evolution_MailConfig_addAccount): + Check if the transport is NULL. 2001-09-25 Iain Holmes - * mail-display.c (link_menu): Remove the Save Link as (FIXME) item. + * mail-display.c (link_menu): Remove the Save Link as (FIXME) + item. 2001-09-25 Jeffrey Stedfast diff --git a/mail/component-factory.c b/mail/component-factory.c index 87f4fadbc2..cddf142891 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -635,6 +635,12 @@ shell_client_destroy (GtkObject *object) global_shell_client = NULL; } +static void +warning_clicked (GtkWidget *dialog, gpointer user_data) +{ + gtk_widget_destroy (dialog); +} + static void owner_set_cb (EvolutionShellComponent *shell_component, EvolutionShellClient *shell_client, @@ -679,10 +685,20 @@ owner_set_cb (EvolutionShellComponent *shell_component, } mail_session_enable_interaction (TRUE); - + vfolder_load_storage(corba_shell); mail_autoreceive_setup (); + + if (mail_config_is_corrupt ()) { + GtkWidget *dialog; + + dialog = gnome_warning_dialog (_("Some of your mail settings seem corrupt, " + "please check that everything is in order.")); + gtk_signal_connect (GTK_OBJECT (dialog), "clicked", warning_clicked, NULL); + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + gtk_widget_show (dialog); + } } static void diff --git a/mail/mail-config.c b/mail/mail-config.c index 115e1d0d28..0eef9edf16 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -58,6 +58,8 @@ typedef struct { Bonobo_ConfigDatabase db; + gboolean corrupt; + gboolean show_preview; gboolean thread_list; gboolean hide_deleted; @@ -284,7 +286,7 @@ mail_config_clear (void) static void config_read (void) { - gint len, i, default_num; + int len, i, default_num; mail_config_clear (); @@ -296,12 +298,19 @@ config_read (void) MailConfigIdentity *id; MailConfigService *source; MailConfigService *transport; - gchar *path, *val; + char *path, *val; account = g_new0 (MailConfigAccount, 1); path = g_strdup_printf ("/Mail/Accounts/account_name_%d", i); - account->name = bonobo_config_get_string (config->db, path, NULL); + val = bonobo_config_get_string (config->db, path, NULL); g_free (path); + if (val && *val) { + account->name = val; + } else { + g_free (val); + account->name = g_strdup_printf (_("Account %d"), i + 1); + config->corrupt = TRUE; + } path = g_strdup_printf ("/Mail/Accounts/account_drafts_folder_name_%d", i); val = bonobo_config_get_string (config->db, path, NULL); @@ -593,7 +602,7 @@ void mail_config_write (void) { CORBA_Environment ev; - gint len, i, default_num; + int len, i, default_num; /* Accounts */ @@ -617,7 +626,7 @@ mail_config_write (void) for (i = 0; i < len; i++) { MailConfigAccount *account; - gchar *path; + char *path; account = g_slist_nth_data (config->accounts, i); @@ -903,6 +912,12 @@ mail_config_is_configured (void) return config->accounts != NULL; } +gboolean +mail_config_is_corrupt (void) +{ + return config->corrupt; +} + static char * uri_to_key (const char *uri) { diff --git a/mail/mail-config.h b/mail/mail-config.h index 10bce30d07..141c2bba22 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -106,6 +106,7 @@ void mail_config_write_on_exit (void); /* General Accessor functions */ gboolean mail_config_is_configured (void); +gboolean mail_config_is_corrupt (void); gboolean mail_config_get_filter_log (void); void mail_config_set_filter_log (gboolean value); -- cgit v1.2.3