From 6df51e3ed291f4f5142c56c580b090e83ac48510 Mon Sep 17 00:00:00 2001 From: Russell Steinthal Date: Fri, 22 Oct 1999 01:48:15 +0000 Subject: Commit debugging support to HEAD as well; there's no good reason to have debugging in the stable but not devel version, is there? svn path=/trunk/; revision=1340 --- calendar/alarm.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'calendar/alarm.c') diff --git a/calendar/alarm.c b/calendar/alarm.c index 7e56ce790a..25c30a9e20 100644 --- a/calendar/alarm.c +++ b/calendar/alarm.c @@ -29,6 +29,10 @@ typedef struct { CalendarAlarm *alarm; } AlarmRecord; +void debug_alarm (AlarmRecord* ar, int add); +void calendar_notify (time_t time, CalendarAlarm *which, void *data); +extern int debug_alarms; + /* * SIGALRM handler. Notifies the callback about the alarm */ @@ -56,6 +60,8 @@ alarm_ready (void *closure, int fd, GdkInputCondition cond) } while (head_alarm){ + if (debug_alarms) + debug_alarm (ar, 0); (*ar->fn)(ar->activation_time, ar->alarm, ar->closure); alarms = g_list_remove (alarms, head_alarm); @@ -135,7 +141,8 @@ alarm_add (CalendarAlarm *alarm, AlarmFunction fn, void *closure) v = setitimer (ITIMER_REAL, &itimer, NULL); head_alarm = alarms->data; } - + if (debug_alarms) + debug_alarm (ar, 1); return TRUE; } @@ -179,3 +186,32 @@ alarm_init (void) sigaction (SIGALRM, &sa, NULL); } +void debug_alarm (AlarmRecord* ar, int add) +{ + time_t now = time (NULL); + iCalObject *ico = ar->closure; + printf ("%s", ctime(&now)); + if (add) + printf ("Added alarm for %s", ctime(&ar->activation_time)); + else + printf ("Activated alarm\n"); + + if (ar->fn!=&calendar_notify) return; + printf ("--- Summary: %s\n", ico->summary); + switch (ar->alarm->type) { + case ALARM_MAIL: + printf ("--- Type: Mail\n"); + break; + case ALARM_PROGRAM: + printf ("--- Type: Program\n"); + break; + case ALARM_DISPLAY: + printf ("--- Type: Display\n"); + break; + case ALARM_AUDIO: + printf ("--- Type: Audio\n"); + break; + } +} + + -- cgit v1.2.3