diff options
author | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-07-17 19:40:29 +0000 |
---|---|---|
committer | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-07-17 19:40:29 +0000 |
commit | cdfb9990ad122b984e00eed53e8f2f7858e3338f (patch) | |
tree | 7e225066fa0140f45cb6f8338bcade84fdc30ec1 /apps/app_dial.c | |
parent | a139ab742b8a9b652bcc6e79f4d195889e5c61f2 (diff) |
via 10206, I have added an option (e) to Dial to allow the h exten to get run on peer. Had to upgrade ast_flag stuff to 64 bits to do this.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@75400 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_dial.c')
-rw-r--r-- | apps/app_dial.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index d9b068dc7..ac97f5a32 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -109,7 +109,8 @@ static char *descrip = " 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" @@ -256,10 +257,11 @@ enum { OPT_IGNORE_FORWARDING = (1 << 27), OPT_CALLEE_GOSUB = (1 << 28), OPT_CANCEL_ELSEWHERE = (1 << 29), + OPT_PEER_H = (1 << 30), }; -#define DIAL_STILLGOING (1 << 30) -#define DIAL_NOFORWARDHTML (1 << 31) +#define DIAL_STILLGOING (1 << 31) +#define DIAL_NOFORWARDHTML ((uint64_t)1 << 32) /* flags are now 64 bits, so keep it up! */ enum { OPT_ARG_ANNOUNCE = 0, @@ -282,6 +284,7 @@ AST_APP_OPTIONS(dial_exec_options, { AST_APP_OPTION('c', OPT_CANCEL_ELSEWHERE), 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), @@ -314,7 +317,7 @@ AST_APP_OPTIONS(dial_exec_options, { struct chanlist { struct chanlist *next; struct ast_channel *chan; - unsigned int flags; + uint64_t flags; int forwards; }; @@ -1789,7 +1792,29 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags 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_debug(1, "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; |