/** All instance iterator ConstructL() for when a starting instance is provided.

Set the find instance settings that are provided.

@internalComponent
*/
void CCalInstanceIteratorAll::ConstructL(const CCalFindInstanceSettings& aSettings, TCalLocalUid aLocalUid, const TCalTime& aInstanceTime, TCalCollectionId aCollectionId)	
	{
	iInstanceIdCache = new(ELeave) CArrayFixSeg<TAgnInstance> (KNumInstances / 4);
	
	SetFindInstanceSettingsL(aSettings);
	
	CAgnSimpleEntry* simpleEntry = iInstanceViewImpl.GetServ().GetSimpleEntryL(aCollectionId, aLocalUid);
	TCleanSimpleEntry cleanSimpleEntry(*simpleEntry, iInstanceViewImpl.GetServ().SimpleEntryAllocator());
	TCleanupItem cleanupItem(TCleanSimpleEntry::DestroySimpleEntry, &cleanSimpleEntry);
	CleanupStack::PushL(cleanupItem);
	
	// The entry should exist
	__ASSERT_ALWAYS(simpleEntry, User::Leave(KErrNotFound));
	
	// Check that the instance is a valid instance of the entry
	__ASSERT_ALWAYS(iInstanceViewImpl.IsValidInstanceL(*simpleEntry, aInstanceTime), User::Leave(KErrNotFound));
	
	// Create and put the starting instance as the first in the array
	
	TAgnInstance instance;
	instance.iCollectionId = aCollectionId;
	if (simpleEntry->EndTime().IsSet())
		{
		// for an undated todo we do not set the instance time
		instance.iId.SetDate(CalUtils::TCalTimeToTAgnCalendarTimeL(aInstanceTime));
		}	
	
	instance.iId.SetEntryId(simpleEntry->EntryId());
	iInstanceIdCache->AppendL(instance);
	iCurrentIndex = 0;
	
	CleanupStack::PopAndDestroy(); // simpleEntry
	}
