|
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: Handles tutorial mode resources and dialog showing |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <avkon.rsg> |
|
22 #include <avkon.hrh> |
|
23 #include <centralrepository.h> |
|
24 #include <vcommanddomaincrkeys.h> |
|
25 #include <e32property.h> |
|
26 #include <ScreensaverInternalPSKeys.h> |
|
27 |
|
28 #include <vuivoicerecognition.rsg> |
|
29 |
|
30 #include "vuivoicerecognition.hrh" |
|
31 |
|
32 #include "vuictutorial.h" |
|
33 #include "vuictutorialmessagedialog.h" |
|
34 |
|
35 #include "rubydebug.h" |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CTutorial::InstanceL |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CTutorial* CTutorial::NewL() |
|
42 { |
|
43 CTutorial* self = new ( ELeave ) CTutorial(); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // Destructor |
|
51 CTutorial::~CTutorial() |
|
52 { |
|
53 RUBY_DEBUG0( "CTutorial::~CTutorial START" ); |
|
54 |
|
55 // Save tutorial mode settings before exiting |
|
56 TRAP_IGNORE( SaveSettingsL() ); |
|
57 |
|
58 DestroyMessage(); |
|
59 |
|
60 RUBY_DEBUG0( "CTutorial::~CTutorial EXIT" ); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CTutorial::CreateMessageL |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CTutorial::CreateMessageL() |
|
68 { |
|
69 RUBY_DEBUG_BLOCK( "CTutorial::CreateMessageL" ); |
|
70 |
|
71 if ( iDlg ) |
|
72 { |
|
73 User::Leave( KErrAlreadyExists ); |
|
74 } |
|
75 |
|
76 iDlg = CTutorialMessageDialog::NewL(); |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CTutorial::CreateAndShowMessageL |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 TInt CTutorial::CreateAndShowMessageL() |
|
84 { |
|
85 RUBY_DEBUG_BLOCK( "CTutorial::CreateAndShowMessageL" ); |
|
86 |
|
87 CreateMessageL(); |
|
88 return ShowMessageL(); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CTutorial::ShowMessageL |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 TInt CTutorial::ShowMessageL( TBool aDeviceLockMode ) |
|
96 { |
|
97 RUBY_DEBUG_BLOCK( "CTutorial::ShowMessageL" ); |
|
98 |
|
99 TInt returnValue = KErrGeneral; |
|
100 |
|
101 switch( iState ) |
|
102 { |
|
103 case EIntroState: |
|
104 |
|
105 if ( IsTutorialModeEnabled() && iTutorialMode ) |
|
106 { |
|
107 iState = ECommandState; |
|
108 returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY, |
|
109 R_TEXT_SIND_TUTORIAL_PAGE_INTRO_TITLE, |
|
110 R_TEXT_SIND_TUTORIAL_PAGE_INTRO_TEXT_UP, |
|
111 R_TEXT_SIND_TUTORIAL_PAGE_INTRO_TEXT_DOWN, |
|
112 R_SOFTKEYS_NEXT_CANCEL__NEXT ); |
|
113 } |
|
114 else if ( IsTutorialModeEnabled() && !aDeviceLockMode ) |
|
115 { |
|
116 iState = ETryState; |
|
117 returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY, |
|
118 R_TEXT_SIND_TUTORIAL_PAGE_INTRO_TITLE, |
|
119 R_TEXT_SIND_TUTORIAL_FIRST_TIME_TEXT_UP, |
|
120 R_TEXT_SIND_TUTORIAL_FIRST_TIME_TEXT_DOWN, |
|
121 R_SOFTKEYS_ACTIVATE_CANCEL__ACTIVATE, |
|
122 SecondaryDisplay::ECmdShowFirstTimeActivationQuery ); |
|
123 if ( returnValue == EVoiceInfoSoftKeyActivate ) |
|
124 { |
|
125 DisableFirstTimeMode(); |
|
126 } |
|
127 } |
|
128 else |
|
129 { |
|
130 iState = ETryState; |
|
131 } |
|
132 break; |
|
133 |
|
134 case ECommandState: |
|
135 |
|
136 iState = EDialState; |
|
137 returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY, |
|
138 R_TEXT_SIND_TUTORIAL_PAGE_COMMAND_TITLE, |
|
139 R_TEXT_SIND_TUTORIAL_PAGE_COMMAND_TEXT_UP, |
|
140 R_TEXT_SIND_TUTORIAL_PAGE_COMMAND_TEXT_DOWN, |
|
141 R_SOFTKEYS_NEXT_CANCEL__NEXT ); |
|
142 break; |
|
143 |
|
144 case EDialState: |
|
145 |
|
146 iState = EOtherState; |
|
147 returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY, |
|
148 R_TEXT_SIND_TUTORIAL_PAGE_DIAL_TITLE, |
|
149 R_TEXT_SIND_TUTORIAL_PAGE_DIAL_TEXT_UP, |
|
150 R_TEXT_SIND_TUTORIAL_PAGE_DIAL_TEXT_DOWN, |
|
151 R_SOFTKEYS_NEXT_CANCEL__NEXT ); |
|
152 break; |
|
153 |
|
154 case EOtherState: |
|
155 |
|
156 iState = ETryState; |
|
157 returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY, |
|
158 R_TEXT_SIND_TUTORIAL_PAGE_OTHER_TITLE, |
|
159 R_TEXT_SIND_TUTORIAL_PAGE_OTHER_TEXT_UP, |
|
160 R_TEXT_SIND_TUTORIAL_PAGE_OTHER_TEXT_DOWN, |
|
161 R_SOFTKEYS_NEXT_CANCEL__NEXT ); |
|
162 break; |
|
163 |
|
164 case ETryState: |
|
165 |
|
166 iState = EBestState; |
|
167 if ( IsTutorialModeEnabled() && !aDeviceLockMode ) |
|
168 { |
|
169 returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY, |
|
170 R_TEXT_SIND_TUTORIAL_PAGE_TRY_TITLE, |
|
171 R_TEXT_SIND_TUTORIAL_PAGE_TRY_TEXT_UP, |
|
172 R_TEXT_SIND_TUTORIAL_PAGE_TRY_TEXT_DOWN, |
|
173 R_SOFTKEYS_ACTIVATE_CANCEL__ACTIVATE ); |
|
174 } |
|
175 break; |
|
176 |
|
177 case EBestState: |
|
178 |
|
179 iState = EActivationState; |
|
180 if ( IsTutorialModeEnabled() && !aDeviceLockMode ) |
|
181 { |
|
182 returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY, |
|
183 R_TEXT_SIND_TUTORIAL_PAGE_BEST_TITLE, |
|
184 R_TEXT_SIND_TUTORIAL_PAGE_BEST_TEXT_UP, |
|
185 R_TEXT_SIND_TUTORIAL_PAGE_BEST_TEXT_DOWN, |
|
186 R_SOFTKEYS_NEXT_CANCEL__NEXT ); |
|
187 } |
|
188 break; |
|
189 |
|
190 case EActivationState: |
|
191 |
|
192 iState = EFinishedState; |
|
193 if ( IsTutorialModeEnabled() && !aDeviceLockMode ) |
|
194 { |
|
195 returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY, |
|
196 R_TEXT_SIND_TUTORIAL_PAGE_ACTIVATION_TITLE, |
|
197 R_TEXT_SIND_TUTORIAL_PAGE_ACTIVATION_TEXT, |
|
198 KErrNone, |
|
199 R_AVKON_SOFTKEYS_QUIT ); |
|
200 } |
|
201 break; |
|
202 |
|
203 case EErrorState: |
|
204 |
|
205 iState = EFinishedState; |
|
206 if ( IsTutorialModeEnabled() && !aDeviceLockMode ) |
|
207 { |
|
208 returnValue = iDlg->ShowMessageDialogL( R_MESSAGE_QUERY, |
|
209 R_TEXT_SIND_TUTORIAL_PAGE_ERROR_TITLE, |
|
210 R_TEXT_SIND_TUTORIAL_PAGE_ERROR_TEXT_UP, |
|
211 R_TEXT_SIND_TUTORIAL_PAGE_ERROR_TEXT_DOWN, |
|
212 R_SOFTKEYS_NEXT_CANCEL__NEXT ); |
|
213 if ( returnValue == EVoiceInfoSoftKeyNext ) |
|
214 { |
|
215 iState = ETryState; |
|
216 } |
|
217 } |
|
218 break; |
|
219 |
|
220 default: |
|
221 returnValue = KErrCancel; |
|
222 break; |
|
223 } |
|
224 |
|
225 if ( returnValue == EVoiceInfoSoftKeyCancel || returnValue == EAknSoftkeyQuit ) |
|
226 { |
|
227 iTutorialMode = EFalse; |
|
228 returnValue = KErrCancel; |
|
229 } |
|
230 else if ( returnValue == KErrNone ) |
|
231 { |
|
232 // Return general error because dialog has been canceled without any keypress |
|
233 returnValue = KErrGeneral; |
|
234 } |
|
235 else if ( returnValue != KErrCancel ) |
|
236 { |
|
237 returnValue = KErrNone; |
|
238 } |
|
239 |
|
240 return returnValue; |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CTutorial::DestroyMessage |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 void CTutorial::DestroyMessage() |
|
248 { |
|
249 RUBY_DEBUG0( "CTutorial::DestroyMessage START" ); |
|
250 |
|
251 if ( iDlg ) |
|
252 { |
|
253 delete iDlg; |
|
254 iDlg = NULL; |
|
255 } |
|
256 |
|
257 RUBY_DEBUG0( "CTutorial::DestroyMessage EXIT" ); |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CTutorial::GetTutorialState |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 CTutorial::TTutorialState CTutorial::GetTutorialState() |
|
265 { |
|
266 RUBY_DEBUG0( "CTutorial::GetTutorialState" ); |
|
267 return iState; |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CTutorial::ShowError |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 void CTutorial::ErrorState() |
|
275 { |
|
276 RUBY_DEBUG0( "CTutorial::ErrorState" ); |
|
277 iState = EErrorState; |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CTutorial::IsTutorialModeEnabled |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 TBool CTutorial::IsTutorialModeEnabled() |
|
285 { |
|
286 RUBY_DEBUG0( "CTutorial::IsTutorialModeEnabled" ); |
|
287 return iTutorialMode || iFirstTimeMode; |
|
288 } |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // CTutorial::DisableTutorialMode |
|
292 // ----------------------------------------------------------------------------- |
|
293 // |
|
294 void CTutorial::DisableFirstTimeMode() |
|
295 { |
|
296 RUBY_DEBUG0( "CTutorial::DisableFirstTimeMode" ); |
|
297 if ( !iTutorialMode ) |
|
298 { |
|
299 iFirstTimeMode = EFalse; |
|
300 |
|
301 TRAP_IGNORE( SaveSettingsL() ); |
|
302 } |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CTutorial::CTutorial |
|
307 // C++ default constructor can NOT contain any code, that |
|
308 // might leave. |
|
309 // ----------------------------------------------------------------------------- |
|
310 // |
|
311 CTutorial::CTutorial() |
|
312 : iTutorialMode( EFalse ), iFirstTimeMode( EFalse ), iState( EIntroState ) |
|
313 { |
|
314 // Nothing |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CTutorialMessageDialog::ConstructL |
|
319 // Symbian 2nd phase constructor can leave. |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 void CTutorial::ConstructL() |
|
323 { |
|
324 RUBY_DEBUG_BLOCK( "CTutorial::ConstructL" ); |
|
325 |
|
326 LoadSettingsL(); |
|
327 } |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // CTutorial::LoadSettingsL |
|
331 // --------------------------------------------------------------------------- |
|
332 // |
|
333 void CTutorial::LoadSettingsL() |
|
334 { |
|
335 RUBY_DEBUG_BLOCK( "CTutorial::LoadSettingsL" ); |
|
336 |
|
337 CRepository* client = CRepository::NewLC( KCRUidVCommandSettings ); |
|
338 |
|
339 User::LeaveIfError( client->Get( KVuiDemoFirstTime, |
|
340 iFirstTimeMode ) ); |
|
341 |
|
342 User::LeaveIfError( client->Get( KVuiDemoMode, |
|
343 iTutorialMode ) ); |
|
344 |
|
345 CleanupStack::PopAndDestroy( client ); |
|
346 |
|
347 if ( iTutorialMode ) |
|
348 { |
|
349 //Allow screensaver if in tutorial mode |
|
350 RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 0 ); |
|
351 } |
|
352 } |
|
353 |
|
354 // --------------------------------------------------------------------------- |
|
355 // CTutorial::SaveSettingsL |
|
356 // --------------------------------------------------------------------------- |
|
357 // |
|
358 void CTutorial::SaveSettingsL() |
|
359 { |
|
360 RUBY_DEBUG_BLOCK( "CTutorial::SaveSettingsL" ); |
|
361 |
|
362 CRepository* client = CRepository::NewLC( KCRUidVCommandSettings ); |
|
363 |
|
364 User::LeaveIfError( client->Set( KVuiDemoFirstTime, |
|
365 iFirstTimeMode ) ); |
|
366 |
|
367 User::LeaveIfError( client->Set( KVuiDemoMode, |
|
368 EFalse ) ); |
|
369 |
|
370 CleanupStack::PopAndDestroy( client ); |
|
371 } |
|
372 |
|
373 // End of File |
|
374 |