mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp
branchRCL_3
changeset 6 ef55b168cedb
parent 4 60a94a45d437
child 15 f85613f12947
equal deleted inserted replaced
5:3673b591050c 6:ef55b168cedb
    18  @internalTechnology
    18  @internalTechnology
    19 */
    19 */
    20 
    20 
    21 #include <f32file.h>
    21 #include <f32file.h>
    22 #include <bautils.h>
    22 #include <bautils.h>
       
    23 #include <e32const.h>
    23 
    24 
    24 #include <mtp/mmtpdataproviderframework.h>
    25 #include <mtp/mmtpdataproviderframework.h>
    25 
       
    26 #include <mtp/cmtpobjectmetadata.h>
    26 #include <mtp/cmtpobjectmetadata.h>
    27 #include <mtp/cmtptypefile.h>
    27 #include <mtp/cmtptypefile.h>
    28 #include <mtp/cmtptypeobjectinfo.h>
    28 #include <mtp/cmtptypeobjectinfo.h>
    29 #include <mtp/cmtptypeobjectproplist.h>
    29 #include <mtp/cmtptypeobjectproplist.h>
    30 #include <mtp/cmtptypestring.h>
    30 #include <mtp/cmtptypestring.h>
   320         
   320         
   321         if (iStorageId == KMTPStorageDefault)
   321         if (iStorageId == KMTPStorageDefault)
   322             {
   322             {
   323             iStorageId = iFramework.StorageMgr().DefaultStorageId();
   323             iStorageId = iFramework.StorageMgr().DefaultStorageId();
   324             }
   324             }
   325              
   325         
       
   326         if(IsTooLarge(iObjectSize))
       
   327             {
       
   328             *ret = EMTPRespCodeObjectTooLarge;
       
   329             }
   326         }
   330         }
   327     
   331     
   328     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL - Exit"));
   332     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL - Exit"));
   329     return (*ret == EMTPRespCodeOK) ? ETrue : EFalse;
   333     return (*ret == EMTPRespCodeOK) ? ETrue : EFalse;
   330     }
   334     }
   606         }
   610         }
   607         
   611         
   608     if (result)
   612     if (result)
   609         {
   613         {
   610         iObjectSize = iObjectInfo->Uint32L(CMTPTypeObjectInfo::EObjectCompressedSize);
   614         iObjectSize = iObjectInfo->Uint32L(CMTPTypeObjectInfo::EObjectCompressedSize);
       
   615         if(IsTooLarge(iObjectSize))
       
   616             {
       
   617             SendResponseL(EMTPRespCodeObjectTooLarge);
       
   618             result = EFalse;
       
   619             }
   611         }
   620         }
   612 
   621 
   613     if (result)
   622     if (result)
   614         {
   623         {
   615         iProtectionStatus = iObjectInfo->Uint16L(CMTPTypeObjectInfo::EProtectionStatus);
   624         iProtectionStatus = iObjectInfo->Uint16L(CMTPTypeObjectInfo::EProtectionStatus);
  1275         break;
  1284         break;
  1276         }
  1285         }
  1277         
  1286         
  1278     return resp;
  1287     return resp;
  1279     }
  1288     }
       
  1289 
       
  1290 /**
       
  1291 Check if the object is too large
       
  1292 @return ETrue if yes, otherwise EFalse
       
  1293 */
       
  1294 TBool CMTPImageDpSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const
       
  1295     {
       
  1296     __FLOG(_L8("IsTooLarge - Entry"));
       
  1297     TBool ret(aObjectSize > KMaxTInt64);
       
  1298     
       
  1299     if(!ret)
       
  1300         {
       
  1301         TBuf<255> fsname;
       
  1302         TUint32 storageId = iStorageId;
       
  1303         if (storageId == KMTPStorageDefault)
       
  1304             {
       
  1305             storageId = iFramework.StorageMgr().DefaultStorageId();
       
  1306             }
       
  1307         TInt drive( iFramework.StorageMgr().DriveNumber(storageId) );
       
  1308         if(drive != KErrNotFound)
       
  1309             {
       
  1310             iFramework.Fs().FileSystemSubType(drive, fsname);        
       
  1311         
       
  1312             const TUint64 KMaxFatFileSize = 0xFFFFFFFF; //Maximal file size supported by all FAT filesystems (4GB-1)
       
  1313             _LIT(KFsFAT16, "FAT16");
       
  1314             _LIT(KFsFAT32, "FAT32");
       
  1315         
       
  1316             if((fsname.CompareF(KFsFAT16) == 0 || fsname.CompareF(KFsFAT32) == 0) && aObjectSize > KMaxFatFileSize)
       
  1317                 {
       
  1318                 ret = ETrue;
       
  1319                 }
       
  1320             }
       
  1321         }
       
  1322     __FLOG_VA((_L8("Result = %d"), ret));
       
  1323     __FLOG(_L8("IsTooLarge - Exit"));
       
  1324     return ret;
       
  1325     }