mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp
changeset 49 c20dd21d1eb4
parent 31 a26669f87b46
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    40 #include "mtpimagedppanic.h"
    40 #include "mtpimagedppanic.h"
    41 #include "mtpimagedpconst.h"
    41 #include "mtpimagedpconst.h"
    42 #include "cmtpimagedpthumbnailcreator.h"
    42 #include "cmtpimagedpthumbnailcreator.h"
    43 #include "mtpimagedputilits.h"
    43 #include "mtpimagedputilits.h"
    44 #include "cmtpimagedp.h"
    44 #include "cmtpimagedp.h"
    45 
    45 #include "OstTraceDefinitions.h"
    46 // Class constants.
    46 #ifdef OST_TRACE_COMPILER_IN_USE
    47 __FLOG_STMT(_LIT8(KComponent, "ImageDPSendObjectInfo");)
    47 #include "cmtpimagedpsendobjectinfoTraces.h"
       
    48 #endif
       
    49 
    48 
    50 
    49 const TInt RollbackFuncCnt = 3;
    51 const TInt RollbackFuncCnt = 3;
    50 
    52 
    51 const TMTPRequestElementInfo KMTPSendObjectPropListPolicy[] = 
    53 const TMTPRequestElementInfo KMTPSendObjectPropListPolicy[] = 
    52     {
    54     {
    71 /**
    73 /**
    72 Destructor
    74 Destructor
    73 */    
    75 */    
    74 CMTPImageDpSendObjectInfo::~CMTPImageDpSendObjectInfo()
    76 CMTPImageDpSendObjectInfo::~CMTPImageDpSendObjectInfo()
    75     {
    77     {
    76     __FLOG(_L8("CMTPImageDpSendObjectInfo::~CMTPImageDpSendObjectInfo - Entry"));   
    78     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_CMTPIMAGEDPSENDOBJECTINFO_DES_ENTRY );
    77         
    79         
    78     Rollback();
    80     Rollback();
    79     iRollbackList.Close();
    81     iRollbackList.Close();
    80 
    82 
    81     delete iDateMod;
    83     delete iDateMod;
    83     delete iFileReceived;
    85     delete iFileReceived;
    84     delete iParentSuid;    
    86     delete iParentSuid;    
    85     delete iReceivedObject;
    87     delete iReceivedObject;
    86     delete iObjectInfo;
    88     delete iObjectInfo;
    87     delete iObjectPropList;
    89     delete iObjectPropList;
    88     
    90 
    89     __FLOG(_L8("CMTPImageDpSendObjectInfo::~CMTPImageDpSendObjectInfo - Exit"));
    91     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CMTPIMAGEDPSENDOBJECTINFO_DES_EXIT );
    90     __FLOG_CLOSE; 
       
    91     }
    92     }
    92 
    93 
    93 /**
    94 /**
    94 Standard c++ constructor
    95 Standard c++ constructor
    95 @param aFramework    The data provider framework
    96 @param aFramework    The data provider framework
    96 @param aConnection    The connection from which the request comes
    97 @param aConnection    The connection from which the request comes
    97 */    
    98 */    
    98 CMTPImageDpSendObjectInfo::CMTPImageDpSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider) :
    99 CMTPImageDpSendObjectInfo::CMTPImageDpSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider) :
    99     CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
   100     CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
   100     iDataProvider(aDataProvider),
   101     iDataProvider(aDataProvider),
       
   102     iHiddenStatus( EMTPVisible ),
   101     iObjectPropertyMgr(aDataProvider.PropertyMgr())
   103     iObjectPropertyMgr(aDataProvider.PropertyMgr())
   102     {
   104     {
   103 
   105 
   104     }
   106     }
   105 
   107 
   111 /**
   113 /**
   112 Second-phase construction
   114 Second-phase construction
   113 */        
   115 */        
   114 void CMTPImageDpSendObjectInfo::ConstructL()
   116 void CMTPImageDpSendObjectInfo::ConstructL()
   115     {
   117     {
   116     __FLOG_OPEN(KMTPSubsystem, KComponent);
   118     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_CONSTRUCTL_ENTRY );
   117     __FLOG(_L8("CMTPImageDpSendObjectInfo::ConstructL - Entry"));   
       
   118          
   119          
   119     iRollbackList.ReserveL(RollbackFuncCnt);
   120     iRollbackList.ReserveL(RollbackFuncCnt);
   120     iExpectedSendObjectRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, EMTPOpCodeSendObject);
   121     iExpectedSendObjectRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, EMTPOpCodeSendObject);
   121     iReceivedObject = CMTPObjectMetaData::NewL();
   122     iReceivedObject = CMTPObjectMetaData::NewL();
   122     iReceivedObject->SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId());
   123     iReceivedObject->SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId());
   145     ADD_FSM_ENTRY(EObjectCheck, EObjectEvent,         EObjectServ, EObjectInfoSucceed, FsmServiceSendObjectL);
   146     ADD_FSM_ENTRY(EObjectCheck, EObjectEvent,         EObjectServ, EObjectInfoSucceed, FsmServiceSendObjectL);
   146     
   147     
   147     ADD_FSM_ENTRY(EObjectServ, EObjectInfoEvent,     EStateEnd,   EStateEnd,  NULL);
   148     ADD_FSM_ENTRY(EObjectServ, EObjectInfoEvent,     EStateEnd,   EStateEnd,  NULL);
   148     ADD_FSM_ENTRY(EObjectServ, EObjectPropListEvent, EStateEnd,   EStateEnd,  NULL);
   149     ADD_FSM_ENTRY(EObjectServ, EObjectPropListEvent, EStateEnd,   EStateEnd,  NULL);
   149     ADD_FSM_ENTRY(EObjectServ, EObjectEvent,         EStateIdle,  EObjectInfoSucceed, FsmDoHandleSendObjectCompleteL);
   150     ADD_FSM_ENTRY(EObjectServ, EObjectEvent,         EStateIdle,  EObjectInfoSucceed, FsmDoHandleSendObjectCompleteL);
   150     
   151 
   151     __FLOG(_L8("CMTPImageEnumerator::ConstructL - Exit"));  
   152     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CONSTRUCTL_EXIT );
   152     }
   153     }
   153 
   154 
   154 TBool CMTPImageDpSendObjectInfo::FsmCheckObjectInfoParamsL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr)
   155 TBool CMTPImageDpSendObjectInfo::FsmCheckObjectInfoParamsL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr)
   155     {
   156     {
   156     return aObject->CheckObjectInfoParamsL(aPtr);
   157     return aObject->CheckObjectInfoParamsL(aPtr);
   200 Verify the request
   201 Verify the request
   201 @return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
   202 @return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
   202 */    
   203 */    
   203 TMTPResponseCode CMTPImageDpSendObjectInfo::CheckRequestL()
   204 TMTPResponseCode CMTPImageDpSendObjectInfo::CheckRequestL()
   204     {
   205     {
   205     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckRequestL - Entry"));
   206     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_CHECKREQUESTL_ENTRY );
   206     
   207     
   207     iOperationCode = Request().Uint16(TMTPTypeRequest::ERequestOperationCode);
   208     iOperationCode = Request().Uint16(TMTPTypeRequest::ERequestOperationCode);
   208     
   209     
   209     switch (iOperationCode)
   210     switch (iOperationCode)
   210         {      
   211         {      
   251             }
   252             }
   252         else
   253         else
   253             {
   254             {
   254             iCurrentState = iStateMachine[iCurrentState][iEvent].iNextFailedState;
   255             iCurrentState = iStateMachine[iCurrentState][iEvent].iNextFailedState;
   255             }
   256             }
   256         User::LeaveIfError(err);
   257         LEAVEIFERROR(err,
   257         }
   258                 OstTrace1( TRACE_ERROR, DUP1_CMTPIMAGEDPSENDOBJECTINFO_CHECKREQUESTL,
   258     __FLOG_1(_L8("CheckRequestL - Result: 0x%04x"), result);
   259                         "the request check failed! error code %d", err ));
   259     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckRequestL - Exit"));
   260         }
   260     
   261 
       
   262     OstTrace1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_CHECKREQUESTL, "Result: 0x%04x", result );
       
   263     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CHECKREQUESTL_EXIT );
   261     return result;    
   264     return result;    
   262     }
   265     }
   263     
   266     
   264 TBool CMTPImageDpSendObjectInfo::HasDataphase() const
   267 TBool CMTPImageDpSendObjectInfo::HasDataphase() const
   265     {
   268     {
   266     return ETrue;
   269     return ETrue;
   267     }
   270     }
   268 
   271 
   269 TBool CMTPImageDpSendObjectInfo::CheckObjectInfoParamsL(TAny *aPtr)
   272 TBool CMTPImageDpSendObjectInfo::CheckObjectInfoParamsL(TAny *aPtr)
   270     {
   273     {
   271     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectInfoParamsL - Entry"));
   274     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_CHECKOBJECTINFOPARAMSL_ENTRY );
   272     
   275     
   273     TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr);
   276     TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr);
   274     *ret = EMTPRespCodeOK;
   277     *ret = EMTPRespCodeOK;
   275     
   278     
   276     const TUint32 storeId(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
   279     const TUint32 storeId(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
   294             *ret = EMTPRespCodeInvalidObjectHandle;            
   297             *ret = EMTPRespCodeInvalidObjectHandle;            
   295             }        
   298             }        
   296         CleanupStack::PopAndDestroy(parentObjInfo);
   299         CleanupStack::PopAndDestroy(parentObjInfo);
   297         }
   300         }
   298     
   301     
   299     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectInfoParamsL - Exit"));
   302     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CHECKOBJECTINFOPARAMSL_EXIT );
   300     return (*ret == EMTPRespCodeOK) ? ETrue : EFalse;
   303     return (*ret == EMTPRespCodeOK) ? ETrue : EFalse;
   301     }
   304     }
   302 
   305 
   303 TBool CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL(TAny *aPtr)
   306 TBool CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL(TAny *aPtr)
   304     {
   307     {
   305     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL - Entry"));
   308     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_CHECKOBJECTPROPLISTPARAMSL_ENTRY );
   306     TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr);
   309     TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr);
   307     *ret = EMTPRespCodeOK;
   310     *ret = EMTPRespCodeOK;
   308     
   311     
   309     TMTPFormatCode formatCode = static_cast<TMTPFormatCode>(Request().Uint32(TMTPTypeRequest::ERequestParameter3));
   312     TMTPFormatCode formatCode = static_cast<TMTPFormatCode>(Request().Uint32(TMTPTypeRequest::ERequestParameter3));
   310     if (!IsFormatValid(formatCode))
   313     if (!IsFormatValid(formatCode))
   326         if(IsTooLarge(iObjectSize))
   329         if(IsTooLarge(iObjectSize))
   327             {
   330             {
   328             *ret = EMTPRespCodeObjectTooLarge;
   331             *ret = EMTPRespCodeObjectTooLarge;
   329             }
   332             }
   330         }
   333         }
   331     
   334 
   332     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL - Exit"));
   335     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CHECKOBJECTPROPLISTPARAMSL_EXIT );
   333     return (*ret == EMTPRespCodeOK) ? ETrue : EFalse;
   336     return (*ret == EMTPRespCodeOK) ? ETrue : EFalse;
   334     }
   337     }
   335 
   338 
   336 TBool CMTPImageDpSendObjectInfo::CheckObjectParams(TAny *aPtr)
   339 TBool CMTPImageDpSendObjectInfo::CheckObjectParams(TAny *aPtr)
   337     {
   340     {
   338     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectParamsL - Entry"));
   341     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_CHECKOBJECTPARAMS_ENTRY );
   339     TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr);
   342     TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr);
   340     *ret = EMTPRespCodeOK;
   343     *ret = EMTPRespCodeOK;
   341     
   344     
   342     /**
   345     /**
   343     * If the previous request is not the SendObjectInfo/SendObjectPropList/UpdateObjectPropList operation,
   346     * If the previous request is not the SendObjectInfo/SendObjectPropList/UpdateObjectPropList operation,
   345     */
   348     */
   346     if ( (iPreviousTransactionID + 1) != Request().Uint32(TMTPTypeRequest::ERequestTransactionID))
   349     if ( (iPreviousTransactionID + 1) != Request().Uint32(TMTPTypeRequest::ERequestTransactionID))
   347         {
   350         {
   348         *ret = EMTPRespCodeNoValidObjectInfo;
   351         *ret = EMTPRespCodeNoValidObjectInfo;
   349         }
   352         }
   350     
   353 
   351     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectParamsL - Exit"));
   354     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CHECKOBJECTPARAMS_EXIT );
   352     return (*ret == EMTPRespCodeOK) ? ETrue : EFalse;    
   355     return (*ret == EMTPRespCodeOK) ? ETrue : EFalse;    
   353     }
   356     }
   354 
   357 
   355 /**
   358 /**
   356 SendObjectInfo/SendObject request handler
   359 SendObjectInfo/SendObject request handler
   357 NOTE: SendObjectInfo has to be comes before SendObject requests.  To maintain the state information
   360 NOTE: SendObjectInfo has to be comes before SendObject requests.  To maintain the state information
   358 between the two requests, the two requests are combined together in one request processor.
   361 between the two requests, the two requests are combined together in one request processor.
   359 */    
   362 */    
   360 void CMTPImageDpSendObjectInfo::ServiceL()
   363 void CMTPImageDpSendObjectInfo::ServiceL()
   361     {
   364     {
   362     __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceL - Entry"));
   365     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_SERVICEL_ENTRY );
   363 
   366 
   364     FsmAction pService = iStateMachine[iCurrentState][iEvent].iFsmAction;
   367     FsmAction pService = iStateMachine[iCurrentState][iEvent].iFsmAction;
   365     __ASSERT_DEBUG(pService, Panic(EMTPImageDpNoMatchingProcessor));
   368     __ASSERT_DEBUG(pService, Panic(EMTPImageDpNoMatchingProcessor));
   366     
   369     
   367     TBool ret = EFalse;
   370     TBool ret = EFalse;
   377     
   380     
   378     if (err != KErrNone)
   381     if (err != KErrNone)
   379         {
   382         {
   380         Rollback();
   383         Rollback();
   381         }
   384         }
   382     User::LeaveIfError(err);
   385     LEAVEIFERROR(err,
   383     
   386             OstTrace1( TRACE_ERROR, CMTPIMAGEDPSENDOBJECTINFO_SERVICEL, "Action failed! error code %d", err));
   384     __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceL - Exit"));  
   387 
       
   388     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_SERVICEL_EXIT );
   385     }
   389     }
   386 
   390 
   387 /**
   391 /**
   388 Override to match both the SendObjectInfo and SendObject requests
   392 Override to match both the SendObjectInfo and SendObject requests
   389 @param aRequest    The request to match
   393 @param aRequest    The request to match
   390 @param aConnection The connection from which the request comes
   394 @param aConnection The connection from which the request comes
   391 @return ETrue if the processor can handle the request, otherwise EFalse
   395 @return ETrue if the processor can handle the request, otherwise EFalse
   392 */        
   396 */        
   393 TBool CMTPImageDpSendObjectInfo::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
   397 TBool CMTPImageDpSendObjectInfo::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
   394     {
   398     {
   395     __FLOG(_L8("CMTPImageDpSendObjectInfo::Match - Entry"));
   399     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_MATCH_ENTRY );
   396     TBool result = EFalse;
   400     TBool result = EFalse;
   397     TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
   401     TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
   398     if ((operationCode == EMTPOpCodeSendObjectInfo || 
   402     if ((operationCode == EMTPOpCodeSendObjectInfo || 
   399         operationCode == EMTPOpCodeSendObject ||
   403         operationCode == EMTPOpCodeSendObject ||
   400         operationCode == EMTPOpCodeSendObjectPropList) &&
   404         operationCode == EMTPOpCodeSendObjectPropList) &&
   401         &iConnection == &aConnection)
   405         &iConnection == &aConnection)
   402         {
   406         {
   403         result = ETrue;
   407         result = ETrue;
   404         }
   408         }
   405     __FLOG(_L8("CMTPImageDpSendObjectInfo::Match - Exit"));  
   409     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_MATCH_EXIT );
   406     return result;    
   410     return result;    
   407     }
   411     }
   408 
   412 
   409 /**
   413 /**
   410 Override to handle the response phase of SendObjectInfo and SendObject requests
   414 Override to handle the response phase of SendObjectInfo and SendObject requests
   411 @return EFalse
   415 @return EFalse
   412 */
   416 */
   413 TBool CMTPImageDpSendObjectInfo::DoHandleResponsePhaseL()
   417 TBool CMTPImageDpSendObjectInfo::DoHandleResponsePhaseL()
   414     {
   418     {
   415     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleResponsePhaseL - Entry"));
   419     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLERESPONSEPHASEL_ENTRY );
   416 
   420 
   417     //to check if the sending/receiving data is successful
   421     //to check if the sending/receiving data is successful
   418     iSuccessful = !iCancelled;
   422     iSuccessful = !iCancelled;
   419  
   423  
   420     FsmAction pResponse = iStateMachine[iCurrentState][iEvent].iFsmAction;
   424     FsmAction pResponse = iStateMachine[iCurrentState][iEvent].iFsmAction;
   433     
   437     
   434     if (err != KErrNone)
   438     if (err != KErrNone)
   435         {
   439         {
   436         Rollback();
   440         Rollback();
   437         }
   441         }
   438     User::LeaveIfError(err);
   442     LEAVEIFERROR(err,
   439     
   443             OstTrace1( TRACE_ERROR, CMTPIMAGEDPSENDOBJECTINFO_DOHANDLERESPONSEPHASEL, "Response error! error code %d", err));
   440     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleResponsePhaseL - Exit"));   
   444 
       
   445     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLERESPONSEPHASEL_EXIT );
   441     return EFalse;
   446     return EFalse;
   442     }
   447     }
   443 
   448 
   444 /**
   449 /**
   445 Override to handle the completing phase of SendObjectInfo and SendObject requests
   450 Override to handle the completing phase of SendObjectInfo and SendObject requests
   446 @return ETrue if succesfully received the file, otherwise EFalse
   451 @return ETrue if succesfully received the file, otherwise EFalse
   447 */    
   452 */    
   448 TBool CMTPImageDpSendObjectInfo::DoHandleCompletingPhaseL()
   453 TBool CMTPImageDpSendObjectInfo::DoHandleCompletingPhaseL()
   449     {
   454     {
   450     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleCompletingPhaseL - Entry"));
   455     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLECOMPLETINGPHASEL_ENTRY );
   451     TBool result = ETrue;
   456     TBool result = ETrue;
   452     CMTPRequestProcessor::DoHandleCompletingPhaseL();
   457     CMTPRequestProcessor::DoHandleCompletingPhaseL();
   453 
   458 
   454     if (iSuccessful)
   459     if (iSuccessful)
   455         {
   460         {
   465             {
   470             {
   466             iPreviousTransactionID++;
   471             iPreviousTransactionID++;
   467             }
   472             }
   468         result = EFalse;
   473         result = EFalse;
   469         }
   474         }
   470     
   475 
   471     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleCompletingPhaseL - Exit"));  
   476     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLECOMPLETINGPHASEL_EXIT );
   472     return result;    
   477     return result;    
   473     }
   478     }
   474 
   479 
   475 /**
   480 /**
   476 SendObjectInfo request handler
   481 SendObjectInfo request handler
   477 */
   482 */
   478 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectInfoL(TAny* /*aPtr*/)
   483 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectInfoL(TAny* /*aPtr*/)
   479     {
   484     {
   480     __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectInfoL - Entry"));
   485     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTINFOL_ENTRY );
   481     
   486     
   482     delete iObjectInfo;
   487     delete iObjectInfo;
   483     iObjectInfo = NULL;
   488     iObjectInfo = NULL;
   484     iObjectInfo = CMTPTypeObjectInfo::NewL();
   489     iObjectInfo = CMTPTypeObjectInfo::NewL();
   485     ReceiveDataL(*iObjectInfo);
   490     ReceiveDataL(*iObjectInfo);
   486     
   491 
   487     __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectInfoL - Exit"));
   492     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTINFOL_EXIT );
   488     return ETrue;
   493     return ETrue;
   489     }
   494     }
   490 
   495 
   491 /**
   496 /**
   492 SendObjectPropList request handler
   497 SendObjectPropList request handler
   493 */
   498 */
   494 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectPropListL(TAny* /*aPtr*/)
   499 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectPropListL(TAny* /*aPtr*/)
   495     {
   500     {
   496     __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectPropListL - Entry"));
   501     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTPROPLISTL_ENTRY );
   497     
   502     
   498     delete iObjectPropList;
   503     delete iObjectPropList;
   499     iObjectPropList = NULL;
   504     iObjectPropList = NULL;
   500     iObjectPropList = CMTPTypeObjectPropList::NewL();
   505     iObjectPropList = CMTPTypeObjectPropList::NewL();
   501     iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32(TMTPTypeRequest::ERequestParameter3));
   506     iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32(TMTPTypeRequest::ERequestParameter3));
   502     ReceiveDataL(*iObjectPropList);
   507     ReceiveDataL(*iObjectPropList);
   503     
   508 
   504     __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectPropListL - Exit"));
   509     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTPROPLISTL_EXIT );
   505     return ETrue;
   510     return ETrue;
   506     }
   511     }
   507     
   512     
   508 /**
   513 /**
   509 SendObject request handler
   514 SendObject request handler
   510 */    
   515 */    
   511 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectL(TAny* /*aPtr*/)
   516 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectL(TAny* /*aPtr*/)
   512     {
   517     {
   513     __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectL - Entry"));
   518     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTL_ENTRY );
   514          
   519          
   515     iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);
   520     iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);
   516     //prepare for rollback
   521     //prepare for rollback
   517     iRollbackList.AppendL(RemoveObjectFromDb);        
   522     iRollbackList.AppendL(RemoveObjectFromDb);        
   518     
   523     
   519     ReceiveDataL(*iFileReceived);
   524     ReceiveDataL(*iFileReceived);
   520     
   525 
   521     __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectL - Exit"));
   526     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTL_EXIT );
   522     return ETrue;
   527     return ETrue;
   523     }
   528     }
   524 
   529 
   525 /**
   530 /**
   526 Get a default parent object, if the request does not specify a parent object.
   531 Get a default parent object, if the request does not specify a parent object.
   527 */
   532 */
   528 void CMTPImageDpSendObjectInfo::GetDefaultParentObjectL()
   533 void CMTPImageDpSendObjectInfo::GetDefaultParentObjectL()
   529     {    
   534     {    
   530     __FLOG(_L8("CMTPImageDpSendObjectInfo::GetDefaultParentObjectL - Entry"));  
   535     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL_ENTRY );
   531 
   536 
   532     if (iStorageId == KMTPStorageDefault)
   537     if (iStorageId == KMTPStorageDefault)
   533         {
   538         {
   534         iStorageId = iFramework.StorageMgr().DefaultStorageId();
   539         iStorageId = iFramework.StorageMgr().DefaultStorageId();
   535         }
   540         }
   536     TInt drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId)));
   541     TInt drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId)));
   537     User::LeaveIfError(drive);       
   542     LEAVEIFERROR(drive,
       
   543             OstTraceExt2( TRACE_ERROR, CMTPIMAGEDPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL, 
       
   544                     "Can't get drive number for storage %d! error code %d", iStorageId, munged_err ));
   538 
   545 
   539     delete iParentSuid;
   546     delete iParentSuid;
   540     iParentSuid = NULL;
   547     iParentSuid = NULL;
   541     iParentSuid = (iFramework.StorageMgr().StorageL(iStorageId).DesC(CMTPStorageMetaData::EStorageSuid)).AllocL();
   548     iParentSuid = (iFramework.StorageMgr().StorageL(iStorageId).DesC(CMTPStorageMetaData::EStorageSuid)).AllocL();
   542     iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent);
   549     iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent);
   543     
   550               
   544     __FLOG(_L8("CMTPImageDpSendObjectInfo::GetDefaultParentObjectL - Exit"));                 
   551     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL_EXIT );
   545     }
   552     }
   546 
   553 
   547 /**
   554 /**
   548 Get parent object and storage id
   555 Get parent object and storage id
   549 @return EMTPRespCodeOK if successful, otherwise, EMTPRespCodeInvalidParentObject
   556 @return EMTPRespCodeOK if successful, otherwise, EMTPRespCodeInvalidParentObject
   550 */
   557 */
   551 TMTPResponseCode CMTPImageDpSendObjectInfo::GetParentObjectAndStorageIdL()
   558 TMTPResponseCode CMTPImageDpSendObjectInfo::GetParentObjectAndStorageIdL()
   552     {
   559     {
   553     __FLOG(_L8("CMTPImageDpSendObjectInfo::GetParentObjectAndStorageIdL - Entry"));    
   560     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL_ENTRY );  
   554     __ASSERT_DEBUG(iRequestChecker, Panic(EMTPImageDpRequestCheckNull));
   561     __ASSERT_DEBUG(iRequestChecker, Panic(EMTPImageDpRequestCheckNull));
   555 
   562 
   556     iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   563     iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   557     iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   564     iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   558     //does not take ownership
   565     //does not take ownership
   568         iParentSuid = NULL;
   575         iParentSuid = NULL;
   569         iParentSuid = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
   576         iParentSuid = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
   570         iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
   577         iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
   571         }
   578         }
   572 
   579 
   573     __FLOG_VA((_L8("ParentSuid = %S"), iParentSuid));
   580     OstTraceExt1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL, 
   574     __FLOG(_L8("CMTPImageDpSendObjectInfo::GetParentObjectAndStorageIdL - Exit"));     
   581             "ParentSuid = %S", *iParentSuid );
       
   582     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL_EXIT );
   575     return EMTPRespCodeOK;
   583     return EMTPRespCodeOK;
   576     }
   584     }
   577 
   585 
   578 /**
   586 /**
   579 Handling the completing phase of SendObjectInfo request
   587 Handling the completing phase of SendObjectInfo request
   580 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
   588 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
   581 */    
   589 */    
   582 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectInfoCompleteL(TAny* /*aPtr*/)
   590 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectInfoCompleteL(TAny* /*aPtr*/)
   583     {
   591     {
   584     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectInfoCompleteL - Entry"));    
   592     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTINFOCOMPLETEL_ENTRY );  
   585   
   593   
   586     TBool result(ETrue);
   594     TBool result(ETrue);
   587     TUint16 format(iObjectInfo->Uint16L(CMTPTypeObjectInfo::EObjectFormat));
   595     TUint16 format(iObjectInfo->Uint16L(CMTPTypeObjectInfo::EObjectFormat));
   588     
   596     
   589     result = IsFormatValid(TMTPFormatCode(format));
   597     result = IsFormatValid(TMTPFormatCode(format));
   650         else
   658         else
   651             {            
   659             {            
   652             TRAPD(err,CreateFsObjectL());
   660             TRAPD(err,CreateFsObjectL());
   653             if (err != KErrNone)
   661             if (err != KErrNone)
   654                 {
   662                 {
   655                 __FLOG_1(_L8("Fail to create fs object %d"),err);
   663                 OstTrace1( TRACE_ERROR, CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTINFOCOMPLETEL, 
       
   664                         "Fail to create fs object %d", err );
   656                 SendResponseL(ErrorToMTPError(err));
   665                 SendResponseL(ErrorToMTPError(err));
   657                 Rollback();
   666                 Rollback();
   658                 result = EFalse;
   667                 result = EFalse;
   659                 }
   668                 }
   660             else
   669             else
   669                 }
   678                 }
   670             }
   679             }
   671         }
   680         }
   672     
   681     
   673     iSuccessful = result;    
   682     iSuccessful = result;    
   674     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectInfoCompleteL - Exit"));
   683     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTINFOCOMPLETEL_EXIT );
   675     return result;    
   684     return result;    
   676     }
   685     }
   677 
   686 
   678 /**
   687 /**
   679 Handling the completing phase of SendObjectPropList request
   688 Handling the completing phase of SendObjectPropList request
   680 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
   689 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
   681 */    
   690 */    
   682 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectPropListCompleteL(TAny* /*aPtr*/)
   691 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectPropListCompleteL(TAny* /*aPtr*/)
   683     {
   692     {
   684     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectPropListCompleteL - Entry"));
   693     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTPROPLISTCOMPLETEL_ENTRY );
   685     TBool result(ETrue);
   694     TBool result(ETrue);
   686     
   695     
   687     TMTPResponseCode responseCode(GetParentObjectAndStorageIdL());
   696     TMTPResponseCode responseCode(GetParentObjectAndStorageIdL());
   688     if (responseCode != EMTPRespCodeOK)
   697     if (responseCode != EMTPRespCodeOK)
   689         {
   698         {
   723     if (result)
   732     if (result)
   724         {
   733         {
   725         TRAPD(err,CreateFsObjectL());
   734         TRAPD(err,CreateFsObjectL());
   726         if (err != KErrNone)
   735         if (err != KErrNone)
   727             {
   736             {
   728             __FLOG_1(_L8("Fail to create fs object %d"),err);
   737             OstTrace1( TRACE_ERROR, CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTPROPLISTCOMPLETEL, 
       
   738                     "Fail to create fs object %d", err );
   729             SendResponseL(ErrorToMTPError(err));
   739             SendResponseL(ErrorToMTPError(err));
   730             Rollback();
   740             Rollback();
   731             result = EFalse;
   741             result = EFalse;
   732             }
   742             }
   733         else
   743         else
   738             ReturnResponseL();
   748             ReturnResponseL();
   739             }
   749             }
   740         }
   750         }
   741         
   751         
   742     iSuccessful = result;
   752     iSuccessful = result;
   743     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectPropListCompleteL - Exit"));
   753     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTPROPLISTCOMPLETEL_EXIT );
   744     return result;    
   754     return result;    
   745     }
   755     }
   746     
   756     
   747 /**
   757 /**
   748 Handling the completing phase of SendObject request
   758 Handling the completing phase of SendObject request
   749 @return ETrue if the object has been successfully saved on the device, otherwise, EFalse
   759 @return ETrue if the object has been successfully saved on the device, otherwise, EFalse
   750 */    
   760 */    
   751 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL(TAny* /*aPtr*/)
   761 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL(TAny* /*aPtr*/)
   752     {
   762     {
   753     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL - Entry"));    
   763     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL_ENTRY );  
   754     TBool result(ETrue);
   764     TBool result(ETrue);
   755 
       
   756     delete iFileReceived;
       
   757     iFileReceived = NULL;  
       
   758     
   765     
   759 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   766 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   760     TInt64 objectsize = 0;
   767     TInt64 objectsize = 0;
   761 #else
   768 #else
   762     TInt objectsize = 0;
   769     TInt objectsize = 0;
   763 #endif
   770 #endif
   764     
   771     
   765     TEntry entry;
   772     iFileReceived->File().Size(objectsize);    
   766     User::LeaveIfError(iFramework.Fs().Entry(iFullPath, entry));
   773     
   767     objectsize = entry.FileSize();
       
   768    
       
   769     if (objectsize != iObjectSize)
   774     if (objectsize != iObjectSize)
   770         {
   775         {
   771         __FLOG_VA((_L8("object sizes differ %lu != %lu"), objectsize, iObjectSize));
   776         OstTraceExt2( TRACE_NORMAL, DUP1_CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL, 
       
   777                 "object sizes differ %Lu != %Lu", objectsize, iObjectSize );
   772         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);         
   778         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);         
   773         Rollback();
   779         Rollback();
   774         
   780         
   775         TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge;
   781         TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge;
   776         if (objectsize < iObjectSize)
   782         if (objectsize < iObjectSize)
   782         }
   788         }
   783         
   789         
   784     // SendObject is cancelled or connection is dropped.
   790     // SendObject is cancelled or connection is dropped.
   785     if(result && iCancelled)
   791     if(result && iCancelled)
   786         {
   792         {
   787         __FLOG(_L8("It is a cancel for sendObject."));
   793         OstTrace0( TRACE_NORMAL, DUP2_CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL, "It is a cancel for sendObject." );
   788         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   794         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   789         Rollback();
   795         Rollback();
   790         SendResponseL(EMTPRespCodeTransactionCancelled);    
   796         SendResponseL(EMTPRespCodeTransactionCancelled);    
   791         }
   797         }
   792     else if (result && !iCancelled)
   798     else if (result && !iCancelled)
   793 	    {	    	    
   799 	    {
       
   800         TUint attValue = 0;
       
   801         User::LeaveIfError(iFileReceived->File().Att(attValue));
   794         if (iProtectionStatus ==  EMTPProtectionNoProtection ||
   802         if (iProtectionStatus ==  EMTPProtectionNoProtection ||
   795             iProtectionStatus == EMTPProtectionReadOnly)
   803             iProtectionStatus == EMTPProtectionReadOnly)
   796             {
   804             {
   797             entry.iAtt &= ~(KEntryAttNormal | KEntryAttReadOnly);
   805             attValue &= ~(KEntryAttNormal | KEntryAttReadOnly);
       
   806             
   798             if (iProtectionStatus == EMTPProtectionNoProtection)
   807             if (iProtectionStatus == EMTPProtectionNoProtection)
   799                 {                        
   808                 {                        
   800                 entry.iAtt |= KEntryAttNormal;
   809                 attValue |= KEntryAttNormal;
   801                 }
   810                 }
   802             else
   811             else
   803                 {
   812                 {
   804                 entry.iAtt |= KEntryAttReadOnly;
   813                 attValue |= KEntryAttReadOnly;
   805                 }
   814                 }
   806             User::LeaveIfError(iFramework.Fs().SetAtt(iFullPath, entry.iAtt, ~entry.iAtt));
   815             User::LeaveIfError(iFileReceived->File().SetAtt(attValue, ~attValue));
   807             }
   816             }
   808 
   817         if ( iHiddenStatus == EMTPHidden )
       
   818             {
       
   819             attValue &= ~KEntryAttHidden;
       
   820             attValue |= KEntryAttHidden;
       
   821             User::LeaveIfError(iFileReceived->File().SetAtt(attValue, ~attValue));
       
   822             }
   809         TTime modifiedTime;
   823         TTime modifiedTime;
   810         //update datemodified property.
   824         //update datemodified property.
   811         if(iDateMod != NULL && iDateMod->Length())
   825         if(iDateMod != NULL && iDateMod->Length())
   812            {           
   826            {           
   813            iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateMod, modifiedTime);
   827            iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateMod, modifiedTime);
   814            }
   828            }
   815         else if(iDateCreated != NULL && iDateCreated->Length())
   829         else if(iDateCreated != NULL && iDateCreated->Length())
   816            {
   830            {
   817            iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateCreated, modifiedTime);
   831            iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateCreated, modifiedTime);
   818            }
   832            }
   819         User::LeaveIfError(iFramework.Fs().SetModified(iFullPath, modifiedTime));
   833         User::LeaveIfError(iFileReceived->File().SetModified(modifiedTime));
   820 
   834 
   821         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   835         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   822         
   836         
   823         //The MTP spec states that it is not mandatory for SendObjectInfo/SendObjectPropList
   837         //The MTP spec states that it is not mandatory for SendObjectInfo/SendObjectPropList
   824         //to be followed by a SendObject.  An object is reserved in the ObjectStore on 
   838         //to be followed by a SendObject.  An object is reserved in the ObjectStore on 
   829 		
   843 		
   830         CleanUndoList();
   844         CleanUndoList();
   831         SendResponseL(EMTPRespCodeOK);
   845         SendResponseL(EMTPRespCodeOK);
   832 	    }
   846 	    }
   833     
   847     
       
   848     delete iFileReceived;
       
   849     iFileReceived = NULL;  
   834     
   850     
   835     iSuccessful = result;
   851     iSuccessful = result;
   836     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL - Exit"));
   852     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL_EXIT );
   837     return result;
   853     return result;
   838     }
   854     }
   839 
   855 
   840 void CMTPImageDpSendObjectInfo::UnreserveObject(CMTPImageDpSendObjectInfo* aObject)
   856 void CMTPImageDpSendObjectInfo::UnreserveObject(CMTPImageDpSendObjectInfo* aObject)
   841     {
   857     {
   858     TRAP_IGNORE(iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject));
   874     TRAP_IGNORE(iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject));
   859     }
   875     }
   860 
   876 
   861 void CMTPImageDpSendObjectInfo::RemoveObjectFromFs()
   877 void CMTPImageDpSendObjectInfo::RemoveObjectFromFs()
   862     {  
   878     {  
   863     __FLOG(_L8("RemoveObjectFromFs"));
   879     OstTraceFunctionEntry0( DUP1_CMTPIMAGEDPSENDOBJECTINFO_REMOVEOBJECTFROMFS_ENTRY );
   864     delete iFileReceived;
   880     delete iFileReceived;
   865     iFileReceived = NULL;
   881     iFileReceived = NULL;
   866     TInt err = iFramework.Fs().Delete(iFullPath);
   882     TInt err = iFramework.Fs().Delete(iFullPath);
   867     if (err != KErrNone)
   883     if (err != KErrNone)
   868         {
   884         {
   869         //add Suid to deleteobjectlist
   885         //add Suid to deleteobjectlist
   870         TRAP_IGNORE(iDataProvider.AppendDeleteObjectsArrayL(iFullPath));
   886         TRAP_IGNORE(iDataProvider.AppendDeleteObjectsArrayL(iFullPath));
   871         }
   887         }
       
   888     OstTraceFunctionExit0( DUP1_CMTPIMAGEDPSENDOBJECTINFO_REMOVEOBJECTFROMFS_EXIT );
   872     }
   889     }
   873 
   890 
   874 void CMTPImageDpSendObjectInfo::RemoveObjectFromDb()
   891 void CMTPImageDpSendObjectInfo::RemoveObjectFromDb()
   875     {    
   892     {    
   876     /**
   893     /**
   896 
   913 
   897 /**
   914 /**
   898 */
   915 */
   899 TBool CMTPImageDpSendObjectInfo::IsFormatValid(TMTPFormatCode aFormat) const
   916 TBool CMTPImageDpSendObjectInfo::IsFormatValid(TMTPFormatCode aFormat) const
   900     {
   917     {
   901     __FLOG_1(_L8("CMTPImageDpSendObjectInfo::IsFormatValid - Format: 0x%04x"), aFormat);
   918     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_ISFORMATVALID_ENTRY );
       
   919     OstTrace1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_ISFORMATVALID, "Format: 0x%04x", aFormat );
   902     TInt count(sizeof(KMTPValidCodeExtensionMappings) / sizeof(KMTPValidCodeExtensionMappings[0]));        
   920     TInt count(sizeof(KMTPValidCodeExtensionMappings) / sizeof(KMTPValidCodeExtensionMappings[0]));        
   903     for(TInt i=0; i < count; i++)
   921     for(TInt i=0; i < count; i++)
   904         {
   922         {
   905         if (KMTPValidCodeExtensionMappings[i].iFormatCode == aFormat)
   923         if (KMTPValidCodeExtensionMappings[i].iFormatCode == aFormat)
   906             {
   924             {
       
   925             OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_ISFORMATVALID_EXIT );
   907             return ETrue;
   926             return ETrue;
   908             }
   927             }
   909         }
   928         }
   910     __FLOG(_L8("CMTPImageDpSendObjectInfo::IsFormatValid - Exit"));
   929     OstTraceFunctionExit0( DUP1_CMTPIMAGEDPSENDOBJECTINFO_ISFORMATVALID_EXIT );
   911     return EFalse;
   930     return EFalse;
   912     }
   931     }
   913 
   932 
   914 /**
   933 /**
   915 Get the full path name of the object to be saved
   934 Get the full path name of the object to be saved
   917 on return, contains the full path name of the object to be saved
   936 on return, contains the full path name of the object to be saved
   918 @return ETrue if the name is valid, EFalse otherwise
   937 @return ETrue if the name is valid, EFalse otherwise
   919 */
   938 */
   920 TBool CMTPImageDpSendObjectInfo::GetFullPathName(const TDesC& aFileName)
   939 TBool CMTPImageDpSendObjectInfo::GetFullPathName(const TDesC& aFileName)
   921     {
   940     {
   922     __FLOG_1(_L8("CMTPImageDpSendObjectInfo::GetFullPathNameL - FileName: %S"), &aFileName);
   941     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_GETFULLPATHNAME_ENTRY );
       
   942     OstTraceExt1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_GETFULLPATHNAME, "FileName: %S", aFileName );
   923     TBool result(EFalse);
   943     TBool result(EFalse);
   924     if (aFileName.Length() > 0)
   944     if (aFileName.Length() > 0)
   925         {
   945         {
   926         iFullPath = *iParentSuid;
   946         iFullPath = *iParentSuid;
   927         if (iFullPath.Length() + aFileName.Length() < iFullPath.MaxLength())
   947         if (iFullPath.Length() + aFileName.Length() < iFullPath.MaxLength())
   928             {
   948             {
   929             iFullPath.Append(aFileName);
   949             iFullPath.Append(aFileName);
   930             result = iFramework.Fs().IsValidName(iFullPath);
   950             result = iFramework.Fs().IsValidName(iFullPath);
   931             }
   951             }
   932         __FLOG_1(_L16("FullPath: %S"), &iFullPath);
   952         OstTraceExt1( TRACE_NORMAL, DUP1_CMTPIMAGEDPSENDOBJECTINFO_GETFULLPATHNAME, "FullPath: %S", iFullPath );
   933         }
   953         }
   934 
   954 
   935     __FLOG(_L8("CMTPImageDpSendObjectInfo::GetFullPathNameL - Exit"));
   955     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_GETFULLPATHNAME_EXIT );
   936     return result;
   956     return result;
   937     }
   957     }
   938 
   958 
   939 /**
   959 /**
   940 Check if the file already exists on the storage.
   960 Check if the file already exists on the storage.
   941 @return ETrue if file is exists, otherwise EFalse
   961 @return ETrue if file is exists, otherwise EFalse
   942 */
   962 */
   943 TBool CMTPImageDpSendObjectInfo::Exists(const TDesC& aName) const
   963 TBool CMTPImageDpSendObjectInfo::Exists(const TDesC& aName) const
   944     {
   964     {
   945     __FLOG(_L8("CMTPImageDpSendObjectInfo::Exists - Entry")); 
   965     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_EXISTS_ENTRY );
   946     // This detects both files and folders
   966     // This detects both files and folders
   947     TBool ret(EFalse); 
   967     TBool ret(EFalse); 
   948     ret = BaflUtils::FileExists(iFramework.Fs(), aName);
   968     ret = BaflUtils::FileExists(iFramework.Fs(), aName);
   949     __FLOG_VA((_L16("Exists: %S (%d)"), &aName, ret));
   969     OstTraceExt2( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_EXISTS, "Exists: %S (%d)", aName, ret);
   950     __FLOG(_L8("CMTPImageDpSendObjectInfo::IsTooLarge - Exit"));
   970     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_EXISTS_EXIT );
   951     return ret;
   971     return ret;
   952     }
   972     }
   953 
   973 
   954 /**
   974 /**
   955 Check if the property list is valid and extract properties (file name)
   975 Check if the property list is valid and extract properties (file name)
   956 @param aInvalidParameterIndex if invalid, contains the index of the property.  Undefined, if it is valid.
   976 @param aInvalidParameterIndex if invalid, contains the index of the property.  Undefined, if it is valid.
   957 @return if error, one of the error response code; otherwise EMTPRespCodeOK
   977 @return if error, one of the error response code; otherwise EMTPRespCodeOK
   958 */
   978 */
   959 TMTPResponseCode CMTPImageDpSendObjectInfo::VerifyObjectPropListL(TInt& aInvalidParameterIndex)
   979 TMTPResponseCode CMTPImageDpSendObjectInfo::VerifyObjectPropListL(TInt& aInvalidParameterIndex)
   960     {
   980     {
   961     __FLOG(_L8("CMTPImageDpSendObjectInfo::VerifyObjectPropListL - Entry"));
   981     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_VERIFYOBJECTPROPLISTL_ENTRY );
   962     
   982     
   963     TMTPResponseCode responseCode(EMTPRespCodeOK);
   983     TMTPResponseCode responseCode(EMTPRespCodeOK);
   964     const TUint KCount(iObjectPropList->NumberOfElements());
   984     const TUint KCount(iObjectPropList->NumberOfElements());
   965     iObjectPropList->ResetCursor();
   985     iObjectPropList->ResetCursor();
   966     for (TUint i(0); (i < KCount); i++)
   986     for (TUint i(0); (i < KCount); i++)
   983         if (responseCode != EMTPRespCodeOK)
  1003         if (responseCode != EMTPRespCodeOK)
   984             {
  1004             {
   985             break;
  1005             break;
   986             }        
  1006             }        
   987         }
  1007         }
   988     __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
  1008     OstTrace1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_VERIFYOBJECTPROPLISTL, "Result = 0x%04X", responseCode );
   989     __FLOG(_L8("CMTPImageDpSendObjectInfo::VerifyObjectPropListL - Exit"));
  1009     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_VERIFYOBJECTPROPLISTL_EXIT );
   990     return responseCode;        
  1010     return responseCode;        
   991     }
  1011     }
   992 
  1012 
   993 /**
  1013 /**
   994 Extracts the file information from the object property list element
  1014 Extracts the file information from the object property list element
   996 @param aPropertyCode MTP property code for the element
  1016 @param aPropertyCode MTP property code for the element
   997 @return MTP response code
  1017 @return MTP response code
   998 */
  1018 */
   999 TMTPResponseCode CMTPImageDpSendObjectInfo::ExtractPropertyL(const CMTPTypeObjectPropListElement& aElement)
  1019 TMTPResponseCode CMTPImageDpSendObjectInfo::ExtractPropertyL(const CMTPTypeObjectPropListElement& aElement)
  1000     {
  1020     {
  1001     __FLOG(_L8("CMTPImageDpSendObjectInfo::ExtractPropertyL - Entry"));
  1021     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_EXTRACTPROPERTYL_ENTRY );
  1002     TMTPResponseCode responseCode(EMTPRespCodeOK);
  1022     TMTPResponseCode responseCode(EMTPRespCodeOK);
  1003     switch (aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
  1023     switch (aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
  1004         {       
  1024         {       
  1005     case EMTPObjectPropCodeObjectFileName:
  1025     case EMTPObjectPropCodeObjectFileName:
  1006         {
  1026         {
  1060         break;
  1080         break;
  1061         
  1081         
  1062     case EMTPObjectPropCodeNonConsumable:
  1082     case EMTPObjectPropCodeNonConsumable:
  1063         iNonConsumable = aElement.Uint8L(CMTPTypeObjectPropListElement::EValue);       
  1083         iNonConsumable = aElement.Uint8L(CMTPTypeObjectPropListElement::EValue);       
  1064         break;
  1084         break;
  1065         
  1085     case EMTPObjectPropCodeHidden:
       
  1086         iHiddenStatus = aElement.Uint16L(CMTPTypeObjectPropListElement::EValue);
       
  1087         break;    
  1066     default:
  1088     default:
  1067         break;
  1089         break;
  1068         }
  1090         }
  1069     __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
  1091     OstTrace1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_EXTRACTPROPERTYL, "Result = 0x%04X", responseCode );
  1070     __FLOG(_L8("CMTPImageDpSendObjectInfo::ExtractPropertyL - Exit"));
  1092     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_EXTRACTPROPERTYL_EXIT );
  1071     return responseCode;    
  1093     return responseCode;    
  1072     }
  1094     }
  1073 
  1095 
  1074 /**
  1096 /**
  1075 Validates the data type for a given property code.
  1097 Validates the data type for a given property code.
  1077 @param aPropertyCode MTP property code for the element
  1099 @param aPropertyCode MTP property code for the element
  1078 @return EMTPRespCodeOK if the combination is valid, or another MTP response code if not
  1100 @return EMTPRespCodeOK if the combination is valid, or another MTP response code if not
  1079 */
  1101 */
  1080 TMTPResponseCode CMTPImageDpSendObjectInfo::CheckPropCodeL(const CMTPTypeObjectPropListElement& aElement) const
  1102 TMTPResponseCode CMTPImageDpSendObjectInfo::CheckPropCodeL(const CMTPTypeObjectPropListElement& aElement) const
  1081     {
  1103     {
  1082     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckPropCode - Entry"));
  1104     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_CHECKPROPCODEL_ENTRY );
  1083     TMTPResponseCode responseCode(EMTPRespCodeOK);
  1105     TMTPResponseCode responseCode(EMTPRespCodeOK);
  1084     switch(aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
  1106     switch(aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
  1085         {
  1107         {
  1086     case EMTPObjectPropCodeStorageID:
  1108     case EMTPObjectPropCodeStorageID:
  1087         if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32)
  1109         if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32)
  1131         responseCode =     EMTPRespCodeAccessDenied;
  1153         responseCode =     EMTPRespCodeAccessDenied;
  1132         break;
  1154         break;
  1133 
  1155 
  1134     case EMTPObjectPropCodeRepresentativeSampleFormat:
  1156     case EMTPObjectPropCodeRepresentativeSampleFormat:
  1135     case EMTPObjectPropCodeProtectionStatus:
  1157     case EMTPObjectPropCodeProtectionStatus:
       
  1158     case EMTPObjectPropCodeHidden:
  1136         if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
  1159         if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
  1137             {
  1160             {
  1138             responseCode = EMTPRespCodeInvalidObjectPropFormat;
  1161             responseCode = EMTPRespCodeInvalidObjectPropFormat;
  1139             }                        
  1162             }                        
  1140         break;
  1163         break;
  1174         break;        
  1197         break;        
  1175     default:
  1198     default:
  1176         responseCode = EMTPRespCodeInvalidObjectPropCode;
  1199         responseCode = EMTPRespCodeInvalidObjectPropCode;
  1177         break;
  1200         break;
  1178         }
  1201         }
  1179     __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
  1202     OstTrace1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_CHECKPROPCODEL, "Result = 0x%04X", responseCode );
  1180     __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckPropCode - Exit"));
  1203     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CHECKPROPCODEL_EXIT );
  1181     return responseCode;    
  1204     return responseCode;    
  1182     }
  1205     }
  1183 
  1206 
  1184 /**
  1207 /**
  1185 Reserves space for and assigns an object handle to the received object, then
  1208 Reserves space for and assigns an object handle to the received object, then
  1186 sends a success response.
  1209 sends a success response.
  1187 */
  1210 */
  1188 void CMTPImageDpSendObjectInfo::ReserveObjectL()
  1211 void CMTPImageDpSendObjectInfo::ReserveObjectL()
  1189     {
  1212     {
  1190     __FLOG(_L8("CMTPImageDpSendObjectInfo::ReserveObjectL - Entry"));
  1213     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_RESERVEOBJECTL_ENTRY );
  1191     const TInt objectStatusBitmask = 0x8000;//the most significant bit represents importing flag
  1214     const TInt objectStatusBitmask = 0x8000;//the most significant bit represents importing flag
  1192     
  1215     
  1193     iReceivedObject->SetUint(CMTPObjectMetaData::EFormatSubCode, objectStatusBitmask);//mark object imported due to it sent by PC
  1216     iReceivedObject->SetUint(CMTPObjectMetaData::EFormatSubCode, objectStatusBitmask);//mark object imported due to it sent by PC
  1194     iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);    
  1217     iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);    
  1195     iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize);    
  1218     iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize);    
  1196     
  1219     
  1197     // prepare for rollback
  1220     // prepare for rollback
  1198     iRollbackList.AppendL(UnreserveObject);    
  1221     iRollbackList.AppendL(UnreserveObject);    
  1199     __FLOG(_L8("CMTPImageDpSendObjectInfo::ReserveObjectL - Exit"));   
  1222     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_RESERVEOBJECTL_EXIT );
  1200     }
  1223     }
  1201 
  1224 
  1202 /**
  1225 /**
  1203 Sets the read only status on the current file to match the sent object.
  1226 Sets the read only status on the current file to match the sent object.
  1204 */
  1227 */
  1205 void CMTPImageDpSendObjectInfo::SetPropertiesL()
  1228 void CMTPImageDpSendObjectInfo::SetPropertiesL()
  1206     {
  1229     {
  1207     __FLOG(_L8("CMTPImageDpSendObjectInfo::SetPropertiesL - Entry"));
  1230     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_SETPROPERTIESL_ENTRY );
  1208     
  1231     
  1209     iObjectPropertyMgr.SetCurrentObjectL(*iReceivedObject, ETrue, ETrue);
  1232     iObjectPropertyMgr.SetCurrentObjectL(*iReceivedObject, ETrue, ETrue);
  1210     iReceivedObject->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath);
  1233     iReceivedObject->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath);
  1211     if (iName.Length() == 0)
  1234     if (iName.Length() == 0)
  1212         {
  1235         {
  1223     if(iDateCreated != NULL && iDateCreated->Length())
  1246     if(iDateCreated != NULL && iDateCreated->Length())
  1224         {//currently image dp can not support this property
  1247         {//currently image dp can not support this property
  1225         iObjectPropertyMgr.SetPropertyL(EMTPObjectPropCodeDateCreated, *iDateCreated);
  1248         iObjectPropertyMgr.SetPropertyL(EMTPObjectPropCodeDateCreated, *iDateCreated);
  1226         }
  1249         }
  1227     
  1250     
  1228     __FLOG(_L8("CMTPImageDpSendObjectInfo::SetPropertiesL - Exit"));
  1251     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_SETPROPERTIESL_EXIT );
  1229     }
  1252     }
  1230     
  1253     
  1231 void CMTPImageDpSendObjectInfo::Rollback()
  1254 void CMTPImageDpSendObjectInfo::Rollback()
  1232     {
  1255     {
  1233     __FLOG(_L8("CMTPImageDpSendObjectInfo::Rollback - Entry"));  
  1256     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_ROLLBACK_ENTRY ); 
  1234     
  1257     
  1235     TInt count = iRollbackList.Count();
  1258     TInt count = iRollbackList.Count();
  1236     while(--count >= 0)
  1259     while(--count >= 0)
  1237         {
  1260         {
  1238         TRAP_IGNORE((*iRollbackList[count])(this));
  1261         TRAP_IGNORE((*iRollbackList[count])(this));
  1239         }
  1262         }
  1240     iRollbackList.Reset();
  1263     iRollbackList.Reset();
  1241     
  1264 
  1242     __FLOG(_L8("CMTPImageDpSendObjectInfo::Rollback - Exit"));  
  1265     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_ROLLBACK_EXIT );
  1243     }
  1266     }
  1244     
  1267     
  1245 void CMTPImageDpSendObjectInfo::CleanUndoList()
  1268 void CMTPImageDpSendObjectInfo::CleanUndoList()
  1246     {
  1269     {
  1247     __FLOG(_L8("CMTPImageDpSendObjectInfo::CleanUndoList - Entry")); 
  1270     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_CLEANUNDOLIST_ENTRY );
  1248     
  1271     
  1249     iRollbackList.Reset();
  1272     iRollbackList.Reset();
  1250     
  1273 
  1251     __FLOG(_L8("CMTPImageDpSendObjectInfo::CleanUndoList - Exit"));  
  1274     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CLEANUNDOLIST_EXIT );
  1252     }
  1275     }
  1253 
  1276 
  1254 void CMTPImageDpSendObjectInfo::CreateFsObjectL()
  1277 void CMTPImageDpSendObjectInfo::CreateFsObjectL()
  1255     {
  1278     {
  1256     delete iFileReceived;
  1279     delete iFileReceived;
  1281         break;
  1304         break;
  1282         
  1305         
  1283     default:
  1306     default:
  1284         break;
  1307         break;
  1285         }
  1308         }
  1286         
  1309 
  1287     return resp;
  1310     return resp;
  1288     }
  1311     }
  1289 
  1312 
  1290 /**
  1313 /**
  1291 Check if the object is too large
  1314 Check if the object is too large
  1292 @return ETrue if yes, otherwise EFalse
  1315 @return ETrue if yes, otherwise EFalse
  1293 */
  1316 */
  1294 TBool CMTPImageDpSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const
  1317 TBool CMTPImageDpSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const
  1295     {
  1318     {
  1296     __FLOG(_L8("IsTooLarge - Entry"));
  1319     OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_ISTOOLARGE_ENTRY );
  1297     TBool ret(aObjectSize > KMaxTInt64);
  1320     TBool ret(aObjectSize > KMaxTInt64);
  1298     
  1321     
  1299     if(!ret)
  1322     if(!ret)
  1300         {
  1323         {
  1301         TBuf<255> fsname;
  1324         TBuf<255> fsname;
  1317                 {
  1340                 {
  1318                 ret = ETrue;
  1341                 ret = ETrue;
  1319                 }
  1342                 }
  1320             }
  1343             }
  1321         }
  1344         }
  1322     __FLOG_VA((_L8("Result = %d"), ret));
  1345     OstTrace1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_ISTOOLARGE, "Result = %d", ret );
  1323     __FLOG(_L8("IsTooLarge - Exit"));
  1346     OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_ISTOOLARGE_EXIT );
  1324     return ret;
  1347     return ret;
  1325     }
  1348     }