mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp
changeset 29 3ae5cb0b4c02
parent 20 6e82ae192c3a
child 31 a26669f87b46
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp	Mon May 03 13:19:02 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp	Fri Jun 25 16:54:01 2010 +0800
@@ -455,8 +455,16 @@
     for (TInt i = (iFirstUnprocessed - count); i < iFirstUnprocessed; ++i)
         {
         const TEntry& entry = iEntries[i];
+        TInt len = entry.iName.Length();
+        if(iCurrentPath.Length()  + len > KMaxFileName)
+            {
+            __FLOG_VA(_L8("Full name exceeds KMaxFileName, ignored."));
+            continue;
+            }
+        
         iCurrentPath.Append(entry.iName);
-        __FLOG_VA((_L8("Process path %S name %S"), &iCurrentPath, &entry.iName));
+
+        __FLOG_VA((_L("Process path %S name %S"), &iCurrentPath, &entry.iName));
 #ifdef __FLOG_ACTIVE    
         TBuf8<KMTPMaxFullFileName> tmp;
         tmp.Copy(iCurrentPath);
@@ -478,15 +486,6 @@
             }
 #endif // __FLOG_ACTIVE
 
-        TInt len = entry.iName.Length();
-        TInt totalLen = iCurrentPath.Length();
-        if(totalLen > KMaxFileName)
-            {
-            // Remove filename part
-            iCurrentPath.SetLength(totalLen - len);
-            __FLOG_VA(_L8("Full name exceeds KMaxFileName, ignored."));
-            continue;
-            }
         TUint32 handle = 0;
         TMTPFormatCode format;
         if(-- iObjectNeedToScan <=0 && iAllRootScaned)
@@ -531,7 +530,7 @@
                         if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(iCurrentPath))
                             {
                             format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1));  
-                            TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC);
+                            TUint32 DpId = iDpSingletons.MTPUtility().GetDpIdL(parse.Ext().Mid(1), KNullDesC);
                             AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], iParentHandle);
                             }
                         break;
@@ -542,33 +541,23 @@
                         TUint32 DpId = iFramework.DataProviderId();
                         if (parse.Ext().CompareF(KTxtExtensionODF)==0)
                             {
-                            format = iDpSingletons.MTPUtility().FormatFromFilename(parse.Ext().Mid(1));
-                            if ( EMTPFormatCode3GPContainer==format || EMTPFormatCodeMP4Container==format )
+                            HBufC* mime = iDpSingletons.MTPUtility().ContainerMimeType(iCurrentPath);
+                            CleanupStack::PushL(mime);
+                            if ( mime != NULL )
                                 {
-                                DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1),KNullDesC);
-                                if ( 255 == DpId )
-                                    {
-                                    HBufC* mime = NULL;
-                                    mime = iDpSingletons.MTPUtility().ContainerMimeType(iCurrentPath);
-                                    if ( mime != NULL )
-                                        {
-                                        DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1),*mime);
-                                        delete mime;
-                                        mime = NULL;
-                                        }
-                                    }
-                                AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], iParentHandle);
+                                __FLOG_VA((_L("mime %S"), mime));
+                                DpId = iDpSingletons.MTPUtility().GetDpIdL(parse.Ext().Mid(1),*mime);
+                                __FLOG_VA((_L("DpId find %d"), DpId));
                                 }
-                            else
-                                {
-                                format = EMTPFormatCodeUndefined;
-                                AddEntryL(iCurrentPath, handle, format, iDpID, entry, iStorages[iScanPos], iParentHandle);
-                                }
+                            format = iDpSingletons.MTPUtility().GetFormatCodeByMimeTypeL(parse.Ext().Mid(1),*mime);
+                            AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], 
+                                    iParentHandle, iDpSingletons.MTPUtility().GetSubFormatCodeL(parse.Ext().Mid(1),*mime));
+                            CleanupStack::PopAndDestroy(mime);
                             }
                         else
                             {
                             format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1));  
-                            TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC);
+                            TUint32 DpId = iDpSingletons.MTPUtility().GetDpIdL(parse.Ext().Mid(1), KNullDesC);
                             AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], iParentHandle);
                             }
                         }
@@ -637,7 +626,7 @@
 	__FLOG_VA(_L8("AddEntryL - exit"));	
 	}
 
-void CMTPFSEnumerator::AddFileEntryForOtherDpL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& /*aEntry*/, TUint32 aStorageId, TUint32 aParentHandle)
+void CMTPFSEnumerator::AddFileEntryForOtherDpL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& /*aEntry*/, TUint32 aStorageId, TUint32 aParentHandle, TUint16 aSubFormatCode/* = 0*/)
     {
 #ifdef __FLOG_ACTIVE    
     TBuf8<KMaxFileName> tmp;
@@ -646,7 +635,6 @@
     __FLOG_VA((_L8("AddFileEntryForOtherDpL - entry: %S"), &tmp));
 #endif // __FLOG_ACTIVE
 
-    TUint16 assoc = EMTPAssociationTypeUndefined;
     TParsePtrC pathParser(aPath);
     TPtrC name(pathParser.Name());    
     
@@ -656,7 +644,7 @@
     iObject->SetUint(CMTPObjectMetaData::EFormatCode, format);
     iObject->SetUint(CMTPObjectMetaData::EStorageId, aStorageId);
     iObject->SetDesCL(CMTPObjectMetaData::ESuid, aPath);
-    iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc);
+    iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, aSubFormatCode);
     iObject->SetUint(CMTPObjectMetaData::EParentHandle, aParentHandle);
     iObject->SetUint(CMTPObjectMetaData::ENonConsumable, EMTPConsumable);
     iObject->SetDesCL(CMTPObjectMetaData::EName, name);