diff options
Diffstat (limited to 'calendar/gui/alarm-notify')
-rw-r--r-- | calendar/gui/alarm-notify/alarm-queue.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 9d2c57db26..0a68d1e3b9 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -125,6 +125,7 @@ typedef struct { /* Alarm ID for the midnight refresh function */ static gpointer midnight_refresh_id = NULL; +static time_t midnight = 0; static void remove_client_alarms (ClientAlarms *ca); @@ -152,7 +153,6 @@ static void midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer dat static void queue_midnight_refresh (void) { - time_t midnight; icaltimezone *zone; if (midnight_refresh_id != NULL) { @@ -1295,6 +1295,25 @@ procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id +static gboolean +check_midnight_refresh (gpointer user_data) +{ + time_t new_midnight; + icaltimezone *zone; + + zone = config_data_get_timezone (); + new_midnight = time_day_end_with_zone (time (NULL), zone); + + if (new_midnight > midnight) { + /* Re-load the alarms for all clients */ + g_hash_table_foreach (client_alarms_hash, add_client_alarms_cb, NULL); + + queue_midnight_refresh (); + } + + return TRUE; +} + /** * alarm_queue_init: * @@ -1315,6 +1334,9 @@ alarm_queue_init (void) config_data_set_last_notification_time (saved_notification_time); } + /* install timeout handler (every 30 mins) for not missing the midnight refresh */ + g_timeout_add (1800000, (GSourceFunc) check_midnight_refresh, NULL); + alarm_queue_inited = TRUE; } |