mmappcomponents/mmmtpdataprovider/mmmtpdpplugins/abstractmediamtpdataprovider/src/cabstractmediamtpdataproviderenumerator.cpp
branchRCL_3
changeset 19 51035f0751c2
parent 17 780c925249c1
child 28 f56ec6ce2732
equal deleted inserted replaced
17:780c925249c1 19:51035f0751c2
   267 // Proceed to next abstract media item
   267 // Proceed to next abstract media item
   268 // -----------------------------------------------------------------------------
   268 // -----------------------------------------------------------------------------
   269 //
   269 //
   270 void CAbstractMediaMtpDataProviderEnumerator::ScanNextL()
   270 void CAbstractMediaMtpDataProviderEnumerator::ScanNextL()
   271     {
   271     {
   272     while (iStorages.Count() > 0)
   272     while ( iStorages.Count() > 0 )
   273         {
   273         {
   274         while ( iEnumState < EEnumCount )
   274         while ( iEnumState < EEnumCount )
   275             {
   275             {
   276             if ( iCurrentIndex < iCount )
   276             if ( iCurrentIndex < iCount )
   277                 {
   277                 {
   282                     iCurrentIndex,
   282                     iCurrentIndex,
   283                     iCount );
   283                     iCount );
   284                 return;
   284                 return;
   285                 }
   285                 }
   286             ++iEnumState;
   286             ++iEnumState;
   287             if (iEnumState == EEnumCount)
   287             if ( iEnumState == EEnumCount )
   288                 {
   288                 {
   289                 break;
   289                 break;
   290                 }
   290                 }
   291             InitStorageL();
   291             InitStorageL();
   292             }
   292             }
       
   293 
   293         iStorages.Remove( 0 );
   294         iStorages.Remove( 0 );
   294         if (iStorages.Count() == 0)
   295         if ( iStorages.Count() == 0 )
   295             {
   296             {
   296             break;
   297             break;
   297             }
   298             }
   298         iEnumState = EEnumPlaylist;
   299         iEnumState = EEnumPlaylist;
   299         InitStorageL();
   300         InitStorageL();
   311 // NOTE: preserve for performance improvement
   312 // NOTE: preserve for performance improvement
   312 // -----------------------------------------------------------------------------
   313 // -----------------------------------------------------------------------------
   313 //
   314 //
   314 void CAbstractMediaMtpDataProviderEnumerator::RunL()
   315 void CAbstractMediaMtpDataProviderEnumerator::RunL()
   315     {
   316     {
   316     PRINT( _L( "MM MTP => CAbstractMediaMtpDataProviderEnumerator::RunL" ) );
       
   317 
       
   318     // insert all abstract medias into handle db of framework
   317     // insert all abstract medias into handle db of framework
   319     CMPXMedia* media = ( *iAbstractMedias )[iCurrentIndex];
   318     CMPXMedia* media = ( *iAbstractMedias )[iCurrentIndex];
   320     
   319     
   321     // Increase the index first in case of leave
   320     // Increase the index first in case of leave
   322     iCurrentIndex++;
   321     iCurrentIndex++;
   409     TParsePtrC parser( aSuid );
   408     TParsePtrC parser( aSuid );
   410     PERFLOGSTART( KObjectManagerObjectUid );
   409     PERFLOGSTART( KObjectManagerObjectUid );
   411     TUint32 parentHandle = iFramework.ObjectMgr().HandleL( parser.DriveAndPath() );
   410     TUint32 parentHandle = iFramework.ObjectMgr().HandleL( parser.DriveAndPath() );
   412     PERFLOGSTOP( KObjectManagerObjectUid );
   411     PERFLOGSTOP( KObjectManagerObjectUid );
   413 
   412 
   414     object->SetUint( CMTPObjectMetaData::EParentHandle, parentHandle );
   413     // MTP FW returns KMTPHandleNone for parentHandle in two situations:
   415 
   414     // 1. The path doesn't exist
   416     PERFLOGSTART( KObjectManagerInsert );
   415     // 2. The object is under root directory
   417     iObjectMgr.InsertObjectL( *object );
   416     if ( parentHandle == KMTPHandleNone )
   418     PERFLOGSTOP( KObjectManagerInsert );
   417         {
   419 
   418         if ( BaflUtils::PathExists( iFramework.Fs(), parser.DriveAndPath() ) )
   420     CleanupStack::PopAndDestroy( object );// - object
   419             {
   421 
   420             parentHandle = KMTPHandleNoParent;
   422     //Only remember the playlist file for clean up
   421             }
   423     if( iEnumState == EEnumPlaylist )
   422         else
   424         {
   423             {
   425         iDataProvider.GetWrapperL().CreateDummyFile( aSuid );
   424             iDataProvider.GetWrapperL().DeleteObjectL( *object );
   426 
   425             }
   427         // remember the abstract media file for clean up
   426         }
   428         iDataProvider.GetWrapperL().AddDummyFileL( aSuid );
   427 
       
   428     if ( parentHandle != KMTPHandleNone )
       
   429         {
       
   430         object->SetUint( CMTPObjectMetaData::EParentHandle, parentHandle );
       
   431 
       
   432         PERFLOGSTART( KObjectManagerInsert );
       
   433         iObjectMgr.InsertObjectL( *object );
       
   434         PERFLOGSTOP( KObjectManagerInsert );
       
   435 
       
   436         CleanupStack::PopAndDestroy( object );// - object
       
   437 
       
   438         //Only remember the playlist file for clean up
       
   439         if( iEnumState == EEnumPlaylist )
       
   440             {
       
   441             iDataProvider.GetWrapperL().CreateDummyFile( aSuid );
       
   442 
       
   443             // remember the abstract media file for clean up
       
   444             iDataProvider.GetWrapperL().AddDummyFileL( aSuid );
       
   445             }
   429         }
   446         }
   430 
   447 
   431     PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProviderEnumerator::AddEntryL" ) );
   448     PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProviderEnumerator::AddEntryL" ) );
   432     }
   449     }
   433 
   450