From 2b60e44890dc2bb86310e4d6699372c3c5ac2833 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 3 Aug 2000 21:49:11 +0000 Subject: set config = NULL (provider_list) Eek! Initialize news to NULL! Also, use 2000-08-03 Jeffrey Stedfast * mail-config.c: set config = NULL (provider_list) Eek! Initialize news to NULL! Also, use g_slist_prepend() for "performance" gains ;-) (init_config): Set the config member data to NULL just to be on the safe side (clear_config): Don't bother freeing slist data if the slist is NULL svn path=/trunk/; revision=4517 --- mail/mail-config.c | 72 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 29 deletions(-) (limited to 'mail/mail-config.c') diff --git a/mail/mail-config.c b/mail/mail-config.c index 73c081ea4b..bcc3327460 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -162,7 +162,7 @@ typedef struct } MailDialog; static const char GCONFPATH[] = "/apps/Evolution/Mail"; -static MailConfig *config; +static MailConfig *config = NULL; /* private prototypes - these are ugly, rename some of them? */ static void html_size_req (GtkWidget *widget, GtkRequisition *requisition); @@ -303,7 +303,7 @@ provider_list_add (GSList *services, CamelProviderType type, mcs->authtypes = camel_service_query_auth_types (mcs->service, ex); camel_exception_free (ex); - return g_slist_append (services, mcs); + return g_slist_prepend (services, mcs); } static void @@ -313,7 +313,7 @@ provider_list (GSList **sources, GSList **news, GSList **transports) /* Fetch list of all providers. */ providers = camel_session_list_providers (session, TRUE); - *sources = *transports = NULL; + *sources = *transports = *news = NULL; for (p = providers; p; p = p->next) { CamelProvider *prov = p->data; @@ -430,6 +430,10 @@ init_config () return; config = g_new0 (MailConfig, 1); + + config->ids = NULL; + config->sources = NULL; + config->transport = NULL; } static void @@ -437,15 +441,19 @@ clear_config () { if (!config) return; - - g_slist_foreach (config->ids, identity_destroy_each, NULL); - g_slist_free (config->ids); - config->ids = NULL; - - g_slist_foreach (config->sources, service_destroy_each, NULL); - g_slist_free (config->sources); - config->sources = NULL; - + + if (config->ids) { + g_slist_foreach (config->ids, identity_destroy_each, NULL); + g_slist_free (config->ids); + config->ids = NULL; + } + + if (config->sources) { + g_slist_foreach (config->sources, service_destroy_each, NULL); + g_slist_free (config->sources); + config->sources = NULL; + } + service_destroy (config->transport); config->transport = NULL; } @@ -471,7 +479,7 @@ read_config () g_free (str); len = gnome_config_get_int ("num"); - for (i=0; iurl = gnome_config_get_string (path); g_free (path); - + config->sources = g_slist_append (config->sources, s); } gnome_config_pop_prefix (); @@ -520,7 +528,7 @@ read_config () g_free (str); len = gnome_config_get_int ("num"); - for (i=0; iids); gnome_config_set_int ("num", len); - for (i=0; ivbox, "Connection successful!"); - + return TRUE; } - + gtk_object_unref (GTK_OBJECT (service)); - + error: error_dialog (page->vbox, camel_exception_get_description (ex)); camel_exception_free (ex); @@ -1519,6 +1528,7 @@ source_dialog (MailConfigService *source, GtkWidget *parent) gboolean new = !source; sdialog = g_new0 (MailDialogSource, 1); + sdialog->source = source; provider_list (&sources, &news, &transports); @@ -1540,7 +1550,8 @@ source_dialog (MailConfigService *source, GtkWidget *parent) /* Get the identity widget */ sdialog->page = source_page_new (sources); - service_page_set_url (sdialog->page->page, source); + if (!new) + service_page_set_url (sdialog->page->page, source); service_page_set_done_cb (sdialog->page->page, sdialog_page_done, sdialog); gtk_box_pack_start (GTK_BOX (dialog_vbox), sdialog->page->vbox, @@ -1569,8 +1580,9 @@ source_dialog (MailConfigService *source, GtkWidget *parent) gnome_dialog_run_and_close (GNOME_DIALOG (sdialog->dialog)); + /* FIXME: */ returnsource = sdialog->source; - g_free (sdialog); + /*g_free (sdialog);*/ return returnsource; } @@ -1935,7 +1947,7 @@ sources_add_clicked (GtkWidget *widget, MailDialog *dialog) gint row = 0; text[0] = source->url; - + row = gtk_clist_append (clist, text); gtk_clist_set_row_data (clist, row, source); gtk_clist_select_row (clist, row, 0); @@ -2124,7 +2136,7 @@ mail_config (void) GladeXML *gui; GtkCList *clist; GtkWidget *button, *tvbox; - GSList *sources=NULL, *news=NULL, *transports=NULL; + GSList *sources = NULL, *news = NULL, *transports = NULL; gint len, row; read_config (); @@ -2143,7 +2155,7 @@ mail_config (void) gtk_clist_set_column_width (clist, 0, 80); len = g_slist_length (config->ids); - for (row=0; rowsources); - for (row=0; row