示例#2
0
// Clean-up unused file items.
void qtractorFileListView::cleanupItem ( QTreeWidgetItem *pItem )
{
	if (pItem == NULL)
		return;

	switch (pItem->type()) {
	case GroupItem: {
		const int iChildCount = pItem->childCount();
		for (int i = 0; i < iChildCount; ++i)
			cleanupItem(pItem->child(i));
		break;
	}
	case FileItem: {
		qtractorSession *pSession = qtractorSession::getInstance();
		qtractorFileListItem *pFileItem
			= static_cast<qtractorFileListItem *> (pItem);
		if (pSession && pFileItem) {
			const QString& sPath = pFileItem->path();
			qtractorFileList::Item *pFileListItem
				= pSession->files()->findItem(m_iFileType, sPath);
			if (pFileListItem && pFileListItem->clipRefCount() < 1)
				pItem->setSelected(true);
		}
		break;
	}
	default:
		break;
	}
}
示例#3
0
void qtractorFileListView::cleanup (void)
{
	QTreeWidget::setCurrentItem(NULL);
	QTreeWidget::selectionModel()->clearSelection();

	const int iItemCount = QTreeWidget::topLevelItemCount();
	for (int i = 0; i < iItemCount; ++i)
		cleanupItem(QTreeWidget::topLevelItem(i));

	removeItem();
}
//Opening a repository and closing the repository
LOCAL_C void CreateDeleteL(TBool /*aOOMMode*/)
{
	CServerRepository* serverRepo=new (ELeave)CServerRepository();
	TCleanupItem cleanupItem(&ReleaseRepository, serverRepo);
	CleanupStack::PushL(cleanupItem);

	CSessionNotifier* sessNotif=new (ELeave)CSessionNotifier();
	CleanupStack::PushL(sessNotif);

// 	test access to a valid repository
	serverRepo->OpenL(KCurrentTestUid,*sessNotif);
	serverRepo->Close();

	CleanupStack::PopAndDestroy(sessNotif);
	CleanupStack::PopAndDestroy(1);
}
LOCAL_C void CreateDeleteCorruptL(TBool /*aOOMMode*/)
{
	CServerRepository* serverRepo=new (ELeave)CServerRepository();
	TCleanupItem cleanupItem(&ReleaseRepository, serverRepo);
	CleanupStack::PushL(cleanupItem);

	CSessionNotifier* sessNotif=new (ELeave)CSessionNotifier();
	CleanupStack::PushL(sessNotif);

// 	test access to a corrupt repository
	// trap KErrCorrupt
	TRAPD(err, serverRepo->OpenL(KCorruptRepositoryUid,*sessNotif));
	// leave if not KErrCorrupt
	User::LeaveIfError((err == KErrCorrupt) ? KErrNone : err);
	serverRepo->Close();

	CleanupStack::PopAndDestroy(sessNotif);
	CleanupStack::PopAndDestroy(1);
}
// ----------------------------------------------------------------------------
// CSipAcceptContactStrategy::CreateFeatureSetsL
// ----------------------------------------------------------------------------
//
RPointerArray<CSIPFeatureSet> CSipAcceptContactStrategy::CreateFeatureSetsL(
    CSIPRequest& aRequest)
    {
    RPointerArray<CSIPFeatureSet> featureSets;
    TCleanupItem cleanupItem(DestroyFeatureSets,&featureSets);
	CleanupStack::PushL(cleanupItem);
	TSglQueIter<CSIPHeaderBase> iter = 
	    aRequest.Headers(iAcceptContactHeaderName);	
	while (iter)
		{
		CSIPHeaderBase* tmp = iter++;
		CSIPAcceptContactHeader* acceptContact = 
		    static_cast<CSIPAcceptContactHeader*>(tmp);
		CSIPFeatureSet* featureSet = CSIPFeatureSet::NewLC(*acceptContact);
		featureSets.AppendL(featureSet);
		CleanupStack::Pop(featureSet);
		}	
	CleanupStack::Pop(1); // cleanupItem 
    return featureSets;
    }
// -----------------------------------------------------------------------------
// CSIPSubscribeDialogAssoc::DoSendUnsubscribeL
// Sending (un)SUBSCRIBE does not terminate the dialog. (un)SUBSCRIBE is not a
// dialog creating request.
// -----------------------------------------------------------------------------
//
CSIPClientTransaction*
CSIPSubscribeDialogAssoc::DoSendUnsubscribeL(CSIPMessageElements* aElements)
    {
    CSIPMessageElements* elem = aElements;
    if (!aElements)
    	{
    	elem = CSIPMessageElements::NewLC();
    	}

    TMessageHeaderCleanup headerCleanup(*elem);
    TCleanupItem cleanupItem(TMessageHeaderCleanup::Cleanup, &headerCleanup);
    if (aElements)
    	{
    	CleanupStack::PushL(cleanupItem);
    	}    	
    CSIPDialogAssocImplementation::CopyHeaderL(*iEvent, *elem, headerCleanup);
    RPointerArray<CSIPHeaderBase> expireHeaders = elem->UserHeadersL(
    		SIPStrings::StringF(SipStrConsts::EExpiresHeader));
    CleanupClosePushL(expireHeaders);

	TBool hasExpiresZero = EFalse;
    TInt expiresHeaderCount = expireHeaders.Count();
    __ASSERT_ALWAYS(expiresHeaderCount <= 1, User::Leave(KErrArgument));
  
	if (expiresHeaderCount == 1)
        {
        CSIPExpiresHeader* expires =
        	static_cast<CSIPExpiresHeader*>(expireHeaders[0]);
        __ASSERT_ALWAYS(expires->Value() == 0, User::Leave(KErrArgument));
        hasExpiresZero = ETrue;
        }
    CleanupStack::PopAndDestroy(); //expireHeaders

    if (!hasExpiresZero)
    	{
        CSIPExpiresHeader* expires = new (ELeave) CSIPExpiresHeader(0);
        CleanupStack::PushL(expires);
        CSIPDialogAssocImplementation::CopyHeaderL(*expires,
        										   *elem,
        										   headerCleanup);
        CleanupStack::PopAndDestroy(expires);
    	}

	CSIPClientTransaction* ta =
    	CSIPClientTransaction::NewLC(Type(), Implementation(), iRefresh);
    TUint32 requestId(0);
	if (iRefresh)
	    {
	    //Terminates an existing refreshed subscription
	    Implementation().ClientConnectionL().SendRequestWithinDialogL(
	                            Dialog().Implementation().DialogId(),
	                            iRefresh->RefreshId(),
	                            requestId,
	                            elem);
        }
	else
	    {
	    TUint32 refreshId(0);
        Implementation().ClientConnectionL().SendRequestWithinDialogL(
                                Dialog().Implementation().DialogId(),
                                requestId,
                                refreshId,
                                Type(),
                                elem,
                                CSIPTransactionBase::IsTargetRefresh(Type()));
        }
    CleanupStack::Pop(ta);
	ta->SetRequestId(requestId);

    //Take ownership of aElements when leave can't occur
    delete elem;
    CleanupStack::Pop(); //TCleanupItem or elem

    return ta;
    }
