<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#ffffff">
Whoops... I had did a reply and changed the subject.<br>
If anyone wants to reply to my patch, please reply to this message
instead<br>
<br>
Original Post:<br>
------------------<br>
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 12px;" lang="x-western">
<pre wrap="">I've just finished writing a hangup handler module. And associated
helper function ast_pbx_exten_parse(), which I think is needed to
separate the functionality of parsing a gosub target from actually going
to the target. It's been malloc debugged and valgrind debugged.
Overview of module:
I find the 'h' extensions to be limited, cumbersome, and error prone
when writing very complex dialplan, especially when using lots of gotos
and gosubs. Say you have a main dialplan entry point context called
callqueue. If at any point after callqueue runs, you want to run a
hangup handler specific for the callqueue dialplan, you have to put an
'h' extension in every single context you plan to possibly jump to after
entering callqueue. This solves that problem, and gives the added
benefit of cascading hangup handlers.
For proof of concept development convenience, I used an existing
function for setting up the hangup handlers, but it should probably be
it's own function
And for more convenience, I have the bulk of the code in channel.c, but
I'm not totally sure where it should belong.
Some other stuff needs adjusting as well... right now there's fixed
sized buffers for context,exten,priority... and there's several spots
that didn't get tabs...
If this gets the thumbs up, I'll fix the formatting and post a reviewboard.
Without further ado, here it is:
Usage:
context callqueueHangupHandler {
s => {
// cleanup here
}
}
context callqueue {
s => {
Set(CHANNEL(addhanguphandler)="callqueueHangupHandler,s,1");
gosub(foo...)
goto bar..;
}
}
Execution:
1. callqueue: set(channel(addhanguphandler...)
2. gosub
3. goto bar
4. channel hangs up
5. channel launches dialplan @callqueueHangupHandler
Cascading hangup handlers are also possible, where as with standard
dialplan h extensions, they are not:
context test {
s => {
goto fooTest, s, 1;
}
}
context fooTest {
s => {
GoSub(barTest,s,1);
}
h => {
NoOp(footest hangup);
}
}
context barTest {
s => {
NoOp(something in bar);
Hangup();
}
h => {
NoOp(bartest hangup);
}
}
Execution:
-- Goto (fooTest,s,1)
-- Executing [s@fooTest:1] Gosub("SIP/tipton-local-0000000b",
"barTest,s,1") in new stack
-- Executing [s@barTest:1] NoOp("SIP/tipton-local-0000000b",
"something in bar") in new stack
-- Executing [s@barTest:2] Hangup("SIP/tipton-local-0000000b", "")
in new stack
== Spawn extension (barTest, s, 2) exited non-zero on
'SIP/intellasoft-tipton-local-0000000b'
-- Executing [h@barTest:1] NoOp("SIP/tipton-local-0000000b",
"bartest hangup") in new stack
Only the deepest 'h' exten will execute
Where as with this new method, you could call addhanguphandler as many
times as you like, and they will all execute in the order of most
recently added will execute first.
Set(CHANNEL(addhanguphandler)="callqueueHangupHandler,s,1");
Set(CHANNEL(addhanguphandler)="someotherHangupHandler,s,1");
Set(CHANNEL(addhanguphandler)="yetanotherHangupHandler,s,1");
Code (based off of 1.6.0.26)
</pre>
</div>
attached to preserve formatting<br>
</body>
</html>