/**
@SYMTestCaseID SYSLIB-CENREP-CT-0032
@SYMTestCaseDesc BasicPlatsecTestsL() function calls test for the Secure Cenrep (setting).
	Methods of CRepository class are called for various combination of different settings
	and the results are asserted.
@SYMTestPriority High
@SYMTestActions  BasicPlatsecTestsL() method calls test.
@SYMTestExpectedResults The test must not fail.
@SYMPREQ PREQ277
         PREQ280
*/
LOCAL_C void BasicPlatsecTestsL()
	{
	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENREP-CT-0032 Basic functional tests for PlatSec "));
	OomTesting = EFalse;

	// Instead of wait for cache clear, this test uses the ResetAll API to
	// restore keyspaces to original ROM settings. See the notes at implementation
	// of ResetModifiedRepsL which explains why this is done and possible
	// undesirable effects.
	RepsToReset.AppendL(KUidPlatsecTestRepository);
	RepsToReset.AppendL(KUidTransactionTestRepository);
	RepsToReset.AppendL(KUidResetTestRepository);
	::ResetModifiedRepsL();

	FuncBasicTestsL();

	TheTest.Next(_L("Basic Out-of-memory tests"));

	// Instead of wait for cache clear, this test uses the ResetAll API to
	// restore keyspaces to original ROM settings. See the notes at implementation
	// of ResetModifiedRepsL which explains why this is done and possible
	// undesirable effects.
	::ResetModifiedRepsL();

	OomTesting = ETrue;
	TheTest.Next(_L("OOM Open/Close repository"));
	OomTest(OpenRepositoryL);

	GetSetL();

	TheTest.Next(_L("OOM Find"));
	OomTest(FindL);

	TheTest.End();
	}
void UT_CMccRtpDataSource::UT_CMccRtpDataSource_RegisterPayloadTypesLL()
    {
    RArray<TUint> payloads;
    CleanupClosePushL( payloads );
    payloads.AppendL( KPcmuPayloadType );
    payloads.AppendL( KDefaultAmrNbPT );
    iSource->RegisterPayloadTypesL( payloads );
    EUNIT_ASSERT_EQUALS( iSource->iUsers.Count(), 2 );
    
    // Do again, multiple entries are not created
    iSource->RegisterPayloadTypesL( payloads );
    EUNIT_ASSERT_EQUALS( iSource->iUsers.Count(), 2 );

    // Try to unregister not registered payload type
    RArray<TUint> payloads2;
    CleanupClosePushL( payloads2 );
    payloads2.AppendL( KPcmaPayloadType );
    iSource->UnRegisterPayloadTypes( payloads2 );
    EUNIT_ASSERT_EQUALS( iSource->iUsers.Count(), 2 );
    CleanupStack::PopAndDestroy( &payloads2 );
    
    // Unregister registered payload types
    iSource->UnRegisterPayloadTypes( payloads );
    EUNIT_ASSERT_EQUALS( iSource->iUsers.Count(), 0 );
    CleanupStack::PopAndDestroy( &payloads );
    }
void CalFileVersionUtils::FileVersionSupportedL(const TAgnVersion& aFileVersion, CalCommon::TCalFileVersionSupport& aStatus)
	{
	if ( aFileVersion == CurrentFileVersion() ||
			aFileVersion == TAgnVersion(TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildCompatibleVersion)))
		{
		// The the file was created by an agenda model
		// of the current version
		//
		aStatus = CalCommon::EFileIsCurrentVersion;
		}
	else
		{
		RArray<TAgnVersion> supportedFileVersions;
		CleanupClosePushL(supportedFileVersions);
		supportedFileVersions.AppendL(TAgnVersion(TVersion(KMajorVersionNumber, KOldMinorVersionNumber, KOldBuildV94)));
		supportedFileVersions.AppendL(TAgnVersion(TVersion(KMajorVersionNumber, KOldMinorVersionNumber, KOldBuildV92)));
		supportedFileVersions.AppendL(TAgnVersion(TVersion(KMajorVersionNumber, KOldMinorVersionNumber, KOldBuildV91)));
		
		// The file version is not current but if it is in the 
		// list of versions supported by this agenda model it can
		// be converted to current version.
		//
		aStatus = CalCommon::EUnsupportedFileVersion;
		for ( TInt i = 0; i < supportedFileVersions.Count(); ++i )
			{
			if ( supportedFileVersions[i] == aFileVersion )
				{
				aStatus = CalCommon::EFileNeedsConverting;
				break;
				}
			}
		CleanupStack::PopAndDestroy(&supportedFileVersions);
		}
	}
EXPORT_C void T_LbsUtils::GetConfigured_ClientDetailsL(const TDesC& aConfigFileName, const TDesC& aConfigSection, 
						RArray<TCTClientDetails>& aClientDetailsArray)