// -----------------------------------------------------------------------------
// CSIPSubscribeDialogAssoc::DoSendSubscribeL
// If subscription is already being refreshed, leaves with KErrAlreadyExists
// -----------------------------------------------------------------------------
//
CSIPClientTransaction*
CSIPSubscribeDialogAssoc::DoSendSubscribeL(CSIPMessageElements* aElements,
                                           CSIPRefresh* aRefresh,
                                           TBool aWithinDialog)
    {
    __ASSERT_ALWAYS(!(aRefresh && iRefresh), User::Leave(KErrAlreadyExists));
    
	CSIPMessageElements* elem = aElements;
    if (!aElements)
    	{
    	elem = CSIPMessageElements::NewLC();
    	}

    TMessageHeaderCleanup headerCleanup(*elem);
    TCleanupItem cleanupItem(TMessageHeaderCleanup::Cleanup, &headerCleanup);
    if (aElements)
    	{
    	CleanupStack::PushL(cleanupItem);
    	}
    CSIPDialogAssocImplementation::CopyHeaderL(*iEvent, *elem, headerCleanup);
	CSIPClientTransaction* ta = NULL;
	if (aWithinDialog)
		{
		ta = CSIPClientTransaction::NewLC(Type(),										  
										  Implementation(),
										  aRefresh ? aRefresh : iRefresh);
		TUint32 requestId(0);
		TUint32 refreshId(0);
	    if (iRefresh)
	        {
	        //Updates an existing refreshed subscription
	        Implementation().ClientConnectionL().SendRequestWithinDialogL(
        								Dialog().Implementation().DialogId(),
		                           		iRefresh->RefreshId(),
                                        requestId,
                                        elem);
	        }
	    else
	        {
	        Implementation().ClientConnectionL().SendRequestWithinDialogL(
	        				 Dialog().Implementation().DialogId(),
				           	 requestId,
				           	 refreshId,
						 	 Type(),
				             elem,
				             CSIPTransactionBase::IsTargetRefresh(Type()),
				             (aRefresh != NULL));
		    }
		if (aRefresh)
		    {
		    aRefresh->SetRefreshIdIfEmpty(refreshId);
		    }
		CleanupStack::Pop(ta);
		ta->SetRequestId(requestId);
	    //Take ownership of aElements when leave can't occur
	    delete elem;
		}
	else
		{
	    const CSIPContactHeader* contact =
	    	Dialog().Implementation().ContactHeader();
		if (contact)
			{
			CSIPDialogAssocImplementation::CopyHeaderL(*contact,
													   *elem,
													   headerCleanup);
			}
		ta = Dialog().Implementation().SendDialogCreatingRequestL(
										Implementation(), elem, aRefresh);	
		}

	CleanupStack::Pop(); //TCleanupItem or elem
	if (aRefresh)
        {
        aRefresh->SetRequestType(Type());                
    	iRefresh = aRefresh;
    	iRefresh->SetRefreshOwner(Implementation());            
        }
    return ta;
    }
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
EXPORT_C void CSymbianUnitTestRunner::ExecuteTestsL(
    const MDesCArray& aTestDllNames,
    TBool aMemoryAllocationFailureSimulation,
    const TDesC& aOutputFileName,
    const TDesC& aOutputFormat,
    const CDesCArray& aTestCaseNames,
    TInt  aTimeout )
    {
    //init logger
    TBuf<50> version;
    version.Format(KLogVersion, SUT_MAJOR_VERSION, SUT_MINOR_VERSION, SUT_BUILD_VERSION);
    SUT_LOG_START(version);
    
    iTestCount = 0;
    
    MSymbianUnitTestInterface::TFailureSimulation failureSimulation = 
        MSymbianUnitTestInterface::ENoFailureSimulation;
    if ( aMemoryAllocationFailureSimulation )
        {
        failureSimulation = 
            MSymbianUnitTestInterface::EMemAllocFailureSimulation;
        }
    
    for ( TInt i = 0; i < aTestDllNames.MdcaCount(); i++ )
        {
        TPtrC16 testDllName( aTestDllNames.MdcaPoint( i ) );
        RLibrary library;
        TInt ret;
        ret = library.Load( testDllName );
        if ( ret != KErrNone )
            {
            iUiCallBack.InfoMsg( KFailedToFindDll, testDllName );
            SUT_LOG_FORMAT(KFailedToFindDll, &testDllName);
            //User::Leave( KErrNotFound );
            User::Leave( ret );
            } 
        CleanupClosePushL( library );
        // The second UID of the dll to be used must be compatible
        if ( library.Type()[ 1 ] != KSymbianUnitTestDllUid )
            {
            iUiCallBack.InfoMsg( KNonCompatibleUIDs );
            User::Leave( KErrNotFound );
            }  
        TLibraryFunction entryFunction = library.Lookup( 1 );
        if ( !entryFunction )
            {
            iUiCallBack.InfoMsg( KExportFuncNotFound );
            User::Leave( KErrNotFound );
            }
        
        MSymbianUnitTestInterface* test = 
            reinterpret_cast< MSymbianUnitTestInterface* >( 
                entryFunction() );
        TCleanupItem cleanupItem( DeleteTest, test );
        CleanupStack::PushL( cleanupItem );
        iTestCount += test->TestCaseCount();
        test->ExecuteL( *this, *iResult, failureSimulation, aTestCaseNames, aTimeout);
        CleanupStack::PopAndDestroy(); // cleanupItem
        
        CleanupStack::PopAndDestroy( &library ); 
        }
    
    CSymbianUnitTestOutputFormatter* outputFormatter = 
        SymbianUnitTestOutputFactory::CreateOutputLC( 
            aOutputFileName, aOutputFormat );
    outputFormatter->PrintL( *iResult );
    CleanupStack::PopAndDestroy( outputFormatter );    
    SUT_LOG_INFO(KLogFinish);
    }
