From 064c9ac23dd9d4d7f1f7a2249a3bc903e4a71807 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Mon, 16 Feb 2004 17:26:10 +0000 Subject: open the calendars asynchonously. (cal_opened_cb): callback for 2004-02-16 Rodrigo Moya * gui/alarm-notify/alarm-notify.c (alarm_notify_add_calendar): open the calendars asynchonously. (cal_opened_cb): callback for "cal_opened" signal. Add the calendars to the alarm queue here. svn path=/trunk/; revision=24751 --- calendar/ChangeLog | 5 +++++ calendar/gui/alarm-notify/alarm-notify.c | 30 +++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 6e74427136..bcaca29f4e 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,5 +1,10 @@ 2004-02-16 Rodrigo Moya + * gui/alarm-notify/alarm-notify.c (alarm_notify_add_calendar): open the + calendars asynchonously. + (cal_opened_cb): callback for "cal_opened" signal. Add the calendars to + the alarm queue here. + * gui/alarm-notify/alarm-queue.c (query_objects_changed_cb): get alarms since the last notification, only use current time when there is no previous notification time. diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c index 84159e562c..53aacea4aa 100644 --- a/calendar/gui/alarm-notify/alarm-notify.c +++ b/calendar/gui/alarm-notify/alarm-notify.c @@ -129,6 +129,28 @@ alarm_notify_new (void) return an; } +static void +cal_opened_cb (ECal *client, ECalendarStatus status, gpointer user_data) +{ + AlarmNotifyPrivate *priv; + AlarmNotify *an = ALARM_NOTIFY (user_data); + + priv = an->priv; + + if (status == E_CALENDAR_STATUS_OK) + alarm_queue_add_client (client); + else { + gpointer orig_key, orig_value; + + if (g_hash_table_lookup_extended (priv->uri_client_hash, e_cal_get_uri (client), &orig_key, &orig_value)) { + g_hash_table_remove (priv->uri_client_hash, orig_key); + g_free (orig_key); + } + + g_object_unref (client); + } +} + /** * alarm_notify_add_calendar: * @an: An alarm notification service. @@ -159,11 +181,9 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a client = auth_new_cal_from_uri (str_uri, E_CAL_SOURCE_TYPE_EVENT); if (client) { - if (e_cal_open (client, FALSE, NULL)) { - g_hash_table_insert (priv->uri_client_hash, - g_strdup (str_uri), client); - alarm_queue_add_client (client); - } + g_hash_table_insert (priv->uri_client_hash, g_strdup (str_uri), client); + g_signal_connect (G_OBJECT (client), "cal_opened", G_CALLBACK (cal_opened_cb), an); + e_cal_open_async (client, FALSE); } } -- cgit v1.2.3