|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <avkon.hrh> |
|
21 |
|
22 #include "vuicstate.h" |
|
23 #include "vuictutorialstate.h" |
|
24 #include "vuicinitstate.h" |
|
25 #include "vuicresultsstate.h" |
|
26 #include "vuicverificationinitstate.h" |
|
27 #include "vuicadaptstate.h" |
|
28 #include "vuicexitstate.h" |
|
29 #include "vuicabortstate.h" |
|
30 |
|
31 #include "vuicdatastorage.h" |
|
32 |
|
33 #include "vuicvoicerecogdialogimpl.h" |
|
34 #include "vuictoneplayer.h" |
|
35 #include "vuictutorial.h" |
|
36 |
|
37 #include "rubydebug.h" |
|
38 |
|
39 // Constants |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CTutorialState::NewL |
|
43 // Two-phased constructor. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CTutorialState* CTutorialState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel ) |
|
47 { |
|
48 CTutorialState* self = new (ELeave) CTutorialState( aDataStorage, aUiModel ); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // Destructor |
|
56 CTutorialState::~CTutorialState() |
|
57 { |
|
58 RUBY_DEBUG0( "CTutorialState::~CTutorialState START" ); |
|
59 |
|
60 DataStorage().Tutorial()->DestroyMessage(); |
|
61 |
|
62 RUBY_DEBUG0( "CTutorialState::~CTutorialState EXIT" ); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------- |
|
66 // CTutorialState::HandleEventL |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 void CTutorialState::HandleEventL( TInt aEvent ) |
|
70 { |
|
71 RUBY_DEBUG_BLOCK( "CTutorialState::HandleEventL" ); |
|
72 |
|
73 CState* nextState = NULL; |
|
74 |
|
75 switch( aEvent ) |
|
76 { |
|
77 case KErrNone: |
|
78 |
|
79 if ( iCurrentTutorialState == CTutorial::ETryState ) |
|
80 { |
|
81 nextState = CInitState::NewL( DataStorage(), UiModel() ); |
|
82 } |
|
83 else if ( iCurrentTutorialState == CTutorial::EBestState ) |
|
84 { |
|
85 if ( DataStorage().VerificationMode() != EVoice ) |
|
86 { |
|
87 nextState = CResultsState::NewL( DataStorage(), UiModel() ); |
|
88 } |
|
89 else |
|
90 { |
|
91 nextState = CVerificationInitState::NewL( DataStorage(), UiModel() ); |
|
92 } |
|
93 } |
|
94 else if ( iCurrentTutorialState == CTutorial::EActivationState ) |
|
95 { |
|
96 nextState = CAdaptState::NewL( DataStorage(), UiModel() ); |
|
97 } |
|
98 else if ( iInternalState == EStarted ) |
|
99 { |
|
100 iInternalState = EInitialized; |
|
101 nextState = this; |
|
102 } |
|
103 else if ( iInternalState == EInitialized ) |
|
104 { |
|
105 iInternalState = ECompleted; |
|
106 } |
|
107 else |
|
108 { |
|
109 nextState = this; |
|
110 } |
|
111 break; |
|
112 |
|
113 case KErrCancel: |
|
114 |
|
115 nextState = CExitState::NewL( DataStorage(), UiModel() ); |
|
116 break; |
|
117 |
|
118 case EShortKeypress: |
|
119 case ELongKeypress: |
|
120 case EEndCallKeypress: |
|
121 |
|
122 // Do nothing |
|
123 break; |
|
124 |
|
125 default: |
|
126 |
|
127 nextState = CAbortState::NewL( DataStorage(), UiModel() ); |
|
128 break; |
|
129 } |
|
130 |
|
131 DataStorage().VoiceRecognitionImpl()->ChangeState( nextState ); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------- |
|
135 // CTutorialState::ExecuteL |
|
136 // --------------------------------------------------------- |
|
137 // |
|
138 void CTutorialState::ExecuteL() |
|
139 { |
|
140 RUBY_DEBUG_BLOCK( "CTutorialState::ExecuteL" ); |
|
141 |
|
142 iCurrentTutorialState = DataStorage().Tutorial()->GetTutorialState(); |
|
143 |
|
144 if ( iCurrentTutorialState == CTutorial::ECommandState ) |
|
145 { |
|
146 if ( iInternalState == ENotStarted ) |
|
147 { |
|
148 // Initialize start tone |
|
149 DataStorage().TonePlayer()->InitToneL( EAvkonSIDNameDiallerStartTone ); |
|
150 iInternalState = EStarted; |
|
151 } |
|
152 else |
|
153 { |
|
154 // Play the starting tone |
|
155 DataStorage().TonePlayer()->PlayTone( EAvkonSIDNameDiallerStartTone ); |
|
156 } |
|
157 } |
|
158 |
|
159 if ( iInternalState != EStarted ) |
|
160 { |
|
161 BringToForeground(); |
|
162 |
|
163 TInt returnValue = DataStorage().Tutorial()->ShowMessageL( DataStorage().DeviceLockMode() ); |
|
164 |
|
165 if ( returnValue != KErrGeneral ) |
|
166 { |
|
167 HandleEventL( returnValue ); |
|
168 } |
|
169 } |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // CTutorialState::CTutorialState |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 CTutorialState::CTutorialState( CDataStorage& aDataStorage, CUiModel& aUiModel ) |
|
177 : CState( aDataStorage, aUiModel ), iCurrentTutorialState( CTutorial::EIntroState ), |
|
178 iInternalState( ENotStarted ) |
|
179 { |
|
180 } |
|
181 |
|
182 // --------------------------------------------------------- |
|
183 // CTutorialState::ConstructL |
|
184 // --------------------------------------------------------- |
|
185 // |
|
186 void CTutorialState::ConstructL() |
|
187 { |
|
188 RUBY_DEBUG_BLOCK( "CTutorialState::ConstructL" ); |
|
189 |
|
190 CState::ConstructL(); |
|
191 |
|
192 DataStorage().Tutorial()->CreateMessageL(); |
|
193 } |
|
194 |
|
195 // End of File |
|
196 |