Example #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" ) );
    }
// ---------------------------------------------------------
// CPosTp666::SetupTestPartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosTp666::SetupTestPartL(TInt aIndex)
    {
    iLog->Put(_L("StartL(TInt aIndex)"));
/* 
#ifdef __WINS__
	_LIT(KNotOnWins, "!!!!This test is NOT supported on WINS!!!!");
	LogErrorAndLeave(KNotOnWins);		
	
#endif
*/
TBuf<20> capability;
switch (aIndex)
{
    case 0:
    iLog->Put(_L("Part1"));
    capability.Zero();
    // Set to all cap but readuserdata and writeuserdata
    capability.Append(_L("27FFF"));
    break;
    
    case 1:
    iLog->Put(_L("Part2"));
    // Set to Set to all cap but writeuserdata
    capability.Append(_L("2FFFF"));
    break;
    
    case 2:
    iLog->Put(_L("Part3"));
    // Set to Set to all cap but readuserdata
    capability.Append(_L("37FFF"));
    break;
    
    case 3:
    iLog->Put(_L("Part4"));
    // Set to only readuserdata and writeuserdata
    capability.Append(_L("18000"));
    break;
    
    default:
    iLog->Put(_L("Default"));
    LogErrorAndLeave(_L("We should never come here"));
    break;
}
    // Only for target, on winscw use bat-script
	RProcess execlient;
	RFile file;
	RFs fileSession;
	User::LeaveIfError(fileSession.Connect());
	CleanupClosePushL(fileSession);
	CleanupClosePushL(file);
	CFileMan* fileMan = CFileMan::NewL(fileSession);
	CleanupStack::PushL(fileMan);	

    TBuf<100> buf;

    buf.Append(_L("CapabilityTests.exe "));
    buf.Append(capability);
    buf.Append(_L(" CapabilityTests_tmp.exe"));

    // Make call to SetCap
	TInt result = execlient.Create(KSetCapPath, 
		//_L("CapabilityTests.exe 3FFFF CapabilityTests_All.exe"),
		buf,
		TUidType(KNullUid, KNullUid, KNullUid));
	User::LeaveIfError(result);
	execlient.Resume();	//make the execlient visible
	User::After(800000); //Wait 0.8 s
	
	execlient.Close(); //Close handle to exe-client
		
	// now move file CapabilityTests_tmp.exe to CapabilityTests.exe
	TInt err = fileMan->Move(_L("c:\\sys\\bin\\CapabilityTests_tmp.exe"), _L("c:\\sys\\bin\\CapabilityTests.exe"), CFileMan::EOverWrite);
	if (err != KErrNone)
	    {
	    iLog->Put(_L("Move problem"));
	    LogErrorAndLeave(_L("Move problem"), err);
	    }

	CleanupStack::PopAndDestroy(fileMan); //fileMan
	CleanupStack::PopAndDestroy(&file); //file
	CleanupStack::PopAndDestroy(&fileSession); //fileSession

    // Prepare test conditions
    SetupTestEnvironmentL();
    
    buf.Zero();
    buf.Format(_L("SetCap done, Now Execute CapabilityTest TP107, part %d"), aIndex+1);
    TUtfwUserAnswer answer = iUserInfo->ShowDialog(buf, EUtfwDialogTypeOk, EFalse);
    //if(answer == EUtfwUserAnswerNo)
	}
TUid CDeploymentComponentData::SetDataL(const TFileName &aData,
        const TDesC8& aMimeType)
    {
    RDEBUG_2("CDeploymentComponentData::SetDataL() TFileName: (%S)", &aData);
    
    _LIT(KNewPath, "c:\\private\\200267FB\\");

    TUid ret(TUid::Null());
    iMimeType = aMimeType.Left(KMaxMimeLength) ;
    RFs fs;
    User::LeaveIfError(fs.Connect() );
    CleanupClosePushL(fs);
    CFileMan *fm = CFileMan::NewL(fs);
    CleanupStack::PushL(fm);
    TFileName fn;
    fn.Copy(iDataFileName);

    RDEBUG("App Mgmt before copy start");

    
    TInt maxLength = iDataFileName.Length();
    TChar charvaldot = '.';
    TChar charvalslash = '\\';
    
    TInt pos = iDataFileName.LocateReverse(charvaldot);
    
    TInt lengthDeleted = maxLength-pos;
    
    iDataFileName.Delete(pos, lengthDeleted);
    
    TInt srcpos = aData.LocateReverse(charvaldot);
    
    TBuf<15> extn(aData.Mid(srcpos));
    
    iDataFileName.Append(extn);
    
    TFileName newfilepath;
    newfilepath.Copy(iDataFileName);
    
    User::LeaveIfError(fm->Move(aData,KNewPath()));
    
    TFileName oldfilepath(KNewPath());
    oldfilepath.Append(aData.Mid(aData.LocateReverse(charvalslash)));
    
    User::LeaveIfError(fm->Rename(oldfilepath, newfilepath));
   
    
    //User::LeaveIfError(fm->Copy(aData, fn) );

    RDEBUG("App Mgmt before copy End");


    if (IsSISInstallFile(aMimeType) )
        {
        ret = ResolveUidL(fs);
        }

    CleanupStack::PopAndDestroy(fm);
    CleanupStack::PopAndDestroy( &fs);
    RDEBUG_2("CDeploymentComponentData::SetDataL() (%d)", ret.iUid);

    return ret;
    }