File Coverage

blib/lib/VoiceXML/Client/Item/Record.pm
Criterion Covered Total %
statement 12 31 38.7
branch 0 4 0.0
condition 0 16 0.0
subroutine 4 6 66.6
pod 1 2 50.0
total 17 59 28.8


line stmt bran cond sub pod time code
1              
2             package VoiceXML::Client::Item::Record;
3              
4              
5 3     3   18 use strict;
  3         7  
  3         119  
6              
7 3     3   19 use base qw (VoiceXML::Client::Item);
  3         9  
  3         220  
8 3     3   17 use VoiceXML::Client::Util;
  3         6  
  3         101  
9              
10             =head1 COPYRIGHT AND LICENSE
11              
12            
13             Copyright (C) 2007,2008 by Pat Deegan.
14             All rights reserved
15             http://voicexml.psychogenic.com
16              
17             This library is released under the terms of the GNU GPL version 3, making it available only for
18             free programs ("free" here being used in the sense of the GPL, see http://www.gnu.org for more details).
19             Anyone wishing to use this library within a proprietary or otherwise non-GPLed program MUST contact psychogenic.com to
20             acquire a distinct license for their application. This approach encourages the use of free software
21             while allowing for proprietary solutions that support further development.
22              
23              
24             This file is part of VoiceXML::Client.
25              
26            
27            
28             VoiceXML::Client is free software: you can redistribute it and/or modify
29             it under the terms of the GNU General Public License as published by
30             the Free Software Foundation, either version 3 of the License, or
31             (at your option) any later version.
32              
33             VoiceXML::Client is distributed in the hope that it will be useful,
34             but WITHOUT ANY WARRANTY; without even the implied warranty of
35             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36             GNU General Public License for more details.
37              
38             You should have received a copy of the GNU General Public License
39             along with VoiceXML::Client. If not, see .
40              
41              
42             =cut
43              
44              
45              
46              
47 3         1089 use vars qw{
48             $BeepFrequency
49             $BeepMilliseconds
50             $VERSION
51 3     3   15 };
  3         7  
52              
53             $BeepFrequency = 400;
54             $BeepMilliseconds = 1000;
55              
56             $VERSION = $VoiceXML::Client::Item::VERSION;
57              
58              
59              
60              
61              
62             sub init {
63 0     0 1   my $self = shift;
64            
65 0   0       $self->{'name'} = $self->{'XMLElement'}->attribute('name') || warn "No record name specified";
66 0   0       $self->{'beep'} = $self->{'XMLElement'}->attribute('beep') || 'true';
67 0   0       $self->{'maxtime'} = $self->{'XMLElement'}->attribute('maxtime') || '10s';
68 0   0       $self->{'dtmfterm'} = $self->{'XMLElement'}->attribute('dtmfterm') || 'true';
69 0   0       $self->{'finalsilence'} = $self->{'XMLElement'}->attribute('finalsilence') || '4000ms';
70 0   0       $self->{'type'} = $self->{'XMLElement'}->attribute('type') || 'audio/x-wav';
71            
72            
73 0           return 1;
74            
75            
76             }
77              
78              
79             sub execute {
80 0     0 0   my $self = shift;
81 0           my $handle = shift;
82 0           my $optParams = shift;
83            
84 0 0         unless ($self->{'name'})
85             {
86 0           warn "Record::execute called but no name set?";
87            
88 0           return $VoiceXML::Client::Flow::Directive{'ABORT'};
89             }
90            
91 0 0 0       if ($self->{'beep'} && $self->{'beep'} =~ m/true/i)
92             {
93 0           $handle->beep($BeepFrequency, $BeepMilliseconds);
94             }
95            
96 0           $handle->record($self->{'name'});
97            
98 0           chmod 0666, $self->{'name'};
99            
100 0           return $self->executeChildren($handle, $optParams);
101             }
102            
103              
104             1;