aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_page.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-31 20:05:46 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-31 20:05:46 +0000
commit9bc20020f1e99162aca248e3f071ee5b5fea35d0 (patch)
treee8f75f4ce91647652c8eaec16c7afe3c7b0bcc5f /apps/app_page.c
parentb417a0a687cc0c5ed9bac14430cfa70281274657 (diff)
* Fixed timeout logic in the dialing API as setting timeouts
had no effect * Updated dialing API documentation to indicate that timeouts are specified in milliseconds * Added a new timeout argument to the Page application. If time expires, any endpoints which have not answered will be hung up. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@153223 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_page.c')
-rw-r--r--apps/app_page.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/apps/app_page.c b/apps/app_page.c
index 9f94b491d..33ff1b489 100644
--- a/apps/app_page.c
+++ b/apps/app_page.c
@@ -49,7 +49,7 @@ static const char *app_page= "Page";
static const char *page_synopsis = "Pages phones";
static const char *page_descrip =
-"Page(Technology/Resource&Technology2/Resource2[,options])\n"
+"Page(Technology/Resource&Technology2/Resource2[,options][,timeout])\n"
" Places outbound calls to the given technology / resource and dumps\n"
"them into a conference bridge as muted participants. The original\n"
"caller is dumped into the conference as a speaker and the room is\n"
@@ -57,7 +57,10 @@ static const char *page_descrip =
" d - full duplex audio\n"
" q - quiet, do not play beep to caller\n"
" r - record the page into a file (see 'r' for app_meetme)\n"
-" s - only dial channel if devicestate says it is not in use\n";
+" s - only dial channel if devicestate says it is not in use\n"
+"The timeout parameter specifies the length of time that the system\n"
+"will attempt to connect a call. After this duration, any intercom\n"
+"calls that have not been answered will be hung up by the system.\n";
enum {
PAGE_DUPLEX = (1 << 0),
@@ -77,13 +80,21 @@ AST_APP_OPTIONS(page_opts, {
static int page_exec(struct ast_channel *chan, void *data)
{
- char *options, *tech, *resource, *tmp;
+ char *tech, *resource, *tmp;
char meetmeopts[88], originator[AST_CHANNEL_NAME], *opts[0];
struct ast_flags flags = { 0 };
unsigned int confid = ast_random();
struct ast_app *app;
int res = 0, pos = 0, i = 0;
struct ast_dial *dials[MAX_DIALS];
+ int timeout = 0;
+ char *parse;
+
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(devices);
+ AST_APP_ARG(options);
+ AST_APP_ARG(timeout);
+ );
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "This application requires at least one argument (destination(s) to page)\n");
@@ -95,21 +106,28 @@ static int page_exec(struct ast_channel *chan, void *data)
return -1;
};
- options = ast_strdupa(data);
+ parse = ast_strdupa(data);
+
+ AST_STANDARD_APP_ARGS(args, parse);
ast_copy_string(originator, chan->name, sizeof(originator));
- if ((tmp = strchr(originator, '-')))
+ if ((tmp = strchr(originator, '-'))) {
*tmp = '\0';
+ }
+
+ if (!ast_strlen_zero(args.options)) {
+ ast_app_parse_options(page_opts, &flags, opts, args.options);
+ }
- tmp = strsep(&options, ",");
- if (options)
- ast_app_parse_options(page_opts, &flags, opts, options);
+ if (!ast_strlen_zero(args.timeout)) {
+ timeout = atoi(args.timeout);
+ }
snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe,%ud,%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"),
(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );
/* Go through parsing/calling each device */
- while ((tech = strsep(&tmp, "&"))) {
+ while ((tech = strsep(&args.devices, "&"))) {
int state = 0;
struct ast_dial *dial = NULL;
@@ -143,11 +161,18 @@ static int page_exec(struct ast_channel *chan, void *data)
}
/* Append technology and resource */
- ast_dial_append(dial, tech, resource);
+ if (ast_dial_append(dial, tech, resource) == -1) {
+ ast_log(LOG_ERROR, "Failed to add %s to outbound dial\n", tech);
+ continue;
+ }
/* Set ANSWER_EXEC as global option */
ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, meetmeopts);
+ if (timeout) {
+ ast_dial_set_global_timeout(dial, timeout * 1000);
+ }
+
/* Run this dial in async mode */
ast_dial_run(dial, chan, 1);