ruby-agi 0.0.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +1 -1
- data/Release-Notes +2 -0
- data/extconf.rb +2 -0
- data/lib/ruby-agi/agi.rb +847 -0
- data/lib/{asterisk_variable.rb → ruby-agi/asterisk_variable.rb} +49 -34
- data/lib/ruby-agi/command.rb +897 -0
- data/lib/ruby-agi.rb +5 -0
- metadata +12 -32
- data/examples/call_log.rb +0 -0
- data/lib/agi.rb +0 -310
- data/lib/command.rb +0 -486
- data.tar.gz.sig +0 -1
- metadata.gz.sig +0 -0
- /data/lib/{error.rb → ruby-agi/error.rb} +0 -0
- /data/lib/{return_status.rb → ruby-agi/return_status.rb} +0 -0
data/lib/ruby-agi/agi.rb
ADDED
@@ -0,0 +1,847 @@
|
|
1
|
+
#
|
2
|
+
# File: agi.rb
|
3
|
+
#
|
4
|
+
# ruby-agi: Ruby Language API for Asterisk
|
5
|
+
#
|
6
|
+
# Copyright (C) <2005> Mohammad Khan <info@beeplove.com>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#
|
22
|
+
|
23
|
+
|
24
|
+
require 'sync'
|
25
|
+
|
26
|
+
require 'ruby-agi/error.rb'
|
27
|
+
require 'ruby-agi/command.rb'
|
28
|
+
require 'ruby-agi/asterisk_variable.rb'
|
29
|
+
require 'ruby-agi/return_status.rb'
|
30
|
+
|
31
|
+
|
32
|
+
class AGI
|
33
|
+
|
34
|
+
#
|
35
|
+
# constructor method of class AGI
|
36
|
+
#
|
37
|
+
# <b>Parameters</b>
|
38
|
+
# - none
|
39
|
+
#
|
40
|
+
# <b>Returns</b>
|
41
|
+
# - self
|
42
|
+
#
|
43
|
+
def initialize
|
44
|
+
@@env = nil
|
45
|
+
@@command = nil
|
46
|
+
|
47
|
+
@@debug = nil
|
48
|
+
@@stdin_semaphore = nil
|
49
|
+
@@stdout_semaphore = nil
|
50
|
+
@@stderr_semaphore = nil
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# method to get Command object instance
|
55
|
+
#
|
56
|
+
# <b>Parameters</b>
|
57
|
+
# - none
|
58
|
+
# <b>Returns</b>
|
59
|
+
# - Command object
|
60
|
+
#
|
61
|
+
private
|
62
|
+
def command
|
63
|
+
if @@command.nil?
|
64
|
+
@@command = Command.new
|
65
|
+
end
|
66
|
+
return @@command
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# <method description>
|
71
|
+
#
|
72
|
+
# <b>Parameters</b>
|
73
|
+
# - none
|
74
|
+
# <b>Returns</b>
|
75
|
+
# - AsteriskVariable object
|
76
|
+
#
|
77
|
+
private
|
78
|
+
def env
|
79
|
+
if @@env.nil?
|
80
|
+
@@env = AsteriskVariable.new
|
81
|
+
end
|
82
|
+
|
83
|
+
return @@env
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# <method description>
|
88
|
+
#
|
89
|
+
# <b>Parameters</b>
|
90
|
+
# - none
|
91
|
+
# <b>Returns</b>
|
92
|
+
# - Sync object
|
93
|
+
#
|
94
|
+
private
|
95
|
+
def stdin_semaphore
|
96
|
+
if @@stdin_semaphore.nil?
|
97
|
+
@@stdin_semaphore = Sync.new
|
98
|
+
end
|
99
|
+
$stdin.sync = true
|
100
|
+
|
101
|
+
return @@stdin_semaphore
|
102
|
+
end
|
103
|
+
|
104
|
+
#
|
105
|
+
# <method description>
|
106
|
+
#
|
107
|
+
# <b>Parameters</b>
|
108
|
+
# - none
|
109
|
+
# <b>Returns</b>
|
110
|
+
# - Sync object
|
111
|
+
#
|
112
|
+
private
|
113
|
+
def stdout_semaphore
|
114
|
+
if @@stdout_semaphore.nil?
|
115
|
+
@@stdout_semaphore = Sync.new
|
116
|
+
end
|
117
|
+
$stdout.sync = true
|
118
|
+
|
119
|
+
return @@stdout_semaphore
|
120
|
+
end
|
121
|
+
|
122
|
+
#
|
123
|
+
# <method description>
|
124
|
+
#
|
125
|
+
# <b>Parameters</b>
|
126
|
+
# - none
|
127
|
+
# <b>Returns</b>
|
128
|
+
# - Sync object
|
129
|
+
#
|
130
|
+
private
|
131
|
+
def stderr_semaphore
|
132
|
+
if @@stderr_semaphore.nil?
|
133
|
+
@@stderr_semaphore = Sync.new
|
134
|
+
end
|
135
|
+
$stderr.sync = true
|
136
|
+
|
137
|
+
return @@stderr_semaphore
|
138
|
+
end
|
139
|
+
|
140
|
+
#
|
141
|
+
# <method description>
|
142
|
+
#
|
143
|
+
# <b>Parameters</b>
|
144
|
+
# - none
|
145
|
+
# <b>Returns</b>
|
146
|
+
# - yield
|
147
|
+
#
|
148
|
+
public
|
149
|
+
def semaphore
|
150
|
+
if block_given?
|
151
|
+
stderr_semaphore.synchronize do
|
152
|
+
stdout_semaphore.synchronize do
|
153
|
+
stdin_semaphore.synchronize do
|
154
|
+
yield
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
#
|
162
|
+
# <method description>
|
163
|
+
#
|
164
|
+
# <b>Parameters</b>
|
165
|
+
# - val(Boolean)
|
166
|
+
# <b>Returns</b>
|
167
|
+
# - none
|
168
|
+
#
|
169
|
+
def debug=(val)
|
170
|
+
@@debug = val
|
171
|
+
end
|
172
|
+
|
173
|
+
#
|
174
|
+
# <method description>
|
175
|
+
#
|
176
|
+
# <b>Parameters</b>
|
177
|
+
# - none
|
178
|
+
# <b>Returns</b>
|
179
|
+
# - Boolean
|
180
|
+
#
|
181
|
+
def debug?
|
182
|
+
return @@debug == true
|
183
|
+
end
|
184
|
+
|
185
|
+
#
|
186
|
+
# <method description>
|
187
|
+
#
|
188
|
+
# <b>Parameters</b>
|
189
|
+
# - none
|
190
|
+
# <b>Returns</b>
|
191
|
+
# - String
|
192
|
+
#
|
193
|
+
def request
|
194
|
+
return env.request
|
195
|
+
end
|
196
|
+
|
197
|
+
#
|
198
|
+
# <method description>
|
199
|
+
#
|
200
|
+
# <b>Parameters</b>
|
201
|
+
# - none
|
202
|
+
# <b>Returns</b>
|
203
|
+
# - String
|
204
|
+
#
|
205
|
+
def channel
|
206
|
+
return env.channel
|
207
|
+
end
|
208
|
+
|
209
|
+
#
|
210
|
+
# <method description>
|
211
|
+
#
|
212
|
+
# <b>Parameters</b>
|
213
|
+
# - none
|
214
|
+
# <b>Returns</b>
|
215
|
+
# - String
|
216
|
+
#
|
217
|
+
def language
|
218
|
+
return env.language
|
219
|
+
end
|
220
|
+
|
221
|
+
#
|
222
|
+
# <method description>
|
223
|
+
#
|
224
|
+
# <b>Parameters</b>
|
225
|
+
# - none
|
226
|
+
# <b>Returns</b>
|
227
|
+
# - String
|
228
|
+
#
|
229
|
+
def type
|
230
|
+
return env.type
|
231
|
+
end
|
232
|
+
|
233
|
+
#
|
234
|
+
# <method description>
|
235
|
+
#
|
236
|
+
# <b>Parameters</b>
|
237
|
+
# - none
|
238
|
+
# <b>Returns</b>
|
239
|
+
# - String
|
240
|
+
#
|
241
|
+
def uniqueid
|
242
|
+
return env.uniqueid
|
243
|
+
end
|
244
|
+
|
245
|
+
#
|
246
|
+
# <method description>
|
247
|
+
#
|
248
|
+
# <b>Parameters</b>
|
249
|
+
# - none
|
250
|
+
# <b>Returns</b>
|
251
|
+
# - String
|
252
|
+
#
|
253
|
+
def callerid
|
254
|
+
return env.callerid
|
255
|
+
end
|
256
|
+
|
257
|
+
#
|
258
|
+
# <method description>
|
259
|
+
#
|
260
|
+
# <b>Parameters</b>
|
261
|
+
# - none
|
262
|
+
# <b>Returns</b>
|
263
|
+
# - String
|
264
|
+
#
|
265
|
+
def calleridname
|
266
|
+
return env.calleridname
|
267
|
+
end
|
268
|
+
|
269
|
+
#
|
270
|
+
# <method description>
|
271
|
+
#
|
272
|
+
# <b>Parameters</b>
|
273
|
+
# - none
|
274
|
+
# <b>Returns</b>
|
275
|
+
# - String
|
276
|
+
#
|
277
|
+
def callingpres
|
278
|
+
return env.callingpres
|
279
|
+
end
|
280
|
+
|
281
|
+
#
|
282
|
+
# <method description>
|
283
|
+
#
|
284
|
+
# <b>Parameters</b>
|
285
|
+
# - none
|
286
|
+
# <b>Returns</b>
|
287
|
+
# - String
|
288
|
+
#
|
289
|
+
def callingani2
|
290
|
+
return env.callingani2
|
291
|
+
end
|
292
|
+
|
293
|
+
#
|
294
|
+
# <method description>
|
295
|
+
#
|
296
|
+
# <b>Parameters</b>
|
297
|
+
# - none
|
298
|
+
# <b>Returns</b>
|
299
|
+
# - String
|
300
|
+
#
|
301
|
+
def callington
|
302
|
+
return env.callington
|
303
|
+
end
|
304
|
+
|
305
|
+
#
|
306
|
+
# <method description>
|
307
|
+
#
|
308
|
+
# <b>Parameters</b>
|
309
|
+
# - none
|
310
|
+
# <b>Returns</b>
|
311
|
+
# - String
|
312
|
+
#
|
313
|
+
def callingtns
|
314
|
+
return env.callingtns
|
315
|
+
end
|
316
|
+
|
317
|
+
#
|
318
|
+
# <method description>
|
319
|
+
#
|
320
|
+
# <b>Parameters</b>
|
321
|
+
# - none
|
322
|
+
# <b>Returns</b>
|
323
|
+
# - String
|
324
|
+
#
|
325
|
+
def dnid
|
326
|
+
return env.dnid
|
327
|
+
end
|
328
|
+
|
329
|
+
#
|
330
|
+
# <method description>
|
331
|
+
#
|
332
|
+
# <b>Parameters</b>
|
333
|
+
# - none
|
334
|
+
# <b>Returns</b>
|
335
|
+
# - String
|
336
|
+
#
|
337
|
+
def rdnid
|
338
|
+
return env.rdnid
|
339
|
+
end
|
340
|
+
|
341
|
+
#
|
342
|
+
# <method description>
|
343
|
+
#
|
344
|
+
# <b>Parameters</b>
|
345
|
+
# - none
|
346
|
+
# <b>Returns</b>
|
347
|
+
# - String
|
348
|
+
#
|
349
|
+
def context
|
350
|
+
return env.context
|
351
|
+
end
|
352
|
+
|
353
|
+
#
|
354
|
+
# <method description>
|
355
|
+
#
|
356
|
+
# <b>Parameters</b>
|
357
|
+
# - none
|
358
|
+
# <b>Returns</b>
|
359
|
+
# - String
|
360
|
+
#
|
361
|
+
def extension
|
362
|
+
return env.extension
|
363
|
+
end
|
364
|
+
|
365
|
+
#
|
366
|
+
# <method description>
|
367
|
+
#
|
368
|
+
# <b>Parameters</b>
|
369
|
+
# - none
|
370
|
+
# <b>Returns</b>
|
371
|
+
# - String
|
372
|
+
#
|
373
|
+
def priority
|
374
|
+
return env.priority
|
375
|
+
end
|
376
|
+
|
377
|
+
#
|
378
|
+
# <method description>
|
379
|
+
#
|
380
|
+
# <b>Parameters</b>
|
381
|
+
# - none
|
382
|
+
# <b>Returns</b>
|
383
|
+
# - String
|
384
|
+
#
|
385
|
+
def enhanced
|
386
|
+
return env.enhanced
|
387
|
+
end
|
388
|
+
|
389
|
+
#
|
390
|
+
# <method description>
|
391
|
+
#
|
392
|
+
# <b>Parameters</b>
|
393
|
+
# - none
|
394
|
+
# <b>Returns</b>
|
395
|
+
# - String
|
396
|
+
#
|
397
|
+
def accountcode
|
398
|
+
return env.accountcode
|
399
|
+
end
|
400
|
+
|
401
|
+
#
|
402
|
+
# <method description>
|
403
|
+
#
|
404
|
+
# <b>Parameters</b>
|
405
|
+
# - str(String) : asterisk command in raw format to be executed
|
406
|
+
# <b>Returns</b>
|
407
|
+
# - ReturnStatus object
|
408
|
+
#
|
409
|
+
def raw_command(str)
|
410
|
+
return command.raw_command(str)
|
411
|
+
end
|
412
|
+
|
413
|
+
#
|
414
|
+
# Answers channel if not already in answer state.
|
415
|
+
#
|
416
|
+
# <b>Parameters</b>
|
417
|
+
# - none
|
418
|
+
#
|
419
|
+
# <b>Returns</b>
|
420
|
+
# - ReturnStatus object
|
421
|
+
#
|
422
|
+
def answer
|
423
|
+
return command.answer
|
424
|
+
end
|
425
|
+
|
426
|
+
#
|
427
|
+
# <method description>
|
428
|
+
#
|
429
|
+
# <b>Parameters</b>
|
430
|
+
# - val(Integer) : time in secconds
|
431
|
+
# <b>Returns</b>
|
432
|
+
# - ReturnStatus object
|
433
|
+
#
|
434
|
+
def set_auto_hangup(val)
|
435
|
+
return command.set_auto_hangup(val)
|
436
|
+
end
|
437
|
+
|
438
|
+
#
|
439
|
+
# Returns the status of the specified channel.
|
440
|
+
# If no channel name is given the returns the status of the current channel.
|
441
|
+
#
|
442
|
+
# <b>Parameters</b>
|
443
|
+
# - channel : name of the channel.
|
444
|
+
#
|
445
|
+
# <b>Returns</b>
|
446
|
+
# - ReturnStatus object
|
447
|
+
#
|
448
|
+
def channel_status(channel=nil)
|
449
|
+
return command.channel_status(channel)
|
450
|
+
end
|
451
|
+
|
452
|
+
#
|
453
|
+
# Executes <application> with given <options>.
|
454
|
+
# Applications are the functions you use to create a dial plan in extensions.conf.
|
455
|
+
#
|
456
|
+
# <b>Parameters</b>
|
457
|
+
# - application : Asterisk command of the application
|
458
|
+
# - options : options to be passed with the asterisk application
|
459
|
+
#
|
460
|
+
# <b>Returns</b>
|
461
|
+
# - ReturnStatus object
|
462
|
+
#
|
463
|
+
def exec(asterisk_application, options=nil)
|
464
|
+
return command.exec(asterisk_application, options)
|
465
|
+
end
|
466
|
+
|
467
|
+
#
|
468
|
+
# method to get digit(s)
|
469
|
+
# pressing '#' will always terminate the input process
|
470
|
+
#
|
471
|
+
# <b>Parameters</b>
|
472
|
+
# - filename : audio to be played before get as input
|
473
|
+
# - timeout : maximum allowed time in second(s) to receive each digit
|
474
|
+
# wait for ever if timeout is nil or negative or zero
|
475
|
+
# - max_digit: maximum number of digits to get as input
|
476
|
+
# wait for unlimited number of digits if max_digit is nil or negative or zero
|
477
|
+
# <b>Returns</b>
|
478
|
+
# - ReturnStatus object
|
479
|
+
#
|
480
|
+
def wait_for_digits(filename, timeout=nil, max_digit=nil)
|
481
|
+
return command.wait_for_digits(filename, timeout, max_digit)
|
482
|
+
end
|
483
|
+
|
484
|
+
#
|
485
|
+
# method to read a variable
|
486
|
+
#
|
487
|
+
# <b>Parameters</b>
|
488
|
+
# - name : name of the variable to read
|
489
|
+
#
|
490
|
+
# <b>Returns</b>
|
491
|
+
# - ReturnStatus object
|
492
|
+
#
|
493
|
+
def get_variable(name)
|
494
|
+
return command.get_variable(name)
|
495
|
+
end
|
496
|
+
|
497
|
+
#
|
498
|
+
# method to hang up the specified channel.
|
499
|
+
# If no channel name is given, hangs up the current channel.
|
500
|
+
#
|
501
|
+
# <b>Parameters</b>
|
502
|
+
# - channel : name of the channel to hang up
|
503
|
+
# <b>Returns</b>
|
504
|
+
# - ReturnStatus object
|
505
|
+
#
|
506
|
+
def hangup(channel=nil)
|
507
|
+
return command.hangup(channel)
|
508
|
+
end
|
509
|
+
|
510
|
+
#
|
511
|
+
# method that Does nothing !!
|
512
|
+
#
|
513
|
+
# <b>Parameters</b>
|
514
|
+
# - msg : message to pass this method
|
515
|
+
#
|
516
|
+
# <b>Returns</b>
|
517
|
+
# - ReturnStatus object
|
518
|
+
# success: 200 result=0
|
519
|
+
#
|
520
|
+
def noop(msg)
|
521
|
+
return command.noop(msg)
|
522
|
+
end
|
523
|
+
|
524
|
+
#
|
525
|
+
# Receives a character of text on a channel, and discards any further characters after the first one waiting.
|
526
|
+
# Most channels do not support the reception of text. See Asterisk Text for details.
|
527
|
+
#
|
528
|
+
# <b>Parameters</b>
|
529
|
+
# - timeout : maximum time to wait for input in seconds
|
530
|
+
# negative or zero is not acceptable
|
531
|
+
#
|
532
|
+
# <b>Returns</b>
|
533
|
+
# - ReturnStatus object
|
534
|
+
#
|
535
|
+
def receive_char(timeout)
|
536
|
+
return command.receive_char(timeout)
|
537
|
+
end
|
538
|
+
|
539
|
+
#
|
540
|
+
# Receives a string text on a channel.
|
541
|
+
# Most channels do not support the reception of text.
|
542
|
+
#
|
543
|
+
# <b>Parameters</b>
|
544
|
+
# - timeout : time to wait for input in seconds
|
545
|
+
# negative or zero is not acceptable
|
546
|
+
#
|
547
|
+
# <b>Returns</b>
|
548
|
+
# - ReturnStatus object
|
549
|
+
#
|
550
|
+
def receive_text(timeout)
|
551
|
+
return command.receive_text(timeout)
|
552
|
+
end
|
553
|
+
|
554
|
+
#
|
555
|
+
# Record to a file until <escape digits> are received as dtmf.
|
556
|
+
#
|
557
|
+
# <b>Parameters</b>
|
558
|
+
# - filename : location of the file where the audio file will be saved
|
559
|
+
# - format : specify what kind of file will be recorded.
|
560
|
+
# - timeout : maximum record time in seconds
|
561
|
+
# nil, negative or 0 for no timeout.
|
562
|
+
# - offset : [offset samples] is optional,
|
563
|
+
# and if provided will seek to the offset without exceeding the end of the file.
|
564
|
+
# - silence : number of seconds of silence allowed before the function returns
|
565
|
+
# despite the lack of dtmf digits or reaching timeout.
|
566
|
+
# Silence value must be preceeded by "s=" and is optional.
|
567
|
+
#
|
568
|
+
# <b>Returns</b>
|
569
|
+
# - ReturnStatus object
|
570
|
+
#
|
571
|
+
def record_file(filename, format='gsm', escape_digits=nil, timeout=nil, beep=true)
|
572
|
+
return command.record_file(filename, format, escape_digits, timeout, beep)
|
573
|
+
end
|
574
|
+
|
575
|
+
#
|
576
|
+
# Say a given digit string, returning early if any of the given DTMF digits are received on the channel.
|
577
|
+
#
|
578
|
+
# <b>Parameters</b>
|
579
|
+
# - number : number to announce
|
580
|
+
# - escape_digit : if digit pressed during playback, will return from announce
|
581
|
+
#
|
582
|
+
# <b>Returns</b>
|
583
|
+
# - ReturnStatus (object)
|
584
|
+
#
|
585
|
+
# failure: 200 result=-1
|
586
|
+
# success: 200 result=0
|
587
|
+
# digit pressed: 200 result=<digit>
|
588
|
+
# <digit> is the ascii code for the digit pressed.
|
589
|
+
#
|
590
|
+
def say_digits(digit_string, escape_digits=nil)
|
591
|
+
return command.say_digits(digit_string, escape_digits)
|
592
|
+
end
|
593
|
+
|
594
|
+
#
|
595
|
+
# Say a given number, returning early if any of the given DTMF digits are received on the channel.
|
596
|
+
#
|
597
|
+
# <b>Parameters</b>
|
598
|
+
# - number : number to announce
|
599
|
+
# - escape_digit : if pressed, return from program
|
600
|
+
#
|
601
|
+
# <b>Returns</b>
|
602
|
+
# - ReturnStatus object
|
603
|
+
#
|
604
|
+
def say_number(number, escape_digits=nil)
|
605
|
+
return command.say_number(number, escape_digits)
|
606
|
+
end
|
607
|
+
|
608
|
+
#
|
609
|
+
# Say a given character string with phonetics, returning early if any of the given DTMF digits are received on the channel.
|
610
|
+
#
|
611
|
+
# <b>Parameters</b>
|
612
|
+
# - string : character string to announce
|
613
|
+
# - escape_digit : digit to be pressed to escape from program
|
614
|
+
#
|
615
|
+
# <b>Returns</b>
|
616
|
+
# - ReturnStatus (object)
|
617
|
+
#
|
618
|
+
def say_phonetic(string, escape_digits=nil)
|
619
|
+
return command.say_phonetic(string, escape_digits)
|
620
|
+
end
|
621
|
+
|
622
|
+
#
|
623
|
+
# Say a given time, returning early if any of the given DTMF digits are received on the channel.
|
624
|
+
#
|
625
|
+
# <b>Parameters</b>
|
626
|
+
# - time : number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
|
627
|
+
# - escape_digits : digit to be pressed to escape from the program
|
628
|
+
#
|
629
|
+
# <b>Returns</b>
|
630
|
+
# - ReturnStatus (object)
|
631
|
+
#
|
632
|
+
def say_time(time=Time.now.to_i, escape_digits='#')
|
633
|
+
return command.say_time(time, escape_digits)
|
634
|
+
end
|
635
|
+
|
636
|
+
#
|
637
|
+
# Sends the given image on a channel.
|
638
|
+
# Most channels do not support the transmission of images.
|
639
|
+
# Image names should not include extensions.
|
640
|
+
#
|
641
|
+
# <b>Parameters</b>
|
642
|
+
# - image : location of image
|
643
|
+
#
|
644
|
+
# <b>Returns</b>
|
645
|
+
# - ReturnStatus (object)
|
646
|
+
#
|
647
|
+
def send_image(image)
|
648
|
+
return command.send_image(image)
|
649
|
+
end
|
650
|
+
|
651
|
+
#
|
652
|
+
# Sends the given text on a channel.
|
653
|
+
# Most channels do not support the transmission of text.
|
654
|
+
# Text consisting of greater than one word should be placed in quotes since the command only accepts a single argument.
|
655
|
+
#
|
656
|
+
# <b>Parameters</b>
|
657
|
+
# - text : text to be send
|
658
|
+
#
|
659
|
+
# <b>Returns</b>
|
660
|
+
# - ReturnStatus (object)
|
661
|
+
#
|
662
|
+
def send_text(text)
|
663
|
+
return command.send_text(text)
|
664
|
+
end
|
665
|
+
|
666
|
+
#
|
667
|
+
# Changes the callerid of the current channel.
|
668
|
+
#
|
669
|
+
# <b>Parameters</b>
|
670
|
+
# - number : number to be set a callerid
|
671
|
+
#
|
672
|
+
# <b>Returns</b>
|
673
|
+
# - ReturnStatus (object)
|
674
|
+
#
|
675
|
+
def set_caller_id(number)
|
676
|
+
return command.set_caller_id(number)
|
677
|
+
end
|
678
|
+
|
679
|
+
#
|
680
|
+
# Sets the context for continuation upon exiting the application.
|
681
|
+
#
|
682
|
+
# <b>Parameters</b>
|
683
|
+
# - context : name of the context
|
684
|
+
#
|
685
|
+
# <b>Returns</b>
|
686
|
+
# - ReturnStatus object
|
687
|
+
#
|
688
|
+
def set_context(context)
|
689
|
+
return command.set_context(context)
|
690
|
+
end
|
691
|
+
|
692
|
+
#
|
693
|
+
# Changes the extension for continuation upon exiting the application.
|
694
|
+
#
|
695
|
+
# <b>Parameters</b>
|
696
|
+
# - extension: name or number of extension to be set
|
697
|
+
#
|
698
|
+
# <b>Returns</b>
|
699
|
+
# - ReturnStatus object
|
700
|
+
#
|
701
|
+
def set_extension(extension)
|
702
|
+
return command.set_extension(extension)
|
703
|
+
end
|
704
|
+
|
705
|
+
#
|
706
|
+
# Changes the priority for continuation upon exiting the application.
|
707
|
+
#
|
708
|
+
# <b>Parameters</b>
|
709
|
+
# - priority : number of priority
|
710
|
+
#
|
711
|
+
# <b>Returns</b>
|
712
|
+
# - ReturnStatus object
|
713
|
+
def set_priority(priority)
|
714
|
+
return command.set_priority(priority)
|
715
|
+
end
|
716
|
+
|
717
|
+
#
|
718
|
+
# Enables/Disables the music on hold generator.
|
719
|
+
#
|
720
|
+
# <b>Parameters</b>
|
721
|
+
# - mode : on or off
|
722
|
+
# - moh_class : name of the music on hold class
|
723
|
+
# 'default' for not provided or nil
|
724
|
+
#
|
725
|
+
# <b>Returns</b>
|
726
|
+
# - ReturnStatus object
|
727
|
+
#
|
728
|
+
def set_music(mode=true, moh_class='default')
|
729
|
+
return command.set_music(mode, moh_class)
|
730
|
+
end
|
731
|
+
|
732
|
+
#
|
733
|
+
# set variable: Sets a channel variable
|
734
|
+
# These variables live in the channel Asterisk creates
|
735
|
+
# when you pickup a phone and as such they are both local
|
736
|
+
# and temporary. Variables created in one channel can not
|
737
|
+
# be accessed by another channel. When you hang up the phone,
|
738
|
+
# the channel is deleted and any variables in that channel are deleted as well.
|
739
|
+
#
|
740
|
+
# <b>Parameters</b>
|
741
|
+
# - variablename : name of the variable
|
742
|
+
# - value : value to be set for the variable
|
743
|
+
#
|
744
|
+
# <b>Returns</b>
|
745
|
+
# - ReturnStatus object
|
746
|
+
#
|
747
|
+
def set_variable(name, value)
|
748
|
+
return command.set_variable(name, value)
|
749
|
+
end
|
750
|
+
|
751
|
+
#
|
752
|
+
# stream file: Sends audio file on channel
|
753
|
+
# Send the given file, allowing playback to be interrupted by the given digits, if any.
|
754
|
+
# Use double quotes for the digits if you wish none to be permitted.
|
755
|
+
# If sample offset is provided then the audio will seek to sample offset before play starts.
|
756
|
+
# Remember, the file extension must not be included in the filename.
|
757
|
+
#
|
758
|
+
# <b>Parameters</b>
|
759
|
+
# - filename : location of the file to be played
|
760
|
+
# - escape_digit: digit to be pressed to escape from playback
|
761
|
+
#
|
762
|
+
# <b>Returns</b>
|
763
|
+
# - ReturnStatus object
|
764
|
+
#
|
765
|
+
def stream_file(filename, escape_digits='#')
|
766
|
+
return command.stream_file(filename, escape_digits)
|
767
|
+
end
|
768
|
+
|
769
|
+
#
|
770
|
+
# tdd mode: Activates TDD mode on channels supporting it, to enable communication with TDDs.
|
771
|
+
# Enable/Disable TDD transmission/reception on a channel.
|
772
|
+
# This function is currently (01July2005) only supported on Zap channels.
|
773
|
+
# As of 02July2005, this function never returns 0 (Not Capable).
|
774
|
+
# If it fails for any reason, -1 (Failure) will be returned, otherwise 1 (Success) will be returned.
|
775
|
+
# The capability for returning 0 if the channel is not capable of TDD MODE is a future plan.
|
776
|
+
#
|
777
|
+
# <b>Parameters</b>
|
778
|
+
# - mode : mode of the tdd to be set
|
779
|
+
# set tdd on if non-zero or 'true' specified
|
780
|
+
#
|
781
|
+
# <b>Returns</b>
|
782
|
+
# - ReturnStatus object
|
783
|
+
#
|
784
|
+
def tdd_mode(settings=true)
|
785
|
+
return command.tdd_mode(settings)
|
786
|
+
end
|
787
|
+
|
788
|
+
#
|
789
|
+
# Sends <message> to the console via verbose message system.
|
790
|
+
# The Asterisk verbosity system works as follows.
|
791
|
+
# The Asterisk user gets to set the desired verbosity at startup time
|
792
|
+
# or later using the console 'set verbose' command.
|
793
|
+
# Messages are displayed on the console if their verbose level
|
794
|
+
# is less than or equal to desired verbosity set by the user.
|
795
|
+
# More important messages should have a low verbose level;
|
796
|
+
# less important messages should have a high verbose level.
|
797
|
+
#
|
798
|
+
# <b>Parameters</b>
|
799
|
+
# - message : message to be send as log
|
800
|
+
# - level : verbose level to be set
|
801
|
+
# [level] is the the verbose level (1-4)
|
802
|
+
# If you specify a verbose level less than 1 or greater than 4, the verbosity is 1.
|
803
|
+
# The default verbosity seems to be 0 (in 1.0.8),
|
804
|
+
# and supplying a 0 (zero) verbosity does work:
|
805
|
+
# the message will be displayed regardless of the console verbosity setting.
|
806
|
+
#
|
807
|
+
# <b>Returns</b>
|
808
|
+
# - ReturnStatus object
|
809
|
+
#
|
810
|
+
def verbose(message, level=3)
|
811
|
+
return command.verbose(message, level)
|
812
|
+
end
|
813
|
+
|
814
|
+
#
|
815
|
+
# wait for digit: Waits for a digit to be pressed
|
816
|
+
# Waits up to <timeout> milliseconds for channel to receive a DTMF digit.
|
817
|
+
#
|
818
|
+
# <b>Parameters</b>
|
819
|
+
# - timeout : maximum allow waiting time in seconds to get input
|
820
|
+
# nil, zero or negative would be considered as infinite wait time
|
821
|
+
#
|
822
|
+
# <b>Returns</b>
|
823
|
+
# - ReturnStatus object
|
824
|
+
#
|
825
|
+
def wait_for_digit(timeout=nil)
|
826
|
+
return command.wait_for_digit(timeout)
|
827
|
+
end
|
828
|
+
|
829
|
+
#
|
830
|
+
# method to dial out
|
831
|
+
#
|
832
|
+
# <b>Parameters</b>
|
833
|
+
# - telephone_number : telephone_number or extension to dial
|
834
|
+
# - protocol : protocol to be used to make this call
|
835
|
+
# - username : username to be used to make this call using the specified protocol
|
836
|
+
# - context : name of the context to be used for authentication
|
837
|
+
# - timeout : maximum allowed time in seconds to make this call
|
838
|
+
# - options : options to be passed in 'Dial' command
|
839
|
+
#
|
840
|
+
# <b>Returns</b>
|
841
|
+
# - ReturnStatus object
|
842
|
+
#
|
843
|
+
def dial(telephone_number=nil, protocol=nil, username=nil, context=nil, timeout=nil, options=nil)
|
844
|
+
return command.dial(telephone_number, protocol, username, context, timeout, options)
|
845
|
+
end
|
846
|
+
end
|
847
|
+
|