mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp
changeset 28 85e0c0339cc3
parent 22 a5c0bb5018eb
child 33 883e91c086aa
equal deleted inserted replaced
25:48a2e0d8a4ce 28:85e0c0339cc3
    21 #include <f32file.h>
    21 #include <f32file.h>
    22 #include <bautils.h>
    22 #include <bautils.h>
    23 #include <e32const.h>
    23 #include <e32const.h>
    24 
    24 
    25 #include <mtp/mmtpdataproviderframework.h>
    25 #include <mtp/mmtpdataproviderframework.h>
       
    26 
    26 #include <mtp/cmtpobjectmetadata.h>
    27 #include <mtp/cmtpobjectmetadata.h>
    27 #include <mtp/cmtptypefile.h>
    28 #include <mtp/cmtptypefile.h>
    28 #include <mtp/cmtptypeobjectinfo.h>
    29 #include <mtp/cmtptypeobjectinfo.h>
    29 #include <mtp/cmtptypeobjectproplist.h>
    30 #include <mtp/cmtptypeobjectproplist.h>
    30 #include <mtp/cmtptypestring.h>
    31 #include <mtp/cmtptypestring.h>
   750 */    
   751 */    
   751 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL(TAny* /*aPtr*/)
   752 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL(TAny* /*aPtr*/)
   752     {
   753     {
   753     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL - Entry"));    
   754     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL - Entry"));    
   754     TBool result(ETrue);
   755     TBool result(ETrue);
       
   756 
       
   757     delete iFileReceived;
       
   758     iFileReceived = NULL;  
   755     
   759     
   756 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   760 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   757     TInt64 objectsize = 0;
   761     TInt64 objectsize = 0;
   758 #else
   762 #else
   759     TInt objectsize = 0;
   763     TInt objectsize = 0;
   760 #endif
   764 #endif
   761     
   765     
   762     iFileReceived->File().Size(objectsize);    
   766     TEntry entry;
   763     
   767     User::LeaveIfError(iFramework.Fs().Entry(iFullPath, entry));
       
   768     objectsize = entry.FileSize();
       
   769    
   764     if (objectsize != iObjectSize)
   770     if (objectsize != iObjectSize)
   765         {
   771         {
   766         __FLOG_VA((_L8("object sizes differ %lu != %lu"), objectsize, iObjectSize));
   772         __FLOG_VA((_L8("object sizes differ %lu != %lu"), objectsize, iObjectSize));
   767         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);         
   773         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);         
   768         Rollback();
   774         Rollback();
   787     else if (result && !iCancelled)
   793     else if (result && !iCancelled)
   788 	    {	    	    
   794 	    {	    	    
   789         if (iProtectionStatus ==  EMTPProtectionNoProtection ||
   795         if (iProtectionStatus ==  EMTPProtectionNoProtection ||
   790             iProtectionStatus == EMTPProtectionReadOnly)
   796             iProtectionStatus == EMTPProtectionReadOnly)
   791             {
   797             {
   792             TUint attValue = 0;
   798             entry.iAtt &= ~(KEntryAttNormal | KEntryAttReadOnly);
   793             User::LeaveIfError(iFileReceived->File().Att(attValue));
       
   794             attValue &= ~(KEntryAttNormal | KEntryAttReadOnly);
       
   795             
       
   796             if (iProtectionStatus == EMTPProtectionNoProtection)
   799             if (iProtectionStatus == EMTPProtectionNoProtection)
   797                 {                        
   800                 {                        
   798                 attValue |= KEntryAttNormal;
   801                 entry.iAtt |= KEntryAttNormal;
   799                 }
   802                 }
   800             else
   803             else
   801                 {
   804                 {
   802                 attValue |= KEntryAttReadOnly;
   805                 entry.iAtt |= KEntryAttReadOnly;
   803                 }
   806                 }
   804             User::LeaveIfError(iFileReceived->File().SetAtt(attValue, ~attValue));
   807             User::LeaveIfError(iFramework.Fs().SetAtt(iFullPath, entry.iAtt, ~entry.iAtt));
   805             }
   808             }
       
   809 
   806         TTime modifiedTime;
   810         TTime modifiedTime;
   807         //update datemodified property.
   811         //update datemodified property.
   808         if(iDateMod != NULL && iDateMod->Length())
   812         if(iDateMod != NULL && iDateMod->Length())
   809            {           
   813            {           
   810            iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateMod, modifiedTime);
   814            iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateMod, modifiedTime);
   811            User::LeaveIfError(iFileReceived->File().SetModified(modifiedTime));
       
   812            }
   815            }
   813         else if(iDateCreated != NULL && iDateCreated->Length())
   816         else if(iDateCreated != NULL && iDateCreated->Length())
   814            {
   817            {
   815            iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateCreated, modifiedTime);
   818            iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateCreated, modifiedTime);
   816            User::LeaveIfError(iFileReceived->File().SetModified(modifiedTime));
       
   817            }
   819            }
   818                                    
   820         User::LeaveIfError(iFramework.Fs().SetModified(iFullPath, modifiedTime));
   819 	     iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   821 
       
   822         iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
   820         
   823         
   821         //The MTP spec states that it is not mandatory for SendObjectInfo/SendObjectPropList
   824         //The MTP spec states that it is not mandatory for SendObjectInfo/SendObjectPropList
   822         //to be followed by a SendObject.  An object is reserved in the ObjectStore on 
   825         //to be followed by a SendObject.  An object is reserved in the ObjectStore on 
   823         //receiving a SendObjectInfo/SendObjectPropList request, but we only commit it 
   826         //receiving a SendObjectInfo/SendObjectPropList request, but we only commit it 
   824         //on receiving the corresponding SendObject request.  With Associations however 
   827         //on receiving the corresponding SendObject request.  With Associations however 
   825         //we commit the object straight away as the SendObject phase is often absent 
   828         //we commit the object straight away as the SendObject phase is often absent 
   826         //with folder creation.
   829         //with folder creation.
   827 		
   830 		
   828         CleanUndoList();
   831         CleanUndoList();
   829         SendResponseL(EMTPRespCodeOK);
   832         SendResponseL(EMTPRespCodeOK);
   830 	    }        
   833 	    }
   831     
   834     
   832     delete iFileReceived;
       
   833     iFileReceived = NULL;  
       
   834     
   835     
   835     iSuccessful = result;
   836     iSuccessful = result;
   836     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL - Exit"));
   837     __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL - Exit"));
   837     return result;
   838     return result;
   838     }
   839     }