/** Gets the delays for each client with values read from a configuration ini file.

@param aConfigFileName		The name of the ini file to read. If the file name is empty (0 length) then
							default values will be used.
@param aConfigSection		The section within the ini file to read data from.
@param aClientDelayArray	The array of client delays.
*/
	{
	// Use default values if file name not given.
	if (aConfigFileName.Length() == 0)
		{ // by default have one client
		TCTClientDetails client;
		aClientDetailsArray.AppendL(client);
		return;
		}
	
	else
		{
		CClientDetailsConfigReader* reader;
		reader = CClientDetailsConfigReader::NewL(aConfigFileName, aConfigSection, aClientDetailsArray);
		CleanupStack::PushL(reader);
		
		reader->ProcessL();
	
		CleanupStack::PopAndDestroy(reader);
		if(aClientDetailsArray.Count() == 0)
			{ // by default have one client
			TCTClientDetails client;
			aClientDetailsArray.AppendL(client);
			}
		}
	}
TVerdict CTSmallWindowsTest::doTestStepPreambleL()
	{
	CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
	iScreenSize = CTWindow::GetDisplaySizeInPixels();	
	TBool preload = EFalse;
	GetBoolFromConfig(_L("FlowTests"), _L("Preload"), preload);

	TPtrC fileNameList;
	TEST(GetStringFromConfig(_L("FlowTests"), _L("Files"), fileNameList));
	ExtractListL(fileNameList, iFileNames);

	ComputeSmallWindows();

	TPoint initialPosition(0, 0);
	RArray<TPoint> initialPositions;
    RArray<pTWindowCreatorFunction> windowCreatorFunctions;
    CleanupClosePushL(initialPositions);
    CleanupClosePushL(windowCreatorFunctions);
	for (TInt i = 0; i < iWindowsAcross; i++)
		{
		initialPosition.iY = 0;
		for (TInt j = 0; j < iWindowsAcross; j++)
			{
			windowCreatorFunctions.AppendL(CTSmallWindowRaster::NewL);
			initialPositions.AppendL(initialPosition);
			initialPosition.iY += iWindowSize.iHeight;
			}
		initialPosition.iX += iWindowSize.iWidth;
		}

	iFlowWindowsController = CTFlowWindowsController::NewL(preload, iFileNames, iWindowSize, windowCreatorFunctions, initialPositions, ETrue);
    CleanupStack::PopAndDestroy(2, &initialPositions);
	return TestStepResult();
	}
void UT_CIceValidList::UT_CICEValidList_HasPairForComponentsL()
    {
    RArray<TUint> components;
    CleanupClosePushL( components );
    
    components.AppendL( 5 );
    EUNIT_ASSERT( 
        EFalse == iValidList->HasPairForComponents( components ) );
    
    UT_CICEValidList_AddValidPairLL();
    EUNIT_ASSERT( 
        EFalse == iValidList->HasPairForComponents( components ) );
    components.AppendL( KComponentIdRtp );
    EUNIT_ASSERT( 
        EFalse == iValidList->HasPairForComponents( components ) );
    components.Remove( 0 );
    EUNIT_ASSERT( 
        ETrue == iValidList->HasPairForComponents( components ) );
    
    components.Reset();
    EUNIT_ASSERT_PANIC( 
        iValidList->HasPairForComponents( components ), "USER", 0 );
    
    CleanupStack::PopAndDestroy( &components );
    }
/**
Creates the user added city database table if it doesn't exist
@return KErrNone if succesful, or one of the DBMS Leave codes
@internalTechnology
*/
TInt CTzLocalizationDbAccessor::CreateUserCityTableL()
	{
	//Create the columns for the user aded cities table
	RArray<TDbCol> cityTableCols;
	CleanupClosePushL(cityTableCols);
	cityTableCols.AppendL(TDbCol(KUCTableTzId,			EDbColUint16));
	cityTableCols.AppendL(TDbCol(KUCTableCity,			EDbColText));
	cityTableCols.AppendL(TDbCol(KUCTableGroup,			EDbColUint8));
	cityTableCols.AppendL(TDbCol(KUCTableResourceId,	EDbColUint32));

	// Create the columnset - add the columns
	// Columns MUST be added in the same order they appear in TTzCityColumn
	CDbColSet* userCityColSet = CDbColSet::NewLC();
	TInt numCols = cityTableCols.Count();
	for(TInt i = 0; i < numCols; ++i)
		{
		userCityColSet->AddL(cityTableCols[i]);
		}

	// Create the User City table
	TInt error = iLocalizedTimeZoneDb.CreateTable(KUCTableName,*userCityColSet);
	
	CleanupStack::PopAndDestroy(userCityColSet);
	CleanupStack::PopAndDestroy(); //cityTableCols

	return error;
	}
void CSsmCommandListResourceReaderImpl::CResourcePool::GetCommandListIdsL(RArray<TInt>& aArray) const
	{
	TInt count = iMappings.Count();
	__ASSERT_ALWAYS(count > 0, PanicNow(KPanicCmdResourceReader, ENotInitialized3));
	if (aArray.Count() != 0)
		{
		SSMLOGLEAVE(KErrArgument);
		}
	aArray.ReserveL(count);
#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
	TInt i = 0;
	for(i = 0; i < iMappings.Count() - 1 ; ++i)
		{
		if(iMappings[i].iCommandListId != iMappings[i+1].iCommandListId)
			{
			aArray.AppendL(iMappings[i].iCommandListId);
			}
		}
	//append the last element anyway as it is already compared
	aArray.AppendL(iMappings[i].iCommandListId);
	aArray.Compress();
		
	DEBUGPRINT2(_L("The number of substates in resource files : %d"),iMappings.Count() );
	DEBUGPRINT2(_L("The number of substates after filtering duplicates : %d"),aArray.Count());
#else
	for(TInt i = 0; i < count; ++i)
		{
		aArray.AppendL(iMappings[i].iCommandListId);
		}
#endif
	}
