23
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2007 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 |
#include <StringLoader.h>
|
|
22 |
|
|
23 |
#include <vuivoicerecognition.rsg>
|
|
24 |
|
|
25 |
#include "vuivoicerecognition.hrh"
|
|
26 |
|
|
27 |
#include "vuicstate.h"
|
|
28 |
#include "vuicerrorstate.h"
|
|
29 |
#include "vuictutorialstate.h"
|
|
30 |
#include "vuicexitstate.h"
|
|
31 |
|
|
32 |
#include "vuicdatastorage.h"
|
|
33 |
#include "vuicuimodel.h"
|
|
34 |
|
|
35 |
#include "vuicvoicerecogdialogimpl.h"
|
|
36 |
#include "vuictoneplayer.h"
|
|
37 |
#include "vuicttsplayer.h"
|
|
38 |
#include "vuicglobalnote.h"
|
|
39 |
|
|
40 |
#include "rubydebug.h"
|
|
41 |
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
// CErrorState::NewL
|
|
44 |
// Two-phased constructor.
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
CErrorState* CErrorState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel, TInt aError )
|
|
48 |
{
|
|
49 |
CErrorState* self = new (ELeave) CErrorState( aDataStorage, aUiModel, aError );
|
|
50 |
CleanupStack::PushL( self );
|
|
51 |
self->ConstructL();
|
|
52 |
CleanupStack::Pop( self );
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
// Destructor
|
|
57 |
CErrorState::~CErrorState()
|
|
58 |
{
|
|
59 |
RUBY_DEBUG0( "CErrorState::~CErrorState START" );
|
|
60 |
|
|
61 |
DataStorage().TtsPlayer()->Stop();
|
|
62 |
|
|
63 |
RUBY_DEBUG0( "CErrorState::~CErrorState EXIT" );
|
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------
|
|
67 |
// CErrorState::HandleEventL
|
|
68 |
// ---------------------------------------------------------
|
|
69 |
//
|
|
70 |
void CErrorState::HandleEventL( TInt aEvent )
|
|
71 |
{
|
|
72 |
RUBY_DEBUG_BLOCK( "CErrorState::HandleEventL" );
|
|
73 |
|
|
74 |
CState* nextState = NULL;
|
|
75 |
|
|
76 |
switch( aEvent )
|
|
77 |
{
|
|
78 |
case KErrNone:
|
|
79 |
|
|
80 |
if ( iInternalState == EStarted )
|
|
81 |
{
|
|
82 |
iInternalState = EInitialized;
|
|
83 |
nextState = this;
|
|
84 |
}
|
|
85 |
break;
|
|
86 |
|
|
87 |
case KErrNoMatch:
|
|
88 |
|
|
89 |
nextState = CTutorialState::NewL( DataStorage(), UiModel() );
|
|
90 |
break;
|
|
91 |
|
|
92 |
default:
|
|
93 |
|
|
94 |
nextState = CExitState::NewL( DataStorage(), UiModel() );
|
|
95 |
break;
|
|
96 |
}
|
|
97 |
|
|
98 |
DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
|
|
99 |
}
|
|
100 |
|
|
101 |
// ---------------------------------------------------------
|
|
102 |
// CErrorState::ExecuteL
|
|
103 |
// ---------------------------------------------------------
|
|
104 |
//
|
|
105 |
void CErrorState::ExecuteL()
|
|
106 |
{
|
|
107 |
RUBY_DEBUG_BLOCK( "CErrorState::ExecuteL" );
|
|
108 |
|
|
109 |
if ( iInternalState == ENotStarted )
|
|
110 |
{
|
|
111 |
if ( !DataStorage().DeviceLockMode() )
|
|
112 |
{
|
|
113 |
UiModel().Note().DisplayGlobalNoteL( NoteType() );
|
|
114 |
}
|
|
115 |
|
|
116 |
iInternalState = EStarted;
|
|
117 |
|
|
118 |
TInt toneType = ToneType();
|
|
119 |
|
|
120 |
if ( toneType == EVoiceNoMatchFound )
|
|
121 |
{
|
|
122 |
HBufC* ttsText = StringLoader::LoadLC( R_TEXT_VOICE_NO_MATCHES );
|
|
123 |
|
|
124 |
DataStorage().TtsPlayer()->PlayL( *ttsText );
|
|
125 |
|
|
126 |
CleanupStack::PopAndDestroy( ttsText );
|
|
127 |
}
|
|
128 |
else if ( toneType != KErrNone )
|
|
129 |
{
|
|
130 |
DataStorage().SetPlayDuration( 0 );
|
|
131 |
DataStorage().TonePlayer()->PlayTone( toneType );
|
|
132 |
}
|
|
133 |
else
|
|
134 |
{
|
|
135 |
DataStorage().SetPlayDuration( 0 );
|
|
136 |
HandleEventL( toneType );
|
|
137 |
}
|
|
138 |
}
|
|
139 |
else if ( iInternalState == EInitialized )
|
|
140 |
{
|
|
141 |
TInt timeoutValue = DataStorage().PlayDuration().Int64();
|
|
142 |
if ( timeoutValue < KErrorMessageTimeoutMicroseconds )
|
|
143 |
{
|
|
144 |
timeoutValue = KErrorMessageTimeoutMicroseconds;
|
|
145 |
}
|
|
146 |
|
|
147 |
StartTimerL( *this, timeoutValue, timeoutValue );
|
|
148 |
iInternalState = EReady;
|
|
149 |
}
|
|
150 |
}
|
|
151 |
|
|
152 |
// ---------------------------------------------------------
|
|
153 |
// CErrorState::CErrorState
|
|
154 |
// ---------------------------------------------------------
|
|
155 |
//
|
|
156 |
CErrorState::CErrorState( CDataStorage& aDataStorage, CUiModel& aUiModel, TInt aError )
|
|
157 |
: CState( aDataStorage, aUiModel ), iInternalState( ENotStarted ), iError( aError )
|
|
158 |
{
|
|
159 |
}
|
|
160 |
|
|
161 |
// ---------------------------------------------------------
|
|
162 |
// CErrorState::DoTimedEventL
|
|
163 |
// ---------------------------------------------------------
|
|
164 |
//
|
|
165 |
void CErrorState::DoTimedEventL()
|
|
166 |
{
|
|
167 |
RUBY_DEBUG_BLOCK( "CErrorState::DoTimedEventL" );
|
|
168 |
|
|
169 |
// Dismiss error message dialog
|
|
170 |
UiModel().Note().DismissGlobalNoteL();
|
|
171 |
|
|
172 |
DataStorage().Tutorial()->ErrorState();
|
|
173 |
|
|
174 |
HandleEventL( iError );
|
|
175 |
}
|
|
176 |
|
|
177 |
// ---------------------------------------------------------
|
|
178 |
// CErrorState::NoteType
|
|
179 |
// ---------------------------------------------------------
|
|
180 |
//
|
|
181 |
CGlobalNote::TGlobalNoteState CErrorState::NoteType()
|
|
182 |
{
|
|
183 |
RUBY_DEBUG0( "CErrorState::NoteType START" );
|
|
184 |
|
|
185 |
CGlobalNote::TGlobalNoteState type;
|
|
186 |
|
|
187 |
switch( iError )
|
|
188 |
{
|
|
189 |
case KErrNoMatch:
|
|
190 |
case KErrNoResults:
|
|
191 |
{
|
|
192 |
type = CGlobalNote::ENoMatchPermanent;
|
|
193 |
break;
|
|
194 |
}
|
|
195 |
case KErrCallInProgress:
|
|
196 |
{
|
|
197 |
type = CGlobalNote::ECallInProgress;
|
|
198 |
break;
|
|
199 |
}
|
|
200 |
case KErrNoContacts:
|
|
201 |
{
|
|
202 |
type = CGlobalNote::ENoTag;
|
|
203 |
break;
|
|
204 |
}
|
|
205 |
case KErrInit:
|
|
206 |
{
|
|
207 |
type = CGlobalNote::ESystemError;
|
|
208 |
break;
|
|
209 |
}
|
|
210 |
case KErrNoMemory:
|
|
211 |
{
|
|
212 |
type = CGlobalNote::ENoMemory;
|
|
213 |
break;
|
|
214 |
}
|
|
215 |
default:
|
|
216 |
{
|
|
217 |
type = CGlobalNote::ENotRecognizedPermanent;
|
|
218 |
break;
|
|
219 |
}
|
|
220 |
}
|
|
221 |
|
|
222 |
RUBY_DEBUG0( "CErrorState::NoteType EXIT" );
|
|
223 |
|
|
224 |
return type;
|
|
225 |
}
|
|
226 |
|
|
227 |
// ---------------------------------------------------------
|
|
228 |
// CErrorState::ToneType
|
|
229 |
// ---------------------------------------------------------
|
|
230 |
//
|
|
231 |
TInt CErrorState::ToneType()
|
|
232 |
{
|
|
233 |
RUBY_DEBUG0( "CErrorState::ToneType START" );
|
|
234 |
|
|
235 |
TInt type;
|
|
236 |
|
|
237 |
switch( iError )
|
|
238 |
{
|
|
239 |
case KErrNoMatch:
|
|
240 |
case KErrNoResults:
|
|
241 |
{
|
|
242 |
// if TTS is used
|
|
243 |
if ( DataStorage().SynthesizerMode() != KErrNone ||
|
|
244 |
DataStorage().DeviceLockMode() )
|
|
245 |
{
|
|
246 |
type = EVoiceNoMatchFound;
|
|
247 |
}
|
|
248 |
else
|
|
249 |
{
|
|
250 |
type = EAvkonSIDNameDiallerAbortTone;
|
|
251 |
}
|
|
252 |
break;
|
|
253 |
}
|
|
254 |
case KErrCallInProgress:
|
|
255 |
{
|
|
256 |
// No tone should be played
|
|
257 |
type = KErrNone;
|
|
258 |
break;
|
|
259 |
}
|
|
260 |
default:
|
|
261 |
{
|
|
262 |
type = EAvkonSIDNameDiallerErrorTone;
|
|
263 |
break;
|
|
264 |
}
|
|
265 |
}
|
|
266 |
|
|
267 |
RUBY_DEBUG0( "CErrorState::ToneType EXIT" );
|
|
268 |
|
|
269 |
return type;
|
|
270 |
}
|
|
271 |
|
|
272 |
// End of File
|
|
273 |
|