From 76d4c1fa56ec4c02d68ad39ac847890936a4c098 Mon Sep 17 00:00:00 2001 From: Iain Holmes Date: Wed, 11 Jul 2001 19:08:53 +0000 Subject: Free the data stop all the transfers when the summary is destroyed. svn path=/trunk/; revision=11010 --- my-evolution/ChangeLog | 14 ++++++++ my-evolution/e-summary-calendar.c | 16 +++++++++ my-evolution/e-summary-calendar.h | 2 +- my-evolution/e-summary-mail.c | 33 ++++++++++++++++++ my-evolution/e-summary-mail.h | 6 ++++ my-evolution/e-summary-preferences.c | 1 - my-evolution/e-summary-rdf.c | 67 +++++++++++++++++++++++++++++++++--- my-evolution/e-summary-rdf.h | 1 + my-evolution/e-summary-tasks.c | 16 +++++++++ my-evolution/e-summary-tasks.h | 1 + my-evolution/e-summary-weather.c | 42 ++++++++++++++++++++++ my-evolution/e-summary-weather.h | 1 + my-evolution/e-summary.c | 39 +++++++++++++++++++-- 13 files changed, 230 insertions(+), 9 deletions(-) (limited to 'my-evolution') diff --git a/my-evolution/ChangeLog b/my-evolution/ChangeLog index 4a50decabc..ed082fedb8 100644 --- a/my-evolution/ChangeLog +++ b/my-evolution/ChangeLog @@ -1,3 +1,17 @@ +2001-07-11 Iain Holmes + + * e-summary.c (destroy): Destroy all the subcomponents. + + * e-summary-rdf.c (e_summary_rdf_free): Free and stop all tranfsers + + * e-summary-weather.c (e_summary_weather_free): Same. + + * e-summary-mail.c (e_summary_mail_free): Same. + + * e-summary-calendar.c (e_summary_calendar_free): Same. + + * e-summary-tasks.c (e_summary_tasks_free): Guess what. + 2001-07-10 Iain Holmes * e-summary-preferences.c: Correct the Register RDF url. diff --git a/my-evolution/e-summary-calendar.c b/my-evolution/e-summary-calendar.c index 43d1a9ac29..5e5b730620 100644 --- a/my-evolution/e-summary-calendar.c +++ b/my-evolution/e-summary-calendar.c @@ -322,3 +322,19 @@ e_summary_calendar_reconfigure (ESummary *summary) { generate_html (summary); } + +void +e_summary_calendar_free (ESummary *summary) +{ + ESummaryCalendar *calendar; + + g_return_if_fail (summary != NULL); + g_return_if_fail (IS_E_SUMMARY (summary)); + + calendar = summary->calendar; + gtk_object_unref (GTK_OBJECT (calendar->client)); + g_free (calendar->html); + + g_free (calendar); + summary->calendar = NULL; +} diff --git a/my-evolution/e-summary-calendar.h b/my-evolution/e-summary-calendar.h index 5cf3fd936f..bad6d783cc 100644 --- a/my-evolution/e-summary-calendar.h +++ b/my-evolution/e-summary-calendar.h @@ -28,5 +28,5 @@ typedef struct _ESummaryCalendar ESummaryCalendar; const char *e_summary_calendar_get_html (ESummary *summary); void e_summary_calendar_init (ESummary *summary); void e_summary_calendar_reconfigure (ESummary *summary); - +void e_summary_calendar_free (ESummary *summary); #endif diff --git a/my-evolution/e-summary-mail.c b/my-evolution/e-summary-mail.c index bf00686f1e..1cd3a1ec16 100644 --- a/my-evolution/e-summary-mail.c +++ b/my-evolution/e-summary-mail.c @@ -440,3 +440,36 @@ e_summary_mail_uri_to_name (ESummary *summary, } } +static void +free_folder (gpointer key, + gpointer value, + gpointer data) +{ + ESummaryMailFolder *folder = value; + + g_free (folder->name); + g_free (folder->path); + g_free (folder); + g_free (value); +} + +void +e_summary_mail_free (ESummary *summary) +{ + ESummaryMail *mail; + + g_return_if_fail (summary != NULL); + g_return_if_fail (IS_E_SUMMARY (summary)); + + mail = summary->mail; + bonobo_object_release_unref (mail->folder_info, NULL); + bonobo_object_unref (BONOBO_OBJECT (mail->listener)); + + g_hash_table_foreach (mail->folders, free_folder, NULL); + g_hash_table_destroy (mail->folders); + + g_free (mail->html); + + g_free (mail); + summary->mail = NULL; +} diff --git a/my-evolution/e-summary-mail.h b/my-evolution/e-summary-mail.h index 09a79ec1f3..9af0572a53 100644 --- a/my-evolution/e-summary-mail.h +++ b/my-evolution/e-summary-mail.h @@ -11,6 +11,7 @@ #include "e-summary-type.h" #include +#include typedef enum _ESummaryMailMode ESummaryMailMode; enum _ESummaryMailMode { @@ -30,4 +31,9 @@ const char *e_summary_mail_get_html (ESummary *summary); void e_summary_mail_init (ESummary *summary, GNOME_Evolution_Shell corba_shell); void e_summary_mail_reconfigure (ESummary *summary); +void e_summary_mail_free (ESummary *summary); +void e_summary_mail_fill_list (GtkCList *clist, + ESummary *summary); +const char *e_summary_mail_uri_to_name (ESummary *summary, + const char *uri); #endif diff --git a/my-evolution/e-summary-preferences.c b/my-evolution/e-summary-preferences.c index deb522541e..147358b12e 100644 --- a/my-evolution/e-summary-preferences.c +++ b/my-evolution/e-summary-preferences.c @@ -685,7 +685,6 @@ mail_add_clicked_cb (GtkButton *button, int row; ESummaryMailRowData *rd; char *text[1]; - char *uri; row = GPOINTER_TO_INT (GTK_CLIST (pd->mail->all)->selection->data); rd = gtk_clist_get_row_data (GTK_CLIST (pd->mail->all), row); diff --git a/my-evolution/e-summary-rdf.c b/my-evolution/e-summary-rdf.c index dee5077bda..954e03fc4a 100644 --- a/my-evolution/e-summary-rdf.c +++ b/my-evolution/e-summary-rdf.c @@ -335,17 +335,22 @@ close_callback (GnomeVFSAsyncHandle *handle, if (r->handle == NULL) { g_free (r->buffer); + r->buffer = NULL; g_string_free (r->string, TRUE); + r->string = NULL; return; } r->handle = NULL; g_free (r->buffer); + r->buffer = NULL; xml = r->string->str; g_string_free (r->string, FALSE); + r->string = NULL; if (r->cache != NULL) { xmlFreeDoc (r->cache); + r->cache = NULL; } doc = xmlParseMemory (xml, strlen (xml)); @@ -376,6 +381,9 @@ read_callback (GnomeVFSAsyncHandle *handle, RDF *r) { if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) { + if (r->html) { + g_free (r->html); + } r->html = e_utf8_from_locale_string (_("Error downloading RDF")); e_summary_draw (r->summary); @@ -589,6 +597,31 @@ e_summary_rdf_init (ESummary *summary) return; } +static void +rdf_free (RDF *r) +{ + /* Stop the download */ + if (r->handle) { + gnome_vfs_async_cancel (r->handle); + } + if (r->uri) { + g_free (r->uri); + } + if (r->html) { + g_free (r->html); + } + if (r->string) { + g_string_free (r->string, TRUE); + } + if (r->buffer) { + g_free (r->buffer); + } + if (r->cache) { + xmlFreeDoc (r->cache); + } + g_free (r); +} + void e_summary_rdf_reconfigure (ESummary *summary) { @@ -607,10 +640,7 @@ e_summary_rdf_reconfigure (ESummary *summary) RDF *r; r = old->data; - g_free (r->uri); - g_free (r->html); - xmlFree (r->cache); - g_free (r); + rdf_free (r); } g_list_free (rdf->rdfs); rdf->rdfs = NULL; @@ -622,3 +652,32 @@ e_summary_rdf_reconfigure (ESummary *summary) rdf->timeout = gtk_timeout_add (summary->preferences->rdf_refresh_time * 1000, (GtkFunction) e_summary_rdf_update, summary); e_summary_rdf_update (summary); } + +void +e_summary_rdf_free (ESummary *summary) +{ + ESummaryRDF *rdf; + GList *p; + + g_return_if_fail (summary != NULL); + g_return_if_fail (IS_E_SUMMARY (summary)); + + rdf = summary->rdf; + + if (rdf->timeout != 0) { + gtk_timeout_remove (rdf->timeout); + } + for (p = rdf->rdfs; p; p = p->next) { + RDF *r = p->data; + + rdf_free (r); + } + g_list_free (rdf->rdfs); + g_free (rdf->html); + + e_summary_remove_online_connection (summary, rdf->connection); + g_free (rdf->connection); + + g_free (rdf); + summary->rdf = NULL; +} diff --git a/my-evolution/e-summary-rdf.h b/my-evolution/e-summary-rdf.h index 329bdd8bb6..aae99b383e 100644 --- a/my-evolution/e-summary-rdf.h +++ b/my-evolution/e-summary-rdf.h @@ -16,5 +16,6 @@ typedef struct _ESummaryRDF ESummaryRDF; char *e_summary_rdf_get_html (ESummary *summary); void e_summary_rdf_init (ESummary *summary); void e_summary_rdf_reconfigure (ESummary *summary); +void e_summary_rdf_free (ESummary *summary); #endif diff --git a/my-evolution/e-summary-tasks.c b/my-evolution/e-summary-tasks.c index 963f8bf87b..e8dc52de7a 100644 --- a/my-evolution/e-summary-tasks.c +++ b/my-evolution/e-summary-tasks.c @@ -287,3 +287,19 @@ e_summary_tasks_reconfigure (ESummary *summary) { } + +void +e_summary_tasks_free (ESummary *summary) +{ + ESummaryTasks *tasks; + + g_return_if_fail (summary != NULL); + g_return_if_fail (IS_E_SUMMARY (summary)); + + tasks = summary->tasks; + gtk_object_unref (GTK_OBJECT (tasks->client)); + g_free (tasks->html); + + g_free (tasks); + summary->tasks = NULL; +} diff --git a/my-evolution/e-summary-tasks.h b/my-evolution/e-summary-tasks.h index aec1b39424..fbf0ae4f32 100644 --- a/my-evolution/e-summary-tasks.h +++ b/my-evolution/e-summary-tasks.h @@ -16,5 +16,6 @@ typedef struct _ESummaryTasks ESummaryTasks; const char *e_summary_tasks_get_html (ESummary *summary); void e_summary_tasks_init (ESummary *summary); void e_summary_tasks_reconfigure (ESummary *summary); +void e_summary_tasks_free (ESummary *summary); #endif diff --git a/my-evolution/e-summary-weather.c b/my-evolution/e-summary-weather.c index 47d077212a..a2b3d5ffe3 100644 --- a/my-evolution/e-summary-weather.c +++ b/my-evolution/e-summary-weather.c @@ -229,14 +229,18 @@ close_callback (GnomeVFSAsyncHandle *handle, if (w->handle == NULL) { g_free (w->buffer); + w->buffer = NULL; g_string_free (w->string, TRUE); + w->string = NULL; return; } w->handle = NULL; g_free (w->buffer); + w->buffer = NULL; html = w->string->str; g_string_free (w->string, FALSE); + w->string = NULL; /* Find the metar data */ search_str = g_strdup_printf ("\n%s", w->location); @@ -335,10 +339,18 @@ weather_free (Weather *w) if (w->handle != NULL) { gnome_vfs_async_cancel (w->handle); } + if (w->string) { + g_string_free (w->string, TRUE); + } + if (w->buffer) { + g_free (w->buffer); + } + g_free (w->location); g_free (w->html); g_free (w); } + static void e_summary_weather_add_location (ESummary *summary, const char *location) @@ -729,3 +741,33 @@ e_summary_weather_reconfigure (ESummary *summary) (GtkFunction) e_summary_weather_update, summary); e_summary_weather_update (summary); } + +void +e_summary_weather_free (ESummary *summary) +{ + ESummaryWeather *weather; + GList *p; + + g_return_if_fail (summary != NULL); + g_return_if_fail (IS_E_SUMMARY (summary)); + + weather = summary->weather; + + if (weather->timeout != 0) { + gtk_timeout_remove (weather->timeout); + } + for (p = weather->weathers; p; p = p->next) { + Weather *w = p->data; + + weather_free (w); + } + g_list_free (weather->weathers); + g_free (weather->html); + + e_summary_remove_online_connection (summary, weather->connection); + g_free (weather->connection); + + g_free (weather); + summary->weather = NULL; +} + diff --git a/my-evolution/e-summary-weather.h b/my-evolution/e-summary-weather.h index 290efc6aa8..5ee1623f6d 100644 --- a/my-evolution/e-summary-weather.h +++ b/my-evolution/e-summary-weather.h @@ -129,5 +129,6 @@ void e_summary_weather_init (ESummary *summary); void e_summary_weather_reconfigure (ESummary *summary); void e_summary_weather_ctree_fill (GtkCTree *tree); const char *e_summary_weather_code_to_name (const char *code); +void e_summary_weather_free (ESummary *summary); #endif diff --git a/my-evolution/e-summary.c b/my-evolution/e-summary.c index db9257f8f1..db43067a17 100644 --- a/my-evolution/e-summary.c +++ b/my-evolution/e-summary.c @@ -97,6 +97,22 @@ destroy (GtkObject *object) return; } + if (summary->mail) { + e_summary_mail_free (summary); + } + if (summary->calendar) { + e_summary_calendar_free (summary); + } + if (summary->rdf) { + e_summary_rdf_free (summary); + } + if (summary->weather) { + e_summary_weather_free (summary); + } + if (summary->tasks) { + e_summary_tasks_free (summary); + } + g_free (priv); summary->priv = NULL; @@ -112,6 +128,9 @@ e_summary_draw (ESummary *summary) char date[256]; time_t t; + g_return_if_fail (summary != NULL); + g_return_if_fail (IS_E_SUMMARY (summary)); + if (summary->mail == NULL || summary->calendar == NULL || summary->rdf == NULL || summary->weather == NULL) { return; @@ -260,8 +279,6 @@ e_summary_url_clicked (GtkHTML *html, char *protocol, *protocol_end; ProtocolListener *protocol_listener; - g_print ("URL: %s\n", url); - protocol_end = strchr (url, ':'); if (protocol_end == NULL) { /* No url, let gnome work it out */ @@ -270,7 +287,6 @@ e_summary_url_clicked (GtkHTML *html, } protocol = g_strndup (url, protocol_end - url); - g_print ("Protocol: %s.\n", protocol); protocol_listener = g_hash_table_lookup (summary->priv->protocol_hash, protocol); @@ -686,3 +702,20 @@ e_summary_add_online_connection (ESummary *summary, summary->priv->connections = g_list_prepend (summary->priv->connections, connection); } + +void +e_summary_remove_online_connection (ESummary *summary, + ESummaryConnection *connection) +{ + GList *p; + + g_return_if_fail (summary != NULL); + g_return_if_fail (IS_E_SUMMARY (summary)); + g_return_if_fail (connection != NULL); + + p = g_list_find (summary->priv->connections, connection); + g_return_if_fail (p != NULL); + + summary->priv->connections = g_list_remove_link (summary->priv->connections, p); + g_list_free (p); +} -- cgit v1.2.3