mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpsendobjectinfo.cpp
branchRCL_3
changeset 14 60a94a45d437
parent 11 4843bb5893b6
child 29 3ae5cb0b4c02
equal deleted inserted replaced
12:8b094906a049 14:60a94a45d437
    68 Destructor
    68 Destructor
    69 */    
    69 */    
    70 CMTPPictBridgeDpSendObjectInfo::~CMTPPictBridgeDpSendObjectInfo()
    70 CMTPPictBridgeDpSendObjectInfo::~CMTPPictBridgeDpSendObjectInfo()
    71     {
    71     {
    72     __FLOG_VA((_L8(">> CMTPPictBridgeDpSendObjectInfo::~CMTPPictBridgeDpSendObjectInfo iProgress=%d iNoRollback=%d "), iProgress, iNoRollback));
    72     __FLOG_VA((_L8(">> CMTPPictBridgeDpSendObjectInfo::~CMTPPictBridgeDpSendObjectInfo iProgress=%d iNoRollback=%d "), iProgress, iNoRollback));
    73 
    73     __FLOG_2(_L8("iProgress:%d NoRollback:%d"),iProgress,iNoRollback);
       
    74     
    74     if ((iProgress == EObjectInfoSucceed || 
    75     if ((iProgress == EObjectInfoSucceed || 
    75         iProgress == EObjectInfoFail || 
    76         iProgress == EObjectInfoFail || 
    76         iProgress == EObjectInfoInProgress) && !iNoRollback)
    77         iProgress == EObjectInfoInProgress) && !iNoRollback)
    77         {
    78         {
    78         // Not finished SendObjectInfo/PropList SendObject pair detected.
    79         // Not finished SendObjectInfo/PropList SendObject pair detected.
   144         TUint32 objectSizeLow = Request().Uint32(TMTPTypeRequest::ERequestParameter5);
   145         TUint32 objectSizeLow = Request().Uint32(TMTPTypeRequest::ERequestParameter5);
   145         iObjectSize = MAKE_TUINT64(objectSizeHigh, objectSizeLow);
   146         iObjectSize = MAKE_TUINT64(objectSizeHigh, objectSizeLow);
   146         if (IsTooLarge(iObjectSize))
   147         if (IsTooLarge(iObjectSize))
   147             {
   148             {
   148              result = EMTPRespCodeObjectTooLarge;            
   149              result = EMTPRespCodeObjectTooLarge;            
   149             }
   150             }       
   150         if(result && !CanStoreFileL(iStorageId, iObjectSize))
       
   151            {
       
   152            result = EMTPRespCodeStoreFull;            
       
   153            }        
       
   154         }
   151         }
   155     // If the previous request is not SendObjectInfo, SendObject fails
   152     // If the previous request is not SendObjectInfo, SendObject fails
   156     if (result == EMTPRespCodeOK && iOperationCode == EMTPOpCodeSendObject)
   153     if (result == EMTPRespCodeOK && iOperationCode == EMTPOpCodeSendObject)
   157         {
   154         {
   158         if (iPreviousTransactionID + 1 != Request().Uint32(TMTPTypeRequest::ERequestTransactionID))
   155         if (iPreviousTransactionID + 1 != Request().Uint32(TMTPTypeRequest::ERequestTransactionID))
   293             }
   290             }
   294         iProgress = EObjectInfoSucceed;
   291         iProgress = EObjectInfoSucceed;
   295         result = EFalse;
   292         result = EFalse;
   296         }
   293         }
   297     
   294     
   298     __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::DoHandleCompletingPhaseL"));    
   295     __FLOG_2(_L8("<< CMTPPictBridgeDpSendObjectInfo::DoHandleCompletingPhaseL result:%d progress %d"),result,iProgress);    
   299     return result;    
   296     return result;    
   300     }
   297     }
   301 
   298 
   302 /**
   299 /**
   303 Verify if the SendObject request comes after SendObjectInfo request
   300 Verify if the SendObject request comes after SendObjectInfo request
   473         {
   470         {
   474         iObjectSize = iObjectInfoP->Uint32L(CMTPTypeObjectInfo::EObjectCompressedSize);
   471         iObjectSize = iObjectInfoP->Uint32L(CMTPTypeObjectInfo::EObjectCompressedSize);
   475         if (IsTooLarge(iObjectSize))
   472         if (IsTooLarge(iObjectSize))
   476             {
   473             {
   477             SendResponseL(EMTPRespCodeObjectTooLarge);
   474             SendResponseL(EMTPRespCodeObjectTooLarge);
   478             result = EFalse;            
       
   479             }
       
   480         if(result && !CanStoreFileL(iStorageId, iObjectSize))
       
   481             {
       
   482             SendResponseL(EMTPRespCodeStoreFull);
       
   483             result = EFalse;            
   475             result = EFalse;            
   484             }
   476             }
   485         }
   477         }
   486 
   478 
   487     if (result)
   479     if (result)
   526         iPictBridgeDP.PtpServer()->Printer()->DpsDiscovery(iFullPath, &iConnection);
   518         iPictBridgeDP.PtpServer()->Printer()->DpsDiscovery(iFullPath, &iConnection);
   527         TRAPD(err, CreateFsObjectL()); 
   519         TRAPD(err, CreateFsObjectL()); 
   528         
   520         
   529         if (err != KErrNone)
   521         if (err != KErrNone)
   530             {
   522             {
       
   523             __FLOG_1(_L8("Fail to create fs object %d"),err);
   531             SendResponseL(ErrorToMTPError(err));
   524             SendResponseL(ErrorToMTPError(err));
       
   525             result = EFalse;
   532             }
   526             }
   533         else
   527         else
   534             {
   528             {
   535             ReserveObjectL();
   529             ReserveObjectL();
   536             }
   530             }
   572         iReceivedObjectP->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32( TMTPTypeRequest::ERequestParameter3 ));
   566         iReceivedObjectP->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32( TMTPTypeRequest::ERequestParameter3 ));
   573         iPictBridgeDP.PtpServer()->Printer()->DpsDiscovery(iFullPath, &iConnection);
   567         iPictBridgeDP.PtpServer()->Printer()->DpsDiscovery(iFullPath, &iConnection);
   574         TRAPD(err, CreateFsObjectL());
   568         TRAPD(err, CreateFsObjectL());
   575         if ( err != KErrNone )
   569         if ( err != KErrNone )
   576             {
   570             {
       
   571             __FLOG_1(_L8("Fail to create fs object %d"),err);
   577             SendResponseL(ErrorToMTPError(err));
   572             SendResponseL(ErrorToMTPError(err));
       
   573             result = EFalse;
   578             }
   574             }
   579         else
   575         else
   580             {
   576             {
   581             ReserveObjectL();
   577             ReserveObjectL();
   582             }
   578             }
   693     __FLOG_VA((_L16("<< CMTPPictBridgeDpSendObjectInfo::GetFullPathNameL full path %S"), &iFullPath));
   689     __FLOG_VA((_L16("<< CMTPPictBridgeDpSendObjectInfo::GetFullPathNameL full path %S"), &iFullPath));
   694     return result;
   690     return result;
   695     }
   691     }
   696 
   692 
   697 /**
   693 /**
   698 Check if we can store the file on the storage
       
   699 @return ETrue if yes, otherwise EFalse
       
   700 */
       
   701 TBool CMTPPictBridgeDpSendObjectInfo::CanStoreFileL(TUint32 aStorageId, TInt64 aObjectSize) const
       
   702     {
       
   703     TBool result(ETrue);
       
   704     if (aStorageId == KMTPStorageDefault)
       
   705         {
       
   706         aStorageId = iFramework.StorageMgr().DefaultStorageId();
       
   707         }
       
   708     TInt drive(iFramework.StorageMgr().DriveNumber(aStorageId));
       
   709     User::LeaveIfError(drive);
       
   710     TVolumeInfo volumeInfo;
       
   711     User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
       
   712     if (volumeInfo.iFree < aObjectSize)
       
   713         {        
       
   714         result = EFalse;
       
   715         }
       
   716     return result;        
       
   717     }
       
   718 
       
   719 /**
       
   720 Check if the object is too large
   694 Check if the object is too large
   721 @return ETrue if yes, otherwise EFalse
   695 @return ETrue if yes, otherwise EFalse
   722 */
   696 */
   723 TBool CMTPPictBridgeDpSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const
   697 TBool CMTPPictBridgeDpSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const
   724     {
   698     {