EXPORT_C void PlayerApplicationSettingsResourceInit::DefineAttributesL(MPlayerApplicationSettingsObserver& aSettings,
																CResourceFile& aResourceFile)
	{
	// Read the settings from the resource file
	RResourceReader reader;
	reader.OpenLC(&aResourceFile, KAVRCPResourceId);
	
	// Check the version of this resource file
	TUint16 formatVersion = reader.ReadUint16L();
	if (formatVersion != KAVRCPFormatVersion)
		{
		reader.Close();
		User::Leave(KErrCorrupt);
		}
	
	// Find out how many settings this resource file contains
	TInt settingsCount = reader.ReadUint16L();
	if (settingsCount < 0)
		{
		reader.Close();
		User::Leave(KErrCorrupt);
		}

	// read the settings from aResource
	RArray<TUint> values;
	RArray<TPtrC8> valueTexts;
	CleanupClosePushL(values);
 	CleanupClosePushL(valueTexts);

	// Read each AVRCP attribute setting in turn
	for (int i = 0; i < settingsCount; i++)
		{
		values.Reset();
		valueTexts.Reset();
		
		// Read attribute, description text, initial value and defined values
		TUint attributeID(reader.ReadUint8L());
		TUint initialValue(reader.ReadUint8L());
		TPtrC8 attributeText(reader.ReadTPtrC8L());
		TInt valuesCount(reader.ReadUint16L());

		for (int j = 0; j < valuesCount; j++)
			{
			TUint thisValue = reader.ReadUint8L();
			TPtrC8 thisDescription = reader.ReadTPtrC8L();
			
			values.AppendL(thisValue);
			valueTexts.AppendL(thisDescription);
			}
		
		// Now define this attribute, then continue to next attribute
		aSettings.DefineAttributeL(attributeID, attributeText, values, valueTexts, initialValue);
		}
	// cleaning up values and valueTexts
	 CleanupStack::PopAndDestroy(3); // values, valueTexts, reader
	}
void T_PresenceWatcherListManagement::SetupListenerReqCompleteAllowEventsL(  CXIMPTestContextWrapper* aWrapper, TXIMPTestStatusEventTemplate aEventType )
    {
    RArray< TInt32 > array;
    CleanupClosePushL( array );
    array.AppendL( MXIMPRequestCompleteEvent::KInterfaceId );
    array.AppendL( MXIMPContextStateEvent::KInterfaceId );
    array.AppendL( MPresentityPresenceEvent::KInterfaceId );
    aWrapper->SetupListenerReqCompleteL( aEventType, &array );
    CleanupStack::PopAndDestroy(); // array
    }
void CFeatMgrABNormalPlugin::GenericTimerFiredL(
	    MFeatureInfoPluginCallback& aService,
	    FeatureInfoCommand::TFeatureInfoCmd aCommandId,
	    TUint8 aTransId,
	    TInt aRetVal )
    {
    INFO_LOG2( "FeatMgr Plugin: GenericTimerFiredL (0x%x, 0x%x)", 
                         aCommandId, aTransId );
    TInt err( KErrNone );
    
    switch ( aCommandId )
    {
    case FeatureInfoCommand::ELoadFeatureInfoCmdId:
        {
        // Return some features and KErrNone.
        FeatureInfoCommand::TFeatureInfo featureList;
        TInt err( KErrNone );
        RArray<FeatureInfoCommand::TFeature> list;
        CleanupClosePushL( list );
        FeatureInfoCommand::TFeature feature; 

        // Adding support to feature A
        feature.iFeatureID = KFeatureAUid.iUid;
        feature.iValue = ETrue;
        list.AppendL(feature);
        // Adding support to feature B
        feature.iFeatureID = KFeatureBUid.iUid;
        feature.iValue = ETrue;
        list.AppendL(feature);
        
        featureList.iErrorCode = KErrNone;
        featureList.iList = list;
            
        FeatureInfoCommand::TFeatureInfoRespPckg resPackage(featureList);
        
        TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage));    
        
        CleanupStack::PopAndDestroy( &list );
        break;
        }
        
    default :
        break;
    }
    
    // TEST CASES END
 
    if ( err != KErrNone )
        {
        ERROR_LOG1( "FeatMgr Plugin: Error in ProcessResponseL: %d", err );
        }
    CFeatMgrBasePlugin::GenericTimerFiredL(aService,aCommandId,aTransId,aRetVal);
    	    
    }
