*** cvs/asterisk/apps/app_queue.c Sat Jul 26 23:24:37 2003 --- build4/asterisk/apps/app_queue.c Sat Jul 26 23:51:10 2003 *************** *** 282,290 **** } } #define MAX 256 ! static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, int *allowredir_in, int *allowredir_out, int *allowdisconnect, char *queue) { struct localuser *o; int found; --- 282,306 ---- } } + static int valid_exit(struct queue_ent *qe, char digit) + { + char tmp[2]; + if (!strlen(qe->context)) + return 0; + tmp[0] = digit; + tmp[1] = '\0'; + if (ast_exists_extension(qe->chan, qe->context, tmp, 1, qe->chan->callerid)) { + strncpy(qe->chan->context, qe->context, sizeof(qe->chan->context) - 1); + strncpy(qe->chan->exten, tmp, sizeof(qe->chan->exten) - 1); + qe->chan->priority = 0; + return 1; + } + return 0; + } + #define MAX 256 ! static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, int *allowredir_in, int *allowredir_out, int *allowdisconnect, char *queue, char *digit) { struct localuser *o; int found; *************** *** 410,415 **** --- 426,438 ---- *to=0; return NULL; } + if (f && (f->frametype == AST_FRAME_DTMF) && (f->subclass != '*')) { + if (option_verbose > 3) + ast_verbose(VERBOSE_PREFIX_3 "User pressed digit: %c", f->subclass); + *to=0; + *digit=f->subclass; + return NULL; + } } if (!*to && (option_verbose > 2)) ast_verbose( VERBOSE_PREFIX_3 "Nobody picked up in %d ms\n", orig); *************** *** 454,459 **** --- 477,483 ---- int res = 0, bridge = 0; int zapx = 2; char *announce = NULL; + char digit = 0; /* Hold the lock while we setup the outgoing calls */ ast_pthread_mutex_lock(&qe->parent->lock); cur = qe->parent->members; *************** *** 575,588 **** to = -1; ast_pthread_mutex_unlock(&qe->parent->lock); ! peer = wait_for_answer(qe->chan, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect, qe->parent->name); if (!peer) { ! if (to) /* Musta gotten hung up */ res = -1; ! else ! /* Nobody answered, next please? */ ! res=0; goto out; } --- 599,616 ---- to = -1; ast_pthread_mutex_unlock(&qe->parent->lock); ! peer = wait_for_answer(qe->chan, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect, qe->parent->name, &digit); if (!peer) { ! if (to) { /* Musta gotten hung up */ res = -1; ! } else { ! if (digit && valid_exit(qe, digit)) ! res=digit; ! else ! /* Nobody answered, next please? */ ! res=0; ! } goto out; } *************** *** 655,676 **** retrywait = qe->parent->retry * 1000; ast_pthread_mutex_unlock(&qe->parent->lock); return ast_waitfordigit(qe->chan, retrywait); - } - - static int valid_exit(struct queue_ent *qe, char digit) - { - char tmp[2]; - if (!strlen(qe->context)) - return 0; - tmp[0] = digit; - tmp[1] = '\0'; - if (ast_exists_extension(qe->chan, qe->context, tmp, 1, qe->chan->callerid)) { - strncpy(qe->chan->context, qe->context, sizeof(qe->chan->context) - 1); - strncpy(qe->chan->exten, tmp, sizeof(qe->chan->exten) - 1); - qe->chan->priority = 0; - return 1; - } - return 0; } // [PHM 06/26/03] --- 683,688 ----