[Amportal-devel] [PATCH] Allow dialparties.agi to play nice

Problem: Dialparties adds M(whatever) macros to the dial string. Since
asterisk only supports one M(macro) command on a dialstring, this makes
it impossible for users to define their own M(custom) macro using
DIAL_OPTIONS.

Solution: Create a generic macro that will accept a list of other macros
to call. Modify dialparties to use this new macro.

The two attached patches will add a new [macro-dial-answered] macro to
extensions.conf and modify dialparties.agi to call this new macro.

Use scenario:

DIAL_OPTIONS is defined as "trM(custom-macro)"
A ring group is dialed, so dialparties needs to call M(auto-blkvm) after
the call is answered

Previous Behavior: the dialstring would be
|trM(custom-macro)M(auto-blkvm). custom-macro will never be
called

New Behavior: the dialstring would be
|trM(dial-answered|custom-macro|auto-blkvm). dial-answered
will call auto-blkvm and then custom-macro

— dialparties.agi 2007-02-23 12:03:25.513894888 -0500
+++ dialparties.agi.new 2007-02-23 12:02:31.830056072 -0500
@@ -410,17 +410,35 @@

$ds = chop($ds," &");

+$macros=“dial-answered”;
+
+# Find all of the existing macros on the dialstring and add them to $macros
+preg_match_all("/M((.*?))/", $dialopts, $match);
+foreach ($match[1] as $val)
+{

  • $macros .= “|” . $val;
    +}

+# Remove all of the existing macros from the dialstring
+$dialopts = preg_replace("/M((.*?))/", “”, $dialopts);
+
if ($nodest != ‘’ && $use_confirmation == ‘FALSE’) {

  • if (strpos($dialopts,“M(auto-blkvm)”) > 0 || strpos($dialopts,“M(auto-blkvm)”) === 0 ||
  •   strpos($dialopts,"M(auto-confirm") > 0 || strpos($dialopts,"M(auto-confirm") === 0 ||
    
  •   strpos($dialopts,"M(confirm") > 0      || strpos($dialopts,"M(confirm") === 0) {
    
  •   debug("NODEST: $nodest blkvm enabled macro already in dialopts: $dialopts",4);
    
  • if ( strpos($macros, “|auto-blkvm”) > 0 || strpos($macros, “,auto-blkvm”) === 0 ||
  •         strpos($macros, "|auto-confirm") > 0 || strpos($macros, ",auto-confirm") === 0 || 
    
  •         strpos($macros, "|confirm") > 0 || strpos($macros, ",confirm") === 0 ) 
    
  •    { 
    
  •   debug("NODEST: $nodest blkvm enabled macro already in dialopts.",4);
    
    } else {
  •   $dialopts .= "M(auto-blkvm)";
    
  •   debug("NODEST: $nodest adding M(auto-blkvm) to dialopts: $dialopts",4);
    
  •   $macros .= "|auto-blkvm";
    
  •   debug("NODEST: $nodest adding auto-blkvm macro to dialopts.",4);
    
    }
    }

+# Add the combined macro reference to the dialstring
+$dialopts .= “M($macros)”;
+
+
if (!strlen($ds))
{
$AGI->noop(’’);

— extensions.conf 2007-02-20 22:08:26.950627136 -0500
+++ extensions.conf.new 2007-02-23 12:06:25.666507528 -0500
@@ -86,6 +87,19 @@
;
exten => h,1,Macro(hangupcall)

+; Macro called after the dial command has been answered
+; accepts as parameters a list of other macros to call
+; Example Macro(dial-answered|Macro1|Macro2|Macro3)
+[macro-dial-answered]
+exten => s,1,Set(MacroLoop=1)
+exten => s,n(loop),GotoIf($[“foo${ARG${MacroLoop}}” = “foo”]?end
+exten => s,n,Macro(${ARG${MacroLoop}})
+exten => s,n,Set(MacroLoop=$[1 + ${MacroLoop}])
+exten => s,n,Goto(loop)
+exten => s,n(end),NoOp(“dial-answered complete”)
+
+
; Ring an extension, if the extension is busy or there is no answer send it
; to voicemail
; ARGS: $VMBOX, $EXT


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


Amportal-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amportal-devel

Post generated using Mail2Forum (http://www.mail2forum.com)