void FmBkupEnginePrivate::GetRestoreInfoArray( QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
        QList< FmRestoreInfo > &restoreInfoList,
        const QString& aDrive )
    {
    int targetDrive = DriverNameToNumber( aDrive );    

    restoreInfoList.clear();
    
    ///////
    iDrvAndOpList->Reset();
    iBkupCategoryList->ResetAndDestroy();
    
    for( QList<FmBkupDrivesAndOperation* >::iterator it = drivesAndOperationList.begin();
        it != drivesAndOperationList.end(); ++it )
        {
        FmBkupDrivesAndOperation* fmDrvAndOp = *it;
        TBkupDrivesAndOperation drvAndOp;
        drvAndOp.setOwnerDataType( fmDrvAndOp->ownerDataType() );
        drvAndOp.setDrvCategories( fmDrvAndOp->drvCategories() );
        iDrvAndOpList->AppendL( drvAndOp );
        }
    ////////

    CMMCScBkupOpParamsRestoreFull* params =
        CMMCScBkupOpParamsRestoreFull::NewL(
                iDrvAndOpList, FmBkupEngine::EBUCatAllSeparately );
    CleanupStack::PushL( params );

    // Get list of all archives
    RPointerArray< CMMCScBkupArchiveInfo > archives;
    TCleanupItem cleanupItem( ResetAndDestroyArchives, &archives );
    CleanupStack::PushL( cleanupItem );
    iBkupEngine->ListArchivesL(
        archives,
        params,
        AllowedDriveAttMatchMask(),
        targetDrive );

    // Fill restore info
    TInt count( archives.Count() );
//    restoreInfoList.ReserveL( count );

    for( TInt i( 0 ); i < count; ++i )
        {
        // Content
        CMMCScBkupArchiveInfo& archiveInfo( *archives[ i ] );
        
        TUint32 iContent = BkupToFmgrMask( archiveInfo.Category().iFlags );
        TTime iTime = archiveInfo.DateTime();
        TInt iDrive = archiveInfo.Drive();
        TDateTime iDateTime = iTime.DateTime();
        
        int h       = iDateTime.Hour();
        int m       = iDateTime.Minute();
        int s       = iDateTime.Second();
        int year    = iDateTime.Year();
        int month   = iDateTime.Month() + 1;
        int day     = iDateTime.Day()+1;
        QTime time( h, m, s);
        QDate date( year, month, day );
        
        QDateTime dateTime( date, time );
        dateTime = dateTime.toLocalTime();
        
        FmRestoreInfo restoreInfo( iContent, dateTime, NumberToDriverName( iDrive ) );
        restoreInfoList.append( restoreInfo );
        }

    CleanupStack::PopAndDestroy( &archives );
    CleanupStack::PopAndDestroy( params );
    }
