summaryrefslogtreecommitdiff
path: root/res/res_calendar.c
diff options
context:
space:
mode:
authorLudovic Gasc (GMLudo) <gmludo@gmail.com>2016-09-29 19:45:39 +0200
committerJoshua Colp <jcolp@digium.com>2016-10-10 10:43:53 -0500
commit9f62feca6085ba7bf71bfafa953846d255603369 (patch)
tree7663c51b4cb8b86eb57e6b4f7b608c7f363f007c /res/res_calendar.c
parent2d2a8944bed593e3cd2a66fe1b25288a62437423 (diff)
res_calendar: Add support for fetching calendars when reloading
We use a lot res_calendar, we are very happy with that, especially because you use libical, the almost alone opensource library that supports really ical format with all types of recurrency. Nevertheless, some features are missed for our business use cases. This first patch adds a new option in calendar.conf: fetch_again_at_reload. Be my guest for a better name. If it's true, when you'll launch "module reload res_calendar.so", Asterisk will download again the calendar. The business use case is that we have a WebUI with a scheduler planner, we know when the calendars are modified. For now, we need to define 1 minute of timeout to have a chance that our user doesn't wait too long between the modification and the real test. But it generates a lot of useless HTTP traffic. ASTERISK-26422 #close Change-Id: I384b02ebfa42b142bbbd5b7221458c7f4dee7077
Diffstat (limited to 'res/res_calendar.c')
-rw-r--r--res/res_calendar.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/res/res_calendar.c b/res/res_calendar.c
index 6f6f711b3..029ecebd0 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -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);