mmappcomponents/mmmtpdataprovider/mmmtpdpplugins/mediamtpdataprovider/src/cmediamtpdataproviderenumerator.cpp
branchRCL_3
changeset 9 bee149131e4b
parent 0 a2952bb97e68
child 14 05b0d2323768
equal deleted inserted replaced
4:d45095c2f4f3 9:bee149131e4b
    28 #include "mmmtpdplogger.h"
    28 #include "mmmtpdplogger.h"
    29 #include "mmmtpdputility.h"
    29 #include "mmmtpdputility.h"
    30 #include "cmmmtpdpaccesssingleton.h"
    30 #include "cmmmtpdpaccesssingleton.h"
    31 #include "cmmmtpdpmetadataaccesswrapper.h"
    31 #include "cmmmtpdpmetadataaccesswrapper.h"
    32 
    32 
       
    33 
       
    34 #if defined(_DEBUG) || defined(MMMTPDP_PERFLOG)
       
    35 _LIT( KDirectoryScan, "DirectoryScan" );
       
    36 _LIT( KFormatFilter, "FormatFilter" );
       
    37 _LIT( KObjectManagerObjectUid, "ObjectManagerObjectUid" );
       
    38 _LIT( KObjectManagerInsert, "ObjectManagerInsert" );
       
    39 #endif
       
    40 
    33 // Unit: microsecond
    41 // Unit: microsecond
    34 const TInt KThresholdOfEnumerationLoopDuration = 1000 * 1000; // microsecond
    42 const TInt KThresholdOfEnumerationLoopDuration = 1000 * 1000; // microsecond
    35 
    43 
    36 const TInt KMTPDriveGranularity = 5;
    44 const TInt KMTPDriveGranularity = 5;
    37 const TInt KMediaDpArrayGranularity = 2;
    45 const TInt KMediaDpArrayGranularity = 2;
   185         User::Invariant() );
   193         User::Invariant() );
   186 
   194 
   187     TFileName root( storage.DesC( CMTPStorageMetaData::EStorageSuid ) );
   195     TFileName root( storage.DesC( CMTPStorageMetaData::EStorageSuid ) );
   188     PRINT2( _L("MM MTP <> CMediaMtpDataProviderEnumerator::ScanStorageL aStorageId = 0x%x, StorageSuid = %S"), aStorageId, &root );
   196     PRINT2( _L("MM MTP <> CMediaMtpDataProviderEnumerator::ScanStorageL aStorageId = 0x%x, StorageSuid = %S"), aStorageId, &root );
   189 
   197 
   190     iParentHandle = KMTPHandleNone;
   198     iParentHandle = KMTPHandleNoParent;
   191     iPath.Set( root, NULL, NULL);
   199     iPath.Set( root, NULL, NULL);
   192     iDir.Close();
   200     iDir.Close();
   193     User::LeaveIfError( iDir.Open( iFramework.Fs(),
   201     User::LeaveIfError( iDir.Open( iFramework.Fs(),
   194         iPath.DriveAndPath(),
   202         iPath.DriveAndPath(),
   195         KEntryAttNormal | KEntryAttDir ) );
   203         KEntryAttNormal | KEntryAttDir ) );
   216         iStorages.Remove( 0 );
   224         iStorages.Remove( 0 );
   217         ScanStorageL( iStorages[0] );
   225         ScanStorageL( iStorages[0] );
   218         }
   226         }
   219     else
   227     else
   220         {
   228         {
   221 
       
   222         // Round trip suppport
   229         // Round trip suppport
   223         const CMTPStorageMetaData& storage( iFramework.StorageMgr().StorageL( iStorages[0] ) );
   230         const CMTPStorageMetaData& storage( iFramework.StorageMgr().StorageL( iStorages[0] ) );
   224         TFileName root( storage.DesC( CMTPStorageMetaData::EStorageSuid ) );
   231         TFileName root( storage.DesC( CMTPStorageMetaData::EStorageSuid ) );
   225         GetModifiedContentL( root );
   232         GetModifiedContentL( root );
   226 
   233 
   281                 iPath.PopDir();
   288                 iPath.PopDir();
   282                 iDirStack.Remove( count - 1 );
   289                 iDirStack.Remove( count - 1 );
   283                 delete entry;
   290                 delete entry;
   284                 entry = NULL;
   291                 entry = NULL;
   285                 iDir.Close();
   292                 iDir.Close();
   286     
   293 
   287                 // Scan the next directory of the parent
   294                 // Scan the next directory of the parent
   288                 ScanNextDirL();
   295                 ScanNextDirL();
   289                 }
   296                 }
   290             // Going into a subdirectory of current
   297             // Going into a subdirectory of current
   291             else
   298             else
   312     PRINT( _L( "MM MTP => CMediaMtpDataProviderEnumerator::ScanNextSubdirL" ) );
   319     PRINT( _L( "MM MTP => CMediaMtpDataProviderEnumerator::ScanNextSubdirL" ) );
   313 
   320 
   314     // A empty (non-constructed) TEntry is our marker telling us to pop a directory
   321     // A empty (non-constructed) TEntry is our marker telling us to pop a directory
   315     // from iPath when we see this
   322     // from iPath when we see this
   316     TEntry* entry = new TEntry( TEntry() );
   323     TEntry* entry = new TEntry( TEntry() );
   317     
   324 
   318     User::LeaveIfNull( entry );
   325     User::LeaveIfNull( entry );
   319     
   326 
   320     iDirStack.AppendL( entry );
   327     iDirStack.AppendL( entry );
   321 
   328 
   322     // Leave with KErrNotFound if we don't find the object handle since it shouldn't be on the
   329     // Leave with KErrNotFound if we don't find the object handle since it shouldn't be on the
   323     // dirstack if the entry wasn't added
   330     // dirstack if the entry wasn't added
   324     TPtrC suid = iPath.DriveAndPath().Left( iPath.DriveAndPath().Length() );
   331     TPtrC suid = iPath.DriveAndPath().Left( iPath.DriveAndPath().Length() );
   325     // Update the current parenthandle with object of the directory
   332     // Update the current parenthandle with object of the directory
   326     PERFLOGSTART( KObjectManagerObjectUid );
   333     PERFLOGSTART( KObjectManagerObjectUid );
   327     iParentHandle = iFramework.ObjectMgr().HandleL( suid );
   334     iParentHandle = iFramework.ObjectMgr().HandleL( suid );
   328     PERFLOGSTOP( KObjectManagerObjectUid );
   335     PERFLOGSTOP( KObjectManagerObjectUid );
   329     PRINT1( _L( "MM MTP <> iParentHandle = 0x%Lx" ), iParentHandle );
   336     PRINT1( _L( "MM MTP <> iParentHandle = 0x%x" ), iParentHandle );
   330 
   337 
   331     // Kick-off a scan of the next directory
   338     // Kick-off a scan of the next directory
   332     iDir.Close();
   339     iDir.Close();
   333 
   340 
   334     TInt err = iDir.Open( iFramework.Fs(),
   341     TInt err = iDir.Open( iFramework.Fs(),
   551 // Is the file format is supported by this Dp
   558 // Is the file format is supported by this Dp
   552 // -----------------------------------------------------------------------------
   559 // -----------------------------------------------------------------------------
   553 //
   560 //
   554 TBool CMediaMtpDataProviderEnumerator::IsFileAccepted( const TDesC& aFullFileName )
   561 TBool CMediaMtpDataProviderEnumerator::IsFileAccepted( const TDesC& aFullFileName )
   555     {
   562     {
   556     PERFLOGSTART(KFormatFilter);
   563     PERFLOGSTART( KFormatFilter );
   557     iFormatCode = GetObjectFormatCode( aFullFileName );
   564     iFormatCode = GetObjectFormatCode( aFullFileName );
   558     PRINT1( _L( "MM MTP <> CMediaMtpDataProviderEnumerator::IsFileAcceptedL formatCode = 0x%x" ), iFormatCode );
   565     PRINT1( _L( "MM MTP <> CMediaMtpDataProviderEnumerator::IsFileAcceptedL formatCode = 0x%x" ), iFormatCode );
   559     TBool accepted = EFalse;
   566     TBool accepted = EFalse;
   560     TInt count = sizeof( KMediaMtpDataProviderSupportedFormats ) / sizeof( TUint16 );
   567     TInt count = sizeof( KMediaMtpDataProviderSupportedFormats ) / sizeof( TUint16 );
   561     for ( TInt i = 0; i < count; i++ )
   568     for ( TInt i = 0; i < count; i++ )
   565             accepted = ETrue;
   572             accepted = ETrue;
   566             break;
   573             break;
   567             }
   574             }
   568         }
   575         }
   569 
   576 
   570     PERFLOGSTOP(KFormatFilter);
   577     PERFLOGSTOP( KFormatFilter );
   571     return accepted;
   578     return accepted;
   572     }
   579     }
   573 
   580 
   574 // -----------------------------------------------------------------------------
   581 // -----------------------------------------------------------------------------
   575 // CMediaDpMtpEnumerator::StartEnumerationCount
   582 // CMediaDpMtpEnumerator::StartEnumerationCount