mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp
changeset 0 d0791faffa3f
child 1 f8e15b44d440
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <f32file.h>
       
    17 #include <bautils.h>
       
    18 #include <mtp/cmtpdataproviderplugin.h>
       
    19 #include <mtp/cmtpobjectmetadata.h>
       
    20 #include <mtp/mmtpdataproviderframework.h>
       
    21 #include <mtp/mmtpobjectmgr.h>
       
    22 #include <mtp/mmtpstoragemgr.h>
       
    23 #include <mtp/mtpprotocolconstants.h>
       
    24 #include <mtp/tmtptypeevent.h>
       
    25 #include "cmtpfsexclusionmgr.h"
       
    26 #include "cmtpfsenumerator.h"
       
    27 #include "mmtpenumerationcallback.h"
       
    28 #include "cmtpdataprovidercontroller.h"
       
    29 #include "cmtpdataprovider.h"
       
    30 
       
    31 // Class constants.
       
    32 __FLOG_STMT(_LIT8(KComponent,"FSEnumerator");)
       
    33 
       
    34 /**
       
    35  * the files should not be owned by any dp. 
       
    36  */
       
    37 #define FILES_OWNED_BY_NONE             0
       
    38 
       
    39 /**
       
    40  * the missed files of other dps should be owned by file dp
       
    41  */
       
    42 #define MISSED_FILES_OWNED_BY_FILE_DP   1
       
    43 
       
    44 /**
       
    45  * the missed files of other dps should be owned by counterparter dps
       
    46  */
       
    47 #define MISSED_FILES_OWNED_BY_OTHER_DP  2
       
    48 
       
    49 /**
       
    50  * the files of other dps should be owned by counterparter dps
       
    51  */
       
    52 #define FILES_OWNED_BY_OTHER_DP         3
       
    53 
       
    54 /**
       
    55 Two-phase construction
       
    56 @param aFramework    data provider framework of data provider
       
    57 @param aObjectMgr    the reference to the object manager
       
    58 @param aExclusionMgr    the reference to the exclusion manager 
       
    59 @param aCallback callback to be called when enumeration is complete
       
    60 */
       
    61 EXPORT_C CMTPFSEnumerator* CMTPFSEnumerator::NewL(MMTPDataProviderFramework& aFramework, CMTPFSExclusionMgr& aExclusionMgr, MMTPEnumerationCallback& aCallback, TInt aProcessLimit)
       
    62     {
       
    63     CMTPFSEnumerator* self = new (ELeave) CMTPFSEnumerator(aFramework, aExclusionMgr, aCallback, aProcessLimit);
       
    64     CleanupStack::PushL(self);
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop(self);
       
    67     return self;
       
    68     }
       
    69 
       
    70 /**
       
    71 destructor
       
    72 */    
       
    73 EXPORT_C CMTPFSEnumerator::~CMTPFSEnumerator()
       
    74 	{
       
    75 	Cancel();	
       
    76 	iDir.Close();
       
    77 	iDirStack.Close();
       
    78 	iStorages.Close();
       
    79 	iDpSingletons.Close();
       
    80 	iSingletons.Close();
       
    81 	delete iObject;
       
    82 	__FLOG_CLOSE; 
       
    83 	}
       
    84 
       
    85 /**
       
    86 Kick off the enumeration on the specified storage
       
    87 @param aStorageId storage to be enumerated
       
    88 */
       
    89 EXPORT_C void CMTPFSEnumerator::StartL(TUint32 aStorageId)
       
    90 	{
       
    91 	__ASSERT_DEBUG(!IsActive(), User::Invariant());
       
    92 	MMTPStorageMgr& storageMgr(iFramework.StorageMgr());
       
    93 	if (aStorageId == KMTPStorageAll)
       
    94 	    {
       
    95         // Retrieve the available logical StorageIDs
       
    96         RPointerArray<const CMTPStorageMetaData> storages;
       
    97         CleanupClosePushL(storages);
       
    98         TMTPStorageMgrQueryParams params(KNullDesC, CMTPStorageMetaData::ESystemTypeDefaultFileSystem);
       
    99         storageMgr.GetLogicalStoragesL(params, storages);
       
   100         
       
   101         // Construct the StorageIDs list.
       
   102         const TUint KCount(storages.Count());
       
   103         for (TUint i(0); (i < KCount); i++)
       
   104             {
       
   105             iStorages.Insert(storages[i]->Uint(CMTPStorageMetaData::EStorageId),0);
       
   106             __FLOG_VA((_L8("FileEnumerator is doing storage id = %x\r\n"), storages[i]->Uint(CMTPStorageMetaData::EStorageId) ));
       
   107             }
       
   108         CleanupStack::PopAndDestroy(&storages);
       
   109 	    }
       
   110     else if (aStorageId != KMTPNotSpecified32)
       
   111         {
       
   112 		__ASSERT_DEBUG(storageMgr.ValidStorageId(aStorageId), User::Invariant());
       
   113 		const CMTPStorageMetaData& storage(storageMgr.StorageL(aStorageId));
       
   114 		if (storage.Uint(CMTPStorageMetaData::EStorageSystemType) == CMTPStorageMetaData::ESystemTypeDefaultFileSystem)
       
   115 		    {
       
   116     	    if (storageMgr.LogicalStorageId(aStorageId))
       
   117     		    {
       
   118     		    // Logical StorageID.
       
   119     			iStorages.AppendL(aStorageId);
       
   120     		    }
       
   121     		else
       
   122     		    {
       
   123     		    // Physical StorageID. Enumerate all eligible logical storages.
       
   124     		    const RArray<TUint>& logicalIds(storage.UintArray(CMTPStorageMetaData::EStorageLogicalIds));
       
   125     		    const TUint KCountLogicalIds(logicalIds.Count());
       
   126                 for (TUint i(0); (i < KCountLogicalIds); i++)
       
   127                     {
       
   128                     iStorages.AppendL(logicalIds[i]);
       
   129                     }
       
   130     		    }
       
   131 		    }
       
   132 		}
       
   133 
       
   134 	iStorageId = aStorageId;
       
   135 	iSkipCurrentStorage = EFalse;
       
   136 	
       
   137 	if (iStorages.Count() > 0)
       
   138 		{
       
   139 		 TRAPD(err, ScanStorageL(iStorages[0]));        
       
   140 		 if(err != KErrNone)
       
   141 			 {
       
   142 			 if( !storageMgr.ValidStorageId(iStorages[0]) )
       
   143 				 {
       
   144 				 //Scan storage leave because storage(memory card) removed.
       
   145 				 //Scan next specified storage in RunL, if there is.
       
   146 				 __FLOG_VA(_L8("StartL - iSkipCurrentStorage - ETrue."));
       
   147 				 iSkipCurrentStorage = ETrue;
       
   148 				TRequestStatus* status = &iStatus;
       
   149 				User::RequestComplete(status, iStatus.Int());
       
   150 				 SetActive();
       
   151 				 }
       
   152 			 else
       
   153 				 {
       
   154 				 User::Leave(err);
       
   155 				 }
       
   156 			 }
       
   157 		}
       
   158 	else
       
   159 		{
       
   160 		iCallback.NotifyEnumerationCompleteL(iStorageId, KErrNone);
       
   161 		
       
   162 		TMTPTypeEvent event;
       
   163 		
       
   164 		event.SetUint16(TMTPTypeEvent::EEventCode, EMTPEventCodeUnreportedStatus);
       
   165 		event.SetUint32(TMTPTypeEvent::EEventSessionID, KMTPSessionAll);
       
   166 		
       
   167 		iFramework.SendEventL(event);
       
   168 		}
       
   169 	}
       
   170 	
       
   171 /**
       
   172 Cancel the enumeration process
       
   173 */    
       
   174 void CMTPFSEnumerator::DoCancel()
       
   175 	{
       
   176 	iDir.Close();
       
   177 	}
       
   178 
       
   179 void CMTPFSEnumerator::ScanStorageL(TUint32 aStorageId)
       
   180 	{
       
   181 	__FLOG_VA(_L8("ScanStorageL - entry"));
       
   182     const CMTPStorageMetaData& storage(iFramework.StorageMgr().StorageL(aStorageId));
       
   183     __ASSERT_DEBUG((storage.Uint(CMTPStorageMetaData::EStorageSystemType) == CMTPStorageMetaData::ESystemTypeDefaultFileSystem), User::Invariant());
       
   184     TFileName root(storage.DesC(CMTPStorageMetaData::EStorageSuid));
       
   185     
       
   186     #ifdef __FLOG_ACTIVE    
       
   187 	TBuf8<KMaxFileName> tmp;
       
   188 	tmp.Copy(root);
       
   189  	__FLOG_VA((_L8("StorageSuid - %S"), &tmp));	
       
   190 	#endif // __FLOG_ACTIVE
       
   191  	
       
   192  	if ( iExclusionMgr.IsFolderAcceptedL(root, aStorageId) )
       
   193  	    {
       
   194  	    iParentHandle = KMTPHandleNoParent;
       
   195  	    iPath.Set(root, NULL, NULL);
       
   196  	    User::LeaveIfError(iDir.Open(iFramework.Fs(), iPath.DriveAndPath(), KEntryAttNormal | KEntryAttDir));
       
   197  	    ScanDirL();
       
   198  	    }
       
   199  	else
       
   200  	    {
       
   201  	    TRequestStatus* status = &iStatus;
       
   202  	    User::RequestComplete(status, iStatus.Int());
       
   203  	    SetActive();
       
   204  	    }
       
   205  	__FLOG_VA(_L8("ScanStorageL - exit"));
       
   206 	}
       
   207 
       
   208 /**
       
   209 Scans directory at aPath recursing into subdirectories on a depth first basis.
       
   210 
       
   211 Directory entries are kept in iDirStack - which is a LIFO stack.
       
   212 The current path, needed since TEntries don't keep track of it, 
       
   213 is kept in iPath.
       
   214 
       
   215 The algorithm works as follows:
       
   216 
       
   217 1. Read directory entries.
       
   218 2. ProcessEntriesL is called if no error occurs and >= 1 entries are read.
       
   219 3. ProcessEntriesL adds entries to database, if entry is directory add to iDirStack.
       
   220 4. When all entries are processed pop entry off the dirstack, 
       
   221 	if entry is empty TEntry remove one directory from iPath.
       
   222 5. Append entry name onto iPath - to update path with new depth (parent/subdir).
       
   223 6. Push an empty TEntry onto iDirStack - this tells us we have recursed one,
       
   224 	think of it as pushing the '\' separator onto iDirStack.
       
   225 7. Repeat 1-7 until iDirStack is empty.
       
   226 */
       
   227 
       
   228 void CMTPFSEnumerator::ScanDirL()
       
   229 	{
       
   230 	__FLOG_VA(_L8("ScanDirL - entry"));
       
   231 	iFirstUnprocessed = 0;
       
   232 	iDir.Read(iEntries, iStatus);
       
   233 	SetActive();
       
   234 	__FLOG_VA(_L8("ScanDirL - exit"));
       
   235 	}
       
   236 
       
   237 void CMTPFSEnumerator::ScanNextStorageL()
       
   238 	{
       
   239 	__FLOG_VA(_L8("ScanNextStorageL - entry"));
       
   240 	// If there are one or more unscanned storages left
       
   241 	// (the currently scanned one is still on the list)
       
   242 	if (iStorages.Count() > 1)
       
   243 		{
       
   244 		iStorages.Remove(0);
       
   245 		ScanStorageL(iStorages[0]);
       
   246 		}
       
   247 	else
       
   248 		{
       
   249 		// We are done
       
   250 		iStorages.Reset();
       
   251 		iCallback.NotifyEnumerationCompleteL(iStorageId, KErrNone);
       
   252 		}
       
   253 	__FLOG_VA(_L8("ScanNextStorageL - exit"));
       
   254 	}
       
   255 
       
   256 void CMTPFSEnumerator::ScanNextSubdirL()
       
   257 	{
       
   258 	__FLOG_VA(_L8("ScanNextSubdirL - entry"));
       
   259 	// A empty (non-constructed) TEntry is our marker telling us to pop a directory 
       
   260 	// from iPath when we see this
       
   261 	iDirStack.AppendL(TEntry());
       
   262 			
       
   263 	// Leave with KErrNotFound if we don't find the object handle since it shouldn't be on the 
       
   264 	// dirstack if the entry wasn't added
       
   265 	TPtrC suid = iPath.DriveAndPath().Left(iPath.DriveAndPath().Length());
       
   266 	// Update the current parentId with object of the directory
       
   267 	iParentHandle = iFramework.ObjectMgr().HandleL(suid);
       
   268 				
       
   269 	// Kick-off a scan of the next directory
       
   270 	iDir.Close();
       
   271 	User::LeaveIfError(iDir.Open(iFramework.Fs(), iPath.DriveAndPath(), KEntryAttNormal | KEntryAttDir));
       
   272 	ScanDirL();
       
   273 	__FLOG_VA(_L8("ScanNextSubdirL - exit"));
       
   274 	}
       
   275 
       
   276 /**
       
   277 Recurse into the next directory on the stack
       
   278 and scan it for entries.
       
   279 */
       
   280 
       
   281 void CMTPFSEnumerator::ScanNextL()
       
   282 	{
       
   283 	__FLOG_VA(_L8("ScanNextL - entry"));
       
   284 	TInt count = iDirStack.Count();
       
   285 	
       
   286 	if (count == 0)
       
   287 		{
       
   288 		// No more directories on the stack, try the next storage
       
   289 		ScanNextStorageL();
       
   290 		}
       
   291 	else
       
   292 		{
       
   293 		TEntry& entry = iDirStack[count - 1];
       
   294 		
       
   295 		// Empty TEntry, no more subdirectories in
       
   296 		// the current path
       
   297 		if (entry.iName == KNullDesC)
       
   298 			{
       
   299 			// Remove current dir from path
       
   300 			iPath.PopDir();
       
   301 			iDirStack.Remove(count - 1);
       
   302 			iDir.Close();
       
   303 			
       
   304 			// Scan the next directory of the parent
       
   305 			ScanNextL();
       
   306 			}
       
   307 			
       
   308 		// Going into a subdirectory of current
       
   309 		else 
       
   310 			{
       
   311 			// Add directory to path		
       
   312 			iPath.AddDir(entry.iName);
       
   313 			// Remove directory so we don't think it's a subdirectory
       
   314 			iDirStack.Remove(count - 1);
       
   315 	
       
   316 			ScanNextSubdirL();
       
   317 			}
       
   318 		}
       
   319 	__FLOG_VA(_L8("ScanNextL - exit"));
       
   320 	}
       
   321 
       
   322 void CMTPFSEnumerator::RunL()
       
   323 	{
       
   324 	__FLOG_VA(_L8("RunL - entry"));
       
   325 	if(iSkipCurrentStorage)
       
   326 		{
       
   327 		__FLOG_VA(_L8("RunL - iSkipCurrentStorage - ETrue."));
       
   328 		iSkipCurrentStorage = EFalse;
       
   329 		ScanNextStorageL();
       
   330 		}
       
   331 	else if (iEntries.Count() == 0)
       
   332 		{
       
   333 		// No entries to process, scan next dir or storage
       
   334 		ScanNextL();
       
   335 		}
       
   336 	else if (iFirstUnprocessed < iEntries.Count())
       
   337 		{
       
   338 		ProcessEntriesL();
       
   339 		
       
   340 		// Complete ourselves with current TRequestStatus
       
   341 		// since we need to run again to either scan a new dir or drive
       
   342 		// or process more entries
       
   343 		TRequestStatus* status = &iStatus;
       
   344 		User::RequestComplete(status, iStatus.Int());
       
   345 		SetActive();
       
   346 		}
       
   347 	else
       
   348 		{
       
   349 		switch (iStatus.Int())
       
   350 			{
       
   351 			case KErrNone:
       
   352 				// There are still entries left to be read
       
   353 				ScanDirL();
       
   354 				break;
       
   355 			
       
   356 			case KErrEof:
       
   357 				// There are no more entries
       
   358 			default:
       
   359 				// Error, ignore and continue with next dir
       
   360 				ScanNextL();
       
   361 				break;
       
   362 			}
       
   363 		}
       
   364 	__FLOG_VA(_L8("RunL - exit"));
       
   365 	}
       
   366 
       
   367 /**
       
   368 Ignore the error, continue with the next one
       
   369 */    
       
   370 TInt CMTPFSEnumerator::RunError(TInt aError)
       
   371 	{
       
   372 	__FLOG_VA((_L8("RunError - entry with error %d"), aError));
       
   373 	 if(!iFramework.StorageMgr().ValidStorageId(iStorages[0]))
       
   374 		 {
       
   375 		 if (iStorages.Count()>1)
       
   376 			 {
       
   377 			 //Not necessary to process any entry on the storage, since the storage removed.
       
   378 			 //Then need to start from root dir of next storage if there is.
       
   379 			 //So, the dir stack is popped to bottom.
       
   380 			 iDirStack.Reset();
       
   381 			 }
       
   382 		 iSkipCurrentStorage = ETrue;
       
   383 		 }
       
   384 	
       
   385 	// Reschedule ourselves
       
   386 	TRequestStatus* status = &iStatus;
       
   387 	User::RequestComplete(status, aError);
       
   388 	SetActive();
       
   389 	
       
   390 	__FLOG(_L8("RunError - Exit"));
       
   391 	return KErrNone;
       
   392 	}
       
   393 	
       
   394 /**
       
   395 Standard c++ constructor
       
   396 */	
       
   397 CMTPFSEnumerator::CMTPFSEnumerator(MMTPDataProviderFramework& aFramework, CMTPFSExclusionMgr& aExclusionMgr, MMTPEnumerationCallback& aCallback, TInt aProcessLimit)
       
   398 	: CActive(EPriorityLow),
       
   399   	iFramework(aFramework),
       
   400   	iExclusionMgr(aExclusionMgr),
       
   401     iCallback(aCallback),
       
   402     iProcessLimit(aProcessLimit)
       
   403 	{
       
   404 	__FLOG_OPEN(KMTPSubsystem, KComponent);
       
   405 	CActiveScheduler::Add(this);
       
   406 	}
       
   407 
       
   408 void CMTPFSEnumerator::ConstructL()
       
   409 	{
       
   410 	iSingletons.OpenL();
       
   411 	iDpSingletons.OpenL(iFramework);
       
   412 	iObject = CMTPObjectMetaData::NewL();	
       
   413 	iDpID = iFramework.DataProviderId();
       
   414 	}
       
   415 
       
   416 /**
       
   417 Iterates iEntries adding entries as needed to object manager and iDirStack.
       
   418 */
       
   419 
       
   420 void CMTPFSEnumerator::ProcessEntriesL()
       
   421 	{
       
   422 	const TUint KMTPMaxFullFileName = 259;
       
   423 
       
   424 	TBuf<KMTPMaxFullFileName> path = iPath.DriveAndPath();
       
   425 	
       
   426 	// Start looping through entries at where we left off
       
   427 	TInt count = iEntries.Count() - iFirstUnprocessed;
       
   428 	// Process no more than KProcessLimit entries
       
   429 	count = Min(count, iProcessLimit);
       
   430 	iFirstUnprocessed += count;		
       
   431 	
       
   432 		
       
   433 	for (TInt i = (iFirstUnprocessed - count); i < iFirstUnprocessed; ++i)
       
   434 		{
       
   435 		const TEntry& entry = iEntries[i];
       
   436 		path.Append(entry.iName);
       
   437 		
       
   438 #ifdef __FLOG_ACTIVE    
       
   439 		TBuf8<KMTPMaxFullFileName> tmp;
       
   440         tmp.Copy(path);
       
   441         TInt pathLen=path.Length();
       
   442         if(pathLen > KLogBufferSize)
       
   443             {
       
   444             TBuf8<KLogBufferSize> tmp1;
       
   445             tmp1.Copy(tmp.Ptr(),KLogBufferSize);
       
   446 			__FLOG_VA(_L8("Entry - "));
       
   447 	        __FLOG_VA((_L8("%S"), &tmp1));
       
   448 
       
   449 	        tmp1.Copy(tmp.Ptr()+KLogBufferSize, pathLen-KLogBufferSize);
       
   450 	        __FLOG_VA((_L8("%S"), &tmp1));
       
   451             }
       
   452         else
       
   453             {
       
   454             __FLOG_VA(_L8("Entry - "));
       
   455 			__FLOG_VA((_L8("%S"), &tmp));
       
   456             }
       
   457 #endif // __FLOG_ACTIVE
       
   458 		
       
   459 		TInt len = entry.iName.Length();
       
   460 		TInt totalLen = path.Length();
       
   461 		if(totalLen > KMaxFileName)
       
   462 		    {
       
   463 			// Remove filename part
       
   464 		    path.SetLength(totalLen - len);
       
   465 		    __FLOG_VA(_L8("Full name exceeds KMaxFileName, ignored."));
       
   466 		    continue;
       
   467 		    }
       
   468 		TUint32 handle = 0;
       
   469 		TMTPFormatCode format;
       
   470 		  TParsePtrC parse(path);
       
   471 		if (entry.IsDir())
       
   472 			{
       
   473 			if (iExclusionMgr.IsFolderAcceptedL(path, iStorages[0]))
       
   474 				{
       
   475 				path.Append('\\');
       
   476 				++len;
       
   477 				format = EMTPFormatCodeAssociation;
       
   478 				AddEntryL(path, handle, format, iDpID, entry);
       
   479 				iDirStack.AppendL(entry);
       
   480 				}
       
   481 			}
       
   482 		else if ( iExclusionMgr.IsFileAcceptedL(path,iStorages[0]) )
       
   483 			{
       
   484 			format = EMTPFormatCodeUndefined;
       
   485 			AddEntryL(path, handle, format, iDpID, entry);
       
   486 			}
       
   487 		else if ( parse.ExtPresent() )
       
   488 		    {
       
   489 		    switch(iDpSingletons.MTPUtility().GetEnumerationFlag(parse.Ext().Mid(1)))
       
   490 		        {
       
   491             case MISSED_FILES_OWNED_BY_FILE_DP:
       
   492                 if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(path))
       
   493                     {
       
   494                     format = EMTPFormatCodeUndefined;
       
   495                     AddEntryL(path, handle, format, iDpID, entry);		   
       
   496                     }
       
   497                 break;
       
   498                 
       
   499             case MISSED_FILES_OWNED_BY_OTHER_DP:
       
   500                 if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(path))
       
   501                     {
       
   502                     format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1));  
       
   503                     TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC);
       
   504                     AddFileEntryForOtherDpL(path, handle, format, DpId, entry);
       
   505                     }
       
   506                 break;
       
   507                 
       
   508             case FILES_OWNED_BY_OTHER_DP:
       
   509                 {
       
   510                 format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1));  
       
   511                 TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC);
       
   512                 AddFileEntryForOtherDpL(path, handle, format, DpId, entry);
       
   513                 }
       
   514                 break;
       
   515                 
       
   516 //          case FILES_OWNED_BY_NONE:
       
   517             default:
       
   518                 //nothing to do
       
   519                 break;
       
   520 		        }    
       
   521 		    }
       
   522 		// Remove filename part					
       
   523 		path.SetLength(path.Length() - len);
       
   524 		}
       
   525 		
       
   526 	}
       
   527 
       
   528 /**
       
   529 Add a file entry to the object store
       
   530 @param aEntry    The file Entry to be added
       
   531 @param aPath    The full path name of the entry
       
   532 @return MTP object handle, or KMTPHandleNone if entry was not accepted
       
   533 */    
       
   534 void CMTPFSEnumerator::AddEntryL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& aEntry)
       
   535 	{
       
   536 #ifdef __FLOG_ACTIVE    
       
   537 	TBuf8<KMaxFileName> tmp;
       
   538 	tmp.Copy(aPath);
       
   539 	
       
   540 	__FLOG_VA((_L8("AddEntryL - entry: %S"), &tmp));
       
   541 #endif // __FLOG_ACTIVE
       
   542 
       
   543     TUint16 assoc;
       
   544     TPtrC name;
       
   545     if (format == EMTPFormatCodeAssociation)
       
   546         {
       
   547         assoc = EMTPAssociationTypeGenericFolder;
       
   548         TParsePtrC pathParser(aPath.Left(aPath.Length() - 1)); // Ignore the trailing "\".
       
   549 		name.Set(aEntry.iName);
       
   550         }
       
   551     else
       
   552         {
       
   553         assoc = EMTPAssociationTypeUndefined;
       
   554         TParsePtrC pathParser(aPath);
       
   555 		name.Set(pathParser.Name());	
       
   556         }
       
   557     
       
   558     if(iExclusionMgr.IsFormatValid(format))
       
   559         {
       
   560         aHandle = KMTPHandleNone;
       
   561         
       
   562         iObject->SetUint(CMTPObjectMetaData::EDataProviderId, aDPId);
       
   563         iObject->SetUint(CMTPObjectMetaData::EFormatCode, format);
       
   564         iObject->SetUint(CMTPObjectMetaData::EStorageId, iStorages[0]);
       
   565         iObject->SetDesCL(CMTPObjectMetaData::ESuid, aPath);
       
   566         iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc);
       
   567         iObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
       
   568         iObject->SetUint(CMTPObjectMetaData::ENonConsumable, EMTPConsumable);
       
   569         iObject->SetDesCL(CMTPObjectMetaData::EName, name);
       
   570         iFramework.ObjectMgr().InsertObjectL(*iObject);
       
   571         }
       
   572 	__FLOG_VA(_L8("AddEntryL - exit"));	
       
   573 	}
       
   574 
       
   575 void CMTPFSEnumerator::AddFileEntryForOtherDpL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& /*aEntry*/)
       
   576     {
       
   577 #ifdef __FLOG_ACTIVE    
       
   578     TBuf8<KMaxFileName> tmp;
       
   579     tmp.Copy(aPath);
       
   580     
       
   581     __FLOG_VA((_L8("AddFileEntryForOtherDpL - entry: %S"), &tmp));
       
   582 #endif // __FLOG_ACTIVE
       
   583 
       
   584     TUint16 assoc = EMTPAssociationTypeUndefined;
       
   585     TParsePtrC pathParser(aPath);
       
   586     TPtrC name(pathParser.Name());    
       
   587     
       
   588     aHandle = KMTPHandleNone;
       
   589     
       
   590     iObject->SetUint(CMTPObjectMetaData::EDataProviderId, aDPId);
       
   591     iObject->SetUint(CMTPObjectMetaData::EFormatCode, format);
       
   592     iObject->SetUint(CMTPObjectMetaData::EStorageId, iStorages[0]);
       
   593     iObject->SetDesCL(CMTPObjectMetaData::ESuid, aPath);
       
   594     iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc);
       
   595     iObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
       
   596     iObject->SetUint(CMTPObjectMetaData::ENonConsumable, EMTPConsumable);
       
   597     iObject->SetDesCL(CMTPObjectMetaData::EName, name);
       
   598     iFramework.ObjectMgr().InsertObjectL(*iObject);
       
   599     __FLOG_VA(_L8("AddEntryL - exit")); 
       
   600     }
       
   601 
       
   602 void CMTPFSEnumerator::NotifyObjectAddToDP(const TUint32 aHandle,const TUint DpId)
       
   603     {
       
   604     iSingletons.DpController().NotifyDataProvidersL(DpId,EMTPObjectAdded,(TAny*)&aHandle);
       
   605     }
       
   606