diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-05-27 01:09:33 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-05-27 01:09:33 +0800 |
commit | c9ec8c3f4dce2b02c91268529977770364ef87fe (patch) | |
tree | d574f2be1b5438407e59e2fead1321766c9bbc83 /calendar/gui/alarm-notify/alarm-queue.c | |
parent | 6fec6bf39467dd32625847be1b021a7e5bc94d76 (diff) | |
parent | 96538878911586a9e9ca26b81e1916c04e538980 (diff) | |
download | gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar.gz gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar.bz2 gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar.lz gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar.xz gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.tar.zst gsoc2013-evolution-c9ec8c3f4dce2b02c91268529977770364ef87fe.zip |
Merge branch 'express2'
Diffstat (limited to 'calendar/gui/alarm-notify/alarm-queue.c')
-rw-r--r-- | calendar/gui/alarm-notify/alarm-queue.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index afba3e4602..f7ef6fdcf4 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -183,6 +183,25 @@ message_push (Message *msg) msg->func (msg); } +/* + * use a static ring-buffer so we can call this twice + * in a printf without getting nonsense results. + */ +static const gchar * +e_ctime (const time_t *timep) +{ + static gchar *buffer[4] = { 0, }; + static gint next = 0; + const gchar *ret; + + g_free (buffer[next]); + ret = buffer[next++] = g_strdup (ctime (timep)); + if (next >= G_N_ELEMENTS (buffer)) + next = 0; + + return ret; +} + /* Queues an alarm trigger for midnight so that we can load the next day's worth * of alarms. */ @@ -199,7 +218,7 @@ queue_midnight_refresh (void) zone = config_data_get_timezone (); midnight = time_day_end_with_zone (time (NULL), zone); - d(printf("%s:%d (queue_midnight_refresh) - Refresh at %s \n",__FILE__, __LINE__, ctime(&midnight))); + d(printf("%s:%d (queue_midnight_refresh) - Refresh at %s \n",__FILE__, __LINE__, e_ctime(&midnight))); midnight_refresh_id = alarm_add (midnight, midnight_refresh_cb, NULL, NULL); if (!midnight_refresh_id) { @@ -471,7 +490,7 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL); if (!alarm_id) { - d(printf("%s:%d (add_component_alarms) - Could not schedule a trigger for %s. Discarding \n",__FILE__, __LINE__, ctime(&(instance->trigger)))); + d(printf("%s:%d (add_component_alarms) - Could not schedule a trigger for %s. Discarding \n",__FILE__, __LINE__, e_ctime(&(instance->trigger)))); continue; } @@ -482,7 +501,7 @@ add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) qa->snooze = FALSE; cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa); - d(printf("%s:%d (add_component_alarms) - Adding alarm %p %p at %s %s\n",__FILE__, __LINE__, qa, alarm_id, ctime (&(instance->trigger)), ctime(&tnow))); + d(printf("%s:%d (add_component_alarms) - Adding alarm %p %p at %s %s\n",__FILE__, __LINE__, qa, alarm_id, ctime (&(instance->trigger)), e_ctime(&tnow))); } id = e_cal_component_get_id (alarms->comp); @@ -571,7 +590,8 @@ load_alarms_for_today (ClientAlarms *ca) from = MAX (config_data_get_last_notification_time (ca->client) + 1, day_start); day_end = time_day_end_with_zone (now, zone); - d(printf("%s:%d (load_alarms_for_today) - From %s to %s\n",__FILE__, __LINE__, ctime (&from), ctime(&day_end))); + d(printf("%s:%d (load_alarms_for_today) - From %s to %s\n",__FILE__, __LINE__, + g_strdup (ctime (&from)), g_strdup (e_ctime(&day_end)))); load_alarms (ca, from, day_end); } @@ -707,7 +727,7 @@ query_objects_changed_async (struct _query_msg *msg) day_end = time_day_end_with_zone (time (NULL), zone); - d(printf("%s:%d (query_objects_changed_async) - Querying for object between %s to %s\n",__FILE__, __LINE__, ctime(&from), ctime(&day_end))); + d(printf("%s:%d (query_objects_changed_async) - Querying for object between %s to %s\n",__FILE__, __LINE__, e_ctime(&from), e_ctime(&day_end))); for (l = objects; l != NULL; l = l->next) { ECalComponentId *id; @@ -771,7 +791,7 @@ query_objects_changed_async (struct _query_msg *msg) alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL); if (!alarm_id) { - d(printf("%s:%d (query_objects_changed_async) -Unable to schedule trigger for %s \n",__FILE__, __LINE__, ctime(&(instance->trigger)))); + d(printf("%s:%d (query_objects_changed_async) -Unable to schedule trigger for %s \n",__FILE__, __LINE__, e_ctime(&(instance->trigger)))); continue; } @@ -869,14 +889,14 @@ create_snooze (CompQueuedAlarms *cqa, gpointer alarm_id, gint snooze_mins) new_id = alarm_add (t, alarm_trigger_cb, cqa, NULL); if (!new_id) { - d(printf("%s:%d (create_snooze) -Unable to schedule trigger for %s \n",__FILE__, __LINE__, ctime(&t))); + d(printf("%s:%d (create_snooze) -Unable to schedule trigger for %s \n",__FILE__, __LINE__, e_ctime(&t))); return; } orig_qa->instance->trigger = t; orig_qa->alarm_id = new_id; orig_qa->snooze = TRUE; - d(printf("%s:%d (create_snooze) - Adding a alarm at %s\n",__FILE__, __LINE__, ctime(&t))); + d(printf("%s:%d (create_snooze) - Adding a alarm at %s\n",__FILE__, __LINE__, e_ctime(&t))); } /* Launches a component editor for a component */ @@ -1839,7 +1859,7 @@ alarm_queue_init (gpointer data) if (config_data_get_last_notification_time (NULL) == -1) { time_t tmval = time (NULL); - d(printf("%s:%d (alarm_queue_init) - Setting last notification time to %s\n",__FILE__, __LINE__, ctime(&tmval))); + d(printf("%s:%d (alarm_queue_init) - Setting last notification time to %s\n",__FILE__, __LINE__, e_ctime(&tmval))); config_data_set_last_notification_time (NULL, tmval); } @@ -2145,7 +2165,7 @@ update_cqa (CompQueuedAlarms *cqa, ECalComponent *newcomp) from = time_day_begin_with_zone (time (NULL), zone); to = time_day_end_with_zone (time (NULL), zone); - d(printf("%s:%d (update_cqa) - Generating alarms between %s and %s\n",__FILE__, __LINE__, ctime(&from), ctime(&to))); + d(printf("%s:%d (update_cqa) - Generating alarms between %s and %s\n",__FILE__, __LINE__, e_ctime(&from), e_ctime(&to))); alarms = e_cal_util_generate_alarms_for_comp (newcomp, from, to, omit, e_cal_resolve_tzid_cb, cqa->parent_client->client, zone); |