mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp
branchRCL_3
changeset 17 dbd1c5e08735
parent 12 523717cdb0ad
equal deleted inserted replaced
15:f85613f12947 17:dbd1c5e08735
   538             // File and/or parent pathname invalid.
   538             // File and/or parent pathname invalid.
   539             SendResponseL(EMTPRespCodeInvalidDataset);
   539             SendResponseL(EMTPRespCodeInvalidDataset);
   540             }
   540             }
   541         }
   541         }
   542 
   542 
   543     if (result)
   543     if (result && !iIsFolder)
   544         {    
   544         {    
   545         result &= !Exists(iFullPath);
   545         result &= !Exists(iFullPath);
   546         if (!result)
   546         if (!result)
   547             {        
   547             {        
   548             // Object with the same name already exists.
   548             // Object with the same name already exists.
   611             parameters[3] = invalidParameterIndex;
   611             parameters[3] = invalidParameterIndex;
   612             SendResponseL(responseCode, 4, parameters);
   612             SendResponseL(responseCode, 4, parameters);
   613             }
   613             }
   614         }
   614         }
   615         
   615         
   616     if (result) 
   616     if (result && !iIsFolder)
   617         {
   617         {
   618         result = !Exists(iFullPath);
   618         result = !Exists(iFullPath);
   619         if (!result)
   619         if (!result)
   620             {
   620             {
   621             // Object with the same name already exists.
   621             // Object with the same name already exists.
  1098     {
  1098     {
  1099     __FLOG(_L8("ReserveObjectL - Entry"));    
  1099     __FLOG(_L8("ReserveObjectL - Entry"));    
  1100     iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
  1100     iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
  1101     iReceivedObject->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath);
  1101     iReceivedObject->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath);
  1102     
  1102     
  1103     iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize);    
       
  1104     
       
  1105     if(iIsFolder)
  1103     if(iIsFolder)
  1106         {
  1104         {
  1107         SetPropertiesL(); 
  1105         SetPropertiesL();
  1108         iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);       
  1106         TUint32 handle = iFramework.ObjectMgr().HandleL(iFullPath);
       
  1107         if (handle != KMTPHandleNone)
       
  1108             {
       
  1109             // The folder is already in DB
       
  1110             iReceivedObject->SetUint(CMTPObjectMetaData::EHandle, handle);
       
  1111             iFramework.ObjectMgr().ModifyObjectL(*iReceivedObject);
       
  1112             }
       
  1113         else
       
  1114             {
       
  1115             iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize);
       
  1116             iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);
       
  1117             }
  1109         }
  1118         }
  1110     else
  1119     else
  1111     	{
  1120         {
  1112     	iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
  1121         iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize);    
  1113     	iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
  1122         iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
  1114     	}
  1123         iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
       
  1124         }
  1115     TUint32 parameters[3];
  1125     TUint32 parameters[3];
  1116     parameters[0] = iStorageId;
  1126     parameters[0] = iStorageId;
  1117     parameters[1] = iParentHandle;
  1127     parameters[1] = iParentHandle;
  1118     parameters[2] = iReceivedObject->Uint(CMTPObjectMetaData::EHandle);
  1128     parameters[2] = iReceivedObject->Uint(CMTPObjectMetaData::EHandle);
  1119     SendResponseL(EMTPRespCodeOK, (sizeof(parameters) / sizeof(parameters[0])), parameters);
  1129     SendResponseL(EMTPRespCodeOK, (sizeof(parameters) / sizeof(parameters[0])), parameters);
  1122     
  1132     
  1123 void CMTPSendObjectInfo::CreateFsObjectL()
  1133 void CMTPSendObjectInfo::CreateFsObjectL()
  1124     {
  1134     {
  1125     if (iIsFolder)
  1135     if (iIsFolder)
  1126         {
  1136         {
  1127         User::LeaveIfError(iFramework.Fs().MkDirAll(iFullPath));
  1137         if (!Exists(iFullPath))
       
  1138             {
       
  1139             User::LeaveIfError(iFramework.Fs().MkDirAll(iFullPath));
       
  1140             }
  1128         }
  1141         }
  1129     else
  1142     else
  1130         {
  1143         {
  1131         delete iFileReceived;
  1144         delete iFileReceived;
  1132         iFileReceived = NULL;
  1145         iFileReceived = NULL;