line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package VoiceXML::Client::Item::If; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
18
|
use base qw (VoiceXML::Client::Item); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
226
|
|
6
|
3
|
|
|
3
|
|
17
|
use VoiceXML::Client::Util; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
59
|
|
7
|
3
|
|
|
3
|
|
1849
|
use VoiceXML::Client::Item::Util; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
118
|
|
8
|
|
|
|
|
|
|
|
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
|
3
|
|
|
3
|
|
20
|
use strict; |
|
3
|
|
|
|
|
35
|
|
|
3
|
|
|
|
|
105
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
3
|
|
|
|
|
1628
|
use vars qw{ |
50
|
|
|
|
|
|
|
$VERSION |
51
|
3
|
|
|
3
|
|
16
|
}; |
|
3
|
|
|
|
|
5
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$VERSION = $VoiceXML::Client::Item::VERSION; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub init { |
59
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
6
|
my $cond = $self->{'XMLElement'}->attribute('cond'); |
62
|
|
|
|
|
|
|
|
63
|
1
|
50
|
|
|
|
14
|
unless (defined $cond) |
64
|
|
|
|
|
|
|
{ |
65
|
0
|
|
|
|
|
0
|
VoiceXML::Client::Util::log_msg("No condition set in IF clause"); |
66
|
0
|
|
|
|
|
0
|
return undef; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
8
|
$self->{'cond'} = $cond; |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
4
|
return 1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub execute { |
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
79
|
0
|
|
|
|
|
|
my $handle = shift; |
80
|
0
|
|
|
|
|
|
my $optParms = shift; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
my $vxmlDoc = $self->getParentVXMLDocument(); |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$self->reset(); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# check if the IF condition is met... |
87
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
if ($self->evaluateCondition($self->{'cond'}, $vxmlDoc)) |
89
|
|
|
|
|
|
|
{ |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
while (my $curChild = $self->getNextSameLevelChild()) |
93
|
|
|
|
|
|
|
{ |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
my $rv = $curChild->execute($handle, $optParms); |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
return $rv if ($rv != $VoiceXML::Client::Flow::Directive{'CONTINUE'}); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return $VoiceXML::Client::Flow::Directive{'CONTINUE'}; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# if condition not met... if we have any kids |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
while (my $condChild = $self->getNextConditionChild()) |
106
|
|
|
|
|
|
|
{ |
107
|
0
|
|
|
|
|
|
my $matchFound = 0; |
108
|
0
|
0
|
|
|
|
|
if (exists $condChild->{'cond'}) |
109
|
|
|
|
|
|
|
{ |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
if ($self->evaluateCondition($condChild->{'cond'}, $vxmlDoc)) |
112
|
|
|
|
|
|
|
{ |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# we've found a good one. |
115
|
0
|
|
|
|
|
|
$matchFound = 1; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} else { |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# it's an else... |
120
|
0
|
|
|
|
|
|
$matchFound = 1; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
|
if ($matchFound) |
124
|
|
|
|
|
|
|
{ |
125
|
|
|
|
|
|
|
# got a good one... |
126
|
0
|
|
|
|
|
|
while (my $sChild = $self->getNextSameLevelChild()) |
127
|
|
|
|
|
|
|
{ |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my $rv = $sChild->execute($handle, $optParms); |
130
|
0
|
0
|
|
|
|
|
return $rv if ($rv != $VoiceXML::Client::Flow::Directive{'CONTINUE'}); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# and we're done. |
136
|
0
|
|
|
|
|
|
return $VoiceXML::Client::Flow::Directive{'CONTINUE'}; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
#if we get here... nothing matched/there's nothing to do. |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
return $VoiceXML::Client::Flow::Directive{'CONTINUE'}; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub getNextSameLevelChild { |
148
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
while (my $curChild = $self->getCurrentChild()) |
151
|
|
|
|
|
|
|
{ |
152
|
0
|
|
|
|
|
|
$self->proceedToNextChild(); |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
my $ctype = $curChild->getType() ; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
0
|
0
|
0
|
|
|
|
if ($ctype eq 'VoiceXML::Client::Item::Elseif' |
158
|
|
|
|
|
|
|
|| $ctype eq 'VoiceXML::Client::Item::Else') |
159
|
|
|
|
|
|
|
{ |
160
|
|
|
|
|
|
|
# party's over... |
161
|
0
|
|
|
|
|
|
return undef; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
return $curChild ; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
return undef; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub getNextConditionChild { |
172
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
while (my $curChild = $self->getCurrentChild()) |
176
|
|
|
|
|
|
|
{ |
177
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
$self->proceedToNextChild(); |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
my $ctype = $curChild->getType() ; |
182
|
0
|
0
|
0
|
|
|
|
return $curChild if ($ctype eq 'VoiceXML::Client::Item::Elseif' |
183
|
|
|
|
|
|
|
|| $ctype eq 'VoiceXML::Client::Item::Else'); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
return undef; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub evaluateCondition { |
192
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
193
|
0
|
|
0
|
|
|
|
my $condition = shift || ''; |
194
|
0
|
|
0
|
|
|
|
my $vxmlDoc = shift || $self->getParentVXMLDocument(); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
return VoiceXML::Client::Item::Util->evaluateCondition($self, $condition, $vxmlDoc); |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
1; |