--- old/asterisk-1.0.5/apps/app_dial.c 2005-01-17 17:52:49.000000000 -0500 +++ asterisk-1.0.5/apps/app_dial.c 2005-02-22 16:08:51.000000000 -0500 @@ -73,6 +73,7 @@ " 'C' -- reset call detail record for this call.\n" " 'P[(x)]' -- privacy mode, using 'x' as database if provided.\n" " 'g' -- goes on in context if the destination channel hangs up\n" +" 'e' -- Force the caller to Explicitly accept the call\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" " 'D([digits])' -- Send DTMF digit string *after* called party has answered\n" @@ -432,6 +433,7 @@ int privacy=0; int announce=0; int resetcdr=0; + int eca=0; // Explicit Call Acceptance /BAK/ char numsubst[AST_MAX_EXTENSION]; char restofit[AST_MAX_EXTENSION]; char *transfer = NULL; @@ -730,6 +732,8 @@ else allowdisconnect_in = tmp->allowdisconnect_in = 0; if(strchr(transfer, 'g')) go_on=1; + if (strchr(transfer, 'e')) + eca = 1; if (strchr(transfer, 'f')) tmp->forcecallerid = 1; else tmp->forcecallerid = 0; @@ -969,6 +973,57 @@ } } + if (!res && eca) { + ast_verbose(VERBOSE_PREFIX_3 "Requesting explicit call acceptance...\n"); + // Start autoservice on the other chan + res = ast_autoservice_start(chan); + + eca = 0; // Counter to prevent looping forever + do { + // Detect if we're looping too many times + eca++; + if (eca > 2) { + ast_verbose(VERBOSE_PREFIX_3 "Called user did not enter a decision. Continuing...\n"); + go_on = 1; + res = -1; + digit = -1; + } + + if (!res) + digit = ast_play_and_wait(peer, "incoming-call"); + if (!digit) { + if (chan->callerid) { + digit = ast_say_digit_str(peer, chan->callerid, AST_DIGIT_ANY, peer->language); + } else { + digit = ast_play_and_wait(peer, "from-unknown-caller"); + } + } + + if (!digit) + digit = ast_play_and_wait(peer, "accept-or-reject"); + if (!digit) + digit = ast_waitfordigit(peer, 6000); + switch(digit) { + // FIXME Why do I have to use 49==1, 50==2 here? + case 49: + ast_verbose(VERBOSE_PREFIX_3 "Call accepted by peer.\n"); + break; + case 50: + case -1: + ast_verbose(VERBOSE_PREFIX_3 "Call rejected by peer.\n"); + go_on = 1; + res = -1; + break; + default: + // Invalid digit pressed, loop + digit = 0; + break; + } + } while (!digit && !res); + // Ok, done. stop autoservice + ast_autoservice_stop(chan); + } + if (!res) { if (calldurationlimit > 0) { time(&now);