aboutsummaryrefslogtreecommitdiffstats
path: root/app.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-01-05 19:56:47 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-01-05 19:56:47 +0000
commitdeb2725de83abe0712764f81efec19cc6d9be82d (patch)
tree69c3623b6d48846b6aba6bcdb42dec663d2fc808 /app.c
parentdd80a5a5c083c54a1eb0156d2ac44b3311a67dbb (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-xapp.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/app.c b/app.c
index f964bd2a1..8b7ecb05c 100755
--- a/app.c
+++ b/app.c
@@ -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)