|
1 /* |
|
2 * Copyright (c) 2004-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 the global progress dialog for voice recognition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <featmgr.h> |
|
21 |
|
22 #include <data_caging_path_literals.hrh> |
|
23 |
|
24 #include <AknProgressDialog.h> |
|
25 #include <AknsItemID.h> |
|
26 #include <eikprogi.h> |
|
27 #include <eikbtgpc.h> |
|
28 #include <eikimage.h> |
|
29 #include <AknsUtils.h> |
|
30 |
|
31 #include <AknMediatorFacade.h> |
|
32 |
|
33 #include <SecondaryDisplay/AknSecondaryDisplayDefs.h> |
|
34 |
|
35 #include <vuivoicerecognition.rsg> |
|
36 |
|
37 #include "vuivoicerecognition.hrh" |
|
38 |
|
39 #include "vuicglobalprogressdialog.h" |
|
40 #include "vuimkeycallback.h" |
|
41 |
|
42 #include "vuivoiceicondefs.h" |
|
43 |
|
44 #include "rubydebug.h" |
|
45 |
|
46 _LIT( KNewLine, "\n" ); |
|
47 |
|
48 // ================= MEMBER FUNCTIONS ======================= |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CGlobalProgressDialog::NewL |
|
52 // Two-phased constructor. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CGlobalProgressDialog* CGlobalProgressDialog::NewL() |
|
56 { |
|
57 RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::NewL" ); |
|
58 |
|
59 CGlobalProgressDialog* self = NewLC(); |
|
60 CleanupStack::Pop( self ); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CGlobalProgressDialog::NewLC |
|
66 // Two-phased constructor. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CGlobalProgressDialog* CGlobalProgressDialog::NewLC() |
|
70 { |
|
71 CGlobalProgressDialog* self = new ( ELeave ) CGlobalProgressDialog(); |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 // Destructor |
|
79 CGlobalProgressDialog::~CGlobalProgressDialog() |
|
80 { |
|
81 RUBY_DEBUG0( "CGlobalProgressDialog::~CGlobalProgressDialog START" ); |
|
82 |
|
83 RegisterForKeyCallback( NULL ); |
|
84 |
|
85 if ( iInternalState == EStarted || iInternalState == ERunning ) |
|
86 { |
|
87 if ( iProgressDialog ) |
|
88 { |
|
89 iProgressDialog->MakeVisible( EFalse ); |
|
90 } |
|
91 delete iProgressDialog; |
|
92 } |
|
93 |
|
94 RUBY_DEBUG0( "CGlobalProgressDialog::~CGlobalProgressDialog EXIT" ); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // CGlobalProgressDialog::RegisterForKeyCallback |
|
99 // Register for callback to receive notification when a softkey |
|
100 // is pressed |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 void CGlobalProgressDialog::RegisterForKeyCallback( MKeyCallback* aKeyCallback ) |
|
104 { |
|
105 RUBY_DEBUG0( "CGlobalProgressDialog::RegisterForKeyCallback START" ); |
|
106 |
|
107 if ( iInternalState != EFinished ) |
|
108 { |
|
109 if ( aKeyCallback ) |
|
110 { |
|
111 iProgressDialog->SetCallback( this ); |
|
112 } |
|
113 else |
|
114 { |
|
115 iProgressDialog->SetCallback( NULL ); |
|
116 } |
|
117 } |
|
118 iKeyCallback = aKeyCallback; |
|
119 |
|
120 RUBY_DEBUG0( "CGlobalProgressDialog::RegisterForKeyCallback EXIT" ); |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------- |
|
124 // CGlobalProgressDialog::SetIconL |
|
125 // Set icon on the dialog |
|
126 // --------------------------------------------------------- |
|
127 // |
|
128 void CGlobalProgressDialog::SetIconL( const TDesC& aIconFile, |
|
129 TInt aIconId, TInt aIconMaskId ) |
|
130 { |
|
131 RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::SetIconL" ); |
|
132 |
|
133 // If icon should be left bland do not set it at all |
|
134 if ( aIconId != EMbmAvkonQgn_stat_bt_blank ) |
|
135 { |
|
136 CEikImage* image = new ( ELeave ) CEikImage(); |
|
137 CleanupStack::PushL( image ); |
|
138 |
|
139 image->CreatePictureFromFileL( aIconFile, aIconId, aIconMaskId ); |
|
140 |
|
141 iProgressDialog->SetIconL( image ); // ownership of the image is transferred to dialog |
|
142 |
|
143 CleanupStack::Pop( image ); |
|
144 } |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------- |
|
148 // CGlobalProgressDialog::SetImageL |
|
149 // Set image on the dialog |
|
150 // --------------------------------------------------------- |
|
151 // |
|
152 void CGlobalProgressDialog::SetImageL( const TDesC& aImageFile, TInt aImageId, |
|
153 TInt aImageMaskId ) |
|
154 { |
|
155 RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::SetImageL" ); |
|
156 |
|
157 CEikImage* image = new ( ELeave ) CEikImage(); |
|
158 CleanupStack::PushL( image ); |
|
159 |
|
160 image->CreatePictureFromFileL( aImageFile, aImageId, aImageMaskId ); |
|
161 |
|
162 iProgressDialog->SetImageL( image ); // ownership of the image is transferred to dialog |
|
163 |
|
164 CleanupStack::Pop( image ); |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------- |
|
168 // CGlobalProgressDialog::SetSecondaryDisplayDataL |
|
169 // Sets additional information to be sent to secondary display |
|
170 // --------------------------------------------------------- |
|
171 // |
|
172 void CGlobalProgressDialog::SetSecondaryDisplayDataL( TUid aCategory, TInt aDialogIndex, |
|
173 const SecondaryDisplay::TMatchData* aData ) |
|
174 { |
|
175 RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::SetSecondaryDisplayDataL" ); |
|
176 |
|
177 if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) |
|
178 { |
|
179 iProgressDialog->PublishDialogL( aDialogIndex, aCategory ); |
|
180 |
|
181 if ( aData ) |
|
182 { |
|
183 // fetch akn utility for mediator support, \oem\aknmediatorfacade.h |
|
184 CAknMediatorFacade* covercl = AknMediatorFacade( iProgressDialog ); |
|
185 |
|
186 if ( covercl ) |
|
187 { |
|
188 covercl->BufStream() << aData->iType; |
|
189 covercl->BufStream() << aData->iName; |
|
190 covercl->BufStream() << aData->iNumber; |
|
191 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
192 } |
|
193 } |
|
194 } |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------- |
|
198 // CGlobalProgressDialog::ShowProgressDialogL |
|
199 // Shows progress dialog |
|
200 // --------------------------------------------------------- |
|
201 // |
|
202 void CGlobalProgressDialog::ShowProgressDialogL( const TDesC& aPrompt, const TDesC& aIconText, TInt aSoftkeys ) |
|
203 { |
|
204 RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::ShowProgressDialogL" ); |
|
205 |
|
206 iProgressDialog->PrepareLC( R_PROGRESSNOTE ); |
|
207 |
|
208 HBufC* string = HBufC::NewLC( aPrompt.Length() + aIconText.Length() + KNewLine.iTypeLength ); |
|
209 |
|
210 string->Des() = aPrompt; |
|
211 string->Des() += KNewLine; |
|
212 string->Des() += aIconText; |
|
213 |
|
214 iProgressDialog->SetTextL( *string ); |
|
215 |
|
216 CleanupStack::PopAndDestroy( string ); |
|
217 |
|
218 CEikButtonGroupContainer* cba = &iProgressDialog->ButtonGroupContainer(); |
|
219 cba->SetCommandSetL( aSoftkeys ); |
|
220 |
|
221 iProgressDialog->RunLD(); |
|
222 |
|
223 iInternalState = ERunning; |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------- |
|
227 // CGlobalProgressDialog::UpdateProgressDialogL |
|
228 // Updates the progress dialog |
|
229 // --------------------------------------------------------- |
|
230 // |
|
231 void CGlobalProgressDialog::UpdateProgressDialogL( TInt aValue, TInt aFinalValue ) |
|
232 { |
|
233 RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::UpdateProgressDialogL" ); |
|
234 |
|
235 if ( iProgressDialog ) |
|
236 { |
|
237 CEikProgressInfo* progressInfo = iProgressDialog->GetProgressInfoL(); |
|
238 progressInfo->SetFinalValue( aFinalValue ); |
|
239 progressInfo->SetAndDraw( aValue ); |
|
240 |
|
241 if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) |
|
242 { |
|
243 CAknMediatorFacade* coverData = AknMediatorFacade( iProgressDialog ); |
|
244 if( coverData ) |
|
245 { |
|
246 coverData->ResetBuffer(); |
|
247 coverData->BufStream().WriteInt32L( EAknGlobalPDialogValuesUpdate ); |
|
248 coverData->BufStream().WriteInt32L( aValue ); |
|
249 coverData->BufStream().WriteInt32L( aFinalValue ); |
|
250 coverData->BufStream().CommitL(); |
|
251 coverData->PostUpdatedDataL(); |
|
252 } |
|
253 } |
|
254 } |
|
255 } |
|
256 |
|
257 // --------------------------------------------------------- |
|
258 // CGlobalProgressDialog::SetSkinIds |
|
259 // Set skin ids on the dialog |
|
260 // --------------------------------------------------------- |
|
261 // |
|
262 void CGlobalProgressDialog::SetSkinIds( TAknsItemID aImageId, TInt aImageBitmapId, |
|
263 TInt aImageMaskId, TAknsItemID aIconId ) |
|
264 { |
|
265 RUBY_DEBUG0( "CGlobalProgressDialog::SetSkinIds START" ); |
|
266 |
|
267 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
268 CEikImage* image = NULL; |
|
269 CFbsBitmap* bitmap = NULL; |
|
270 CFbsBitmap* mask = NULL; |
|
271 TBuf<KMaxFileName> fileName = AknIconUtils::AvkonIconFileName(); |
|
272 |
|
273 if ( skin ) |
|
274 { |
|
275 TRAP_IGNORE( |
|
276 AknsUtils::CreateIconL( skin, aImageId, bitmap, mask, fileName, |
|
277 aImageBitmapId, aImageMaskId ); |
|
278 CleanupStack::PushL( bitmap ); |
|
279 CleanupStack::PushL( mask ); |
|
280 |
|
281 image = new ( ELeave ) CEikImage(); |
|
282 CleanupStack::PushL( image ); |
|
283 |
|
284 image->SetBitmap( bitmap ); // ownership of the bitmap is transferred to image |
|
285 image->SetMask( mask ); // ownership of the mask is transferred to image |
|
286 |
|
287 iProgressDialog->SetImageL( image ); // ownership of the image is transferred to dialog |
|
288 |
|
289 CleanupStack::Pop( image ); |
|
290 CleanupStack::Pop( mask ); |
|
291 CleanupStack::Pop( bitmap ); |
|
292 ); |
|
293 |
|
294 TInt iconId = 0; |
|
295 for ( ; iconId < KSindNumberOfIcons; ++iconId ) |
|
296 { |
|
297 if ( aIconId == *KIconId[ iconId ] ) |
|
298 { |
|
299 break; |
|
300 } |
|
301 } |
|
302 |
|
303 if ( aIconId == *KIconId[ EIconProfile ] || aIconId == *KIconId[ EIconApplication ] ) |
|
304 { |
|
305 TRAP_IGNORE( |
|
306 TParse* fp = new ( ELeave ) TParse(); |
|
307 CleanupStack::PushL( fp ); |
|
308 User::LeaveIfError( fp->Set( KDirAndFile, &KDC_BITMAP_DIR, NULL ) ); |
|
309 |
|
310 fileName = fp->FullName(); |
|
311 CleanupStack::PopAndDestroy( fp ); |
|
312 ); |
|
313 } |
|
314 |
|
315 // Don't set blank icon |
|
316 if ( aIconId != KAknsIIDQgnStatBtBlank ) |
|
317 { |
|
318 TRAP_IGNORE( |
|
319 AknsUtils::CreateIconL( skin, aIconId, bitmap, mask, fileName, |
|
320 KBitmapId[ iconId ], KMaskId[ iconId ] ); |
|
321 CleanupStack::PushL( bitmap ); |
|
322 CleanupStack::PushL( mask ); |
|
323 |
|
324 image = new ( ELeave ) CEikImage(); |
|
325 CleanupStack::PushL( image ); |
|
326 |
|
327 image->SetBitmap( bitmap ); // ownership of the bitmap is transferred to image |
|
328 image->SetMask( mask ); // ownership of the mask is transferred to image |
|
329 |
|
330 iProgressDialog->SetIconL( image ); // ownership of the image is transferred to dialog |
|
331 |
|
332 CleanupStack::Pop( image ); |
|
333 CleanupStack::Pop( mask ); |
|
334 CleanupStack::Pop( bitmap ); |
|
335 ); |
|
336 } |
|
337 } |
|
338 RUBY_DEBUG0( "CGlobalProgressDialog::SetSkinIds EXIT" ); |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------- |
|
342 // CGlobalProgressDialog::DialogDismissedL |
|
343 // |
|
344 // --------------------------------------------------------- |
|
345 // |
|
346 void CGlobalProgressDialog::DialogDismissedL( TInt aButtonId ) |
|
347 { |
|
348 RUBY_DEBUG0( "CGlobalProgressDialog::DialogDismissedL START" ); |
|
349 |
|
350 // Enter key selection returns EAknSoftkeyOk |
|
351 if ( aButtonId == EAknSoftkeyOk ) |
|
352 { |
|
353 aButtonId = EVoiceTagSoftKeyOther; |
|
354 } |
|
355 |
|
356 if ( iInternalState == ERunning && iKeyCallback ) |
|
357 { |
|
358 iInternalState = EFinished; |
|
359 iProgressDialog->SetCallback( NULL ); |
|
360 iKeyCallback->HandleKeypressL( aButtonId ); |
|
361 } |
|
362 |
|
363 RUBY_DEBUG0( "CGlobalProgressDialog::DialogDismissedL EXIT" ); |
|
364 } |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // CGlobalProgressDialog::ConstructL |
|
368 // Symbian 2nd phase constructor can leave. |
|
369 // ----------------------------------------------------------------------------- |
|
370 // |
|
371 void CGlobalProgressDialog::ConstructL() |
|
372 { |
|
373 RUBY_DEBUG_BLOCK( "CGlobalProgressDialog::ConstructL" ); |
|
374 |
|
375 iProgressDialog = new ( ELeave ) CAknProgressDialog( |
|
376 ( REINTERPRET_CAST( CEikDialog**, &iProgressDialog ) ), ETrue ); |
|
377 |
|
378 iProgressDialog->SetGloballyCapturing( ETrue ); |
|
379 } |
|
380 |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // CGlobalProgressDialog::CGlobalProgressDialog |
|
384 // C++ default constructor can NOT contain any code, that |
|
385 // might leave. |
|
386 // ----------------------------------------------------------------------------- |
|
387 // |
|
388 CGlobalProgressDialog::CGlobalProgressDialog() |
|
389 : iInternalState( EStarted ) |
|
390 { |
|
391 } |
|
392 |
|
393 // --------------------------------------------------------- |
|
394 // CGlobalProgressDialog::ProcessFinished |
|
395 // Stops the progress dialog |
|
396 // --------------------------------------------------------- |
|
397 // |
|
398 void CGlobalProgressDialog::ProcessFinished() |
|
399 { |
|
400 RUBY_DEBUG0( "CGlobalProgressDialog::ProcessFinished START" ); |
|
401 |
|
402 if ( iInternalState == ERunning ) |
|
403 { |
|
404 iInternalState = EFinished; |
|
405 iProgressDialog->SetCallback( NULL ); |
|
406 TRAP_IGNORE( iProgressDialog->ProcessFinishedL() ); |
|
407 } |
|
408 |
|
409 RUBY_DEBUG0( "CGlobalProgressDialog::ProcessFinished EXIT" ); |
|
410 } |
|
411 |
|
412 // End of File |
|
413 |