summaryrefslogtreecommitdiff
path: root/funcs/func_channel.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-06-29 17:02:32 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-06-29 17:02:32 +0000
commitac35b92b628064a1fcf962895f0befd57aff0442 (patch)
tree0f2a4fb769643d0ae24dfed49468d80e8652aabf /funcs/func_channel.c
parent35c533156cf94b005bd7c561d69e40dc5e837dd6 (diff)
Hangup handlers - Dialplan subroutines that run when the channel hangs up.
Hangup handlers are an alternative to the h extension. They can be used in addition to the h extension. The idea is to attach a Gosub routine to a channel that will execute when the call hangs up. Whereas which h extension gets executed depends on the location of dialplan execution when the call hangs up, hangup handlers are attached to the call channel. You can attach multiple handlers that will execute in the order of most recently added first. (closes issue ASTERISK-19549) Reported by: Mark Murawski Tested by: rmudgett Review: https://reviewboard.asterisk.org/r/2002/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369493 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs/func_channel.c')
-rw-r--r--funcs/func_channel.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/funcs/func_channel.c b/funcs/func_channel.c
index 14ece0cfd..699f3b660 100644
--- a/funcs/func_channel.c
+++ b/funcs/func_channel.c
@@ -98,6 +98,29 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<enum name="checkhangup">
<para>R/O Whether the channel is hanging up (1/0)</para>
</enum>
+ <enum name="hangup_handler_pop">
+ <para>W/O Replace the most recently added hangup handler
+ with a new hangup handler on the channel if supplied. The
+ assigned string is passed to the Gosub application when
+ the channel is hung up. Any optionally omitted context
+ and exten are supplied by the channel pushing the handler
+ before it is pushed.</para>
+ </enum>
+ <enum name="hangup_handler_push">
+ <para>W/O Push a hangup handler onto the channel hangup
+ handler stack. The assigned string is passed to the
+ Gosub application when the channel is hung up. Any
+ optionally omitted context and exten are supplied by the
+ channel pushing the handler before it is pushed.</para>
+ </enum>
+ <enum name="hangup_handler_wipe">
+ <para>W/O Wipe the entire hangup handler stack and replace
+ with a new hangup handler on the channel if supplied. The
+ assigned string is passed to the Gosub application when
+ the channel is hung up. Any optionally omitted context
+ and exten are supplied by the channel pushing the handler
+ before it is pushed.</para>
+ </enum>
<enum name="language">
<para>R/W language for sounds played.</para>
</enum>
@@ -523,6 +546,17 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
break;
}
}
+ } else if (!strcasecmp(data, "hangup_handler_pop")) {
+ /* Pop one hangup handler before pushing the new handler. */
+ ast_pbx_hangup_handler_pop(chan);
+ ast_pbx_hangup_handler_push(chan, value);
+ } else if (!strcasecmp(data, "hangup_handler_push")) {
+ ast_pbx_hangup_handler_push(chan, value);
+ } else if (!strcasecmp(data, "hangup_handler_wipe")) {
+ /* Pop all hangup handlers before pushing the new handler. */
+ while (ast_pbx_hangup_handler_pop(chan)) {
+ }
+ ast_pbx_hangup_handler_push(chan, value);
} else if (!strncasecmp(data, "secure_bridge_", 14)) {
struct ast_datastore *ds;
struct ast_secure_call_store *store;