rendered paste body else if (f->frametype == AST_FRAME_DTMF_BEGIN)
{
//else if ((f->frametype == AST_FRAME_DTMF) && (!res))
ASTOBJ_WRLOCK(ps);
ps->immediate_exit = 1;
ASTOBJ_UNLOCK(ps);
int x;
int tries = 3;
int maxdigits = 255;
int to = chan->pbx ? chan->pbx->rtimeout * 1000 : 6000;
char tmp[256] = "";
while(tries && !res)
{
for (x = 0; x < maxdigits; )
{
res = ast_waitfordigit(chan, to); // returns DTMF
if (res < 1) // 0 on error or no entry
{
tmp[x]='\0';
break;
}
tmp[x++] = res; // append it to array
if (tmp[x-1] == '#')
{
tmp[x-1] = '\0'; // # delimits
break;
}
}
if (res > -1)
{
pbx_builtin_setvar_helper(chan, "SWIFT_DTMF", tmp);
if (!ast_strlen_zero(tmp))
{
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "User entered '%s'\n", tmp);
tries = 0;
}
else
{
tries--;
if (option_verbose > 2)
{
if (tries)
ast_verbose(VERBOSE_PREFIX_3 "User entered nothing, %d chance%s left\n", tries, (tries != 1) ? "s" : "");
else
ast_verbose(VERBOSE_PREFIX_3 "User entered nothing.\n");
}
}
res = 0;
}
else
{
pbx_builtin_setvar_helper(chan, "SWIFT_DTMF", tmp);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "User disconnected\n");
}
}
ast_frfree(f);
} else { // ignore other frametypes
ast_frfree(f);
}