| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | package VoiceXML::Client::Item::SubDialog; | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 3 |  |  | 3 |  | 17 | use base qw (VoiceXML::Client::Item); | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 225 |  | 
| 6 | 3 |  |  | 3 |  | 19 | use VoiceXML::Client::Util; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 61 |  | 
| 7 | 3 |  |  | 3 |  | 15 | use VoiceXML::Client::Item::Util; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 89 |  | 
| 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 |  | 15 | use strict; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 97 |  | 
| 47 |  |  |  |  |  |  |  | 
| 48 | 3 |  |  |  |  | 1655 | use vars qw{ | 
| 49 |  |  |  |  |  |  | $VERSION | 
| 50 | 3 |  |  | 3 |  | 14 | }; | 
|  | 3 |  |  |  |  | 6 |  | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | $VERSION = '1.02'; | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | sub init { | 
| 58 | 1 |  |  | 1 | 1 | 2 | my $self = shift; | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 1 |  |  |  |  | 4 | my $src = $self->{'XMLElement'}->attribute('src'); | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 1 | 50 | 33 |  |  | 19 | unless ( (defined $src) && length($src)) | 
| 63 |  |  |  |  |  |  | { | 
| 64 | 0 |  |  |  |  | 0 | VoiceXML::Client::Util::log_msg("subdialog item must have 'src' set."); | 
| 65 | 0 |  |  |  |  | 0 | return undef; | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 | 1 |  |  |  |  | 3 | $self->{'src'} = $src; | 
| 69 |  |  |  |  |  |  |  | 
| 70 | 1 |  |  |  |  | 4 | my $cond = $self->{'XMLElement'}->attribute('cond'); | 
| 71 | 1 | 50 | 33 |  |  | 39 | if (defined $cond && length($cond)) | 
| 72 |  |  |  |  |  |  | { | 
| 73 | 0 |  |  |  |  | 0 | $self->{'cond'} = $cond; | 
| 74 |  |  |  |  |  |  | } | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  |  | 
| 77 | 1 |  |  |  |  | 5 | return 1; | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | sub execute { | 
| 83 | 1 |  |  | 1 | 0 | 2 | my $self = shift; | 
| 84 | 1 |  |  |  |  | 2 | my $handle = shift; | 
| 85 | 1 |  |  |  |  | 1 | my $optParams = shift; | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  |  | 
| 88 | 1 |  |  |  |  | 8 | my $vxmlDoc = $self->getParentVXMLDocument(); | 
| 89 |  |  |  |  |  |  |  | 
| 90 | 1 | 50 |  |  |  | 4 | if (exists $self->{'cond'}) | 
| 91 |  |  |  |  |  |  | { | 
| 92 | 0 | 0 |  |  |  | 0 | return $VoiceXML::Client::Flow::Directive{'CONTINUE'} | 
| 93 |  |  |  |  |  |  | unless ($self->evaluateCondition($self->{'cond'}, $vxmlDoc)); | 
| 94 |  |  |  |  |  |  | } | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  |  | 
| 97 | 1 |  |  |  |  | 3 | my $src = $self->{'src'}; | 
| 98 |  |  |  |  |  |  |  | 
| 99 | 1 |  |  |  |  | 2 | my $formID; | 
| 100 | 1 | 50 |  |  |  | 7 | if ($src =~ m/^#(.+)/) | 
| 101 |  |  |  |  |  |  | { | 
| 102 | 1 |  |  |  |  | 3 | $formID = $1; | 
| 103 |  |  |  |  |  |  | } else { | 
| 104 | 0 |  |  |  |  | 0 | VoiceXML::Client::Util::log_msg("Subdialog::execute() can only handle #internal src for now"); | 
| 105 | 0 |  |  |  |  | 0 | return $VoiceXML::Client::Flow::Directive{'CONTINUE'}; | 
| 106 |  |  |  |  |  |  | } | 
| 107 |  |  |  |  |  |  |  | 
| 108 | 1 |  |  |  |  | 6 | my $form = $vxmlDoc->getForm($formID); | 
| 109 |  |  |  |  |  |  |  | 
| 110 | 1 | 50 |  |  |  | 3 | if (! $form ) | 
| 111 |  |  |  |  |  |  | { | 
| 112 |  |  |  |  |  |  |  | 
| 113 | 0 |  |  |  |  | 0 | VoiceXML::Client::Util::log_msg("Subdialog::execute() can not find form $formID in document"); | 
| 114 | 0 |  |  |  |  | 0 | return $VoiceXML::Client::Flow::Directive{'CONTINUE'}; | 
| 115 |  |  |  |  |  |  | } | 
| 116 |  |  |  |  |  |  |  | 
| 117 | 1 | 50 |  |  |  | 5 | if ($self->{'parent'}) | 
| 118 |  |  |  |  |  |  | { | 
| 119 | 1 |  |  |  |  | 22 | $self->{'parent'}->proceedToNextChild(); | 
| 120 |  |  |  |  |  |  | } | 
| 121 |  |  |  |  |  |  |  | 
| 122 | 1 | 50 |  |  |  | 12 | VoiceXML::Client::Util::log_msg("Subdialog jumping to form $formID") if ($VoiceXML::Client::Debug); | 
| 123 |  |  |  |  |  |  |  | 
| 124 | 1 |  |  |  |  | 8 | my $parentForm = $self->getParentForm(); | 
| 125 | 1 |  |  |  |  | 4 | $parentForm->clearAutoGuard(); | 
| 126 |  |  |  |  |  |  |  | 
| 127 | 1 |  |  |  |  | 5 | $form->enterSub(); | 
| 128 | 1 |  |  |  |  | 5 | $vxmlDoc->nextFormId($formID); | 
| 129 |  |  |  |  |  |  |  | 
| 130 | 1 |  |  |  |  | 4 | return $VoiceXML::Client::Flow::Directive{'JUMP'}; | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  | } | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | sub evaluateCondition { | 
| 137 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 138 | 0 |  | 0 |  |  |  | my $condition = shift || ''; | 
| 139 | 0 |  | 0 |  |  |  | my $vxmlDoc = shift || $self->getParentVXMLDocument(); | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  |  | 
| 142 | 0 |  |  |  |  |  | return VoiceXML::Client::Item::Util->evaluateCondition($self, $condition, $vxmlDoc); | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | } | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | 1; |