TVerdict CTSmallWindowsTestOpenGL::doTestStepPreambleL()
	{
	CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
	
	TSize screenSize = CTWindow::GetDisplaySizeInPixels();
	
	// set window size to create required grid
	iWindowSize.iHeight = screenSize.iHeight / KWindowsDown;
	iWindowSize.iWidth = screenSize.iWidth / KWindowsAcross;	
    // adjust window size to maintain image aspect ratio
    if (iWindowSize.iWidth > iWindowSize.iHeight)
        {
        iWindowSize.iWidth = iWindowSize.iHeight;
        }
    else
        {
        iWindowSize.iHeight = iWindowSize.iWidth;
        }
    
    TPoint initialPosition(0, 0);
    RArray<TPoint> initialPositions;
    RArray<pTWindowCreatorFunction> windowCreatorFunctions;
    CleanupClosePushL(initialPositions);
    CleanupClosePushL(windowCreatorFunctions);
	for (TInt i = 0; i < KWindowsAcross; i++)
		{
		initialPosition.iY = 0;
		for (TInt j = 0; j < KWindowsDown; j++)
			{
			windowCreatorFunctions.AppendL(CTSmallWindowOpenGL::NewL);
			initialPositions.AppendL(initialPosition);
			iFileNames.AppendL(KDummy());
			initialPosition.iY += iWindowSize.iHeight;			
			}
		initialPosition.iX += iWindowSize.iWidth;
		}
	
	iFlowWindowsController = CTFlowWindowsController::NewL(ETrue, iFileNames, iWindowSize, windowCreatorFunctions, initialPositions, ETrue);
    CleanupStack::PopAndDestroy(2, &initialPositions);
    
	// run the test enough frames to see move the grid across the screen
	if (screenSize.iHeight > screenSize.iWidth)
		{
		iIterationsToTest = KNumberOfBounces * (screenSize.iHeight - iWindowSize.iHeight * KWindowsDown);
		}
	else 
		{
		iIterationsToTest = KNumberOfBounces * (screenSize.iWidth - iWindowSize.iWidth * KWindowsAcross);
		}

	return TestStepResult();
	}
/**
 * Removes contacts from the underlying view based on the data available with contact view update objects
 */ 
void CTestContactViewUnderlyingViewUpdateStep::RemoveContactsFromTheUnderLyingViewsL()
	{
	for(TInt i = 0; i < iViewUpdateArray.Count(); ++i)
		{
		TViewModificationData contactViewValidationObject = iViewUpdateArray[i];		
		CContactViewBase* contactView = ViewCollectionReference().GetDesiredView
							(contactViewValidationObject.ViewTypeInStringFormat(), contactViewValidationObject.ViewIndex());
	

		RArray<TContactItemId> contactItemIdArray;
		CleanupClosePushL(contactItemIdArray);
		
		for(TInt j = 0; j < contactViewValidationObject.NumberOfContactsToBeRemoved(); ++j)
			{
			TContactItemId contactItemId = contactView->AtL(j);
			contactItemIdArray.AppendL(contactItemId);
			}

		for(TInt j = 0; j < contactItemIdArray.Count(); ++j)
			{
			DatabaseReference().DeleteContactL(contactItemIdArray[j]);
			}
			
		CleanupStack::PopAndDestroy(&contactItemIdArray); 
		}
	}
// -----------------------------------------------------------------------------
// CAccConfigFileParser::ParseNamesL
// Detect all subblock names and append them to the gicen array.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CAccConfigFileParser::ParseNamesL( const TUint32& aVal,
                                       RArray<TUint32>& aNames )
    {
    COM_TRACE_( "[AccFW:SrvUtil] CAccConfigFileParser::ParseNamesL()" );
    TUint32 sum( 0 );
    TUint32 curVal( 1 );
    TInt curBit( 0 );

    do {
        COM_TRACE_2( "[AccFW:SrvUtil] CAccConfigFileParser::ParseNamesL Binary for this roundtrip is 0x%x, total sum is 0x%x", curVal, sum );
        COM_TRACE_1( "[AccFW:SrvUtil] CAccConfigFileParser::ParseNamesL & 0x%x", curVal & aVal );
        // Check if this subblock is defined in SB-def block

        if ( ( curVal & aVal ) == curVal )
            {
            COM_TRACE_1( "[AccFW:SrvUtil] (Name) MATCH! 0x%x",curVal );
            aNames.AppendL( curVal ); // Append to found caps array
            sum += curVal;
            }
        curBit++;
        curVal = 2 * curVal;        
        }
    while ( sum < aVal && curBit < KAccConfigMaxCapabilityGroups );

    COM_TRACE_( "[AccFW:SrvUtil] CAccConfigFileParser::ParseNamesL - return void" );
    }
void CMemSpyEngineHelperChunk::GetChunkHandlesL( RArray<TAny*>& aHandles, TType aType, TUint aId )
    {
	TAny* handles[ KMemSpyEngineMaxChunkCount ];
	TInt count = KMemSpyEngineMaxChunkCount;

    TInt r = 0;
    //
    switch( aType )
        {
    case EThread:
        r = iEngine.Driver().GetChunkHandlesForThread( aId, handles, count );
        break;
    case EProcess:
        r = iEngine.Driver().GetChunkHandlesForProcess( aId, handles, count );
        break;
    default:
    case EAll:
        r = iEngine.Driver().GetChunkHandles( handles, count );
        break;
        }
    //
    if  ( r == KErrNone )
    	{
        count = Min( count, KMemSpyEngineMaxChunkCount );
        for( TInt index = 0; index < count; index++ )
            {
            TAny* handle = handles[ index ];

            if  ( aHandles.Find( handle ) == KErrNotFound )
                {
                aHandles.AppendL( handle );
                }
            }
        }
    }
