diff -r 798ee5f1972c -r 826cea16efd9 videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/VCXTestCommon.cpp --- a/videoutils_plat/videoconnutility_api/tsrc/VCXTestCommon/src/VCXTestCommon.cpp Thu Aug 19 10:54:18 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1335 +0,0 @@ -/* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of the License "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include -#include -#include -#include -#include - -#include "VCXTestCommon.h" -#include "IptvTestUtilALR.h" -#include "CIptvTestVerifyData.h" -#include "TestUtilConnectionWaiter.h" -#include "VCXTestLog.h" - -// EXTERNAL DATA STRUCTURES - -// EXTERNAL FUNCTION PROTOTYPES - -// CONSTANTS - -// MACROS - -// LOCAL CONSTANTS AND MACROS -_LIT(KDummyfilePathFormat, "%S:\\data\\temp"); -_LIT(KDummyfileFormat, "%d.dat"); -_LIT(KDoubleBacklash, "\\"); - -// MODULE DATA STRUCTURES - -// LOCAL FUNCTION PROTOTYPES - -// FORWARD DECLARATIONS - -// ============================= LOCAL FUNCTIONS =============================== - -// ============================ MEMBER FUNCTIONS =============================== - -// ----------------------------------------------------------------------------- -// CVCXTestCommon::CVCXTestCommon -// C++ default constructor can NOT contain any code, that -// might leave. -// ----------------------------------------------------------------------------- -// -CVCXTestCommon::CVCXTestCommon() - { - } - -// ----------------------------------------------------------------------------- -// CVCXTestCommon::ConstructL -// Symbian 2nd phase constructor can leave. -// ----------------------------------------------------------------------------- -// -void CVCXTestCommon::ConstructL() - { - VCXLOGLO1(">>>CVCXTestCommon::ConstructL"); - - User::LeaveIfError( iFs.Connect() ); - - PrintIaps(); - - PrintDriveInfo( _L("C") ); - PrintDriveInfo( _L("E") ); - PrintDriveInfo( _L("D") ); - PrintDriveInfo( _L("F") ); - - //ListDir( _L("C:\\"), 0 ); - //ListDir( _L("E:\\"), 0 ); - - iIptvVerifyData = CIptvTestVerifyData::NewL(); - iVideoCreator = CIptvTestVideoCreator::NewL(); - - VCXLOGLO1("<<>>CVCXTestCommon::~CVCXTestCommon"); - - delete iIptvVerifyData; - iIptvVerifyData = NULL; - - delete iVideoCreator; - iVideoCreator = NULL; - - iFs.Close(); - - VCXLOGLO1("<<>>CVCXTestCommon::NewL"); - CVCXTestCommon* self = new( ELeave ) CVCXTestCommon; - - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop(); - VCXLOGLO1("<<>>CVCXTestCommon::GetFileSize"); - TBool rv = FALSE; - TEntry entry; - TInt err = KErrNone; - - aFileSize=0; - - err = iFs.Entry( aFullPath, entry ); - - if(KErrNone == err && !entry.IsDir()) - { - aFileSize = entry.iSize; - rv = TRUE; - } - - VCXLOGLO1("<<>>CVCXTestCommon::GetIapIdL"); - - TBool found( EFalse ); - -#ifdef __WINSCW__ - if( aIapName != KIptvTestBadIapName && aIapName != _L("invalidiap") ) - { - _LIT(KEmulatorIap, "Ethernet with Daemon Dynamic IP"); - found = GetIapIdByNameL(KEmulatorIap, aIapId); - VCXLOGLO1("<<GetDefaultIapCenRep(); - CleanupStack::PopAndDestroy( util ); - if( aIapId != 0 ) - { - VCXLOGLO2("CVCXTestCommon::GetIapIdL -- Got default from cenrep: %d", aIapId); - return ETrue; - } - } - - if( aIapName == _L("default") ) - { - VCXLOGLO1("CVCXTestCommon::GetIapIdL -- Getting default iap via ALR util"); - CIptvTestUtilALR* util = CIptvTestUtilALR::NewLC(); - aIapId = util->GetDefaultIap(); - CleanupStack::PopAndDestroy( util ); - if( aIapId != 0 ) - { - VCXLOGLO2("CVCXTestCommon::GetIapIdL -- Got default: %d", aIapId); - return ETrue; - } - } - - VCXLOGLO2("CVCXTestCommon:: Searching IAP: %S", &aIapName); - - found = GetIapIdByNameL(aIapName, aIapId); - - // Iap with exact name found - if( found ) - { - VCXLOGLO1("<< searchFor(aIapName); - searchFor.LowerCase(); - - if(searchFor == _L("invalidiap") ) - { - aIapId = 6000; - VCXLOGLO1("<<>>CVCXTestCommon::GetIapIdByNameL"); - TBool found = EFalse; - aIapId = 0; - - TBuf<128> searchFor(aIapName); - searchFor.LowerCase(); - - // Get IAP names and ids from the database - CCommsDatabase* cdb( NULL ); - TRAPD( err, cdb = CCommsDatabase::NewL( EDatabaseTypeIAP ) ); - if( err != KErrNone ) - { - VCXLOGLO2("CVCXTestCommon::GetIapIdByNameL: CCommsDatabase::NewL left: %d, leaving", err); - User::Leave( err ); - } - CleanupStack::PushL( cdb ); - - cdb->ShowHiddenRecords(); - - CCommsDbTableView* view( NULL ); - TRAP( err, view = cdb->OpenTableLC( TPtrC(IAP) ); CleanupStack::Pop( view ); ); - CleanupStack::PushL( view ); - - if( err != KErrNone ) - { - VCXLOGLO2("CVCXTestCommon::GetIapIdByNameL: CCommsDatabase::OpenTableLC left: %d, leaving", err); - User::Leave( err ); - } - - TBuf<40> name; - TUint32 id; - TInt res = view->GotoFirstRecord(); - while( res == KErrNone ) - { - TRAP( err, view->ReadTextL( TPtrC(COMMDB_NAME), name ) ); - if( err != KErrNone ) continue; - TRAP( err, view->ReadUintL( TPtrC(COMMDB_ID), id ) ); - if( err != KErrNone ) continue; - - name.LowerCase(); - if(searchFor == name) - { - aIapId = id; - VCXLOGLO3("CVCXTestCommon:: Found IAP: %d, %S", aIapId, &aIapName); - found = ETrue; - break; - } - res = view->GotoNextRecord(); - } - - CleanupStack::PopAndDestroy( view ); - CleanupStack::PopAndDestroy( cdb ); - - VCXLOGLO1("<<>>CVCXTestCommon::GetIapIdByTypeL"); - - aIapId = 0; - TBool found( EFalse ); - - #ifdef __WINSCW__ - found = GetIapIdByNameL( _L("Ethernet with Daemon Dynamic IP"), aIapId ); - VCXLOGLO1("<<ShowHiddenRecords(); - - CCommsDbTableView* view = TheDb->OpenTableLC( TPtrC(IAP) ); - - TBuf<40> name; - TUint32 id; - TBuf<255> iapType; - TInt matchCount(0); - - TInt res = view->GotoFirstRecord(); - - while( res == KErrNone ) - { - view->ReadTextL( TPtrC(COMMDB_NAME), name ); - view->ReadUintL( TPtrC(COMMDB_ID), id ); - view->ReadTextL( TPtrC(IAP_SERVICE_TYPE), iapType); - - VCXLOGLO3("CVCXTestCommon:: name: %S, id: %d", &name, id); - VCXLOGLO2("CVCXTestCommon:: type: %S", &iapType); - - if( ( iapType == _L("LANService") && aType == EWlanIap && name != _L("Easy WLAN") ) || - ( iapType == _L("OutgoingGPRS") && aType == EGprsIap ) ) - { - if( matchCount == aOrderNumber ) - { - found = ETrue; - aIapId = id; - break; - } - matchCount++; - } - - res = view->GotoNextRecord(); - } - - CleanupStack::PopAndDestroy( view ); // view - CleanupStack::PopAndDestroy( TheDb ); // TheDb - - VCXLOGLO1("<<ShowHiddenRecords(); - - CCommsDbTableView* view = TheDb->OpenTableLC( TPtrC(IAP) ); - - TBuf<40> name; - TUint32 id; - TInt res = view->GotoFirstRecord(); - - while( res == KErrNone ) - { - view->ReadTextL( TPtrC(COMMDB_NAME), name ); - view->ReadUintL( TPtrC(COMMDB_ID), id ); - - res = view->GotoNextRecord(); - //VCXLOGLO3("IAP name, id: %S, %d", &name, id); - if(id == aIapId) - { - found = TRUE; - aIapName.Zero(); - aIapName.Append(name); - break; - } - } - - CleanupStack::PopAndDestroy( view ); // view - CleanupStack::PopAndDestroy( TheDb ); // TheDb - - return found; - } - -// ----------------------------------------------------------------------------- -// CVCXTestCommon::PrintIaps -// ----------------------------------------------------------------------------- -// -EXPORT_C void CVCXTestCommon::PrintIaps() - { - VCXLOGLO1(">>>CVCXTestCommon::PrintIaps"); - // Get IAP names and ids from the database - CCommsDatabase* TheDb( NULL ); - TRAPD( err, TheDb = CCommsDatabase::NewL( EDatabaseTypeIAP ) ); - - if( err == KErrNone && TheDb ) - { - CleanupStack::PushL( TheDb ); - - TheDb->ShowHiddenRecords(); - - CCommsDbTableView* view( NULL ); - TRAP( err, view = TheDb->OpenTableLC( TPtrC(IAP) ); CleanupStack::Pop( view ); ); - CleanupStack::PushL( view ); - - if( err == KErrNone && view ) - { - TBuf<40> name; - TUint32 id; - err = view->GotoFirstRecord(); - while( err == KErrNone ) - { - TRAP( err, view->ReadTextL( TPtrC(COMMDB_NAME), name ) ); - if( err != KErrNone ) break; - TRAP( err, view->ReadUintL( TPtrC(COMMDB_ID), id ) ); - if( err != KErrNone ) break; - VCXLOGLO3("CVCXTestCommon:: IAP name, id: %S, %d", &name, id); - - err = view->GotoNextRecord(); - if( err != KErrNone ) break; - } - } - CleanupStack::PopAndDestroy( view ); // view - CleanupStack::PopAndDestroy( TheDb ); // TheDb - } - VCXLOGLO1("<<>>CVCXTestCommon::CreateVerifyData: %S", &aVerifyId); - TInt result = KErrNone; - TRAPD(err, result = iIptvVerifyData->CreateVerifyDataL(aVerifyId, aAppend)); - if(err != KErrNone) - { - VCXLOGLO2("CIptvVerifyData::CreateVerifyDataL caused a leave. %d", err); - result = err; - } - VCXLOGLO1("<<>>CVCXTestCommon::WriteVerifyData"); - TInt result = KErrNone; - TRAPD(err, result = iIptvVerifyData->WriteVerifyDataL(aVerifyId, aVerifyData)); - if(err != KErrNone) - { - VCXLOGLO2("CIptvVerifyData::WriteVerifyDataL caused a leave. %d", err); - result = err; - } - //VCXLOGLO1("<< aFmt, ... ) - { - //VCXLOGLO1(">>>CVCXTestCommon::WriteVerifyData(formatted)"); - - VA_LIST argptr; //pointer to argument list - VA_START( argptr, aFmt ); - - HBufC* str; - str = HBufC::NewLC(1024*3); - - //TBuf<512*3> str; - //TBuf<512> format(_L("TESTI: %d, %S")); - - str->Des().FormatList(aFmt, argptr); - - TInt result = KErrNone; - TRAPD(err, result = iIptvVerifyData->WriteVerifyDataL(aVerifyId, *str)); - - CleanupStack::PopAndDestroy(str); - - if(err != KErrNone) - { - VCXLOGLO2("CIptvVerifyData::WriteVerifyDataL caused a leave. %d", err); - result = err; - } - - //VCXLOGLO1("<<>>CVCXTestCommon::VerifyData"); - TInt result = KErrNone; - TRAPD(err, result = iIptvVerifyData->VerifyDataL(aVerifyId, aVerifyResult)); - if(err != KErrNone) - { - VCXLOGLO2("CIptvVerifyData::VerifyDataL caused a leave. %d", err); - result = err; - } - VCXLOGLO1("<<>>CVCXTestCommon::EnableVerifyTimestamps"); - iIptvVerifyData->EnableTimestamps( aUseTimestamps ); - VCXLOGLO1("<<>>CVCXTestCommon::ParseIntFromString"); - - TLex lex(aString); - TInt err = lex.Val(aInt); - - VCXLOGLO1("<<>>CVCXTestCommon::CreateBadIapL"); - CCommsDatabase* cdb = CCommsDatabase::NewL( EDatabaseTypeIAP ); - CleanupStack::PushL( cdb ); - - TBuf16<40> name; - name.Copy( aName ); - - TUint32 iapId( 0 ); - TUint32 iapServiceId( 1 ); - TUint32 id( 2 ); - TUint32 iapNetworkId( 3 ); - TUint32 weighting( 4 ); - TUint32 loc( 5 ); - - User::LeaveIfError( cdb->BeginTransaction() ); - - CCommsDbTableView* iapTable = cdb->OpenTableLC( TPtrC( IAP ) ); - - User::LeaveIfError( iapTable->InsertRecord( iapId ) ); - - iapTable->WriteTextL( TPtrC( COMMDB_NAME ), name ); - iapTable->WriteUintL( TPtrC( IAP_SERVICE ), iapServiceId ); - iapTable->WriteTextL( TPtrC( IAP_SERVICE_TYPE ), TPtrC( LAN_SERVICE ) ); - iapTable->WriteTextL( TPtrC( IAP_BEARER_TYPE ), TPtrC( LAN_BEARER ) ); - iapTable->WriteUintL( TPtrC( IAP_BEARER ), id ); - iapTable->WriteUintL( TPtrC( IAP_NETWORK ), iapNetworkId ); - iapTable->WriteUintL( TPtrC( IAP_NETWORK_WEIGHTING ), weighting ); - iapTable->WriteUintL( TPtrC( IAP_LOCATION ), loc ); - - User::LeaveIfError( iapTable->PutRecordChanges( EFalse, EFalse ) ); - - CleanupStack::PopAndDestroy( iapTable ); - - User::LeaveIfError( cdb->CommitTransaction() ); - - CleanupStack::PopAndDestroy( cdb ); - VCXLOGLO1("<<>>CVCXTestCommon::AdvanceSystemTimeSeconds"); - - TTime now; - now.HomeTime(); - - TTimeIntervalSeconds second(1*aCount); - now += second; - - TInt err = CVCXTestCommon::SetSystemTime(now); - - VCXLOGLO1("<<>>CVCXTestCommon::AdvanceSystemTimeMinutes"); - - TTime now; - now.HomeTime(); - - TTimeIntervalSeconds minute(1*60*aCount); - now += minute; - - TInt err = CVCXTestCommon::SetSystemTime(now); - - VCXLOGLO1("<<>>CVCXTestCommon::AdvanceSystemTimeHours"); - - TTime now; - now.HomeTime(); - - TTimeIntervalSeconds hour(1*60*60*aCount); - now += hour; - - TInt err = CVCXTestCommon::SetSystemTime(now); - - VCXLOGLO1("<<>>CVCXTestCommon::SetSystemTime"); - - TTime noDST(aTime); - RTz tz; - TInt err = tz.Connect(); - if(err != KErrNone) - { - VCXLOGLO2("RTz::Connect failed: %d", err); - VCXLOGLO1("<<>>CVCXTestCommon::SetTimeZone"); - - RTz tz; - TInt err = tz.Connect(); - if(err != KErrNone) - { - VCXLOGLO2("RTz::Connect failed: %d", err); - VCXLOGLO1("<< timezone; - timezone.Copy( aTimeZone ); // Conversion - - CTzId* tzId = CTzId::NewL( timezone ); - CleanupStack::PushL(tzId); - - TRAP(err, tz.SetTimeZoneL( *tzId ) ); - CleanupStack::PopAndDestroy(tzId); - CleanupStack::PopAndDestroy(&tz); - - if(err != KErrNone) - { - VCXLOGLO2("RTz::SetTimeZone failed: %d", err); - VCXLOGLO1("<<>>CVCXTestCommon::CreateVideoFileL"); - iVideoCreator->CreateVideoL( aVideoType, aFileName, aSize ); - VCXLOGLO1("<<& aFileArray ) - { - VCXLOGLO1(">>>CVCXTestCommon::CreateVideoFilesL"); - iVideoCreator->CreateVideosL( aVideoType, aFileName, aCount, aFileArray ); - VCXLOGLO1("<<>>CVCXTestCommon::SetDriveFreeSpaceL"); - - const TInt KIptvTest1KB = 1024; - const TInt KIptvTest1MB = KIptvTest1KB*KIptvTest1KB; - -#ifdef __WINSCW__ - if(aDriveNumber == EDriveC) - { - VCXLOGLO1("CVCXTestCommon:: ABORT! No C drive fill in emulator."); - User::Leave( KErrAbort ); - } -#endif - - TChar driveLetter; - User::LeaveIfError( RFs::DriveToChar( aDriveNumber, driveLetter ) ); - - TBuf<255> path; - path.Append( driveLetter ); - path.Append( _L(":\\data\\temp") ); - path.Append( KDoubleBacklash ); - - // First check that if there's free space to fill. - - TInt64 spaceToReserve = 0; - CalculateSpaceToReserveL(iFs, aDriveNumber, aDesiredFreeSpace, spaceToReserve); - - if( spaceToReserve == 0 ) - { - VCXLOGLO1("<<0; i-- ) - { - TBuf<256> filePath; - filePath.Zero(); - filePath.Append( path ); - filePath.AppendFormat( KDummyfileFormat, i ); - if( BaflUtils::FileExists( iFs, filePath ) ) - { - VCXLOGLO2("CVCXTestCommon:: Deleting %S.", &filePath); - iFs.Delete( filePath ); - CalculateSpaceToReserveL(iFs, aDriveNumber, aDesiredFreeSpace, spaceToReserve); - - // Is there's enough free space now. - if( spaceToReserve > 0 ) - { - break; - } - } - } - - // Recheck free space. - if( spaceToReserve < 0 ) - { - VCXLOGLO1("CVCXTestCommon:: Error! There's already less than wanted space!"); - User::Leave( KErrAbort ); - } - } - - BaflUtils::EnsurePathExistsL(iFs, path); - - // Start creating files of 256 MB size. - TInt64 dummyFileSize = 256 * KIptvTest1MB; - - TInt count = 0; - while( ETrue ) - { - // Check that there's still enough free space for the dummyfile - CalculateSpaceToReserveL( iFs, aDriveNumber, aDesiredFreeSpace, spaceToReserve ); - - if( spaceToReserve <= 0 ) - { - VCXLOGLO1("CVCXTestCommon:: Nothing to reserve anymore."); - break; - } - - // Fill all at once if less than 1MB to go. - if( spaceToReserve < KIptvTest1MB ) - { - dummyFileSize = spaceToReserve; - } - - // Not enough space for dummy file, find smaller size. - while( dummyFileSize > spaceToReserve ) - { - dummyFileSize /= 2; - } - - // Find free filename. - TBuf<256> filePath; - do - { - filePath.Zero(); - filePath.Append( path ); - count++; - filePath.AppendFormat(KDummyfileFormat, count); - } - while ( BaflUtils::FileExists( iFs, filePath ) ); - - VCXLOGLO3("Creating %Ld b file to '%S'", dummyFileSize, &filePath); - - // Create the file. - RFile file; - TInt err = file.Replace(iFs, filePath, EFileWrite); - if(err != KErrNone) - { - VCXLOGLO2("file.Replace fail: %d", err); - } - User::LeaveIfError(err); - err = file.SetSize( dummyFileSize ); - if(err != KErrNone) - { - VCXLOGLO2("file.SetSize fail: %d", err); - } - User::LeaveIfError(err); - file.Close(); - - TVolumeInfo volumeInfo; - User::LeaveIfError(iFs.Volume(volumeInfo, aDriveNumber)); - VCXLOGLO2("Free space after: %Ld b", volumeInfo.iFree); - } - - VCXLOGLO1("<<>>CVCXTestCommon::DeleteDummyFilesL"); - - CFileMan* fileMan = CFileMan::NewL(iFs); - CleanupStack::PushL(fileMan); - - TBuf<3> driveLetter; - TChar driveChar; - RFs::DriveToChar( aDriveNumber, driveChar ); - driveLetter.Append(driveChar); - - TBuf<255>path; - - path.Format( KDummyfilePathFormat, &driveLetter ); - path.Append(KDoubleBacklash); - fileMan->RmDir(path); - - CleanupStack::PopAndDestroy(fileMan); - - VCXLOGLO1("<< 0 && iFs.CharToDrive( aDriveLetter[0], driveNumber ) == KErrNone ) - { - TVolumeInfo volumeInfo; - if( iFs.Volume(volumeInfo, driveNumber) == KErrNone ) - { - driveSize = volumeInfo.iSize / 1024 / 1024; - driveFreeSpace = volumeInfo.iFree / 1024 / 1024; - VCXLOGLO2("CVCXTestCommon:: drive: %S", &aDriveLetter ); - VCXLOGLO2("CVCXTestCommon:: - size: %d MB", driveSize); - VCXLOGLO2("CVCXTestCommon:: - free: %d MB", driveFreeSpace); - } - } - } - -// ----------------------------------------------------------------------------- -// CVCXTestCommon::ListDir -// ----------------------------------------------------------------------------- -// -EXPORT_C TInt CVCXTestCommon::ListDir( const TDesC& aDir, TInt aLevel ) - { - CDir* fileList = NULL; - CDir* dirList = NULL; - - if( aLevel == 0 ) - { - VCXLOGLO2("CVCXTestCommon:: Listing directory %S", &aDir); - } - - TInt err( KErrNone ); - err = iFs.GetDir( aDir, KEntryAttMatchExclusive | KEntryAttDir, ESortByName, dirList ); - if( err == KErrNone ) - { - err = iFs.GetDir( aDir, KEntryAttMatchExclude | KEntryAttDir, ESortByName, fileList ); - } - - CleanupStack::PushL( dirList ); - CleanupStack::PushL( fileList ); - - HBufC* pre = HBufC::NewL( 256 ); - CleanupStack::PushL( pre ); - - for( TInt i=0; iDes().Append( _L(" ") ); - } - - if( err == KErrNone ) - { - HBufC* fileName = HBufC::NewL( 256 ); - CleanupStack::PushL( fileName ); - - if( dirList ) - for ( TInt file = 0; file < dirList->Count(); file++ ) - { - fileName->Des().Zero(); - fileName->Des().Append( aDir ); - fileName->Des().Append( (*dirList)[file].iName ); - VCXLOGLO3("%S (d) %S", pre, fileName); - fileName->Des().Append( _L("\\") ); - fileName->Des().LowerCase(); -#if 0 - ListDir( *fileName, aLevel+1 ); -#else - if( fileName->Des().Find( _L(":\\private\\") ) < 0 && - fileName->Des().Find( _L(":\\resource\\") ) < 0 && - fileName->Des().Find( _L(":\\sys\\") ) < 0 && - fileName->Des().Find( _L(":\\testframework\\") ) < 0 && - fileName->Des().Find( _L(":\\nokia\\") ) < 0 && - fileName->Des().Find( _L(":\\system\\") ) < 0 ) - { - ListDir( fileName->Des(), aLevel+1 ); - } -#endif - } - - TUint32 totalSize(0); - if( fileList ) - for ( TInt file = 0; file < fileList->Count(); file++ ) - { - fileName->Des().Zero(); - fileName->Des().Append( aDir ); - fileName->Des().Append( (*fileList)[file].iName ); - - RFile rf; - if( rf.Open( iFs, *fileName, EFileRead|EFileShareAny ) == KErrNone ) - { - TInt size(0); - if( rf.Size( size ) == KErrNone ) - { - totalSize += size; - VCXLOGLO4("%S (f) %S - %d KB", pre, fileName, size/1024 ); - } - rf.Close(); - } - else - { - VCXLOGLO3("%S (f) %S", pre, fileName); - } - - } - VCXLOGLO3("%S Total size: %d KB", pre, totalSize/1024 ); - CleanupStack::PopAndDestroy( fileName ); - } - - CleanupStack::PopAndDestroy( pre ); - CleanupStack::PopAndDestroy( fileList ); - CleanupStack::PopAndDestroy( dirList ); - - if( aLevel == 0 ) - { - VCXLOGLO1("CVCXTestCommon:: Directory listed."); - } - - return err; - } - -// ----------------------------------------------------------------------------- -// CVCXTestCommon::GetPSProperty -// ----------------------------------------------------------------------------- -// -EXPORT_C TInt CVCXTestCommon::GetPSProperty( const TUid aCategory, const TUint aKey, TInt& aValue ) - { - VCXLOGLO2("CVCXTestCommon:: RProperty::Get key %d.", aKey); - TInt err = RProperty::Get( aCategory, aKey, aValue ); - if( err != KErrNone ) - { - VCXLOGLO2("CVCXTestCommon:: RProperty::Get int returned error: %d.", err); - } - return err; - } - - -// ----------------------------------------------------------------------------- -// CVCXTestCommon::SetPSProperty -// ----------------------------------------------------------------------------- -// -EXPORT_C TInt CVCXTestCommon::SetPSProperty( const TUid aCategory, const TUint aKey, const TInt aValue ) - { - VCXLOGLO2("CVCXTestCommon:: RProperty::Set key %d.", aKey); - TInt err = RProperty::Set( aCategory, aKey, aValue ); - if( err != KErrNone ) - { - VCXLOGLO2("CVCXTestCommon:: RProperty::Set int returned error: %d.", err); - } - return err; - } - -// ----------------------------------------------------------------------------- -// CVCXTestCommon::GetPSProperty -// ----------------------------------------------------------------------------- -// -EXPORT_C TInt CVCXTestCommon::GetPSProperty( const TUid aCategory, const TUint aKey, TDes& aValue ) - { - VCXLOGLO2("CVCXTestCommon:: RProperty::Get key %d.", aKey); - TInt err = RProperty::Get( aCategory, aKey, aValue ); - if( err != KErrNone ) - { - VCXLOGLO2("CVCXTestCommon:: RProperty::Get desc returned error: %d.", err); - } - return err; - } - - -// ----------------------------------------------------------------------------- -// CVCXTestCommon::SetPSProperty -// ----------------------------------------------------------------------------- -// -EXPORT_C TInt CVCXTestCommon::SetPSProperty( const TUid aCategory, const TUint aKey, const TDesC& aValue ) - { - VCXLOGLO2("CVCXTestCommon:: RProperty::Set key %d.", aKey); - TInt err = RProperty::Set( aCategory, aKey, aValue ); - if( err != KErrNone ) - { - VCXLOGLO2("CVCXTestCommon:: RProperty::Set desc returned error: %d.", err); - } - return err; - } - -// ----------------------------------------------------------------------------- -// CVCXTestCommon::ListFilesProcessesAndThreadsL -// ----------------------------------------------------------------------------- -// -EXPORT_C void CVCXTestCommon::ListFilesProcessesAndThreadsL( RFs& aFs ) - { - RArray fileThreadIds; - CleanupClosePushL( fileThreadIds ); - - RPointerArray fileNames; - CleanupResetAndDestroyPushL( fileNames ); - - // Get list of open files. - CFileList* fileList = 0; - TOpenFileScan fileScan( aFs ); - fileScan.NextL( fileList ); - - CleanupStack::PushL( fileList ); - - while( fileList ) - { - for (TInt i = 0; i < fileList->Count(); ++i) - { - fileNames.Append( (*fileList)[i].iName.AllocL() ); - fileThreadIds.Append( fileScan.ThreadId() ); - //VCXLOGLO4("File: %S Size: %d Thread Id: %d", &(*fileList)[i].iName, (*fileList)[i].iSize, fileScan.ThreadId() ); - } - CleanupStack::PopAndDestroy( fileList ); - fileScan.NextL( fileList ); - CleanupStack::PushL( fileList ); - } - - CleanupStack::PopAndDestroy( fileList ); - - // Get list of processes and their threads. - TFindProcess findProcess; - TFullName processName; - - TInt err( KErrNone ); - - // List processes. - while( findProcess.Next( processName ) == KErrNone ) - { - RProcess process; - err = process.Open( processName ); - if( err != KErrNone ) - { - continue; - } - CleanupClosePushL( process ); - - TProcessId pid; - pid = process.Id(); - TInt id = pid.Id(); - VCXLOGLO4("Process: %S, ID: %d (%x)", &processName, id, pid.Id() ); - - TFindThread findThread; - TFullName threadName; - - // List threads that belong to current process. - while( findThread.Next( threadName ) == KErrNone ) - { - RThread thread; - err = thread.Open( threadName ); - if( err == KErrNone ) - { - CleanupClosePushL( thread ); - RProcess threadProcess; - err = thread.Process( threadProcess ) ; - if( err == KErrNone ) - { - CleanupClosePushL( threadProcess ); - if( threadProcess.Id() == process.Id() ) - { - TThreadId tid; - tid = thread.Id(); - id = tid.Id(); - VCXLOGLO4(" - Thread: %S, ID: %d (%x)", &threadName, id, tid.Id() ); - - // And list open files for the thread. - for( TInt i = 0; i < fileThreadIds.Count(); i++ ) - { - if( fileThreadIds[i] == tid.Id() ) - { - VCXLOGLO2(" - %S", fileNames[i] ); - } - } - } - CleanupStack::PopAndDestroy( &threadProcess ); - } - CleanupStack::PopAndDestroy( &thread ); - } - } - - VCXLOGLO1("---"); - CleanupStack::PopAndDestroy( &process ); - } - - CleanupStack::PopAndDestroy( &fileNames ); - CleanupStack::PopAndDestroy( &fileThreadIds ); - } - -// End of File