bool FmBkupEnginePrivate::StartRestoreL( QList<FmBkupDrivesAndOperation* > drivesAndOperationList )
    {
    TBool diskFull( SysUtil::DiskSpaceBelowCriticalLevelL(
        &iFs, 0, KFmgrSystemDrive ) );
    if ( diskFull )
        {
        mProcess = FmBkupEngine::ProcessRestore;
        notifyStartInternal( KMaxTInt );
        iError = KErrDiskFull;
        notifyFinishInternal();
        mProcess = FmBkupEngine::ProcessNone;
        return false;
        }
///////
    iDrvAndOpList->Reset();
    iBkupCategoryList->ResetAndDestroy();
    
    for( QList<FmBkupDrivesAndOperation* >::iterator it = drivesAndOperationList.begin();
        it != drivesAndOperationList.end(); ++it )
        {
        FmBkupDrivesAndOperation* fmDrvAndOp = *it;
        TBkupDrivesAndOperation drvAndOp;
        drvAndOp.setOwnerDataType( fmDrvAndOp->ownerDataType() );
        drvAndOp.setDrvCategories( fmDrvAndOp->drvCategories() );
        iDrvAndOpList->AppendL( drvAndOp );
        }
    ////////

    // Create restore params - ownership is transferred to
    // secure backup engine

#ifdef RD_FILE_MANAGER_BACKUP

    CMMCScBkupOpParamsRestoreFull* params =
        CMMCScBkupOpParamsRestoreFull::NewL(
                iDrvAndOpList,
            FmBkupEngine::EBUCatAllSeparately );
//    CleanupStack::PopAndDestroy(); // driveReader
    CleanupStack::PushL( params );

    // Get list of all archives
    RPointerArray< CMMCScBkupArchiveInfo > archives;
    TCleanupItem cleanupItem( ResetAndDestroyArchives, &archives );
    CleanupStack::PushL( cleanupItem );
    iBkupEngine->ListArchivesL(
        archives,
        params,
        AllowedDriveAttMatchMask() );

    // Get user set restore selection
    QList< FmRestoreInfo > selection;
//    CleanupClosePushL( selection );
    FmRestoreSettings& rstSettings( *( q->RestoreSettingsL() ) );
    rstSettings.GetSelectionL( selection );

    // Remove non user selected archives
    TInt i( 0 );
    while ( i < archives.Count() )
        {
        TBool remove( ETrue );

        // Compare archives category and drive
        CMMCScBkupArchiveInfo* archiveInfo = archives[ i ];
        TUint32 fmgrContent(
            BkupToFmgrMask( archiveInfo->Category().iFlags ) );
        TInt drive( archiveInfo->Drive() );

        TInt count( selection.count() );
        for( TInt j( 0 ); j < count; ++j )
            {
            const FmRestoreInfo& info( selection[ j ] );
            if ( ( drive == DriverNameToNumber( info.drive() ) ) && ( fmgrContent & info.content() ) )
                {
                // Found user selected archive
                // Do not check this archive again
                selection.removeAt( j );
                remove = EFalse;
                break;
                }
            }
        if ( remove )
            {
            // Remove non selected archive
            archives.Remove( i );
            delete archiveInfo;
            }
        else
            {
            // Move to next archive
            ++i;
            }
        }

//    CleanupStack::PopAndDestroy( &selection );
    params->SetArchiveInfosL( archives );
    CleanupStack::Pop( &archives );
    archives.Close();
    CleanupStack::Pop( params );

#else // RD_FILE_MANAGER_BACKUP

    CMMCScBkupOpParamsRestoreFull* params =
        CMMCScBkupOpParamsRestoreFull::NewL( driveReader, EBUCatAllInOne );
    CleanupStack::PopAndDestroy(); // driveReader

    FmBackupSettings& bkupSettings( *( q->BackupSettingsL() ) );
    // Get list of all archives
    RPointerArray< CMMCScBkupArchiveInfo > archives;
    TCleanupItem cleanupItem( ResetAndDestroyArchives, &archives );
    CleanupStack::PushL( cleanupItem );
    iBkupEngine->ListArchivesL(
        archives,
        params,
        bkupSettings.AllowedDriveAttMatchMask() );
    params->SetArchiveInfosL( archives );
    CleanupStack::Pop( &archives );

#endif // RD_FILE_MANAGER_BACKUP

    // Start the process - engine owns the parameters immediately
    mProcess = FmBkupEngine::ProcessRestore;
    PublishBurStatus( EFileManagerBkupStatusRestore );
    
    CCoeEnv* coeEnv = CCoeEnv::Static();
       CEikonEnv* eikonEnv = (STATIC_CAST(CEikonEnv*,coeEnv));
       eikonEnv->SetSystem(ETrue);
       
    TRAPD( err, iBkupEngine->StartOperationL(
        EMMCScBkupOperationTypeFullRestore, *this, params ) );
    if ( err != KErrNone )
        {
        PublishBurStatus( EFileManagerBkupStatusUnset );
        mProcess = FmBkupEngine::ProcessNone;
        User::Leave( err );
        }
    return true;
    }
