[asterisk-commits] twilson: branch twilson/calendaring r160851 - /team/twilson/calendaring/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Dec 3 18:00:06 CST 2008
Author: twilson
Date: Wed Dec 3 18:00:06 2008
New Revision: 160851
URL: http://svn.digium.com/view/asterisk?view=rev&rev=160851
Log:
Convert calendar_is_busy() to use ao2_callback in response to Russell's review
Modified:
team/twilson/calendaring/main/calendar.c
Modified: team/twilson/calendaring/main/calendar.c
URL: http://svn.digium.com/view/asterisk/team/twilson/calendaring/main/calendar.c?view=diff&rev=160851&r1=160850&r2=160851
==============================================================================
--- team/twilson/calendaring/main/calendar.c (original)
+++ team/twilson/calendaring/main/calendar.c Wed Dec 3 18:00:06 2008
@@ -155,21 +155,27 @@
}
}
+static int calendar_busy_callback(void *obj, void *arg, int flags)
+{
+ struct ast_calendar_event *event = obj;
+ int *is_busy = arg;
+ struct timeval tv = ast_tvnow();
+
+ if (tv.tv_sec >= event->start && tv.tv_sec <= event->end && event->busy_state > AST_CALENDAR_BS_FREE) {
+ *is_busy = 1;
+ return CMP_STOP;
+ }
+
+ return 0;
+}
+
static int calendar_is_busy(struct ast_calendar *cal)
{
- struct ao2_iterator i;
- struct ast_calendar_event *event;
- struct timeval tv = ast_tvnow();
-
- i = ao2_iterator_init(cal->events, 0);
- while ((event = ao2_iterator_next(&i))) {
- if (tv.tv_sec >= event->start && tv.tv_sec <= event->end && event->busy_state > AST_CALENDAR_BS_FREE) {
- event = ast_calendar_unref_event(event);
- return 1;
- }
- event = ast_calendar_unref_event(event);
- }
- return 0;
+ int is_busy = 0;
+
+ ao2_callback(cal->events, OBJ_NODATA, calendar_busy_callback, &is_busy);
+
+ return is_busy;
}
static enum ast_device_state calendarstate(const char *data)
More information about the asterisk-commits
mailing list