25 #include "cmtpfsexclusionmgr.h" |
25 #include "cmtpfsexclusionmgr.h" |
26 #include "cmtpfsenumerator.h" |
26 #include "cmtpfsenumerator.h" |
27 #include "mmtpenumerationcallback.h" |
27 #include "mmtpenumerationcallback.h" |
28 #include "cmtpdataprovidercontroller.h" |
28 #include "cmtpdataprovidercontroller.h" |
29 #include "cmtpdataprovider.h" |
29 #include "cmtpdataprovider.h" |
|
30 #include "mtpframeworkconst.h" |
|
31 |
30 |
32 |
31 // Class constants. |
33 // Class constants. |
32 __FLOG_STMT(_LIT8(KComponent,"FSEnumerator");) |
34 __FLOG_STMT(_LIT8(KComponent,"FSEnumerator");) |
|
35 |
|
36 const TUint KMTPMaxFullFileName = 259; |
|
37 /* |
|
38 * |
|
39 */ |
|
40 #define KMAX_FILECOUNT_ENUMERATINGPHASE1 5000 |
33 |
41 |
34 /** |
42 /** |
35 * the files should not be owned by any dp. |
43 * the files should not be owned by any dp. |
36 */ |
44 */ |
37 #define FILES_OWNED_BY_NONE 0 |
45 #define FILES_OWNED_BY_NONE 0 |
84 |
92 |
85 /** |
93 /** |
86 Kick off the enumeration on the specified storage |
94 Kick off the enumeration on the specified storage |
87 @param aStorageId storage to be enumerated |
95 @param aStorageId storage to be enumerated |
88 */ |
96 */ |
89 EXPORT_C void CMTPFSEnumerator::StartL(TUint32 aStorageId) |
97 EXPORT_C void CMTPFSEnumerator::StartL(TUint32 aStorageId, TBool aOnlyRoot) |
90 { |
98 { |
91 __ASSERT_DEBUG(!IsActive(), User::Invariant()); |
99 __ASSERT_DEBUG(!IsActive(), User::Invariant()); |
|
100 iNumOfFoldersAndFiles = 0; |
|
101 iOnlyScanRoot = aOnlyRoot; |
|
102 __FLOG_VA((_L8("iOnlyScanRoot == %d "), iOnlyScanRoot)); |
|
103 |
92 MMTPStorageMgr& storageMgr(iFramework.StorageMgr()); |
104 MMTPStorageMgr& storageMgr(iFramework.StorageMgr()); |
93 if (aStorageId == KMTPStorageAll) |
105 if (aStorageId == KMTPStorageAll) |
94 { |
106 { |
95 // Retrieve the available logical StorageIDs |
107 // Retrieve the available logical StorageIDs |
96 RPointerArray<const CMTPStorageMetaData> storages; |
108 RPointerArray<const CMTPStorageMetaData> storages; |
370 TInt CMTPFSEnumerator::RunError(TInt aError) |
392 TInt CMTPFSEnumerator::RunError(TInt aError) |
371 { |
393 { |
372 __FLOG_VA((_L8("RunError - entry with error %d"), aError)); |
394 __FLOG_VA((_L8("RunError - entry with error %d"), aError)); |
373 if(!iFramework.StorageMgr().ValidStorageId(iStorages[0])) |
395 if(!iFramework.StorageMgr().ValidStorageId(iStorages[0])) |
374 { |
396 { |
|
397 __FLOG_VA((_L8("Invalid StorageID = %d"),iStorages[0] )); |
375 if (iStorages.Count()>1) |
398 if (iStorages.Count()>1) |
376 { |
399 { |
377 //Not necessary to process any entry on the storage, since the storage removed. |
400 //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. |
401 //Then need to start from root dir of next storage if there is. |
379 //So, the dir stack is popped to bottom. |
402 //So, the dir stack is popped to bottom. |
409 { |
432 { |
410 iSingletons.OpenL(); |
433 iSingletons.OpenL(); |
411 iDpSingletons.OpenL(iFramework); |
434 iDpSingletons.OpenL(iFramework); |
412 iObject = CMTPObjectMetaData::NewL(); |
435 iObject = CMTPObjectMetaData::NewL(); |
413 iDpID = iFramework.DataProviderId(); |
436 iDpID = iFramework.DataProviderId(); |
|
437 iIsFileEnumerator = (KMTPFileDPID == iDpID); |
414 } |
438 } |
415 |
439 |
416 /** |
440 /** |
417 Iterates iEntries adding entries as needed to object manager and iDirStack. |
441 Iterates iEntries adding entries as needed to object manager and iDirStack. |
418 */ |
442 */ |
419 |
443 |
420 void CMTPFSEnumerator::ProcessEntriesL() |
444 void CMTPFSEnumerator::ProcessEntriesL() |
421 { |
445 { |
422 const TUint KMTPMaxFullFileName = 259; |
|
423 |
|
424 TBuf<KMTPMaxFullFileName> path = iPath.DriveAndPath(); |
446 TBuf<KMTPMaxFullFileName> path = iPath.DriveAndPath(); |
425 |
447 |
426 // Start looping through entries at where we left off |
448 // Start looping through entries at where we left off |
427 TInt count = iEntries.Count() - iFirstUnprocessed; |
449 TInt count = iEntries.Count() - iFirstUnprocessed; |
428 // Process no more than KProcessLimit entries |
450 // Process no more than KProcessLimit entries |
429 count = Min(count, iProcessLimit); |
451 count = Min(count, iProcessLimit); |
430 iFirstUnprocessed += count; |
452 iFirstUnprocessed += count; |
431 |
453 |
432 |
454 if(!iIsFileEnumerator) |
|
455 { |
|
456 iNumOfFoldersAndFiles +=count; |
|
457 } |
|
458 |
433 for (TInt i = (iFirstUnprocessed - count); i < iFirstUnprocessed; ++i) |
459 for (TInt i = (iFirstUnprocessed - count); i < iFirstUnprocessed; ++i) |
434 { |
460 { |
435 const TEntry& entry = iEntries[i]; |
461 const TEntry& entry = iEntries[i]; |
436 path.Append(entry.iName); |
462 path.Append(entry.iName); |
437 |
463 |
473 if (iExclusionMgr.IsFolderAcceptedL(path, iStorages[0])) |
499 if (iExclusionMgr.IsFolderAcceptedL(path, iStorages[0])) |
474 { |
500 { |
475 path.Append('\\'); |
501 path.Append('\\'); |
476 ++len; |
502 ++len; |
477 format = EMTPFormatCodeAssociation; |
503 format = EMTPFormatCodeAssociation; |
478 AddEntryL(path, handle, format, iDpID, entry); |
504 AddEntryL(path, handle, format, iDpID, entry, iStorages[0], iParentHandle); |
479 iDirStack.AppendL(entry); |
505 iDirStack.AppendL(entry); |
480 } |
506 } |
481 } |
507 } |
482 else if ( iExclusionMgr.IsFileAcceptedL(path,iStorages[0]) ) |
508 else if ( iExclusionMgr.IsFileAcceptedL(path,iStorages[0]) ) |
483 { |
509 { |
484 format = EMTPFormatCodeUndefined; |
510 format = EMTPFormatCodeUndefined; |
485 AddEntryL(path, handle, format, iDpID, entry); |
511 AddEntryL(path, handle, format, iDpID, entry, iStorages[0], iParentHandle); |
486 } |
512 } |
487 else if ( parse.ExtPresent() ) |
513 else if ( parse.ExtPresent() ) |
488 { |
514 { |
489 switch(iDpSingletons.MTPUtility().GetEnumerationFlag(parse.Ext().Mid(1))) |
515 switch(iDpSingletons.MTPUtility().GetEnumerationFlag(parse.Ext().Mid(1))) |
490 { |
516 { |
491 case MISSED_FILES_OWNED_BY_FILE_DP: |
517 case MISSED_FILES_OWNED_BY_FILE_DP: |
492 if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(path)) |
518 if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(path)) |
493 { |
519 { |
494 format = EMTPFormatCodeUndefined; |
520 format = EMTPFormatCodeUndefined; |
495 AddEntryL(path, handle, format, iDpID, entry); |
521 AddEntryL(path, handle, format, iDpID, entry, iStorages[0], iParentHandle); |
496 } |
522 } |
497 break; |
523 break; |
498 |
524 |
499 case MISSED_FILES_OWNED_BY_OTHER_DP: |
525 case MISSED_FILES_OWNED_BY_OTHER_DP: |
500 if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(path)) |
526 if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(path)) |
501 { |
527 { |
502 format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1)); |
528 format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1)); |
503 TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC); |
529 TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC); |
504 AddFileEntryForOtherDpL(path, handle, format, DpId, entry); |
530 AddFileEntryForOtherDpL(path, handle, format, DpId, entry, iStorages[0], iParentHandle); |
505 } |
531 } |
506 break; |
532 break; |
507 |
533 |
508 case FILES_OWNED_BY_OTHER_DP: |
534 case FILES_OWNED_BY_OTHER_DP: |
509 { |
535 { |
510 format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1)); |
536 format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1)); |
511 TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC); |
537 TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC); |
512 AddFileEntryForOtherDpL(path, handle, format, DpId, entry); |
538 AddFileEntryForOtherDpL(path, handle, format, DpId, entry, iStorages[0], iParentHandle); |
513 } |
539 } |
514 break; |
540 break; |
515 |
541 |
516 // case FILES_OWNED_BY_NONE: |
542 // case FILES_OWNED_BY_NONE: |
517 default: |
543 default: |
529 Add a file entry to the object store |
555 Add a file entry to the object store |
530 @param aEntry The file Entry to be added |
556 @param aEntry The file Entry to be added |
531 @param aPath The full path name of the entry |
557 @param aPath The full path name of the entry |
532 @return MTP object handle, or KMTPHandleNone if entry was not accepted |
558 @return MTP object handle, or KMTPHandleNone if entry was not accepted |
533 */ |
559 */ |
534 void CMTPFSEnumerator::AddEntryL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& aEntry) |
560 void CMTPFSEnumerator::AddEntryL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& aEntry, TUint32 aStorageId, TUint32 aParentHandle) |
535 { |
561 { |
536 #ifdef __FLOG_ACTIVE |
562 #ifdef __FLOG_ACTIVE |
537 TBuf8<KMaxFileName> tmp; |
563 TBuf8<KMaxFileName> tmp; |
538 tmp.Copy(aPath); |
564 tmp.Copy(aPath); |
539 |
565 |
559 { |
585 { |
560 aHandle = KMTPHandleNone; |
586 aHandle = KMTPHandleNone; |
561 |
587 |
562 iObject->SetUint(CMTPObjectMetaData::EDataProviderId, aDPId); |
588 iObject->SetUint(CMTPObjectMetaData::EDataProviderId, aDPId); |
563 iObject->SetUint(CMTPObjectMetaData::EFormatCode, format); |
589 iObject->SetUint(CMTPObjectMetaData::EFormatCode, format); |
564 iObject->SetUint(CMTPObjectMetaData::EStorageId, iStorages[0]); |
590 iObject->SetUint(CMTPObjectMetaData::EStorageId, aStorageId); |
565 iObject->SetDesCL(CMTPObjectMetaData::ESuid, aPath); |
591 iObject->SetDesCL(CMTPObjectMetaData::ESuid, aPath); |
566 iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc); |
592 iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc); |
567 iObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle); |
593 iObject->SetUint(CMTPObjectMetaData::EParentHandle, aParentHandle); |
568 iObject->SetUint(CMTPObjectMetaData::ENonConsumable, EMTPConsumable); |
594 iObject->SetUint(CMTPObjectMetaData::ENonConsumable, EMTPConsumable); |
569 iObject->SetDesCL(CMTPObjectMetaData::EName, name); |
595 iObject->SetDesCL(CMTPObjectMetaData::EName, name); |
570 iFramework.ObjectMgr().InsertObjectL(*iObject); |
596 iFramework.ObjectMgr().InsertObjectL(*iObject); |
571 } |
597 } |
572 __FLOG_VA(_L8("AddEntryL - exit")); |
598 __FLOG_VA(_L8("AddEntryL - exit")); |
573 } |
599 } |
574 |
600 |
575 void CMTPFSEnumerator::AddFileEntryForOtherDpL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& /*aEntry*/) |
601 void CMTPFSEnumerator::AddFileEntryForOtherDpL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& /*aEntry*/, TUint32 aStorageId, TUint32 aParentHandle) |
576 { |
602 { |
577 #ifdef __FLOG_ACTIVE |
603 #ifdef __FLOG_ACTIVE |
578 TBuf8<KMaxFileName> tmp; |
604 TBuf8<KMaxFileName> tmp; |
579 tmp.Copy(aPath); |
605 tmp.Copy(aPath); |
580 |
606 |
587 |
613 |
588 aHandle = KMTPHandleNone; |
614 aHandle = KMTPHandleNone; |
589 |
615 |
590 iObject->SetUint(CMTPObjectMetaData::EDataProviderId, aDPId); |
616 iObject->SetUint(CMTPObjectMetaData::EDataProviderId, aDPId); |
591 iObject->SetUint(CMTPObjectMetaData::EFormatCode, format); |
617 iObject->SetUint(CMTPObjectMetaData::EFormatCode, format); |
592 iObject->SetUint(CMTPObjectMetaData::EStorageId, iStorages[0]); |
618 iObject->SetUint(CMTPObjectMetaData::EStorageId, aStorageId); |
593 iObject->SetDesCL(CMTPObjectMetaData::ESuid, aPath); |
619 iObject->SetDesCL(CMTPObjectMetaData::ESuid, aPath); |
594 iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc); |
620 iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc); |
595 iObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle); |
621 iObject->SetUint(CMTPObjectMetaData::EParentHandle, aParentHandle); |
596 iObject->SetUint(CMTPObjectMetaData::ENonConsumable, EMTPConsumable); |
622 iObject->SetUint(CMTPObjectMetaData::ENonConsumable, EMTPConsumable); |
597 iObject->SetDesCL(CMTPObjectMetaData::EName, name); |
623 iObject->SetDesCL(CMTPObjectMetaData::EName, name); |
598 iFramework.ObjectMgr().InsertObjectL(*iObject); |
624 iFramework.ObjectMgr().InsertObjectL(*iObject); |
599 __FLOG_VA(_L8("AddEntryL - exit")); |
625 __FLOG_VA(_L8("AddEntryL - exit")); |
600 } |
626 } |