int FmBkupEnginePrivate::deleteBackup( QList<FmBkupDrivesAndOperation* > drivesAndOperationList )
{
    iError = FmErrNone;

    QList< FmRestoreInfo > selection;
    FmRestoreSettings& rstSettings( *( q->RestoreSettingsL() ) );
    rstSettings.GetSelectionL( selection );

    iBkupCategoryList->ResetAndDestroy();
    for( QList<FmBkupDrivesAndOperation* >::iterator it = drivesAndOperationList.begin();
        it != drivesAndOperationList.end(); ++it )
        {
        FmBkupDrivesAndOperation* fmDrvAndOp = *it;
        TBkupDrivesAndOperation drvAndOp;
        drvAndOp.setOwnerDataType( fmDrvAndOp->ownerDataType() );
        drvAndOp.setDrvCategories( fmDrvAndOp->drvCategories() );
        iDrvAndOpList->AppendL( drvAndOp );
        }
    ////////

    CMMCScBkupOpParamsRestoreFull* params =
        CMMCScBkupOpParamsRestoreFull::NewL(
                iDrvAndOpList, FmBkupEngine::EBUCatAllSeparately );
    CleanupStack::PushL( params );

    // Get list of all archives
    RPointerArray< CMMCScBkupArchiveInfo > archives;
    TCleanupItem cleanupItem( ResetAndDestroyArchives, &archives );
    CleanupStack::PushL( cleanupItem );
    iBkupEngine->ListArchivesL(
        archives,
        params,
        AllowedDriveAttMatchMask());
    
    TInt i( 0 );
    while ( i < archives.Count() )
            {
            TBool remove( ETrue );

            // Compare archives category and drive
            CMMCScBkupArchiveInfo* archiveInfo = archives[ i ];
            TUint32 fmgrContent(
                BkupToFmgrMask( archiveInfo->Category().iFlags ) );
            TInt drive( archiveInfo->Drive() );

            TInt count( selection.count() );
            for( TInt j( 0 ); j < count; ++j )
                {
                const FmRestoreInfo& info( selection[ j ] );
                if ( ( drive == DriverNameToNumber( info.drive() ) ) && ( fmgrContent & info.content() ) )
                    {
                    // Found user selected archive
                    // Do not check this archive again
                    selection.removeAt( j );
                    remove = EFalse;
                    break;
                    }
                }
            if ( remove )
                {
                // Remove non selected archive
                archives.Remove( i );
                delete archiveInfo;
                }
            else
                {
                // Move to next archive
                ++i;
                }
            }
    
    iBkupEngine->DeleteArchivesL( archives );
    
    CleanupStack::Pop( &archives );
    archives.Close();
    CleanupStack::PopAndDestroy( params );
    
    return iError;
}
// ----------------------------------------------------------------------------
// CSipAcceptContactStrategy::ApplyL
// ----------------------------------------------------------------------------
//
CSIPResponse* CSipAcceptContactStrategy::ApplyL(
    CSIPRequest& aRequest, 
    RArray<TUid>& aUids,
    TBool& aContinueSearch,
    CSIPClientResolver2& aClientResolver2 )
	{
	SIP_CR_LOG("CSipAcceptContactStrategy::ApplyL")
	CSIPResponse* response = NULL;
	// The strategy is applied only for requests that contain Accept-Contact
	if (aRequest.HasHeader(iAcceptContactHeaderName))
        {
        RArray<TSIPClientScore> scores(1);
        CleanupClosePushL(scores);
        RPointerArray<CSIPFeatureSet> requestFeatureSets = 
            CreateFeatureSetsL(aRequest);
        TCleanupItem cleanupItem(DestroyFeatureSets,&requestFeatureSets);
	    CleanupStack::PushL(cleanupItem);
	    for (TInt i=0; i < aUids.Count(); i++)
		    {
		    TUid uid(aUids[i]);
		    MSipClient* client = iSipClients.GetByUID(uid);
		    if (client)
			    {
			    TInt score = CalculateScore(*client,requestFeatureSets);
			    if (score > 0)
			        {
			        TSIPClientScore clientScore(score,uid);
			        // The score is used as a key
			        scores.InsertInSignedKeyOrderAllowRepeatsL(clientScore);
			        }
			    }	
		    }
    	CleanupStack::PopAndDestroy(1); // cleanupItem
    	TInt clientCount = scores.Count();
    	aUids.Reset(); // empties the array
	    if (clientCount > 0)
	        {
	        // The scores are in increasing order. 
	        // The last is the best match. Reverse the order.
	        for (TInt i=scores.Count()-1; i>=0; i--)
	            {
	            // In the resulting array the first is the best match
	            aUids.AppendL(scores[i].iUid);
	            } 
	        if (iNextStrategy && clientCount > 1)
	            {
	            // Apply the next strategy only if 
	            // there are still more than one matching clients.
	            response = iNextStrategy->ApplyL(aRequest,aUids,
	                                             aContinueSearch,
	                                             aClientResolver2);
	            }
	        }
	    else
		    {
		    if ( iNextStrategy2 )
		    	{
		    	response = iNextStrategy2->ApplyL(aRequest,aUids,
		    									  aContinueSearch,
		    									  aClientResolver2);
		    	}
		    else
		    	{
		    	response = CreateResponseL();
		    	}
		    
		    }
		CleanupStack::PopAndDestroy(1); // scores
        }
    else
        {
        if (iNextStrategy)
            {
	        response = iNextStrategy->ApplyL(aRequest,aUids,aContinueSearch,
	        												aClientResolver2);
	        }
        }

    return response;
	}
