#include "asterisk.h"
#include "asterisk/stringfields.h"
#include "asterisk/config.h"
#include "asterisk/linkedlists.h"
#include "asterisk/lock.h"
#include "asterisk/dial.h"


Go to the source code of this file.
Data Structures | |
| struct | ast_calendar |
| Asterisk calendar structure. More... | |
| struct | ast_calendar_attendee |
| struct | ast_calendar_event |
| struct | ast_calendar_event::attendees |
| struct | ast_calendar_tech |
| Individual calendaring technology data. More... | |
Enumerations | |
| enum | ast_calendar_busy_state { AST_CALENDAR_BS_FREE = 0, AST_CALENDAR_BS_BUSY_TENTATIVE, AST_CALENDAR_BS_BUSY } |
Functions | |
| void | ast_calendar_clear_events (struct ast_calendar *cal) |
| Remove all events from calendar. | |
| struct ast_config * | ast_calendar_config_acquire (void) |
| Grab and lock pointer to the calendar config (read only). | |
| void | ast_calendar_config_release (void) |
| Release the calendar config. | |
| struct ast_calendar_event * | ast_calendar_event_alloc (struct ast_calendar *cal) |
| Allocate an astobj2 ast_calendar_event object. | |
| struct ao2_container * | ast_calendar_event_container_alloc (void) |
| Allocate an astobj2 container for ast_calendar_event objects. | |
| void | ast_calendar_merge_events (struct ast_calendar *cal, struct ao2_container *new_events) |
| Add an event to the list of events for a calendar. | |
| int | ast_calendar_register (struct ast_calendar_tech *tech) |
| Register a new calendar technology. | |
| struct ast_calendar_event * | ast_calendar_unref_event (struct ast_calendar_event *event) |
| Unreference an ast_calendar_event. | |
| void | ast_calendar_unregister (struct ast_calendar_tech *tech) |
| Unregister a new calendar technology. | |
BUSYSTATE can have the values 0 (free), 1 (tentatively busy), or 2 (busy)
Usage All calendaring configuration data is located in calendar.conf and is only read directly by the Calendaring API. Each calendar technology resource must register a load_calendar callback which will be passed an ast_calendar_load_data structure. The load_calendar callback function should then set the values it needs from this cfg, load the calendar data, and then loop updating the calendar data and events baesd on the refresh interval in the ast_calendar object. Each call to the load_calendar callback will be will run in its own thread.
Updating events involves creating an astobj2 container of new events and passing it to the API through ast_calendar_merge_events.
Calendar technology resource modules must also register an unref_calendar callback which will only be called when the resource module calls ast_calendar_unregister() to unregister that module's calendar type (usually done in module_unload())
Definition in file calendar.h.
Definition at line 79 of file calendar.h.
00079 { 00080 AST_CALENDAR_BS_FREE = 0, 00081 AST_CALENDAR_BS_BUSY_TENTATIVE, 00082 AST_CALENDAR_BS_BUSY, 00083 };
| void ast_calendar_clear_events | ( | struct ast_calendar * | cal | ) |
Remove all events from calendar.
| cal | calendar whose events need to be cleared |
Definition at line 626 of file res_calendar.c.
References ao2_callback, ast_debug, clear_events_cb(), ast_calendar::events, ast_calendar::name, OBJ_MULTIPLE, OBJ_NODATA, and OBJ_UNLINK.
Referenced by calendar_destructor().
00627 { 00628 ast_debug(3, "Clearing all events for calendar %s\n", cal->name); 00629 00630 ao2_callback(cal->events, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, clear_events_cb, NULL); 00631 }
| struct ast_config* ast_calendar_config_acquire | ( | void | ) | [read] |
Grab and lock pointer to the calendar config (read only).
Definition at line 249 of file res_calendar.c.
References ast_rwlock_rdlock, and ast_rwlock_unlock.
Referenced by caldav_load_calendar(), ewscal_load_calendar(), exchangecal_load_calendar(), and ical_load_calendar().
00250 { 00251 ast_rwlock_rdlock(&config_lock); 00252 00253 if (!calendar_config) { 00254 ast_rwlock_unlock(&config_lock); 00255 return NULL; 00256 } 00257 00258 return calendar_config; 00259 }
| void ast_calendar_config_release | ( | void | ) |
Release the calendar config.
Definition at line 261 of file res_calendar.c.
References ast_rwlock_unlock, and config_lock.
Referenced by caldav_load_calendar(), ewscal_load_calendar(), exchangecal_load_calendar(), and ical_load_calendar().
00262 { 00263 ast_rwlock_unlock(&config_lock); 00264 }
| struct ast_calendar_event* ast_calendar_event_alloc | ( | struct ast_calendar * | cal | ) | [read] |
Allocate an astobj2 ast_calendar_event object.
| cal | calendar to allocate an event for |
Definition at line 633 of file res_calendar.c.
References ao2_alloc, ast_calendar_unref_event(), AST_LIST_HEAD_INIT_NOLOCK, ast_string_field_init, ast_calendar_event::attendees, calendar_event_destructor(), and evententry::event.
Referenced by caldav_add_event(), calendar_write_exec(), icalendar_add_event(), parse_tag(), and startelm().
00634 { 00635 struct ast_calendar_event *event; 00636 if (!(event = ao2_alloc(sizeof(*event), calendar_event_destructor))) { 00637 return NULL; 00638 } 00639 00640 if (ast_string_field_init(event, 32)) { 00641 event = ast_calendar_unref_event(event); 00642 return NULL; 00643 } 00644 00645 event->owner = cal; 00646 event->notify_sched = -1; 00647 event->bs_start_sched = -1; 00648 event->bs_end_sched = -1; 00649 00650 AST_LIST_HEAD_INIT_NOLOCK(&event->attendees); 00651 00652 return event; 00653 }
| struct ao2_container* ast_calendar_event_container_alloc | ( | void | ) | [read] |
Allocate an astobj2 container for ast_calendar_event objects.
Definition at line 655 of file res_calendar.c.
References ao2_container_alloc, CALENDAR_BUCKETS, event_cmp_fn(), and event_hash_fn().
Referenced by caldav_load_calendar(), ewscal_load_calendar(), exchangecal_load_calendar(), and ical_load_calendar().
00656 { 00657 return ao2_container_alloc(CALENDAR_BUCKETS, event_hash_fn, event_cmp_fn); 00658 }
| void ast_calendar_merge_events | ( | struct ast_calendar * | cal, | |
| struct ao2_container * | new_events | |||
| ) |
Add an event to the list of events for a calendar.
| cal | calendar containing the events to be merged | |
| new_events | an oa2 container of events to be merged into cal->events |
Definition at line 1005 of file res_calendar.c.
References add_new_event_cb(), ao2_callback, ast_calendar::events, merge_events_cb(), OBJ_MULTIPLE, OBJ_NODATA, and OBJ_UNLINK.
Referenced by endelm(), icalendar_update_events(), startelm(), update_caldav(), and update_exchangecal().
01006 { 01007 /* Loop through all events attached to the calendar. If there is a matching new event 01008 * merge its data over and handle any schedule changes that need to be made. Then remove 01009 * the new_event from new_events so that we are left with only new_events that we can add later. */ 01010 ao2_callback(cal->events, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, merge_events_cb, new_events); 01011 01012 /* Now, we should only have completely new events in new_events. Loop through and add them */ 01013 ao2_callback(new_events, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, add_new_event_cb, cal->events); 01014 }
| int ast_calendar_register | ( | struct ast_calendar_tech * | tech | ) |
Register a new calendar technology.
| tech | calendar technology to register |
| 0 | success | |
| -1 | failure |
Definition at line 522 of file res_calendar.c.
References AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_verb, ast_calendar_tech::description, evententry::list, load_tech_calendars(), LOG_WARNING, and ast_calendar_tech::type.
Referenced by load_module().
00523 { 00524 struct ast_calendar_tech *iter; 00525 00526 AST_LIST_LOCK(&techs); 00527 AST_LIST_TRAVERSE(&techs, iter, list) { 00528 if(!strcasecmp(tech->type, iter->type)) { 00529 ast_log(LOG_WARNING, "Already have a handler for calendar type '%s'\n", tech->type); 00530 AST_LIST_UNLOCK(&techs); 00531 return -1; 00532 } 00533 } 00534 AST_LIST_INSERT_HEAD(&techs, tech, list); 00535 AST_LIST_UNLOCK(&techs); 00536 00537 ast_verb(2, "Registered calendar type '%s' (%s)\n", tech->type, tech->description); 00538 00539 return load_tech_calendars(tech); 00540 }
| struct ast_calendar_event* ast_calendar_unref_event | ( | struct ast_calendar_event * | event | ) | [read] |
Unreference an ast_calendar_event.
| event | event to unref |
Definition at line 312 of file res_calendar.c.
References ao2_ref.
Referenced by ast_calendar_event_alloc(), caldav_add_event(), calendar_devstate_change(), calendar_query_exec(), calendar_write_exec(), do_notify(), endelm(), event_notification_destroy(), handle_show_calendar(), icalendar_add_event(), merge_events_cb(), and parse_tag().
00313 { 00314 ao2_ref(event, -1); 00315 return NULL; 00316 }
| void ast_calendar_unregister | ( | struct ast_calendar_tech * | tech | ) |
Unregister a new calendar technology.
| tech | calendar technology to unregister |
| 0 | success | |
| -1 | failure |
Definition at line 554 of file res_calendar.c.
References ao2_callback, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_verb, evententry::list, match_caltech_cb(), OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, and ast_calendar_tech::type.
Referenced by load_tech_calendars(), and unload_module().
00555 { 00556 struct ast_calendar_tech *iter; 00557 00558 AST_LIST_LOCK(&techs); 00559 AST_LIST_TRAVERSE_SAFE_BEGIN(&techs, iter, list) { 00560 if (iter != tech) { 00561 continue; 00562 } 00563 00564 ao2_callback(calendars, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, match_caltech_cb, tech); 00565 00566 AST_LIST_REMOVE_CURRENT(list); 00567 ast_verb(2, "Unregistered calendar type '%s'\n", tech->type); 00568 break; 00569 } 00570 AST_LIST_TRAVERSE_SAFE_END; 00571 AST_LIST_UNLOCK(&techs); 00572 00573 }
1.5.6