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