| 1 | package Asterisk::AGI; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | require 5.004; | |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Asterisk; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use vars qw(@ISA $VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | @ISA = ( 'Asterisk' ); | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | $VERSION = $Asterisk::VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | Asterisk::AGI - Simple Asterisk Gateway Interface Class | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | use Asterisk::AGI; | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | $AGI = new Asterisk::AGI; | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | # pull AGI variables into %input | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | %input = $AGI->ReadParse(); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # say the number 1984 | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | $AGI->say_number(1984); | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | This module should make it easier to write scripts that interact with the | ||||||||||||||||||||||||||||||||||||||||||
| 35 | asterisk open source pbx via AGI (asterisk gateway interface) | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | =head1 MODULE COMMANDS | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | $self->{'callback'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | $self->{'status'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | $self->{'lastresponse'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | $self->{'lastresult'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | $self->{'hungup'} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | $self->{'debug'} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | $self->{'env'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | bless $self, ref $class || $class; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | sub ReadParse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ReadParse: called CC=2 SCAR=8.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | my ($self, $fh) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | if (!$self->_env) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | return $self->_ReallyReadParse($fh); | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return %{$self->_env}; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | sub _ReallyReadParse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ReallyReadParse: called CC=7 SCAR=21.1
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | my ($self, $fh) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | my %input = (); | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | $fh = \*STDIN if (!$fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 7 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 7 | ▶ | last unless length($_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 7 | ▶ | if (/^agi_(\w+)\:\s+(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 7 | $input{$1} = $2; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | ▶ | if ($self->_debug > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | print STDERR "AGI Environment Dump:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | foreach my $i (sort keys %input) { | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | print STDERR " -- $i = $input{$i}\n"; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | $self->_env(%input); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | return %input; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | =item $AGI->setcallback($funcref) | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | Set function to execute when call is hungup or function returns error. | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | Example: $AGI->setcallback(\&examplecallback); | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub setcallback { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setcallback: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my ($self, $function) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if (defined($function) && ref($function) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $function and ref $function eq "CODE"
MC/DC0%0/2
defined $function and ref $function eq "CODE"
defined $function
ref $function eq "CODE"
Truth table0%0/3
A and B
A= defined $functionB= ref $function eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $self->{'callback'} = $function; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub callback { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
callback: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my ($self, $result) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if (defined($self->{'callback'}) && ref($self->{'callback'}) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"callback"} and ref $self->{"callback"} eq "CODE"
MC/DC0%0/2
defined $self->{"callback"} and ref $self->{"callback"} eq "CODE"
defined $self->{"callback"}
ref $self->{"callback"} eq "CODE"
Truth table0%0/3
A and B
A= defined $self->{"callback"}B= ref $self->{"callback"} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | &{$self->{'callback'}}($result); | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my ($self, $command) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $self->_execcommand($command); | |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $res = $self->_readresponse(); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $ret = $self->_checkresult($res); | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if (defined($ret) && $ret eq '-1' && !$self->_hungup()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $ret and $ret eq -1 and not $self->_hungup
defined $ret and $ret eq -1
MC/DC0%0/3
defined $ret and $ret eq -1 and not $self->_hungup
defined $ret
$ret eq -1
not $self->_hungup
Truth table0%0/4
A and B and not(C)
A= defined $retB= $ret eq -1C= not $self->_hungup
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $self->_hungup(1); | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $self->callback($ret); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub _execcommand { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_execcommand: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my ($self, $command, $fh) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $fh = \*STDOUT if (!$fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | select ((select ($fh), $| = 1)[0]); | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | return -1 if (!defined($command)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | print STDERR "_execcommand: '$command'\n" if ($self->_debug>3); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return print $fh "$command\n"; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | sub _readresponse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readresponse: called CC=13 SCAR=40.0
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | my ($self, $fh) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | my $response = undef; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | my $readvars = 0; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | ▶ | $fh = \*STDIN if (!$fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | ▶ | while ($response = <$fh>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | chomp($response); | |||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | if (!defined($response)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return '200 result=-1 (noresponse)'; | |||||||||||||||||||||||||||||||||||||||||
| 157 | } elsif ($response =~ /^agi_(\w+)\:\s+(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 158 | # I really hate duplicating code, but if anyone has a way to be backwards compatible and keep everyone happy please let me know! | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if ($self->_debug > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | print STDERR "AGI Environment Dump:\n" if (!$self->_env); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | print STDERR " -- $1 = $2\n"; | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $self->_addenv($1, $2); | |||||||||||||||||||||||||||||||||||||||||
| 164 | ▶ | } elsif (($readvars && ($response eq '')) || ($response eq 'HANGUP')) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$readvars and $response eq "" or $response eq "HANGUP"
$readvars and $response eq ""
MC/DC0%0/3
$readvars and $response eq "" or $response eq "HANGUP"
$readvars
$response eq ""
$response eq "HANGUP"
Truth table20%1/5
A and B or C
A= $readvarsB= $response eq ""C= $response eq "HANGUP"
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | print STDERR "Skipping blank response or HANGUP because we just read vars\n" if ($self->_debug > 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $readvars = 0; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } elsif ($response) { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | return($response); | |||||||||||||||||||||||||||||||||||||||||
| 169 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | print STDERR "AGI Received unknown response: '$response'\n" if ($self->_debug > 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | return '200 result=-1 (noresponse)'; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub _checkresult { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_checkresult: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my ($self, $response) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | return undef if (!defined($response)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $result = undef; | |||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->_lastresponse($response); | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if ($response =~ /^200/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($response =~ /result=(-?[\d*#]+)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $result = $self->{'lastresult'} = $1; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | } elsif ($response =~ /\(noresponse\)/) { | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $self->_status('noresponse'); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | print STDERR "Unexpected result '" . (defined($response) ? $response : '') . "'\n" if ($self->_debug>0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | print STDERR "_checkresult(" . (defined($response) ? $response : '') . ") = " . (defined($result) ? $result : '') . "\n" if ($self->_debug>3); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub _status { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_status: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my ($self, $status) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if (defined($status)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $self->{'status'} = $status; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | return $self->{'status'}; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | sub _lastresponse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lastresponse: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my ($self, $response) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if (defined($response)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $self->{'lastresponse'} = $response; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | return $self->{'lastresponse'}; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | sub _lastresult { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lastresult: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my ($self, $result) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if (defined($result)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->{'lastresult'} = $result; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | return $self->{'lastresult'}; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub _hungup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hungup: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $self->{'hungup'} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return $self->{'hungup'}; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | ▶ | sub _debug { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_debug: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $self->{'debug'} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 242 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | return $self->{'debug'}; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub _addenv { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_addenv: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my ($self, $var, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $self->{'env'}->{$var} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | ▶ | sub _env { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_env: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | my ($self, %env) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | ▶ | if (%env) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | $self->{'env'} = \%env; | |||||||||||||||||||||||||||||||||||||||||
| 258 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | return $self->{'env'}; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub _recurse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_recurse: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my ($self, $s2, $files, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $sub = (caller(1))[3]; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $ret = undef; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | foreach my $fn (@$files) { | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if (!$ret) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $ret = $self->$sub($fn, @args); | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | =head1 AGI COMMANDS | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | =item $AGI->answer() | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | Executes AGI Command "ANSWER" | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | Answers channel if not already in answer state | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | Example: $AGI->answer(); | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | Returns: -1 on channel failure, or | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 if successful | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | sub answer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
answer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | return $self->execute('ANSWER'); | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | =item $AGI->channel_status([$channel]) | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | Executes AGI Command "CHANNEL STATUS $channel" | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | Returns the status of the specified channel. If no channel name is given the | ||||||||||||||||||||||||||||||||||||||||||
| 307 | returns the status of the current channel. | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | Example: $AGI->channel_status(); | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | Returns: -1 Channel hungup or error | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 Channel is down and available | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 Channel is down, but reserved | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 2 Channel is off hook | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 3 Digits (or equivalent) have been dialed | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 4 Line is ringing | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 5 Remote end is ringing | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 6 Line is up | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 7 Line is busy | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | sub channel_status { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
channel_status: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my ($self, $channel) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | return $self->execute("CHANNEL STATUS $channel"); | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | =item $AGI->control_stream_file($filename, $digits [, $skipms [, $ffchar [, $rewchar [, $pausechar]]]]) | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | Executes AGI Command "CONTROL STREAM FILE $filename $digits [$skipms [$ffchar [$rewchar [$pausechar]]]]" | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | Send the given file, allowing playback to be controled by the given digits, if | ||||||||||||||||||||||||||||||||||||||||||
| 334 | any. Use double quotes for the digits if you wish none to be permitted. | ||||||||||||||||||||||||||||||||||||||||||
| 335 | Remember, the file extension must not be included in the filename. | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | Note: ffchar and rewchar default to * and # respectively. | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | Example: $AGI->control_stream_file('status', 'authorized'); | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | Returns: -1 on error or hangup; | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 if playback completes without a digit being pressed; | ||||||||||||||||||||||||||||||||||||||||||
| 343 | the ASCII numerical value of the digit of one was pressed. | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub control_stream_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
control_stream_file: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my ($self, $filename, $digits, $skipms, $ffchar, $rewchar, $pausechar) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | return -1 if (!defined($filename)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | $digits = '""' if (!defined($digits)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | $skipms = '' if (!defined($skipms)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | $ffchar = '' if (!defined($ffchar)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | $rewchar = '' if (!defined($rewchar)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | $pausechar = '' if (!defined($pausechar)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return $self->execute("CONTROL STREAM FILE $filename $digits $skipms $ffchar $rewchar $pausechar"); | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | =item $AGI->database_del($family, $key) | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | Executes AGI Command "DATABASE DEL $family $key" | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | Removes database entry <family>/<key> | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | Example: $AGI->database_del('test', 'status'); | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | Returns: 1 on success, 0 otherwise | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | sub database_del { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
database_del: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my ($self, $family, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | return $self->execute("DATABASE DEL $family $key"); | |||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | =item $AGI->database_deltree($family, $key) | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | Executes AGI Command "DATABASE DELTREE $family $key" | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | Deletes a family or specific keytree within a family in the Asterisk database | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | Example: $AGI->database_deltree('test', 'status'); | ||||||||||||||||||||||||||||||||||||||||||
| 385 | Example: $AGI->database_deltree('test'); | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | Returns: 1 on success, 0 otherwise | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | sub database_deltree { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
database_deltree: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my ($self, $family, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | return $self->execute("DATABASE DELTREE $family $key"); | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | =item $AGI->database_get($family, $key) | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | Executes AGI Command "DATABASE GET $family $key" | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | Example: $var = $AGI->database_get('test', 'status'); | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | Returns: The value of the variable, or undef if variable does not exist | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sub database_get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
database_get: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my ($self, $family, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my $result = undef; | |||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | if ($self->execute("DATABASE GET $family $key")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $tempresult = $self->_lastresponse(); | |||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | if ($tempresult =~ /\((.*)\)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $result = $1; | |||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | =item $AGI->database_put($family, $key, $value) | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | Executes AGI Command "DATABASE PUT $family $key $value" | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | Set/modifes database entry <family>/<key> to <value> | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | Example: $AGI->database_put('test', 'status', 'authorized'); | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | Returns: 1 on success, 0 otherwise | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | sub database_put { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
database_put: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my ($self, $family, $key, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | return $self->execute("DATABASE PUT $family $key $value"); | |||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | =item $AGI->exec($app, $options) | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | Executes AGI Command "EXEC $app "$options"" | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | The most powerful AGI command. Executes the given application passing the given options. | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | Example: $AGI->exec('Dial', 'Zap/g2/8005551212'); | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | Returns: -2 on failure to find application, or | ||||||||||||||||||||||||||||||||||||||||||
| 448 | whatever the given application returns | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | sub exec { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exec: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my ($self, $app, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | return -1 if (!defined($app)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if (!defined($options)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $options = '""'; | |||||||||||||||||||||||||||||||||||||||||
| 457 | } elsif ($options =~ /^\".*\"$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 458 | # Do nothing | ||||||||||||||||||||||||||||||||||||||||||
| 459 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $options = '"' . $options . '"'; | |||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | return $self->execute("EXEC $app $options"); | |||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | =item $AGI->get_data($filename, $timeout, $maxdigits) | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | Executes AGI Command "GET DATA $filename $timeout $maxdigits" | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | Streams $filename and returns when $maxdigits have been received or | ||||||||||||||||||||||||||||||||||||||||||
| 471 | when $timeout has been reached. Timeout is specified in ms | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | Example: $AGI->get_data('demo-welcome', 15000, 5); | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | sub get_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_data: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my ($self, $filename, $timeout, $maxdigits) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | return -1 if (!defined($filename)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | return $self->execute("GET DATA $filename $timeout $maxdigits"); | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | =item $AGI->get_full_variable($variable [, $channel]) | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | Executes AGI Command "GET FULL VARIABLE $variablename $channel" | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | Similar to get_variable, but additionally understands | ||||||||||||||||||||||||||||||||||||||||||
| 489 | complex variable names and builtin variables. If $channel is not set, uses the | ||||||||||||||||||||||||||||||||||||||||||
| 490 | current channel. | ||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | Example: $AGI->get_full_variable('status', 'SIP/4382'); | ||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | Returns: The value of the variable, or undef if variable does not exist | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | sub get_full_variable { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_full_variable: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | my ($self, $variable, $channel) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | $channel = '' if (!defined($channel)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $result = undef; | |||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | if ($self->execute("GET FULL VARIABLE $variable $channel")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $tempresult = $self->_lastresponse(); | |||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | if ($tempresult =~ /\((.*)\)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $result = $1; | |||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | =item $AGI->get_option($filename, $digits [, $timeout]) | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | Executes AGI Command "GET OPTION $filename $digits $timeout" | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | Behaves similar to STREAM FILE but used with a timeout option. | ||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | Streams $filename and returns when $digits is pressed or when $timeout has been | ||||||||||||||||||||||||||||||||||||||||||
| 521 | reached. Timeout is specified in ms. If $timeout is not specified, the command | ||||||||||||||||||||||||||||||||||||||||||
| 522 | will only terminate on the $digits set. $filename can be an array of files | ||||||||||||||||||||||||||||||||||||||||||
| 523 | or a single filename. | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | Example: $AGI->get_option('demo-welcome', '#', 15000); | ||||||||||||||||||||||||||||||||||||||||||
| 526 | $AGI->get_option(['demo-welcome', 'demo-echotest'], '#', 15000); | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | sub get_option { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_option: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my ($self, $filename, $digits, $timeout) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my $ret = undef; | |||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | $timeout = 0 if (!defined($timeout)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | return -1 if (!defined($filename)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | if (ref($filename) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $ret = $self->_recurse(@_); | |||||||||||||||||||||||||||||||||||||||||
| 539 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | $ret = $self->execute("GET OPTION $filename $digits $timeout"); | |||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | =item $AGI->get_variable($variable) | ||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | Executes AGI Command "GET VARIABLE $variablename" | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | Gets the channel variable <variablename> | ||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | Example: $AGI->get_variable('status'); | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | Returns: The value of the variable, or undef if variable does not exist | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | sub get_variable { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_variable: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | my ($self, $variable) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | my $result = undef; | |||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | if ($self->execute("GET VARIABLE $variable")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $tempresult = $self->_lastresponse(); | |||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | if ($tempresult =~ /\((.*)\)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | $result = $1; | |||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | =item $AGI->hangup($channel) | ||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | Executes AGI Command "HANGUP $channel" | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | Hangs up the passed $channel, or the current channel if $channel is not passed. | ||||||||||||||||||||||||||||||||||||||||||
| 576 | It is left to the AGI script to exit properly, otherwise you could end up with zombies. | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | Example: $AGI->hangup(); | ||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | Returns: Always returns 1 | ||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | sub hangup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hangup: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my ($self, $channel) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | if ($channel) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | return $self->execute("HANGUP $channel"); | |||||||||||||||||||||||||||||||||||||||||
| 589 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | return $self->execute("HANGUP"); | |||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | =item $AGI->noop() | ||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | Executes AGI Command "NOOP" | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | Does absolutely nothing except pop up a log message. | ||||||||||||||||||||||||||||||||||||||||||
| 599 | Useful for outputting debugging information to the Asterisk console. | ||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | Example: $AGI->noop("Test Message"); | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | Returns: -1 on hangup or error, 0 otherwise | ||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | sub noop { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
noop: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | my ($self, $string) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | return $self->execute("NOOP $string"); | |||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | =item $AGI->receive_char($timeout) | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | Executes AGI Command "RECEIVE CHAR $timeout" | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | Receives a character of text on a channel. Specify timeout to be the maximum | ||||||||||||||||||||||||||||||||||||||||||
| 618 | time to wait for input in milliseconds, or 0 for infinite. Most channels do not | ||||||||||||||||||||||||||||||||||||||||||
| 619 | support the reception of text. | ||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | Example: $AGI->receive_char(3000); | ||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||
| 623 | Returns: Returns the decimal value of the character if one | ||||||||||||||||||||||||||||||||||||||||||
| 624 | is received, or 0 if the channel does not support text reception. Returns -1 | ||||||||||||||||||||||||||||||||||||||||||
| 625 | only on error/hangup. | ||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | sub receive_char { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
receive_char: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | my ($self, $timeout) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | #wait forever if timeout is not set. is this the prefered default? | ||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | $timeout = 0 if (!defined($timeout)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | return $self->execute("RECEIVE CHAR $timeout"); | |||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | =item $AGI->receive_text($timeout) | ||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | Executes AGI Command "RECEIVE TEXT $timeout" | ||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | Receives a string of text on a channel. Specify timeout to be the maximum time | ||||||||||||||||||||||||||||||||||||||||||
| 642 | to wait for input in milliseconds, or 0 for infinite. Most channels do not | ||||||||||||||||||||||||||||||||||||||||||
| 643 | support the reception of text. | ||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | Example: $AGI->receive_text(3000); | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | Returns: Returns the string of text if received, or -1 for failure, error or hangup. | ||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | sub receive_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
receive_text: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | my ($self, $timeout) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | #wait forever if timeout is not set. is this the prefered default? | ||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | $timeout = 0 if (!defined($timeout)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | return $self->execute("RECEIVE TEXT $timeout"); | |||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | =item $AGI->record_file($filename, $format, $digits, $timeout, $beep, $offset, $beep, $silence) | ||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||
| 661 | Executes AGI Command "RECORD FILE $filename $format $digits $timeout [$offset [$beep [s=$silence]]]" | ||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | Record to a file until $digits are received as dtmf. | ||||||||||||||||||||||||||||||||||||||||||
| 664 | The $format will specify what kind of file will be recorded. | ||||||||||||||||||||||||||||||||||||||||||
| 665 | The $timeout is the maximum record time in milliseconds, or -1 for no timeout. | ||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | $offset samples is optional, and if provided will seek to the offset without | ||||||||||||||||||||||||||||||||||||||||||
| 668 | exceeding the end of the file. | ||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | $silence is the number of seconds of silence allowed before the function | ||||||||||||||||||||||||||||||||||||||||||
| 671 | returns despite the lack of dtmf digits or reaching timeout. | ||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | Example: $AGI->record_file('foo', 'wav', '#', '5000', '0', 1, '2'); | ||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||
| 675 | Returns: 1 on success, -1 on hangup or error. | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | ▶ | sub record_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
record_file: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | my ($self, $filename, $format, $digits, $timeout, $offset, $beep, $silence) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my $extra = ''; | |||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | return -1 if (!defined($filename)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | $digits = '""' if (!defined($digits)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | $extra .= $offset if (defined($offset)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | $extra .= ' ' . $beep if (defined($beep)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | $extra .= ' s=' . $silence if (defined($silence)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | return $self->execute("RECORD FILE $filename $format $digits $timeout $extra"); | |||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | =item $AGI->say_alpha($string, $digits) | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | Executes AGI Command "SAY ALPHA "$string" $digits" | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | Say a given character string, returning early if any of the given DTMF $digits | ||||||||||||||||||||||||||||||||||||||||||
| 698 | are received on the channel. | ||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | Returns | ||||||||||||||||||||||||||||||||||||||||||
| 701 | Example: $AGI->say_alpha('Joe Smith', '#'); | ||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | Returns: 0 if playback completes without a digit being pressed; | ||||||||||||||||||||||||||||||||||||||||||
| 704 | the ASCII numerical value of the digit if one was pressed; | ||||||||||||||||||||||||||||||||||||||||||
| 705 | -1 on error/hangup. | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | sub say_alpha { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_alpha: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | my ($self, $string, $digits) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | $digits = '""' if (!defined($digits)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | return -1 if (!defined($string)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | return $self->execute("SAY ALPHA \"$string\" $digits"); | |||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | =item $AGI->say_date($time [, $digits]) | ||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | =item $AGI->say_time($time [, $digits]) | ||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | =item $AGI->say_datetime($time [, $digits [, $format [, $timezone]]]) | ||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | Executes AGI Command "SAY DATE $number $digits" | ||||||||||||||||||||||||||||||||||||||||||
| 729 | Executes AGI Command "SAY TIME $number $digits" | ||||||||||||||||||||||||||||||||||||||||||
| 730 | Executes AGI Command "SAY DATETIME $number $digits $format $timezone" | ||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | Say a given date or time, returning early if any of the optional DTMF $digits are | ||||||||||||||||||||||||||||||||||||||||||
| 733 | received on the channel. $time is number of seconds elapsed since 00:00:00 on | ||||||||||||||||||||||||||||||||||||||||||
| 734 | January 1, 1970, Coordinated Universal Time (UTC), commonly known as | ||||||||||||||||||||||||||||||||||||||||||
| 735 | "unixtime." | ||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | For say_datetime, $format is the format the time should be said in; see | ||||||||||||||||||||||||||||||||||||||||||
| 738 | voicemail.conf (defaults to "ABdY 'digits/at' IMp"). Acceptable values for | ||||||||||||||||||||||||||||||||||||||||||
| 739 | $timezone can be found in /usr/share/zoneinfo. Defaults to machine default. | ||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | Example: $AGI->say_date('100000000'); | ||||||||||||||||||||||||||||||||||||||||||
| 742 | $AGI->say_time('100000000', '#'); | ||||||||||||||||||||||||||||||||||||||||||
| 743 | $AGI->say_datetime('100000000', '#', 'ABdY IMp', 'EDT'); | ||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | Returns: -1 on error or hangup; | ||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 if playback completes without a digit being pressed; | ||||||||||||||||||||||||||||||||||||||||||
| 747 | the ASCII numerical value of the digit of one was pressed. | ||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | sub say_datetime_all { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_datetime_all: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | my ($self, $type, $time, $digits, $format, $timezone) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | my $ret = 0; | |||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | return -1 if (!defined($time)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | $digits = '""' if (!defined($digits)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | $format = '' if (!defined($format)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | $timezone = '' if (!defined($timezone)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | if ($type eq 'date') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $ret = $self->execute("SAY DATE $time $digits"); | |||||||||||||||||||||||||||||||||||||||||
| 762 | } elsif ($type eq 'time') { | ||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | $ret = $self->execute("SAY TIME $time $digits"); | |||||||||||||||||||||||||||||||||||||||||
| 764 | } elsif ($type eq 'datetime') { | ||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | $ret = $self->execute("SAY DATETIME $time $digits $format $timezone"); | |||||||||||||||||||||||||||||||||||||||||
| 766 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | $ret = -1; | |||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | ▶ | sub say_date { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_date: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | my ($self, $time, $digits) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | return $self->say_datetime_all('date', $time, $digits); | |||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | sub say_time { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_time: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | my ($self, $time, $digits) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | return $self->say_datetime_all('time', $time, $digits); | |||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | sub say_datetime { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_datetime: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | my ($self, $time, $digits, $format, $timezone) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | return $self->say_datetime_all('datetime', $time, $digits, $format, $timezone); | |||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | =item $AGI->say_digits($number, $digits) | ||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||
| 793 | Executes AGI Command "SAY DIGITS $number $digits" | ||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | Says the given digit string $number, returning early if any of the $digits are received. | ||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | Example: $AGI->say_digits('8675309'); | ||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | Returns: -1 on error or hangup, | ||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 if playback completes without a digit being pressed, | ||||||||||||||||||||||||||||||||||||||||||
| 801 | or the ASCII numerical value of the digit of one was pressed. | ||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||
| 803 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | sub say_digits { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_digits: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | my ($self, $number, $digits) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | ▶ | $digits = '""' if (!defined($digits)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | return -1 if (!defined($number)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | $number =~ s/\D//g; | |||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | return $self->execute("SAY DIGITS $number $digits"); | |||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||
| 815 | =item $AGI->say_number($number, $digits, $gender) | ||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||
| 817 | Executes AGI Command "SAY NUMBER $number $digits [$gender]" | ||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | Says the given $number, returning early if any of the $digits are received. | ||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | Example: $AGI->say_number('98765'); | ||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | Returns: -1 on error or hangup, | ||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 if playback completes without a digit being pressed, | ||||||||||||||||||||||||||||||||||||||||||
| 825 | or the ASCII numerical value of the digit of one was pressed. | ||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||
| 827 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | ▶ | sub say_number { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_number: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | my ($self, $number, $digits, $gender) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | ▶ | $digits = '""' if (!defined($digits)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | ▶ | $gender = '' if (!defined($gender)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | ▶ | return -1 if (!defined($number)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | $number =~ s/\D//g; | |||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | return $self->execute("SAY NUMBER $number $digits $gender"); | |||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||
| 840 | =item $AGI->say_phonetic($string, $digits) | ||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | Executes AGI Command "SAY PHONETIC "$string" $digits" | ||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||
| 844 | Say a given character string with phonetics, returning early if any of the | ||||||||||||||||||||||||||||||||||||||||||
| 845 | given DTMF digits are received on the channel. | ||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||
| 847 | Example: $AGI->say_phonetic('Joe Smith', '#'); | ||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | Returns: 0 if playback completes without a digit being pressed; | ||||||||||||||||||||||||||||||||||||||||||
| 850 | the ASCII numerical value of the digit if one was pressed; | ||||||||||||||||||||||||||||||||||||||||||
| 851 | -1 on error/hangup. | ||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||
| 853 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | sub say_phonetic { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_phonetic: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | my ($self, $string, $digits) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | $digits = '""' if (!defined($digits)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | ▶ | return -1 if (!defined($string)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | return $self->execute("SAY PHONETIC \"$string\" $digits"); | |||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||
| 864 | =item $AGI->send_image($image) | ||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||
| 866 | Executes AGI Command "SEND IMAGE $image | ||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | Sends the given image on a channel. Most channels do not support the transmission of images. | ||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||
| 870 | Example: $AGI->send_image('image.png'); | ||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||
| 872 | Returns: -1 on error or hangup, | ||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 if the image was sent or if the channel does not support image transmission. | ||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||
| 875 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | ▶ | sub send_image { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_image: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | my ($self, $image) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | return -1 if (!defined($image)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | return $self->execute("SEND IMAGE $image"); | |||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||
| 885 | =item $AGI->send_text($text) | ||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||
| 887 | Executes AGI Command "SEND TEXT "$text" | ||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||
| 889 | Sends the given text on a channel. Most channels do not support the transmission of text. | ||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||
| 891 | Example: $AGI->send_text('You've got mail!'); | ||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||
| 893 | Returns: -1 on error or hangup, | ||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 if the text was sent or if the channel does not support text transmission. | ||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | sub send_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_text: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | my ($self, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | ▶ | return 0 if (!defined($text)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | return $self->execute("SEND TEXT \"$text\""); | |||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | =item $AGI->set_autohangup($time) | ||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||
| 907 | Executes AGI Command "SET AUTOHANGUP $time" | ||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||
| 909 | Cause the channel to automatically hangup at <time> seconds in the future. | ||||||||||||||||||||||||||||||||||||||||||
| 910 | Of course it can be hungup before then as well. | ||||||||||||||||||||||||||||||||||||||||||
| 911 | Setting to 0 will cause the autohangup feature to be disabled on this channel. | ||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||
| 913 | Example: $AGI->set_autohangup(60); | ||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | Returns: Always returns 1 | ||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||
| 917 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | ▶ | sub set_autohangup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_autohangup: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | my ($self, $time) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | $time = 0 if (!defined($time)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | return $self->execute("SET AUTOHANGUP $time"); | |||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||
| 926 | =item $AGI->set_callerid($number) | ||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||
| 928 | Executes AGI Command "SET CALLERID $number" | ||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | Changes the callerid of the current channel to <number> | ||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | Example: $AGI->set_callerid('9995551212'); | ||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||
| 934 | Returns: Always returns 1 | ||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||
| 936 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | ▶ | sub set_callerid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_callerid: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | my ($self, $number) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | ▶ | return if (!defined($number)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | return $self->execute("SET CALLERID $number"); | |||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | =item $AGI->set_context($context) | ||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | Executes AGI Command "SET CONTEXT $context" | ||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||
| 949 | Changes the context for continuation upon exiting the agi application | ||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||
| 951 | Example: $AGI->set_context('dialout'); | ||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||
| 953 | Returns: Always returns 0 | ||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||
| 955 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | sub set_context { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_context: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | my ($self, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | return -1 if (!defined($context)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | return $self->execute("SET CONTEXT $context"); | |||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||
| 964 | =item $AGI->set_extension($extension) | ||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||
| 966 | Executes AGI Command "SET EXTENSION $extension" | ||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||
| 968 | Changes the extension for continuation upon exiting the agi application | ||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||
| 970 | Example: $AGI->set_extension('7'); | ||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||
| 972 | Returns: Always returns 0 | ||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||
| 974 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | ▶ | sub set_extension { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_extension: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | my ($self, $extension) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | ▶ | return -1 if (!defined($extension)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | return $self->execute("SET EXTENSION $extension"); | |||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||
| 983 | =item $AGI->set_music($mode [, $class]) | ||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||
| 985 | Executes AGI Command "SET MUSIC $mode $class" | ||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||
| 987 | Enables/Disables the music on hold generator. If $class is not specified, then | ||||||||||||||||||||||||||||||||||||||||||
| 988 | the default music on hold class will be used. $mode must be "on" or "off". | ||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||
| 990 | Example: $AGI->set_music("on", "happy"); | ||||||||||||||||||||||||||||||||||||||||||
| 991 | $AGI->set_music("off"); | ||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||
| 993 | Returns: -1 on hangup or error, 0 otherwise. | ||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||
| 995 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ▶ | sub set_music { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_music: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | my ($self, $mode, $class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | ▶ | $mode = '' if (!defined($mode)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | ▶ | $class = '' if (!defined($class)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | return $self->execute("SET MUSIC $mode $class"); | |||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||
| 1006 | =item $AGI->set_priority($priority) | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | Executes AGI Command "SET PRIORITY $priority" | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||
| 1010 | Changes the priority for continuation upon exiting the agi application | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||
| 1012 | Example: $AGI->set_priority(1); | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||
| 1014 | Returns: Always returns 0 | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||
| 1016 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | ▶ | sub set_priority { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_priority: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | my ($self, $priority) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | ▶ | return -1 if (!defined($priority)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | return $self->execute("SET PRIORITY $priority"); | |||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||
| 1025 | =item $AGI->set_variable($variable, $value) | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||
| 1027 | Executes AGI Command "SET VARIABLE $variable $value" | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||
| 1029 | Sets the channel variable <variablename> to <value> | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||
| 1031 | Example: $AGI->set_variable('status', 'authorized'); | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||
| 1033 | Returns: Always returns 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||
| 1035 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | ▶ | sub set_variable { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_variable: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | my ($self, $variable, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | return $self->execute("SET VARIABLE $variable \"$value\""); | |||||||||||||||||||||||||||||||||||||||||
| 1041 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||
| 1043 | =item $AGI->stream_file($filename, $digits, $offset) | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||
| 1045 | Executes AGI Command "STREAM FILE $filename $digits [$offset]" | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||
| 1047 | This command instructs Asterisk to play the given sound file and listen for the given dtmf digits. The | ||||||||||||||||||||||||||||||||||||||||||
| 1048 | fileextension must not be used in the filename because Asterisk will find the most appropriate file | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | type. $filename can be an array of files or a single filename. | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||
| 1051 | Example: $AGI->stream_file('demo-echotest', '0123'); | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | $AGI->stream_file(['demo-echotest', 'demo-welcome'], '0123'); | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||
| 1054 | Returns: -1 on error or hangup, | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 if playback completes without a digit being pressed, | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | or the ASCII numerical value of the digit if a digit was pressed | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||
| 1058 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | ▶ | sub stream_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stream_file: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | my ($self, $filename, $digits, $offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | ▶ | return -1 if (!defined($filename)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | my $ret = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | $digits = '""' if (!defined($digits)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | ▶ | $offset = '' if (!defined($offset)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | ▶ | if (ref($filename) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | $ret = $self->_recurse(@_); | |||||||||||||||||||||||||||||||||||||||||
| 1070 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | $ret = $self->execute("STREAM FILE $filename $digits $offset"); | |||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 1075 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||
| 1077 | =item $AGI->tdd_mode($mode) | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||
| 1079 | Executes AGI Command "TDD MODE <on|off>" | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||
| 1081 | Enable/Disable TDD transmission/reception on a channel. | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||
| 1083 | Example: $AGI->tdd_mode('on'); | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||
| 1085 | Returns: Returns 1 if successful, or 0 if channel is not TDD-capable. | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||
| 1087 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | ▶ | sub tdd_mode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tdd_mode: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | my ($self, $mode) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | ▶ | return 0 if (!defined($mode)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | return $self->execute("TDD MODE $mode"); | |||||||||||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||
| 1096 | =item $AGI->verbose($message, $level) | ||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||
| 1098 | Executes AGI Command "VERBOSE $message $level" | ||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||
| 1100 | Logs $message with verboselevel $level | ||||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||
| 1102 | Example: $AGI->verbose("System Crashed", 1); | ||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||
| 1104 | Returns: Always returns 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||
| 1106 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | sub verbose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbose: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | my ($self, $message, $level) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | ▶ | $level = '' if (!$level); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | return $self->execute("VERBOSE \"$message\" $level"); | |||||||||||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | =item $AGI->wait_for_digit($timeout) | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||
| 1117 | Executes AGI Command "WAIT FOR DIGIT $timeout" | ||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||
| 1119 | Waits up to 'timeout' milliseconds for channel to receive a DTMF digit. | ||||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||
| 1121 | Use -1 for the timeout value if you desire the call to block indefinitely. | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||
| 1123 | Example: $AGI->wait_for_digit($timeout); | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||
| 1125 | Returns: Returns -1 on channel failure, 0 if no digit is received in the timeout, or | ||||||||||||||||||||||||||||||||||||||||||
| 1126 | the numerical value of the ascii of the digit if one is received. | ||||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||
| 1128 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | ▶ | sub wait_for_digit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wait_for_digit: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | my ($self, $timeout) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | ▶ | $timeout = -1 if (!defined($timeout)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | return $self->execute("WAIT FOR DIGIT $timeout"); | |||||||||||||||||||||||||||||||||||||||||
| 1135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||
| 1137 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||
| 1139 | __END__ | ||||||||||||||||||||||||||||||||||||||||||