Exemple #16
0
// ---------------------------------------------------------------------------
// TIap::ResolveIapL
// ---------------------------------------------------------------------------
//  
TInt TIap::ResolveIapL( RArray<TIap>& aIapArray )
    {
    RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -start\n") );
    
    TBuf<40> name;
    TUint32 iapid;

    CCommsDatabase* db = CCommsDatabase::NewL( EDatabaseTypeIAP );
    CleanupStack::PushL( db );
    CCommsDbTableView* view = db->OpenTableLC( TPtrC( IAP ) );

    TInt res = view->GotoFirstRecord();
    
    if ( res != KErrNone )
        {
        CleanupStack::PopAndDestroy( 2 ); // db, view
        RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -end err: %d\n"), res );
        return res;
        }
    while ( res == KErrNone )  
        {
        view->ReadTextL( TPtrC( COMMDB_NAME ), name );
        view->ReadUintL( TPtrC( COMMDB_ID ), iapid );
        aIapArray.AppendL( TIap( iapid, name ) );
        res = view->GotoNextRecord();
        }
    CleanupStack::PopAndDestroy( 2 ); // db, view

    RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -end" ) );
    return KErrNone;
    }
void CSmsStackTestServer::GetTsyNamesFromCommsdatL(RArray<TName>& aTsyNameList)
    {
    CMDBSession* db = CMDBSession::NewL(KCDVersion1_2);
    CleanupStack::PushL(db);

    TName tsy;
    TUint32 modemId = 0;

    CMDBField<TUint32>* globalSettingsField = new(ELeave) CMDBField<TUint32>(KCDTIdModemPhoneServicesSMS);
    CleanupStack::PushL(globalSettingsField);
    globalSettingsField->SetRecordId(1);
    globalSettingsField->LoadL(*db);
    modemId = *globalSettingsField;
    CleanupStack::PopAndDestroy(globalSettingsField);

    CMDBField<TDesC>* tsyField = new(ELeave) CMDBField<TDesC>(KCDTIdTsyName);
    CleanupStack::PushL(tsyField);
    tsyField->SetRecordId(modemId);
    tsyField->SetMaxLengthL(KMaxTextLength);
    tsyField->LoadL(*db);
    tsy = *tsyField;
    aTsyNameList.AppendL(tsy);

    CleanupStack::PopAndDestroy(2, db); // db, tsyField
    }
// -----------------------------------------------------------------------------
// CTestPosLandmarkDatabase::ImportedLmkIterator
// 
// 
// -----------------------------------------------------------------------------
//
TInt CTestPosLandmarkDatabase::ImportedLmkIteratorL( CStifItemParser& aItem )
	{
	TPtrC importFilePtr;
	TInt err = aItem.GetNextString( importFilePtr );	
	// Open and initialize DB
	CPosLandmarkDatabase* lmkDatabase = CPosLandmarkDatabase::OpenL( KDBUri );
	CleanupStack::PushL( lmkDatabase );
	// Initialize database
	ExecuteAndDeleteLD( lmkDatabase->InitializeL() );
	// Create parser
	CPosLandmarkParser* parser = CPosLandmarkParser::NewL( KPosMimeTypeLandmarkCollectionXml );
	CleanupStack::PushL( parser );
	// Set Input file
	parser->SetInputFileL( importFilePtr );
	// Import landmarks to DB	
	CPosLmOperation* operation = lmkDatabase->ImportLandmarksL( *parser, CPosLandmarkDatabase::EDefaultOptions );
	CleanupStack::PushL( operation );
	operation->ExecuteL();
	// Get iterator for imported landmarks
	CPosLmItemIterator* iterator = lmkDatabase->ImportedLandmarksIteratorL( operation );
	CleanupStack::PushL( iterator );
	// Get ids of imported landmarks
	RArray<TPosLmItemId> idArray;
	TPosLmItemId id;
	while( (id = iterator->NextL()) != KPosLmNullItemId )
		{
		idArray.AppendL( id );
		}
	iLog->Log(_L("ImportedLmkIterator successful")); 
	CleanupStack::PopAndDestroy( 4, lmkDatabase);
	ReleaseLandmarkResources();		
	return KErrNone;	
	}
// -----------------------------------------------------------------------------
// Maps email api sort criteria to sort criteria type that protocol plugin
// accepts.
// -----------------------------------------------------------------------------
void CEmailFolder::ToFsSortCriteriaL( 
    const RSortCriteriaArray& aSortCriteria, 
    RArray<TFSMailSortCriteria>& aFsCriteria )
    {
    const TFSMailSortField fieldValues[] = {
        EFSMailDontCare,        
        EFSMailSortByDate,      
        EFSMailSortBySender,    
        EFSMailSortByRecipient, 
        EFSMailSortBySubject,   
        EFSMailSortByPriority,  
        EFSMailSortByFlagStatus,
        EFSMailSortByUnread,    
        EFSMailSortBySize,      
        EFSMailSortByAttachment };

    for ( TInt i=0; i < aSortCriteria.Count(); i++ )
        {
        const TEmailSortCriteria& criteria  = aSortCriteria[i];
        __ASSERT_ALWAYS( criteria.iField < sizeof( fieldValues ) / sizeof (fieldValues [i] ),
            Panic( EMailPanicSortMapIndexOutOfBounds ) );
        TFSMailSortCriteria fsCriteria;
        fsCriteria.iField = fieldValues[ criteria.iField ];
        if ( criteria.iAscending )
            {
            fsCriteria.iOrder = EFSMailAscending;
            }
        else
            {
            fsCriteria.iOrder = EFSMailDescending;
            }
        aFsCriteria.AppendL( fsCriteria );
        }
    }
