diff options
author | anthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-04-26 23:22:34 +0000 |
---|---|---|
committer | anthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-04-26 23:22:34 +0000 |
commit | aa820ac9405d4a3f4fb6532730d830312304fa77 (patch) | |
tree | 795ee349d435830084b8f5f9c00c84301b059439 /apps | |
parent | b1ebc7d3c1eb97b62eab34fdc3e3e2d67b1f791b (diff) |
applied final release of bug 1353 per Mark's permission
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2782 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/app_dial.c | 109 | ||||
-rwxr-xr-x | apps/app_queue.c | 9 |
2 files changed, 114 insertions, 4 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index af3c70c6d..3492c1004 100755 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -20,6 +20,7 @@ #include <asterisk/module.h> #include <asterisk/translate.h> #include <asterisk/say.h> +#include <asterisk/config.h> #include <asterisk/parking.h> #include <asterisk/musiconhold.h> #include <asterisk/callerid.h> @@ -68,6 +69,15 @@ static char *descrip = " 'g' -- goes on in context if the destination channel hangs up\n" " 'A(x)' -- play an announcement to the called party, using x as file\n" " 'S(x)' -- hangup the call after x seconds AFTER called party picked up\n" +" 'L(x[:y][:z])' -- Limit the call to 'x' ms warning when 'y' ms are left (repeated every 'z' ms)\n" +" -- Only 'x' is required, 'y' and 'z' are optional.\n" +" -- The following special variables are optional:\n" +" ** LIMIT_PLAYAUDIO_CALLER (default yes) Play sounds to the caller.\n" +" ** LIMIT_PLAYAUDIO_CALLEE Play sounds to the callee.\n" +" ** LIMIT_TIMEOUT_FILE File to play when time is up.\n" +" ** LIMIT_CONNECT_FILE File to play when call begins.\n" +" ** LIMIT_WARNING_FILE File to play as warning if 'y' is defined.\n" +" -- 'timeleft' is a special sound macro to auto-say the time left and is the default.\n\n" " In addition to transferring the call, a call may be parked and then picked\n" "up by another user.\n" " The optional URL will be sent to the called party if the channel supports\n" @@ -390,7 +400,19 @@ static int dial_exec(struct ast_channel *chan, void *data) unsigned int calldurationlimit=0; char *cdl; time_t now; - + struct ast_bridge_config config; + long timelimit = 0; + long play_warning = 0; + long warning_freq=0; + char *warning_sound=NULL; + char *end_sound=NULL; + char *start_sound=NULL; + char *limitptr; + char limitdata[256]; + char *stack,*var; + int play_to_caller=0,play_to_callee=0; + int playargs=0; + if (!data) { ast_log(LOG_WARNING, "Dial requires an argument (technology1/number1&technology2/number2...|optional timeout|options)\n"); return -1; @@ -430,13 +452,81 @@ static int dial_exec(struct ast_channel *chan, void *data) if (transfer) { + /* Extract call duration limit */ if ((cdl = strstr(transfer, "S("))) { calldurationlimit=atoi(cdl+2); if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Setting call duration limit to %i seconds.\n",calldurationlimit); } - + + /* XXX LIMIT SUPPORT */ + if ((limitptr = strstr(transfer, "L("))) { + strncpy(limitdata, limitptr + 2, sizeof(limitdata) - 1); + /* Overwrite with X's what was the limit info */ + while(*limitptr && (*limitptr != ')')) + *(limitptr++) = 'X'; + if (*limitptr) + *limitptr = 'X'; + /* Now find the end of the privdb */ + limitptr = strchr(limitdata, ')'); + if (limitptr) + *limitptr = '\0'; + else { + ast_log(LOG_WARNING, "Limit Data lacking trailing ')'\n"); + } + + var = pbx_builtin_getvar_helper(chan,"LIMIT_PLAYAUDIO_CALLER"); + play_to_caller = var ? ast_true(var) : 1; + + var = pbx_builtin_getvar_helper(chan,"LIMIT_PLAYAUDIO_CALLEE"); + play_to_callee = var ? ast_true(var) : 0; + + if(! play_to_caller && ! play_to_callee) + play_to_caller=1; + + var = pbx_builtin_getvar_helper(chan,"LIMIT_WARNING_FILE"); + warning_sound = var ? var : "timeleft"; + + var = pbx_builtin_getvar_helper(chan,"LIMIT_TIMEOUT_FILE"); + end_sound = var ? var : NULL; + + var = pbx_builtin_getvar_helper(chan,"LIMIT_CONNECT_FILE"); + start_sound = var ? var : NULL; + + var=stack=limitdata; + + var = strsep(&stack, ":"); + if(var) { + timelimit = atol(var); + playargs++; + } + var = strsep(&stack, ":"); + if(var) { + play_warning = atol(var); + playargs++; + } + + var = strsep(&stack, ":"); + if(var) { + warning_freq = atol(var); + playargs++; + } + + if(! timelimit) { + timelimit=play_to_caller=play_to_callee=play_warning=warning_freq=0; + warning_sound=NULL; + } + calldurationlimit=0; /* undo effect of S(x) in case they are both used */ + if(! play_warning && ! start_sound && ! end_sound && timelimit) { /* more efficient do it like S(x) does since no advanced opts*/ + calldurationlimit=timelimit/1000; + timelimit=play_to_caller=play_to_callee=play_warning=warning_freq=0; + } + else + ast_verbose(VERBOSE_PREFIX_3"Limit Data: timelimit=%ld\n -- play_warning=%ld\n -- play_to_caller=%s\n -- play_to_callee=%s\n -- warning_freq=%ld\n -- warning_sound=%s\n -- end_sound=%s\n -- start_sound=%s\n",timelimit,play_warning,play_to_caller ? "yes" : "no",play_to_callee ? "yes" : "no",warning_freq,warning_sound ? warning_sound : "UNDEF",end_sound ? end_sound : "UNDEF",start_sound ? start_sound : "UNDEF"); + + } + /* XXX ANNOUNCE SUPPORT */ if ((ann = strstr(transfer, "A("))) { announce = 1; @@ -729,7 +819,20 @@ static int dial_exec(struct ast_channel *chan, void *data) time(&now); chan->whentohangup = now + calldurationlimit; } - res = ast_bridge_call(chan, peer, allowredir_in, allowredir_out, allowdisconnect); + + memset(&config,0,sizeof(struct ast_bridge_config)); + config.play_to_caller=play_to_caller; + config.play_to_callee=play_to_callee; + config.allowredirect_in = allowredir_in; + config.allowredirect_out = allowredir_out; + config.allowdisconnect = allowdisconnect; + config.timelimit = timelimit; + config.play_warning = play_warning; + config.warning_freq = warning_freq; + config.warning_sound = warning_sound; + config.end_sound = end_sound; + config.start_sound = start_sound; + res = ast_bridge_call(chan,peer,&config); if (res != AST_PBX_NO_HANGUP_PEER) ast_hangup(peer); diff --git a/apps/app_queue.c b/apps/app_queue.c index d8e13313c..611b1f2c9 100755 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -874,6 +874,7 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri char digit = 0; time_t callstart; time_t now; + struct ast_bridge_config config; /* Hold the lock while we setup the outgoing calls */ ast_mutex_lock(&qe->parent->lock); strncpy(queuename, qe->parent->name, sizeof(queuename) - 1); @@ -1030,7 +1031,13 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri strncpy(oldcontext, qe->chan->context, sizeof(oldcontext) - 1); strncpy(oldexten, qe->chan->exten, sizeof(oldexten) - 1); time(&callstart); - bridge = ast_bridge_call(qe->chan, peer, allowredir_in, allowredir_out, allowdisconnect); + + memset(&config,0,sizeof(struct ast_bridge_config)); + config.allowredirect_in = allowredir_in; + config.allowredirect_out = allowredir_out; + config.allowdisconnect = allowdisconnect; + bridge = ast_bridge_call(qe->chan,peer,&config); + if (strcasecmp(oldcontext, qe->chan->context) || strcasecmp(oldexten, qe->chan->exten)) { ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "TRANSFER", "%s|%s", qe->chan->exten, qe->chan->context); } else if (qe->chan->_softhangup) { |