mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp
changeset 47 63cf70d3ecd8
parent 38 48c22c726cf9
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    35 #include "mtpdppanic.h"
    35 #include "mtpdppanic.h"
    36 #include "cmtpfsexclusionmgr.h"
    36 #include "cmtpfsexclusionmgr.h"
    37 #include "cmtpdataprovidercontroller.h"
    37 #include "cmtpdataprovidercontroller.h"
    38 #include "cmtpdataprovider.h"
    38 #include "cmtpdataprovider.h"
    39 #include "cmtpstoragemgr.h"
    39 #include "cmtpstoragemgr.h"
    40 
    40 #include "mtpdebug.h"
    41 
    41 #include "OstTraceDefinitions.h"
    42 // Class constants.
    42 #ifdef OST_TRACE_COMPILER_IN_USE
    43 __FLOG_STMT(_LIT8(KComponent,"SendObjectInfo");)
    43 #include "cmtpsendobjectinfoTraces.h"
       
    44 #endif
       
    45 
       
    46 
    44 
    47 
    45 /**
    48 /**
    46 Verification data for the SendObjectInfo request
    49 Verification data for the SendObjectInfo request
    47 */
    50 */
    48 const TMTPRequestElementInfo KMTPSendObjectInfoPolicy[] = 
    51 const TMTPRequestElementInfo KMTPSendObjectInfoPolicy[] = 
    70 /**
    73 /**
    71 Destructor
    74 Destructor
    72 */    
    75 */    
    73 EXPORT_C CMTPSendObjectInfo::~CMTPSendObjectInfo()
    76 EXPORT_C CMTPSendObjectInfo::~CMTPSendObjectInfo()
    74     {
    77     {
    75     __FLOG(_L8("~CMTPSendObjectInfo - Entry"));
    78     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_CMTPSENDOBJECTINFO_DES_ENTRY );
    76     __FLOG_2(_L8("iProgress:%d NoRollback:%d"),iProgress,iNoRollback);
    79     OstTraceExt2( TRACE_NORMAL, CMTPSENDOBJECTINFO_CMTPSENDOBJECTINFO, 
       
    80             "iProgress:%d NoRollback:%d", iProgress,iNoRollback );
    77     if ((iProgress == EObjectInfoSucceed ||
    81     if ((iProgress == EObjectInfoSucceed ||
    78         iProgress == EObjectInfoFail || 
    82         iProgress == EObjectInfoFail || 
    79         iProgress == EObjectInfoInProgress) && !iNoRollback)
    83         iProgress == EObjectInfoInProgress) && !iNoRollback)
    80         {
    84         {
    81         // Not finished SendObjectInfo/PropList SendObject pair detected.
    85         // Not finished SendObjectInfo/PropList SendObject pair detected.
    88     delete iParentSuid;    
    92     delete iParentSuid;    
    89     delete iReceivedObject;
    93     delete iReceivedObject;
    90     delete iObjectInfo;
    94     delete iObjectInfo;
    91     delete iObjectPropList;
    95     delete iObjectPropList;
    92     iSingletons.Close();
    96     iSingletons.Close();
    93     __FLOG(_L8("~CMTPSendObjectInfo - Exit"));
    97     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_CMTPSENDOBJECTINFO_DES_EXIT );
    94     __FLOG_CLOSE; 
       
    95     }
    98     }
    96 
    99 
    97 /**
   100 /**
    98 Standard c++ constructor
   101 Standard c++ constructor
    99 @param aFramework    The data provider framework
   102 @param aFramework    The data provider framework
   100 @param aConnection    The connection from which the request comes
   103 @param aConnection    The connection from which the request comes
   101 */    
   104 */    
   102 CMTPSendObjectInfo::CMTPSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
   105 CMTPSendObjectInfo::CMTPSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
   103     CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
   106     CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
       
   107     iHiddenStatus( EMTPVisible )
   104     {
   108     {
   105     }
   109     }
   106 
   110 
   107 /**
   111 /**
   108 Verify the request
   112 Verify the request
   109 @return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
   113 @return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
   110 */    
   114 */    
   111 TMTPResponseCode CMTPSendObjectInfo::CheckRequestL()
   115 TMTPResponseCode CMTPSendObjectInfo::CheckRequestL()
   112     {
   116     {
   113     __FLOG(_L8("CheckRequestL - Entry"));
   117     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_CHECKREQUESTL_ENTRY );
   114     TMTPResponseCode result = CheckSendingStateL();
   118     TMTPResponseCode result = CheckSendingStateL();
   115     
   119     
   116     if (result != EMTPRespCodeOK) 
   120     if (result != EMTPRespCodeOK) 
   117         {
   121         {
       
   122         OstTraceFunctionExit0( CMTPSENDOBJECTINFO_CHECKREQUESTL_EXIT );
   118         return result;
   123         return result;
   119         }
   124         }
   120     
   125     
   121     if (iProgress == EObjectNone)    //this is the SendObjectInfo phase
   126     if (iProgress == EObjectNone)    //this is the SendObjectInfo phase
   122         {
   127         {
   168             {
   173             {
   169             result = EMTPRespCodeNoValidObjectInfo;
   174             result = EMTPRespCodeNoValidObjectInfo;
   170             }
   175             }
   171         }
   176         }
   172         
   177         
   173     __FLOG_VA((_L8("Result = 0x%04X"), result));
   178     OstTrace1( TRACE_NORMAL, CMTPSENDOBJECTINFO_CHECKREQUESTL, "Result = 0x%04X", result );
   174     __FLOG(_L8("CheckRequestL - Exit"));
   179     OstTraceFunctionExit0( DUP1_CMTPSENDOBJECTINFO_CHECKREQUESTL_EXIT );
   175     return result;    
   180     return result;    
   176     }
   181     }
   177     
   182     
   178 TBool CMTPSendObjectInfo::HasDataphase() const
   183 TBool CMTPSendObjectInfo::HasDataphase() const
   179     {
   184     {
   185 NOTE: SendObjectInfo has to be comes before SendObject requests.  To maintain the state information
   190 NOTE: SendObjectInfo has to be comes before SendObject requests.  To maintain the state information
   186 between the two requests, the two requests are combined together in one request processor.
   191 between the two requests, the two requests are combined together in one request processor.
   187 */    
   192 */    
   188 void CMTPSendObjectInfo::ServiceL()
   193 void CMTPSendObjectInfo::ServiceL()
   189     {
   194     {
   190     __FLOG(_L8("ServiceL - Entry"));
   195     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_SERVICEL_ENTRY );
   191     if (iProgress == EObjectNone)
   196     if (iProgress == EObjectNone)
   192         {
   197         {
   193         iIsFolder = EFalse;
   198         iIsFolder = EFalse;
   194         if (iOperationCode == EMTPOpCodeSendObjectInfo)
   199         if (iOperationCode == EMTPOpCodeSendObjectInfo)
   195             {
   200             {
   202         }
   207         }
   203     else
   208     else
   204         {
   209         {
   205         ServiceSendObjectL();
   210         ServiceSendObjectL();
   206         }    
   211         }    
   207     __FLOG(_L8("ServiceL - Exit"));
   212     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_SERVICEL_EXIT );
   208     }
   213     }
   209 
   214 
   210 /**
   215 /**
   211 Second-phase construction
   216 Second-phase construction
   212 */        
   217 */        
   213 void CMTPSendObjectInfo::ConstructL()
   218 void CMTPSendObjectInfo::ConstructL()
   214     {
   219     {
   215     __FLOG_OPEN(KMTPSubsystem, KComponent);
   220     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_CONSTRUCTL_ENTRY );
   216     __FLOG(_L8("ConstructL - Entry")); 
       
   217     iExpectedSendObjectRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, EMTPOpCodeSendObject);
   221     iExpectedSendObjectRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, EMTPOpCodeSendObject);
   218     iReceivedObject = CMTPObjectMetaData::NewL();
   222     iReceivedObject = CMTPObjectMetaData::NewL();
   219     iReceivedObject->SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId());
   223     iReceivedObject->SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId());
   220     iDpSingletons.OpenL(iFramework);
   224     iDpSingletons.OpenL(iFramework);
   221     iNoRollback = EFalse;
   225     iNoRollback = EFalse;
   222     iSingletons.OpenL();
   226     iSingletons.OpenL();
   223     _LIT(KM4A, ".m4a");
   227     _LIT(KM4A, ".m4a");
   224     _LIT(KODF, ".odf");
   228     _LIT(KODF, ".odf");
   225     iExceptionList.AppendL(KM4A());
   229     iExceptionList.AppendL(KM4A());
   226     iExceptionList.AppendL(KODF());
   230     iExceptionList.AppendL(KODF());
   227     __FLOG(_L8("ConstructL - Exit"));
   231     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_CONSTRUCTL_EXIT );
   228     }
   232     }
   229 
   233 
   230 /**
   234 /**
   231 Override to match both the SendObjectInfo and SendObject requests
   235 Override to match both the SendObjectInfo and SendObject requests
   232 @param aRequest    The request to match
   236 @param aRequest    The request to match
   233 @param aConnection The connection from which the request comes
   237 @param aConnection The connection from which the request comes
   234 @return ETrue if the processor can handle the request, otherwise EFalse
   238 @return ETrue if the processor can handle the request, otherwise EFalse
   235 */        
   239 */        
   236 TBool CMTPSendObjectInfo::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
   240 TBool CMTPSendObjectInfo::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
   237     {
   241     {
   238     __FLOG(_L8("Match - Entry"));
   242     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_MATCH_ENTRY );
   239     TBool result = EFalse;
   243     TBool result = EFalse;
   240     TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
   244     TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
   241     if ((operationCode == EMTPOpCodeSendObjectInfo || 
   245     if ((operationCode == EMTPOpCodeSendObjectInfo || 
   242         operationCode == EMTPOpCodeSendObject ||
   246         operationCode == EMTPOpCodeSendObject ||
   243         operationCode == EMTPOpCodeSendObjectPropList) &&
   247         operationCode == EMTPOpCodeSendObjectPropList) &&
   244         &iConnection == &aConnection)
   248         &iConnection == &aConnection)
   245         {
   249         {
   246         result = ETrue;
   250         result = ETrue;
   247         }
   251         }
   248     __FLOG(_L8("Match - Exit"));
   252     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_MATCH_EXIT );
   249     return result;    
   253     return result;    
   250     }
   254     }
   251 
   255 
   252 /**
   256 /**
   253 Override to handle the response phase of SendObjectInfo and SendObject requests
   257 Override to handle the response phase of SendObjectInfo and SendObject requests
   254 @return EFalse
   258 @return EFalse
   255 */
   259 */
   256 TBool CMTPSendObjectInfo::DoHandleResponsePhaseL()
   260 TBool CMTPSendObjectInfo::DoHandleResponsePhaseL()
   257     {
   261     {
   258     __FLOG(_L8("DoHandleResponsePhaseL - Entry"));
   262     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_DOHANDLERESPONSEPHASEL_ENTRY );
   259     //to check if the sending/receiving data is successful
   263     //to check if the sending/receiving data is successful
   260     TBool successful = !iCancelled;
   264     TBool successful = !iCancelled;
   261     if (iProgress == EObjectInfoInProgress)
   265     if (iProgress == EObjectInfoInProgress)
   262         {
   266         {
   263         if (iOperationCode == EMTPOpCodeSendObjectInfo)
   267         if (iOperationCode == EMTPOpCodeSendObjectInfo)
   278         {
   282         {
   279         successful = DoHandleSendObjectCompleteL();
   283         successful = DoHandleSendObjectCompleteL();
   280         iProgress = (successful ? ESendObjectSucceed : ESendObjectFail);
   284         iProgress = (successful ? ESendObjectSucceed : ESendObjectFail);
   281         }
   285         }
   282         
   286         
   283     __FLOG(_L8("DoHandleResponsePhaseL - Exit"));
   287     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_DOHANDLERESPONSEPHASEL_EXIT );
   284     return EFalse;
   288     return EFalse;
   285     }
   289     }
   286 
   290 
   287 /**
   291 /**
   288 Override to handle the completing phase of SendObjectInfo and SendObject requests
   292 Override to handle the completing phase of SendObjectInfo and SendObject requests
   289 @return ETrue if succesfully received the file, otherwise EFalse
   293 @return ETrue if succesfully received the file, otherwise EFalse
   290 */    
   294 */    
   291 TBool CMTPSendObjectInfo::DoHandleCompletingPhaseL()
   295 TBool CMTPSendObjectInfo::DoHandleCompletingPhaseL()
   292     {
   296     {
   293     __FLOG(_L8("DoHandleCompletingPhaseL - Entry"));
   297     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_DOHANDLECOMPLETINGPHASEL_ENTRY );
   294     TBool result = ETrue;
   298     TBool result = ETrue;
   295     CMTPRequestProcessor::DoHandleCompletingPhaseL();
   299     CMTPRequestProcessor::DoHandleCompletingPhaseL();
   296     if (iProgress == EObjectInfoSucceed)
   300     if (iProgress == EObjectInfoSucceed)
   297         {
   301         {
   298         if (iOperationCode == EMTPOpCodeSendObjectInfo || iOperationCode == EMTPOpCodeSendObjectPropList)
   302         if (iOperationCode == EMTPOpCodeSendObjectInfo || iOperationCode == EMTPOpCodeSendObjectPropList)
   308             iPreviousTransactionID++;
   312             iPreviousTransactionID++;
   309             }
   313             }
   310         iProgress = EObjectInfoSucceed;
   314         iProgress = EObjectInfoSucceed;
   311         result = EFalse;
   315         result = EFalse;
   312         }
   316         }
   313     
   317 
   314     __FLOG_2(_L8("DoHandleCompletingPhaseL - Exit result:%d progress:%d"),result,iProgress);
   318     OstTraceExt2( TRACE_NORMAL, CMTPSENDOBJECTINFO_DOHANDLECOMPLETINGPHASEL, 
       
   319             "Exit result:%d progress:%d",result,iProgress );
       
   320     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_DOHANDLECOMPLETINGPHASEL_EXIT );
   315     return result;    
   321     return result;    
   316     }
   322     }
   317 
   323 
   318 
   324 
   319 /**
   325 /**
   321 @return EMTPRespCodeOK if SendObject request comes after a valid SendObjectInfo request, otherwise
   327 @return EMTPRespCodeOK if SendObject request comes after a valid SendObjectInfo request, otherwise
   322 EMTPRespCodeNoValidObjectInfo
   328 EMTPRespCodeNoValidObjectInfo
   323 */
   329 */
   324 TMTPResponseCode CMTPSendObjectInfo::CheckSendingStateL()
   330 TMTPResponseCode CMTPSendObjectInfo::CheckSendingStateL()
   325     {
   331     {
   326     __FLOG(_L8("CheckSendingState - Entry"));
   332     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_CHECKSENDINGSTATEL_ENTRY );
   327     TMTPResponseCode result = EMTPRespCodeOK;
   333     TMTPResponseCode result = EMTPRespCodeOK;
   328     iOperationCode = Request().Uint16(TMTPTypeRequest::ERequestOperationCode);
   334     iOperationCode = Request().Uint16(TMTPTypeRequest::ERequestOperationCode);
   329 
   335 
   330     if (iOperationCode == EMTPOpCodeSendObject)
   336     if (iOperationCode == EMTPOpCodeSendObject)
   331     	{
   337     	{
   362             iProgress = EObjectNone;
   368             iProgress = EObjectNone;
   363             }
   369             }
   364         }
   370         }
   365     else 
   371     else 
   366         {
   372         {
       
   373         OstTrace1( TRACE_ERROR, CMTPSENDOBJECTINFO_CHECKSENDINGSTATEL, 
       
   374                 "The progress state is not right.  Current state is %d", iProgress );
   367         User::Leave( KErrGeneral );
   375         User::Leave( KErrGeneral );
   368         }
   376         }
   369     __FLOG(_L8("CheckSendingState - Exit"));
   377     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_CHECKSENDINGSTATEL_EXIT );
   370     return result;    
   378     return result;    
   371     }
   379     }
   372 
   380 
   373 /**
   381 /**
   374 SendObjectInfo request handler
   382 SendObjectInfo request handler
   375 */
   383 */
   376 void CMTPSendObjectInfo::ServiceSendObjectInfoL()
   384 void CMTPSendObjectInfo::ServiceSendObjectInfoL()
   377     {
   385     {
   378     __FLOG(_L8("ServiceSendObjectInfoL - Entry"));
   386     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_SERVICESENDOBJECTINFOL_ENTRY );
   379     delete iObjectInfo;
   387     delete iObjectInfo;
   380     iObjectInfo = NULL;
   388     iObjectInfo = NULL;
   381     iObjectInfo = CMTPTypeObjectInfo::NewL();
   389     iObjectInfo = CMTPTypeObjectInfo::NewL();
   382     iCancelled = EFalse;
   390     iCancelled = EFalse;
   383     ReceiveDataL(*iObjectInfo);
   391     ReceiveDataL(*iObjectInfo);
   384     iProgress = EObjectInfoInProgress;
   392     iProgress = EObjectInfoInProgress;
   385     __FLOG(_L8("ServiceSendObjectInfoL - Exit"));
   393     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_SERVICESENDOBJECTINFOL_EXIT );
   386     }
   394     }
   387 
   395 
   388 /**
   396 /**
   389 SendObjectPropList request handler
   397 SendObjectPropList request handler
   390 */
   398 */
   391 void CMTPSendObjectInfo::ServiceSendObjectPropListL()
   399 void CMTPSendObjectInfo::ServiceSendObjectPropListL()
   392     {
   400     {
   393     __FLOG(_L8("ServiceSendObjectPropListL - Entry"));
   401     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_SERVICESENDOBJECTPROPLISTL_ENTRY );
   394     delete iObjectPropList;
   402     delete iObjectPropList;
   395     iObjectPropList = NULL;
   403     iObjectPropList = NULL;
   396     iObjectPropList = CMTPTypeObjectPropList::NewL();
   404     iObjectPropList = CMTPTypeObjectPropList::NewL();
   397     iCancelled = EFalse;
   405     iCancelled = EFalse;
   398     iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32(TMTPTypeRequest::ERequestParameter3));
   406     iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32(TMTPTypeRequest::ERequestParameter3));
   399     ReceiveDataL(*iObjectPropList);
   407     ReceiveDataL(*iObjectPropList);
   400     iProgress = EObjectInfoInProgress;
   408     iProgress = EObjectInfoInProgress;
   401     __FLOG(_L8("ServiceSendObjectPropListL - Exit"));
   409     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_SERVICESENDOBJECTPROPLISTL_EXIT );
   402     }
   410     }
   403     
   411     
   404 /**
   412 /**
   405 SendObject request handler
   413 SendObject request handler
   406 */    
   414 */    
   407 void CMTPSendObjectInfo::ServiceSendObjectL()
   415 void CMTPSendObjectInfo::ServiceSendObjectL()
   408     {
   416     {
   409     __FLOG(_L8("ServiceSendObjectL - Entry"));
   417     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_SERVICESENDOBJECTL_ENTRY );
   410     if (iIsFolder)
   418     if (iIsFolder)
   411         {
   419         {
   412         // A generic folder doesn't have anything interesting during its data phase
   420         // A generic folder doesn't have anything interesting during its data phase
   413         ReceiveDataL(iNullObject);
   421         ReceiveDataL(iNullObject);
   414         }
   422         }
   416         {        
   424         {        
   417         ReceiveDataL(*iFileReceived);
   425         ReceiveDataL(*iFileReceived);
   418         }
   426         }
   419     
   427     
   420     iProgress = ESendObjectInProgress;
   428     iProgress = ESendObjectInProgress;
   421     __FLOG(_L8("ServiceSendObjectL - Exit"));
   429     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_SERVICESENDOBJECTL_EXIT );
   422     }
   430     }
   423 
   431 
   424 /**
   432 /**
   425 Get a default parent object, if the request does not specify a parent object.
   433 Get a default parent object, if the request does not specify a parent object.
   426 */
   434 */
   427 void CMTPSendObjectInfo::GetDefaultParentObjectL()
   435 void CMTPSendObjectInfo::GetDefaultParentObjectL()
   428     {    
   436     {    
   429     __FLOG(_L8("GetDefaultParentObjectL - Entry"));
   437     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL_ENTRY );
   430     if (iStorageId == KMTPStorageDefault)
   438     if (iStorageId == KMTPStorageDefault)
   431         {
   439         {
   432         iStorageId = iFramework.StorageMgr().DefaultStorageId();
   440         iStorageId = iFramework.StorageMgr().DefaultStorageId();
   433         }
   441         }
   434     TInt drive(iFramework.StorageMgr().DriveNumber(iStorageId));
   442     TInt drive(iFramework.StorageMgr().DriveNumber(iStorageId));
   435     User::LeaveIfError(drive);
   443     LEAVEIFERROR(drive,
       
   444             OstTrace1( TRACE_ERROR, CMTPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL, "can't get driver number for storage %d", iStorageId));
   436 
   445 
   437     // Obtain the root of the drive.  Logical storages can sometimes have a filesystem root
   446     // Obtain the root of the drive.  Logical storages can sometimes have a filesystem root
   438     // other than <drive>:\ .  For example an MP3 DP might have a root of c:\media\music\
   447     // other than <drive>:\ .  For example an MP3 DP might have a root of c:\media\music\
   439     // The DevDP needs to be aware of this when handling associations (folders) so they are
   448     // The DevDP needs to be aware of this when handling associations (folders) so they are
   440     // created in the correct location on the filesystem.
   449     // created in the correct location on the filesystem.
   441     delete iParentSuid;
   450     delete iParentSuid;
   442     iParentSuid = NULL;
   451     iParentSuid = NULL;
   443     iParentSuid=(iFramework.StorageMgr().StorageL(iStorageId).DesC(CMTPStorageMetaData::EStorageSuid)).AllocL();
   452     iParentSuid=(iFramework.StorageMgr().StorageL(iStorageId).DesC(CMTPStorageMetaData::EStorageSuid)).AllocL();
   444     iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent);
   453     iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent);     
   445     __FLOG(_L8("GetDefaultParentObjectL - Exit"));        
   454     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL_EXIT );
   446     }
   455     }
   447 
   456 
   448 /**
   457 /**
   449 Get parent object and storage id
   458 Get parent object and storage id
   450 @return EMTPRespCodeOK if successful, otherwise, EMTPRespCodeInvalidParentObject
   459 @return EMTPRespCodeOK if successful, otherwise, EMTPRespCodeInvalidParentObject
   451 */
   460 */
   452 TMTPResponseCode CMTPSendObjectInfo::GetParentObjectAndStorageIdL()
   461 TMTPResponseCode CMTPSendObjectInfo::GetParentObjectAndStorageIdL()
   453     {
   462     {
   454     __FLOG(_L8("GetParentObjectAndStorageIdL - Entry"));    
   463     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL_ENTRY );    
   455     __ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
   464     __ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
   456 
   465 
   457     iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   466     iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   458     iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   467     iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   459     //does not take ownership
   468     //does not take ownership
   469         iParentSuid = NULL;
   478         iParentSuid = NULL;
   470         iParentSuid = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
   479         iParentSuid = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
   471         iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
   480         iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle);
   472         }
   481         }
   473 
   482 
   474     __FLOG_VA((_L8("iParentSuid = %S"), iParentSuid));
   483     OstTraceExt1( TRACE_NORMAL, CMTPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL, "iParentSuid = %S", *iParentSuid );
   475     __FLOG(_L8("GetParentObjectAndStorageIdL - Exit"));    
   484     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL_EXIT );
   476     return EMTPRespCodeOK;
   485     return EMTPRespCodeOK;
   477     }
   486     }
   478 
   487 
   479 /**
   488 /**
   480 Handling the completing phase of SendObjectInfo request
   489 Handling the completing phase of SendObjectInfo request
   481 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
   490 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
   482 */    
   491 */    
   483 TBool CMTPSendObjectInfo::DoHandleSendObjectInfoCompleteL()
   492 TBool CMTPSendObjectInfo::DoHandleSendObjectInfoCompleteL()
   484     {
   493     {
   485     __FLOG(_L8("DoHandleSendObjectInfoCompleteL - Entry"));    
   494     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTINFOCOMPLETEL_ENTRY ); 
   486     TBool result(ETrue);
   495     TBool result(ETrue);
   487     TUint16 format(iObjectInfo->Uint16L(CMTPTypeObjectInfo::EObjectFormat));
   496     TUint16 format(iObjectInfo->Uint16L(CMTPTypeObjectInfo::EObjectFormat));
   488     
   497     
   489     result = iDpSingletons.ExclusionMgrL().IsFormatValid(TMTPFormatCode(format));
   498     result = iDpSingletons.ExclusionMgrL().IsFormatValid(TMTPFormatCode(format));
   490     
   499     
   491     if (result)
   500     if (result)
   492         {
   501         {     
   493         __FLOG_VA((_L8("ASSOCIATION TYPE IS: %X"), iObjectInfo->Uint16L(CMTPTypeObjectInfo::EAssociationType)));        
   502 		OstTrace1( TRACE_NORMAL, CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTINFOCOMPLETEL, 
   494 		if(format == EMTPFormatCodeAssociation)
   503 		        "ASSOCIATION TYPE IS: %X", iObjectInfo->Uint16L(CMTPTypeObjectInfo::EAssociationType));
       
   504 		
       
   505         if(format == EMTPFormatCodeAssociation)
   495 			{
   506 			{
   496 			if((iObjectInfo->Uint16L(CMTPTypeObjectInfo::EAssociationType) == EMTPAssociationTypeGenericFolder) ||
   507 			if((iObjectInfo->Uint16L(CMTPTypeObjectInfo::EAssociationType) == EMTPAssociationTypeGenericFolder) ||
   497         		      (iObjectInfo->Uint16L(CMTPTypeObjectInfo::EAssociationType) == EMTPAssociationTypeUndefined))
   508         		      (iObjectInfo->Uint16L(CMTPTypeObjectInfo::EAssociationType) == EMTPAssociationTypeUndefined))
   498 				iIsFolder = ETrue;
   509 				iIsFolder = ETrue;
   499 			else{
   510 			else{
   562         	
   573         	
   563         TRAPD(err, CreateFsObjectL());
   574         TRAPD(err, CreateFsObjectL());
   564         
   575         
   565         if (err != KErrNone)
   576         if (err != KErrNone)
   566             {
   577             {
   567             __FLOG_1(_L8("Fail to create fs object %d"),err);
   578             OstTrace1( TRACE_ERROR, DUP1_CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTINFOCOMPLETEL, "Fail to create fs object %d", err );
   568             SendResponseL(ErrorToMTPError(err));
   579             SendResponseL(ErrorToMTPError(err));
   569             result = EFalse;
   580             result = EFalse;
   570             }
   581             }
   571         else
   582         else
   572             {
   583             {
   573             ReserveObjectL();
   584             ReserveObjectL();
   574             }
   585             }
   575         }
   586         }
   576     __FLOG(_L8("DoHandleSendObjectInfoCompleteL - Exit"));
   587     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTINFOCOMPLETEL_EXIT );
   577     return result;    
   588     return result;    
   578     }
   589     }
   579 
   590 
   580 /**
   591 /**
   581 Handling the completing phase of SendObjectPropList request
   592 Handling the completing phase of SendObjectPropList request
   582 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
   593 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse
   583 */    
   594 */    
   584 TBool CMTPSendObjectInfo::DoHandleSendObjectPropListCompleteL()
   595 TBool CMTPSendObjectInfo::DoHandleSendObjectPropListCompleteL()
   585     {
   596     {
   586     __FLOG(_L8("DoHandleSendObjectPropListCompleteL - Entry"));
   597     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTPROPLISTCOMPLETEL_ENTRY );
   587     TBool result(ETrue);
   598     TBool result(ETrue);
   588     
   599     
   589     TMTPResponseCode responseCode(GetParentObjectAndStorageIdL());
   600     TMTPResponseCode responseCode(GetParentObjectAndStorageIdL());
   590     if (responseCode != EMTPRespCodeOK)
   601     if (responseCode != EMTPRespCodeOK)
   591         {
   602         {
   633         
   644         
   634         TRAPD(err, CreateFsObjectL());
   645         TRAPD(err, CreateFsObjectL());
   635         
   646         
   636         if (err != KErrNone)
   647         if (err != KErrNone)
   637             {
   648             {
   638             __FLOG_1(_L8("Fail to create fs object %d"),err);
   649             OstTrace1( TRACE_ERROR, CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTPROPLISTCOMPLETEL, "Fail to create fs object %d", err );
   639             SendResponseL(ErrorToMTPError(err));
   650             SendResponseL(ErrorToMTPError(err));
   640             result = EFalse;
   651             result = EFalse;
   641             }
   652             }
   642         else
   653         else
   643             {
   654             {
   644             ReserveObjectL();
   655             ReserveObjectL();
   645             }
   656             }
   646         }
   657         }
   647         
   658 
   648     __FLOG(_L8("DoHandleSendObjectPropListCompleteL - Exit"));
   659     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTPROPLISTCOMPLETEL_EXIT );
   649     return result;    
   660     return result;    
   650     }
   661     }
   651     
   662     
   652 /**
   663 /**
   653 Handling the completing phase of SendObject request
   664 Handling the completing phase of SendObject request
   654 @return ETrue if the object has been successfully saved on the device, otherwise, EFalse
   665 @return ETrue if the object has been successfully saved on the device, otherwise, EFalse
   655 */    
   666 */    
   656 TBool CMTPSendObjectInfo::DoHandleSendObjectCompleteL()
   667 TBool CMTPSendObjectInfo::DoHandleSendObjectCompleteL()
   657     {
   668     {
   658     __FLOG(_L8("DoHandleSendObjectCompleteL - Entry"));
   669     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL_ENTRY );
   659     TBool result(ETrue);
   670     TBool result(ETrue);
   660         
   671         
   661     if (!iIsFolder)
   672     if (!iIsFolder)
   662         {        
   673         {        
   663         delete iFileReceived;
   674         delete iFileReceived;
   664         iFileReceived = NULL;
   675         iFileReceived = NULL;
   665         
   676         
   666         TEntry fileEntry;
   677         TEntry fileEntry;
   667         User::LeaveIfError(iFramework.Fs().Entry(iFullPath, fileEntry));
   678         LEAVEIFERROR(iFramework.Fs().Entry(iFullPath, fileEntry),
   668 
   679                 OstTraceExt1( TRACE_ERROR, CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL, "Gets the entry details for %S failed!", iFullPath));
   669         if (fileEntry.FileSize() != iObjectSize)
   680         if (fileEntry.FileSize() != iObjectSize)
   670             {
   681             {
       
   682 			delete iFileReceived;
       
   683         	iFileReceived = NULL;
   671             iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   684             iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   672             
   685             
   673             iFramework.Fs().Delete(iFullPath);
   686             iFramework.Fs().Delete(iFullPath);
   674             iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject);
   687             iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject);
   675             TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge;
   688             TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge;
   692     TInt ret = connection.GetDataReceiveResult(); 
   705     TInt ret = connection.GetDataReceiveResult(); 
   693     frameworkSingletons.Close();
   706     frameworkSingletons.Close();
   694      // SendObject is cancelled or connection is dropped.
   707      // SendObject is cancelled or connection is dropped.
   695     if(result && (iCancelled || (ret == KErrAbort)))
   708     if(result && (iCancelled || (ret == KErrAbort)))
   696         {
   709         {
   697         __FLOG(_L8("It is a cancel for sendObject."));
   710         OstTrace0( TRACE_NORMAL, DUP1_CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL, "It is a cancel for sendObject." );
   698         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   711         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   699         Rollback();
   712         Rollback();
   700         SendResponseL(EMTPRespCodeTransactionCancelled);        
   713         SendResponseL(EMTPRespCodeTransactionCancelled);        
   701         }
   714         }
   702     else if (result && !iCancelled)
   715     else if (result && !iCancelled)
   711         //with folder creation.
   724         //with folder creation.
   712 
   725 
   713         if(!iIsFolder)
   726         if(!iIsFolder)
   714             {
   727             {
   715             SetPropertiesL();    
   728             SetPropertiesL();    
       
   729             delete iFileReceived;
       
   730             iFileReceived = NULL;
   716             iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);
   731             iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);
   717             iFullPath.LowerCase();
   732             iFullPath.LowerCase();
   718             __FLOG_VA((_L8("File Name %S"), &iFullPath));
   733             OstTraceExt1( TRACE_NORMAL, DUP2_CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL, "File Name %S", iFullPath);
   719             TParsePtrC file( iFullPath );
   734             TParsePtrC file( iFullPath );
   720             if ( file.ExtPresent() && file.Ext().Length()<=KExtensionLength && iExceptionList.Find(file.Ext()) != KErrNotFound)
   735             if ( file.ExtPresent() && file.Ext().Length()<=KExtensionLength && iExceptionList.Find(file.Ext()) != KErrNotFound)
   721                 {
   736                 {
   722                 TUint32 DpId = iFramework.DataProviderId();
   737                 TUint32 DpId = iFramework.DataProviderId();
   723                 HBufC* mime = iDpSingletons.MTPUtility().ContainerMimeType(iFullPath);
   738                 HBufC* mime = iDpSingletons.MTPUtility().ContainerMimeType(iFullPath);
   754                 }
   769                 }
   755             }
   770             }
   756         
   771         
   757         SendResponseL(EMTPRespCodeOK);
   772         SendResponseL(EMTPRespCodeOK);
   758 	    }
   773 	    }
   759     __FLOG(_L8("DoHandleSendObjectCompleteL - Exit"));
   774     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL_EXIT );
   760     return result;
   775     return result;
   761     }
   776     }
   762 
   777 
   763 
   778 
   764 /**
   779 /**
   767 on return, contains the full path name of the object to be saved
   782 on return, contains the full path name of the object to be saved
   768 @return ETrue if the name is valid, EFalse otherwise
   783 @return ETrue if the name is valid, EFalse otherwise
   769 */
   784 */
   770 TBool CMTPSendObjectInfo::GetFullPathNameL(const TDesC& aFileName)
   785 TBool CMTPSendObjectInfo::GetFullPathNameL(const TDesC& aFileName)
   771     {
   786     {
   772     __FLOG(_L8("GetFullPathNameL - Entry"));
   787     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_GETFULLPATHNAMEL_ENTRY );
   773     TBool result(EFalse);
   788     TBool result(EFalse);
   774     if (aFileName.Length() > 0)
   789     if (aFileName.Length() > 0)
   775         {
   790         {
   776         iFullPath = *iParentSuid;
   791         iFullPath = *iParentSuid;
   777         if (iFullPath.Length() + aFileName.Length() < iFullPath.MaxLength())
   792         if (iFullPath.Length() + aFileName.Length() < iFullPath.MaxLength())
   792                 result = iFramework.Fs().IsValidName(iFullPath);
   807                 result = iFramework.Fs().IsValidName(iFullPath);
   793                 }
   808                 }
   794             }
   809             }
   795         }
   810         }
   796 
   811 
   797 #ifdef __FLOG_ACTIVE
   812 #ifdef OST_TRACE_COMPILER_IN_USE
   798     TFileName tempName;
   813     TFileName tempName;
   799     tempName.Copy(iFullPath);
   814     tempName.Copy(iFullPath);
   800     tempName.Collapse();
   815     tempName.Collapse();
   801     __FLOG_VA((_L8("iFullPath = %S, Result = %d"), &tempName, result));
   816     OstTraceExt2( TRACE_NORMAL, CMTPSENDOBJECTINFO_GETFULLPATHNAMEL, "iFullPath = %S, Result = %d", tempName, result);
   802     __FLOG(_L8("GetFullPathNameL - Exit"));
       
   803 #endif
   817 #endif
       
   818     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_GETFULLPATHNAMEL_EXIT );
   804     return result;
   819     return result;
   805     }
   820     }
   806 
   821 
   807 /**
   822 /**
   808 Check if the object is too large
   823 Check if the object is too large
   809 @return ETrue if yes, otherwise EFalse
   824 @return ETrue if yes, otherwise EFalse
   810 */
   825 */
   811 TBool CMTPSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const
   826 TBool CMTPSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const
   812     {
   827     {
   813     __FLOG(_L8("IsTooLarge - Entry"));
   828     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_ISTOOLARGE_ENTRY );
   814     TBool ret(aObjectSize > KMaxTInt64);
   829     TBool ret(aObjectSize > KMaxTInt64);
   815     
   830     
   816     if(!ret)
   831     if(!ret)
   817         {
   832         {
   818         TBuf<255> fsname;
   833         TBuf<255> fsname;
   820         if (storageId == KMTPStorageDefault)
   835         if (storageId == KMTPStorageDefault)
   821             {
   836             {
   822             storageId = iFramework.StorageMgr().DefaultStorageId();
   837             storageId = iFramework.StorageMgr().DefaultStorageId();
   823             }
   838             }
   824         TInt drive( iFramework.StorageMgr().DriveNumber(storageId) );
   839         TInt drive( iFramework.StorageMgr().DriveNumber(storageId) );
   825         User::LeaveIfError(drive);
   840         LEAVEIFERROR(drive,
       
   841                 OstTrace1( TRACE_ERROR, CMTPSENDOBJECTINFO_ISTOOLARGE, "can't get driver number for storage %d", storageId));
   826         iFramework.Fs().FileSystemSubType(drive, fsname);        
   842         iFramework.Fs().FileSystemSubType(drive, fsname);        
   827         
   843         
   828         const TUint64 KMaxFatFileSize = 0xFFFFFFFF; //Maximal file size supported by all FAT filesystems (4GB-1)
   844         const TUint64 KMaxFatFileSize = 0xFFFFFFFF; //Maximal file size supported by all FAT filesystems (4GB-1)
   829         _LIT(KFsFAT16, "FAT16");
   845         _LIT(KFsFAT16, "FAT16");
   830         _LIT(KFsFAT32, "FAT32");
   846         _LIT(KFsFAT32, "FAT32");
   832         if((fsname.CompareF(KFsFAT16) == 0 || fsname.CompareF(KFsFAT32) == 0) && aObjectSize > KMaxFatFileSize)
   848         if((fsname.CompareF(KFsFAT16) == 0 || fsname.CompareF(KFsFAT32) == 0) && aObjectSize > KMaxFatFileSize)
   833             {
   849             {
   834             ret = ETrue;
   850             ret = ETrue;
   835             }
   851             }
   836         }
   852         }
   837     __FLOG_VA((_L8("Result = %d"), ret));
   853     OstTrace1( TRACE_NORMAL, DUP1_CMTPSENDOBJECTINFO_ISTOOLARGE, "Result = %d", ret );
   838     __FLOG(_L8("IsTooLarge - Exit"));
   854     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_ISTOOLARGE_EXIT );
   839     return ret;
   855     return ret;
   840     }
   856     }
   841     
   857     
   842 /**
   858 /**
   843 Check if the file already exists on the storage.
   859 Check if the file already exists on the storage.
   844 @return ETrue if file is exists, otherwise EFalse
   860 @return ETrue if file is exists, otherwise EFalse
   845 */
   861 */
   846 TBool CMTPSendObjectInfo::Exists(const TDesC& aName) const
   862 TBool CMTPSendObjectInfo::Exists(const TDesC& aName) const
   847     {
   863     {
   848     __FLOG(_L8("Exists - Entry"));
   864     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_EXISTS_ENTRY );
   849     // This detects both files and folders
   865     // This detects both files and folders
   850     TBool ret(EFalse); 
   866     TBool ret(EFalse); 
   851     ret = BaflUtils::FileExists(iFramework.Fs(), aName);
   867     ret = BaflUtils::FileExists(iFramework.Fs(), aName);
   852     __FLOG_VA((_L8("Result = %d"), ret));
   868     OstTrace1( TRACE_NORMAL, CMTPSENDOBJECTINFO_EXISTS, "Result = %d", ret );
   853     __FLOG(_L8("Exists - Exit"));
   869     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_EXISTS_EXIT );
   854     return ret;
   870     return ret;
   855     }
   871     }
   856 
   872 
   857 /**
   873 /**
   858 Check if the property list is valid and extract properties (file name)
   874 Check if the property list is valid and extract properties (file name)
   859 @param aInvalidParameterIndex if invalid, contains the index of the property.  Undefined, if it is valid.
   875 @param aInvalidParameterIndex if invalid, contains the index of the property.  Undefined, if it is valid.
   860 @return if error, one of the error response code; otherwise EMTPRespCodeOK
   876 @return if error, one of the error response code; otherwise EMTPRespCodeOK
   861 */
   877 */
   862 TMTPResponseCode CMTPSendObjectInfo::VerifyObjectPropListL(TInt& aInvalidParameterIndex)
   878 TMTPResponseCode CMTPSendObjectInfo::VerifyObjectPropListL(TInt& aInvalidParameterIndex)
   863     {
   879     {
   864     __FLOG(_L8("VerifyObjectPropListL - Entry"));
   880     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_VERIFYOBJECTPROPLISTL_ENTRY );
   865     TMTPResponseCode responseCode(EMTPRespCodeOK);
   881     TMTPResponseCode responseCode(EMTPRespCodeOK);
   866     const TUint KCount(iObjectPropList->NumberOfElements());
   882     const TUint KCount(iObjectPropList->NumberOfElements());
   867 	iObjectPropList->ResetCursor();
   883 	iObjectPropList->ResetCursor();
   868     for (TUint i(0); (i < KCount); i++)
   884     for (TUint i(0); (i < KCount); i++)
   869         {
   885         {
   885         if (responseCode != EMTPRespCodeOK)
   901         if (responseCode != EMTPRespCodeOK)
   886             {
   902             {
   887             break;
   903             break;
   888             }        
   904             }        
   889         }
   905         }
   890     __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
   906     OstTrace1( TRACE_NORMAL, CMTPSENDOBJECTINFO_VERIFYOBJECTPROPLISTL, "Result = 0x%04X", responseCode);
   891     __FLOG(_L8("VerifyObjectPropListL - Exit"));
   907     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_VERIFYOBJECTPROPLISTL_EXIT );
   892     return responseCode;        
   908     return responseCode;        
   893     }
   909     }
   894 
   910 
   895 /**
   911 /**
   896 Extracts the file information from the object property list element
   912 Extracts the file information from the object property list element
   898 @param aPropertyCode MTP property code for the element
   914 @param aPropertyCode MTP property code for the element
   899 @return MTP response code
   915 @return MTP response code
   900 */
   916 */
   901 TMTPResponseCode CMTPSendObjectInfo::ExtractPropertyL(const CMTPTypeObjectPropListElement& aElement)
   917 TMTPResponseCode CMTPSendObjectInfo::ExtractPropertyL(const CMTPTypeObjectPropListElement& aElement)
   902     {
   918     {
   903     __FLOG(_L8("ExtractPropertyL - Entry"));
   919     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_EXTRACTPROPERTYL_ENTRY );
   904     TMTPResponseCode responseCode(EMTPRespCodeOK);
   920     TMTPResponseCode responseCode(EMTPRespCodeOK);
   905     switch (aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
   921     switch (aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
   906         {
   922         {
   907     case EMTPObjectPropCodeAssociationDesc:
   923     case EMTPObjectPropCodeAssociationDesc:
   908         // Actually, any association is treated as a folder, and iIsFolder should already be set
   924         // Actually, any association is treated as a folder, and iIsFolder should already be set
   937         iDateMod = aElement.StringL(CMTPTypeObjectPropListElement::EValue).AllocL();
   953         iDateMod = aElement.StringL(CMTPTypeObjectPropListElement::EValue).AllocL();
   938         break;
   954         break;
   939     case EMTPObjectPropCodeName:
   955     case EMTPObjectPropCodeName:
   940     	iName = aElement.StringL(CMTPTypeObjectPropListElement::EValue);
   956     	iName = aElement.StringL(CMTPTypeObjectPropListElement::EValue);
   941     	break;
   957     	break;
       
   958     case EMTPObjectPropCodeHidden:
       
   959         iHiddenStatus = aElement.Uint16L(CMTPTypeObjectPropListElement::EValue);
       
   960         break;
   942     default:
   961     default:
   943         break;
   962         break;
   944         }
   963         }
   945     __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
   964     OstTrace1( TRACE_NORMAL, CMTPSENDOBJECTINFO_EXTRACTPROPERTYL, "Result = 0x%04X", responseCode);
   946     __FLOG(_L8("ExtractPropertyL - Exit"));
   965     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_EXTRACTPROPERTYL_EXIT );
   947     return responseCode;    
   966     return responseCode;    
   948     }
   967     }
   949 
   968 
   950 /**
   969 /**
   951 Validates the data type for a given property code.
   970 Validates the data type for a given property code.
   953 @param aPropertyCode MTP property code for the element
   972 @param aPropertyCode MTP property code for the element
   954 @return EMTPRespCodeOK if the combination is valid, or another MTP response code if not
   973 @return EMTPRespCodeOK if the combination is valid, or another MTP response code if not
   955 */
   974 */
   956 TMTPResponseCode CMTPSendObjectInfo::CheckPropCodeL(const CMTPTypeObjectPropListElement& aElement) const
   975 TMTPResponseCode CMTPSendObjectInfo::CheckPropCodeL(const CMTPTypeObjectPropListElement& aElement) const
   957     {
   976     {
   958     __FLOG(_L8("CheckPropCode - Entry"));
   977     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_CHECKPROPCODEL_ENTRY );
   959     TMTPResponseCode responseCode(EMTPRespCodeOK);
   978     TMTPResponseCode responseCode(EMTPRespCodeOK);
   960     switch(aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
   979     switch(aElement.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode))
   961         {
   980         {
   962     case EMTPObjectPropCodeStorageID:
   981     case EMTPObjectPropCodeStorageID:
   963         if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32)
   982         if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT32)
  1029             responseCode = EMTPRespCodeInvalidObjectPropFormat;
  1048             responseCode = EMTPRespCodeInvalidObjectPropFormat;
  1030             }
  1049             }
  1031         break;
  1050         break;
  1032         
  1051         
  1033     case EMTPObjectPropCodeAssociationType:
  1052     case EMTPObjectPropCodeAssociationType:
       
  1053     case EMTPObjectPropCodeHidden:
  1034         if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
  1054         if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
  1035              {
  1055              {
  1036              responseCode = EMTPRespCodeInvalidObjectPropFormat;
  1056              responseCode = EMTPRespCodeInvalidObjectPropFormat;
  1037              }
  1057              }
  1038     	break;
  1058     	break;
  1046                 
  1066                 
  1047     default:
  1067     default:
  1048         responseCode = EMTPRespCodeInvalidObjectPropCode;
  1068         responseCode = EMTPRespCodeInvalidObjectPropCode;
  1049         break;
  1069         break;
  1050         }
  1070         }
  1051     __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
  1071     OstTrace1( TRACE_NORMAL, CMTPSENDOBJECTINFO_CHECKPROPCODEL, "Result = 0x%04X", responseCode);
  1052     __FLOG(_L8("CheckPropCode - Exit"));
  1072     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_CHECKPROPCODEL_EXIT );
  1053     return responseCode;    
  1073     return responseCode;    
  1054     }
  1074     }
  1055 
  1075 
  1056 /**
  1076 /**
  1057 Validates the data type for a given property code.
  1077 Validates the data type for a given property code.
  1084 				{
  1104 				{
  1085 				ret = EMTPRespCodeInvalidObjectHandle;
  1105 				ret = EMTPRespCodeInvalidObjectHandle;
  1086 				}
  1106 				}
  1087 			}
  1107 			}
  1088     	}
  1108     	}
  1089     
  1109 
  1090     return ret;
  1110     return ret;
  1091     }
  1111     }
  1092 
  1112 
  1093 /**
  1113 /**
  1094 Reserves space for and assigns an object handle to the received object, then
  1114 Reserves space for and assigns an object handle to the received object, then
  1095 sends a success response.
  1115 sends a success response.
  1096 */
  1116 */
  1097 void CMTPSendObjectInfo::ReserveObjectL()
  1117 void CMTPSendObjectInfo::ReserveObjectL()
  1098     {
  1118     {
  1099     __FLOG(_L8("ReserveObjectL - Entry"));    
  1119     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_RESERVEOBJECTL_ENTRY );
  1100     iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
  1120     iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
  1101     iReceivedObject->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath);
  1121     iReceivedObject->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath);
  1102     
  1122     
  1103     if(iIsFolder)
  1123     if(iIsFolder)
  1104         {
  1124         {
  1125     TUint32 parameters[3];
  1145     TUint32 parameters[3];
  1126     parameters[0] = iStorageId;
  1146     parameters[0] = iStorageId;
  1127     parameters[1] = iParentHandle;
  1147     parameters[1] = iParentHandle;
  1128     parameters[2] = iReceivedObject->Uint(CMTPObjectMetaData::EHandle);
  1148     parameters[2] = iReceivedObject->Uint(CMTPObjectMetaData::EHandle);
  1129     SendResponseL(EMTPRespCodeOK, (sizeof(parameters) / sizeof(parameters[0])), parameters);
  1149     SendResponseL(EMTPRespCodeOK, (sizeof(parameters) / sizeof(parameters[0])), parameters);
  1130     __FLOG(_L8("ReserveObjectL - Exit"));    
  1150     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_RESERVEOBJECTL_EXIT );
  1131     }
  1151     }
  1132     
  1152     
  1133 void CMTPSendObjectInfo::CreateFsObjectL()
  1153 void CMTPSendObjectInfo::CreateFsObjectL()
  1134     {
  1154     {
  1135     if (iIsFolder)
  1155     if (iIsFolder)
  1136         {
  1156         {
  1137         if (!Exists(iFullPath))
  1157         if (!Exists(iFullPath))
  1138             {
  1158             {
  1139             User::LeaveIfError(iFramework.Fs().MkDirAll(iFullPath));
  1159             LEAVEIFERROR(iFramework.Fs().MkDirAll(iFullPath),
       
  1160                     OstTraceExt1( TRACE_ERROR, CMTPSENDOBJECTINFO_CREATEFSOBJECTL, "Makes directories failed for %S", iFullPath));      
  1140             }
  1161             }
  1141         }
  1162         }
  1142     else
  1163     else
  1143         {
  1164         {
  1144         delete iFileReceived;
  1165         delete iFileReceived;
  1150     
  1171     
  1151 void CMTPSendObjectInfo::Rollback()
  1172 void CMTPSendObjectInfo::Rollback()
  1152     {
  1173     {
  1153     if(iIsFolder)
  1174     if(iIsFolder)
  1154         {
  1175         {
  1155         __FLOG(_L8("Rollback the dir created."));
  1176         OstTrace0( TRACE_NORMAL, CMTPSENDOBJECTINFO_ROLLBACK, "Rollback the dir created." );
  1156         iFramework.Fs().RmDir(iFullPath);
  1177         iFramework.Fs().RmDir(iFullPath);
  1157         // If it is folder, delete it from MTP database, i.e ObjectStore.
  1178         // If it is folder, delete it from MTP database, i.e ObjectStore.
  1158         TRAP_IGNORE(iFramework.ObjectMgr().RemoveObjectL(iFullPath));
  1179         TRAP_IGNORE(iFramework.ObjectMgr().RemoveObjectL(iFullPath));
  1159         }
  1180         }
  1160     else
  1181     else
  1161         {
  1182         {
  1162         __FLOG(_L8("Rollback the file created."));
  1183         OstTrace0( TRACE_NORMAL, DUP1_CMTPSENDOBJECTINFO_ROLLBACK, "Rollback the file created." );
  1163         delete iFileReceived;
  1184         delete iFileReceived;
  1164         iFileReceived = NULL;
  1185         iFileReceived = NULL;
  1165         // Delete this object from file system.
  1186         // Delete this object from file system.
  1166         iFramework.Fs().Delete(iFullPath);
  1187         iFramework.Fs().Delete(iFullPath);
  1167         TRAP_IGNORE(iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject));
  1188         TRAP_IGNORE(iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject));
  1187         break;
  1208         break;
  1188         
  1209         
  1189     default:
  1210     default:
  1190         break;
  1211         break;
  1191         }
  1212         }
  1192         
  1213 
  1193     return resp;
  1214     return resp;
  1194     }
  1215     }
  1195 
  1216 
  1196 /**
  1217 /**
  1197 Sets the read only status on the current file to match the sent object.
  1218 Sets the read only status on the current file to match the sent object.
  1198 */
  1219 */
  1199 void CMTPSendObjectInfo::SetPropertiesL()
  1220 void CMTPSendObjectInfo::SetPropertiesL()
  1200     {
  1221     {
  1201     __FLOG(_L8("SetPropertiesL - Entry"));
  1222     OstTraceFunctionEntry0( CMTPSENDOBJECTINFO_SETPROPERTIESL_ENTRY );
  1202     TEntry entry;
  1223     TEntry entry;
  1203     User::LeaveIfError(iFramework.Fs().Entry(iFullPath, entry));  
  1224     LEAVEIFERROR(iFramework.Fs().Entry(iFullPath, entry),
       
  1225             OstTraceExt1( TRACE_ERROR, CMTPSENDOBJECTINFO_SETPROPERTIESL, "can't get entry details from %S", iFullPath));
  1204     
  1226     
  1205     TUint16 assoc(EMTPAssociationTypeUndefined);
  1227     TUint16 assoc(EMTPAssociationTypeUndefined);
  1206 	if (entry.IsDir())
  1228 	if (entry.IsDir())
  1207 		{
  1229 		{
  1208 		assoc = EMTPAssociationTypeGenericFolder;
  1230 		assoc = EMTPAssociationTypeGenericFolder;
  1233             }
  1255             }
  1234         else
  1256         else
  1235             {
  1257             {
  1236             entry.iAtt |= KEntryAttReadOnly;
  1258             entry.iAtt |= KEntryAttReadOnly;
  1237             }
  1259             }
  1238         User::LeaveIfError(iFramework.Fs().SetAtt(iFullPath, entry.iAtt, ~entry.iAtt));
  1260         if ( iFileReceived )
  1239         }
  1261             {
  1240 
  1262             User::LeaveIfError(iFileReceived->File().SetAtt(entry.iAtt, ~entry.iAtt));
       
  1263             }
       
  1264         else
       
  1265             {
       
  1266         LEAVEIFERROR(iFramework.Fs().SetAtt(iFullPath, entry.iAtt, ~entry.iAtt),
       
  1267                 OstTraceExt2( TRACE_ERROR, DUP1_CMTPSENDOBJECTINFO_SETPROPERTIESL, "set attribute %d for %S failed!", (TInt32)entry.iAtt, iFullPath));      
       
  1268             }
       
  1269         }
       
  1270     
       
  1271     if ( EMTPHidden == iHiddenStatus )
       
  1272         {
       
  1273 		entry.iAtt &= ~KEntryAttHidden;
       
  1274         entry.iAtt |= KEntryAttHidden;
       
  1275         if ( iFileReceived )
       
  1276             {
       
  1277             User::LeaveIfError(iFileReceived->File().SetAtt(entry.iAtt, ~entry.iAtt));
       
  1278             }
       
  1279         else
       
  1280             {
       
  1281             User::LeaveIfError(iFramework.Fs().SetAtt(iFullPath, entry.iAtt, ~entry.iAtt));
       
  1282             }
       
  1283         }
       
  1284     
  1241     if(iDateMod != NULL && iDateMod->Length())
  1285     if(iDateMod != NULL && iDateMod->Length())
  1242        {
  1286        {
  1243        TTime modifiedTime;
  1287        TTime modifiedTime;
  1244        iDpSingletons.MTPUtility().MTPTimeStr2TTime(*iDateMod, modifiedTime);
  1288        iDpSingletons.MTPUtility().MTPTimeStr2TTime(*iDateMod, modifiedTime);
  1245        User::LeaveIfError(iFramework.Fs().SetModified(iFullPath, modifiedTime));
  1289        if ( iFileReceived )
       
  1290            { 
       
  1291            User::LeaveIfError(iFileReceived->File().SetModified( modifiedTime ));
       
  1292            }
       
  1293        else
       
  1294            {
       
  1295            User::LeaveIfError(iFramework.Fs().SetModified(iFullPath, modifiedTime));
       
  1296            }
  1246        }  
  1297        }  
  1247     
  1298     
  1248     iReceivedObject->SetDesCL(CMTPObjectMetaData::EName, iName);
  1299     iReceivedObject->SetDesCL(CMTPObjectMetaData::EName, iName);
  1249     
  1300     
  1250     __FLOG(_L8("SetPropertiesL - Exit"));
  1301     OstTraceFunctionExit0( CMTPSENDOBJECTINFO_SETPROPERTIESL_EXIT );
  1251     }
  1302     }
  1252 
  1303