TInt CSCPParamDB :: GetApplicationIDListL(RArray <TUid>& aIDArray) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> GetApplicationIDList() >>>"));
    
    RDbView lDBView;
    CleanupClosePushL(lDBView);
    
    HBufC* lSelectQry  = HBufC :: NewLC(KSelectAll().Length());
    lSelectQry->Des().Append(KSelectAll);
    
    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());
    
    TBool lStatus(EFalse);
    TInt lRet(KErrNone);
    
    TRAP(lRet, lStatus = lDBView.FirstL());
    
    if(lRet == KErrNone && lStatus) {
        do {
            lDBView.GetL();
            TUid lAppUID = TUid :: Uid(lDBView.ColInt(iColSet->ColNo(KColAppId)));
            
            if(aIDArray.Find(lAppUID) == KErrNotFound) {
                aIDArray.AppendL(lAppUID);
            }
        }
        while(lDBView.NextL());
    }
    
    _SCPDB_LOG(_L("[CSCPParamDB]-> GetApplicationIDList() >>>"));
    CleanupStack :: PopAndDestroy(2);
    return KErrNone;
}
TBool CCalInstanceIteratorUid::HasMoreL() const
	{
	TBool returnValue(EFalse);

	//Store the current state
	TCalTime storedCurrentIndex = iCurrentIndexTime;
	TInt storedArrayIndex = iCurrentIndex;
	RArray<TInt> storedArray;
	CleanupClosePushL(storedArray);
	const TInt count = iEntryWithSameTime.Count();
	for(TInt ii=0; ii<count;++ii)
		{
		storedArray.AppendL(iEntryWithSameTime[ii]);
		}

	//Find instances
	CCalInstance* nextInstance = const_cast<CCalInstanceIteratorUid*>(this)->NextL();
	returnValue = (nextInstance != NULL);
	delete nextInstance;

	// restore the state
	const_cast<CCalInstanceIteratorUid*>(this)->iCurrentIndexTime = storedCurrentIndex; 
	iCurrentIndex = storedArrayIndex;//reset index since it could be moved in NextL
	iEntryWithSameTime.Reset();
	const TInt countSortedArray = storedArray.Count();
	for(TInt ii=0; ii<countSortedArray;++ii)
		{
		iEntryWithSameTime.AppendL(storedArray[ii]);
		}

	CleanupStack::PopAndDestroy(&storedArray);

	return returnValue;
	}
// --------------------------------------------------------------------------
// void CNSmlSOSHandler::ReadTasksFromDBL( RArray<TInt>& aArray )
// --------------------------------------------------------------------------
//
void CNSmlSOSHandler::ReadTasksFromDBL( RArray<TInt>& aArray )
    {
    // Get non-overrided data from settings.
    CNSmlDSSettings* settings = CNSmlDSSettings::NewLC();
    CNSmlDSProfile* prof = settings->ProfileL( iCurrentJob->ProfileId() );

    if ( prof )
        {        
        CleanupStack::PushL(prof);
        RImplInfoPtrArray implArray;
        CleanupStack::PushL(PtrArrCleanupItemRArr( CImplementationInformation, &implArray ) );    
        TUid ifUid = { KNSmlDSInterfaceUid };
        REComSession::ListImplementationsL( ifUid, implArray );

        for ( TInt i = 0 ; i < implArray.Count() ; i++ )
            {    
            CImplementationInformation* implInfo = implArray[i];
            CNSmlDSContentType* ctype = prof->ContentType( implInfo->ImplementationUid().iUid );
            if ( ctype )
                {            
                aArray.AppendL( ctype->IntValue( EDSAdapterTableId ) );
                }
            }        
        CleanupStack::PopAndDestroy(&implArray); 
        CleanupStack::PopAndDestroy(prof);
        REComSession::FinalClose();        
        }    
    CleanupStack::PopAndDestroy(settings);
    }
