mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp
branchRCL_3
changeset 48 debf68073f2f
parent 39 dbd1c5e08735
child 58 142dacf7b30e
equal deleted inserted replaced
45:74aa6861c87d 48:debf68073f2f
    98 Standard c++ constructor
    98 Standard c++ constructor
    99 @param aFramework    The data provider framework
    99 @param aFramework    The data provider framework
   100 @param aConnection    The connection from which the request comes
   100 @param aConnection    The connection from which the request comes
   101 */    
   101 */    
   102 CMTPSendObjectInfo::CMTPSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
   102 CMTPSendObjectInfo::CMTPSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
   103     CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
   103     CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
       
   104     iHiddenStatus( EMTPVisible )
   104     {
   105     {
   105     }
   106     }
   106 
   107 
   107 /**
   108 /**
   108 Verify the request
   109 Verify the request
   658     __FLOG(_L8("DoHandleSendObjectCompleteL - Entry"));
   659     __FLOG(_L8("DoHandleSendObjectCompleteL - Entry"));
   659     TBool result(ETrue);
   660     TBool result(ETrue);
   660         
   661         
   661     if (!iIsFolder)
   662     if (!iIsFolder)
   662         {        
   663         {        
   663         delete iFileReceived;
       
   664         iFileReceived = NULL;
       
   665         
   664         
   666         TEntry fileEntry;
   665         TEntry fileEntry;
   667         User::LeaveIfError(iFramework.Fs().Entry(iFullPath, fileEntry));
   666         User::LeaveIfError(iFramework.Fs().Entry(iFullPath, fileEntry));
   668 
   667 
   669         if (fileEntry.FileSize() != iObjectSize)
   668         if (fileEntry.FileSize() != iObjectSize)
   670             {
   669             {
       
   670 			delete iFileReceived;
       
   671         	iFileReceived = NULL;
       
   672 			
   671             iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   673             iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   672             
   674             
   673             iFramework.Fs().Delete(iFullPath);
   675             iFramework.Fs().Delete(iFullPath);
   674             iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject);
   676             iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject);
   675             TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge;
   677             TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge;
   711         //with folder creation.
   713         //with folder creation.
   712 
   714 
   713         if(!iIsFolder)
   715         if(!iIsFolder)
   714             {
   716             {
   715             SetPropertiesL();    
   717             SetPropertiesL();    
       
   718             delete iFileReceived;
       
   719             iFileReceived = NULL;
   716             iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);
   720             iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);
   717             iFullPath.LowerCase();
   721             iFullPath.LowerCase();
   718             __FLOG_VA((_L8("File Name %S"), &iFullPath));
   722             __FLOG_VA((_L8("File Name %S"), &iFullPath));
   719             TParsePtrC file( iFullPath );
   723             TParsePtrC file( iFullPath );
   720             if ( file.ExtPresent() && file.Ext().Length()<=KExtensionLength && iExceptionList.Find(file.Ext()) != KErrNotFound)
   724             if ( file.ExtPresent() && file.Ext().Length()<=KExtensionLength && iExceptionList.Find(file.Ext()) != KErrNotFound)
   937         iDateMod = aElement.StringL(CMTPTypeObjectPropListElement::EValue).AllocL();
   941         iDateMod = aElement.StringL(CMTPTypeObjectPropListElement::EValue).AllocL();
   938         break;
   942         break;
   939     case EMTPObjectPropCodeName:
   943     case EMTPObjectPropCodeName:
   940     	iName = aElement.StringL(CMTPTypeObjectPropListElement::EValue);
   944     	iName = aElement.StringL(CMTPTypeObjectPropListElement::EValue);
   941     	break;
   945     	break;
       
   946     case EMTPObjectPropCodeHidden:
       
   947         iHiddenStatus = aElement.Uint16L(CMTPTypeObjectPropListElement::EValue);
       
   948         break;
   942     default:
   949     default:
   943         break;
   950         break;
   944         }
   951         }
   945     __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
   952     __FLOG_VA((_L8("Result = 0x%04X"), responseCode));
   946     __FLOG(_L8("ExtractPropertyL - Exit"));
   953     __FLOG(_L8("ExtractPropertyL - Exit"));
  1029             responseCode = EMTPRespCodeInvalidObjectPropFormat;
  1036             responseCode = EMTPRespCodeInvalidObjectPropFormat;
  1030             }
  1037             }
  1031         break;
  1038         break;
  1032         
  1039         
  1033     case EMTPObjectPropCodeAssociationType:
  1040     case EMTPObjectPropCodeAssociationType:
       
  1041     case EMTPObjectPropCodeHidden:
  1034         if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
  1042         if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT16)
  1035              {
  1043              {
  1036              responseCode = EMTPRespCodeInvalidObjectPropFormat;
  1044              responseCode = EMTPRespCodeInvalidObjectPropFormat;
  1037              }
  1045              }
  1038     	break;
  1046     	break;
  1197 Sets the read only status on the current file to match the sent object.
  1205 Sets the read only status on the current file to match the sent object.
  1198 */
  1206 */
  1199 void CMTPSendObjectInfo::SetPropertiesL()
  1207 void CMTPSendObjectInfo::SetPropertiesL()
  1200     {
  1208     {
  1201     __FLOG(_L8("SetPropertiesL - Entry"));
  1209     __FLOG(_L8("SetPropertiesL - Entry"));
       
  1210 
  1202     TEntry entry;
  1211     TEntry entry;
  1203     User::LeaveIfError(iFramework.Fs().Entry(iFullPath, entry));  
  1212     User::LeaveIfError(iFramework.Fs().Entry(iFullPath, entry));  
  1204     
  1213     
  1205     TUint16 assoc(EMTPAssociationTypeUndefined);
  1214     TUint16 assoc(EMTPAssociationTypeUndefined);
  1206 	if (entry.IsDir())
  1215 	if (entry.IsDir())
  1233             }
  1242             }
  1234         else
  1243         else
  1235             {
  1244             {
  1236             entry.iAtt |= KEntryAttReadOnly;
  1245             entry.iAtt |= KEntryAttReadOnly;
  1237             }
  1246             }
  1238         User::LeaveIfError(iFramework.Fs().SetAtt(iFullPath, entry.iAtt, ~entry.iAtt));
  1247         if ( iFileReceived )
  1239         }
  1248             {
  1240 
  1249             User::LeaveIfError(iFileReceived->File().SetAtt(entry.iAtt, ~entry.iAtt));
       
  1250             }
       
  1251         else
       
  1252             {
       
  1253             User::LeaveIfError(iFramework.Fs().SetAtt(iFullPath, entry.iAtt, ~entry.iAtt));
       
  1254             }
       
  1255         }
       
  1256     
       
  1257     if ( EMTPHidden == iHiddenStatus )
       
  1258         {
       
  1259 		entry.iAtt &= ~KEntryAttHidden;
       
  1260         entry.iAtt |= KEntryAttHidden;
       
  1261         if ( iFileReceived )
       
  1262             {
       
  1263             User::LeaveIfError(iFileReceived->File().SetAtt(entry.iAtt, ~entry.iAtt));
       
  1264             }
       
  1265         else
       
  1266             {
       
  1267             User::LeaveIfError(iFramework.Fs().SetAtt(iFullPath, entry.iAtt, ~entry.iAtt));
       
  1268             }
       
  1269         }
       
  1270     
  1241     if(iDateMod != NULL && iDateMod->Length())
  1271     if(iDateMod != NULL && iDateMod->Length())
  1242        {
  1272        {
  1243        TTime modifiedTime;
  1273        TTime modifiedTime;
  1244        iDpSingletons.MTPUtility().MTPTimeStr2TTime(*iDateMod, modifiedTime);
  1274        iDpSingletons.MTPUtility().MTPTimeStr2TTime(*iDateMod, modifiedTime);
  1245        User::LeaveIfError(iFramework.Fs().SetModified(iFullPath, modifiedTime));
  1275        if ( iFileReceived )
       
  1276            { 
       
  1277            User::LeaveIfError(iFileReceived->File().SetModified( modifiedTime ));
       
  1278            }
       
  1279        else
       
  1280            {
       
  1281            User::LeaveIfError(iFramework.Fs().SetModified(iFullPath, modifiedTime));
       
  1282            }
  1246        }  
  1283        }  
  1247     
  1284     
  1248     iReceivedObject->SetDesCL(CMTPObjectMetaData::EName, iName);
  1285     iReceivedObject->SetDesCL(CMTPObjectMetaData::EName, iName);
  1249     
  1286     
  1250     __FLOG(_L8("SetPropertiesL - Exit"));
  1287     __FLOG(_L8("SetPropertiesL - Exit"));