Client/Device/Dummy.pm

filter: Statementstmt 16.1% 11 / 68 Branchbran 25.0% 1 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 18.7% 3 / 16 Podpod 64.2% 9 / 14 totaltotal 22.8% 24 / 105 CC 4 SCAR 10.1
CC
4
Cov
16%
connect
6.0
readnum
6.0
disconnect
2.0
CRAP 2.7
« Client/Item/Return.pm ↑ Summary Client/Item/Factory.pm »
1 package VoiceXML::Client::Device::Dummy;
2  
3  
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use base qw(VoiceXML::Client::DeviceHandle);
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8  
9 =head1 VoiceXML::Client::Device::Dummy
10  
11 =head1 NAME
12  
13 VoiceXML::Client::Device::Dummy -- a minimally functional implementation the DeviceHandle interface
14  
15  
16  
17  
18 =head1 COPYRIGHT AND LICENSE
19  
20  
21 VoiceXML::Client::DeviceHandle module, device handle api based on the VOCP voice messaging system package
22 VOCP::Device.
23
24 Copyright (C) 2002,2008 Patrick Deegan
25 All rights reserved
26  
27  
28 This file is part of VoiceXML::Client.
29
30 VoiceXML::Client is free software: you can redistribute it and/or modify
31 it under the terms of the GNU General Public License as published by
32 the Free Software Foundation, either version 3 of the License, or
33 (at your option) any later version.
34  
35 VoiceXML::Client is distributed in the hope that it will be useful,
36 but WITHOUT ANY WARRANTY; without even the implied warranty of
37 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 GNU General Public License for more details.
39  
40 You should have received a copy of the GNU General Public License
41 along with VoiceXML::Client. If not, see <http://www.gnu.org/licenses/>.
42  
43  
44  
45  
46 =cut
47  
48  
49  
50 0 ▶sub connect {
Subroutine connect: not called CC=2 SCAR=17.9
Pod undocumented
51 0 my $self = shift;
52 0 my $params = shift;
53
54 0 ▶ print "VoiceXML::Client::Device::Dummy::connect() called\n"
Branch: 1 branch
BranchTrueFalseTotal
if $VoiceXML::Client::Debug 0 0 0
55 if ($VoiceXML::Client::Debug);
56
57 0 return 1;
58 }
59  
60  
61 3 ▶sub disconnect {
Subroutine disconnect: called CC=2 SCAR=7.0
Pod undocumented
62 3 my $self = shift;
63 3 my $params = shift;
64
65 3 ▶ print "VoiceXML::Client::Device::Dummy::disconnect()\n"
Branch: 1 branch
BranchTrueFalseTotal
if $VoiceXML::Client::Debug 0 3 3
66 if ($VoiceXML::Client::Debug);
67
68 3 return 1;
69 }
70  
71  
72  
73 =head2 beep FREQUENCY LENGTH
74  
75 Sends a beep through the chosen device using given frequency (HZ) and length (in miliseconds). Returns a defined
76 and true value on success.
77  
78 =cut
79  
80 0 ▶sub beep {
Subroutine beep: not called CC=1 SCAR=6.9
Pod documented
81 0 my $self = shift;
82 0 my $frequency = shift;
83 0 my $length = shift;
84
85 0 print "VoiceXML::Client::Device::Dummy::beep($frequency, $length)\n";
86
87 0 return 1;
88 }
89  
90  
91  
92 =head2 dial DESTINATION
93  
94 Connects to destination. Returns defined & true on success.
95  
96 =cut
97  
98 0 ▶sub dial {
Subroutine dial: not called CC=1 SCAR=6.9
Pod documented
99 0 my $self = shift;
100 0 my $destination = shift;
101
102 0 print "dialing ($destination)\n";
103
104 0 return 1;
105 }
106  
107  
108 =head2 play PLAYPARAM
109  
110 plays a sound (file, text-to-speech, whatever is appropriate) base on PLAYPARAM. May or may not block during
111 play depending on device implementation. Returns true on success.
112  
113 =cut
114  
115 0 ▶sub play {
Subroutine play: not called CC=1 SCAR=6.9
Pod documented
116 0 my $self = shift;
117 0 my $playthis = shift;
118 0 my $type = shift;
119
120
121 0 print "Playing ($playthis)\n";
122
123 0 return 1;
124 }
125  
126  
127 =head2 record TOFILE
128  
129 Records input from user to device to file TOFILE. Returns true on success.
130  
131 =cut
132  
133 0 ▶sub record {
Subroutine record: not called CC=1 SCAR=6.9
Pod documented
134 0 my $self = shift;
135 0 my $tofile = shift;
136
137
138 0 print "Recording ($tofile) \n";
139
140 0 return 1;
141 }
142  
143  
144 =head2 wait TIME
145  
146 Simply waits for TIME seconds. Device should accept/queue user input
147 during interval.
148  
149 =cut
150  
151 0 ▶sub wait {
Subroutine wait: not called CC=1 SCAR=6.9
Pod documented
152 0 my $self = shift;
153 0 my $time = shift;
154
155
156 0 print "Waiting ($time)\n";
157
158 0 return 1;
159 }
160  
161  
162 =head2 waitFor STATE
163  
164 Waits until STATE is reached/returned by device. Device should accept/queue user input
165 during interval.
166  
167 =cut
168  
169 0 ▶sub waitFor {
Subroutine waitFor: not called CC=1 SCAR=6.9
Pod documented
170 0 my $self = shift;
171 0 my $state = shift;
172
173 0 print "WaitFor($state)\n";
174
175 0 return 1;
176 }
177  
178 =head2 stop
179  
180 Immediately stop any current activity (wait, play, record, etc.).
181  
182 =cut
183 0 ▶sub stop {
Subroutine stop: not called CC=1 SCAR=6.9
Pod documented
184 0 my $self = shift;
185
186
187 0 print "Stop()\n";
188
189 0 return 1;
190 }
191  
192 =head2 blocking_play PLAYTHIS
193  
194 play PLAYTHIS and return only when done.
195  
196 =cut
197  
198 0 ▶sub blockingPlay {
Subroutine blockingPlay: not called CC=1 SCAR=6.9
Pod undocumented
199 0 my $self = shift;
200 0 my $playthis = shift;
201 0 my $type = shift;
202
203
204 0 print "Playing ($playthis)... blocked\n";
205
206 0 return 1;
207 }
208  
209  
210  
211  
212 =head2 readnum PLAYTHIS TIMEOUT [REPEATTIMES]
213  
214 Plays the PLAYTHIS and then waits for the sequence of the digit input finished. If none are entered within TIMEOUT
215 seconds, it re-plays the message again. It returns failure (undefined value) if no digits are entered after the message
216 has been played REPEATTIMES (defaults to 3) times.
217  
218  
219 It returns a string (a sequence of DTMF tones 0-9,A-D and `*') without the final stop key (normally '#').
220  
221  
222 =cut
223  
224  
225 0 ▶sub readnum {
Subroutine readnum: not called CC=2 SCAR=17.9
Pod documented
226 0 my $self = shift;
227 0 my $playthis = shift;
228 0 my $timeout = shift;
229 0 ▶ my $repeatTimes = shift || 3;
Condition0%0/2
shift() || 3
l!l
00
MC/DC0%0/1
shift() || 3
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
230
231
232 0 print STDOUT "\nEnter DTMF Selection ([0-9]+<ENTER>):";
233 0 my $num = <STDIN>;
234 0 chomp($num);
235 0 $num =~ s/[^\d\*]+//g;
236  
237  
238 0 return $num;
239  
240 }
241  
242  
243 =head2 validDataFormats
244  
245 Returns an array ref of valid data formats (eg 'rmd', 'wav', 'au') the device will accept.
246  
247 =cut
248  
249 0 ▶sub validDataFormats {
Subroutine validDataFormats: not called CC=1 SCAR=6.9
Pod documented
250 0 my $self = shift;
251
252 0 print "ValidDataFormats() queried\n";
253
254 0 return ['rmd', 'wav', 'mp3'];
255 }
256  
257  
258  
259 0 ▶sub receiveImage {
Subroutine receiveImage: not called CC=1 SCAR=6.9
Pod undocumented
260 0 my $self = shift;
261
262 0 print "ReceiveImage()\n";
263
264 0 return 1;
265 }
266  
267  
268 # Not sure what to do with this method... how do you support faxes while abstracting the modem voice device??
269 0 ▶sub sendImage {
Subroutine sendImage: not called CC=1 SCAR=6.9
Pod undocumented
270 0 my $self = shift;
271 0 my $file = shift;
272
273 0 print "SendImage()\n";
274
275 0 return 1;
276 }
277  
278  
279  
280 3 1;
« Client/Item/Return.pm ↑ Summary Client/Item/Factory.pm »