|
1 /* |
|
2 * Copyright (c) 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: Wait note dialog |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <AknIconUtils.h> |
|
21 #include <eikimage.h> |
|
22 #include <eikenv.h> |
|
23 #include <bautils.h> |
|
24 #include <AknUtils.h> |
|
25 #include <AknsUtils.h> |
|
26 #include <aknnotewrappers.h> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 #include <mpxlog.h> |
|
29 #include <mpxcollectionutility.h> |
|
30 #include <aknSDData.h> |
|
31 #include <AknMediatorFacade.h> |
|
32 //#include <S32STRM.H> |
|
33 #include <mplayersecondarydisplayapi.h> |
|
34 |
|
35 #include <mpxwaitnotedialog.rsg> |
|
36 #include <mpxuser.h> |
|
37 #include "mpxwaitnotedialog.h" |
|
38 #include <mpxlog.h> |
|
39 |
|
40 // CONSTANTS |
|
41 _LIT( KMPXWaitNoteRscPath, "mpxwaitnotedialog.rsc" ); |
|
42 |
|
43 |
|
44 // ======== MEMBER FUNCTIONS ======== |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // Default constructor |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CMPXWaitNoteDialog::CMPXWaitNoteDialog( MMPXWaitNoteObserver* aObs, |
|
51 TWaitNoteType aType, |
|
52 TBool aVisibilityDelayOff ) |
|
53 : iObserver( aObs ), |
|
54 iWaitNoteType( aType ), |
|
55 iVisDelayOff( aVisibilityDelayOff ), |
|
56 iResourceOffset(0) |
|
57 { |
|
58 |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // Base Second Phase Constructor |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void CMPXWaitNoteDialog::BaseConstructL() |
|
66 { |
|
67 // Collection Utility |
|
68 iCollection = MMPXCollectionUtility::NewL( this ); |
|
69 |
|
70 // Resource file |
|
71 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
72 TParse parse; |
|
73 parse.Set( KMPXWaitNoteRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
74 TFileName resourceFile( parse.FullName() ); |
|
75 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
76 BaflUtils::NearestLanguageFile( eikEnv->FsSession(), resourceFile ); |
|
77 iResourceOffset = eikEnv->AddResourceFileL( resourceFile ); |
|
78 } |
|
79 |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Virtual destructor |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CMPXWaitNoteDialog::~CMPXWaitNoteDialog() |
|
86 { |
|
87 MPX_DEBUG1("CMPXWaitNoteDialog::~CMPXWaitNoteDialog <---"); |
|
88 if( iWaitDialog ) |
|
89 { |
|
90 iWaitDialog->SetCallback( NULL ); |
|
91 TRAP_IGNORE( iWaitDialog->ProcessFinishedL() ); |
|
92 } |
|
93 |
|
94 if( iResourceOffset ) |
|
95 { |
|
96 CEikonEnv::Static()->DeleteResourceFile( iResourceOffset ); |
|
97 } |
|
98 |
|
99 // Close any queries, if any |
|
100 TRAP_IGNORE( DismissQueryNoteL() ); |
|
101 |
|
102 if( iCollection ) |
|
103 { |
|
104 iCollection->Close(); |
|
105 } |
|
106 MPX_DEBUG1("CMPXWaitNoteDialog::~CMPXWaitNoteDialog --->"); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // Execute the wait note |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CMPXWaitNoteDialog::ExecuteLD() |
|
114 { |
|
115 MPX_DEBUG1("CMPXWaitNoteDialog::ExecuteLD <--"); |
|
116 // Construct the wait note |
|
117 if(iWaitDialog ) |
|
118 { |
|
119 MPX_DEBUG1("CMPXWaitNoteDialog::ExecuteLD -- deleting dlg"); |
|
120 iWaitDialog->SetCallback( NULL ); |
|
121 iWaitDialog->ProcessFinishedL(); |
|
122 iWaitDialog = NULL; |
|
123 } |
|
124 |
|
125 MPX_DEBUG1("CMPXWaitNoteDialog::ExecuteLD -- new dlg"); |
|
126 iWaitDialog = new ( ELeave ) CAknWaitDialog( |
|
127 ( CEikDialog** )&iWaitDialog, |
|
128 iVisDelayOff ); |
|
129 TInt dialogIndex = KErrNotFound; |
|
130 switch ( iWaitNoteType ) |
|
131 { |
|
132 case EMPXScanningNote: |
|
133 { |
|
134 dialogIndex = EMPlayerNoteCreatingDb; |
|
135 break; |
|
136 } |
|
137 |
|
138 case EMPXOpeningNote: |
|
139 { |
|
140 dialogIndex = EMPlayerNoteOpeningDb; |
|
141 break; |
|
142 } |
|
143 |
|
144 case EMPXRefreshingNote: |
|
145 { |
|
146 dialogIndex = EMPlayerNoteUpdatingDb; |
|
147 break; |
|
148 } |
|
149 |
|
150 case EMPXCorruptScanningNote: |
|
151 { |
|
152 dialogIndex = EMPlayerNoteRebuildingDb; |
|
153 break; |
|
154 } |
|
155 |
|
156 case EMPXUsbEventNote: |
|
157 { |
|
158 dialogIndex = EMPlayerUSBConnectionInProgress; |
|
159 break; |
|
160 } |
|
161 |
|
162 case EMPXMTPEventNote: |
|
163 { |
|
164 dialogIndex = EMPlayerMTPConnectionInProgress; |
|
165 break; |
|
166 } |
|
167 |
|
168 case EMPXFormatScanningNote: |
|
169 { |
|
170 dialogIndex = EMPlayerFormatting; |
|
171 break; |
|
172 } |
|
173 |
|
174 case EMPXMediaNotAvailableNote: |
|
175 case EMPXNoteNotDefined: |
|
176 default: |
|
177 break; |
|
178 }; |
|
179 |
|
180 if ( dialogIndex != KErrNotFound ) |
|
181 { |
|
182 iWaitDialog->PublishDialogL( |
|
183 dialogIndex, |
|
184 KMPlayerNoteCategory ); |
|
185 |
|
186 CAknMediatorFacade* covercl = AknMediatorFacade( iWaitDialog ); |
|
187 if ( covercl ) |
|
188 { |
|
189 covercl->BufStream().WriteInt32L( 0 ); |
|
190 covercl->BufStream().CommitL(); |
|
191 } |
|
192 } |
|
193 iWaitDialog->SetCallback( this ); |
|
194 iWaitDialog->PrepareLC( R_MPX_GENERIC_WAIT_NOTE ); |
|
195 |
|
196 PreNoteDisplayHandleL(); |
|
197 |
|
198 iWaitDialog->RunLD(); |
|
199 MPX_DEBUG1("CMPXWaitNoteDialog::ExecuteLD -->"); |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // Cancel the wait note |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 void CMPXWaitNoteDialog::CancelNoteL() |
|
207 { |
|
208 MPX_DEBUG1("CMPXWaitNoteDialog::CancelNoteL <---"); |
|
209 if( iWaitDialog ) |
|
210 { |
|
211 iWaitDialog->ProcessFinishedL(); |
|
212 } |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // Check the destruction status of wait dialog |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 TBool CMPXWaitNoteDialog::ReadyToDestroy() |
|
220 { |
|
221 // iWaitDialog will be updated by CAknWaitDialog self-destruction mech |
|
222 return iWaitDialog == NULL; |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // Do anything after the wait note is dismissed |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 void CMPXWaitNoteDialog::PostNoteHandleL( TInt /*aButtonId*/ ) |
|
230 { |
|
231 // Not used |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // Set the wait note CBA buttons |
|
236 // --------------------------------------------------------------------------- |
|
237 // |
|
238 void CMPXWaitNoteDialog::SetCBAL( TInt aCBAId ) |
|
239 { |
|
240 if( iWaitDialog ) |
|
241 { |
|
242 MEikButtonGroup* buttonGroup = |
|
243 iWaitDialog->ButtonGroupContainer().ButtonGroup(); |
|
244 buttonGroup->SetCommandSetL( aCBAId ); |
|
245 buttonGroup->AsControl()->DrawDeferred(); |
|
246 } |
|
247 else |
|
248 { |
|
249 User::Leave( KErrNotReady ); |
|
250 } |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // Set the wait note CBA text |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 void CMPXWaitNoteDialog::SetTextL( const TDesC& aText ) |
|
258 { |
|
259 if( iWaitDialog ) |
|
260 { |
|
261 iWaitDialog->SetTextL( aText ); |
|
262 } |
|
263 else |
|
264 { |
|
265 User::Leave( KErrNotReady ); |
|
266 } |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // Set the wait note Icon |
|
271 // --------------------------------------------------------------------------- |
|
272 // |
|
273 void CMPXWaitNoteDialog::SetIconL( TNoteIconInfo& aIconInfo ) |
|
274 { |
|
275 if( iWaitDialog ) |
|
276 { |
|
277 MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
|
278 |
|
279 CFbsBitmap* bitmap = NULL; |
|
280 CFbsBitmap* mask = NULL; |
|
281 |
|
282 AknsUtils::CreateIconLC( |
|
283 skin, |
|
284 KAknsIIDNone, |
|
285 bitmap, |
|
286 mask, |
|
287 aIconInfo.bmpfile, |
|
288 aIconInfo.bitmapId, |
|
289 aIconInfo.maskId ); |
|
290 |
|
291 CEikImage* icon = new ( ELeave ) CEikImage(); |
|
292 CleanupStack::PushL( icon ); |
|
293 icon->SetPicture( bitmap, mask ); |
|
294 icon->SetPictureOwnedExternally( EFalse ); |
|
295 iWaitDialog->SetImageL( icon ); |
|
296 CleanupStack::Pop( 3 ); // icon, bitmap, mask |
|
297 } |
|
298 else |
|
299 { |
|
300 User::Leave( KErrNotReady ); |
|
301 } |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // MMPXCollectionObserver |
|
306 // --------------------------------------------------------------------------- |
|
307 // |
|
308 void CMPXWaitNoteDialog::HandleCollectionMediaL(const CMPXMedia& /*aMedia*/, |
|
309 TInt /*aError*/) |
|
310 { |
|
311 // Not used |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // MMPXCollectionObserver |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 void CMPXWaitNoteDialog::HandleCollectionMessage( |
|
319 CMPXMessage* /*aMessage*/, TInt /*aError*/ ) |
|
320 { |
|
321 // Not used |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------------------------- |
|
325 // MMPXCollectionObserver |
|
326 // --------------------------------------------------------------------------- |
|
327 // |
|
328 void CMPXWaitNoteDialog::HandleOpenL(const CMPXMedia& /*aEntries*/, |
|
329 TInt /*aIndex*/,TBool /*aComplete*/,TInt /*aError*/) |
|
330 { |
|
331 // Not used |
|
332 } |
|
333 |
|
334 // --------------------------------------------------------------------------- |
|
335 // MMPXCollectionObserver |
|
336 // --------------------------------------------------------------------------- |
|
337 // |
|
338 void CMPXWaitNoteDialog::HandleOpenL(const CMPXCollectionPlaylist& /*aPlaylist*/, |
|
339 TInt /*aError*/) |
|
340 { |
|
341 // Not used |
|
342 } |
|
343 |
|
344 // --------------------------------------------------------------------------- |
|
345 // MProgressDialogCallback |
|
346 // --------------------------------------------------------------------------- |
|
347 // |
|
348 void CMPXWaitNoteDialog::DialogDismissedL( TInt aButtonId ) |
|
349 { |
|
350 // Tell inherited class abut the event |
|
351 PostNoteHandleL( aButtonId ); |
|
352 |
|
353 // Tell view that wait dialog is finished |
|
354 iObserver->HandleWaitNoteDismissedL(); |
|
355 } |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // Display a confirmation note |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 void CMPXWaitNoteDialog::DisplayConfirmationNoteL( const TDesC& aLabel ) |
|
362 { |
|
363 CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote(); |
|
364 note->ExecuteLD( aLabel ); |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // Display a information note |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 void CMPXWaitNoteDialog::DisplayInformationNoteL( const TDesC& aLabel ) |
|
372 { |
|
373 CAknInformationNote* note = new ( ELeave ) CAknInformationNote(); |
|
374 note->ExecuteLD( aLabel ); |
|
375 } |
|
376 |
|
377 // --------------------------------------------------------------------------- |
|
378 // Display a query note |
|
379 // --------------------------------------------------------------------------- |
|
380 // |
|
381 TInt CMPXWaitNoteDialog::DisplayQueryNoteL( const TDesC& aQuery ) |
|
382 { |
|
383 CAknQueryDialog* query = new( ELeave ) CAknQueryDialog(); |
|
384 iQueryDialog = query; |
|
385 |
|
386 TInt rtn = query->ExecuteLD( R_MPX_QUERY_YES_NO , |
|
387 aQuery ); |
|
388 iQueryDialog = NULL; // Dialog destroyed |
|
389 return rtn; |
|
390 } |
|
391 |
|
392 // --------------------------------------------------------------------------- |
|
393 // Dismiss the current query note |
|
394 // --------------------------------------------------------------------------- |
|
395 // |
|
396 void CMPXWaitNoteDialog::DismissQueryNoteL() |
|
397 { |
|
398 if( iQueryDialog ) |
|
399 { |
|
400 iQueryDialog->DismissQueryL(); |
|
401 } |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // Display a generic note dialog |
|
406 // --------------------------------------------------------------------------- |
|
407 // |
|
408 void CMPXWaitNoteDialog::DisplayNoteDialogL( TInt aDlgRsc, const TDesC& aLabel, |
|
409 CAknNoteDialog::TTone aTone ) |
|
410 { |
|
411 iObserver->NoteDialogL( iNoteDialog, aDlgRsc, aTone ); |
|
412 if ( iNoteDialog ) |
|
413 { |
|
414 iNoteDialog->SetTextL( aLabel ); |
|
415 } |
|
416 } |
|
417 |
|
418 // --------------------------------------------------------------------------- |
|
419 // Display a generic note dialog |
|
420 // --------------------------------------------------------------------------- |
|
421 // |
|
422 void CMPXWaitNoteDialog::DisplayNoteDialogL( TInt aDlgRsc, TInt aTextRsc, |
|
423 TInt aItemsAdded, const TDesC& aLabel, |
|
424 CAknNoteDialog::TTone aTone ) |
|
425 { |
|
426 MPX_DEBUG1("CMPXWaitNoteDialog::DisplayNoteDialogL for COVER DISPLAY--->"); |
|
427 |
|
428 CAknNoteDialog* note = new ( ELeave ) CAknNoteDialog( aTone ); |
|
429 note->PrepareLC( aDlgRsc ); |
|
430 note->SetTextL( aLabel ); |
|
431 if ( aTextRsc == R_MPX_REFRESHING_DB_STOPPED_TXT ) |
|
432 { |
|
433 note->PublishDialogL( |
|
434 EMPlayerNoteDbUpdateStopped, |
|
435 KMPlayerNoteCategory); |
|
436 } |
|
437 else if ( aTextRsc == R_MPX_SCANNING_STOPPED_TXT ) |
|
438 { |
|
439 note->PublishDialogL( |
|
440 EMPlayerNoteDbSearchStoppedItemFound, |
|
441 KMPlayerNoteCategory); |
|
442 } |
|
443 else if ( aTextRsc == R_MPX_SCANNING_COMPLETE_TXT ) |
|
444 { |
|
445 TInt noteId( EMPlayerNoteDbCreationCompleteEmpty ); |
|
446 if ( aItemsAdded > 0 ) |
|
447 { |
|
448 noteId = EMPlayerNoteDbCreationComplete; |
|
449 }; |
|
450 |
|
451 note->PublishDialogL( |
|
452 noteId, |
|
453 KMPlayerNoteCategory); |
|
454 } |
|
455 else if ( aTextRsc == R_MPX_REFRESHING_DB_COMPLETE_TXT ) |
|
456 { |
|
457 note->PublishDialogL( |
|
458 EMPlayerNoteDbUpdateComplete, |
|
459 KMPlayerNoteCategory); |
|
460 } |
|
461 |
|
462 if ( aTextRsc != KErrNotFound ) |
|
463 { |
|
464 CAknMediatorFacade* covercl = AknMediatorFacade( note ); |
|
465 if ( covercl ) |
|
466 { |
|
467 covercl->BufStream().WriteInt32L( aItemsAdded ); |
|
468 covercl->BufStream().CommitL(); |
|
469 } |
|
470 } |
|
471 |
|
472 note->RunLD(); |
|
473 MPX_DEBUG1("<--CMPXWaitNoteDialog::DisplayNoteDialogL for COVER DISPLAY End"); |
|
474 } |
|
475 |
|
476 // End of file |