diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-01-05 19:56:47 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-01-05 19:56:47 +0000 |
commit | deb2725de83abe0712764f81efec19cc6d9be82d (patch) | |
tree | 69c3623b6d48846b6aba6bcdb42dec663d2fc808 /app.c | |
parent | dd80a5a5c083c54a1eb0156d2ac44b3311a67dbb (diff) |
Merge Tony's attended # transfer with changes (bug #3241)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4677 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'app.c')
-rwxr-xr-x | app.c | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -30,11 +30,56 @@ #include <asterisk/options.h> #include <asterisk/utils.h> #include <asterisk/lock.h> +#include <asterisk/indications.h> #include "asterisk.h" #include "astconf.h" #define MAX_OTHER_FORMATS 10 + +int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout) +{ + struct tone_zone_sound *ts; + int res=0, x=0; + + if(!timeout && chan->pbx) + timeout = chan->pbx->dtimeout; + else if(!timeout) + timeout = 5; + + ts = ast_get_indication_tone(chan->zone,"dial"); + if (ts && ts->data[0]) { + res = ast_playtones_start(chan, 0, ts->data, 0); + } else + ast_log(LOG_NOTICE,"Huh....? no dial for indications?\n"); + + memset(collect, 0, size); + for (x=0; strlen(collect) < size; ) { + res = ast_waitfordigit(chan, timeout); + if (!ast_ignore_pattern(context, collect)) + ast_playtones_stop(chan); + if (res < 1) + break; + collect[x++] = res; + if (!ast_matchmore_extension(chan, context, collect, 1, chan->cid.cid_num)) { + if (collect[x-1] == '#') { + /* Not a valid extension, ending in #, assume the # was to finish dialing */ + collect[x-1] = '\0'; + } + break; + } + } + if (res >= 0) { + if (ast_exists_extension(chan, context, collect, 1, chan->cid.cid_num)) + res = 1; + else + res = 0; + } + return res; +} + + + /* set timeout to 0 for "standard" timeouts. Set timeout to -1 for "ludicrous time" (essentially never times out) */ int ast_app_getdata(struct ast_channel *c, char *prompt, char *s, int maxlen, int timeout) |