From 6c988be90916e1928b48b8ac7a8feceaed9f5c57 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 12 Nov 2002 20:59:08 +0000 Subject: #include 2002-11-12 Federico Mena Quintero * pcs/cal-backend-util.c: #include * pcs/cal.c: Fixed prototypes of the CORBA method implementations. * pcs/cal-backend-file.c (cal_backend_file_dispose): Added a dispose method. (cal_backend_file_get_free_busy): Converted to use EConfigListener rather than BonoboConfigDatabase. * gui/alarm-notify/alarm-notify.c: #include , fix use of g_hash_table_lookup_extended(). * gui/alarm-notify/alarm-notify-dialog.c: Substitute deprecated GTK+ functions for new ones. * gui/alarm-notify/alarm-queue.c: Likewise. * gui/alarm-notify/notify-main.c: #include , . * gui/alarm-notify/save.c: #include . svn path=/trunk/; revision=18726 --- calendar/pcs/cal-backend-file.c | 94 +++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 46 deletions(-) (limited to 'calendar/pcs/cal-backend-file.c') diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index 3f457a0a57..595626f043 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -21,6 +21,7 @@ */ #include +#include #include #include #include @@ -73,7 +74,7 @@ struct _CalBackendFilePrivate { GHashTable *removed_categories; /* Config database handle for free/busy organizer information */ - Bonobo_ConfigDatabase db; + EConfigListener *config_listener; /* Idle handler for saving the calendar when it is dirty */ guint idle_id; @@ -87,6 +88,7 @@ struct _CalBackendFilePrivate { static void cal_backend_file_class_init (CalBackendFileClass *class); static void cal_backend_file_init (CalBackendFile *cbfile, CalBackendFileClass *class); +static void cal_backend_file_dispose (GObject *object); static void cal_backend_file_finalize (GObject *object); static const char *cal_backend_file_get_uri (CalBackend *backend); @@ -136,6 +138,7 @@ static gboolean cal_backend_file_set_default_timezone (CalBackend *backend, const char *tzid); static void notify_categories_changed (CalBackendFile *cbfile); +static void notify_error (CalBackendFile *cbfile, const char *message); static CalBackendClass *parent_class; @@ -185,6 +188,7 @@ cal_backend_file_class_init (CalBackendFileClass *class) parent_class = (CalBackendClass *) g_type_class_peek_parent (class); + object_class->dispose = cal_backend_file_dispose; object_class->finalize = cal_backend_file_finalize; backend_class->get_uri = cal_backend_file_get_uri; @@ -214,24 +218,6 @@ cal_backend_file_class_init (CalBackendFileClass *class) backend_class->set_default_timezone = cal_backend_file_set_default_timezone; } -static Bonobo_ConfigDatabase -load_db (void) -{ - Bonobo_ConfigDatabase db = CORBA_OBJECT_NIL; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev); - - if (BONOBO_EX (&ev)) - db = CORBA_OBJECT_NIL; - - CORBA_exception_free (&ev); - - return db; -} - static void cal_added_cb (CalBackend *backend, gpointer user_data) { @@ -260,7 +246,7 @@ cal_backend_file_init (CalBackendFile *cbfile, CalBackendFileClass *class) /* The timezone defaults to UTC. */ priv->default_zone = icaltimezone_get_utc_timezone (); - priv->db = load_db (); + priv->config_listener = e_config_listener_new (); g_signal_connect (G_OBJECT (cbfile), "cal_added", G_CALLBACK (cal_added_cb), NULL); @@ -358,23 +344,16 @@ free_category_cb (gpointer key, gpointer value, gpointer data) g_free (c); } -/* Finalize handler for the file backend */ +/* Dispose handler for the file backend */ static void -cal_backend_file_finalize (GObject *object) +cal_backend_file_dispose (GObject *object) { CalBackendFile *cbfile; CalBackendFilePrivate *priv; - GList *clients; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND_FILE (object)); cbfile = CAL_BACKEND_FILE (object); priv = cbfile->priv; - clients = CAL_BACKEND (cbfile)->clients; - g_assert (clients == NULL); - /* Save if necessary */ if (priv->idle_id != 0) { @@ -383,13 +362,6 @@ cal_backend_file_finalize (GObject *object) priv->idle_id = 0; } - /* Clean up */ - - if (priv->uri) { - g_free (priv->uri); - priv->uri = NULL; - } - if (priv->comp_uid_hash) { g_hash_table_foreach (priv->comp_uid_hash, free_cal_component, NULL); @@ -404,6 +376,44 @@ cal_backend_file_finalize (GObject *object) priv->todos = NULL; priv->journals = NULL; + if (priv->icalcomp) { + icalcomponent_free (priv->icalcomp); + priv->icalcomp = NULL; + } + + if (priv->config_listener) { + g_object_unref (priv->config_listener); + priv->config_listener = NULL; + } + + if (G_OBJECT_CLASS (parent_class)->dispose) + (* G_OBJECT_CLASS (parent_class)->dispose) (object); +} + +/* Finalize handler for the file backend */ +static void +cal_backend_file_finalize (GObject *object) +{ + CalBackendFile *cbfile; + CalBackendFilePrivate *priv; + GList *clients; + + g_return_if_fail (object != NULL); + g_return_if_fail (IS_CAL_BACKEND_FILE (object)); + + cbfile = CAL_BACKEND_FILE (object); + priv = cbfile->priv; + + clients = CAL_BACKEND (cbfile)->clients; + g_assert (clients == NULL); + + /* Clean up */ + + if (priv->uri) { + g_free (priv->uri); + priv->uri = NULL; + } + g_hash_table_foreach (priv->categories, free_category_cb, NULL); g_hash_table_destroy (priv->categories); priv->categories = NULL; @@ -412,14 +422,6 @@ cal_backend_file_finalize (GObject *object) g_hash_table_destroy (priv->removed_categories); priv->removed_categories = NULL; - if (priv->icalcomp) { - icalcomponent_free (priv->icalcomp); - priv->icalcomp = NULL; - } - - bonobo_object_release_unref (priv->db, NULL); - priv->db = CORBA_OBJECT_NIL; - g_free (priv); cbfile->priv = NULL; @@ -1406,7 +1408,7 @@ cal_backend_file_get_free_busy (CalBackend *backend, GList *users, time_t start, g_return_val_if_fail (start <= end, NULL); if (users == NULL) { - if (cal_backend_mail_account_get_default (priv->db, &address, &name)) { + if (cal_backend_mail_account_get_default (priv->config_listener, &address, &name)) { vfb = create_user_free_busy (cbfile, address, name, start, end); calobj = icalcomponent_as_ical_string (vfb); obj_list = g_list_append (obj_list, g_strdup (calobj)); @@ -1417,7 +1419,7 @@ cal_backend_file_get_free_busy (CalBackend *backend, GList *users, time_t start, } else { for (l = users; l != NULL; l = l->next ) { address = l->data; - if (cal_backend_mail_account_is_valid (priv->db, address, &name)) { + if (cal_backend_mail_account_is_valid (priv->config_listener, address, &name)) { vfb = create_user_free_busy (cbfile, address, name, start, end); calobj = icalcomponent_as_ical_string (vfb); obj_list = g_list_append (obj_list, g_strdup (calobj)); -- cgit v1.2.3