// -----------------------------------------------------------------------------
// CContextEnginePluginTest::LoadPluginL
// -----------------------------------------------------------------------------
//
TInt CContextEnginePluginTest::LoadPluginL( CStifItemParser& /* aItem */ )
    {
    _LIT( KMsg1, "Enter LoadPlugins" );
    iLog->Log( KMsg1 );
    RDebug::Print( KMsg1 );
    
    iInitTarget = 2;
    
    TUid calendarContextUID = { 0x102823CB }; // calendar context plugin uid
    TUid locationContextUID = { 0x200071D0 }; // location context plugin uid
    
    RImplInfoPtrArray infoArray;
    	
	TCleanupItem cleanupItem( MdsUtils::CleanupEComArray, &infoArray );
	CleanupStack::PushL( cleanupItem );
	
	CContextPlugin::ListImplementationsL( infoArray );
	TInt count( 0 );
	count = infoArray.Count();
	
	TBool locationPluginFound( EFalse );
	TBool calendarPluginFound( EFalse );
	for ( TInt i=0; i < count; i++ )
		{
		TUid uid = infoArray[i]->ImplementationUid();
		
		// context plugin found
		if( uid == locationContextUID )
			{
			iLocationPlugin = CContextPlugin::NewL( uid );
			iLocationPlugin->SetMdeSession(*iMdEClient);
			iLocationPlugin->Init(*this);
			locationPluginFound = ETrue;
			iPlugin = iLocationPlugin;
			iPluginSet = ETrue;
			}		
		else if( uid == calendarContextUID )
	        {
	        iCalendarPlugin = CContextPlugin::NewL( uid );
	        iCalendarPlugin->SetMdeSession(*iMdEClient);
	        iCalendarPlugin->Init(*this);
	        calendarPluginFound = ETrue;
	        }   
		}
	
	CleanupStack::PopAndDestroy( &infoArray ); // infoArray, results in a call to CleanupEComArray
    
	if( !locationPluginFound )
	    {
	    _LIT( KLocation, "Location context plugin not found" );
	    iLog->Log( KLocation );
	    RDebug::Print( KLocation );
	    return KErrNotFound;
	    }
	
    if( !calendarPluginFound )
        {
        _LIT( KCalendar, "Calendar context plugin not found" );
        iLog->Log( KCalendar );
        RDebug::Print( KCalendar );
        return KErrNotFound;
        }
    
    _LIT( KMsg2, "Exit LoadPlugins" );
    iLog->Log( KMsg2 );
    RDebug::Print( KMsg2 );
    
    return KErrNone;
    }