agi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +223 -0
- data/README +19 -0
- data/Rakefile +20 -0
- data/VERSION +1 -0
- data/agi.gemspec +49 -0
- data/examples/call_log.rb +18 -0
- data/extconf.rb +2 -0
- data/lib/agi.rb +5 -0
- data/lib/agi/agi.rb +891 -0
- data/lib/agi/asterisk_variable.rb +239 -0
- data/lib/agi/command.rb +908 -0
- data/lib/agi/error.rb +45 -0
- data/lib/agi/return_status.rb +92 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7f4c1f11d678b0119867f80ace7096281c78055e
|
4
|
+
data.tar.gz: 9606b5f0f68b8e7dde8b6dac6243ef9a8fadad3e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 217ffd15bdb142f088146beee27cb7da04199376e60c67fd3b19d929f80974c0bb3b4fb5870a6e45c76d0068581110377c096ee4883909b1df73dc16825d41f3
|
7
|
+
data.tar.gz: d5e0cdcfee9ae01dd7d0c220b9e8f0938bb5c695eccb80279af867398c5edaeb0c9efd5804f256f2297186902381da26b193bcd6050ed066be83e00a581dec93
|
data/LICENSE
ADDED
@@ -0,0 +1,223 @@
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
2
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
3
|
+
|
4
|
+
0. This License applies to any program or other work which contains
|
5
|
+
a notice placed by the copyright holder saying it may be distributed
|
6
|
+
under the terms of this General Public License. The "Program", below,
|
7
|
+
refers to any such program or work, and a "work based on the Program"
|
8
|
+
means either the Program or any derivative work under copyright law:
|
9
|
+
that is to say, a work containing the Program or a portion of it,
|
10
|
+
either verbatim or with modifications and/or translated into another
|
11
|
+
language. (Hereinafter, translation is included without limitation in
|
12
|
+
the term "modification".) Each licensee is addressed as "you".
|
13
|
+
|
14
|
+
Activities other than copying, distribution and modification are not
|
15
|
+
covered by this License; they are outside its scope. The act of
|
16
|
+
running the Program is not restricted, and the output from the Program
|
17
|
+
is covered only if its contents constitute a work based on the
|
18
|
+
Program (independent of having been made by running the Program).
|
19
|
+
Whether that is true depends on what the Program does.
|
20
|
+
|
21
|
+
1. You may copy and distribute verbatim copies of the Program's
|
22
|
+
source code as you receive it, in any medium, provided that you
|
23
|
+
conspicuously and appropriately publish on each copy an appropriate
|
24
|
+
copyright notice and disclaimer of warranty; keep intact all the
|
25
|
+
notices that refer to this License and to the absence of any warranty;
|
26
|
+
and give any other recipients of the Program a copy of this License
|
27
|
+
along with the Program.
|
28
|
+
|
29
|
+
You may charge a fee for the physical act of transferring a copy, and
|
30
|
+
you may at your option offer warranty protection in exchange for a fee.
|
31
|
+
|
32
|
+
2. You may modify your copy or copies of the Program or any portion
|
33
|
+
of it, thus forming a work based on the Program, and copy and
|
34
|
+
distribute such modifications or work under the terms of Section 1
|
35
|
+
above, provided that you also meet all of these conditions:
|
36
|
+
|
37
|
+
a) You must cause the modified files to carry prominent notices
|
38
|
+
stating that you changed the files and the date of any change.
|
39
|
+
|
40
|
+
b) You must cause any work that you distribute or publish, that in
|
41
|
+
whole or in part contains or is derived from the Program or any
|
42
|
+
part thereof, to be licensed as a whole at no charge to all third
|
43
|
+
parties under the terms of this License.
|
44
|
+
|
45
|
+
c) If the modified program normally reads commands interactively
|
46
|
+
when run, you must cause it, when started running for such
|
47
|
+
interactive use in the most ordinary way, to print or display an
|
48
|
+
announcement including an appropriate copyright notice and a
|
49
|
+
notice that there is no warranty (or else, saying that you provide
|
50
|
+
a warranty) and that users may redistribute the program under
|
51
|
+
these conditions, and telling the user how to view a copy of this
|
52
|
+
License. (Exception: if the Program itself is interactive but
|
53
|
+
does not normally print such an announcement, your work based on
|
54
|
+
the Program is not required to print an announcement.)
|
55
|
+
|
56
|
+
These requirements apply to the modified work as a whole. If
|
57
|
+
identifiable sections of that work are not derived from the Program,
|
58
|
+
and can be reasonably considered independent and separate works in
|
59
|
+
themselves, then this License, and its terms, do not apply to those
|
60
|
+
sections when you distribute them as separate works. But when you
|
61
|
+
distribute the same sections as part of a whole which is a work based
|
62
|
+
on the Program, the distribution of the whole must be on the terms of
|
63
|
+
this License, whose permissions for other licensees extend to the
|
64
|
+
entire whole, and thus to each and every part regardless of who wrote it.
|
65
|
+
|
66
|
+
Thus, it is not the intent of this section to claim rights or contest
|
67
|
+
your rights to work written entirely by you; rather, the intent is to
|
68
|
+
exercise the right to control the distribution of derivative or
|
69
|
+
collective works based on the Program.
|
70
|
+
|
71
|
+
In addition, mere aggregation of another work not based on the Program
|
72
|
+
with the Program (or with a work based on the Program) on a volume of
|
73
|
+
a storage or distribution medium does not bring the other work under
|
74
|
+
the scope of this License.
|
75
|
+
|
76
|
+
3. You may copy and distribute the Program (or a work based on it,
|
77
|
+
under Section 2) in object code or executable form under the terms of
|
78
|
+
Sections 1 and 2 above provided that you also do one of the following:
|
79
|
+
|
80
|
+
a) Accompany it with the complete corresponding machine-readable
|
81
|
+
source code, which must be distributed under the terms of Sections
|
82
|
+
1 and 2 above on a medium customarily used for software interchange; or,
|
83
|
+
|
84
|
+
b) Accompany it with a written offer, valid for at least three
|
85
|
+
years, to give any third party, for a charge no more than your
|
86
|
+
cost of physically performing source distribution, a complete
|
87
|
+
machine-readable copy of the corresponding source code, to be
|
88
|
+
distributed under the terms of Sections 1 and 2 above on a medium
|
89
|
+
customarily used for software interchange; or,
|
90
|
+
|
91
|
+
c) Accompany it with the information you received as to the offer
|
92
|
+
to distribute corresponding source code. (This alternative is
|
93
|
+
allowed only for noncommercial distribution and only if you
|
94
|
+
received the program in object code or executable form with such
|
95
|
+
an offer, in accord with Subsection b above.)
|
96
|
+
|
97
|
+
The source code for a work means the preferred form of the work for
|
98
|
+
making modifications to it. For an executable work, complete source
|
99
|
+
code means all the source code for all modules it contains, plus any
|
100
|
+
associated interface definition files, plus the scripts used to
|
101
|
+
control compilation and installation of the executable. However, as a
|
102
|
+
special exception, the source code distributed need not include
|
103
|
+
anything that is normally distributed (in either source or binary
|
104
|
+
form) with the major components (compiler, kernel, and so on) of the
|
105
|
+
operating system on which the executable runs, unless that component
|
106
|
+
itself accompanies the executable.
|
107
|
+
|
108
|
+
If distribution of executable or object code is made by offering
|
109
|
+
access to copy from a designated place, then offering equivalent
|
110
|
+
access to copy the source code from the same place counts as
|
111
|
+
distribution of the source code, even though third parties are not
|
112
|
+
compelled to copy the source along with the object code.
|
113
|
+
|
114
|
+
4. You may not copy, modify, sublicense, or distribute the Program
|
115
|
+
except as expressly provided under this License. Any attempt
|
116
|
+
otherwise to copy, modify, sublicense or distribute the Program is
|
117
|
+
void, and will automatically terminate your rights under this License.
|
118
|
+
However, parties who have received copies, or rights, from you under
|
119
|
+
this License will not have their licenses terminated so long as such
|
120
|
+
parties remain in full compliance.
|
121
|
+
|
122
|
+
5. You are not required to accept this License, since you have not
|
123
|
+
signed it. However, nothing else grants you permission to modify or
|
124
|
+
distribute the Program or its derivative works. These actions are
|
125
|
+
prohibited by law if you do not accept this License. Therefore, by
|
126
|
+
modifying or distributing the Program (or any work based on the
|
127
|
+
Program), you indicate your acceptance of this License to do so, and
|
128
|
+
all its terms and conditions for copying, distributing or modifying
|
129
|
+
the Program or works based on it.
|
130
|
+
|
131
|
+
6. Each time you redistribute the Program (or any work based on the
|
132
|
+
Program), the recipient automatically receives a license from the
|
133
|
+
original licensor to copy, distribute or modify the Program subject to
|
134
|
+
these terms and conditions. You may not impose any further
|
135
|
+
restrictions on the recipients' exercise of the rights granted herein.
|
136
|
+
You are not responsible for enforcing compliance by third parties to
|
137
|
+
this License.
|
138
|
+
|
139
|
+
7. If, as a consequence of a court judgment or allegation of patent
|
140
|
+
infringement or for any other reason (not limited to patent issues),
|
141
|
+
conditions are imposed on you (whether by court order, agreement or
|
142
|
+
otherwise) that contradict the conditions of this License, they do not
|
143
|
+
excuse you from the conditions of this License. If you cannot
|
144
|
+
distribute so as to satisfy simultaneously your obligations under this
|
145
|
+
License and any other pertinent obligations, then as a consequence you
|
146
|
+
may not distribute the Program at all. For example, if a patent
|
147
|
+
license would not permit royalty-free redistribution of the Program by
|
148
|
+
all those who receive copies directly or indirectly through you, then
|
149
|
+
the only way you could satisfy both it and this License would be to
|
150
|
+
refrain entirely from distribution of the Program.
|
151
|
+
|
152
|
+
If any portion of this section is held invalid or unenforceable under
|
153
|
+
any particular circumstance, the balance of the section is intended to
|
154
|
+
apply and the section as a whole is intended to apply in other
|
155
|
+
circumstances.
|
156
|
+
|
157
|
+
It is not the purpose of this section to induce you to infringe any
|
158
|
+
patents or other property right claims or to contest validity of any
|
159
|
+
such claims; this section has the sole purpose of protecting the
|
160
|
+
integrity of the free software distribution system, which is
|
161
|
+
implemented by public license practices. Many people have made
|
162
|
+
generous contributions to the wide range of software distributed
|
163
|
+
through that system in reliance on consistent application of that
|
164
|
+
system; it is up to the author/donor to decide if he or she is willing
|
165
|
+
to distribute software through any other system and a licensee cannot
|
166
|
+
impose that choice.
|
167
|
+
|
168
|
+
This section is intended to make thoroughly clear what is believed to
|
169
|
+
be a consequence of the rest of this License.
|
170
|
+
|
171
|
+
8. If the distribution and/or use of the Program is restricted in
|
172
|
+
certain countries either by patents or by copyrighted interfaces, the
|
173
|
+
original copyright holder who places the Program under this License
|
174
|
+
may add an explicit geographical distribution limitation excluding
|
175
|
+
those countries, so that distribution is permitted only in or among
|
176
|
+
countries not thus excluded. In such case, this License incorporates
|
177
|
+
the limitation as if written in the body of this License.
|
178
|
+
|
179
|
+
9. The Free Software Foundation may publish revised and/or new versions
|
180
|
+
of the General Public License from time to time. Such new versions will
|
181
|
+
be similar in spirit to the present version, but may differ in detail to
|
182
|
+
address new problems or concerns.
|
183
|
+
|
184
|
+
Each version is given a distinguishing version number. If the Program
|
185
|
+
specifies a version number of this License which applies to it and "any
|
186
|
+
later version", you have the option of following the terms and conditions
|
187
|
+
either of that version or of any later version published by the Free
|
188
|
+
Software Foundation. If the Program does not specify a version number of
|
189
|
+
this License, you may choose any version ever published by the Free Software
|
190
|
+
Foundation.
|
191
|
+
|
192
|
+
10. If you wish to incorporate parts of the Program into other free
|
193
|
+
programs whose distribution conditions are different, write to the author
|
194
|
+
to ask for permission. For software which is copyrighted by the Free
|
195
|
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
196
|
+
make exceptions for this. Our decision will be guided by the two goals
|
197
|
+
of preserving the free status of all derivatives of our free software and
|
198
|
+
of promoting the sharing and reuse of software generally.
|
199
|
+
|
200
|
+
NO WARRANTY
|
201
|
+
|
202
|
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
203
|
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
204
|
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
205
|
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
206
|
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
207
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
208
|
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
209
|
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
210
|
+
REPAIR OR CORRECTION.
|
211
|
+
|
212
|
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
213
|
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
214
|
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
215
|
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
216
|
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
217
|
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
218
|
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
219
|
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
220
|
+
POSSIBILITY OF SUCH DAMAGES.
|
221
|
+
|
222
|
+
END OF TERMS AND CONDITIONS
|
223
|
+
|
data/README
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
This is a fork of the original ruby-agi version 1.1.2 code, which is located @ rubyforge.
|
2
|
+
|
3
|
+
Original notes still located below.
|
4
|
+
-------------------------------------------------------------------------------------------
|
5
|
+
|
6
|
+
This library comes with absolutely no warranty.
|
7
|
+
|
8
|
+
agi is a library to write AGI scripts in ruby language for Asterisk. agi does not depend of Asterisk Manager.
|
9
|
+
There have a very simple AGI script in example/call_log.rb.
|
10
|
+
I couldn't write any tutorial for agi and I am not good at it, if anybody want to give me a hand on writing documentation and tutorial, would be greatly appreciated.
|
11
|
+
|
12
|
+
Here are a sites that may help to know more about agi
|
13
|
+
http://agi.rubyforge.org (agi homepage)
|
14
|
+
|
15
|
+
Feel free to send me email, if you don't find any answer related to agi
|
16
|
+
|
17
|
+
Thank you,
|
18
|
+
Alaxey Gordienko,
|
19
|
+
email: alx <AT> anadyr <DOT> org
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift('lib')
|
4
|
+
|
5
|
+
gem 'git'
|
6
|
+
require 'git'
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'jeweler'
|
10
|
+
Jeweler::Tasks.new do |gemspec|
|
11
|
+
gemspec.name = "agi"
|
12
|
+
gemspec.summary = "Ruby AGI interface into Asterisk"
|
13
|
+
gemspec.description = "This is a fork of agi version 1.1.2 by Mohammad Khan."
|
14
|
+
gemspec.email = "alx@anadyr.org"
|
15
|
+
gemspec.homepage = "http://github.com/erichmond/agi"
|
16
|
+
gemspec.authors = ["Alexey Gordienko"]
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
|
20
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/agi.gemspec
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{agi}
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Alexey Gordienko"]
|
9
|
+
s.date = %q{2915-09-06}
|
10
|
+
s.description = %q{This is a fork of ruby-agi version 1.1.2 by Mohammad Khan.}
|
11
|
+
s.email = %q{alx@anadyr.org}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"LICENSE",
|
14
|
+
"README"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
"LICENSE",
|
18
|
+
"README",
|
19
|
+
"Rakefile",
|
20
|
+
"VERSION",
|
21
|
+
"examples/call_log.rb",
|
22
|
+
"extconf.rb",
|
23
|
+
"lib/agi.rb",
|
24
|
+
"lib/agi/agi.rb",
|
25
|
+
"lib/agi/asterisk_variable.rb",
|
26
|
+
"lib/agi/command.rb",
|
27
|
+
"lib/agi/error.rb",
|
28
|
+
"lib/agi/return_status.rb",
|
29
|
+
"agi.gemspec"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/gordienko/agi}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.4}
|
35
|
+
s.summary = %q{Ruby AGI interface into Asterisk}
|
36
|
+
s.test_files = [
|
37
|
+
"examples/call_log.rb"
|
38
|
+
]
|
39
|
+
|
40
|
+
if s.respond_to? :specification_version then
|
41
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
45
|
+
else
|
46
|
+
end
|
47
|
+
else
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# File : call_log.rb
|
4
|
+
# Purpose: log caller and calleridname in syslog as warning message
|
5
|
+
# Author: Alexey Gordienko, alx@anadyr.org
|
6
|
+
# Liscense: GNU GENERAL PUBLIC LICENSE
|
7
|
+
#
|
8
|
+
|
9
|
+
|
10
|
+
require 'syslog'
|
11
|
+
require 'rubygems'
|
12
|
+
require 'agi'
|
13
|
+
|
14
|
+
|
15
|
+
log = Syslog.open("call_log.rb")
|
16
|
+
agi = AGI.new
|
17
|
+
|
18
|
+
log.warning("#{agi.callerid} <#{agi.calleridname}>")
|
data/extconf.rb
ADDED
data/lib/agi.rb
ADDED
data/lib/agi/agi.rb
ADDED
@@ -0,0 +1,891 @@
|
|
1
|
+
#
|
2
|
+
# File: agi.rb
|
3
|
+
#
|
4
|
+
# 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 'agi/error.rb'
|
27
|
+
require 'agi/command.rb'
|
28
|
+
require 'agi/asterisk_variable.rb'
|
29
|
+
require '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
|
+
@@debug = nil
|
45
|
+
@@stdin_semaphore = nil
|
46
|
+
@@stdout_semaphore = nil
|
47
|
+
@@stderr_semaphore = nil
|
48
|
+
|
49
|
+
begin
|
50
|
+
@@env = AsteriskVariable.new if @@env.nil?
|
51
|
+
rescue NameError
|
52
|
+
@@env = AsteriskVariable.new
|
53
|
+
rescue
|
54
|
+
raise(AGIError, "Error to initialize @@env in AGI#initialize, please report to info@beeplove.com")
|
55
|
+
end
|
56
|
+
|
57
|
+
begin
|
58
|
+
@@command = Command.new if @@command.nil?
|
59
|
+
rescue NameError
|
60
|
+
@@command = Command.new
|
61
|
+
rescue
|
62
|
+
raise(AGIError, "Error to initialize @@command in AGI#initialize, please report to info@beeplove.com")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# method to get Command object instance
|
68
|
+
#
|
69
|
+
# <b>Parameters</b>
|
70
|
+
# - none
|
71
|
+
# <b>Returns</b>
|
72
|
+
# - Command object
|
73
|
+
#
|
74
|
+
private
|
75
|
+
def command
|
76
|
+
if @@command.nil?
|
77
|
+
@@command = Command.new
|
78
|
+
end
|
79
|
+
return @@command
|
80
|
+
end
|
81
|
+
|
82
|
+
#
|
83
|
+
# <method description>
|
84
|
+
#
|
85
|
+
# <b>Parameters</b>
|
86
|
+
# - none
|
87
|
+
# <b>Returns</b>
|
88
|
+
# - AsteriskVariable object
|
89
|
+
#
|
90
|
+
private
|
91
|
+
def env
|
92
|
+
if @@env.nil?
|
93
|
+
@@env = AsteriskVariable.new
|
94
|
+
end
|
95
|
+
|
96
|
+
return @@env
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# <method description>
|
101
|
+
#
|
102
|
+
# <b>Parameters</b>
|
103
|
+
# - none
|
104
|
+
# <b>Returns</b>
|
105
|
+
# - Sync object
|
106
|
+
#
|
107
|
+
private
|
108
|
+
def stdin_semaphore
|
109
|
+
if @@stdin_semaphore.nil?
|
110
|
+
@@stdin_semaphore = Sync.new
|
111
|
+
end
|
112
|
+
$stdin.sync = true
|
113
|
+
|
114
|
+
return @@stdin_semaphore
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# <method description>
|
119
|
+
#
|
120
|
+
# <b>Parameters</b>
|
121
|
+
# - none
|
122
|
+
# <b>Returns</b>
|
123
|
+
# - Sync object
|
124
|
+
#
|
125
|
+
private
|
126
|
+
def stdout_semaphore
|
127
|
+
if @@stdout_semaphore.nil?
|
128
|
+
@@stdout_semaphore = Sync.new
|
129
|
+
end
|
130
|
+
$stdout.sync = true
|
131
|
+
|
132
|
+
return @@stdout_semaphore
|
133
|
+
end
|
134
|
+
|
135
|
+
#
|
136
|
+
# <method description>
|
137
|
+
#
|
138
|
+
# <b>Parameters</b>
|
139
|
+
# - none
|
140
|
+
# <b>Returns</b>
|
141
|
+
# - Sync object
|
142
|
+
#
|
143
|
+
private
|
144
|
+
def stderr_semaphore
|
145
|
+
if @@stderr_semaphore.nil?
|
146
|
+
@@stderr_semaphore = Sync.new
|
147
|
+
end
|
148
|
+
$stderr.sync = true
|
149
|
+
|
150
|
+
return @@stderr_semaphore
|
151
|
+
end
|
152
|
+
|
153
|
+
#
|
154
|
+
# <method description>
|
155
|
+
#
|
156
|
+
# <b>Parameters</b>
|
157
|
+
# - none
|
158
|
+
# <b>Returns</b>
|
159
|
+
# - yield
|
160
|
+
#
|
161
|
+
public
|
162
|
+
def semaphore
|
163
|
+
if block_given?
|
164
|
+
stderr_semaphore.synchronize do
|
165
|
+
stdout_semaphore.synchronize do
|
166
|
+
stdin_semaphore.synchronize do
|
167
|
+
yield
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
#
|
175
|
+
# <method description>
|
176
|
+
#
|
177
|
+
# <b>Parameters</b>
|
178
|
+
# - val(Boolean)
|
179
|
+
# <b>Returns</b>
|
180
|
+
# - none
|
181
|
+
#
|
182
|
+
def debug=(val)
|
183
|
+
@@debug = val
|
184
|
+
end
|
185
|
+
|
186
|
+
#
|
187
|
+
# <method description>
|
188
|
+
#
|
189
|
+
# <b>Parameters</b>
|
190
|
+
# - none
|
191
|
+
# <b>Returns</b>
|
192
|
+
# - Boolean
|
193
|
+
#
|
194
|
+
def debug?
|
195
|
+
return @@debug == true
|
196
|
+
end
|
197
|
+
|
198
|
+
#
|
199
|
+
# <method description>
|
200
|
+
#
|
201
|
+
# <b>Parameters</b>
|
202
|
+
# - none
|
203
|
+
# <b>Returns</b>
|
204
|
+
# - String
|
205
|
+
#
|
206
|
+
def request
|
207
|
+
return env.request
|
208
|
+
end
|
209
|
+
|
210
|
+
#
|
211
|
+
# <method description>
|
212
|
+
#
|
213
|
+
# <b>Parameters</b>
|
214
|
+
# - none
|
215
|
+
# <b>Returns</b>
|
216
|
+
# - String
|
217
|
+
#
|
218
|
+
def channel
|
219
|
+
return env.channel
|
220
|
+
end
|
221
|
+
|
222
|
+
#
|
223
|
+
# <method description>
|
224
|
+
#
|
225
|
+
# <b>Parameters</b>
|
226
|
+
# - none
|
227
|
+
# <b>Returns</b>
|
228
|
+
# - String
|
229
|
+
#
|
230
|
+
def language
|
231
|
+
return env.language
|
232
|
+
end
|
233
|
+
|
234
|
+
#
|
235
|
+
# <method description>
|
236
|
+
#
|
237
|
+
# <b>Parameters</b>
|
238
|
+
# - none
|
239
|
+
# <b>Returns</b>
|
240
|
+
# - String
|
241
|
+
#
|
242
|
+
def type
|
243
|
+
return env.type
|
244
|
+
end
|
245
|
+
|
246
|
+
#
|
247
|
+
# <method description>
|
248
|
+
#
|
249
|
+
# <b>Parameters</b>
|
250
|
+
# - none
|
251
|
+
# <b>Returns</b>
|
252
|
+
# - String
|
253
|
+
#
|
254
|
+
def uniqueid
|
255
|
+
return env.uniqueid
|
256
|
+
end
|
257
|
+
|
258
|
+
#
|
259
|
+
# method to read callerid, Ex. "John Smith" <1234567890>
|
260
|
+
# regardless of asterisk version, method callerid would return "Caller Name" <Number>
|
261
|
+
#
|
262
|
+
# <b>Parameters</b>
|
263
|
+
# - none
|
264
|
+
#
|
265
|
+
# <b>Returns</b>
|
266
|
+
# - String : empty string for Unidentified
|
267
|
+
#
|
268
|
+
def callerid
|
269
|
+
return env.callerid
|
270
|
+
end
|
271
|
+
|
272
|
+
#
|
273
|
+
# method to read calleridname, Ex. John Smith
|
274
|
+
#
|
275
|
+
# <b>Parameters</b>
|
276
|
+
# - none
|
277
|
+
#
|
278
|
+
# <b>Returns</b>
|
279
|
+
# - String : empty string for Unidentified
|
280
|
+
#
|
281
|
+
def calleridname
|
282
|
+
return env.calleridname
|
283
|
+
end
|
284
|
+
|
285
|
+
#
|
286
|
+
# method to read calleridnumber, Ex. 1234567890
|
287
|
+
#
|
288
|
+
# <b>Parameters</b>
|
289
|
+
# - none
|
290
|
+
#
|
291
|
+
# <b>Returns</b>
|
292
|
+
# - String : empty string for Unidentified
|
293
|
+
#
|
294
|
+
def calleridnumber
|
295
|
+
return env.calleridnumber
|
296
|
+
end
|
297
|
+
|
298
|
+
#
|
299
|
+
# <method description>
|
300
|
+
#
|
301
|
+
# <b>Parameters</b>
|
302
|
+
# - none
|
303
|
+
# <b>Returns</b>
|
304
|
+
# - String
|
305
|
+
#
|
306
|
+
def callingpres
|
307
|
+
return env.callingpres
|
308
|
+
end
|
309
|
+
|
310
|
+
#
|
311
|
+
# <method description>
|
312
|
+
#
|
313
|
+
# <b>Parameters</b>
|
314
|
+
# - none
|
315
|
+
# <b>Returns</b>
|
316
|
+
# - String
|
317
|
+
#
|
318
|
+
def callingani2
|
319
|
+
return env.callingani2
|
320
|
+
end
|
321
|
+
|
322
|
+
#
|
323
|
+
# <method description>
|
324
|
+
#
|
325
|
+
# <b>Parameters</b>
|
326
|
+
# - none
|
327
|
+
# <b>Returns</b>
|
328
|
+
# - String
|
329
|
+
#
|
330
|
+
def callington
|
331
|
+
return env.callington
|
332
|
+
end
|
333
|
+
|
334
|
+
#
|
335
|
+
# <method description>
|
336
|
+
#
|
337
|
+
# <b>Parameters</b>
|
338
|
+
# - none
|
339
|
+
# <b>Returns</b>
|
340
|
+
# - String
|
341
|
+
#
|
342
|
+
def callingtns
|
343
|
+
return env.callingtns
|
344
|
+
end
|
345
|
+
|
346
|
+
#
|
347
|
+
# <method description>
|
348
|
+
#
|
349
|
+
# <b>Parameters</b>
|
350
|
+
# - none
|
351
|
+
# <b>Returns</b>
|
352
|
+
# - String
|
353
|
+
#
|
354
|
+
def dnid
|
355
|
+
return env.dnid
|
356
|
+
end
|
357
|
+
|
358
|
+
#
|
359
|
+
# <method description>
|
360
|
+
#
|
361
|
+
# <b>Parameters</b>
|
362
|
+
# - none
|
363
|
+
# <b>Returns</b>
|
364
|
+
# - String
|
365
|
+
#
|
366
|
+
def rdnid
|
367
|
+
return env.rdnid
|
368
|
+
end
|
369
|
+
|
370
|
+
#
|
371
|
+
# <method description>
|
372
|
+
#
|
373
|
+
# <b>Parameters</b>
|
374
|
+
# - none
|
375
|
+
# <b>Returns</b>
|
376
|
+
# - String
|
377
|
+
#
|
378
|
+
def context
|
379
|
+
return env.context
|
380
|
+
end
|
381
|
+
|
382
|
+
#
|
383
|
+
# <method description>
|
384
|
+
#
|
385
|
+
# <b>Parameters</b>
|
386
|
+
# - none
|
387
|
+
# <b>Returns</b>
|
388
|
+
# - String
|
389
|
+
#
|
390
|
+
def extension
|
391
|
+
return env.extension
|
392
|
+
end
|
393
|
+
|
394
|
+
#
|
395
|
+
# <method description>
|
396
|
+
#
|
397
|
+
# <b>Parameters</b>
|
398
|
+
# - none
|
399
|
+
# <b>Returns</b>
|
400
|
+
# - String
|
401
|
+
#
|
402
|
+
def priority
|
403
|
+
return env.priority
|
404
|
+
end
|
405
|
+
|
406
|
+
#
|
407
|
+
# <method description>
|
408
|
+
#
|
409
|
+
# <b>Parameters</b>
|
410
|
+
# - none
|
411
|
+
# <b>Returns</b>
|
412
|
+
# - String
|
413
|
+
#
|
414
|
+
def enhanced
|
415
|
+
return env.enhanced
|
416
|
+
end
|
417
|
+
|
418
|
+
#
|
419
|
+
# <method description>
|
420
|
+
#
|
421
|
+
# <b>Parameters</b>
|
422
|
+
# - none
|
423
|
+
# <b>Returns</b>
|
424
|
+
# - String
|
425
|
+
#
|
426
|
+
def accountcode
|
427
|
+
return env.accountcode
|
428
|
+
end
|
429
|
+
|
430
|
+
#
|
431
|
+
# <method description>
|
432
|
+
#
|
433
|
+
# <b>Parameters</b>
|
434
|
+
# - str(String) : asterisk command in raw format to be executed
|
435
|
+
# <b>Returns</b>
|
436
|
+
# - ReturnStatus object
|
437
|
+
#
|
438
|
+
def raw_command(str)
|
439
|
+
return command.raw_command(str)
|
440
|
+
end
|
441
|
+
|
442
|
+
#
|
443
|
+
# Answers channel if not already in answer state.
|
444
|
+
#
|
445
|
+
# <b>Parameters</b>
|
446
|
+
# - none
|
447
|
+
#
|
448
|
+
# <b>Returns</b>
|
449
|
+
# - ReturnStatus object
|
450
|
+
#
|
451
|
+
def answer
|
452
|
+
return command.answer
|
453
|
+
end
|
454
|
+
|
455
|
+
#
|
456
|
+
# <method description>
|
457
|
+
#
|
458
|
+
# <b>Parameters</b>
|
459
|
+
# - val(Integer) : time in secconds
|
460
|
+
# <b>Returns</b>
|
461
|
+
# - ReturnStatus object
|
462
|
+
#
|
463
|
+
def set_auto_hangup(val)
|
464
|
+
return command.set_auto_hangup(val)
|
465
|
+
end
|
466
|
+
|
467
|
+
#
|
468
|
+
# Returns the status of the specified channel.
|
469
|
+
# If no channel name is given the returns the status of the current channel.
|
470
|
+
#
|
471
|
+
# <b>Parameters</b>
|
472
|
+
# - channel : name of the channel.
|
473
|
+
#
|
474
|
+
# <b>Returns</b>
|
475
|
+
# - ReturnStatus object
|
476
|
+
#
|
477
|
+
def channel_status(channel=nil)
|
478
|
+
return command.channel_status(channel)
|
479
|
+
end
|
480
|
+
|
481
|
+
#
|
482
|
+
# Executes <application> with given <options>.
|
483
|
+
# Applications are the functions you use to create a dial plan in extensions.conf.
|
484
|
+
#
|
485
|
+
# <b>Parameters</b>
|
486
|
+
# - application : Asterisk command of the application
|
487
|
+
# - options : options to be passed with the asterisk application
|
488
|
+
#
|
489
|
+
# <b>Returns</b>
|
490
|
+
# - ReturnStatus object
|
491
|
+
#
|
492
|
+
def exec(asterisk_application, options=nil)
|
493
|
+
return command.exec(asterisk_application, options)
|
494
|
+
end
|
495
|
+
|
496
|
+
#
|
497
|
+
# method to get digit(s)
|
498
|
+
# pressing '#' will always terminate the input process
|
499
|
+
#
|
500
|
+
# <b>Parameters</b>
|
501
|
+
# - filename : audio to be played before get as input
|
502
|
+
# - timeout : maximum allowed time in second(s) to receive each digit
|
503
|
+
# wait for ever if timeout is nil or negative or zero
|
504
|
+
# - max_digit: maximum number of digits to get as input
|
505
|
+
# wait for unlimited number of digits if max_digit is nil or negative or zero
|
506
|
+
# <b>Returns</b>
|
507
|
+
# - ReturnStatus object
|
508
|
+
#
|
509
|
+
def wait_for_digits(filename, timeout=nil, max_digit=nil)
|
510
|
+
return command.wait_for_digits(filename, timeout, max_digit)
|
511
|
+
end
|
512
|
+
|
513
|
+
#
|
514
|
+
# method to read a variable
|
515
|
+
#
|
516
|
+
# <b>Parameters</b>
|
517
|
+
# - name : name of the variable to read
|
518
|
+
#
|
519
|
+
# <b>Returns</b>
|
520
|
+
# - ReturnStatus object
|
521
|
+
#
|
522
|
+
def get_variable(name)
|
523
|
+
return command.get_variable(name)
|
524
|
+
end
|
525
|
+
|
526
|
+
#
|
527
|
+
# method to hang up the specified channel.
|
528
|
+
# If no channel name is given, hangs up the current channel.
|
529
|
+
#
|
530
|
+
# <b>Parameters</b>
|
531
|
+
# - channel : name of the channel to hang up
|
532
|
+
# <b>Returns</b>
|
533
|
+
# - ReturnStatus object
|
534
|
+
#
|
535
|
+
def hangup(channel=nil)
|
536
|
+
return command.hangup(channel)
|
537
|
+
end
|
538
|
+
|
539
|
+
#
|
540
|
+
# method that Does nothing !!
|
541
|
+
#
|
542
|
+
# <b>Parameters</b>
|
543
|
+
# - msg : message to pass this method
|
544
|
+
#
|
545
|
+
# <b>Returns</b>
|
546
|
+
# - ReturnStatus object
|
547
|
+
# success: 200 result=0
|
548
|
+
#
|
549
|
+
def noop(msg)
|
550
|
+
return command.noop(msg)
|
551
|
+
end
|
552
|
+
|
553
|
+
#
|
554
|
+
# Receives a character of text on a channel, and discards any further characters after the first one waiting.
|
555
|
+
# Most channels do not support the reception of text. See Asterisk Text for details.
|
556
|
+
#
|
557
|
+
# <b>Parameters</b>
|
558
|
+
# - timeout : maximum time to wait for input in seconds
|
559
|
+
# negative or zero is not acceptable
|
560
|
+
#
|
561
|
+
# <b>Returns</b>
|
562
|
+
# - ReturnStatus object
|
563
|
+
#
|
564
|
+
def receive_char(timeout)
|
565
|
+
return command.receive_char(timeout)
|
566
|
+
end
|
567
|
+
|
568
|
+
#
|
569
|
+
# Receives a string text on a channel.
|
570
|
+
# Most channels do not support the reception of text.
|
571
|
+
#
|
572
|
+
# <b>Parameters</b>
|
573
|
+
# - timeout : time to wait for input in seconds
|
574
|
+
# negative or zero is not acceptable
|
575
|
+
#
|
576
|
+
# <b>Returns</b>
|
577
|
+
# - ReturnStatus object
|
578
|
+
#
|
579
|
+
def receive_text(timeout)
|
580
|
+
return command.receive_text(timeout)
|
581
|
+
end
|
582
|
+
|
583
|
+
#
|
584
|
+
# Record to a file until <escape digits> are received as dtmf.
|
585
|
+
#
|
586
|
+
# <b>Parameters</b>
|
587
|
+
# - filename : location of the file where the audio file will be saved
|
588
|
+
# - format : specify what kind of file will be recorded.
|
589
|
+
# - timeout : maximum record time in seconds
|
590
|
+
# nil, negative or 0 for no timeout.
|
591
|
+
# - offset : [offset samples] is optional,
|
592
|
+
# and if provided will seek to the offset without exceeding the end of the file.
|
593
|
+
# - silence : number of seconds of silence allowed before the function returns
|
594
|
+
# despite the lack of dtmf digits or reaching timeout.
|
595
|
+
# Silence value must be preceeded by "s=" and is optional.
|
596
|
+
#
|
597
|
+
# <b>Returns</b>
|
598
|
+
# - ReturnStatus object
|
599
|
+
#
|
600
|
+
def record_file(filename, format='gsm', escape_digits=nil, timeout=nil, beep=true)
|
601
|
+
return command.record_file(filename, format, escape_digits, timeout, beep)
|
602
|
+
end
|
603
|
+
|
604
|
+
#
|
605
|
+
# Say a given digit string, returning early if any of the given DTMF digits are received on the channel.
|
606
|
+
#
|
607
|
+
# <b>Parameters</b>
|
608
|
+
# - number : number to announce
|
609
|
+
# - escape_digit : if digit pressed during playback, will return from announce
|
610
|
+
#
|
611
|
+
# <b>Returns</b>
|
612
|
+
# - ReturnStatus (object)
|
613
|
+
#
|
614
|
+
# failure: 200 result=-1
|
615
|
+
# success: 200 result=0
|
616
|
+
# digit pressed: 200 result=<digit>
|
617
|
+
# <digit> is the ascii code for the digit pressed.
|
618
|
+
#
|
619
|
+
def say_digits(digit_string, escape_digits=nil)
|
620
|
+
return command.say_digits(digit_string, escape_digits)
|
621
|
+
end
|
622
|
+
|
623
|
+
#
|
624
|
+
# Say a given number, returning early if any of the given DTMF digits are received on the channel.
|
625
|
+
#
|
626
|
+
# <b>Parameters</b>
|
627
|
+
# - number : number to announce
|
628
|
+
# - escape_digit : if pressed, return from program
|
629
|
+
#
|
630
|
+
# <b>Returns</b>
|
631
|
+
# - ReturnStatus object
|
632
|
+
#
|
633
|
+
def say_number(number, escape_digits=nil)
|
634
|
+
return command.say_number(number, escape_digits)
|
635
|
+
end
|
636
|
+
|
637
|
+
#
|
638
|
+
# Say a given character string with phonetics, returning early if any of the given DTMF digits are received on the channel.
|
639
|
+
#
|
640
|
+
# <b>Parameters</b>
|
641
|
+
# - string : character string to announce
|
642
|
+
# - escape_digit : digit to be pressed to escape from program
|
643
|
+
#
|
644
|
+
# <b>Returns</b>
|
645
|
+
# - ReturnStatus (object)
|
646
|
+
#
|
647
|
+
def say_phonetic(string, escape_digits=nil)
|
648
|
+
return command.say_phonetic(string, escape_digits)
|
649
|
+
end
|
650
|
+
|
651
|
+
#
|
652
|
+
# Say a given time, returning early if any of the given DTMF digits are received on the channel.
|
653
|
+
#
|
654
|
+
# <b>Parameters</b>
|
655
|
+
# - time : number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
|
656
|
+
# - escape_digits : digit to be pressed to escape from the program
|
657
|
+
#
|
658
|
+
# <b>Returns</b>
|
659
|
+
# - ReturnStatus (object)
|
660
|
+
#
|
661
|
+
def say_time(time=Time.now.to_i, escape_digits='#')
|
662
|
+
return command.say_time(time, escape_digits)
|
663
|
+
end
|
664
|
+
|
665
|
+
#
|
666
|
+
# Sends the given image on a channel.
|
667
|
+
# Most channels do not support the transmission of images.
|
668
|
+
# Image names should not include extensions.
|
669
|
+
#
|
670
|
+
# <b>Parameters</b>
|
671
|
+
# - image : location of image
|
672
|
+
#
|
673
|
+
# <b>Returns</b>
|
674
|
+
# - ReturnStatus (object)
|
675
|
+
#
|
676
|
+
def send_image(image)
|
677
|
+
return command.send_image(image)
|
678
|
+
end
|
679
|
+
|
680
|
+
#
|
681
|
+
# Sends the given text on a channel.
|
682
|
+
# Most channels do not support the transmission of text.
|
683
|
+
# Text consisting of greater than one word should be placed in quotes since the command only accepts a single argument.
|
684
|
+
#
|
685
|
+
# <b>Parameters</b>
|
686
|
+
# - text : text to be send
|
687
|
+
#
|
688
|
+
# <b>Returns</b>
|
689
|
+
# - ReturnStatus (object)
|
690
|
+
#
|
691
|
+
def send_text(text)
|
692
|
+
return command.send_text(text)
|
693
|
+
end
|
694
|
+
|
695
|
+
#
|
696
|
+
# Changes the callerid of the current channel.
|
697
|
+
#
|
698
|
+
# <b>Parameters</b>
|
699
|
+
# - number : number to be set a callerid
|
700
|
+
#
|
701
|
+
# <b>Returns</b>
|
702
|
+
# - ReturnStatus (object)
|
703
|
+
#
|
704
|
+
def set_caller_id(number)
|
705
|
+
return command.set_caller_id(number)
|
706
|
+
end
|
707
|
+
|
708
|
+
#
|
709
|
+
# Sets the context for continuation upon exiting the application.
|
710
|
+
#
|
711
|
+
# <b>Parameters</b>
|
712
|
+
# - context : name of the context
|
713
|
+
#
|
714
|
+
# <b>Returns</b>
|
715
|
+
# - ReturnStatus object
|
716
|
+
#
|
717
|
+
def set_context(context)
|
718
|
+
return command.set_context(context)
|
719
|
+
end
|
720
|
+
|
721
|
+
#
|
722
|
+
# Changes the extension for continuation upon exiting the application.
|
723
|
+
#
|
724
|
+
# <b>Parameters</b>
|
725
|
+
# - extension: name or number of extension to be set
|
726
|
+
#
|
727
|
+
# <b>Returns</b>
|
728
|
+
# - ReturnStatus object
|
729
|
+
#
|
730
|
+
def set_extension(extension)
|
731
|
+
return command.set_extension(extension)
|
732
|
+
end
|
733
|
+
|
734
|
+
#
|
735
|
+
# Changes the priority for continuation upon exiting the application.
|
736
|
+
#
|
737
|
+
# <b>Parameters</b>
|
738
|
+
# - priority : number of priority
|
739
|
+
#
|
740
|
+
# <b>Returns</b>
|
741
|
+
# - ReturnStatus object
|
742
|
+
def set_priority(priority)
|
743
|
+
return command.set_priority(priority)
|
744
|
+
end
|
745
|
+
|
746
|
+
#
|
747
|
+
# Enables/Disables the music on hold generator.
|
748
|
+
#
|
749
|
+
# <b>Parameters</b>
|
750
|
+
# - mode : on or off
|
751
|
+
# - moh_class : name of the music on hold class
|
752
|
+
# 'default' for not provided or nil
|
753
|
+
#
|
754
|
+
# <b>Returns</b>
|
755
|
+
# - ReturnStatus object
|
756
|
+
#
|
757
|
+
def set_music(mode=true, moh_class='default')
|
758
|
+
return command.set_music(mode, moh_class)
|
759
|
+
end
|
760
|
+
|
761
|
+
#
|
762
|
+
# set variable: Sets a channel variable
|
763
|
+
# These variables live in the channel Asterisk creates
|
764
|
+
# when you pickup a phone and as such they are both local
|
765
|
+
# and temporary. Variables created in one channel can not
|
766
|
+
# be accessed by another channel. When you hang up the phone,
|
767
|
+
# the channel is deleted and any variables in that channel are deleted as well.
|
768
|
+
#
|
769
|
+
# <b>Parameters</b>
|
770
|
+
# - variablename : name of the variable
|
771
|
+
# - value : value to be set for the variable
|
772
|
+
#
|
773
|
+
# <b>Returns</b>
|
774
|
+
# - ReturnStatus object
|
775
|
+
#
|
776
|
+
def set_variable(name, value)
|
777
|
+
return command.set_variable(name, value)
|
778
|
+
end
|
779
|
+
|
780
|
+
#
|
781
|
+
# stream file: Sends audio file on channel
|
782
|
+
# Send the given file, allowing playback to be interrupted by the given digits, if any.
|
783
|
+
# Use double quotes for the digits if you wish none to be permitted.
|
784
|
+
# If sample offset is provided then the audio will seek to sample offset before play starts.
|
785
|
+
# Remember, the file extension must not be included in the filename.
|
786
|
+
#
|
787
|
+
# <b>Parameters</b>
|
788
|
+
# - filename : location of the file to be played
|
789
|
+
# - escape_digit: digit to be pressed to escape from playback
|
790
|
+
#
|
791
|
+
# <b>Returns</b>
|
792
|
+
# - ReturnStatus object
|
793
|
+
#
|
794
|
+
def stream_file(filename, escape_digits='#')
|
795
|
+
return command.stream_file(filename, escape_digits)
|
796
|
+
end
|
797
|
+
|
798
|
+
#
|
799
|
+
# tdd mode: Activates TDD mode on channels supporting it, to enable communication with TDDs.
|
800
|
+
# Enable/Disable TDD transmission/reception on a channel.
|
801
|
+
# This function is currently (01July2005) only supported on Zap channels.
|
802
|
+
# As of 02July2005, this function never returns 0 (Not Capable).
|
803
|
+
# If it fails for any reason, -1 (Failure) will be returned, otherwise 1 (Success) will be returned.
|
804
|
+
# The capability for returning 0 if the channel is not capable of TDD MODE is a future plan.
|
805
|
+
#
|
806
|
+
# <b>Parameters</b>
|
807
|
+
# - mode : mode of the tdd to be set
|
808
|
+
# set tdd on if non-zero or 'true' specified
|
809
|
+
#
|
810
|
+
# <b>Returns</b>
|
811
|
+
# - ReturnStatus object
|
812
|
+
#
|
813
|
+
def tdd_mode(settings=true)
|
814
|
+
return command.tdd_mode(settings)
|
815
|
+
end
|
816
|
+
|
817
|
+
#
|
818
|
+
# Sends <message> to the console via verbose message system.
|
819
|
+
# The Asterisk verbosity system works as follows.
|
820
|
+
# The Asterisk user gets to set the desired verbosity at startup time
|
821
|
+
# or later using the console 'set verbose' command.
|
822
|
+
# Messages are displayed on the console if their verbose level
|
823
|
+
# is less than or equal to desired verbosity set by the user.
|
824
|
+
# More important messages should have a low verbose level;
|
825
|
+
# less important messages should have a high verbose level.
|
826
|
+
#
|
827
|
+
# <b>Parameters</b>
|
828
|
+
# - message : message to be send as log
|
829
|
+
# - level : verbose level to be set
|
830
|
+
# [level] is the the verbose level (1-4)
|
831
|
+
# If you specify a verbose level less than 1 or greater than 4, the verbosity is 1.
|
832
|
+
# The default verbosity seems to be 0 (in 1.0.8),
|
833
|
+
# and supplying a 0 (zero) verbosity does work:
|
834
|
+
# the message will be displayed regardless of the console verbosity setting.
|
835
|
+
#
|
836
|
+
# <b>Returns</b>
|
837
|
+
# - ReturnStatus object
|
838
|
+
#
|
839
|
+
def verbose(message, level=3)
|
840
|
+
return command.verbose(message, level)
|
841
|
+
end
|
842
|
+
|
843
|
+
#
|
844
|
+
# wait for digit: Waits for a digit to be pressed
|
845
|
+
# Waits up to <timeout> milliseconds for channel to receive a DTMF digit.
|
846
|
+
#
|
847
|
+
# <b>Parameters</b>
|
848
|
+
# - timeout : maximum allow waiting time in seconds to get input
|
849
|
+
# nil, zero or negative would be considered as infinite wait time
|
850
|
+
#
|
851
|
+
# <b>Returns</b>
|
852
|
+
# - ReturnStatus object
|
853
|
+
#
|
854
|
+
def wait_for_digit(timeout=nil)
|
855
|
+
return command.wait_for_digit(timeout)
|
856
|
+
end
|
857
|
+
|
858
|
+
#
|
859
|
+
# method to dial out
|
860
|
+
#
|
861
|
+
# <b>Parameters</b>
|
862
|
+
# - telephone_number : telephone_number or extension to dial
|
863
|
+
# - protocol : protocol to be used to make this call
|
864
|
+
# - username : username to be used to make this call using the specified protocol
|
865
|
+
# - context : name of the context to be used for authentication
|
866
|
+
# - timeout : maximum allowed time in seconds to make this call
|
867
|
+
# - options : options to be passed in 'Dial' command
|
868
|
+
#
|
869
|
+
# <b>Returns</b>
|
870
|
+
# - ReturnStatus object
|
871
|
+
#
|
872
|
+
def dial(telephone_number=nil, protocol=nil, username=nil, context=nil, timeout=nil, options=nil)
|
873
|
+
return command.dial(telephone_number, protocol, username, context, timeout, options)
|
874
|
+
end
|
875
|
+
|
876
|
+
#
|
877
|
+
# method to jump in a specified context, extension and priority
|
878
|
+
#
|
879
|
+
# <b>Parameters</b>
|
880
|
+
# - context : name of the context
|
881
|
+
# - extension : name of the extension
|
882
|
+
# - priority : name of the priority
|
883
|
+
#
|
884
|
+
# <b>Returns</b>
|
885
|
+
# - none
|
886
|
+
#
|
887
|
+
def jump_to(context=nil, extension=nil, priority=nil)
|
888
|
+
command.jump_to(context, extension, priority)
|
889
|
+
end
|
890
|
+
end
|
891
|
+
|