line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Asterisk::AGI; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.004; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
532
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
6
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
7
|
1
|
|
|
1
|
|
228
|
use Asterisk; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
2
|
use vars qw(@ISA $VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2654
|
|
10
|
|
|
|
|
|
|
@ISA = ( 'Asterisk' ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
sub new { |
44
|
1
|
|
|
1
|
0
|
303
|
my ($class, %args) = @_; |
45
|
1
|
|
|
|
|
2
|
my $self = {}; |
46
|
1
|
|
|
|
|
1
|
$self->{'callback'} = undef; |
47
|
1
|
|
|
|
|
2
|
$self->{'status'} = undef; |
48
|
1
|
|
|
|
|
1
|
$self->{'lastresponse'} = undef; |
49
|
1
|
|
|
|
|
1
|
$self->{'lastresult'} = undef; |
50
|
1
|
|
|
|
|
1
|
$self->{'hungup'} = 0; |
51
|
1
|
|
|
|
|
2
|
$self->{'debug'} = 0; |
52
|
1
|
|
|
|
|
0
|
$self->{'env'} = undef; |
53
|
1
|
|
33
|
|
|
7
|
bless $self, ref $class || $class; |
54
|
1
|
|
|
|
|
2
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub ReadParse { |
58
|
1
|
|
|
1
|
0
|
820
|
my ($self, $fh) = @_; |
59
|
|
|
|
|
|
|
|
60
|
1
|
50
|
|
|
|
2
|
if (!$self->_env) { |
61
|
1
|
|
|
|
|
2
|
return $self->_ReallyReadParse($fh); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
return %{$self->_env}; |
|
0
|
|
|
|
|
0
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _ReallyReadParse { |
68
|
1
|
|
|
1
|
|
1
|
my ($self, $fh) = @_; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
2
|
my %input = (); |
71
|
|
|
|
|
|
|
|
72
|
1
|
50
|
|
|
|
2
|
$fh = \*STDIN if (!$fh); |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
12
|
while (<$fh>) { |
75
|
7
|
|
|
|
|
6
|
chomp; |
76
|
7
|
50
|
|
|
|
8
|
last unless length($_); |
77
|
7
|
50
|
|
|
|
18
|
if (/^agi_(\w+)\:\s+(.*)$/) { |
78
|
7
|
|
|
|
|
22
|
$input{$1} = $2; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
1
|
50
|
|
|
|
2
|
if ($self->_debug > 0) { |
84
|
0
|
|
|
|
|
0
|
print STDERR "AGI Environment Dump:\n"; |
85
|
0
|
|
|
|
|
0
|
foreach my $i (sort keys %input) { |
86
|
0
|
|
|
|
|
0
|
print STDERR " -- $i = $input{$i}\n"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
4
|
$self->_env(%input); |
91
|
1
|
|
|
|
|
7
|
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
|
|
|
|
|
|
|
sub setcallback { |
103
|
0
|
|
|
0
|
1
|
0
|
my ($self, $function) = @_; |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
0
|
|
|
0
|
if (defined($function) && ref($function) eq 'CODE') { |
106
|
0
|
|
|
|
|
0
|
$self->{'callback'} = $function; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub callback { |
111
|
0
|
|
|
0
|
0
|
0
|
my ($self, $result) = @_; |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
0
|
|
|
0
|
if (defined($self->{'callback'}) && ref($self->{'callback'}) eq 'CODE') { |
114
|
0
|
|
|
|
|
0
|
&{$self->{'callback'}}($result); |
|
0
|
|
|
|
|
0
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub execute { |
119
|
0
|
|
|
0
|
0
|
0
|
my ($self, $command) = @_; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
0
|
$self->_execcommand($command); |
122
|
0
|
|
|
|
|
0
|
my $res = $self->_readresponse(); |
123
|
0
|
|
|
|
|
0
|
my $ret = $self->_checkresult($res); |
124
|
|
|
|
|
|
|
|
125
|
0
|
0
|
0
|
|
|
0
|
if (defined($ret) && $ret eq '-1' && !$self->_hungup()) { |
|
|
|
0
|
|
|
|
|
126
|
0
|
|
|
|
|
0
|
$self->_hungup(1); |
127
|
0
|
|
|
|
|
0
|
$self->callback($ret); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
0
|
return $ret; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub _execcommand { |
134
|
0
|
|
|
0
|
|
0
|
my ($self, $command, $fh) = @_; |
135
|
|
|
|
|
|
|
|
136
|
0
|
0
|
|
|
|
0
|
$fh = \*STDOUT if (!$fh); |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
0
|
select ((select ($fh), $| = 1)[0]); |
139
|
|
|
|
|
|
|
|
140
|
0
|
0
|
|
|
|
0
|
return -1 if (!defined($command)); |
141
|
|
|
|
|
|
|
|
142
|
0
|
0
|
|
|
|
0
|
print STDERR "_execcommand: '$command'\n" if ($self->_debug>3); |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
0
|
return print $fh "$command\n"; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub _readresponse { |
148
|
1
|
|
|
1
|
|
203
|
my ($self, $fh) = @_; |
149
|
|
|
|
|
|
|
|
150
|
1
|
|
|
|
|
1
|
my $response = undef; |
151
|
1
|
|
|
|
|
2
|
my $readvars = 0; |
152
|
1
|
50
|
|
|
|
4
|
$fh = \*STDIN if (!$fh); |
153
|
1
|
|
|
|
|
7
|
while ($response = <$fh>) { |
154
|
1
|
|
|
|
|
2
|
chomp($response); |
155
|
1
|
50
|
33
|
|
|
10
|
if (!defined($response)) { |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
156
|
0
|
|
|
|
|
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
|
0
|
|
|
|
0
|
if ($self->_debug > 0) { |
160
|
0
|
0
|
|
|
|
0
|
print STDERR "AGI Environment Dump:\n" if (!$self->_env); |
161
|
0
|
|
|
|
|
0
|
print STDERR " -- $1 = $2\n"; |
162
|
|
|
|
|
|
|
} |
163
|
0
|
|
|
|
|
0
|
$self->_addenv($1, $2); |
164
|
|
|
|
|
|
|
} elsif (($readvars && ($response eq '')) || ($response eq 'HANGUP')) { |
165
|
0
|
0
|
|
|
|
0
|
print STDERR "Skipping blank response or HANGUP because we just read vars\n" if ($self->_debug > 0); |
166
|
0
|
|
|
|
|
0
|
$readvars = 0; |
167
|
|
|
|
|
|
|
} elsif ($response) { |
168
|
1
|
|
|
|
|
2
|
return($response); |
169
|
|
|
|
|
|
|
} else { |
170
|
0
|
0
|
|
|
|
0
|
print STDERR "AGI Received unknown response: '$response'\n" if ($self->_debug > 0); |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
} |
173
|
0
|
|
|
|
|
0
|
return '200 result=-1 (noresponse)'; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub _checkresult { |
177
|
0
|
|
|
0
|
|
0
|
my ($self, $response) = @_; |
178
|
|
|
|
|
|
|
|
179
|
0
|
0
|
|
|
|
0
|
return undef if (!defined($response)); |
180
|
0
|
|
|
|
|
0
|
my $result = undef; |
181
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
0
|
$self->_lastresponse($response); |
183
|
0
|
0
|
|
|
|
0
|
if ($response =~ /^200/) { |
|
|
0
|
|
|
|
|
|
184
|
0
|
0
|
|
|
|
0
|
if ($response =~ /result=(-?[\d*#]+)/) { |
185
|
0
|
|
|
|
|
0
|
$result = $self->{'lastresult'} = $1; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
} elsif ($response =~ /\(noresponse\)/) { |
188
|
0
|
|
|
|
|
0
|
$self->_status('noresponse'); |
189
|
|
|
|
|
|
|
} else { |
190
|
0
|
0
|
|
|
|
0
|
print STDERR "Unexpected result '" . (defined($response) ? $response : '') . "'\n" if ($self->_debug>0); |
|
|
0
|
|
|
|
|
|
191
|
|
|
|
|
|
|
} |
192
|
0
|
0
|
|
|
|
0
|
print STDERR "_checkresult(" . (defined($response) ? $response : '') . ") = " . (defined($result) ? $result : '') . "\n" if ($self->_debug>3); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
194
|
0
|
|
|
|
|
0
|
return $result; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub _status { |
198
|
0
|
|
|
0
|
|
0
|
my ($self, $status) = @_; |
199
|
|
|
|
|
|
|
|
200
|
0
|
0
|
|
|
|
0
|
if (defined($status)) { |
201
|
0
|
|
|
|
|
0
|
$self->{'status'} = $status; |
202
|
|
|
|
|
|
|
} else { |
203
|
0
|
|
|
|
|
0
|
return $self->{'status'}; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub _lastresponse { |
208
|
0
|
|
|
0
|
|
0
|
my ($self, $response) = @_; |
209
|
|
|
|
|
|
|
|
210
|
0
|
0
|
|
|
|
0
|
if (defined($response)) { |
211
|
0
|
|
|
|
|
0
|
$self->{'lastresponse'} = $response; |
212
|
|
|
|
|
|
|
} else { |
213
|
0
|
|
|
|
|
0
|
return $self->{'lastresponse'}; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub _lastresult { |
218
|
0
|
|
|
0
|
|
0
|
my ($self, $result) = @_; |
219
|
|
|
|
|
|
|
|
220
|
0
|
0
|
|
|
|
0
|
if (defined($result)) { |
221
|
0
|
|
|
|
|
0
|
$self->{'lastresult'} = $result; |
222
|
|
|
|
|
|
|
} else { |
223
|
0
|
|
|
|
|
0
|
return $self->{'lastresult'}; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub _hungup { |
228
|
0
|
|
|
0
|
|
0
|
my ($self, $value) = @_; |
229
|
|
|
|
|
|
|
|
230
|
0
|
0
|
|
|
|
0
|
if (defined($value)) { |
231
|
0
|
|
|
|
|
0
|
$self->{'hungup'} = $value; |
232
|
|
|
|
|
|
|
} else { |
233
|
0
|
|
|
|
|
0
|
return $self->{'hungup'}; |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
sub _debug { |
238
|
1
|
|
|
1
|
|
2
|
my ($self, $value) = @_; |
239
|
|
|
|
|
|
|
|
240
|
1
|
50
|
|
|
|
3
|
if (defined($value)) { |
241
|
0
|
|
|
|
|
0
|
$self->{'debug'} = $value; |
242
|
|
|
|
|
|
|
} else { |
243
|
1
|
|
|
|
|
3
|
return $self->{'debug'}; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub _addenv { |
248
|
0
|
|
|
0
|
|
0
|
my ($self, $var, $value) = @_; |
249
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
0
|
$self->{'env'}->{$var} = $value; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
sub _env { |
254
|
2
|
|
|
2
|
|
4
|
my ($self, %env) = @_; |
255
|
|
|
|
|
|
|
|
256
|
2
|
100
|
|
|
|
4
|
if (%env) { |
257
|
1
|
|
|
|
|
2
|
$self->{'env'} = \%env; |
258
|
|
|
|
|
|
|
} else { |
259
|
1
|
|
|
|
|
7
|
return $self->{'env'}; |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
sub _recurse { |
264
|
0
|
|
|
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
|
0
|
|
|
|
|
if (!$ret) { |
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
|
|
|
|
|
|
|
sub answer { |
297
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub channel_status { |
324
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub control_stream_file { |
348
|
0
|
|
|
0
|
1
|
|
my ($self, $filename, $digits, $skipms, $ffchar, $rewchar, $pausechar) = @_; |
349
|
|
|
|
|
|
|
|
350
|
0
|
0
|
|
|
|
|
return -1 if (!defined($filename)); |
351
|
0
|
0
|
|
|
|
|
$digits = '""' if (!defined($digits)); |
352
|
0
|
0
|
|
|
|
|
$skipms = '' if (!defined($skipms)); |
353
|
0
|
0
|
|
|
|
|
$ffchar = '' if (!defined($ffchar)); |
354
|
0
|
0
|
|
|
|
|
$rewchar = '' if (!defined($rewchar)); |
355
|
0
|
0
|
|
|
|
|
$pausechar = '' if (!defined($pausechar)); |
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 / |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
Example: $AGI->database_del('test', 'status'); |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
Returns: 1 on success, 0 otherwise |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
=cut |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
sub database_del { |
373
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub database_deltree { |
392
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub database_get { |
408
|
0
|
|
|
0
|
1
|
|
my ($self, $family, $key) = @_; |
409
|
|
|
|
|
|
|
|
410
|
0
|
|
|
|
|
|
my $result = undef; |
411
|
|
|
|
|
|
|
|
412
|
0
|
0
|
|
|
|
|
if ($self->execute("DATABASE GET $family $key")) { |
413
|
0
|
|
|
|
|
|
my $tempresult = $self->_lastresponse(); |
414
|
0
|
0
|
|
|
|
|
if ($tempresult =~ /\((.*)\)/) { |
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 / to |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
Example: $AGI->database_put('test', 'status', 'authorized'); |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
Returns: 1 on success, 0 otherwise |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=cut |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
sub database_put { |
434
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub exec { |
453
|
0
|
|
|
0
|
1
|
|
my ($self, $app, $options) = @_; |
454
|
0
|
0
|
|
|
|
|
return -1 if (!defined($app)); |
455
|
0
|
0
|
|
|
|
|
if (!defined($options)) { |
|
|
0
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub get_data { |
478
|
0
|
|
|
0
|
1
|
|
my ($self, $filename, $timeout, $maxdigits) = @_; |
479
|
|
|
|
|
|
|
|
480
|
0
|
0
|
|
|
|
|
return -1 if (!defined($filename)); |
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
|
|
|
|
|
|
|
sub get_full_variable { |
499
|
0
|
|
|
0
|
1
|
|
my ($self, $variable, $channel) = @_; |
500
|
|
|
|
|
|
|
|
501
|
0
|
0
|
|
|
|
|
$channel = '' if (!defined($channel)); |
502
|
|
|
|
|
|
|
|
503
|
0
|
|
|
|
|
|
my $result = undef; |
504
|
|
|
|
|
|
|
|
505
|
0
|
0
|
|
|
|
|
if ($self->execute("GET FULL VARIABLE $variable $channel")) { |
506
|
0
|
|
|
|
|
|
my $tempresult = $self->_lastresponse(); |
507
|
0
|
0
|
|
|
|
|
if ($tempresult =~ /\((.*)\)/) { |
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
|
|
|
|
|
|
|
sub get_option { |
531
|
0
|
|
|
0
|
1
|
|
my ($self, $filename, $digits, $timeout) = @_; |
532
|
0
|
|
|
|
|
|
my $ret = undef; |
533
|
|
|
|
|
|
|
|
534
|
0
|
0
|
|
|
|
|
$timeout = 0 if (!defined($timeout)); |
535
|
0
|
0
|
|
|
|
|
return -1 if (!defined($filename)); |
536
|
|
|
|
|
|
|
|
537
|
0
|
0
|
|
|
|
|
if (ref($filename) eq "ARRAY") { |
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 |
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
|
|
|
|
|
|
|
sub get_variable { |
558
|
0
|
|
|
0
|
1
|
|
my ($self, $variable) = @_; |
559
|
|
|
|
|
|
|
|
560
|
0
|
|
|
|
|
|
my $result = undef; |
561
|
|
|
|
|
|
|
|
562
|
0
|
0
|
|
|
|
|
if ($self->execute("GET VARIABLE $variable")) { |
563
|
0
|
|
|
|
|
|
my $tempresult = $self->_lastresponse(); |
564
|
0
|
0
|
|
|
|
|
if ($tempresult =~ /\((.*)\)/) { |
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
|
|
|
|
|
|
|
sub hangup { |
585
|
0
|
|
|
0
|
1
|
|
my ($self, $channel) = @_; |
586
|
|
|
|
|
|
|
|
587
|
0
|
0
|
|
|
|
|
if ($channel) { |
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
|
|
|
|
|
|
|
sub noop { |
608
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub receive_char { |
630
|
0
|
|
|
0
|
1
|
|
my ($self, $timeout) = @_; |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
#wait forever if timeout is not set. is this the prefered default? |
633
|
0
|
0
|
|
|
|
|
$timeout = 0 if (!defined($timeout)); |
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
|
|
|
|
|
|
|
sub receive_text { |
652
|
0
|
|
|
0
|
1
|
|
my ($self, $timeout) = @_; |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
#wait forever if timeout is not set. is this the prefered default? |
655
|
0
|
0
|
|
|
|
|
$timeout = 0 if (!defined($timeout)); |
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
|
|
|
|
|
|
|
sub record_file { |
680
|
0
|
|
|
0
|
1
|
|
my ($self, $filename, $format, $digits, $timeout, $offset, $beep, $silence) = @_; |
681
|
|
|
|
|
|
|
|
682
|
0
|
|
|
|
|
|
my $extra = ''; |
683
|
|
|
|
|
|
|
|
684
|
0
|
0
|
|
|
|
|
return -1 if (!defined($filename)); |
685
|
0
|
0
|
|
|
|
|
$digits = '""' if (!defined($digits)); |
686
|
0
|
0
|
|
|
|
|
$extra .= $offset if (defined($offset)); |
687
|
0
|
0
|
|
|
|
|
$extra .= ' ' . $beep if (defined($beep)); |
688
|
0
|
0
|
|
|
|
|
$extra .= ' s=' . $silence if (defined($silence)); |
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
|
|
|
|
|
|
|
sub say_alpha { |
710
|
0
|
|
|
0
|
1
|
|
my ($self, $string, $digits) = @_; |
711
|
|
|
|
|
|
|
|
712
|
0
|
0
|
|
|
|
|
$digits = '""' if (!defined($digits)); |
713
|
|
|
|
|
|
|
|
714
|
0
|
0
|
|
|
|
|
return -1 if (!defined($string)); |
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
|
|
|
|
|
|
|
sub say_datetime_all { |
752
|
0
|
|
|
0
|
0
|
|
my ($self, $type, $time, $digits, $format, $timezone) = @_; |
753
|
|
|
|
|
|
|
|
754
|
0
|
|
|
|
|
|
my $ret = 0; |
755
|
0
|
0
|
|
|
|
|
return -1 if (!defined($time)); |
756
|
0
|
0
|
|
|
|
|
$digits = '""' if (!defined($digits)); |
757
|
0
|
0
|
|
|
|
|
$format = '' if (!defined($format)); |
758
|
0
|
0
|
|
|
|
|
$timezone = '' if (!defined($timezone)); |
759
|
|
|
|
|
|
|
|
760
|
0
|
0
|
|
|
|
|
if ($type eq 'date') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub say_date { |
774
|
0
|
|
|
0
|
1
|
|
my ($self, $time, $digits) = @_; |
775
|
|
|
|
|
|
|
|
776
|
0
|
|
|
|
|
|
return $self->say_datetime_all('date', $time, $digits); |
777
|
|
|
|
|
|
|
} |
778
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
sub say_time { |
780
|
0
|
|
|
0
|
1
|
|
my ($self, $time, $digits) = @_; |
781
|
|
|
|
|
|
|
|
782
|
0
|
|
|
|
|
|
return $self->say_datetime_all('time', $time, $digits); |
783
|
|
|
|
|
|
|
} |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
sub say_datetime { |
786
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub say_digits { |
806
|
0
|
|
|
0
|
1
|
|
my ($self, $number, $digits) = @_; |
807
|
|
|
|
|
|
|
|
808
|
0
|
0
|
|
|
|
|
$digits = '""' if (!defined($digits)); |
809
|
|
|
|
|
|
|
|
810
|
0
|
0
|
|
|
|
|
return -1 if (!defined($number)); |
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
|
|
|
|
|
|
|
sub say_number { |
830
|
0
|
|
|
0
|
1
|
|
my ($self, $number, $digits, $gender) = @_; |
831
|
|
|
|
|
|
|
|
832
|
0
|
0
|
|
|
|
|
$digits = '""' if (!defined($digits)); |
833
|
0
|
0
|
|
|
|
|
$gender = '' if (!defined($gender)); |
834
|
|
|
|
|
|
|
|
835
|
0
|
0
|
|
|
|
|
return -1 if (!defined($number)); |
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
|
|
|
|
|
|
|
sub say_phonetic { |
856
|
0
|
|
|
0
|
1
|
|
my ($self, $string, $digits) = @_; |
857
|
|
|
|
|
|
|
|
858
|
0
|
0
|
|
|
|
|
$digits = '""' if (!defined($digits)); |
859
|
|
|
|
|
|
|
|
860
|
0
|
0
|
|
|
|
|
return -1 if (!defined($string)); |
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
|
|
|
|
|
|
|
sub send_image { |
878
|
0
|
|
|
0
|
1
|
|
my ($self, $image) = @_; |
879
|
|
|
|
|
|
|
|
880
|
0
|
0
|
|
|
|
|
return -1 if (!defined($image)); |
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
|
|
|
|
|
|
|
sub send_text { |
899
|
0
|
|
|
0
|
1
|
|
my ($self, $text) = @_; |
900
|
|
|
|
|
|
|
|
901
|
0
|
0
|
|
|
|
|
return 0 if (!defined($text)); |
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 |
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
|
|
|
|
|
|
|
sub set_autohangup { |
920
|
0
|
|
|
0
|
1
|
|
my ($self, $time) = @_; |
921
|
|
|
|
|
|
|
|
922
|
0
|
0
|
|
|
|
|
$time = 0 if (!defined($time)); |
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 |
931
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
Example: $AGI->set_callerid('9995551212'); |
933
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
Returns: Always returns 1 |
935
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
=cut |
937
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
sub set_callerid { |
939
|
0
|
|
|
0
|
1
|
|
my ($self, $number) = @_; |
940
|
|
|
|
|
|
|
|
941
|
0
|
0
|
|
|
|
|
return if (!defined($number)); |
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
|
|
|
|
|
|
|
sub set_context { |
958
|
0
|
|
|
0
|
1
|
|
my ($self, $context) = @_; |
959
|
|
|
|
|
|
|
|
960
|
0
|
0
|
|
|
|
|
return -1 if (!defined($context)); |
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
|
|
|
|
|
|
|
sub set_extension { |
977
|
0
|
|
|
0
|
1
|
|
my ($self, $extension) = @_; |
978
|
|
|
|
|
|
|
|
979
|
0
|
0
|
|
|
|
|
return -1 if (!defined($extension)); |
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
|
|
|
|
|
|
|
sub set_music { |
998
|
0
|
|
|
0
|
1
|
|
my ($self, $mode, $class) = @_; |
999
|
|
|
|
|
|
|
|
1000
|
0
|
0
|
|
|
|
|
$mode = '' if (!defined($mode)); |
1001
|
0
|
0
|
|
|
|
|
$class = '' if (!defined($class)); |
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
|
|
|
|
|
|
|
sub set_priority { |
1019
|
0
|
|
|
0
|
1
|
|
my ($self, $priority) = @_; |
1020
|
|
|
|
|
|
|
|
1021
|
0
|
0
|
|
|
|
|
return -1 if (!defined($priority)); |
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 to |
1030
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
Example: $AGI->set_variable('status', 'authorized'); |
1032
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
Returns: Always returns 1 |
1034
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
=cut |
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
sub set_variable { |
1038
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub stream_file { |
1061
|
0
|
|
|
0
|
1
|
|
my ($self, $filename, $digits, $offset) = @_; |
1062
|
|
|
|
|
|
|
|
1063
|
0
|
0
|
|
|
|
|
return -1 if (!defined($filename)); |
1064
|
0
|
|
|
|
|
|
my $ret = undef; |
1065
|
0
|
0
|
|
|
|
|
$digits = '""' if (!defined($digits)); |
1066
|
0
|
0
|
|
|
|
|
$offset = '' if (!defined($offset)); |
1067
|
|
|
|
|
|
|
|
1068
|
0
|
0
|
|
|
|
|
if (ref($filename) eq "ARRAY") { |
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 " |
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
|
|
|
|
|
|
|
sub tdd_mode { |
1090
|
0
|
|
|
0
|
1
|
|
my ($self, $mode) = @_; |
1091
|
|
|
|
|
|
|
|
1092
|
0
|
0
|
|
|
|
|
return 0 if (!defined($mode)); |
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
|
|
|
|
|
|
|
sub verbose { |
1109
|
0
|
|
|
0
|
1
|
|
my ($self, $message, $level) = @_; |
1110
|
|
|
|
|
|
|
|
1111
|
0
|
0
|
|
|
|
|
$level = '' if (!$level); |
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
|
|
|
|
|
|
|
sub wait_for_digit { |
1131
|
0
|
|
|
0
|
1
|
|
my ($self, $timeout) = @_; |
1132
|
|
|
|
|
|
|
|
1133
|
0
|
0
|
|
|
|
|
$timeout = -1 if (!defined($timeout)); |
1134
|
0
|
|
|
|
|
|
return $self->execute("WAIT FOR DIGIT $timeout"); |
1135
|
|
|
|
|
|
|
} |
1136
|
|
|
|
|
|
|
|
1137
|
|
|
|
|
|
|
1; |
1138
|
|
|
|
|
|
|
|
1139
|
|
|
|
|
|
|
__END__ |