mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetpartialobject.cpp
changeset 47 63cf70d3ecd8
parent 17 aabe5387f5ce
child 52 866b4af7ffbe
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    23 #include <mtp/mtpprotocolconstants.h>
    23 #include <mtp/mtpprotocolconstants.h>
    24 #include <mtp/tmtptyperequest.h>
    24 #include <mtp/tmtptyperequest.h>
    25 
    25 
    26 #include "cmtpgetpartialobject.h"
    26 #include "cmtpgetpartialobject.h"
    27 #include "mtpdppanic.h"
    27 #include "mtpdppanic.h"
       
    28 #include "mtpdebug.h"
       
    29 #include "OstTraceDefinitions.h"
       
    30 #ifdef OST_TRACE_COMPILER_IN_USE
       
    31 #include "cmtpgetpartialobjectTraces.h"
       
    32 #endif
    28 
    33 
    29 // Class constants.
       
    30 __FLOG_STMT(_LIT8(KComponent,"GetObject");)
       
    31 
    34 
    32 /**
    35 /**
    33 Verification data for the GetNumObjects request
    36 Verification data for the GetNumObjects request
    34 */
    37 */
    35 const TMTPRequestElementInfo KMTPGetPartialObjectPolicy[] = 
    38 const TMTPRequestElementInfo KMTPGetPartialObjectPolicy[] = 
    56 /**
    59 /**
    57 Destructor
    60 Destructor
    58 */	
    61 */	
    59 EXPORT_C CMTPGetPartialObject::~CMTPGetPartialObject()
    62 EXPORT_C CMTPGetPartialObject::~CMTPGetPartialObject()
    60 	{	
    63 	{	
    61     __FLOG(_L8("~CMTPGetPartialObject - Entry"));
    64     OstTraceFunctionEntry0( CMTPGETPARTIALOBJECT_CMTPGETPARTIALOBJECT_DES_ENTRY );
    62 	delete iFileObject;
    65 	delete iFileObject;
    63     __FLOG(_L8("~CMTPGetPartialObject - Exit"));
    66 	OstTraceFunctionExit0( CMTPGETPARTIALOBJECT_CMTPGETPARTIALOBJECT_DES_EXIT );
    64     __FLOG_CLOSE;
       
    65 	}
    67 	}
    66 	
    68 	
    67 /**
    69 /**
    68 Standard c++ constructor
    70 Standard c++ constructor
    69 */	
    71 */	
    76 /**
    78 /**
    77 Second-phase constructor.
    79 Second-phase constructor.
    78 */        
    80 */        
    79 void CMTPGetPartialObject::ConstructL()
    81 void CMTPGetPartialObject::ConstructL()
    80     {
    82     {
    81     __FLOG_OPEN(KMTPSubsystem, KComponent);
    83     OstTraceFunctionEntry0( CMTPGETPARTIALOBJECT_CONSTRUCTL_ENTRY );
    82     __FLOG(_L8("ConstructL - Entry"));
    84     OstTraceFunctionExit0( CMTPGETPARTIALOBJECT_CONSTRUCTL_EXIT );
    83     __FLOG(_L8("ConstructL - Exit"));
       
    84     }
    85     }
    85 
    86 
    86 /**
    87 /**
    87 Check the GetPartialObject reqeust
    88 Check the GetPartialObject reqeust
    88 @return EMTPRespCodeOK if the request is good, otherwise, one of the error response codes
    89 @return EMTPRespCodeOK if the request is good, otherwise, one of the error response codes
    89 */  
    90 */  
    90 TMTPResponseCode CMTPGetPartialObject::CheckRequestL()
    91 TMTPResponseCode CMTPGetPartialObject::CheckRequestL()
    91     {
    92     {
    92     __FLOG(_L8("CheckRequestL - Entry"));
    93     OstTraceFunctionEntry0( CMTPGETPARTIALOBJECT_CHECKREQUESTL_ENTRY );
    93     TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
    94     TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
    94     if(result == EMTPRespCodeOK)
    95     if(result == EMTPRespCodeOK)
    95         {
    96         {
    96         TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
    97         TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
    97         iOffset = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
    98         iOffset = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   107             result = EMTPRespCodeInvalidObjectHandle;
   108             result = EMTPRespCodeInvalidObjectHandle;
   108             }
   109             }
   109         else
   110         else
   110             {
   111             {
   111             TEntry fileEntry;
   112             TEntry fileEntry;
   112             User::LeaveIfError(iFramework.Fs().Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry));
   113             LEAVEIFERROR(iFramework.Fs().Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry),
       
   114                     OstTraceExt1(TRACE_ERROR, CMTPGETPARTIALOBJECT_CHECKREQUESTL, 
       
   115                             "can't get entry details for %S!", iObjectInfo->DesC(CMTPObjectMetaData::ESuid)));
   113 
   116 
   114             if((iOffset >= fileEntry.FileSize())) 
   117             if((iOffset >= fileEntry.FileSize())) 
   115                 {
   118                 {
   116                 result = EMTPRespCodeInvalidParameter;
   119                 result = EMTPRespCodeInvalidParameter;
   117                 }
   120                 }
   118             }
   121             }
   119         }
   122         }
   120 
   123 
   121     __FLOG(_L8("CheckRequestL - Exit"));
   124     OstTraceFunctionExit0( CMTPGETPARTIALOBJECT_CHECKREQUESTL_EXIT );
   122     return result;  
   125     return result;  
   123     }
   126     }
   124 
   127 
   125 /**
   128 /**
   126 GetObject request handler
   129 GetObject request handler
   127 */		
   130 */		
   128 void CMTPGetPartialObject::ServiceL()
   131 void CMTPGetPartialObject::ServiceL()
   129 	{
   132 	{
   130     __FLOG(_L8("ServiceL - Entry"));
   133     OstTraceFunctionEntry0( CMTPGETPARTIALOBJECT_SERVICEL_ENTRY );
   131     
   134     
   132 	if (!iObjectInfo)
   135 	if (!iObjectInfo)
   133 	    {
   136 	    {
   134 	    SendResponseL(EMTPRespCodeInvalidObjectHandle);
   137 	    SendResponseL(EMTPRespCodeInvalidObjectHandle);
   135 	    }
   138 	    }
   137         {
   140         {
   138         delete iFileObject;
   141         delete iFileObject;
   139         iFileObject = CMTPTypeFile::NewL(iFramework.Fs(), iObjectInfo->DesC(CMTPObjectMetaData::ESuid), EFileRead, iLength, iOffset);
   142         iFileObject = CMTPTypeFile::NewL(iFramework.Fs(), iObjectInfo->DesC(CMTPObjectMetaData::ESuid), EFileRead, iLength, iOffset);
   140     	SendDataL(*iFileObject);
   143     	SendDataL(*iFileObject);
   141         }
   144         }
   142 	
   145 
   143     __FLOG(_L8("ServiceL - Exit"));
   146 	OstTraceFunctionExit0( CMTPGETPARTIALOBJECT_SERVICEL_EXIT );
   144 	}
   147 	}
   145 
   148 
   146 /**
   149 /**
   147 Handle the response phase of the current request
   150 Handle the response phase of the current request
   148 @return EFalse
   151 @return EFalse
   149 */		
   152 */		
   150 TBool CMTPGetPartialObject::DoHandleResponsePhaseL()
   153 TBool CMTPGetPartialObject::DoHandleResponsePhaseL()
   151 	{
   154 	{
   152     __FLOG(_L8("DoHandleResponsePhaseL - Entry"));
   155     OstTraceFunctionEntry0( CMTPGETPARTIALOBJECT_DOHANDLERESPONSEPHASEL_ENTRY );
   153     __ASSERT_DEBUG(iFileObject, Panic(EMTPDpObjectNull));
   156     __ASSERT_DEBUG(iFileObject, Panic(EMTPDpObjectNull));
   154 
   157 
   155     TUint32 dataLength = iFileObject->GetByteSent();
   158     TUint32 dataLength = iFileObject->GetByteSent();
   156 	SendResponseL(EMTPRespCodeOK, 1, &dataLength);
   159 	SendResponseL(EMTPRespCodeOK, 1, &dataLength);
   157 	
   160 
   158     __FLOG(_L8("DoHandleResponsePhaseL - Exit"));
   161 	OstTraceFunctionExit0( CMTPGETPARTIALOBJECT_DOHANDLERESPONSEPHASEL_EXIT );
   159 	return EFalse;
   162 	return EFalse;
   160 	}
   163 	}
   161 
   164 
   162 
   165