267 // Proceed to next abstract media item |
261 // Proceed to next abstract media item |
268 // ----------------------------------------------------------------------------- |
262 // ----------------------------------------------------------------------------- |
269 // |
263 // |
270 void CAbstractMediaMtpDataProviderEnumerator::ScanNextL() |
264 void CAbstractMediaMtpDataProviderEnumerator::ScanNextL() |
271 { |
265 { |
272 while ( iStorages.Count() > 0 ) |
266 PRINT( _L( "MM MTP => CAbstractMediaMtpDataProviderEnumerator::ScanNextL" ) ); |
273 { |
267 |
274 while ( iEnumState < EEnumCount ) |
268 if ( iCurrentIndex >= iCount ) |
275 { |
269 { |
276 if ( iCurrentIndex < iCount ) |
270 iEnumState++; |
277 { |
271 } |
278 TRequestStatus* status = &iStatus; |
272 |
279 User::RequestComplete( status, iStatus.Int() ); |
273 if ( iEnumState >= EEnumCount ) |
280 SetActive(); |
274 { |
281 PRINT2( _L( "MM MTP <> Current storage is still being scanned, current index = %d, total AbstractMedia count = %d" ), |
275 iEnumState = EEnumPlaylist; |
282 iCurrentIndex, |
276 iStorages.Remove( 0 ); |
283 iCount ); |
277 } |
284 return; |
278 |
285 } |
279 if ( iStorages.Count() > 0 ) |
286 ++iEnumState; |
280 { |
287 if ( iEnumState == EEnumCount ) |
281 if( iCurrentIndex >= iCount ) |
288 { |
282 { |
289 break; |
|
290 } |
|
291 InitStorageL(); |
283 InitStorageL(); |
292 } |
284 } |
293 |
285 |
294 iStorages.Remove( 0 ); |
286 TRequestStatus* status = &iStatus; |
295 if ( iStorages.Count() == 0 ) |
287 User::RequestComplete( status, iStatus.Int() ); |
296 { |
288 SetActive(); |
297 break; |
289 } |
298 } |
290 else |
299 iEnumState = EEnumPlaylist; |
291 { |
300 InitStorageL(); |
292 // We are done |
301 } |
293 PRINT( _L( "MM MTP <> Objects enumeration completed" ) ); |
302 // We are done |
294 delete iAbstractMedias; |
303 PRINT( _L( "MM MTP <> Objects enumeration completed" ) ); |
295 iAbstractMedias = NULL; |
304 delete iAbstractMedias; |
296 iStorages.Reset(); |
305 iAbstractMedias = NULL; |
297 SignalCompleteL( iDataProvider ); |
306 iStorages.Reset(); |
298 } |
307 SignalCompleteL( iDataProvider ); |
299 |
|
300 PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProviderEnumerator::ScanNextL" ) ); |
308 } |
301 } |
309 |
302 |
310 // ----------------------------------------------------------------------------- |
303 // ----------------------------------------------------------------------------- |
311 // CAbstractMediaMtpDataProviderEnumerator::RunL |
304 // CAbstractMediaMtpDataProviderEnumerator::RunL |
312 // NOTE: preserve for performance improvement |
305 // NOTE: preserve for performance improvement |
313 // ----------------------------------------------------------------------------- |
306 // ----------------------------------------------------------------------------- |
314 // |
307 // |
315 void CAbstractMediaMtpDataProviderEnumerator::RunL() |
308 void CAbstractMediaMtpDataProviderEnumerator::RunL() |
316 { |
309 { |
317 // insert all abstract medias into handle db of framework |
310 PRINT( _L( "MM MTP => CAbstractMediaMtpDataProviderEnumerator::RunL" ) ); |
318 CMPXMedia* media = ( *iAbstractMedias )[iCurrentIndex]; |
311 if ( iCurrentIndex < iCount ) |
319 |
312 { |
320 // Increase the index first in case of leave |
313 PRINT2( _L( "MM MTP <> Current storage is still being scanned, current index = %d, total AbstractMedia count = %d" ), |
321 iCurrentIndex++; |
314 iCurrentIndex, |
322 TMPXGeneralCategory category = ( iEnumState == EEnumPlaylist ) ? EMPXPlaylist : EMPXAbstractAlbum; |
315 iCount ); |
323 HBufC* abstractMedia = iDataProvider.GetWrapperL().GetAbstractMediaNameL( media, category ); |
316 // insert all abstract medias into handle db of framework |
324 CleanupStack::PushL( abstractMedia ); // + abstractMedia |
317 CMPXMedia* media = ( *iAbstractMedias )[iCurrentIndex]; |
325 TBool ret = ETrue; |
318 |
326 if ( iEnumState == EEnumAbstractAlbum ) |
319 // Increase the index first in case of leave |
327 { |
320 iCurrentIndex++; |
328 //The abstract album may be removed, check it first |
321 TMPXGeneralCategory category = ( iEnumState == EEnumPlaylist ) ? EMPXPlaylist : EMPXAbstractAlbum; |
329 ret = BaflUtils::FileExists( iFramework.Fs(), *abstractMedia ); |
322 HBufC* abstractMedia = iDataProvider.GetWrapperL().GetAbstractMediaNameL( media, category ); |
330 PRINT2( _L( "MM MTP <> BaflUtils::FileExists( RFs,%S ) ret = %d" ), abstractMedia, ret ); |
323 CleanupStack::PushL( abstractMedia ); // + abstractMedia |
331 } |
324 |
332 |
325 TBool ret = ETrue; |
333 if ( ret ) |
326 if ( iEnumState == EEnumAbstractAlbum ) |
334 { |
327 { |
335 PRINT1( _L( "MM MTP <> CAbstractMediaMtpDataProviderEnumerator::RunL abstractMedia=%S" ), abstractMedia ); |
328 // The abstract album may be removed, check it first |
336 AddEntryL( *abstractMedia ); |
329 ret = BaflUtils::FileExists( iFramework.Fs(), *abstractMedia ); |
337 |
330 PRINT2( _L( "MM MTP <> BaflUtils::FileExists( RFs,%S ) ret = %d" ), abstractMedia, ret ); |
338 // find all reference of each abstract media |
331 } |
339 CDesCArray* references = new ( ELeave ) CDesCArrayFlat( KMTPDriveGranularity ); |
332 else // EEnumPlaylist |
340 CleanupStack::PushL( references ); // + references |
333 { |
341 |
334 // Add an object to the object store for DB based playlist |
342 PERFLOGSTART( KMpxQueryAbstractMediaReference ); |
335 AddEntryL( *abstractMedia ); |
343 iDataProvider.GetWrapperL().GetAllReferenceL( media, *references ); |
336 } |
344 PERFLOGSTOP( KMpxQueryAbstractMediaReference ); |
337 |
345 |
338 if ( ret ) |
346 // insert references into reference db |
339 { |
347 AddReferencesL( *abstractMedia, *references ); |
340 PRINT1( _L( "MM MTP <> CAbstractMediaMtpDataProviderEnumerator::RunL abstractMedia=%S" ), abstractMedia ); |
348 |
341 |
349 CleanupStack::PopAndDestroy( references ); // - references |
342 // find all reference of each abstract media |
350 } |
343 CDesCArray* references = new ( ELeave ) CDesCArrayFlat( KMTPDriveGranularity ); |
351 CleanupStack::PopAndDestroy( abstractMedia ); // - abstractMedia |
344 CleanupStack::PushL( references ); // + references |
|
345 |
|
346 PERFLOGSTART( KMpxQueryAbstractMediaReference ); |
|
347 iDataProvider.GetWrapperL().GetAllReferenceL( media, *references ); |
|
348 PERFLOGSTOP( KMpxQueryAbstractMediaReference ); |
|
349 |
|
350 // insert references into reference db |
|
351 AddReferencesL( *abstractMedia, *references ); |
|
352 |
|
353 CleanupStack::PopAndDestroy( references ); // - references |
|
354 } |
|
355 CleanupStack::PopAndDestroy( abstractMedia ); // - abstractMedia |
|
356 } |
352 |
357 |
353 ScanNextL(); |
358 ScanNextL(); |
|
359 PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProviderEnumerator::RunL" ) ); |
354 } |
360 } |
355 |
361 |
356 // ----------------------------------------------------------------------------- |
362 // ----------------------------------------------------------------------------- |
357 // CAbstractMediaMtpDataProviderEnumerator::RunError |
363 // CAbstractMediaMtpDataProviderEnumerator::RunError |
358 // NOTE: preserve for performance improvement |
364 // NOTE: preserve for performance improvement |
425 } |
432 } |
426 } |
433 } |
427 |
434 |
428 if ( parentHandle != KMTPHandleNone ) |
435 if ( parentHandle != KMTPHandleNone ) |
429 { |
436 { |
430 object->SetUint( CMTPObjectMetaData::EParentHandle, parentHandle ); |
437 // Handle .m3u playlist like abstract playlist in two situations: |
431 |
438 // 1. The .m3u file is not on the file system. |
432 PERFLOGSTART( KObjectManagerInsert ); |
439 // 2. The .m3u file is hidden and 0 size |
433 iObjectMgr.InsertObjectL( *object ); |
440 TBool add = ETrue; |
434 PERFLOGSTOP( KObjectManagerInsert ); |
441 if ( format == EMTPFormatCodeM3UPlaylist ) |
435 |
442 { |
436 CleanupStack::PopAndDestroy( object );// - object |
443 TEntry entry; |
437 |
444 TInt err = iFramework.Fs().Entry( aSuid, entry ); |
438 //Only remember the playlist file for clean up |
445 add = ( err != KErrNone) || ( entry.iSize == 0 && entry.IsHidden() ); |
439 if( iEnumState == EEnumPlaylist ) |
446 } |
440 { |
447 |
|
448 if ( add ) |
|
449 { |
|
450 object->SetUint( CMTPObjectMetaData::EParentHandle, parentHandle ); |
|
451 |
|
452 PERFLOGSTART( KObjectManagerInsert ); |
|
453 iObjectMgr.InsertObjectL( *object ); |
|
454 PERFLOGSTOP( KObjectManagerInsert ); |
|
455 |
|
456 //Create the dummy file on file system |
441 iDataProvider.GetWrapperL().CreateDummyFile( aSuid ); |
457 iDataProvider.GetWrapperL().CreateDummyFile( aSuid ); |
442 |
|
443 // remember the abstract media file for clean up |
458 // remember the abstract media file for clean up |
444 iDataProvider.GetWrapperL().AddDummyFileL( aSuid ); |
459 iDataProvider.GetWrapperL().AddDummyFileL( aSuid ); |
445 } |
460 } |
446 } |
461 } |
|
462 |
|
463 CleanupStack::PopAndDestroy( object );// - object |
447 |
464 |
448 PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProviderEnumerator::AddEntryL" ) ); |
465 PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProviderEnumerator::AddEntryL" ) ); |
449 } |
466 } |
450 |
467 |
451 // ----------------------------------------------------------------------------- |
468 // ----------------------------------------------------------------------------- |