// -----------------------------------------------------------------------------
// CTestPosLandmarkDatabase::ImportSelectedLandmarks
// 
// 
// -----------------------------------------------------------------------------
//
TInt CTestPosLandmarkDatabase::ImportSelectedLandmarksL( CStifItemParser& aItem )
	{
	TPtrC importFilePtr;
	TInt err = aItem.GetNextString( importFilePtr );	
	// Open and initialize DB
	CPosLandmarkDatabase* lmkDatabase = CPosLandmarkDatabase::OpenL( KDBUri );
	CleanupStack::PushL( lmkDatabase );
	// Initialize database
	ExecuteAndDeleteLD( lmkDatabase->InitializeL() );
	// Create parser
	CPosLandmarkParser* parser = CPosLandmarkParser::NewL( KPosMimeTypeLandmarkCollectionXml );
	CleanupStack::PushL( parser );
	// Set Input file
	parser->SetInputFileL( importFilePtr );
	// Import landmarks to DB
	// Define index array
	RArray<TUint> indexArray;
	// Add indexes of selected landmarks, only these should be imported
	indexArray.AppendL( 0 );
	indexArray.AppendL( 1 );	
	CPosLmOperation* operation = lmkDatabase->ImportLandmarksL( *parser, indexArray, CPosLandmarkDatabase::EDefaultOptions );
	CleanupStack::PushL( operation );
	operation->ExecuteL();
	iLog->Log(_L("ImportSelectedLandmarks successful")); 
	CleanupStack::PopAndDestroy( 3, lmkDatabase );
	ReleaseLandmarkResources();
	return KErrNone;	
	}
void CBCTestKeymap::TestCreateL()
    {
    //raw data format:
    //
    // #map //=2*KPtiNumKeys*sizeof(TPtiKeyMapping) = 2*12*(2*sizeof(int))
    // {index, chars}, {index, chars}, ... , {index, chars} //lower case
    // {INDEX, CHARS}, {INDEX, CHARS}, ... , {INDEX, CHARS} //upper case
    //
    // #chars
    // char1, char2, ... , charN
    //

    TInt16 charBuffer[1+(KPtiNumKeys*2)*2+1+sizeof(Keys)/sizeof(TUint16)];

    RArray<TPtiKeyMapping> maps;
    for (TInt i = 0; i < KPtiNumKeys * 2; i++)
        {
        TPtiKeyMapping map = {0, 0};
        maps.AppendL( map );
        }

    TInt16* ptr = charBuffer+1+maps.Count()*2+1;
    TInt curKey=0;
    TInt index=0;
    for (TInt i = 0; i < sizeof(Keys)/sizeof(TUint16)-1; ++i)
        {
        if (Keys[i] == '\t')
            {
            maps[++curKey].iIndex = index;
            continue;
            }

        *(ptr+index)= Keys[i];
        index++;
        maps[curKey].iNumChars++;
        }

    charBuffer[0]=maps.Count();
    ptr=charBuffer+1;
    for(TInt i=0; i<maps.Count(); ++i)
        {
        *ptr=maps[i].iIndex;
        ptr++;
        *ptr=maps[i].iNumChars;
        ptr++;
        }
    *ptr=index;
    maps.Close();

    Teardown();
    TRAPD(err, iMap = CPtiKeyMappings::NewL(charBuffer));
    if(err == KErrCorrupt)
        {
        AssertTrueL(ETrue, _L("data format err"));
        }
    else
        {
        AssertNotNullL(iMap, _L("created by NewL from raw data"));
        }   
    }
void CValidateCertChainStep::TransferToNewWarningsL(RArray<TInt>& aOldWarnings, RArray<TValidationStatus>& aNewWarnings, TInt aCertIndex)
	{
	for (TInt i=0; i < aOldWarnings.Count(); ++i)
		{
		switch (aOldWarnings[i])
			{
			case ECriticalExtendedKeyUsage:
				break;
			case ECriticalPolicyMapping:
				break;
			case ECriticalDeviceId:
				break;
			case ECriticalSid:
				break;
			case ECriticalVid:
				break;
			case ECriticalCapabilities:
				break;
			case ECriticalCertPoliciesWithQualifiers:	//handled by ini parameter due to overloading by warning of iCert value
				break;
			default:
				TValidationError error = (TValidationError) aOldWarnings[i];
				aNewWarnings.AppendL(TValidationStatus(error, aCertIndex));							
			}
		}
	}
void CTestObjectManager::GetObjectHandlesL(
        const TMTPObjectMgrQueryParams& aParams,
        RMTPObjectMgrQueryContext& aContext, RArray<TUint>& aHandles ) const
    {
    CleanupClosePushL( aHandles ); 
    PRINTF3( ">CTestObjectManager::GetObjectHandlesL storage = 0x%x parent = 0x%x format = 0x%x", aParams.iStorageId, aParams.iParentHandle, aParams.iFormatCode );
    for ( TInt i = 0; i < iMTPObjects.Count(); i++ )
         {
         TUint handle = iMTPObjects[i]->Uint( CMTPObjectMetaData::EHandle );
         TUint formatCode = iMTPObjects[i]->Uint( CMTPObjectMetaData::EFormatCode );
         TUint storageId = iMTPObjects[i]->Uint( CMTPObjectMetaData::EStorageId );
         TInt parentId = iMTPObjects[i]->Int( CMTPObjectMetaData::EParentId );
         if ( ( ( aParams.iStorageId == storageId   ) || ( aParams.iStorageId == KMTPStorageAll ) )
            &&
              ( ( aParams.iFormatCode == formatCode ) || ( aParams.iFormatCode == KMTPFormatsAll ) )
            &&
            ( ( aParams.iParentHandle == parentId ) || ( aParams.iParentHandle == KMTPHandleNone ) || ( ( aParams.iParentHandle == KMTPHandleNoParent ) && ( parentId == KErrNotFound ) ) ) )
             {
             PRINTV1( "Appending handle %d", handle );
             aHandles.AppendL( handle );
             }
         }
    aContext.Close();
    PRINTF0( "<CTestObjectManager::GetObjectHandlesL" );
    CleanupStack::Pop(); 
    }
