Пример #1
0
// -----------------------------------------------------------------------------
// CMoveObject::MoveFileL
// A helper function of MoveObjectL
// -----------------------------------------------------------------------------
//
void CMoveObject::MoveFileL( const TDesC& aNewFileName )
    {
    HBufC* oldFileName = iObjectInfo->DesC( CMTPObjectMetaData::ESuid ).AllocLC(); // + oldFileName
    PRINT2( _L( "MM MTP => CMoveObject::MoveFileL old name = %S, aNewFileName = %S" ),
        oldFileName,
        &aNewFileName );

    if ( iStorageId == iObjectInfo->Uint( CMTPObjectMetaData::EStorageId ) )
        iSameStorage = ETrue;
    else
        iSameStorage = EFalse;

    // Move the file first no matter if it will fail in Get/SetPreviousPropertiesL
    // Already trapped inside
    GetPreviousPropertiesL( *iObjectInfo );
    TRAP_IGNORE( SetPropertiesL( aNewFileName ) );

    CFileMan* fileMan = CFileMan::NewL( iFramework.Fs() );
    CleanupStack::PushL( fileMan ); // + fileMan
    TInt err = fileMan->Move( *oldFileName, aNewFileName );
    PRINT1( _L( "MM MTP <> CMoveObject::MoveFileL err = %d" ), err );
    User::LeaveIfError( err );
    CleanupStack::PopAndDestroy( fileMan ); // - fileMan
    CleanupStack::PopAndDestroy( oldFileName );     // - oldFileName

    PRINT( _L( "MM MTP <= CMoveObject::MoveFileL" ) );
    }
Пример #2
0
/**
A helper function of MoveObjectL.
@param aNewFolderName the new file folder name after the folder is moved.
*/
void CMTPMoveObject::MoveFolderL()
{
    OstTraceFunctionEntry0( CMTPMOVEOBJECT_MOVEFOLDERL_ENTRY );

    RBuf oldFolderName;
    oldFolderName.CreateL(KMaxFileName);
    oldFolderName.CleanupClosePushL();
    oldFolderName = iObjectInfo->DesC(CMTPObjectMetaData::ESuid);
    iPathToMove = oldFolderName.AllocL();

    if (iObjectInfo->Uint(CMTPObjectMetaData::EDataProviderId) == iFramework.DataProviderId())
    {
        GetPreviousPropertiesL(oldFolderName);
        // Remove backslash.
        oldFolderName.SetLength(oldFolderName.Length() - 1);
        SetPreviousPropertiesL(*iNewRootFolder);
        _LIT(KBackSlash, "\\");
        oldFolderName.Append(KBackSlash);

        iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, *iNewRootFolder);
        iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
        iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
        iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
    }

    CleanupStack::PopAndDestroy(); // oldFolderName.

    OstTraceFunctionExit0( CMTPMOVEOBJECT_MOVEFOLDERL_EXIT );
}
/**
A helper function of CopyObjectL.
@param aNewFileName the new full filename after copy.
@return objectHandle of new copy of object.
*/
TUint32 CMTPImageDpCopyObject::CopyFileL(const TDesC& aOldFileName, const TDesC& aNewFileName)
    {
    OstTraceFunctionEntry0( CMTPIMAGEDPCOPYOBJECT_COPYFILEL_ENTRY );
    TCleanupItem anItem(FailRecover, reinterpret_cast<TAny*>(this));
    CleanupStack::PushL(anItem);
    
    GetPreviousPropertiesL(aOldFileName);
    LEAVEIFERROR(iFileMan->Copy(aOldFileName, *iDest),
            OstTraceExt3( TRACE_ERROR, CMTPIMAGEDPCOPYOBJECT_COPYFILEL, 
                    "Copy %S to %S failed! error code %d", aOldFileName, *iDest, munged_err));
            
    iRollbackActionL.AppendL(RollBackFromFsL);
    SetPreviousPropertiesL(aNewFileName);
    
    iFramework.ObjectMgr().InsertObjectL(*iTargetObjectInfo);
    //check object whether it is a new image object
    if (MTPImageDpUtilits::IsNewPicture(*iTargetObjectInfo))
        {
        //increate new pictures count
        iDataProvider.IncreaseNewPictures(1);
        }    
    
    CleanupStack::Pop(this);
    OstTraceFunctionExit0( CMTPIMAGEDPCOPYOBJECT_COPYFILEL_EXIT );
    return iTargetObjectInfo->Uint(CMTPObjectMetaData::EHandle);
    }
Пример #4
0
/**
A helper function of MoveObjectL.
@param aNewFileName the new file name after the object is moved.
*/
void CMTPMoveObject::MoveFileL(const TDesC& aNewFileName)
{
    OstTraceFunctionEntry0( CMTPMOVEOBJECT_MOVEFILEL_ENTRY );
    const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
    GetPreviousPropertiesL(suid);

    if(iFramework.StorageMgr().DriveNumber(iObjectInfo->Uint(CMTPObjectMetaData::EStorageId)) ==
            iFramework.StorageMgr().DriveNumber(iStorageId))
        //Move file to the same storage
    {
        LEAVEIFERROR(iFileMan->Move(suid, *iDest),
                     OstTraceExt2( TRACE_ERROR, CMTPMOVEOBJECT_MOVEFILEL, "move %S to %S failed!", suid, *iDest ));
        SetPreviousPropertiesL(aNewFileName);
        iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, aNewFileName);
        iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
        iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
        iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
        SendResponseL(EMTPRespCodeOK);
    }
    else
        //Move file between different storages
    {
        delete iNewFileName;
        iNewFileName = NULL;
        iNewFileName = aNewFileName.AllocL(); // Store the new file name

        LEAVEIFERROR(iFileMan->Move(suid, *iDest, CFileMan::EOverWrite, iStatus),
                     OstTraceExt2( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_MOVEFILEL, "move %S to %S failed!", suid, *iDest));
        if ( !IsActive() )
        {
            SetActive();
        }

        delete iTimer;
        iTimer = NULL;
        iTimer = CPeriodic::NewL(EPriorityStandard);
        TTimeIntervalMicroSeconds32 KMoveObjectIntervalNone = 0;
        iTimer->Start(TTimeIntervalMicroSeconds32(KMoveObjectTimeOut), KMoveObjectIntervalNone, TCallBack(CMTPMoveObject::OnTimeoutL, this));
    }
    OstTraceFunctionExit0( CMTPMOVEOBJECT_MOVEFILEL_EXIT );
}