mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 11:58:52 +00:00
Merge "res_calendar: Add support for fetching calendars when reloading"
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
;refresh = 15 ; refresh calendar every n minutes
|
||||
;timeframe = 60 ; number of minutes of calendar data to pull for each refresh period
|
||||
; ; should always be >= refresh
|
||||
;fetch_again_at_reload = no ; to reload the calendar content when the module is reloaded
|
||||
;
|
||||
;
|
||||
; You can set up res_calendar to execute a call upon an upcoming busy status
|
||||
; The following fields are available from the ${CALENDAR_EVENT(<field>)} dialplan function:
|
||||
|
@@ -129,6 +129,7 @@ struct ast_calendar {
|
||||
int autoreminder; /*!< If set, override any calendar_tech specific notification times and use this time (in mins) */
|
||||
int notify_waittime; /*!< Maxiumum time to allow for a notification attempt */
|
||||
int refresh; /*!< When to refresh the calendar events */
|
||||
int fetch_again_at_reload; /*!< To reload the calendar content when the module is reloaded */
|
||||
int timeframe; /*!< Span (in mins) of calendar data to pull with each request */
|
||||
pthread_t thread; /*!< The thread that the calendar is loaded/updated in */
|
||||
ast_cond_t unload;
|
||||
|
@@ -436,6 +436,7 @@ static struct ast_calendar *build_calendar(struct ast_config *cfg, const char *c
|
||||
cal->refresh = 3600;
|
||||
cal->timeframe = 60;
|
||||
cal->notify_waittime = 30000;
|
||||
cal->fetch_again_at_reload = 0;
|
||||
|
||||
for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
|
||||
if (!strcasecmp(v->name, "autoreminder")) {
|
||||
@@ -457,6 +458,8 @@ static struct ast_calendar *build_calendar(struct ast_config *cfg, const char *c
|
||||
ast_string_field_set(cal, notify_appdata, v->value);
|
||||
} else if (!strcasecmp(v->name, "refresh")) {
|
||||
cal->refresh = atoi(v->value);
|
||||
} else if (!strcasecmp(v->name, "fetch_again_at_reload")) {
|
||||
cal->fetch_again_at_reload = ast_true(v->value);
|
||||
} else if (!strcasecmp(v->name, "timeframe")) {
|
||||
cal->timeframe = atoi(v->value);
|
||||
} else if (!strcasecmp(v->name, "setvar")) {
|
||||
@@ -482,7 +485,7 @@ static struct ast_calendar *build_calendar(struct ast_config *cfg, const char *c
|
||||
}
|
||||
}
|
||||
|
||||
if (new_calendar) {
|
||||
if (new_calendar || cal->fetch_again_at_reload) {
|
||||
cal->thread = AST_PTHREADT_NULL;
|
||||
ast_cond_init(&cal->unload, NULL);
|
||||
ao2_link(calendars, cal);
|
||||
|
Reference in New Issue
Block a user