mtpdataproviders/mtpimagedp/src/cmtpimagedpgetpartialobject.cpp
changeset 47 63cf70d3ecd8
parent 17 aabe5387f5ce
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    31 #include "mtpimagedppanic.h"
    31 #include "mtpimagedppanic.h"
    32 #include "mtpimagedpconst.h"
    32 #include "mtpimagedpconst.h"
    33 #include "cmtpimagedp.h"
    33 #include "cmtpimagedp.h"
    34 #include "mtpimagedputilits.h"
    34 #include "mtpimagedputilits.h"
    35 #include "cmtpimagedpobjectpropertymgr.h"
    35 #include "cmtpimagedpobjectpropertymgr.h"
       
    36 #include "OstTraceDefinitions.h"
       
    37 #ifdef OST_TRACE_COMPILER_IN_USE
       
    38 #include "cmtpimagedpgetpartialobjectTraces.h"
       
    39 #endif
    36 
    40 
    37 __FLOG_STMT(_LIT8(KComponent,"ImageDpGetPartialObject");)
    41 
    38 /**
    42 /**
    39 Verification data for the GetPartialObject request
    43 Verification data for the GetPartialObject request
    40 */
    44 */
    41 
    45 
    42 /**
    46 /**
    57 /**
    61 /**
    58 Destructor
    62 Destructor
    59 */	
    63 */	
    60 CMTPImageDpGetPartialObject::~CMTPImageDpGetPartialObject()
    64 CMTPImageDpGetPartialObject::~CMTPImageDpGetPartialObject()
    61     {
    65     {
    62     __FLOG(_L8(">> CMTPImageDpGetPartialObject::~CMTPImageDpGetPartialObject"));
    66     OstTraceFunctionEntry0( CMTPIMAGEDPGETPARTIALOBJECT_CMTPIMAGEDPGETPARTIALOBJECT_ENTRY );
    63     delete iFileObject;
    67     delete iFileObject;
    64     delete iObjectMeta;
    68     delete iObjectMeta;
    65     __FLOG(_L8("<< CMTPImageDpGetPartialObject::~CMTPImageDpGetPartialObject"));
    69     OstTraceFunctionExit0( CMTPIMAGEDPGETPARTIALOBJECT_CMTPIMAGEDPGETPARTIALOBJECT_EXIT );
    66     __FLOG_CLOSE;
       
    67     }
    70     }
    68     
    71     
    69 /**
    72 /**
    70 Standard c++ constructor
    73 Standard c++ constructor
    71 @param aFramework	The data provider framework
    74 @param aFramework	The data provider framework
    80 /**
    83 /**
    81 Second-phase construction
    84 Second-phase construction
    82 */  
    85 */  
    83 void CMTPImageDpGetPartialObject::ConstructL()
    86 void CMTPImageDpGetPartialObject::ConstructL()
    84     {
    87     {
    85     __FLOG_OPEN(KMTPSubsystem, KComponent);
    88     OstTraceFunctionEntry0( CMTPIMAGEDPGETPARTIALOBJECT_CONSTRUCTL_ENTRY );
    86     __FLOG(_L8(">> CMTPImageDpGetPartialObject::ConstructL"));
       
    87     iObjectMeta = CMTPObjectMetaData::NewL();
    89     iObjectMeta = CMTPObjectMetaData::NewL();
    88     __FLOG(_L8("<< CMTPImageDpGetPartialObject::ConstructL"));
    90     OstTraceFunctionExit0( CMTPIMAGEDPGETPARTIALOBJECT_CONSTRUCTL_EXIT );
    89     }
    91     }
    90     
    92     
    91 /**
    93 /**
    92 Check the GetPartialObject reqeust
    94 Check the GetPartialObject reqeust
    93 @return EMTPRespCodeOK if the request is good, otherwise, one of the error response codes
    95 @return EMTPRespCodeOK if the request is good, otherwise, one of the error response codes
    94 */	
    96 */	
    95 TMTPResponseCode CMTPImageDpGetPartialObject::CheckRequestL()
    97 TMTPResponseCode CMTPImageDpGetPartialObject::CheckRequestL()
    96     {
    98     {
    97     __FLOG(_L8(">> CMTPImageDpGetPartialObject::CheckRequestL"));
    99     OstTraceFunctionEntry0( CMTPIMAGEDPGETPARTIALOBJECT_CHECKREQUESTL_ENTRY );
    98     TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
   100     TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
    99     if(result == EMTPRespCodeOK)
   101     if(result == EMTPRespCodeOK)
   100         {
   102         {
   101         result = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta);
   103         result = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta);
   102         }
   104         }
   103     if(result == EMTPRespCodeOK && !VerifyParametersL())
   105     if(result == EMTPRespCodeOK && !VerifyParametersL())
   104         {
   106         {
   105         result = EMTPRespCodeInvalidParameter;
   107         result = EMTPRespCodeInvalidParameter;
   106         }
   108         }
   107     __FLOG_VA((_L8("<< CMTPImageDpGetPartialObject::CheckRequestL 0x%x"), result));
   109     OstTrace1( TRACE_NORMAL, CMTPIMAGEDPGETPARTIALOBJECT_CHECKREQUESTL, "CheckRequestL result 0x%x", result );
   108     __FLOG(_L8("<< CMTPImageDpGetPartialObject::CheckRequestL"));
   110     OstTraceFunctionExit0( CMTPIMAGEDPGETPARTIALOBJECT_CHECKREQUESTL_EXIT );
   109     return result;	
   111     return result;	
   110     }
   112     }
   111     
   113     
   112 /**
   114 /**
   113 Verify if the parameter of the request (i.e. offset) is good.
   115 Verify if the parameter of the request (i.e. offset) is good.
   114 @return ETrue if the parameter is good, otherwise, EFalse
   116 @return ETrue if the parameter is good, otherwise, EFalse
   115 */		
   117 */		
   116 TBool CMTPImageDpGetPartialObject::VerifyParametersL()
   118 TBool CMTPImageDpGetPartialObject::VerifyParametersL()
   117     {
   119     {
   118     __FLOG(_L8(">> CMTPImageDpGetPartialObject::VerifyParametersL"));
   120     OstTraceFunctionEntry0( CMTPIMAGEDPGETPARTIALOBJECT_VERIFYPARAMETERSL_ENTRY );
   119     TBool result = EFalse;
   121     TBool result = EFalse;
   120     iOffset = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   122     iOffset = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   121     iMaxLength = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
   123     iMaxLength = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
   122 
   124 
   123     TEntry fileEntry;
   125     TEntry fileEntry;
   124     User::LeaveIfError(iFs.Entry(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), fileEntry));
   126     LEAVEIFERROR(iFs.Entry(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), fileEntry),
       
   127             OstTraceExt2( TRACE_ERROR, DUP1_CMTPIMAGEDPGETPARTIALOBJECT_VERIFYPARAMETERSL, 
       
   128                     "Gets the entry details for %S failed! error code %d", iObjectMeta->DesC(CMTPObjectMetaData::ESuid), munged_err));
       
   129          
   125     if((iOffset < fileEntry.FileSize())) 
   130     if((iOffset < fileEntry.FileSize())) 
   126         {
   131         {
   127         result = ETrue;
   132         result = ETrue;
   128         }
   133         }
   129     __FLOG_VA((_L8("<< CMTPImageDpGetPartialObject::VerifyParametersL %d"), result));
   134     OstTrace1( TRACE_NORMAL, CMTPIMAGEDPGETPARTIALOBJECT_VERIFYPARAMETERSL, 
       
   135             "VerifyParametersL result %d", result );    
       
   136     OstTraceFunctionExit0( CMTPIMAGEDPGETPARTIALOBJECT_VERIFYPARAMETERSL_EXIT );
   130     return result;	
   137     return result;	
   131     }
   138     }
   132 /**
   139 /**
   133 GetPartialObject request handler
   140 GetPartialObject request handler
   134 Send the partial object data to the initiator
   141 Send the partial object data to the initiator
   135 */	
   142 */	
   136 void CMTPImageDpGetPartialObject::ServiceL()
   143 void CMTPImageDpGetPartialObject::ServiceL()
   137     {
   144     {
       
   145     OstTraceFunctionEntry0( CMTPIMAGEDPGETPARTIALOBJECT_SERVICEL_ENTRY );
   138     // Get file information
   146     // Get file information
   139     __FLOG(_L8(">> CMTPImageDpGetPartialObject::ServiceL"));
       
   140         // Pass the complete file back to the host
   147         // Pass the complete file back to the host
   141     iFileObject = CMTPTypeFile::NewL(iFramework.Fs(), iObjectMeta->DesC(CMTPObjectMetaData::ESuid), (TFileMode)(EFileRead | EFileShareReadersOnly), iMaxLength, iOffset);
   148     iFileObject = CMTPTypeFile::NewL(iFramework.Fs(), iObjectMeta->DesC(CMTPObjectMetaData::ESuid), (TFileMode)(EFileRead | EFileShareReadersOnly), iMaxLength, iOffset);
   142     SendDataL(*iFileObject);	
   149     SendDataL(*iFileObject);	
   143     __FLOG(_L8("<< CMTPImageDpGetPartialObject::ServiceL"));
   150     OstTraceFunctionExit0( CMTPIMAGEDPGETPARTIALOBJECT_SERVICEL_EXIT );
   144     }
   151     }
   145     
   152     
   146     
   153     
   147 /**
   154 /**
   148 Signal to the initiator how much data has been sent
   155 Signal to the initiator how much data has been sent
   149 @return EFalse
   156 @return EFalse
   150 */
   157 */
   151 TBool CMTPImageDpGetPartialObject::DoHandleResponsePhaseL()
   158 TBool CMTPImageDpGetPartialObject::DoHandleResponsePhaseL()
   152     {
   159     {
   153     __FLOG(_L8(">> CMTPImageDpGetPartialObject::DoHandleResponsePhaseL"));
   160     OstTraceFunctionEntry0( CMTPIMAGEDPGETPARTIALOBJECT_DOHANDLERESPONSEPHASEL_ENTRY );
   154     TUint32 dataLength = iFileObject->GetByteSent();
   161     TUint32 dataLength = iFileObject->GetByteSent();
   155     SendResponseL(EMTPRespCodeOK, 1, &dataLength);
   162     SendResponseL(EMTPRespCodeOK, 1, &dataLength);
   156     __FLOG(_L8("<< CMTPImageDpGetPartialObject::DoHandleResponsePhaseL"));
   163     OstTraceFunctionExit0( CMTPIMAGEDPGETPARTIALOBJECT_DOHANDLERESPONSEPHASEL_EXIT );
   157     return EFalse;
   164     return EFalse;
   158     }
   165     }