line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Asterisk::AMI::Common - Extends Asterisk::AMI to provide simple access to common AMI commands and functions |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
0.2.7_1 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Asterisk::AMI::Common; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $astman = Asterisk::AMI::Common->new( PeerAddr => '127.0.0.1', |
16
|
|
|
|
|
|
|
PeerPort => '5038', |
17
|
|
|
|
|
|
|
Username => 'admin', |
18
|
|
|
|
|
|
|
Secret => 'supersecret' |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
die "Unable to connect to asterisk" unless ($astman); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$astman->db_get(); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This module extends the AMI module to provide easier access to common actions and commands available |
28
|
|
|
|
|
|
|
through the AMI. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 Constructor |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head3 new([ARGS]) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Creates new a Asterisk::AMI::Common object which takes the arguments as key-value pairs. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This module inherits all options from the AMI module. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 Methods |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
attended_transfer ( CHANNEL, EXTEN, CONTEXT [, TIMEOUT ] ) |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Requires Asterisk 1.8+. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Performs an attended transfer on CHANNEL to EXTEN@CONTEXT. Returns 1 on success, 0 on failure, or undef on |
45
|
|
|
|
|
|
|
error or timeout. TIMEOUT is optional |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
bridge ( CHANNEL1, CHANNEL2 [, TIMEOUT ] ) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Requires Asterisk 1.8+. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Bridges CHANNEL1 and CHANNEL2. Returns 1 on success, 0 on failure, or undef on error or timeout. |
52
|
|
|
|
|
|
|
TIMEOUT is optional. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
commands ( [ TIMEOUT ] ) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Returns a hash reference of commands available through the AMI. TIMEOUT is optional |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$hashref->{'CommandName'}->{'Desc'} Contains the command description |
59
|
|
|
|
|
|
|
{'Priv'} Contains list of required privileges. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
db_show ( [ TIMEOUT ] ) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Returns a hash reference containing the contents of the Asterisk database, or undef on error or timeout. |
64
|
|
|
|
|
|
|
TIMEOUT is optional. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Values in the hash reference are stored as below: |
67
|
|
|
|
|
|
|
$hashref->{FAMILY}->{KEY} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
db_get ( FAMILY, KEY [, TIMEOUT ]) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Returns the value of the Asterisk database entry specified by the FAMILY and KEY pair, or undef if |
72
|
|
|
|
|
|
|
does not exist or an error occurred. TIMEOUT is optional. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
db_put ( FAMILY, KEY, VALUE [, TIMEOUT ]) |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Inserts VALUE for the Asterisk database entry specified by the FAMILY and KEY pair. Returns 1 on success, 0 if it |
77
|
|
|
|
|
|
|
failed or undef on error or timeout. TIMEOUT is optional. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
db_del ( FAMILY, KEY [, TIMEOUT ]) |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Requires Asterisk 1.8+. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Support for Asterisk 1.4 is provided through CLI commands. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Deletes the Asterisk database for FAMILY/KEY. Returns 1 on success, 0 if it failed |
86
|
|
|
|
|
|
|
or undef on error or timeout. TIMEOUT is optional. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
db_deltree ( FAMILY [, KEY, TIMEOUT ]) |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Requires Asterisk 1.8+. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Support for Asterisk 1.4 is provided through CLI commands. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Deletes the entire Asterisk database tree found under FAMILY/KEY. KEY is optional. Returns 1 on success, 0 if it failed |
95
|
|
|
|
|
|
|
or undef on error or timeout. TIMEOUT is optional. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
get_var ( CHANNEL, VARIABLE [, TIMEOUT ]) |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Returns the value of VARIABLE for CHANNEL, or undef on error or timeout. TIMEOUT is optional. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
set_var ( CHANNEL, VARIABLE, VALUE [, TIMEOUT ]) |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Sets VARIABLE to VALUE for CHANNEL. Returns 1 on success, 0 if it failed, or undef on error or timeout. |
104
|
|
|
|
|
|
|
TIMEOUT is optional. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
hangup ( CHANNEL [, TIMEOUT ]) |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Hangs up CHANNEL. Returns 1 on success, 0 if it failed, or undef on error or timeout. TIMEOUT is optional. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
exten_state ( EXTEN, CONTEXT [, TIMEOUT ]) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Returns the state of the EXTEN in CONTEXT, or undef on error or timeout. TIMEOUT is optional |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
States: |
115
|
|
|
|
|
|
|
-1 = Extension not found |
116
|
|
|
|
|
|
|
0 = Idle |
117
|
|
|
|
|
|
|
1 = In Use |
118
|
|
|
|
|
|
|
2 = Busy |
119
|
|
|
|
|
|
|
4 = Unavailable |
120
|
|
|
|
|
|
|
8 = Ringing |
121
|
|
|
|
|
|
|
16 = On Hold |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
park ( CHANNEL, CHANNEL2 [, PARKTIME, TIMEOUT ] ) |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Parks CHANNEL and announces park information to CHANNEL2. CHANNEL2 is also the channel the call will return to if |
126
|
|
|
|
|
|
|
it times out. |
127
|
|
|
|
|
|
|
PARKTIME is optional and can be used to control how long a person is parked for. TIMEOUT is optional. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Returns 1 if the call was parked, or 0 if it failed, or undef on error and timeout. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
parked_calls ( [ TIMEOUT ] ) |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Returns a hash reference containing parking lots and their members, or undef if an error/timeout or if no calls |
134
|
|
|
|
|
|
|
were parked. TIMEOUT is optional. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Hash reference structure: |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
$hashref->{lotnumber}->{'Channel'} |
139
|
|
|
|
|
|
|
{'Timeout'} |
140
|
|
|
|
|
|
|
{'CallerID'} |
141
|
|
|
|
|
|
|
{'CallerIDName'} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sip_peers ( [ TIMEOUT ] ) |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Returns a hash reference containing all SIP peers, or undef on error or timeout. TIMEOUT is optional. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Hash reference structure: |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
$hashref->{peername}->{'Channeltype'} |
150
|
|
|
|
|
|
|
{'ChanObjectType'} |
151
|
|
|
|
|
|
|
{'IPaddress'} |
152
|
|
|
|
|
|
|
{'IPport'} |
153
|
|
|
|
|
|
|
{'Dynamic'} |
154
|
|
|
|
|
|
|
{'Natsupport'} |
155
|
|
|
|
|
|
|
{'VideoSupport'} |
156
|
|
|
|
|
|
|
{'ACL'} |
157
|
|
|
|
|
|
|
{'Status'} |
158
|
|
|
|
|
|
|
{'RealtimeDevice'} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sip_peer ( PEERNAME [, TIMEOUT ] ) |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Returns a hash reference containing the information for PEERNAME, or undef on error or timeout. |
163
|
|
|
|
|
|
|
TIMEOUT is optional. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Hash reference structure: |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
$hashref->{'SIPLastMsg'} |
168
|
|
|
|
|
|
|
{'SIP-UserPhone'} |
169
|
|
|
|
|
|
|
{'Dynamic'} |
170
|
|
|
|
|
|
|
{'TransferMode'} |
171
|
|
|
|
|
|
|
{'SIP-NatSupport'} |
172
|
|
|
|
|
|
|
{'Call-limit'} |
173
|
|
|
|
|
|
|
{'CID-CallingPres'} |
174
|
|
|
|
|
|
|
{'LastMsgsSent'} |
175
|
|
|
|
|
|
|
{'Status'} |
176
|
|
|
|
|
|
|
{'Address-IP'} |
177
|
|
|
|
|
|
|
{'RegExpire'} |
178
|
|
|
|
|
|
|
{'ToHost'} |
179
|
|
|
|
|
|
|
{'Codecs'}, |
180
|
|
|
|
|
|
|
{'Default-addr-port'} |
181
|
|
|
|
|
|
|
{'SIP-DTMFmode'} |
182
|
|
|
|
|
|
|
{'Channeltype'} |
183
|
|
|
|
|
|
|
{'ChanObjectType'} |
184
|
|
|
|
|
|
|
{'AMAflags'} |
185
|
|
|
|
|
|
|
{'SIP-AuthInsecure'} |
186
|
|
|
|
|
|
|
{'SIP-VideoSupport'} |
187
|
|
|
|
|
|
|
{'Callerid'} |
188
|
|
|
|
|
|
|
{'Address-Port'} |
189
|
|
|
|
|
|
|
{'Context'} |
190
|
|
|
|
|
|
|
{'ObjectName'} |
191
|
|
|
|
|
|
|
{'ACL'} |
192
|
|
|
|
|
|
|
{'Default-addr-IP'} |
193
|
|
|
|
|
|
|
{'SIP-PromiscRedir'} |
194
|
|
|
|
|
|
|
{'MaxCallBR'} |
195
|
|
|
|
|
|
|
{'MD5SecretExist'} |
196
|
|
|
|
|
|
|
{'SIP-CanReinvite'} |
197
|
|
|
|
|
|
|
{'CodecOrder'} |
198
|
|
|
|
|
|
|
{'SecretExist'} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sip_notify ( PEER, EVENT [, TIMEOUT ]) |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Sends a SIP NOTIFY to PEER with EVENT. Returns 1 on success 0 on failure or undef on error or timeout. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Example - Sending a 'check-sync' event to to a SIP PEER named 'Polycom1': |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
$astman->sip_notify('Polycom1', 'check-sync'); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
mailboxcount ( EXTENSION, CONTEXT [, TIMEOUT ] ) |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Returns an hash reference containing the message counts for the mailbox EXTENSION@CONTEXT, or undef on error or |
211
|
|
|
|
|
|
|
timeout. TIMEOUT is optional. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Hash reference structure: |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
$hashref->{'Mailbox'} |
216
|
|
|
|
|
|
|
{'NewMessages'} |
217
|
|
|
|
|
|
|
{'OldMessages'} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
mailboxstatus ( EXTENSION, CONTEXT [, TIMEOUT ] ) |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Returns the status of the mailbox or undef on error or timeout. TIMEOUT is optional |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
chan_timeout ( CHANNEL, CHANNELTIMEOUT [, TIMEOUT ] ) |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Sets CHANNEL to timeout in CHANNELTIMEOUT seconds. Returns 1 on success, 0 on failure, or undef on error or timeout. |
226
|
|
|
|
|
|
|
TIMEOUT is optional. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
queues ( [ TIMEOUT ] ) |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Returns a hash reference containing all queues, queue members, and people currently waiting in the queue, |
231
|
|
|
|
|
|
|
or undef on error or timeout. TIMEOUT is optional |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Hash reference structure: |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
$hashref->{queue}->{'Max'} |
236
|
|
|
|
|
|
|
{'Calls'} |
237
|
|
|
|
|
|
|
{'Holdtime'} |
238
|
|
|
|
|
|
|
{'Completed'} |
239
|
|
|
|
|
|
|
{'Abandoned'} |
240
|
|
|
|
|
|
|
{'ServiceLevel'} |
241
|
|
|
|
|
|
|
{'ServicelevelPerf'} |
242
|
|
|
|
|
|
|
{'Weight'} |
243
|
|
|
|
|
|
|
{'MEMBERS'}->{name}->{'Location'} |
244
|
|
|
|
|
|
|
{'Membership'} |
245
|
|
|
|
|
|
|
{'Penalty'} |
246
|
|
|
|
|
|
|
{'CallsTaken'} |
247
|
|
|
|
|
|
|
{'LastCall'} |
248
|
|
|
|
|
|
|
{'Status'} |
249
|
|
|
|
|
|
|
{'Paused'} |
250
|
|
|
|
|
|
|
{'ENTRIES'}->{position}->{'Channel'} |
251
|
|
|
|
|
|
|
{'CallerID'} |
252
|
|
|
|
|
|
|
{'CallerIDName'} |
253
|
|
|
|
|
|
|
{'Wait'} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
queue_status ( QUEUE [, TIMEOUT ] ) |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Returns a hash reference containing the queue status, members, and people currently waiting in the queue, |
258
|
|
|
|
|
|
|
or undef on error or timeout. TIMEOUT is optional. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Hash reference structure |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
$hashref->{'Max'} |
263
|
|
|
|
|
|
|
{'Calls'} |
264
|
|
|
|
|
|
|
{'Holdtime'} |
265
|
|
|
|
|
|
|
{'Completed'} |
266
|
|
|
|
|
|
|
{'Abandoned'} |
267
|
|
|
|
|
|
|
{'ServiceLevel'} |
268
|
|
|
|
|
|
|
{'ServicelevelPerf'} |
269
|
|
|
|
|
|
|
{'Weight'} |
270
|
|
|
|
|
|
|
{'MEMBERS'}->{name}->{'Location'} |
271
|
|
|
|
|
|
|
{'Membership'} |
272
|
|
|
|
|
|
|
{'Penalty'} |
273
|
|
|
|
|
|
|
{'CallsTaken'} |
274
|
|
|
|
|
|
|
{'LastCall'} |
275
|
|
|
|
|
|
|
{'Status'} |
276
|
|
|
|
|
|
|
{'Paused'} |
277
|
|
|
|
|
|
|
{'ENTRIES'}->{position}->{'Channel'} |
278
|
|
|
|
|
|
|
{'CallerID'} |
279
|
|
|
|
|
|
|
{'CallerIDName'} |
280
|
|
|
|
|
|
|
{'Wait'} |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
queue_member_pause ( QUEUE, MEMBER, PAUSEVALUE [, TIMEOUT ] ) |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Sets the MEMBER of QUEUE to PAUSEVALUE. A value of 0 will un-pause a member, and 1 will pause them. |
285
|
|
|
|
|
|
|
Returns 1 if the PAUSEVALUE was set, 0 if it failed, or undef on error or timeout. TIMEOUT is optional. |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
queue_member_toggle ( QUEUE, MEMBER [, TIMEOUT ] ) |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
Toggles MEMBER of QUEUE pause status. From paused to un-paused, and un-paused to paused. |
290
|
|
|
|
|
|
|
Returns 1 if the the pause status was toggled, 0 if failed, or undef on error or timeout. TIMEOUT is optional |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
queue_add ( QUEUE, MEMEBER [, TIMEOUT ] ) |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
Adds MEMBER to QUEUE. Returns 1 if the MEMBER was added, or 0 if it failed, or undef on error or timeout. |
295
|
|
|
|
|
|
|
TIMEOUT is optional. |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
queue_remove ( QUEUE, MEMEBER [, TIMEOUT ] ) |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
Removes MEMBER from QUEUE. Returns 1 if the MEMBER was removed, 0 if it failed, or undef on error or timeout. |
300
|
|
|
|
|
|
|
TIMEOUT is optional. |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
play_dtmf ( CHANNEL, DIGIT [, TIMEOUT ] ) |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
Plays the dtmf DIGIT on CHANNEL. Returns 1 if the DIGIT was queued on the channel, or 0 if it failed, or |
305
|
|
|
|
|
|
|
undef on error or timeout. |
306
|
|
|
|
|
|
|
TIMEOUT is optional. |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
play_digits ( CHANNEL, DIGITS [, TIMEOUT ] ) |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
Plays the dtmf DIGITS on CHANNEL. DIGITS should be passed as an array reference. Returns 1 if all DIGITS |
311
|
|
|
|
|
|
|
were queued on the channel, or 0 if an any queuing failed. TIMEOUT is optional. |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
channels ( [ TIMEOUT ] ) |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
Returns a hash reference containing all channels with their information, or undef on error or timeout. |
316
|
|
|
|
|
|
|
TIMEOUT is optional. |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
Hash reference structure: |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
$hashref->{channel}->{'Context'} |
321
|
|
|
|
|
|
|
{'CallerID'} |
322
|
|
|
|
|
|
|
{'CallerIDNum'} |
323
|
|
|
|
|
|
|
{'CallerIDName'} |
324
|
|
|
|
|
|
|
{'Account'} |
325
|
|
|
|
|
|
|
{'State'} |
326
|
|
|
|
|
|
|
{'Context'} |
327
|
|
|
|
|
|
|
{'Extension'} |
328
|
|
|
|
|
|
|
{'Priority'} |
329
|
|
|
|
|
|
|
{'Seconds'} |
330
|
|
|
|
|
|
|
{'Link'} |
331
|
|
|
|
|
|
|
{'Uniqueid'} |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
chan_status ( CHANNEL [, TIMEOUT ] ) |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
Returns a hash reference containing the status of the channel, or undef on error or timeout. |
336
|
|
|
|
|
|
|
TIMEOUT is optional. |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
Hash reference structure: |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
$hashref->{'Channel'} |
341
|
|
|
|
|
|
|
{'CallerID'} |
342
|
|
|
|
|
|
|
{'CallerIDNum'} |
343
|
|
|
|
|
|
|
{'CallerIDName'} |
344
|
|
|
|
|
|
|
{'Account'} |
345
|
|
|
|
|
|
|
{'State'} |
346
|
|
|
|
|
|
|
{'Context'} |
347
|
|
|
|
|
|
|
{'Extension'} |
348
|
|
|
|
|
|
|
{'Priority'} |
349
|
|
|
|
|
|
|
{'Seconds'} |
350
|
|
|
|
|
|
|
{'Link'} |
351
|
|
|
|
|
|
|
{'Uniqueid'} |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
transfer ( CHANNEL, EXTENSION, CONTEXT [, TIMEOUT ] ) |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
Transfers CHANNEL to EXTENSION at CONTEXT. Returns 1 if the channel was transferred, 0 if it failed, |
356
|
|
|
|
|
|
|
or undef on error or timeout. TIMEOUT is optional. |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
meetme_list ( [ TIMEOUT ] ) |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
Full support requires Asterisk 1.8+. |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
Partial support is provided on Asterisk 1.4 via cli commands. When using with asteirsk 1.4 the following |
363
|
|
|
|
|
|
|
keys are missing: Role, MarkedUser |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
Returns a hash reference containing all meetme conferences and their members, or undef if an error occurred. |
366
|
|
|
|
|
|
|
TIMEOUT is optional. |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
Hash reference: |
369
|
|
|
|
|
|
|
$hashref->{RoomNum}->{MemberChannels}->{'Muted'} |
370
|
|
|
|
|
|
|
{'Role'} |
371
|
|
|
|
|
|
|
{'Talking'} |
372
|
|
|
|
|
|
|
{'UserNumber'} |
373
|
|
|
|
|
|
|
{'CallerIDName'} |
374
|
|
|
|
|
|
|
{'MarkedUser'} |
375
|
|
|
|
|
|
|
{'CallerIDNum'} |
376
|
|
|
|
|
|
|
{'Admin'} |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
meetme_members ( ROOMNUM [, TIMEOUT ] ) |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
Full support requires Asterisk 1.8+. |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
Partial support is provided on Asterisk 1.4 via cli commands. When using with asteirsk 1.4 the following |
383
|
|
|
|
|
|
|
keys are missing: Role, MarkedUser |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
Returns a hash reference containing all members of a meetme conference, or undef if an error occurred. |
386
|
|
|
|
|
|
|
TIMEOUT is optional. |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
Hash reference: |
389
|
|
|
|
|
|
|
$hashref->{MemberChannels}->{'Muted'} |
390
|
|
|
|
|
|
|
{'Role'} |
391
|
|
|
|
|
|
|
{'Talking'} |
392
|
|
|
|
|
|
|
{'UserNumber'} |
393
|
|
|
|
|
|
|
{'CallerIDName'} |
394
|
|
|
|
|
|
|
{'MarkedUser'} |
395
|
|
|
|
|
|
|
{'CallerIDNum'} |
396
|
|
|
|
|
|
|
{'Admin'} |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
meetme_mute ( CONFERENCE, USERNUM [, TIMEOUT ] ) |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
Mutes USERNUM in CONFERENCE. Returns 1 if the user was muted, 0 if it failed, or undef on error or timeout. |
401
|
|
|
|
|
|
|
TIMEOUT is optional. |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
meetme_unmute ( CONFERENCE, USERNUM [, TIMEOUT ] ) |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
Un-mutes USERNUM in CONFERENCE. Returns 1 if the user was un-muted, or 0 if it failed, or undef on error or timeout. |
406
|
|
|
|
|
|
|
TIMEOUT is optional. |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
mute_chan ( CHANNEL [, DIRECTION, TIMEOUT ] ) |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
Mutes audio on CHANNEL. DIRECTION is optiona and can be 'in' for inbound audio only, 'out' for outbound audio |
411
|
|
|
|
|
|
|
only or 'all' to for both directions. If not supplied it defaults to 'all'. Returns 1 on success, 0 if it failed, |
412
|
|
|
|
|
|
|
or undef on error or timeout. TIMEOUT is optional. |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
unmute_chan ( CHANNEL [, DIRECTION, TIMEOUT ] ) |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
UnMutes audio on CHANNEL. DIRECTION is optiona and can be 'in' for inbound audio only, 'out' for outbound audio |
417
|
|
|
|
|
|
|
only or 'all' to for both directions. If not supplied it defaults to 'all'. Returns 1 on success, 0 if it failed, |
418
|
|
|
|
|
|
|
or undef on error or timeout. TIMEOUT is optional. |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
monitor ( CHANNEL, FILE [, TIMEOUT ] ) |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
Begins recording CHANNEL to FILE. Uses the 'wav' format and also mixes both directions into a single file. |
423
|
|
|
|
|
|
|
Returns 1 if the channel was set to record, or 0 if it failed, or undef on error or timeout. TIMEOUT is optional. |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
monitor_stop ( CHANNEL [, TIMEOUT ]) |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
Stops recording CHANNEL. Returns 1 if recording on the channel was stopped, 0 if it failed, or undef on error |
428
|
|
|
|
|
|
|
or timeout. |
429
|
|
|
|
|
|
|
TIMEOUT is optional. |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
monitor_pause ( CHANNEL [, TIMEOUT ]) |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
Pauses recording on CHANNEL. Returns 1 if recording on the channel was paused, 0 if it failed, or undef on error |
434
|
|
|
|
|
|
|
or timeout. |
435
|
|
|
|
|
|
|
TIMEOUT is optional. |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
monitor_unpause ( CHANNEL [, TIMEOUT ]) |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
Un-pauses recording on CHANNEL. Returns 1 if recording on the channel was un-paused, 0 if it failed, or undef on error |
440
|
|
|
|
|
|
|
or timeout. |
441
|
|
|
|
|
|
|
TIMEOUT is optional. |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
monitor_change ( CHANNEL, FILE [, TIMEOUT ] ) |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
Changes the monitor file for CHANNEL to FILE. Returns 1 if the file was change, 0 if it failed, or undef on error |
446
|
|
|
|
|
|
|
or timeout. |
447
|
|
|
|
|
|
|
TIMEOUT is optional. |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
mixmonitor_mute ( CHANNEL [, DIRECTION, TIMEOUT] ) |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
Requires Asterisk 1.8+ |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
Mutes audio on CHANNEL. DIRECTION is optiona and can be 'read' for inbound audio only, 'write' for outbound audio |
454
|
|
|
|
|
|
|
only or 'both' to for both directions. If not supplied it defaults to 'both'. Returns 1 on success, 0 if it failed, |
455
|
|
|
|
|
|
|
or undef on error or timeout. TIMEOUT is optional. |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
mixmonitor_unmute ( CHANNEL [, DIRECTION, TIMEOUT] ) |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
Requires Asterisk 1.8+ |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
UnMutes audio on CHANNEL. DIRECTION is optiona and can be 'read' for inbound audio only, 'write' for outbound audio |
462
|
|
|
|
|
|
|
only or 'both' to for both directions. If not supplied it defaults to 'both'. Returns 1 on success, 0 if it failed, |
463
|
|
|
|
|
|
|
or undef on error or timeout. TIMEOUT is optional. |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
text ( CHANNEL, MESSAGE [, TIMEOUT ] ) |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
Requires Asterisk 1.8+. |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
Sends MESSAGE as a text on CHANNEL. Returns 1 on success, 0 on failure, or undef on error or timeout. |
470
|
|
|
|
|
|
|
TIMEOUT is optional. |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
voicemail_list ( [ TIMEOUT ] ) |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
Requires Asterisk 1.8+. |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
Returns a hash reference of all mailboxes on the system, or undef if an error occurred. |
477
|
|
|
|
|
|
|
TIMEOUT is optional. |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
Hash reference: |
480
|
|
|
|
|
|
|
$hashref->{context}->{mailbox}->{'AttachmentFormat'} |
481
|
|
|
|
|
|
|
{'TimeZone'} |
482
|
|
|
|
|
|
|
{'Pager'} |
483
|
|
|
|
|
|
|
{'SayEnvelope'} |
484
|
|
|
|
|
|
|
{'ExitContext'} |
485
|
|
|
|
|
|
|
{'AttachMessage'} |
486
|
|
|
|
|
|
|
{'SayCID'} |
487
|
|
|
|
|
|
|
{'ServerEmail'} |
488
|
|
|
|
|
|
|
{'CanReview'} |
489
|
|
|
|
|
|
|
{'DeleteMessage'} |
490
|
|
|
|
|
|
|
{'UniqueID'} |
491
|
|
|
|
|
|
|
{'Email'} |
492
|
|
|
|
|
|
|
{'MaxMessageLength'} |
493
|
|
|
|
|
|
|
{'CallOperator'} |
494
|
|
|
|
|
|
|
{'SayDurationMinimum'} |
495
|
|
|
|
|
|
|
{'NewMessageCount'} |
496
|
|
|
|
|
|
|
{'Language'} |
497
|
|
|
|
|
|
|
{'MaxMessageCount'} |
498
|
|
|
|
|
|
|
{'Fullname'} |
499
|
|
|
|
|
|
|
{'Callback'} |
500
|
|
|
|
|
|
|
{'MailCommand'} |
501
|
|
|
|
|
|
|
{'VolumeGain'} |
502
|
|
|
|
|
|
|
{'Dialout'} |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
module_check ( MODULE [, TIMEOUT ] ) |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
Full support requires Asterisk 1.8+. |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
Partial support is provided on Asterisk 1.4 via cli commands. |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
Checks to see if MODULE is loaded. Returns 1 on success (loaded), 0 on failure (not loaded), or undef on error or timeout. |
511
|
|
|
|
|
|
|
MODULE is the name of the module minus its extension. To check for 'app_meetme.so' you would only use 'app_meetme'. |
512
|
|
|
|
|
|
|
TIMEOUT is optional. |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
module_load, module_reload, module_unload ( MODULE [, TIMEOUT ] ) |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
Requires Asterisk 1.8+. |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
Attempts to load/reload/unload MODULE. Returns 1 on success, 0 on failure, or undef on error or timeout. |
519
|
|
|
|
|
|
|
MODULE is the name of the module with its extension or an asterisk subsystem. To load 'app_meetme.so' you would use 'app_meetme.so'. |
520
|
|
|
|
|
|
|
TIMEOUT is optional. |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
Valid Asterisk Subsystems: |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
cdr |
525
|
|
|
|
|
|
|
enum |
526
|
|
|
|
|
|
|
dnsmgr |
527
|
|
|
|
|
|
|
extconfig |
528
|
|
|
|
|
|
|
manager |
529
|
|
|
|
|
|
|
rtp |
530
|
|
|
|
|
|
|
http |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
originate ( CHANNEL, CONTEXT, EXTEN [, CALLERID, CTIMEOUT, TIMEOUT ] ) |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
Attempts to dial CHANNEL and then drops it into EXTEN@CONTEXT in the dialplan. Optionally a CALLERID can be provided. |
535
|
|
|
|
|
|
|
CTIMEOUT is optional and determines how long the call will dial/ring for in seconds. TIMEOUT is optional. |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
CTIMEOUT + TIMEOUT will be used for the command timeout. For example if CTIMEOUT is 30 seconds and TIMEOUT is 5 seconds, the entire |
538
|
|
|
|
|
|
|
command will timeout after 35 seconds. |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
Returns 1 on success 0 on failure, or undef on error or timeout. |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
WARNING: This method can block for a very long time (CTIMEOUT + TIMEOUT). |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
originate_async ( CHANNEL, CONTEXT, EXTEN [, CALLERID, CTIMEOUT, TIMEOUT ] ) |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
Attempts to dial CHANNEL and then drops it into EXTEN@CONTEXT in the dialplan asynchronously. Optionally a CALLERID can be provided. |
547
|
|
|
|
|
|
|
CTIMEOUT is optional and determines how long the call will dial/ring for in seconds. TIMEOUT is optional and only affects how long we will |
548
|
|
|
|
|
|
|
wait for the initial response from Asterisk indicating if the call has been queued. |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
Returns 1 if the call was successfully queued, 0 on failure, or undef on error or timeout. |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
WARNING: A successfully queued call does not mean the call completed or even originated. |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
=head1 See Also |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
Asterisk::AMI, Asterisk::AMI::Common::Dev |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
=head1 AUTHOR |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
Ryan Bullock (rrb3942@gmail.com) |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
=head1 BUG REPORTING AND FEEBACK |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
Please report any bugs or errors to our github issue tracker at http://github.com/rrb3942/perl-Asterisk-AMI/issues |
565
|
|
|
|
|
|
|
or the cpan request tracker at https://rt.cpan.org/Public/Bug/Report.html?Queue=perl-Asterisk-AMI |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
=head1 LICENSE |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
Copyright (C) 2011 by Ryan Bullock (rrb3942@gmail.com) |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
This module is free software. You can redistribute it and/or |
572
|
|
|
|
|
|
|
modify it under the terms of the Artistic License 2.0. |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
575
|
|
|
|
|
|
|
but without any warranty; without even the implied warranty of |
576
|
|
|
|
|
|
|
merchantability or fitness for a particular purpose. |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
=cut |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
package Asterisk::AMI::Common; |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
|
583
|
1
|
|
|
1
|
|
10519
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
332
|
|
584
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
585
|
1
|
|
|
1
|
|
1212
|
use parent qw(Asterisk::AMI); |
|
1
|
|
|
|
|
881
|
|
|
1
|
|
|
|
|
8
|
|
586
|
|
|
|
|
|
|
|
587
|
1
|
|
|
1
|
|
76
|
use version 0.77; our $VERSION = version->declare("v0.2.7_1"); |
|
1
|
|
|
|
|
38
|
|
|
1
|
|
|
|
|
12
|
|
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
sub new { |
590
|
0
|
|
|
0
|
1
|
|
my ($class, %options) = @_; |
591
|
|
|
|
|
|
|
|
592
|
0
|
|
|
|
|
|
return $class->SUPER::new(%options); |
593
|
|
|
|
|
|
|
} |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
sub attended_transfer { |
596
|
|
|
|
|
|
|
|
597
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $exten, $context, $timeout) = @_; |
598
|
|
|
|
|
|
|
|
599
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'Atxfer', |
600
|
|
|
|
|
|
|
Channel => $channel, |
601
|
|
|
|
|
|
|
Exten => $exten, |
602
|
|
|
|
|
|
|
Context => $context, |
603
|
|
|
|
|
|
|
Priority => 1 }, $timeout); |
604
|
|
|
|
|
|
|
} |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
sub bridge { |
607
|
0
|
|
|
0
|
0
|
|
my ($self, $chan1, $chan2, $timeout) = @_; |
608
|
|
|
|
|
|
|
|
609
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'Bridge', |
610
|
|
|
|
|
|
|
Channel1 => $chan1, |
611
|
|
|
|
|
|
|
Channel2 => $chan2, |
612
|
|
|
|
|
|
|
Tone => 'Yes'}, $timeout); |
613
|
|
|
|
|
|
|
} |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
#Returns a hash |
616
|
|
|
|
|
|
|
sub commands { |
617
|
|
|
|
|
|
|
|
618
|
0
|
|
|
0
|
0
|
|
my ($self, $timeout) = @_; |
619
|
|
|
|
|
|
|
|
620
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'ListCommands' }, $timeout); |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
#Early bail out on bad response |
623
|
0
|
0
|
|
|
|
|
return unless ($action->{'GOOD'}); |
624
|
|
|
|
|
|
|
|
625
|
0
|
|
|
|
|
|
my %commands; |
626
|
|
|
|
|
|
|
|
627
|
0
|
|
|
|
|
|
while (my ($cmd, $desc) = each %{$action->{'PARSED'}}) { |
|
0
|
|
|
|
|
|
|
628
|
0
|
0
|
|
|
|
|
if ($desc =~ s/\s*\(Priv:\ (.+)\)$//x) { |
629
|
0
|
|
|
|
|
|
my @privs = split /,/x,$1; |
630
|
0
|
|
|
|
|
|
$commands{$cmd}->{'Priv'} = \@privs; |
631
|
|
|
|
|
|
|
} |
632
|
|
|
|
|
|
|
|
633
|
0
|
|
|
|
|
|
$commands{$cmd}->{'Desc'} = $desc; |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
0
|
|
|
|
|
|
return \%commands; |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
} |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
sub db_get { |
641
|
|
|
|
|
|
|
|
642
|
0
|
|
|
0
|
0
|
|
my ($self, $family, $key, $timeout) = @_; |
643
|
|
|
|
|
|
|
|
644
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'DBGet', |
645
|
|
|
|
|
|
|
Family => $family, |
646
|
|
|
|
|
|
|
Key => $key }, $timeout); |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
|
649
|
0
|
0
|
|
|
|
|
if ($action->{'GOOD'}) { |
650
|
0
|
|
|
|
|
|
return $action->{'EVENTS'}->[0]->{'Val'}; |
651
|
|
|
|
|
|
|
} |
652
|
|
|
|
|
|
|
|
653
|
0
|
|
|
|
|
|
return; |
654
|
|
|
|
|
|
|
} |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
sub db_put { |
657
|
|
|
|
|
|
|
|
658
|
0
|
|
|
0
|
0
|
|
my ($self, $family, $key, $value, $timeout) = @_; |
659
|
|
|
|
|
|
|
|
660
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'DBPut', |
661
|
|
|
|
|
|
|
Family => $family, |
662
|
|
|
|
|
|
|
Key => $key, |
663
|
|
|
|
|
|
|
Val => $value }, $timeout); |
664
|
|
|
|
|
|
|
} |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
sub db_show { |
667
|
|
|
|
|
|
|
|
668
|
0
|
|
|
0
|
0
|
|
my ($self, $timeout) = @_; |
669
|
|
|
|
|
|
|
|
670
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'Command', |
671
|
|
|
|
|
|
|
Command => 'database show'}, $timeout); |
672
|
|
|
|
|
|
|
|
673
|
0
|
0
|
|
|
|
|
return unless ($action->{'GOOD'}); |
674
|
|
|
|
|
|
|
|
675
|
0
|
|
|
|
|
|
my $database; |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
#Remove summary line |
678
|
0
|
|
|
|
|
|
delete $action->{'CMD'}->[-1]; |
679
|
|
|
|
|
|
|
|
680
|
0
|
|
|
|
|
|
foreach my $dbentry (@{$action->{'CMD'}}) { |
|
0
|
|
|
|
|
|
|
681
|
0
|
|
|
|
|
|
my ($family, $val) = split /\s*:\s*/, $dbentry, 2; |
682
|
|
|
|
|
|
|
|
683
|
0
|
|
|
|
|
|
my @split = split /\//ox,$family; |
684
|
|
|
|
|
|
|
|
685
|
0
|
|
|
|
|
|
my $key = pop(@split); |
686
|
|
|
|
|
|
|
|
687
|
0
|
|
|
|
|
|
$family = join('/', @split); |
688
|
|
|
|
|
|
|
|
689
|
0
|
|
|
|
|
|
$family = substr($family, 1); |
690
|
|
|
|
|
|
|
|
691
|
0
|
0
|
0
|
|
|
|
if ($val eq '' || $val eq '') { |
692
|
0
|
|
|
|
|
|
$val = undef; |
693
|
|
|
|
|
|
|
} |
694
|
|
|
|
|
|
|
|
695
|
0
|
|
|
|
|
|
$database->{$family}->{$key} = $val; |
696
|
|
|
|
|
|
|
} |
697
|
|
|
|
|
|
|
|
698
|
0
|
|
|
|
|
|
return $database; |
699
|
|
|
|
|
|
|
} |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
sub db_del { |
702
|
|
|
|
|
|
|
|
703
|
0
|
|
|
0
|
0
|
|
my ($self, $family, $key, $timeout) = @_; |
704
|
|
|
|
|
|
|
|
705
|
0
|
|
|
|
|
|
my $ver = $self->amiver(); |
706
|
|
|
|
|
|
|
|
707
|
0
|
0
|
0
|
|
|
|
if (defined($ver) && $ver >= 1.1) { |
708
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'DBDel', |
709
|
|
|
|
|
|
|
Family => $family, |
710
|
|
|
|
|
|
|
Key => $key }, $timeout); |
711
|
|
|
|
|
|
|
} else { |
712
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'Command', |
713
|
|
|
|
|
|
|
Command => 'database del ' . $family . ' ' . $key }, $timeout); |
714
|
|
|
|
|
|
|
} |
715
|
|
|
|
|
|
|
|
716
|
0
|
|
|
|
|
|
return; |
717
|
|
|
|
|
|
|
} |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
sub db_deltree { |
720
|
|
|
|
|
|
|
|
721
|
0
|
|
|
0
|
0
|
|
my ($self, $family, $key, $timeout) = @_; |
722
|
|
|
|
|
|
|
|
723
|
0
|
|
|
|
|
|
my $ver = $self->amiver(); |
724
|
|
|
|
|
|
|
|
725
|
0
|
0
|
0
|
|
|
|
if (defined($ver) && $ver >= 1.1) { |
726
|
|
|
|
|
|
|
|
727
|
0
|
|
|
|
|
|
my %action = ( Action => 'DBDelTree', |
728
|
|
|
|
|
|
|
Family => $family ); |
729
|
|
|
|
|
|
|
|
730
|
0
|
0
|
|
|
|
|
$action{'Key'} = $key if (defined $key); |
731
|
|
|
|
|
|
|
|
732
|
0
|
|
|
|
|
|
return $self->simple_action(\%action, $timeout); |
733
|
|
|
|
|
|
|
} else { |
734
|
|
|
|
|
|
|
|
735
|
0
|
|
|
|
|
|
my $cmd = 'database deltree ' . $family; |
736
|
|
|
|
|
|
|
|
737
|
0
|
0
|
|
|
|
|
if (defined $key) { |
738
|
0
|
|
|
|
|
|
$cmd .= ' ' . $key; |
739
|
|
|
|
|
|
|
} |
740
|
|
|
|
|
|
|
|
741
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'Command', |
742
|
|
|
|
|
|
|
Command => $cmd }, $timeout); |
743
|
|
|
|
|
|
|
} |
744
|
|
|
|
|
|
|
|
745
|
0
|
|
|
|
|
|
return; |
746
|
|
|
|
|
|
|
} |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
sub get_var { |
749
|
|
|
|
|
|
|
|
750
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $variable, $timeout) = @_; |
751
|
|
|
|
|
|
|
|
752
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'GetVar', |
753
|
|
|
|
|
|
|
Channel => $channel, |
754
|
|
|
|
|
|
|
Variable => $variable }, $timeout); |
755
|
|
|
|
|
|
|
|
756
|
0
|
0
|
|
|
|
|
if ($action->{'GOOD'}) { |
757
|
0
|
|
|
|
|
|
return $action->{'PARSED'}->{'Value'}; |
758
|
|
|
|
|
|
|
} |
759
|
|
|
|
|
|
|
|
760
|
0
|
|
|
|
|
|
return; |
761
|
|
|
|
|
|
|
} |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
sub set_var { |
764
|
|
|
|
|
|
|
|
765
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $varname, $value, $timeout) = @_; |
766
|
|
|
|
|
|
|
|
767
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'Setvar', |
768
|
|
|
|
|
|
|
Channel => $channel, |
769
|
|
|
|
|
|
|
Variable => $varname, |
770
|
|
|
|
|
|
|
Value => $value }, $timeout); |
771
|
|
|
|
|
|
|
} |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
sub hangup { |
774
|
|
|
|
|
|
|
|
775
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $timeout) = @_; |
776
|
|
|
|
|
|
|
|
777
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'Hangup', |
778
|
|
|
|
|
|
|
Channel => $channel }, $timeout); |
779
|
|
|
|
|
|
|
} |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
sub exten_state { |
782
|
|
|
|
|
|
|
|
783
|
0
|
|
|
0
|
0
|
|
my ($self, $exten, $context, $timeout) = @_; |
784
|
|
|
|
|
|
|
|
785
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'ExtensionState', |
786
|
|
|
|
|
|
|
Exten => $exten, |
787
|
|
|
|
|
|
|
Context => $context }, $timeout); |
788
|
|
|
|
|
|
|
|
789
|
0
|
0
|
|
|
|
|
if ($action->{'GOOD'}) { |
790
|
0
|
|
|
|
|
|
return $action->{'PARSED'}->{'Status'}; |
791
|
|
|
|
|
|
|
} |
792
|
|
|
|
|
|
|
|
793
|
0
|
|
|
|
|
|
return; |
794
|
|
|
|
|
|
|
} |
795
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
sub park { |
797
|
0
|
|
|
0
|
0
|
|
my ($self, $chan1, $chan2, $parktime, $timeout) = @_; |
798
|
|
|
|
|
|
|
|
799
|
0
|
|
|
|
|
|
my %action = ( Action => 'Park', |
800
|
|
|
|
|
|
|
Channel => $chan1, |
801
|
|
|
|
|
|
|
Channel2 => $chan2 ); |
802
|
|
|
|
|
|
|
|
803
|
0
|
0
|
|
|
|
|
$action{'Timeout'} = $parktime if (defined $parktime); |
804
|
|
|
|
|
|
|
|
805
|
0
|
|
|
|
|
|
return $self->simple_action(\%action, $timeout); |
806
|
|
|
|
|
|
|
} |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
sub parked_calls { |
809
|
|
|
|
|
|
|
|
810
|
0
|
|
|
0
|
0
|
|
my ($self, $timeout) = @_; |
811
|
|
|
|
|
|
|
|
812
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'ParkedCalls' }, $timeout); |
813
|
|
|
|
|
|
|
|
814
|
0
|
0
|
|
|
|
|
return unless ($action->{'GOOD'}); |
815
|
|
|
|
|
|
|
|
816
|
0
|
|
|
|
|
|
my $parkinglots; |
817
|
|
|
|
|
|
|
|
818
|
0
|
|
|
|
|
|
foreach my $lot (@{$action->{'EVENTS'}}) { |
|
0
|
|
|
|
|
|
|
819
|
0
|
|
|
|
|
|
delete $lot->{'ActionID'}; |
820
|
0
|
|
|
|
|
|
delete $lot->{'Event'}; |
821
|
|
|
|
|
|
|
|
822
|
0
|
|
|
|
|
|
my $lotnum = $lot->{'Exten'}; |
823
|
|
|
|
|
|
|
|
824
|
0
|
|
|
|
|
|
delete $lot->{'Exten'}; |
825
|
|
|
|
|
|
|
|
826
|
0
|
|
|
|
|
|
$parkinglots->{$lotnum} = $lot; |
827
|
|
|
|
|
|
|
} |
828
|
|
|
|
|
|
|
|
829
|
0
|
|
|
|
|
|
return $parkinglots; |
830
|
|
|
|
|
|
|
} |
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
sub sip_peers { |
833
|
|
|
|
|
|
|
|
834
|
0
|
|
|
0
|
0
|
|
my ($self, $timeout) = @_; |
835
|
|
|
|
|
|
|
|
836
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'Sippeers' }, $timeout); |
837
|
|
|
|
|
|
|
|
838
|
0
|
0
|
|
|
|
|
return unless ($action->{'GOOD'}); |
839
|
|
|
|
|
|
|
|
840
|
0
|
|
|
|
|
|
my $peers; |
841
|
|
|
|
|
|
|
|
842
|
0
|
|
|
|
|
|
foreach my $peer (@{$action->{'EVENTS'}}) { |
|
0
|
|
|
|
|
|
|
843
|
0
|
|
|
|
|
|
delete $peer->{'ActionID'}; |
844
|
0
|
|
|
|
|
|
delete $peer->{'Event'}; |
845
|
|
|
|
|
|
|
|
846
|
0
|
|
|
|
|
|
my $peername = $peer->{'ObjectName'}; |
847
|
|
|
|
|
|
|
|
848
|
0
|
|
|
|
|
|
delete $peer->{'ObjectName'}; |
849
|
|
|
|
|
|
|
|
850
|
0
|
|
|
|
|
|
$peers->{$peername} = $peer; |
851
|
|
|
|
|
|
|
} |
852
|
|
|
|
|
|
|
|
853
|
0
|
|
|
|
|
|
return $peers; |
854
|
|
|
|
|
|
|
} |
855
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
sub sip_peer { |
857
|
|
|
|
|
|
|
|
858
|
0
|
|
|
0
|
0
|
|
my ($self, $peername, $timeout) = @_; |
859
|
|
|
|
|
|
|
|
860
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'SIPshowpeer', |
861
|
|
|
|
|
|
|
Peer => $peername }, $timeout); |
862
|
|
|
|
|
|
|
|
863
|
0
|
0
|
|
|
|
|
if ($action->{'GOOD'}) { |
864
|
0
|
|
|
|
|
|
return $action->{'PARSED'}; |
865
|
|
|
|
|
|
|
} |
866
|
|
|
|
|
|
|
|
867
|
0
|
|
|
|
|
|
return; |
868
|
|
|
|
|
|
|
} |
869
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
sub sip_notify { |
871
|
0
|
|
|
0
|
0
|
|
my ($self, $peer, $event, $timeout) = @_; |
872
|
|
|
|
|
|
|
|
873
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'SIPnotify', |
874
|
|
|
|
|
|
|
Channel => 'SIP/' . $peer, |
875
|
|
|
|
|
|
|
Variable => 'Event=' . $event }, $timeout); |
876
|
|
|
|
|
|
|
} |
877
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
sub mailboxcount { |
879
|
|
|
|
|
|
|
|
880
|
0
|
|
|
0
|
0
|
|
my ($self, $exten, $context, $timeout) = @_; |
881
|
|
|
|
|
|
|
|
882
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'MailboxCount', |
883
|
|
|
|
|
|
|
Mailbox => $exten . '@' . $context }, $timeout); |
884
|
|
|
|
|
|
|
|
885
|
0
|
0
|
|
|
|
|
if ($action->{'GOOD'}) { |
886
|
0
|
|
|
|
|
|
return $action->{'PARSED'}; |
887
|
|
|
|
|
|
|
} |
888
|
|
|
|
|
|
|
|
889
|
0
|
|
|
|
|
|
return; |
890
|
|
|
|
|
|
|
} |
891
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
sub mailboxstatus { |
893
|
|
|
|
|
|
|
|
894
|
0
|
|
|
0
|
0
|
|
my ($self, $exten, $context, $timeout) = @_; |
895
|
|
|
|
|
|
|
|
896
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'MailboxStatus', |
897
|
|
|
|
|
|
|
Mailbox => $exten . '@' . $context }, $timeout); |
898
|
|
|
|
|
|
|
|
899
|
|
|
|
|
|
|
|
900
|
0
|
0
|
|
|
|
|
if ($action->{'GOOD'}) { |
901
|
0
|
|
|
|
|
|
return $action->{'PARSED'}->{'Waiting'}; |
902
|
|
|
|
|
|
|
} |
903
|
|
|
|
|
|
|
|
904
|
0
|
|
|
|
|
|
return; |
905
|
|
|
|
|
|
|
} |
906
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
sub chan_timeout { |
908
|
|
|
|
|
|
|
|
909
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $chantimeout, $timeout) = @_; |
910
|
|
|
|
|
|
|
|
911
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'AbsoluteTimeout', |
912
|
|
|
|
|
|
|
Channel => $channel, |
913
|
|
|
|
|
|
|
Timeout => $chantimeout }, $timeout); |
914
|
|
|
|
|
|
|
} |
915
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
sub queues { |
917
|
|
|
|
|
|
|
|
918
|
0
|
|
|
0
|
0
|
|
my ($self, $timeout) = @_; |
919
|
|
|
|
|
|
|
|
920
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'QueueStatus' }, $timeout); |
921
|
|
|
|
|
|
|
|
922
|
0
|
0
|
|
|
|
|
return unless ($action->{'GOOD'}); |
923
|
|
|
|
|
|
|
|
924
|
0
|
|
|
|
|
|
my $queues; |
925
|
|
|
|
|
|
|
|
926
|
0
|
|
|
|
|
|
foreach my $event (@{$action->{'EVENTS'}}) { |
|
0
|
|
|
|
|
|
|
927
|
|
|
|
|
|
|
|
928
|
0
|
|
|
|
|
|
my $qevent = $event->{'Event'}; |
929
|
0
|
|
|
|
|
|
my $queue = $event->{'Queue'}; |
930
|
|
|
|
|
|
|
|
931
|
0
|
|
|
|
|
|
delete $event->{'Event'}; |
932
|
0
|
|
|
|
|
|
delete $event->{'ActionID'}; |
933
|
0
|
|
|
|
|
|
delete $event->{'Queue'}; |
934
|
|
|
|
|
|
|
|
935
|
0
|
0
|
|
|
|
|
if ($qevent eq 'QueueParams') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
936
|
0
|
|
|
|
|
|
while (my ($key, $value) = each %{$event}) { |
|
0
|
|
|
|
|
|
|
937
|
0
|
|
|
|
|
|
$queues->{$queue}->{$key} = $value; |
938
|
|
|
|
|
|
|
} |
939
|
|
|
|
|
|
|
} elsif ($qevent eq 'QueueMember') { |
940
|
|
|
|
|
|
|
|
941
|
0
|
|
|
|
|
|
my $name = $event->{'Name'}; |
942
|
|
|
|
|
|
|
|
943
|
0
|
|
|
|
|
|
delete $event->{'Name'}; |
944
|
|
|
|
|
|
|
|
945
|
0
|
|
|
|
|
|
$queues->{$queue}->{'MEMBERS'}->{$name} = $event; |
946
|
|
|
|
|
|
|
|
947
|
|
|
|
|
|
|
} elsif ($qevent eq 'QueueEntry') { |
948
|
|
|
|
|
|
|
|
949
|
0
|
|
|
|
|
|
my $pos = $event->{'Position'}; |
950
|
|
|
|
|
|
|
|
951
|
0
|
|
|
|
|
|
delete $event->{'Position'}; |
952
|
|
|
|
|
|
|
|
953
|
0
|
|
|
|
|
|
$queues->{$queue}->{'ENTRIES'}->{$pos} = $event; |
954
|
|
|
|
|
|
|
} |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
} |
957
|
|
|
|
|
|
|
|
958
|
0
|
|
|
|
|
|
return $queues; |
959
|
|
|
|
|
|
|
} |
960
|
|
|
|
|
|
|
|
961
|
|
|
|
|
|
|
sub queue_status { |
962
|
|
|
|
|
|
|
|
963
|
0
|
|
|
0
|
0
|
|
my ($self, $queue, $timeout) = @_; |
964
|
|
|
|
|
|
|
|
965
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'QueueStatus', |
966
|
|
|
|
|
|
|
Queue => $queue }, $timeout); |
967
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
|
969
|
0
|
0
|
|
|
|
|
return unless ($action->{'GOOD'}); |
970
|
|
|
|
|
|
|
|
971
|
0
|
|
|
|
|
|
my $queueobj; |
972
|
|
|
|
|
|
|
|
973
|
0
|
|
|
|
|
|
foreach my $event (@{$action->{'EVENTS'}}) { |
|
0
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
|
975
|
0
|
|
|
|
|
|
my $qevent = $event->{'Event'}; |
976
|
|
|
|
|
|
|
|
977
|
0
|
|
|
|
|
|
delete $event->{'Event'}; |
978
|
0
|
|
|
|
|
|
delete $event->{'ActionID'}; |
979
|
|
|
|
|
|
|
|
980
|
0
|
0
|
|
|
|
|
if ($qevent eq 'QueueParams') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
981
|
0
|
|
|
|
|
|
while (my ($key, $value) = each %{$event}) { |
|
0
|
|
|
|
|
|
|
982
|
0
|
|
|
|
|
|
$queueobj->{$key} = $value; |
983
|
|
|
|
|
|
|
} |
984
|
|
|
|
|
|
|
} elsif ($qevent eq 'QueueMember') { |
985
|
|
|
|
|
|
|
|
986
|
0
|
|
|
|
|
|
my $name = $event->{'Name'}; |
987
|
|
|
|
|
|
|
|
988
|
0
|
|
|
|
|
|
delete $event->{'Name'}; |
989
|
0
|
|
|
|
|
|
delete $event->{'Queue'}; |
990
|
|
|
|
|
|
|
|
991
|
0
|
|
|
|
|
|
$queueobj->{'MEMBERS'}->{$name} = $event; |
992
|
|
|
|
|
|
|
|
993
|
|
|
|
|
|
|
} elsif ($qevent eq 'QueueEntry') { |
994
|
|
|
|
|
|
|
|
995
|
0
|
|
|
|
|
|
my $pos = $event->{'Position'}; |
996
|
|
|
|
|
|
|
|
997
|
0
|
|
|
|
|
|
delete $event->{'Queue'}; |
998
|
0
|
|
|
|
|
|
delete $event->{'Position'}; |
999
|
|
|
|
|
|
|
|
1000
|
0
|
|
|
|
|
|
$queueobj->{'ENTRIES'}->{$pos} = $event; |
1001
|
|
|
|
|
|
|
} |
1002
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
} |
1004
|
|
|
|
|
|
|
|
1005
|
0
|
|
|
|
|
|
return $queueobj; |
1006
|
|
|
|
|
|
|
} |
1007
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
sub queue_member_pause { |
1009
|
|
|
|
|
|
|
|
1010
|
0
|
|
|
0
|
0
|
|
my ($self, $queue, $member, $paused, $timeout) = @_; |
1011
|
|
|
|
|
|
|
|
1012
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'QueuePause', |
1013
|
|
|
|
|
|
|
Queue => $queue, |
1014
|
|
|
|
|
|
|
Interface => $member, |
1015
|
|
|
|
|
|
|
Paused => $paused }, $timeout); |
1016
|
|
|
|
|
|
|
} |
1017
|
|
|
|
|
|
|
|
1018
|
|
|
|
|
|
|
sub queue_member_toggle { |
1019
|
|
|
|
|
|
|
|
1020
|
0
|
|
|
0
|
0
|
|
my ($self, $queue, $member, $timeout) = @_; |
1021
|
|
|
|
|
|
|
|
1022
|
0
|
|
|
|
|
|
my $queueobj = $self->queue_status($queue, $timeout); |
1023
|
|
|
|
|
|
|
|
1024
|
0
|
0
|
|
|
|
|
return unless ($queueobj); |
1025
|
|
|
|
|
|
|
|
1026
|
0
|
|
|
|
|
|
my $paused; |
1027
|
|
|
|
|
|
|
|
1028
|
0
|
0
|
|
|
|
|
if ($queueobj->{'MEMBERS'}->{$member}->{'Paused'} == 0) { |
|
|
0
|
|
|
|
|
|
1029
|
0
|
|
|
|
|
|
$paused = 1; |
1030
|
|
|
|
|
|
|
} elsif ($queueobj->{'MEMBERS'}->{$member}->{'Paused'}) { |
1031
|
0
|
|
|
|
|
|
$paused = 0; |
1032
|
|
|
|
|
|
|
} |
1033
|
|
|
|
|
|
|
|
1034
|
0
|
0
|
|
|
|
|
if (defined $paused) { $self->queue_pause($queue, $member, $paused, $timeout) or undef $paused }; |
|
0
|
0
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
|
1036
|
0
|
|
|
|
|
|
return $paused; |
1037
|
|
|
|
|
|
|
} |
1038
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
sub queue_add { |
1040
|
|
|
|
|
|
|
|
1041
|
0
|
|
|
0
|
0
|
|
my ($self, $queue, $member, $timeout) = @_; |
1042
|
|
|
|
|
|
|
|
1043
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'QueueAdd', |
1044
|
|
|
|
|
|
|
Queue => $queue, |
1045
|
|
|
|
|
|
|
Interface => $member }, $timeout); |
1046
|
|
|
|
|
|
|
} |
1047
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
sub queue_remove { |
1049
|
|
|
|
|
|
|
|
1050
|
0
|
|
|
0
|
0
|
|
my ($self, $queue, $member, $timeout) = @_; |
1051
|
|
|
|
|
|
|
|
1052
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'QueueRemove', |
1053
|
|
|
|
|
|
|
Queue => $queue, |
1054
|
|
|
|
|
|
|
Interface => $member }, $timeout); |
1055
|
|
|
|
|
|
|
} |
1056
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
sub play_dtmf { |
1058
|
|
|
|
|
|
|
|
1059
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $digit, $timeout) = @_; |
1060
|
|
|
|
|
|
|
|
1061
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'PlayDTMF', |
1062
|
|
|
|
|
|
|
Channel => $channel, |
1063
|
|
|
|
|
|
|
Digit => $digit }, $timeout); |
1064
|
|
|
|
|
|
|
} |
1065
|
|
|
|
|
|
|
|
1066
|
|
|
|
|
|
|
sub play_digits { |
1067
|
|
|
|
|
|
|
|
1068
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $digits, $timeout) = @_; |
1069
|
|
|
|
|
|
|
|
1070
|
0
|
|
|
|
|
|
my $return = 1; |
1071
|
0
|
|
|
|
|
|
my $err = 0; |
1072
|
|
|
|
|
|
|
|
1073
|
0
|
|
|
|
|
|
my @actions = map { $self->send_action({ Action => 'PlayDTMF', |
|
0
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
Channel => $channel, |
1075
|
0
|
|
|
|
|
|
Digit => $_}) } @{$digits}; |
1076
|
|
|
|
|
|
|
|
1077
|
0
|
|
|
|
|
|
foreach my $action (@actions) { |
1078
|
0
|
|
|
|
|
|
my $resp = $self->check_response($action,$timeout); |
1079
|
|
|
|
|
|
|
|
1080
|
0
|
0
|
|
|
|
|
next if ($err); |
1081
|
|
|
|
|
|
|
|
1082
|
0
|
0
|
|
|
|
|
unless (defined $resp) { |
1083
|
0
|
|
|
|
|
|
$err = 1; |
1084
|
0
|
|
|
|
|
|
next; |
1085
|
|
|
|
|
|
|
} |
1086
|
|
|
|
|
|
|
|
1087
|
0
|
0
|
|
|
|
|
$return = 0 unless ($resp); |
1088
|
|
|
|
|
|
|
} |
1089
|
|
|
|
|
|
|
|
1090
|
0
|
0
|
|
|
|
|
if ($err) { return }; |
|
0
|
|
|
|
|
|
|
1091
|
|
|
|
|
|
|
|
1092
|
0
|
|
|
|
|
|
return $return; |
1093
|
|
|
|
|
|
|
} |
1094
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
sub channels { |
1096
|
|
|
|
|
|
|
|
1097
|
0
|
|
|
0
|
0
|
|
my ($self, $timeout) = @_; |
1098
|
|
|
|
|
|
|
|
1099
|
0
|
|
|
|
|
|
my $action = $self->action({Action => 'Status'},$timeout); |
1100
|
|
|
|
|
|
|
|
1101
|
0
|
0
|
|
|
|
|
return unless ($action->{'GOOD'}); |
1102
|
|
|
|
|
|
|
|
1103
|
0
|
|
|
|
|
|
my $channels; |
1104
|
|
|
|
|
|
|
|
1105
|
0
|
|
|
|
|
|
foreach my $chan (@{$action->{'EVENTS'}}) { |
|
0
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
#Clean out junk |
1107
|
0
|
|
|
|
|
|
delete $chan->{'Event'}; |
1108
|
0
|
|
|
|
|
|
delete $chan->{'Privilege'}; |
1109
|
0
|
|
|
|
|
|
delete $chan->{'ActionID'}; |
1110
|
|
|
|
|
|
|
|
1111
|
0
|
|
|
|
|
|
my $name = $chan->{'Channel'}; |
1112
|
|
|
|
|
|
|
|
1113
|
0
|
|
|
|
|
|
delete $chan->{'Channel'}; |
1114
|
|
|
|
|
|
|
|
1115
|
0
|
|
|
|
|
|
$channels->{$name} = $chan; |
1116
|
|
|
|
|
|
|
} |
1117
|
|
|
|
|
|
|
|
1118
|
0
|
|
|
|
|
|
return $channels; |
1119
|
|
|
|
|
|
|
} |
1120
|
|
|
|
|
|
|
|
1121
|
|
|
|
|
|
|
sub chan_status { |
1122
|
|
|
|
|
|
|
|
1123
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $timeout) = @_; |
1124
|
|
|
|
|
|
|
|
1125
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'Status', |
1126
|
|
|
|
|
|
|
Channel => $channel}, $timeout); |
1127
|
|
|
|
|
|
|
|
1128
|
0
|
0
|
|
|
|
|
return unless ($action->{'GOOD'}); |
1129
|
|
|
|
|
|
|
|
1130
|
0
|
|
|
|
|
|
my $status; |
1131
|
|
|
|
|
|
|
|
1132
|
0
|
|
|
|
|
|
$status = $action->{'EVENTS'}->[0]; |
1133
|
|
|
|
|
|
|
|
1134
|
0
|
|
|
|
|
|
delete $status->{'ActionID'}; |
1135
|
0
|
|
|
|
|
|
delete $status->{'Event'}; |
1136
|
0
|
|
|
|
|
|
delete $status->{'Privilege'}; |
1137
|
|
|
|
|
|
|
|
1138
|
0
|
|
|
|
|
|
return $status; |
1139
|
|
|
|
|
|
|
} |
1140
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
sub transfer { |
1142
|
|
|
|
|
|
|
|
1143
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $exten, $context, $timeout) = @_; |
1144
|
|
|
|
|
|
|
|
1145
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'Redirect', |
1146
|
|
|
|
|
|
|
Channel => $channel, |
1147
|
|
|
|
|
|
|
Exten => $exten, |
1148
|
|
|
|
|
|
|
Context => $context, |
1149
|
|
|
|
|
|
|
Priority => 1 }, $timeout); |
1150
|
|
|
|
|
|
|
|
1151
|
|
|
|
|
|
|
} |
1152
|
|
|
|
|
|
|
|
1153
|
|
|
|
|
|
|
sub meetme_list { |
1154
|
0
|
|
|
0
|
0
|
|
my ($self, $timeout) = @_; |
1155
|
|
|
|
|
|
|
|
1156
|
0
|
|
|
|
|
|
my $meetmes; |
1157
|
|
|
|
|
|
|
|
1158
|
0
|
|
|
|
|
|
my $amiver = $self->amiver(); |
1159
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
#1.8+ |
1161
|
0
|
0
|
0
|
|
|
|
if (defined($amiver) && $amiver >= 1.1) { |
1162
|
0
|
|
|
|
|
|
my $action = $self->action({Action => 'MeetmeList'}, $timeout); |
1163
|
|
|
|
|
|
|
|
1164
|
0
|
0
|
|
|
|
|
return unless ($action->{'GOOD'}); |
1165
|
|
|
|
|
|
|
|
1166
|
0
|
|
|
|
|
|
foreach my $member (@{$action->{'EVENTS'}}) { |
|
0
|
|
|
|
|
|
|
1167
|
0
|
|
|
|
|
|
my $conf = $member->{'Conference'}; |
1168
|
0
|
|
|
|
|
|
my $chan = $member->{'Channel'}; |
1169
|
0
|
|
|
|
|
|
delete $member->{'Conference'}; |
1170
|
0
|
|
|
|
|
|
delete $member->{'ActionID'}; |
1171
|
0
|
|
|
|
|
|
delete $member->{'Channel'}; |
1172
|
0
|
|
|
|
|
|
delete $member->{'Event'}; |
1173
|
0
|
|
|
|
|
|
$meetmes->{$conf}->{$chan} = $member; |
1174
|
|
|
|
|
|
|
} |
1175
|
|
|
|
|
|
|
#Compat mode for 1.4 |
1176
|
|
|
|
|
|
|
} else { |
1177
|
|
|
|
|
|
|
#List of all conferences |
1178
|
0
|
|
|
|
|
|
my $list = $self->action({ Action => 'Command', Command => 'meetme' }, $timeout); |
1179
|
|
|
|
|
|
|
|
1180
|
0
|
0
|
|
|
|
|
return unless ($list->{'GOOD'}); |
1181
|
|
|
|
|
|
|
|
1182
|
0
|
|
|
|
|
|
my @cmd = @{$list->{'CMD'}}; |
|
0
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
#Get rid of header and footer of cli |
1185
|
0
|
|
|
|
|
|
shift @cmd; |
1186
|
0
|
|
|
|
|
|
pop @cmd; |
1187
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
#Get members for each list |
1189
|
0
|
|
|
|
|
|
foreach my $conf (@cmd) { |
1190
|
0
|
|
|
|
|
|
my @confline = split/\s{2,}/x, $conf; |
1191
|
0
|
|
|
|
|
|
my $meetme = $self->meetme_members($confline[0], $timeout); |
1192
|
|
|
|
|
|
|
|
1193
|
0
|
0
|
|
|
|
|
return unless (defined $meetme); |
1194
|
|
|
|
|
|
|
|
1195
|
0
|
|
|
|
|
|
$meetmes->{$confline[0]} = $meetme; |
1196
|
|
|
|
|
|
|
} |
1197
|
|
|
|
|
|
|
} |
1198
|
|
|
|
|
|
|
|
1199
|
0
|
|
|
|
|
|
return $meetmes; |
1200
|
|
|
|
|
|
|
} |
1201
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
sub meetme_members { |
1203
|
0
|
|
|
0
|
0
|
|
my ($self, $conf, $timeout) = @_; |
1204
|
|
|
|
|
|
|
|
1205
|
0
|
|
|
|
|
|
my $meetme; |
1206
|
|
|
|
|
|
|
|
1207
|
0
|
|
|
|
|
|
my $amiver = $self->amiver(); |
1208
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
#1.8+ |
1210
|
0
|
0
|
0
|
|
|
|
if (defined($amiver) && $amiver >= 1.1) { |
1211
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'MeetmeList', |
1212
|
|
|
|
|
|
|
Conference => $conf }, $timeout); |
1213
|
|
|
|
|
|
|
|
1214
|
0
|
0
|
|
|
|
|
return unless ($action->{'GOOD'}); |
1215
|
|
|
|
|
|
|
|
1216
|
0
|
|
|
|
|
|
foreach my $member (@{$action->{'EVENTS'}}) { |
|
0
|
|
|
|
|
|
|
1217
|
0
|
|
|
|
|
|
my $chan = $member->{'Channel'}; |
1218
|
0
|
|
|
|
|
|
delete $member->{'Conference'}; |
1219
|
0
|
|
|
|
|
|
delete $member->{'ActionID'}; |
1220
|
0
|
|
|
|
|
|
delete $member->{'Channel'}; |
1221
|
0
|
|
|
|
|
|
delete $member->{'Event'}; |
1222
|
0
|
|
|
|
|
|
$meetme->{$chan} = $member; |
1223
|
|
|
|
|
|
|
} |
1224
|
|
|
|
|
|
|
#1.4 Compat |
1225
|
|
|
|
|
|
|
} else { |
1226
|
|
|
|
|
|
|
|
1227
|
0
|
|
|
|
|
|
my $members = $self->action({ Action => 'Command', |
1228
|
|
|
|
|
|
|
Command => 'meetme list ' . $conf . ' concise' }); |
1229
|
|
|
|
|
|
|
|
1230
|
0
|
0
|
|
|
|
|
return unless ($members->{'GOOD'}); |
1231
|
|
|
|
|
|
|
|
1232
|
0
|
|
|
|
|
|
foreach my $line (@{$members->{'CMD'}}) { |
|
0
|
|
|
|
|
|
|
1233
|
0
|
|
|
|
|
|
my @split = split /\!/x, $line; |
1234
|
|
|
|
|
|
|
|
1235
|
0
|
|
|
|
|
|
my $member; |
1236
|
|
|
|
|
|
|
#0 - User num |
1237
|
|
|
|
|
|
|
#1 - CID Name |
1238
|
|
|
|
|
|
|
#2 - CID Num |
1239
|
|
|
|
|
|
|
#3 - Chan |
1240
|
|
|
|
|
|
|
#4 - Admin |
1241
|
|
|
|
|
|
|
#5 - Monitor? |
1242
|
|
|
|
|
|
|
#6 - Muted |
1243
|
|
|
|
|
|
|
#7 - Talking |
1244
|
|
|
|
|
|
|
#8 - Time |
1245
|
0
|
|
|
|
|
|
$member->{'UserNumber'} = $split[0]; |
1246
|
|
|
|
|
|
|
|
1247
|
0
|
|
|
|
|
|
$member->{'CallerIDName'} = $split[1]; |
1248
|
|
|
|
|
|
|
|
1249
|
0
|
|
|
|
|
|
$member->{'CallerIDNum'} = $split[2]; |
1250
|
|
|
|
|
|
|
|
1251
|
0
|
0
|
|
|
|
|
$member->{'Admin'} = $split[4] ? "Yes" : "No"; |
1252
|
|
|
|
|
|
|
|
1253
|
0
|
0
|
|
|
|
|
$member->{'Muted'} = $split[6] ? "Yes" : "No"; |
1254
|
|
|
|
|
|
|
|
1255
|
0
|
0
|
|
|
|
|
$member->{'Talking'} = $split[7] ? "Yes" : "No"; |
1256
|
|
|
|
|
|
|
|
1257
|
0
|
|
|
|
|
|
$meetme->{$split[3]} = $member; |
1258
|
|
|
|
|
|
|
} |
1259
|
|
|
|
|
|
|
} |
1260
|
|
|
|
|
|
|
|
1261
|
0
|
|
|
|
|
|
return $meetme; |
1262
|
|
|
|
|
|
|
} |
1263
|
|
|
|
|
|
|
|
1264
|
|
|
|
|
|
|
sub meetme_mute { |
1265
|
0
|
|
|
0
|
0
|
|
my ($self, $conf, $user, $timeout) = @_; |
1266
|
|
|
|
|
|
|
|
1267
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'MeetmeMute', |
1268
|
|
|
|
|
|
|
Meetme => $conf, |
1269
|
|
|
|
|
|
|
Usernum => $user }, $timeout); |
1270
|
|
|
|
|
|
|
} |
1271
|
|
|
|
|
|
|
|
1272
|
|
|
|
|
|
|
sub meetme_unmute { |
1273
|
0
|
|
|
0
|
0
|
|
my ($self, $conf, $user, $timeout) = @_; |
1274
|
|
|
|
|
|
|
|
1275
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'MeetmeUnmute', |
1276
|
|
|
|
|
|
|
Meetme => $conf, |
1277
|
|
|
|
|
|
|
Usernum => $user }, $timeout); |
1278
|
|
|
|
|
|
|
} |
1279
|
|
|
|
|
|
|
|
1280
|
|
|
|
|
|
|
sub mute_chan { |
1281
|
0
|
|
|
0
|
0
|
|
my ($self, $chan, $dir, $timeout) = @_; |
1282
|
|
|
|
|
|
|
|
1283
|
0
|
0
|
|
|
|
|
$dir = 'all' if (!defined $dir); |
1284
|
|
|
|
|
|
|
|
1285
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'MuteAudio', |
1286
|
|
|
|
|
|
|
Channel => $chan, |
1287
|
|
|
|
|
|
|
Direction => $dir, |
1288
|
|
|
|
|
|
|
State => 'on' }, $timeout); |
1289
|
|
|
|
|
|
|
} |
1290
|
|
|
|
|
|
|
|
1291
|
|
|
|
|
|
|
sub unmute_chan { |
1292
|
0
|
|
|
0
|
0
|
|
my ($self, $chan, $dir, $timeout) = @_; |
1293
|
|
|
|
|
|
|
|
1294
|
0
|
0
|
|
|
|
|
$dir = 'all' if (!defined $dir); |
1295
|
|
|
|
|
|
|
|
1296
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'MuteAudio', |
1297
|
|
|
|
|
|
|
Channel => $chan, |
1298
|
|
|
|
|
|
|
Direction => $dir, |
1299
|
|
|
|
|
|
|
State => 'off' }, $timeout); |
1300
|
|
|
|
|
|
|
} |
1301
|
|
|
|
|
|
|
|
1302
|
|
|
|
|
|
|
sub monitor { |
1303
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $file, $timeout) = @_; |
1304
|
|
|
|
|
|
|
|
1305
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'Monitor', |
1306
|
|
|
|
|
|
|
Channel => $channel, |
1307
|
|
|
|
|
|
|
File => $file, |
1308
|
|
|
|
|
|
|
Format => 'wav', |
1309
|
|
|
|
|
|
|
Mix => '1' }, $timeout); |
1310
|
|
|
|
|
|
|
} |
1311
|
|
|
|
|
|
|
|
1312
|
|
|
|
|
|
|
sub monitor_stop { |
1313
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $timeout) = @_; |
1314
|
|
|
|
|
|
|
|
1315
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'StopMonitor', |
1316
|
|
|
|
|
|
|
Channel => $channel }, $timeout); |
1317
|
|
|
|
|
|
|
} |
1318
|
|
|
|
|
|
|
|
1319
|
|
|
|
|
|
|
sub monitor_pause { |
1320
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $timeout) = @_; |
1321
|
|
|
|
|
|
|
|
1322
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'PauseMonitor', |
1323
|
|
|
|
|
|
|
Channel => $channel }, $timeout); |
1324
|
|
|
|
|
|
|
} |
1325
|
|
|
|
|
|
|
|
1326
|
|
|
|
|
|
|
sub monitor_unpause { |
1327
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $timeout) = @_; |
1328
|
|
|
|
|
|
|
|
1329
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'UnpauseMonitor', |
1330
|
|
|
|
|
|
|
Channel => $channel }, $timeout); |
1331
|
|
|
|
|
|
|
} |
1332
|
|
|
|
|
|
|
|
1333
|
|
|
|
|
|
|
sub monitor_change { |
1334
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $file, $timeout) = @_; |
1335
|
|
|
|
|
|
|
|
1336
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'ChangeMonitor', |
1337
|
|
|
|
|
|
|
Channel => $channel, |
1338
|
|
|
|
|
|
|
File => $file }, $timeout); |
1339
|
|
|
|
|
|
|
} |
1340
|
|
|
|
|
|
|
|
1341
|
|
|
|
|
|
|
sub mixmonitor_mute { |
1342
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $dir, $timeout) = @_; |
1343
|
|
|
|
|
|
|
|
1344
|
0
|
0
|
|
|
|
|
$dir = 'both' unless (defined $dir); |
1345
|
|
|
|
|
|
|
|
1346
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'MixMonitorMute', |
1347
|
|
|
|
|
|
|
Direction => $dir, |
1348
|
|
|
|
|
|
|
Channel => $channel, |
1349
|
|
|
|
|
|
|
State => 1 }, $timeout); |
1350
|
|
|
|
|
|
|
} |
1351
|
|
|
|
|
|
|
|
1352
|
|
|
|
|
|
|
sub mixmonitor_unmute { |
1353
|
0
|
|
|
0
|
0
|
|
my ($self, $channel, $dir, $timeout) = @_; |
1354
|
|
|
|
|
|
|
|
1355
|
0
|
0
|
|
|
|
|
$dir = 'both' unless (defined $dir); |
1356
|
|
|
|
|
|
|
|
1357
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'MixMonitorMute', |
1358
|
|
|
|
|
|
|
Direction => $dir, |
1359
|
|
|
|
|
|
|
Channel => $channel, |
1360
|
|
|
|
|
|
|
State => 0 }, $timeout); |
1361
|
|
|
|
|
|
|
} |
1362
|
|
|
|
|
|
|
|
1363
|
|
|
|
|
|
|
sub text { |
1364
|
0
|
|
|
0
|
0
|
|
my ($self, $chan, $message, $timeout) = @_; |
1365
|
|
|
|
|
|
|
|
1366
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'SendText', |
1367
|
|
|
|
|
|
|
Channel => $chan, |
1368
|
|
|
|
|
|
|
Message => $message }, $timeout); |
1369
|
|
|
|
|
|
|
} |
1370
|
|
|
|
|
|
|
|
1371
|
|
|
|
|
|
|
sub voicemail_list { |
1372
|
0
|
|
|
0
|
0
|
|
my ($self, $timeout) = @_; |
1373
|
|
|
|
|
|
|
|
1374
|
0
|
|
|
|
|
|
my $action = $self->action({ Action => 'VoicemailUsersList' }, $timeout); |
1375
|
|
|
|
|
|
|
|
1376
|
0
|
0
|
|
|
|
|
return unless ($action->{'GOOD'}); |
1377
|
|
|
|
|
|
|
|
1378
|
0
|
|
|
|
|
|
my $vmusers; |
1379
|
|
|
|
|
|
|
|
1380
|
0
|
|
|
|
|
|
foreach my $box (@{$action->{'EVENTS'}}) { |
|
0
|
|
|
|
|
|
|
1381
|
0
|
|
|
|
|
|
my $context = $box->{'VMContext'}; |
1382
|
0
|
|
|
|
|
|
my $user = $box->{'VoiceMailbox'}; |
1383
|
|
|
|
|
|
|
|
1384
|
0
|
|
|
|
|
|
delete $box->{'VMContext'}; |
1385
|
0
|
|
|
|
|
|
delete $box->{'VoiceMailbox'}; |
1386
|
0
|
|
|
|
|
|
delete $box->{'ActionID'}; |
1387
|
0
|
|
|
|
|
|
delete $box->{'Event'}; |
1388
|
0
|
|
|
|
|
|
$vmusers->{$context}->{$user} = $box; |
1389
|
|
|
|
|
|
|
} |
1390
|
|
|
|
|
|
|
|
1391
|
|
|
|
|
|
|
|
1392
|
0
|
|
|
|
|
|
return $vmusers; |
1393
|
|
|
|
|
|
|
} |
1394
|
|
|
|
|
|
|
|
1395
|
|
|
|
|
|
|
sub module_check { |
1396
|
0
|
|
|
0
|
0
|
|
my ($self, $module, $timeout) = @_; |
1397
|
|
|
|
|
|
|
|
1398
|
0
|
|
|
|
|
|
my $ver = $self->amiver(); |
1399
|
|
|
|
|
|
|
|
1400
|
0
|
0
|
0
|
|
|
|
if (defined $ver && $ver >= 1.1) { |
1401
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'ModuleCheck', |
1402
|
|
|
|
|
|
|
Module => $module }, $timeout); |
1403
|
|
|
|
|
|
|
} else { |
1404
|
0
|
|
|
|
|
|
my $resp = $self->action({ Action => 'Command', |
1405
|
|
|
|
|
|
|
Command => 'module show like ' . $module }, $timeout); |
1406
|
|
|
|
|
|
|
|
1407
|
0
|
0
|
0
|
|
|
|
return unless (defined $resp && $resp->{'GOOD'}); |
1408
|
|
|
|
|
|
|
|
1409
|
0
|
0
|
|
|
|
|
if ($resp->{'CMD'}->[-1] =~ /(\d+)\ .*/x) { |
1410
|
|
|
|
|
|
|
|
1411
|
0
|
0
|
|
|
|
|
return 0 if ($1 == 0); |
1412
|
|
|
|
|
|
|
|
1413
|
0
|
|
|
|
|
|
return 1; |
1414
|
|
|
|
|
|
|
} |
1415
|
|
|
|
|
|
|
|
1416
|
0
|
|
|
|
|
|
return; |
1417
|
|
|
|
|
|
|
} |
1418
|
|
|
|
|
|
|
} |
1419
|
|
|
|
|
|
|
|
1420
|
|
|
|
|
|
|
sub module_load { |
1421
|
0
|
|
|
0
|
0
|
|
my ($self, $module, $timeout) = @_; |
1422
|
|
|
|
|
|
|
|
1423
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'ModuleLoad', |
1424
|
|
|
|
|
|
|
LoadType => 'load', |
1425
|
|
|
|
|
|
|
Module => $module }, $timeout ); |
1426
|
|
|
|
|
|
|
} |
1427
|
|
|
|
|
|
|
|
1428
|
|
|
|
|
|
|
sub module_reload { |
1429
|
0
|
|
|
0
|
0
|
|
my ($self, $module, $timeout) = @_; |
1430
|
|
|
|
|
|
|
|
1431
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'ModuleLoad', |
1432
|
|
|
|
|
|
|
LoadType => 'reload', |
1433
|
|
|
|
|
|
|
Module => $module }, $timeout ); |
1434
|
|
|
|
|
|
|
} |
1435
|
|
|
|
|
|
|
|
1436
|
|
|
|
|
|
|
sub module_unload { |
1437
|
0
|
|
|
0
|
0
|
|
my ($self, $module, $timeout) = @_; |
1438
|
|
|
|
|
|
|
|
1439
|
0
|
|
|
|
|
|
return $self->simple_action({ Action => 'ModuleLoad', |
1440
|
|
|
|
|
|
|
LoadType => 'unload', |
1441
|
|
|
|
|
|
|
Module => $module }, $timeout ); |
1442
|
|
|
|
|
|
|
} |
1443
|
|
|
|
|
|
|
|
1444
|
|
|
|
|
|
|
sub originate { |
1445
|
0
|
|
|
0
|
0
|
|
my ($self, $chan, $context, $exten, $callerid, $ctime, $timeout) = @_; |
1446
|
|
|
|
|
|
|
|
1447
|
0
|
|
|
|
|
|
my %action = ( Action => 'Originate', |
1448
|
|
|
|
|
|
|
Channel => $chan, |
1449
|
|
|
|
|
|
|
Context => $context, |
1450
|
|
|
|
|
|
|
Exten => $exten, |
1451
|
|
|
|
|
|
|
Priority => 1, |
1452
|
|
|
|
|
|
|
); |
1453
|
|
|
|
|
|
|
|
1454
|
0
|
0
|
|
|
|
|
$action{'CallerID'} = $callerid if (defined $callerid); |
1455
|
|
|
|
|
|
|
|
1456
|
0
|
0
|
|
|
|
|
if (defined $ctime) { |
1457
|
0
|
|
|
|
|
|
$action{'Timeout'} = $ctime * 1000; |
1458
|
|
|
|
|
|
|
|
1459
|
0
|
0
|
|
|
|
|
if ($timeout) { |
1460
|
0
|
|
|
|
|
|
$timeout = $ctime + $timeout; |
1461
|
|
|
|
|
|
|
} |
1462
|
|
|
|
|
|
|
} |
1463
|
|
|
|
|
|
|
|
1464
|
0
|
|
|
|
|
|
return $self->simple_action(\%action, $timeout); |
1465
|
|
|
|
|
|
|
} |
1466
|
|
|
|
|
|
|
|
1467
|
|
|
|
|
|
|
sub originate_async { |
1468
|
0
|
|
|
0
|
0
|
|
my ($self, $chan, $context, $exten, $callerid, $ctime, $timeout) = @_; |
1469
|
|
|
|
|
|
|
|
1470
|
0
|
|
|
|
|
|
my %action = ( Action => 'Originate', |
1471
|
|
|
|
|
|
|
Channel => $chan, |
1472
|
|
|
|
|
|
|
Context => $context, |
1473
|
|
|
|
|
|
|
Exten => $exten, |
1474
|
|
|
|
|
|
|
Priority => 1, |
1475
|
|
|
|
|
|
|
Async => 1 |
1476
|
|
|
|
|
|
|
); |
1477
|
|
|
|
|
|
|
|
1478
|
0
|
0
|
|
|
|
|
$action{'CallerID'} = $callerid if (defined $callerid); |
1479
|
0
|
0
|
|
|
|
|
$action{'Timeout'} = $ctime * 1000 if (defined $ctime); |
1480
|
|
|
|
|
|
|
|
1481
|
0
|
|
|
|
|
|
my $actionid = $self->send_action(\%action); |
1482
|
|
|
|
|
|
|
|
1483
|
|
|
|
|
|
|
#Bypass async wait, bit hacky |
1484
|
|
|
|
|
|
|
#allows us to get the intial response |
1485
|
0
|
|
|
|
|
|
delete $self->{RESPONSEBUFFER}->{$actionid}->{'ASYNC'}; |
1486
|
|
|
|
|
|
|
|
1487
|
0
|
|
|
|
|
|
return $self->check_response($actionid, $timeout); |
1488
|
|
|
|
|
|
|
} |
1489
|
|
|
|
|
|
|
|
1490
|
|
|
|
|
|
|
1; |