--- a/mmappcomponents/mmmtpdataprovider/mmmtpdpplugins/mediamtpdataprovider/src/cmediamtpdataproviderenumerator.cpp Fri Apr 16 15:28:14 2010 +0300
+++ b/mmappcomponents/mmmtpdataprovider/mmmtpdpplugins/mediamtpdataprovider/src/cmediamtpdataproviderenumerator.cpp Mon May 03 12:58:40 2010 +0300
@@ -30,6 +30,14 @@
#include "cmmmtpdpaccesssingleton.h"
#include "cmmmtpdpmetadataaccesswrapper.h"
+
+#if defined(_DEBUG) || defined(MMMTPDP_PERFLOG)
+_LIT( KDirectoryScan, "DirectoryScan" );
+_LIT( KFormatFilter, "FormatFilter" );
+_LIT( KObjectManagerObjectUid, "ObjectManagerObjectUid" );
+_LIT( KObjectManagerInsert, "ObjectManagerInsert" );
+#endif
+
// Unit: microsecond
const TInt KThresholdOfEnumerationLoopDuration = 1000 * 1000; // microsecond
@@ -187,7 +195,7 @@
TFileName root( storage.DesC( CMTPStorageMetaData::EStorageSuid ) );
PRINT2( _L("MM MTP <> CMediaMtpDataProviderEnumerator::ScanStorageL aStorageId = 0x%x, StorageSuid = %S"), aStorageId, &root );
- iParentHandle = KMTPHandleNone;
+ iParentHandle = KMTPHandleNoParent;
iPath.Set( root, NULL, NULL);
iDir.Close();
User::LeaveIfError( iDir.Open( iFramework.Fs(),
@@ -211,14 +219,17 @@
const CMTPStorageMetaData& storage( iFramework.StorageMgr().StorageL( iStorages[0] ) );
TFileName root( storage.DesC( CMTPStorageMetaData::EStorageSuid ) );
GetModifiedContentL( root );
- iDataProvider.GetWrapperL().UpdateMusicCollectionL();
+ TRAPD( err, iDataProvider.GetWrapperL().UpdateMusicCollectionL() );
+ if ( err != KErrNone )
+ {
+ PRINT1( _L("MM MTP <> ScanNextStorageL, UpdateMusicCollectionL err =%d "), err );
+ }
iStorages.Remove( 0 );
ScanStorageL( iStorages[0] );
}
else
{
-
// Round trip suppport
const CMTPStorageMetaData& storage( iFramework.StorageMgr().StorageL( iStorages[0] ) );
TFileName root( storage.DesC( CMTPStorageMetaData::EStorageSuid ) );
@@ -283,7 +294,7 @@
delete entry;
entry = NULL;
iDir.Close();
-
+
// Scan the next directory of the parent
ScanNextDirL();
}
@@ -314,9 +325,9 @@
// A empty (non-constructed) TEntry is our marker telling us to pop a directory
// from iPath when we see this
TEntry* entry = new TEntry( TEntry() );
-
+
User::LeaveIfNull( entry );
-
+
iDirStack.AppendL( entry );
// Leave with KErrNotFound if we don't find the object handle since it shouldn't be on the
@@ -326,7 +337,7 @@
PERFLOGSTART( KObjectManagerObjectUid );
iParentHandle = iFramework.ObjectMgr().HandleL( suid );
PERFLOGSTOP( KObjectManagerObjectUid );
- PRINT1( _L( "MM MTP <> iParentHandle = 0x%Lx" ), iParentHandle );
+ PRINT1( _L( "MM MTP <> iParentHandle = 0x%x" ), iParentHandle );
// Kick-off a scan of the next directory
iDir.Close();
@@ -412,7 +423,8 @@
//
TInt CMediaMtpDataProviderEnumerator::RunError( TInt aError )
{
- PRINT1( _L( "MM MTP <> CMediaMtpDataProviderEnumerator::RunError with error %d" ), aError );
+ if ( aError != KErrNone )
+ PRINT1( _L( "MM MTP <> CMediaMtpDataProviderEnumerator::RunError with error %d" ), aError );
TRAP_IGNORE( SignalCompleteL( iDataProvider ) );
@@ -461,34 +473,39 @@
{
PRINT( _L( "MM MTP => CMediaMtpDataProviderEnumerator::ProcessEntriesL" ) );
- TBuf<KMaxFileName> path = iPath.DriveAndPath();
+ TFileName path = iPath.DriveAndPath();
while ( !IsOverThreshold() && iFirstUnprocessed < iEntries.Count() )
{
const TEntry& entry = iEntries[iFirstUnprocessed];
- path.Append( entry.iName );
- PRINT1( _L( "MM MTP <> path = %S" ), &path );
TInt len = entry.iName.Length();
- if ( entry.IsDir() )
+ // Skip object with too long name
+ if ( KMaxFileName >= path.Length() + len )
{
- path.Append( '\\' );
- ++len;
+ path.Append( entry.iName );
+ PRINT1( _L( "MM MTP <> path = %S" ), &path );
+
+ if ( entry.IsDir() )
+ {
+ path.Append( '\\' );
+ ++len;
- // we don't need to process folder, just remember
- // the folder
- TEntry* dirEntry = new TEntry( entry );
- User::LeaveIfNull( dirEntry );
- iDirStack.AppendL( dirEntry );
+ // we don't need to process folder, just remember
+ // the folder
+ TEntry* dirEntry = new TEntry( entry );
+ User::LeaveIfNull( dirEntry );
+ iDirStack.AppendL( dirEntry );
+ }
+ else if ( IsFileAccepted( path ) )
+ {
+ AddEntryL( path );
+ }
+
+ // Remove filename part
+ path.SetLength( path.Length() - len );
}
- else if ( IsFileAccepted( path ) )
- {
- AddEntryL( path );
- }
-
- // Remove filename part
- path.SetLength( path.Length() - len );
iFirstUnprocessed++;
}
@@ -553,7 +570,7 @@
//
TBool CMediaMtpDataProviderEnumerator::IsFileAccepted( const TDesC& aFullFileName )
{
- PERFLOGSTART(KFormatFilter);
+ PERFLOGSTART( KFormatFilter );
iFormatCode = GetObjectFormatCode( aFullFileName );
PRINT1( _L( "MM MTP <> CMediaMtpDataProviderEnumerator::IsFileAcceptedL formatCode = 0x%x" ), iFormatCode );
TBool accepted = EFalse;
@@ -567,7 +584,7 @@
}
}
- PERFLOGSTOP(KFormatFilter);
+ PERFLOGSTOP( KFormatFilter );
return accepted;
}
@@ -612,7 +629,9 @@
CDesCArray* modifiedContents = new ( ELeave ) CDesCArrayFlat( KMTPDriveGranularity );
CleanupStack::PushL( modifiedContents ); // + modifiedContents
- iDataProvider.GetWrapperL().GetModifiedContentL( aStorageRoot, arrayCount, *modifiedContents );
+ TRAPD( err, iDataProvider.GetWrapperL().GetModifiedContentL( aStorageRoot, arrayCount, *modifiedContents ) );
+ if ( err != KErrNone )
+ PRINT1( _L("MM MTP <> GetModifiedContentL err =%d "), err );
if ( arrayCount > 0 )
{