Index: apps/app_dial.c =================================================================== --- apps/app_dial.c (revision 75350) +++ apps/app_dial.c (working copy) @@ -107,7 +107,8 @@ " party has answered, but before the call gets bridged. The 'called'\n" " DTMF string is sent to the called party, and the 'calling' DTMF\n" " string is sent to the calling party. Both parameters can be used\n" -" alone.\n" +" alone.\n" +" e - execute the 'h' extension for peer after the call ends\n" " f - Force the callerid of the *calling* channel to be set as the\n" " extension associated with the channel using a dialplan 'hint'.\n" " For example, some PSTNs do not allow CallerID to be set to anything\n" @@ -241,6 +242,7 @@ OPT_CALLEE_PARK = (1 << 25), OPT_CALLER_PARK = (1 << 26), OPT_IGNORE_FORWARDING = (1 << 27), + OPT_PEER_H = (1 << 28), } dial_exec_option_flags; #define DIAL_STILLGOING (1 << 30) @@ -265,6 +267,7 @@ AST_APP_OPTION('C', OPT_RESETCDR), AST_APP_OPTION('d', OPT_DTMF_EXIT), AST_APP_OPTION_ARG('D', OPT_SENDDTMF, OPT_ARG_SENDDTMF), + AST_APP_OPTION('e', OPT_PEER_H), AST_APP_OPTION('f', OPT_FORCECLID), AST_APP_OPTION('g', OPT_GO_ON), AST_APP_OPTION_ARG('G', OPT_GOTO, OPT_ARG_GOTO), @@ -1663,8 +1666,29 @@ char toast[80]; snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time)); pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast); - } + + if (ast_test_flag(&opts, OPT_PEER_H)) { + ast_log(LOG_NOTICE,"PEER context: %s; PEER exten: %s; PEER priority: %d\n", + peer->context, peer->exten, peer->priority); + } + strcpy(peer->context, chan->context); + + if (ast_test_flag(&opts, OPT_PEER_H) && ast_exists_extension(peer, peer->context, "h", 1, peer->cid.cid_num)) { + strcpy(peer->exten, "h"); + peer->priority = 1; + while (ast_exists_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num)) { + if ((res = ast_spawn_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num))) { + /* Something bad happened, or a hangup has been requested. */ + ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name); + if (option_verbose > 1) + ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name); + break; + } + peer->priority++; + } + } + } if (res != AST_PBX_NO_HANGUP_PEER) { if (!chan->_softhangup) chan->hangupcause = peer->hangupcause;