// -----------------------------------------------------------------------------
// CMccCodecRed::RedPayloadsL
// Fills array with red payload type values
// -----------------------------------------------------------------------------
//
void CMccCodecRed::RedPayloadsL( RArray<TUint>& aRedPayloads ) const
    {
    for ( TInt i = 0; i < iRedPayloads.Count(); i++ )
        {
        aRedPayloads.AppendL( iRedPayloads[ i ] );
        }
    }
// ---------------------------------------------------------------------------
// CLbtAppChangeHandler::HandleAppListEvent
// ---------------------------------------------------------------------------
//
void CLbtAppChangeHandler::HandleAppListEvent(TInt /*aEvent*/)
	{
	FUNC_ENTER("CLbtAppChangeHandler::HandleAppListEvent");
	if( iOperation == EOpNone && !IsActive() )
		{
		iOperation = EOpRegiseteredForListPoplulation;
		iAppArcSession.RegisterListPopulationCompleteObserver(iStatus);
		SetActive();
		return;
		}
	iOperation = EOpNone;
	RArray<TLbtAppInfo> newAppList;
	
	// First get the set of installed applications in the system
	iAppArcSession.GetAllApps();
	
	TApaAppInfo appInfo;
	TInt error = iAppArcSession.GetNextApp(appInfo);
	
	while(KErrNone == error)
		{
		TLbtAppInfo lbtAppInfo;
        lbtAppInfo.iUid = appInfo.iUid;
        lbtAppInfo.iFullName.Zero();
        lbtAppInfo.iFullName.Copy( appInfo.iFullName );

		TRAPD(err, newAppList.AppendL(lbtAppInfo));
		if(err != KErrNone)
			{
			break;
			}
		error = iAppArcSession.GetNextApp(appInfo);
		}
	
	LOG1("newAppList.Count():%d",newAppList.Count());
	LOG1("iCurrentInstalledApps.Count():%d",iCurrentInstalledApps.Count());
	
	if(newAppList.Count() > iCurrentInstalledApps.Count())
		{
		HandleAppListAdditionEvent(newAppList);
		}
	else
		{
		LOG("newAppList.Count() < iCurrentInstalledApps.Count()");
		HandleAppListRemovalEvent(newAppList);
		}
		
	iCurrentInstalledApps.Reset();
	
	for( TInt i=0;i<newAppList.Count();i++ )
	    {
	    TInt error = iCurrentInstalledApps.Append( newAppList[i] );
	    if( error != KErrNone )
	        {
            LOG1("Failed to append new applist to the array:%d",error);
            break;
	        }
	    }
	newAppList.Close();
	}
void RArrayCopyTestL()
	{
	test.Start(_L("Selftest of RArray CopyL"));

	RArray<TInt> orig;
	TInt i;													// VC++
	for(i=0; i<10; i++)
		{
		orig.AppendL(i);
		}

	RArray<TInt> newArray;
	CopyL(orig, newArray);

	test_Equal(10, newArray.Count());

	for(i=0; i<10; i++)
		{
		test_Equal(orig[i], newArray[i])
		}

	orig.Close();
	newArray.Close();
	test.End();
	}
// ---------------------------------------------------------
// CCookieTimer::SettingAttribute
// ---------------------------------------------------------
//
void CCookieManagerServer::SettingAttribute(TDesC8& attrName, TDesC8& attrData,TUint32& aGroupId
        , RArray<TUint32>& aSharedAppUidArray, TBool& aCookieSharableFlag  )
    {
    CLOG( ( EServer, 0, _L( "-> CCookieManagerServer::SettingAttribute" ) ) );
    TBuf8<100> groupname(KNullDesC8);
    TBuf8<100> bufGroupId(KNullDesC8);
    TBuf8<100> bufSharedAppUidName(KNullDesC8);
    TUint32 sharedAppUid = 0;
    if ( ! attrName.CompareF(KGroupName))
         {
          groupname.Copy(attrData);
         } else if ( ! attrName.CompareF(KGroupId)) 
              {
              bufGroupId.Copy(attrData);
              TInt err = ChangeToDecimal(bufGroupId, aGroupId);
              
              }else if ( ! attrName.CompareF(KUid3))
                 {
                 bufSharedAppUidName.Copy(attrData);
                 TInt err = ChangeToDecimal(bufSharedAppUidName, sharedAppUid);
                 if (err == KErrNone)
                     aSharedAppUidArray.AppendL(sharedAppUid);
                 
                 } else if (! attrName.CompareF(KCookieSharable))
                     {
                      if ( !attrData.CompareF(KOff) )
                          aCookieSharableFlag = EFalse;
                      else
                          aCookieSharableFlag = ETrue;
                     }
    CLOG( ( EServer, 0, _L( "<- CCookieManagerServer::SettingAttribute" ) ) );
    }