diff options
author | Rodrigo Moya <rodrigo@novell.com> | 2004-09-17 16:07:21 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2004-09-17 16:07:21 +0800 |
commit | 3e824826986b05b47ca76454e8ae270d1ad90348 (patch) | |
tree | abcdde6b897f18fb396a922a383a2c42f8e99362 | |
parent | ae7375aa9ace7468fd95758507fbc90db50bc33c (diff) | |
download | gsoc2013-evolution-3e824826986b05b47ca76454e8ae270d1ad90348.tar gsoc2013-evolution-3e824826986b05b47ca76454e8ae270d1ad90348.tar.gz gsoc2013-evolution-3e824826986b05b47ca76454e8ae270d1ad90348.tar.bz2 gsoc2013-evolution-3e824826986b05b47ca76454e8ae270d1ad90348.tar.lz gsoc2013-evolution-3e824826986b05b47ca76454e8ae270d1ad90348.tar.xz gsoc2013-evolution-3e824826986b05b47ca76454e8ae270d1ad90348.tar.zst gsoc2013-evolution-3e824826986b05b47ca76454e8ae270d1ad90348.zip |
Fixes #62374
2004-09-10 Rodrigo Moya <rodrigo@novell.com>
Fixes #62374
* gui/alarm-notify/alarm-queue.c (load_missed_alarms): removed this
function.
(cal_opened_cb): no need to call load_missed_alarms,
load_alarms_for_today will do everything.
(alarm_queue_add_client): ditto.
(load_alarms_for_today): take into account the last saved notification
time.
(load_alarms): unref the previous query, this function should now
only be called once per time range.
svn path=/trunk/; revision=27286
-rw-r--r-- | calendar/ChangeLog | 16 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-queue.c | 100 |
2 files changed, 59 insertions, 57 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 5a05d9fad6..21dddaa0a8 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,17 @@ +2004-09-10 Rodrigo Moya <rodrigo@novell.com> + + Fixes #62374 + + * gui/alarm-notify/alarm-queue.c (load_missed_alarms): removed this + function. + (cal_opened_cb): no need to call load_missed_alarms, + load_alarms_for_today will do everything. + (alarm_queue_add_client): ditto. + (load_alarms_for_today): take into account the last saved notification + time. + (load_alarms): unref the previous query, this function should now + only be called once per time range. + 2004-09-09 JP Rosevear <jpr@novell.com> Fixes #65454 @@ -9,7 +23,7 @@ (weren't using it anywhere) (destroy): collapse finalize work into here and guard against multiple destroy calls - + 2004-09-08 JP Rosevear <jpr@novell.com> Fixes #62728 diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 0d978136c5..223fd6fa9f 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -388,76 +388,66 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) static void load_alarms (ClientAlarms *ca, time_t start, time_t end) { - /* create the live query */ - if (!ca->query) { - char *str_query, *iso_start, *iso_end; + char *str_query, *iso_start, *iso_end; - iso_start = isodate_from_time_t (start); - if (!iso_start) - return; + iso_start = isodate_from_time_t (start); + if (!iso_start) + return; - iso_end = isodate_from_time_t (end); - if (!iso_end) { - g_free (iso_start); - return; - } - - str_query = g_strdup_printf ("(has-alarms-in-range? (make-time \"%s\") (make-time \"%s\"))", - iso_start, iso_end); + iso_end = isodate_from_time_t (end); + if (!iso_end) { g_free (iso_start); - g_free (iso_end); - - /* FIXME: handle errors */ - if (!e_cal_get_query (ca->client, str_query, &ca->query, NULL)) { - g_warning (G_STRLOC ": Could not get query for client"); - } else { - g_signal_connect (G_OBJECT (ca->query), "objects_added", - G_CALLBACK (query_objects_changed_cb), ca); - g_signal_connect (G_OBJECT (ca->query), "objects_modified", - G_CALLBACK (query_objects_changed_cb), ca); - g_signal_connect (G_OBJECT (ca->query), "objects_removed", - G_CALLBACK (query_objects_removed_cb), ca); - - e_cal_view_start (ca->query); - } + return; + } - g_free (str_query); + str_query = g_strdup_printf ("(has-alarms-in-range? (make-time \"%s\") (make-time \"%s\"))", + iso_start, iso_end); + g_free (iso_start); + g_free (iso_end); + + /* create the live query */ + if (ca->query) { + g_object_unref (ca->query); + ca->query = NULL; } + + /* FIXME: handle errors */ + if (!e_cal_get_query (ca->client, str_query, &ca->query, NULL)) { + g_warning (G_STRLOC ": Could not get query for client"); + } else { + g_signal_connect (G_OBJECT (ca->query), "objects_added", + G_CALLBACK (query_objects_changed_cb), ca); + g_signal_connect (G_OBJECT (ca->query), "objects_modified", + G_CALLBACK (query_objects_changed_cb), ca); + g_signal_connect (G_OBJECT (ca->query), "objects_removed", + G_CALLBACK (query_objects_removed_cb), ca); + + e_cal_view_start (ca->query); + } + + g_free (str_query); } /* Loads today's remaining alarms for a client */ static void load_alarms_for_today (ClientAlarms *ca) { - time_t now, day_end; + time_t now, from, day_end; icaltimezone *zone; now = time (NULL); + /* Make sure we don't miss some events from the last notification. + * We add 1 to the saved_notification_time to make the time ranges + * half-open; we do not want to display the "last" displayed alarm + * twice, once when it occurs and once when the alarm daemon restarts. + */ + from = MIN (config_data_get_last_notification_time () + 1, now); zone = config_data_get_timezone (); g_message ("Loading alarms for today"); day_end = time_day_end_with_zone (now, zone); - load_alarms (ca, now, day_end); -} - -/* Adds any alarms that should have occurred while the alarm daemon was not - * running. - */ -static void -load_missed_alarms (ClientAlarms *ca) -{ - time_t now; - - now = time (NULL); - - g_assert (saved_notification_time != -1); - - /* We add 1 to the saved_notification_time to make the time ranges - * half-open; we do not want to display the "last" displayed alarm - * twice, once when it occurs and once when the alarm daemon restarts. - */ - load_alarms (ca, saved_notification_time + 1, now); + load_alarms (ca, from, day_end); } /* Called when a calendar client finished loading; we load its alarms */ @@ -472,7 +462,6 @@ cal_opened_cb (ECal *client, ECalendarStatus status, gpointer data) return; load_alarms_for_today (ca); - load_missed_alarms (ca); } /* Looks up a component's queued alarm structure in a client alarms structure */ @@ -591,16 +580,16 @@ query_objects_changed_cb (ECal *client, GList *objects, gpointer data) ECalComponentAlarmInstance *instance; gpointer alarm_id; QueuedAlarm *qa; - + instance = sl->data; - + alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL); if (!alarm_id) { g_message (G_STRLOC ": Could not schedule a trigger for " "%ld, discarding...", (long) instance->trigger); continue; } - + qa = g_new (QueuedAlarm, 1); qa->alarm_id = alarm_id; qa->instance = instance; @@ -1312,7 +1301,6 @@ alarm_queue_add_client (ECal *client) if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) { load_alarms_for_today (ca); - load_missed_alarms (ca); } else { g_signal_connect (client, "cal_opened", G_CALLBACK (cal_opened_cb), |