mtpfws/mtpfw/dataproviders/dputility/src/cmtprequestchecker.cpp
branchRCL_3
changeset 4 60a94a45d437
parent 0 d0791faffa3f
equal deleted inserted replaced
3:8b094906a049 4:60a94a45d437
    19 #include <mtp/mmtpdataproviderframework.h>
    19 #include <mtp/mmtpdataproviderframework.h>
    20 #include <mtp/mmtpobjectmgr.h>
    20 #include <mtp/mmtpobjectmgr.h>
    21 #include <mtp/mmtpstoragemgr.h>
    21 #include <mtp/mmtpstoragemgr.h>
    22 
    22 
    23 #include "cmtprequestchecker.h"
    23 #include "cmtprequestchecker.h"
    24 #include "rmtpdpsingletons.h"
       
    25 #include "cmtpfsexclusionmgr.h"
    24 #include "cmtpfsexclusionmgr.h"
       
    25 #include "cmtpfsentrycache.h"
    26 
    26 
    27 static const TInt KMTPRequestCheckerHandleGranularity = 2;
    27 static const TInt KMTPRequestCheckerHandleGranularity = 2;
    28 __FLOG_STMT(_LIT8(KComponent,"MTPRequestChecker");)
    28 __FLOG_STMT(_LIT8(KComponent,"MTPRequestChecker");)
    29 
    29 
    30 /**
    30 /**
    34 @return a pointer to the created request checker object
    34 @return a pointer to the created request checker object
    35 */   
    35 */   
    36 EXPORT_C CMTPRequestChecker* CMTPRequestChecker::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
    36 EXPORT_C CMTPRequestChecker* CMTPRequestChecker::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
    37 	{
    37 	{
    38 	CMTPRequestChecker* self = new (ELeave) CMTPRequestChecker(aFramework, aConnection);
    38 	CMTPRequestChecker* self = new (ELeave) CMTPRequestChecker(aFramework, aConnection);
       
    39 	CleanupStack::PushL(self);
       
    40 	self->ConstructL();
       
    41 	CleanupStack::Pop(self);
    39 	return self;
    42 	return self;
    40 	}
    43 	}
    41 
    44 
    42 /**
    45 /**
    43 Destructor
    46 Destructor
    44 */	
    47 */	
    45 EXPORT_C CMTPRequestChecker::~CMTPRequestChecker()
    48 EXPORT_C CMTPRequestChecker::~CMTPRequestChecker()
    46 	{
    49 	{
       
    50 	iDpSingletons.Close();
    47 	iHandles.Close();
    51 	iHandles.Close();
    48 	iObjectArray.ResetAndDestroy();
    52 	iObjectArray.ResetAndDestroy();
    49 	__FLOG_CLOSE;
    53 	__FLOG_CLOSE;
    50 	}
    54 	}
    51 
    55 
   213 		
   217 		
   214 	// Obj handle exists
   218 	// Obj handle exists
   215 	if (result)
   219 	if (result)
   216 		{
   220 		{
   217 	    TUint storageID = object->Uint(CMTPObjectMetaData::EStorageId);
   221 	    TUint storageID = object->Uint(CMTPObjectMetaData::EStorageId);
       
   222 	    if(!iFramework.StorageMgr().ValidStorageId(storageID))
       
   223 	    	{
       
   224 			return EMTPRespCodeInvalidObjectHandle;
       
   225 	    	}
       
   226 	    
   218 		CMTPStorageMetaData* storageMetaData = (CMTPStorageMetaData *)& iFramework.StorageMgr().StorageL(storageID);
   227 		CMTPStorageMetaData* storageMetaData = (CMTPStorageMetaData *)& iFramework.StorageMgr().StorageL(storageID);
   219 		if (storageMetaData->Uint(CMTPStorageMetaData::EStorageSystemType) != CMTPStorageMetaData::ESystemTypeDefaultFileSystem)
   228 		if (storageMetaData->Uint(CMTPStorageMetaData::EStorageSystemType) != CMTPStorageMetaData::ESystemTypeDefaultFileSystem)
   220 			{
   229 			{
   221 			return ret;
   230 			return ret;
   222 			}
   231 			}
   231             // Special association type .. not always present on the filesystem.
   240             // Special association type .. not always present on the filesystem.
   232             return ret;
   241             return ret;
   233             }   
   242             }   
   234         else
   243         else
   235             {
   244             {
       
   245             if ( err != KErrNone )
       
   246             	{
       
   247             	if( (iDpSingletons.CopyingBigFileCache().TargetHandle() == aHandle) &&
       
   248             			(iDpSingletons.CopyingBigFileCache().IsOnGoing()))
       
   249             		{
       
   250             		// The object is being copied, it is not created in fs yet. Use its cache entry for check
       
   251             		__FLOG(_L8("VerifyObjectHandleL - The object is being copied, use its cache entry for check"));
       
   252             		entry = iDpSingletons.CopyingBigFileCache().FileEntry();
       
   253             		err = KErrNone;
       
   254             		}
       
   255             	else if( (iDpSingletons.MovingBigFileCache().TargetHandle() == aHandle) &&
       
   256             						(iDpSingletons.MovingBigFileCache().IsOnGoing()))
       
   257             		{
       
   258             		// The object is being moved, it is not created in fs yet. Use its cache entry for check
       
   259             		__FLOG(_L8("VerifyObjectHandleL - The object is being moved, use its cache entry for check"));
       
   260             		entry = iDpSingletons.MovingBigFileCache().FileEntry();
       
   261             		err = KErrNone;
       
   262             		}            	
       
   263             	}
   236             User::LeaveIfError(err);
   264             User::LeaveIfError(err);
   237             }
   265             }
   238 		
   266 		
   239 		if (aElementInfo.iElementAttr & EMTPElementAttrWrite)
   267 		if (aElementInfo.iElementAttr & EMTPElementAttrWrite)
   240         	{
   268         	{
   386 	iObjectArray(KMTPRequestCheckerHandleGranularity)
   414 	iObjectArray(KMTPRequestCheckerHandleGranularity)
   387 	{
   415 	{
   388 	__FLOG_OPEN(KMTPSubsystem, KComponent);
   416 	__FLOG_OPEN(KMTPSubsystem, KComponent);
   389 	}
   417 	}
   390 
   418 
   391 
   419 /**
   392 
   420  Second phase constructor
       
   421 */
       
   422 void CMTPRequestChecker::ConstructL()
       
   423 	{
       
   424 	iDpSingletons.OpenL(iFramework);
       
   425 	}
       
   426 
       
   427