|
1 /* |
|
2 * Copyright (c) 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: Controller for MPX Music player |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <mpx.rsg> |
|
21 #include <mpxlog.h> |
|
22 |
|
23 // Member Variables |
|
24 #include <mpxcollectionutility.h> |
|
25 #include <mpxcollectionmessage.h> |
|
26 #include <mpxcollectionmessagedefs.h> |
|
27 #include <mpxcollectionframeworkdefs.h> |
|
28 #include <mpxcollectionplugin.hrh> |
|
29 #include <mpxviewutility.h> |
|
30 #include <mpxmusicplayerviewplugin.hrh> |
|
31 #include <mpxviewpluginmanager.h> |
|
32 #include <mpxviewplugin.h> |
|
33 #include <mpxplaybackutility.h> |
|
34 |
|
35 // MPX Attributes |
|
36 #include <mpxmediageneraldefs.h> |
|
37 #include <mpxmediacontainerdefs.h> |
|
38 #include <mpxmediamusicdefs.h> |
|
39 #include <mpxmediacollectiondetaildefs.h> |
|
40 #include <mpxmessagegeneraldefs.h> |
|
41 #include <mpxcommandgeneraldefs.h> |
|
42 #include <mpxcollectioncommanddefs.h> |
|
43 #include <mpxmessagecontainerdefs.h> |
|
44 |
|
45 // Other MPX |
|
46 #include <mpxmedia.h> |
|
47 #include <mpxcollectionpath.h> |
|
48 #include <mpxmusicplayer.hrh> |
|
49 |
|
50 // Cover UI start |
|
51 //#ifdef __COVER_DISPLAY |
|
52 #include <aknSDData.h> |
|
53 #include <AknMediatorFacade.h> |
|
54 #include <mplayersecondarydisplayapi.h> |
|
55 //#endif |
|
56 // Cover UI end |
|
57 |
|
58 // System |
|
59 #include <StringLoader.h> |
|
60 #include <textresolver.h> |
|
61 #include <AknQueryDialog.h> |
|
62 #include <aknnotewrappers.h> |
|
63 |
|
64 // Header |
|
65 #include "mpxcontroller.h" |
|
66 |
|
67 // CONSTANTS |
|
68 const TInt KWaitNoteImpUid = 0x101FFC6C; |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // Constructor |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CMPXController::CMPXController( TBool aDisablePodcasting ) |
|
75 : iCurSystemEvent(KErrNotFound), |
|
76 iCurPlugin(KErrNotFound), |
|
77 iDisablePodcasting(aDisablePodcasting) |
|
78 { |
|
79 |
|
80 } |
|
81 |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // 2nd phase constructor |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CMPXController::ConstructL() |
|
88 { |
|
89 iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeDefault ); |
|
90 iPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault ); |
|
91 iViewUtility = MMPXViewUtility::UtilityL(); |
|
92 iIdle = CIdle::NewL( CActive::EPriorityStandard ); |
|
93 |
|
94 // Monitor for when the app is first activated |
|
95 CEikonEnv::Static()->AppUi()->AddViewActivationObserverL( this ); |
|
96 |
|
97 // Fetch the music collection UID |
|
98 RArray<TUid> uid; |
|
99 CleanupClosePushL( uid ); |
|
100 uid.AppendL( TUid::Uid(EMPXCollectionPluginMusic) ); |
|
101 iMusicCollectionId = iCollectionUtility->CollectionIDL( uid.Array() ); |
|
102 |
|
103 // Fetch the podcast collection UID |
|
104 if( !iDisablePodcasting ) |
|
105 { |
|
106 uid.Reset(); |
|
107 uid.AppendL( TUid::Uid(EMPXCollectionPluginPodCast) ); |
|
108 iPodcastCollectionId = iCollectionUtility->CollectionIDL( uid.Array() );; |
|
109 } |
|
110 CleanupStack::PopAndDestroy( &uid ); |
|
111 |
|
112 // Do the initial checking |
|
113 DoRetrieveDetailsL(); |
|
114 } |
|
115 |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // Two phase constructor |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 CMPXController* CMPXController::NewL( TBool aDisablePodcasting ) |
|
122 { |
|
123 CMPXController* self = new( ELeave ) CMPXController( aDisablePodcasting ); |
|
124 CleanupStack::PushL( self ); |
|
125 self->ConstructL(); |
|
126 CleanupStack::Pop( self ); |
|
127 return self; |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // Destructor |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 CMPXController::~CMPXController() |
|
135 { |
|
136 CEikonEnv::Static()->AppUi()->RemoveViewActivationObserver( this ); |
|
137 if ( iCollectionUtility ) |
|
138 { |
|
139 iCollectionUtility->Close(); |
|
140 } |
|
141 |
|
142 if ( iViewUtility ) |
|
143 { |
|
144 iViewUtility->Close(); |
|
145 } |
|
146 |
|
147 if ( iPlaybackUtility ) |
|
148 { |
|
149 iPlaybackUtility->Close(); |
|
150 } |
|
151 |
|
152 delete iCurPath; |
|
153 delete iIdle; |
|
154 } |
|
155 |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // Handle an idle callback event |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 TInt CMPXController::IdleCallback( TAny* ptr ) |
|
162 { |
|
163 TRAP_IGNORE( ( (CMPXController*) ptr )->HandleIdleEventL() ); |
|
164 return 0; |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // Handle an idle callback event |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 void CMPXController::HandleIdleEventL() |
|
172 { |
|
173 MPX_FUNC( "CMPXController::HandleIdleEventL" ); |
|
174 if( iRestartWaitDialog ) |
|
175 { |
|
176 DoHandleBroadcastMsgL( iCurSystemEvent ); |
|
177 iRestartWaitDialog = EFalse; |
|
178 } |
|
179 else |
|
180 { |
|
181 TInt event = iDelayedUsbRefresh ? EMcMsgUSBMassStorageStart : iCurSystemEvent; |
|
182 switch( event ) |
|
183 { |
|
184 case EMcMsgUSBMassStorageStart: |
|
185 { |
|
186 MPX_DEBUG1("CMPXController::HandleIdleEventL -- Mass Storage dialog"); |
|
187 iCurSystemEvent = KErrNotFound; |
|
188 iDelayedUsbRefresh = EFalse; |
|
189 |
|
190 HBufC* title = StringLoader::LoadLC( R_MPX_REFRESH_AFTER_SYNC ); |
|
191 CAknQueryDialog* query = new( ELeave ) CAknQueryDialog(); |
|
192 iQueryDialog = query; |
|
193 |
|
194 // Cover UI start |
|
195 //#ifdef __COVER_DISPLAY |
|
196 query->PublishDialogL( |
|
197 EMPlayerNoteUSBSyncRefresh, |
|
198 KMPlayerNoteCategory); |
|
199 //#endif |
|
200 // Cover UI end |
|
201 |
|
202 TInt rtn = query->ExecuteLD( R_MPX_QUERY_YES_NO , |
|
203 *title ); |
|
204 CleanupStack::PopAndDestroy( title ); |
|
205 iQueryDialog = NULL; // Dialog destroyed |
|
206 |
|
207 if ( rtn == EAknSoftkeyYes ) |
|
208 { |
|
209 StartWaitNoteL( EMPXRefreshingNote ); |
|
210 } |
|
211 else |
|
212 { |
|
213 MPX_DEBUG1("CMPXController::HandleIdleEventL -- refreshing view"); |
|
214 |
|
215 // Refresh the UI view in this case |
|
216 // |
|
217 if ( !CEikonEnv::Static()->StartedAsServerApp() ) |
|
218 { |
|
219 CMPXCollectionPath* cPath = iCollectionUtility->Collection().PathL(); |
|
220 CleanupStack::PushL( cPath ); |
|
221 if( cPath->Levels() > 1 && |
|
222 iViewUtility->ActiveViewType() == TUid::Uid(KMPXPluginTypeCollectionUid) ) |
|
223 { |
|
224 MPX_DEBUG1("CMPXController::HandleIdleEventL() Refreshing UI"); |
|
225 cPath->Back(); |
|
226 iCollectionUtility->Collection().OpenL( *cPath ); |
|
227 } |
|
228 CleanupStack::PopAndDestroy( cPath ); |
|
229 } |
|
230 |
|
231 DoRetrieveDetailsL(); |
|
232 } |
|
233 break; |
|
234 } |
|
235 default: |
|
236 { |
|
237 break; |
|
238 } |
|
239 |
|
240 } |
|
241 } |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // From MMPXCollectionObserver |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 void CMPXController::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError ) |
|
249 { |
|
250 if ( aError == KErrNone && aMessage ) |
|
251 { |
|
252 TRAP_IGNORE( DoHandleCollectionMessageL( *aMessage ) ); |
|
253 } |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // From MMPXCollectionObserver |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 void CMPXController::HandleOpenL( const CMPXMedia& /*aEntries*/, |
|
261 TInt /*aIndex*/, |
|
262 TBool /*aComplete*/, |
|
263 TInt /*aError*/ ) |
|
264 { |
|
265 // Not used |
|
266 } |
|
267 |
|
268 // --------------------------------------------------------------------------- |
|
269 // From MMPXCollectionObserver |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 void CMPXController::HandleOpenL( const CMPXCollectionPlaylist& /*aPlaylist*/, |
|
273 TInt /*aError*/ ) |
|
274 { |
|
275 // Not used |
|
276 } |
|
277 |
|
278 // --------------------------------------------------------------------------- |
|
279 // From MMPXCollectionObserver |
|
280 // --------------------------------------------------------------------------- |
|
281 // |
|
282 void CMPXController::HandleCollectionMediaL( const CMPXMedia& aMedia, |
|
283 TInt aError ) |
|
284 { |
|
285 MPX_FUNC( "CMPXController::HandleCollectionMediaL" ); |
|
286 |
|
287 // Handle Each error condition |
|
288 // |
|
289 if (aError == KErrNoMemory) |
|
290 { |
|
291 TRAP_IGNORE( |
|
292 HandleErrorL( aError ); |
|
293 ); |
|
294 CAknEnv::RunAppShutter(); |
|
295 User::Exit(KErrNoMemory); |
|
296 } |
|
297 else if( aError == KErrCorrupt ) |
|
298 { |
|
299 DoHandleCorruptMsgL(); |
|
300 } |
|
301 else if (aError == KErrDiskFull) |
|
302 { |
|
303 iOutOfDisk = ETrue; |
|
304 CloseWaitNoteL(); |
|
305 iCurPlugin = KErrNotFound; |
|
306 DoRetrieveDetailsL(ETrue); |
|
307 } |
|
308 else // !KErrNoMemory, !KErrCorrupt, !KErrDiskFull |
|
309 { |
|
310 if(!iOutOfDisk) |
|
311 { |
|
312 // Check to see if database has been created for this item |
|
313 // |
|
314 TBool dbCreated = ETrue; |
|
315 if( aMedia.IsSupported(KMPXMediaColDetailDBCreated)) |
|
316 { |
|
317 dbCreated = aMedia.ValueTObjectL<TBool>(KMPXMediaColDetailDBCreated); |
|
318 MPX_DEBUG2("CMPXController::HandleCollectionMediaL dbcreated %i", dbCreated); |
|
319 } |
|
320 iInitDBNeeded |= !dbCreated; //lint !e514 |
|
321 |
|
322 // Check to see if database was corrupted for this item |
|
323 // |
|
324 TBool dbCorrupted = EFalse; |
|
325 if( aMedia.IsSupported(KMPXMediaColDetailDBCorrupted)) |
|
326 { |
|
327 dbCorrupted = aMedia.ValueTObjectL<TBool>(KMPXMediaColDetailDBCorrupted); |
|
328 } |
|
329 iInitDBCorrupted |= dbCorrupted; |
|
330 } |
|
331 |
|
332 // Update the list box item, iCurPlugin++ because first item is pb state |
|
333 // |
|
334 iCurPlugin++; |
|
335 |
|
336 // Check to see if we need to do initial scan or refresh due to db corruption |
|
337 // |
|
338 if( iCurPlugin == iCurPath->Count() ) |
|
339 { |
|
340 MPX_DEBUG1("CMPXController::HandleCollectionMediaL plugins MediaL loaded"); |
|
341 |
|
342 if( (iInitDBNeeded || iInitDBCorrupted) && !iOutOfDisk ) |
|
343 { |
|
344 MPX_DEBUG2("CMPXController::HandleCollectionMediaL iUIReady %d", iUIReady ); |
|
345 //If UI isn't ready,we should wait until UI is ready. |
|
346 //Otherwise we would likely see greyed out status pane. |
|
347 if( iUIReady ) |
|
348 { |
|
349 MPX_DEBUG1("CMPXController::HandleCollectionMediaL starting scan"); |
|
350 TWaitNoteType noteType = iInitDBCorrupted ? EMPXCorruptScanningNote : |
|
351 EMPXScanningNote; |
|
352 |
|
353 StartWaitNoteL( noteType ); |
|
354 iInitDBNeeded = EFalse; |
|
355 iInitDBCorrupted = EFalse; |
|
356 iRefreshingCollection = ETrue; |
|
357 iDelayedUsbRefresh = EFalse; |
|
358 } |
|
359 else |
|
360 { |
|
361 iDelayedRefreshForUIReady = ETrue; |
|
362 } |
|
363 } |
|
364 else if( iDelayedUsbRefresh ) |
|
365 { |
|
366 DoHandleBroadcastMsgL( EMcMsgUSBMassStorageEnd ); |
|
367 } |
|
368 iCurPlugin = KErrNotFound; |
|
369 } |
|
370 else if( iCurPlugin < iCurPath->Count() ) // Fetch next |
|
371 { |
|
372 // Set which plugin |
|
373 iCurPath->Set(iCurPlugin); |
|
374 |
|
375 MPX_DEBUG1("CMPXController::HandleCollectionMediaL fetch next"); |
|
376 |
|
377 // Only fetch next if we haven't been interrupted by another event |
|
378 // |
|
379 if( (iCurSystemEvent == KErrNotFound) && !iOutOfDisk ) |
|
380 { |
|
381 // Fetch the extra data |
|
382 RArray<TMPXAttribute> atts; |
|
383 CleanupClosePushL( atts ); |
|
384 atts.Append(KMPXMediaColDetailDBCreated); |
|
385 atts.Append(KMPXMediaColDetailDBCorrupted); |
|
386 |
|
387 iCollectionUtility->Collection().MediaL(*iCurPath, atts.Array() ); |
|
388 CleanupStack::PopAndDestroy( &atts ); |
|
389 } |
|
390 else |
|
391 { |
|
392 // Reset state machine |
|
393 iCurPlugin = KErrNotFound; |
|
394 } |
|
395 } |
|
396 |
|
397 if ( aError != KErrNone ) //lint !e961 |
|
398 { |
|
399 HandleErrorL( aError ); |
|
400 } |
|
401 } |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // Wait until the view is ready |
|
406 // --------------------------------------------------------------------------- |
|
407 // |
|
408 void CMPXController::HandleViewActivation( const TVwsViewId& aNewlyActivatedViewId, |
|
409 const TVwsViewId& /*aViewIdToBeDeactivated*/) |
|
410 { |
|
411 if( !iUIReady && aNewlyActivatedViewId.iAppUid == TUid::Uid(KMusicPlayerAppUidConstant) ) |
|
412 { |
|
413 iUIReady = ETrue; |
|
414 |
|
415 if( iDelayedUsbRefresh ) |
|
416 { |
|
417 TRAP_IGNORE( DoHandleBroadcastMsgL( EMcMsgUSBMassStorageEnd ) ); |
|
418 } |
|
419 else if( iCurSystemEvent == EMcMsgUSBMassStorageStart || |
|
420 iCurSystemEvent == EMcMsgUSBMTPStart ) |
|
421 { |
|
422 // If the view has not been active, we would likely see |
|
423 // greyed out note. So we re-start the dlg |
|
424 // |
|
425 TRAP_IGNORE( CloseWaitNoteL() ); |
|
426 |
|
427 iRestartWaitDialog = ETrue; |
|
428 if( iIdle->IsActive() ) |
|
429 { |
|
430 iIdle->Cancel(); |
|
431 } |
|
432 TCallBack cb( &IdleCallback, this ); |
|
433 iIdle->Start( cb ); |
|
434 } |
|
435 else if( iDelayedRefreshForUIReady ) |
|
436 { |
|
437 TRAP_IGNORE( DoRetrieveDetailsL() ); |
|
438 } |
|
439 } |
|
440 } |
|
441 |
|
442 // --------------------------------------------------------------------------- |
|
443 // Start a refreshing note |
|
444 // --------------------------------------------------------------------------- |
|
445 // |
|
446 void CMPXController::StartWaitNoteL( TWaitNoteType aNoteType ) |
|
447 { |
|
448 CloseWaitNoteL(); |
|
449 TUid waitnoteId = TUid::Uid( KMPXPluginTypeWaitNoteDialogUid ); |
|
450 TPckg<TWaitNoteType> note = aNoteType; |
|
451 HBufC* arg = MPXUser::AllocL( note ); |
|
452 CleanupStack::PushL( arg ); |
|
453 iViewUtility->ActivateViewL( waitnoteId, arg ); |
|
454 CleanupStack::PopAndDestroy( arg ); |
|
455 } |
|
456 |
|
457 // --------------------------------------------------------------------------- |
|
458 // Close waitnote dialog |
|
459 // --------------------------------------------------------------------------- |
|
460 // |
|
461 void CMPXController::CloseWaitNoteL(TBool aSkipCheckIfActive) |
|
462 { |
|
463 TUid waitnoteId = TUid::Uid( KMPXPluginTypeWaitNoteDialogUid ); |
|
464 TUid activeView = iViewUtility->ActiveViewType(); |
|
465 if(( activeView == waitnoteId ) || (aSkipCheckIfActive)) |
|
466 { |
|
467 CMPXViewPlugin* pi = |
|
468 iViewUtility->ViewPluginManager().PluginL( TUid::Uid(KWaitNoteImpUid) ); |
|
469 pi->DeactivateView(); |
|
470 } |
|
471 } |
|
472 |
|
473 // --------------------------------------------------------------------------- |
|
474 // Calls MediaL to retrieve item details |
|
475 // --------------------------------------------------------------------------- |
|
476 // |
|
477 void CMPXController::DoRetrieveDetailsL(TBool aSkipAttribute) |
|
478 { |
|
479 MPX_DEBUG2("CMPXController::DoRetrieveDetailsL %i", iCurPlugin); |
|
480 |
|
481 // Make sure we don't overlap 2 sets of MediaL() |
|
482 // |
|
483 if( iCurPlugin == KErrNotFound && iCurSystemEvent == KErrNotFound ) |
|
484 { |
|
485 delete iCurPath; |
|
486 iCurPath = NULL; |
|
487 |
|
488 // Default path consisting of the music and podcast plugins |
|
489 RArray<TMPXItemId> ids; |
|
490 CleanupClosePushL( ids ); |
|
491 |
|
492 // Root level path |
|
493 iCurPath = CMPXCollectionPath::NewL(); |
|
494 ids.AppendL( TMPXItemId(iMusicCollectionId.iUid) ); |
|
495 if( !iDisablePodcasting ) |
|
496 { |
|
497 ids.AppendL( TMPXItemId(iPodcastCollectionId.iUid) ); |
|
498 } |
|
499 iCurPath->AppendL( ids.Array() ); |
|
500 |
|
501 CleanupStack::PopAndDestroy( &ids ); |
|
502 |
|
503 if( iCurPath->Levels() == 1 && iCurPath->Count() ) |
|
504 { |
|
505 iCurPath->SetToFirst(); |
|
506 iCurPlugin = 0; |
|
507 |
|
508 // Do a MediaL to re-retrieve details |
|
509 // |
|
510 RArray<TMPXAttribute> atts; |
|
511 CleanupClosePushL( atts ); |
|
512 if(!aSkipAttribute) |
|
513 { |
|
514 atts.Append(KMPXMediaColDetailDBCreated); |
|
515 atts.Append(KMPXMediaColDetailDBCorrupted); |
|
516 } |
|
517 |
|
518 iCollectionUtility->Collection().MediaL(*iCurPath, atts.Array() ); |
|
519 CleanupStack::PopAndDestroy( &atts ); |
|
520 } |
|
521 } |
|
522 } |
|
523 |
|
524 // --------------------------------------------------------------------------- |
|
525 // Handle collection messages. |
|
526 // --------------------------------------------------------------------------- |
|
527 // |
|
528 void CMPXController::DoHandleCollectionMessageL( |
|
529 const CMPXMessage& aMessage ) |
|
530 { |
|
531 MPX_FUNC( "CMPXCommandHandler::DoHandleCollectionMessageL" ); |
|
532 TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) ); |
|
533 if ( KMPXMessageGeneral == id ) |
|
534 { |
|
535 TInt event( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) ); |
|
536 TInt op( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralType ) ); |
|
537 TInt data( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData ) ); |
|
538 |
|
539 // End of refresh message, update the list box text |
|
540 // |
|
541 if( event == TMPXCollectionMessage::EBroadcastEvent && |
|
542 op == EMcMsgRefreshEnd ) |
|
543 { |
|
544 MPX_DEBUG1("CMPXController::HandleCollectionMessageL - refresh end"); |
|
545 iRefreshingCollection = EFalse; |
|
546 iOutOfDisk = data == KErrDiskFull ? ETrue : EFalse; |
|
547 |
|
548 iCurPlugin = KErrNotFound; |
|
549 iInitDBNeeded = EFalse; |
|
550 iInitDBCorrupted = EFalse; |
|
551 |
|
552 DoRetrieveDetailsL(iOutOfDisk); |
|
553 } |
|
554 else if(event == TMPXCollectionMessage::EBroadcastEvent && |
|
555 op == EMcMsgRefreshStart) |
|
556 { |
|
557 iRefreshingCollection = ETrue; |
|
558 } |
|
559 // Handle other broadcast messages |
|
560 // |
|
561 else if( event == TMPXCollectionMessage::EBroadcastEvent ) |
|
562 { |
|
563 MPX_DEBUG1("CMPXController::HandleCollectionMessageL - broadcast"); |
|
564 DoHandleBroadcastMsgL( op ); |
|
565 } |
|
566 } |
|
567 } |
|
568 |
|
569 // --------------------------------------------------------------------------- |
|
570 // Any processing to handle broadcast events |
|
571 // --------------------------------------------------------------------------- |
|
572 // |
|
573 void CMPXController::DoHandleBroadcastMsgL( TInt aEvent ) |
|
574 { |
|
575 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg<--"); |
|
576 switch( aEvent ) |
|
577 { |
|
578 case EMcMsgFormatStart: |
|
579 { |
|
580 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg - EMcMsgFormatStart"); |
|
581 |
|
582 // If we were in MTP sync, we stay in mtp sync mode |
|
583 if( iCurSystemEvent == KErrNotFound ) |
|
584 { |
|
585 // Show a formatting wait note |
|
586 iCurSystemEvent = EMcMsgFormatStart; |
|
587 iDiskDismountDuringFormat = EFalse; |
|
588 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
589 |
|
590 StartWaitNoteL( EMPXFormatScanningNote ); |
|
591 } |
|
592 break; |
|
593 } |
|
594 case EMcMsgFormatEnd: |
|
595 { |
|
596 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg - EMcMsgFormatEnd"); |
|
597 if( iCurSystemEvent == EMcMsgFormatStart ) |
|
598 { |
|
599 iCurSystemEvent = KErrNotFound; |
|
600 |
|
601 if( !iDiskDismountDuringFormat ) |
|
602 { |
|
603 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg - Sync db after format"); |
|
604 |
|
605 if( !iRefreshingCollection ) |
|
606 { |
|
607 StartWaitNoteL( EMPXScanningNote ); |
|
608 iRefreshingCollection = ETrue; |
|
609 } |
|
610 } |
|
611 } |
|
612 break; |
|
613 } |
|
614 case EMcMsgDiskRemoved: |
|
615 { |
|
616 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg - EMcMsgDiskRemoved"); |
|
617 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
618 |
|
619 if( iCurSystemEvent == EMcMsgFormatStart ) |
|
620 { |
|
621 iDiskDismountDuringFormat = ETrue; |
|
622 } |
|
623 else |
|
624 { |
|
625 // Check the database flags |
|
626 DoRetrieveDetailsL(); |
|
627 } |
|
628 break; |
|
629 } |
|
630 case EMcMsgDiskInserted: |
|
631 { |
|
632 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg - EMcMsgDiskInserted"); |
|
633 // Only show the query if we are not processing a usb event |
|
634 // USB dismounts and re-mounts the drive several times |
|
635 // |
|
636 // Ignore the disk insert during format, after format a fake event will be sent. |
|
637 // |
|
638 if( iCurSystemEvent != EMcMsgUSBMassStorageStart && |
|
639 iCurSystemEvent != EMcMsgUSBMTPStart && |
|
640 iCurSystemEvent != EMcMsgFormatStart ) |
|
641 { |
|
642 if( iQueryDialog ) |
|
643 { |
|
644 MPX_DEBUG1("Main View -- Dismissing Query"); |
|
645 iQueryDialog->DismissQueryL(); |
|
646 } |
|
647 |
|
648 // Always start a refresh |
|
649 // |
|
650 if( !iRefreshingCollection ) |
|
651 { |
|
652 StartWaitNoteL( EMPXScanningNote ); |
|
653 iRefreshingCollection = ETrue; |
|
654 } |
|
655 } |
|
656 break; |
|
657 } |
|
658 case EMcMsgUSBMassStorageEnd: |
|
659 { |
|
660 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg - EMcMsgUSBMassStorageEnd"); |
|
661 |
|
662 // Show query dialog to ask if they want to refresh |
|
663 // |
|
664 MPX_DEBUG1( "CMPXController::DoHandleBroadcastMsg - EMcMsgUSBMassStorageEnd" ); |
|
665 |
|
666 if( iUIReady ) |
|
667 { |
|
668 CloseWaitNoteL(ETrue); |
|
669 if( iIdle->IsActive() ) |
|
670 { |
|
671 iIdle->Cancel(); |
|
672 } |
|
673 TCallBack cb( &IdleCallback, this ); |
|
674 iIdle->Start( cb ); |
|
675 } |
|
676 else |
|
677 { |
|
678 iDelayedUsbRefresh = ETrue; |
|
679 iCurSystemEvent = KErrNotFound; |
|
680 } |
|
681 break; |
|
682 } |
|
683 case EMcMsgUSBMassStorageStart: |
|
684 { |
|
685 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg - EMcMsgUSBMassStorageStart"); |
|
686 |
|
687 // Close playback framework and start wait note |
|
688 if( iQueryDialog ) |
|
689 { |
|
690 MPX_DEBUG1("Main View -- Dismissing Query"); |
|
691 iQueryDialog->DismissQueryL(); |
|
692 } |
|
693 iCurSystemEvent = EMcMsgUSBMassStorageStart; |
|
694 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
695 StartWaitNoteL( EMPXUsbEventNote ); |
|
696 break; |
|
697 } |
|
698 case EMcMsgUSBMTPStart: |
|
699 { |
|
700 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg - EMcMsgUSBMTPStart"); |
|
701 // Close playback framework and start wait note |
|
702 if( iQueryDialog ) |
|
703 { |
|
704 MPX_DEBUG1("Main View -- Dismissing Query"); |
|
705 iQueryDialog->DismissQueryL(); |
|
706 } |
|
707 iCurSystemEvent = EMcMsgUSBMTPStart; |
|
708 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
709 StartWaitNoteL( EMPXMTPEventNote ); |
|
710 break; |
|
711 } |
|
712 case EMcMsgUSBMTPEnd: |
|
713 { |
|
714 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg EMcMsgUSBMTPEnd"); |
|
715 iCurSystemEvent = KErrNotFound; |
|
716 CloseWaitNoteL(ETrue); |
|
717 break; |
|
718 } |
|
719 case EMcMsgRefreshEnd: // fall through |
|
720 { |
|
721 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg - EMcMsgRefreshEnd"); |
|
722 iCurSystemEvent = KErrNotFound; |
|
723 break; |
|
724 } |
|
725 case EMcMsgSystemEventMax: |
|
726 case EMcMsgRefreshStart: // fall through |
|
727 { |
|
728 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg - EMcMsgSystemEventMax, EMcMsgRefreshStart"); |
|
729 break; |
|
730 } |
|
731 default: |
|
732 { |
|
733 break; |
|
734 } |
|
735 } |
|
736 MPX_DEBUG1("CMPXController::DoHandleBroadcastMsg -->"); |
|
737 } |
|
738 |
|
739 // --------------------------------------------------------------------------- |
|
740 // Displays error notes. |
|
741 // --------------------------------------------------------------------------- |
|
742 // |
|
743 void CMPXController::HandleErrorL( TInt aError ) |
|
744 { |
|
745 if ( aError ) |
|
746 { |
|
747 MPX_DEBUG2( "CMPXController::HandleErrorL(%d)", aError ); |
|
748 |
|
749 // TextResolver instance for error resolving. |
|
750 CTextResolver* textresolver = CTextResolver::NewLC(); |
|
751 // Resolve the error text |
|
752 const TDesC& text = |
|
753 textresolver->ResolveErrorString( aError ); |
|
754 |
|
755 CAknErrorNote* dlg = new ( ELeave ) CAknErrorNote( ETrue ); |
|
756 dlg->ExecuteLD( text ); |
|
757 CleanupStack::PopAndDestroy( textresolver ); |
|
758 } |
|
759 } |
|
760 |
|
761 // --------------------------------------------------------------------------- |
|
762 // Handle a corrupt message |
|
763 // --------------------------------------------------------------------------- |
|
764 // |
|
765 void CMPXController::DoHandleCorruptMsgL() |
|
766 { |
|
767 // Start the corrupt note. The corrupt note will delete |
|
768 // the old databases and restart everything from SCRATCH |
|
769 // |
|
770 MPX_DEBUG1("CMPXController::DoHandleCorruptMsgL <-- starting scan"); |
|
771 |
|
772 StartWaitNoteL( EMPXCorruptScanningNote ); |
|
773 iInitDBNeeded = EFalse; |
|
774 iInitDBCorrupted = EFalse; |
|
775 } |
|
776 |
|
777 // End of File |