TInt CSenLayeredXmlProperties::PropertiesByTypeL(const TDesC8& aType,
                                                 RPointerArray<MSenProperty>& aArray)
    {
    TInt retVal(KErrNotFound);

    retVal = AllPropertiesByTypeL(aType, aArray);

    // Remove omitted values from the array.
    TInt propsCount = aArray.Count()-1;
    for (TInt i=propsCount; i>=0; i--)
        {
        CSenPropertiesElement* pElement = (CSenPropertiesElement*)aArray[i];
		const TDesC8* pAttrValue = pElement->AttrValue(KSenOmittedAttributeName);
		if ( pAttrValue )
            {
            if ( *pAttrValue == KSenOmittedTrueNoValue)
		        {
		        aArray.Remove(i);
                }
            else if ( *pAttrValue == KSenPropertyTrue)
                {
		        aArray.Remove(i);
                }
            }
        }
    
    if ( aArray.Count() > 0 )
        {
        retVal=KErrNone;
        }
    
    return retVal;
    }
// -----------------------------------------------------------------------------
// CFSMailMessage::AttachmentListL
// -----------------------------------------------------------------------------
EXPORT_C void CFSMailMessage::AttachmentListL(
    RPointerArray<CFSMailMessagePart>& aParts )
    {
    // First list all message parts
    AppendAttachmentsL( aParts );
    
    NM_FUNCTION;
    
    // special case, if single part content type is not given,
    // default type is text/plain
    if ( aParts.Count() == 1 && aParts[0]->GetContentType().Length() == 0)
        {
        aParts.ResetAndDestroy();
        }
    else
        {
        // find plain text body part from the list
        CFSMailMessagePart* txtPart = FindBodyPartL(KFSMailContentTypeTextPlain);
        CleanupStack::PushL( txtPart );
        if ( txtPart
          && txtPart->AttachmentNameL().Length() == 0 ) // real attachments have names
            {
            // remove plain text body part from attachment list
            for ( TInt ii = aParts.Count() - 1; ii >= 0; --ii )
                {
                if ( aParts[ii]->GetPartId() == txtPart->GetPartId() )
                    {
                    delete aParts[ii];
                    aParts.Remove(ii);
                    break;
                    }
                }
            }
        CleanupStack::PopAndDestroy( txtPart );

        // find  html body part from the list
        CFSMailMessagePart* htmlPart = FindBodyPartL(KFSMailContentTypeTextHtml);
        CleanupStack::PushL( htmlPart );
        if ( htmlPart
          && htmlPart->AttachmentNameL().Length() == 0 ) // real attachments have names
            {
            // remove html body part from attachment list
            for ( TInt ii = aParts.Count() - 1; ii >= 0; --ii )
                {
                if ( aParts[ii]->GetPartId() == htmlPart->GetPartId() )
                    {
                    delete aParts[ii];
                    aParts.Remove(ii);
                    break;
                    }
                }
            }
        CleanupStack::PopAndDestroy( htmlPart );
        }

    iMessageParts.ResetAndDestroy();
    iReadMessageParts = ETrue;
    }
// -----------------------------------------------------------------------------
// CSIPProfileRegistryBase::StoreProfileL
// -----------------------------------------------------------------------------
//
void CSIPProfileRegistryBase::StoreArrayL(
	RPointerArray<CSIPConcreteProfile>& aProfiles,
	RPointerArray<CSIPProfile>& aRetProfiles)
	{
	int count = aProfiles.Count();

	for (TInt i = 0; i < count; i++)
		{
		TUint profileId = (aProfiles[0])->Id();
		TInt index = ProfileIndex(profileId);
		
		CSIPProfileCleanupItem* cleanupItem = new (ELeave) CSIPProfileCleanupItem(iITC);
		CleanupStack::PushL(cleanupItem);

		if(index == KErrNotFound) 
			{
			CleanupStack::PushL(TCleanupItem(CrashRevert, cleanupItem));

			cleanupItem->iProfileId = (aProfiles[0])->Id();
			cleanupItem->iConcreteProfile = aProfiles[0];
			aProfiles.Remove(0);

			StoreProfileL(cleanupItem);
			User::LeaveIfError(aRetProfiles.Append(cleanupItem->iManagedProfile));
			}
		else
			{
			CleanupStack::PushL(TCleanupItem(LocalCrashRevert, cleanupItem));

			CSIPProfileItem* item = ProfileItemL(profileId);
			CSIPProfile* managed = NewInstanceL();
			cleanupItem->iManagedProfile = managed;
			managed->SetConcreteProfile(&(item->ConcreteProfile()));
			managed->SetEnabled(item->IsEnabled());
			item->IncrementReferenceCountL(*managed);
			User::LeaveIfError(aRetProfiles.Append(managed));
			CSIPConcreteProfile* profileNotUsed = aProfiles[0];
			aProfiles.Remove(0);
			delete profileNotUsed;
			}
		}
	aProfiles.Reset();

	for (TInt j = 0; j < count; j++)
		{
		CleanupStack::Pop(); //TCleanupItem
		CleanupStack::PopAndDestroy(); //cleanupItem
		}
	}
//1. make a copy(A) of supported oids
//2. set supported oids to list from config
//3. reset supported oids
//4. get supported oids(B)
//5. iterate over B, find and remove first match in A.  if not found we error
//6. if A is not empty we error
void CPkixCertResetSupportedOidsStep::PerformTestL()
	{
	CPkixCertStepBase::PerformTestL();
	
	//1. make a copy(A) of supported oids
	const RPointerArray<TDesC>& suppOids = iCertChain->SupportedCriticalExtensions();	
	//CleanupClosePushL(suppOids);	//don't need to do this as a ref and done in stepbase destructor
	RPointerArray<HBufC> startSuppOids;
	CleanupResetAndDestroy<RPointerArray<HBufC> >::PushL(startSuppOids);
		
	HBufC* des;
	TInt i;
	for (i=0; i < suppOids.Count(); ++i)
		{
		des = (suppOids[i])->AllocLC();
		startSuppOids.AppendL(des);
		CleanupStack::Pop(des);
		}

	//2. set supported oids to list from config
	iCertChain->SetSupportedCriticalExtensionsL(iProcessedOids);
	//3. reset supported oids
	iCertChain->ResetSupportedCriticalExtsToDefaultL();
	//4. get supported oids(B)
	const RPointerArray<TDesC>& suppOids2 = iCertChain->SupportedCriticalExtensions();
	
	//5. iterate over B, find and remove first match in A.  if not found we error
	TBool found;
	for (i=0; i < suppOids2.Count(); ++i)
		{
		found = EFalse;
		for (TInt j=0; j < startSuppOids.Count(); ++j)
			{
			if ((*suppOids2[i]) == (*startSuppOids[j]))
				{
				found = ETrue;
				delete (startSuppOids[j]);
				startSuppOids.Remove(j);
				break;
				}
			}
		if (!found)	
			{
			ERR_PRINTF2(_L("ERROR: Extra OID found in result: %S"), suppOids2[i]);
			User::Leave(KErrGeneral);
			}
		}
		
	//6. if A is not empty we error
	if (startSuppOids.Count() != 0)
		{
		for (TInt j=0; j < startSuppOids.Count(); ++j)
			{	
			ERR_PRINTF2(_L("ERROR: OID missing from result: %S"), startSuppOids[j]);
			}
		User::Leave(KErrGeneral);
		}		
	
	CleanupStack::PopAndDestroy(2, iCertChain);	
	}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CCaUsifScanner::FindDeletedEntriesL(
        RPointerArray<CCaInnerEntry>& aCaArray, const RPointerArray<
                CComponentEntry>& aUsifArray )
    {
    for( TInt i( aCaArray.Count() - 1 ); i >= 0; i-- )
        {
        TBuf<KMaxUnits> compIdDes;
        if( aCaArray[i]->FindAttribute( KCaAttrComponentId, compIdDes ) )
            {
            TLex lex( compIdDes );
            TUint uint( 0 );
            User::LeaveIfError( lex.Val( uint ) );
            //for each usif entry check if entry has to be removed
            for( TInt k( 0 ); k < aUsifArray.Count(); k++ )
                {
                if( aUsifArray[k]->ComponentId() == uint)
                    {
                    delete aCaArray[i];
                    aCaArray.Remove( i );
                    break;
                    }
                }
            }
        }
    }
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
TInt CPolicyClientRequestHandler::RemovePolicyUid(RPointerArray<CClientControlPolicy>& aPolUid, TUint aAction, const TUid aUid)
	{
	CClientControlPolicy* tUid = NULL;
	
	TInt policyCount = aPolUid.Count();
	for(TInt i = 0; i < policyCount; i++)
		{
		tUid = aPolUid[i];
		if(tUid->iUid == aUid)
			{
			TInt err = RemovePolicyInfo(tUid->iControlPolicies, aAction, EFalse);
			if ( err == KErrNone)
				{
				if(tUid->iControlPolicies.Count() == 0)
					{
					delete tUid;
					tUid = NULL;
					aPolUid.Remove(i);
					}
				return err;
				}
			}
		}
	return KErrNotFound;
	}
/**
* Delete all Instances in the calendar file 
*/
void CTestCalInterimApiModifier::DeleteInstancesL()
	{
 	CCalInstanceView* instanceView = CCalInstanceView::NewL(GetSession(), *this);
	CleanupStack::PushL(instanceView);
	CActiveScheduler::Start();
	TInt err;
	RPointerArray<CCalInstance>	instanceArray;
	TCalTime	calStartDateTime;
	calStartDateTime.SetTimeLocalL(TCalTime::MinTime());
	TCalTime	calEndDateTime;
	calEndDateTime.SetTimeLocalL(TCalTime::MaxTime());
	CalCommon::TCalTimeRange	calTimeRange(calStartDateTime, calEndDateTime);

	CleanupStack::PushL(TCleanupItem(ResetAndDestroyInstanceArray, &instanceArray));
	instanceView->FindInstanceL(instanceArray, CalCommon::EIncludeAll, calTimeRange);
	if(instanceArray.Count() != 0)
		{
		TRAP(err, instanceView->DeleteL(instanceArray[0], CalCommon::EThisAndAll));
		instanceArray.Remove(0);
		if(err != KErrNone)
			{
			iTestStep->ERR_PRINTF2(KErrDeleteOperation,err);
			iTestStep->SetTestStepResult(EFail);
			}
		}
	else
		{
		iTestStep->WARN_PRINTF1(KWarnInstancesNotFound);
		}
		
	CleanupStack::PopAndDestroy();// instanceArray
	CleanupStack::PopAndDestroy(); // instanceView
	}
// -----------------------------------------------------------------------------
// CMceComAudioStream::UpdateL
// -----------------------------------------------------------------------------
//
void CMceComAudioStream::UpdateL( CMceComMediaStream& aStream )
    {  
    CMceComMediaStream::UpdateL( aStream );

    CMceComAudioStream* stream = static_cast<CMceComAudioStream*>( &aStream );
    
    RPointerArray<CMceComAudioCodec> updated;
    
    MceCleanupResetAndDestroyPushL( updated );

    for ( TInt i = 0 ; i < stream->CodecCount() ; ++i )
        {
        CMceComAudioCodec* update = stream->CodecL( i );
        TBool isUpdated = EFalse;
        TInt j = 0;

        while( !isUpdated && j < CodecCount() )
            {
            CMceComAudioCodec* codec = CodecL( j );
            if ( codec->Id() == update->Id() )
                {
                codec->UpdateL( *update );
                stream->RemoveCodecFromListL( i );
                delete update;
                updated.AppendL( codec );
                RemoveCodecFromListL( j );
                i--;
                isUpdated = ETrue;
                }
            j++;
            }
        }
        
    if ( CodecCount() > 0 )	//	Codecs have been removed
        {
        Session()->IsStructureChanged() = ETrue;
        }
        
    DestroyCodecs();
    
    while( updated.Count() > 0 )
        {
        AddCodecL( updated[0] );
        updated.Remove( 0 );
        }
        
    CleanupStack::PopAndDestroy();	// updated
            
    if ( stream->CodecCount() > 0 )	// Streams have been added
        {
        Session()->IsStructureChanged() = ETrue;
            
        while( stream->CodecCount() > 0 )
            {
            CMceComAudioCodec* add = stream->CodecL( 0 );
            AddCodecL( add );
            stream->RemoveCodecFromListL( 0 );
            }
        }
    }
/**
Delete user-defined time zones.

@SYMTestCaseID 	PIM-APPSERV-TZS-CO-0003

@SYMTestCaseDesc
	The purpose of this test is to verify that user-defined time zones can be
	deleted.

@SYMTestActions  
	1.	Get all existing user-defined time zones.
	2.	Delete the user-defined time zone as the last element in the array one
		by one.
	3.	Try to read the user-defined time zone deleted in action 2.

@SYMTestExpectedResults
	The user-defined time zone does not exist.

@SYMTestType
	CT

@SYMTestPriority
	1
*/
void CTzUserDataTest::TestDeleteUserDefinedTzL()	
	{
	test.Next(_L("@SYMTestCaseID  PIM-APPSERV-TZS-CO-0003"));
	RPointerArray<CTzId> ids;
	CleanupStack::PushL(TCleanupItem(ResetAndDestroyTzIdArray, &ids));

	for(TInt ii=iTzIds.Count()-1; ii>=0; --ii)
		{
		iUserData->GetTzIdsL(ids);
		
		// The array obtained should be same as expected who elements is deleted
		// one by one in each loop.
		CompareArray(ids,iTzIds);
		ids.ResetAndDestroy();
		
		// Delete the user-defined time zone as the last element in the array.
		iUserData->DeleteL(*(iTzIds[ii]));
		
		// The rule and names of the last element in the array should not be
		// found since it has been deleted.
		TRAPD(err, iUserData->ReadRulesL(*(iTzIds[ii])));
		test(err == KErrNotFound);
		TRAP(err, iUserData->ReadNamesL(*(iTzIds[ii])));
		test(err == KErrNotFound);

		delete iTzIds[ii];
		iTzIds.Remove(ii);
		}

	CleanupStack::PopAndDestroy(&ids);
	}
// ==========================================================================
// METHOD:  DoReleaseLogFileHandler
//
// DESIGN:  
// ==========================================================================
void CDebugLogTlsData::DoReleaseLogFileHandler( CLogFileHandler* aHandler, RDebugLog* aObject )
    {
    TInt index = aHandler->iObjects.FindL( aObject );
    
    if( index >= 0 )
        {
//#ifdef __MAKE_COPY_OF_NAMES
        delete aHandler->iObjectNames[index];
        aHandler->iObjectNames.Remove(index);
//#endif        
        aHandler->iObjects.Remove( index );
        
        if( aHandler->iObjects.Count() == 0 )
            {
            iFiles.Remove( iFiles.Find(aHandler) );
            delete aHandler;
            } // end if
        }
    else
        {        
        // Something is wrong.  The most likely case is incorrect usage of the debug log macros.
        _LIT8( KDummyFuncName, "***" );
        _LIT8( KErrorText, "INCORRECT DEBUG LOG USAGE!" );
        
        aObject->Write( KDummyFuncName, KErrorText );        
        }
        
    } // END DoReleaseLogFileHandler
// ---------------------------------------------------------------------------
// Pop and destroy a dir entry from a dir entry queue
// ---------------------------------------------------------------------------
//
void CMPXFolderScanner::CDirQueueEntry::PopAndDestroy(
                                  RPointerArray< CDirQueueEntry >& aDirQueue )
    {
    CDirQueueEntry* entry = aDirQueue[ 0 ];
    delete entry;
    aDirQueue.Remove( 0 );
    }
void CGlxMediaListsTestCollectionPlugin::RemoveItemL(const TGlxMediaId& aId, RPointerArray<CItem>& aDatabase)
	{
	TIdentityRelation<CItem> match(&MatchById);
	CItem* mediaToCompare = new (ELeave) CItem();
	CleanupStack::PushL(mediaToCompare);
	mediaToCompare->iId = TGlxMediaId(aId);
	TInt index = aDatabase.Find(mediaToCompare, match);
	delete aDatabase[index];
	aDatabase.Remove(index);
	CleanupStack::PopAndDestroy(mediaToCompare);
	}
// ---------------------------------------------------------
// CSyncMLHistoryPushMsg::AddAlertsL(RPointerArray<CSmlAlertInfo>& aAlertInfoArray)
// Adds alerts to entry
// Ownership of CSmlAlertInfo objects is transferred.
// ---------------------------------------------------------
EXPORT_C void CSyncMLHistoryPushMsg::AddAlertsL(RPointerArray<CSmlAlertInfo>& aAlertInfoArray)
{
    ResetAlerts();

    while ( aAlertInfoArray.Count() )
    {
        CSmlAlertInfo* temp = aAlertInfoArray[0];
        iAlerts.AppendL( temp );
        aAlertInfoArray.Remove(0);
    }

}
void CPresenceDataCache::RemoveMeFromArray( RPointerArray< Type >& aItemArray, Type* aChild )
{
    TInt itemCount( aItemArray.Count() );
    for ( TInt i( 0 ); i < itemCount; i++ )
    {
        if ( aChild == aItemArray[ i ] )
        {
            aItemArray.Remove( i );
            break;
        }
    }
}
Exemple #15
0
void CCmdFind::DoRunL()
	{
	RFs& fs = FsL();
	iPath.SetIsDirectoryL();
	if (!iName)
		{
		LeaveIfErr(KErrArgument, _L("You must specify a name to match against"));
		}

	iSearchDirs.AppendL(iPath.AllocLC());
	CleanupStack::Pop();

	while (iSearchDirs.Count())
		{
		const TDesC& path = *iSearchDirs[0];

		TInt err;
		CDir* matchingFiles = NULL;
		iTempName.Copy(path);
		iTempName.AppendComponentL(*iName, TFileName2::EFile);
		// Look for files in this directory first
		err = fs.GetDir(iTempName, KEntryAttNormal|KEntryAttDir, ESortByName, matchingFiles);
		if (!err)
			{
			for (TInt i = 0; i < matchingFiles->Count(); i++)
				{
				const TEntry& entry = (*matchingFiles)[i];
				FoundFile(path, entry.iName, entry.IsDir());
				}
			}
		delete matchingFiles;

		// Then add all this dir's subdirectories to the list of ones to be scanned
		CDir* dirsToRecurse = NULL;
		err = fs.GetDir(path, KEntryAttDir|KEntryAttMatchExclusive, ESortNone, dirsToRecurse);
		if (!err)
			{
			CleanupStack::PushL(dirsToRecurse);
			for (TInt i = 0; i < dirsToRecurse->Count(); i++)
				{
				const TEntry& entry = (*dirsToRecurse)[i];
				iTempName.Copy(path);
				iTempName.AppendComponentL(entry);
				iSearchDirs.AppendL(iTempName.AllocLC());
				CleanupStack::Pop();
				}
			CleanupStack::PopAndDestroy(dirsToRecurse);
			}
		delete iSearchDirs[0];
		iSearchDirs.Remove(0);
		}
	}
// -----------------------------------------------------------------------------
// TMccResourceContainerIterator::Delete
// -----------------------------------------------------------------------------
//
TInt TMccResourceContainerIterator::Delete( RPointerArray<CMccResourceContainer>& aContainers )
    {
    TInt currentIndex = Current();
    
    if ( currentIndex != KErrNotFound && currentIndex < aContainers.Count() )
        {
        delete aContainers[ currentIndex ];
        aContainers.Remove( currentIndex );
        iCurrentIndex = currentIndex;
        }
    
    return currentIndex;
    }
void CHuiFxEffectCache::Remove(RPointerArray<MHuiFxEffectCacheNode> &aEffects, MHuiFxEffectCacheNode *aNode)
    {
    TInt size = aEffects.Count();
    for(TInt i=0;i<size;i++)
        {
        MHuiFxEffectCacheNode *node = aEffects[i];
        if (node == aNode)
            {
            aEffects.Remove(i);
            return;
            }
        }
    }
/** Uid instance iterator ConstructL

Fetches all the related entries to the UID and sets the currently indexed time

@internalComponent
*/
void CCalInstanceIteratorUid::ConstructL(const TDesC8& aUid, const TCalTime& aInstanceTime, TCalCollectionId aCollectionId)
	{
	// record the time to use for undated todos
	TTime now;
	now.HomeTime();
	iUndatedTodoTime.SetTimeLocalL(now);
	
	// Fetch all the entries that relate to the instance
	RPointerArray<CAgnSimpleEntry> simpleEntries;
	TCleanSimpleEntryArray cleanSimpleEntryArray(simpleEntries, iInstanceViewImpl.GetServ());
	CleanupStack::PushL(TCleanupItem(CCalInstanceViewImpl::DestroySimpleEntryArray, &cleanSimpleEntryArray));
	RArray<TInt> fileIds;
	iInstanceViewImpl.GetShortFileIdLC(fileIds);//It is in order 
	iInstanceViewImpl.GetServ().FetchSimpleEntriesByGuidL(aUid, simpleEntries, fileIds);
	CleanupStack::PopAndDestroy(&fileIds);
	
	const TInt KEntryCount(simpleEntries.Count());
	
	// There must be entries associated with this UID
	__ASSERT_ALWAYS(KEntryCount != 0, User::Leave(KErrNotFound));
	
	TBool instanceExists(EFalse);
	
	for (TInt i(0) ; i < KEntryCount ; ++i)
		{
		CCalLiteEntry* liteEntry = CCalLiteEntry::NewL(*simpleEntries[0], iInstanceViewImpl.GetServ());
		liteEntry->IncrementRefCount();
		simpleEntries.Remove(0);
		TInt appendError = iCalLiteEntries.Append(liteEntry);	
		if (appendError != KErrNone)
			{
			liteEntry->DecrementRefCount();
			User::Leave(appendError);
			}
		
		if (iInstanceViewImpl.IsValidInstanceL(liteEntry->LiteEntry(), aInstanceTime))
			{//Add the index of the entry which has the same time as aInstanceTime into iEntryWithSameTime
			if(liteEntry->LiteEntry().CollectionId() == aCollectionId)
				{
				instanceExists = ETrue;
				iCurrentIndexTime = aInstanceTime;
				iCurrentIndex = iEntryWithSameTime.Count();
				}
			iEntryWithSameTime.AppendL(i);
			}
		}
	
	__ASSERT_ALWAYS(instanceExists, User::Leave(KErrNotFound));
	CleanupStack::PopAndDestroy(); // simpleEntries
	}
Exemple #19
0
EXPORT_C TInt DIicBusController::DeRegisterChannel(DIicBusChannel* aChannel)
	{
// To be used by Channel implementations to deregister a channel
    __KTRACE_OPT(KIIC, Kern::Printf("DIicBusController::DeRegisterChannel, aChannel=0x%x\n",aChannel));
	if(aChannel == NULL)
		return KErrArgument;

	RPointerArray<DIicBusChannel>* chanArray = TheController->ChannelArray();

#ifdef IIC_INSTRUMENTATION_MACRO
	IIC_DEREGISTERCHAN_START_PIL_TRACE;
#endif
	TInt r=KErrNone;
	// Get access to the channel pointer array - exit if it is currently unavailable
	// Gaining write access will prevent a client of a Master Channel from instigating a new QueueTransaction
	// (or CancelTransaction), and it will obstruct a client of a Slave Channel in CaptureChannel.
	if((r=TheController->GetChanWriteAccess())!=KErrNone)
		return r;

	// Check channel is registered
	TInt chanIndex = chanArray->FindInOrder(aChannel,EntryOrder);
	if(chanIndex<0)
		{
		TheController->FreeChanWriteAccess();
		return KErrNotFound;
		}

#ifdef _DEBUG
    __KTRACE_OPT(KIIC, Kern::Printf("DIicBusController::DeRegisterChannel - On entry, iChannelArray ...\n"));
	TheController->DumpChannelArray();
#endif

	// Remove the channel from the array
	// Note that this does not delete the channel object
	chanArray->Remove(chanIndex);

#ifdef _DEBUG
    __KTRACE_OPT(KIIC, Kern::Printf("DIicBusController::DeRegisterChannel - On exit, iChannelArray ...\n"));
	TheController->DumpChannelArray();
#endif
	TheController->FreeChanWriteAccess();

#ifdef IIC_INSTRUMENTATION_MACRO
	IIC_DEREGISTERCHAN_END_PIL_TRACE;
#endif
	return KErrNone;
	}
Exemple #20
0
/**
 * Takes a collection of package details and instantiates CUninstallationNode objects
 * (uninstallation node) in a pending state, adding them to the uninstallation tree.
 * 
 * @param aProcessPackages Collection of package details to be added to the tree structure for planning.
 * @param aParentNode Takes ownership of the resulting CUninstallationNode objects.
 * @param aPlannedPackages List of planned packages. This variable is used to avoid creation of duplicate 
 * 			nodes in the tree. 
 */
void CPlanner::CreateNewNodesL(RPointerArray<CSisRegistryPackage>& aProcessPackages, CUninstallationNode& aParentNode, RPointerArray<CSisRegistryPackage>& aPlannedPackages)
	{
	// We are removing items from array (aProcessPackages)and thus require index 
	// adjustment. But if loop run in reverse order there is no need to adjust the index
	for (TInt i = aProcessPackages.Count() - 1; i >= 0; --i)
		{
		// Ignore already added package
		if (IsInPlannedPackages(aPlannedPackages, *aProcessPackages[i]))
			{
			continue;
			}
		RSisRegistryWritableEntry registryEntry;
		TRAPD(retValue, retValue = registryEntry.OpenL(iRegistrySession, *aProcessPackages[i]));
		if( (KErrNotFound == retValue) || (KErrPathNotFound == retValue))
			{
			// The package has already been removed.
			continue;
			}
		User::LeaveIfError(retValue);
		CleanupClosePushL(registryEntry);
	
		if (registryEntry.IsInRomL())
			{
			DEBUG_PRINTF2(_L8("Failed to plan this package for uninstall. Is in ROM; Uid: '0x%08x'"),aProcessPackages[i]->Uid().iUid);
			CleanupStack::PopAndDestroy(&registryEntry);
			continue;
			}
				
		// Don't remove non-removable packages except:-
		// non-removable patches (SP+NR) where the base is is the root package being uninstalled 
		if (!registryEntry.RemovableL() && 
			!(aParentNode.PackageL().Uid() == registryEntry.UidL() && registryEntry.IsAugmentationL()))
			{
			DEBUG_PRINTF2(_L("Cannot uninstall non-removable application; Uid: '0x%08x'"),aProcessPackages[i]->Uid().iUid);
			CleanupStack::PopAndDestroy(&registryEntry);
			continue;	
			}
	
		CUninstallationNode* newNode = CUninstallationNode::NewLC(registryEntry, *aProcessPackages[i]);
		aParentNode.AddNodeAsChildL(newNode);
		CleanupStack::Pop(newNode);
		aPlannedPackages.AppendL(aProcessPackages[i]);
		// Ownership is transfered from aProcessPackages to aPlannedPackages
		aProcessPackages.Remove(i);
		CleanupStack::PopAndDestroy(&registryEntry);
		}
	}
TInt CPolicyClientRequestHandler::RemovePolicyUid(RPointerArray<TControlPolicy>& aAddedPolicies, TUint aAction, const TUid aUid)
	{
	TControlPolicy* tUid = NULL;

	TInt policyCount = aAddedPolicies.Count();
	for(TInt i = 0; i < policyCount; i++)
		{
		tUid = aAddedPolicies[i];
		if(tUid->iId == aUid && tUid->iAction == aAction)
			{
			delete tUid;
			tUid = NULL;
			aAddedPolicies.Remove(i);
			return KErrNone;
			}
		} 
	return KErrNotFound;
	}
/*
Print out current tree content
*/
void CLeafDirTree::DumpTreeContentL() const
	{
	RPointerArray<CLeafDirTreeNode>* nodeStack = new(ELeave) RPointerArray<CLeafDirTreeNode>(4);
	RFs fs;
	
    TInt nRes = fs.Connect();
    User::LeaveIfError(nRes);

	const TUint32 debugRegister = DebugRegister();
	fs.SetDebugRegister(debugRegister|KFSYS);
	if (iRoot != NULL)
		{
		nodeStack->Insert(iRoot, 0);
		while(nodeStack->Count() > 0)
			{
			CLeafDirTreeNode* current = (*nodeStack)[0];
			if (current->Parent() != NULL)
				{
				__PRINT3(_L("(\"%S\") -> \"%S\" : (%d)\n"), &current->Parent()->Path(), &current->Path(), current->StartClusterNum());
				}
			else
				{
				__PRINT2(_L("\"%S\" : (%d)\n"), &current->Path(), current->StartClusterNum());				
				}

			nodeStack->Remove(0);
			
			TInt currentCount = current->Children().Count();
			if (currentCount > 0)
				{
				RPointerArray<CLeafDirTreeNode> children = current->Children();
				for (TInt i = 0; i < currentCount; i++)
					{
					nodeStack->Insert(children[i], 0);
					}
				}
			}
		}

	fs.SetDebugRegister(debugRegister);
	fs.Close();
	nodeStack->Close();
	delete nodeStack;
	}
// ---------------------------------------------------------
// CPosLmDatabaseManagerImpl::ListDatabasesL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosLmDatabaseManagerImpl::ListDatabasesL(
    RPointerArray<HPosLmDatabaseInfo>& aDatabaseInfoArray,
    const TDesC& aProtocol)
    {
    if (aProtocol == KNullDesC)
        {
        TInt pluginCount = iPlugins->NumberOfInstances();
        for (TInt i = 0; i < pluginCount; i++)
            {
            if (i == 0)
                {
                CPosLmDatabaseManagerPluginBase* plugin =
                    iPlugins->GetInstanceAt(i);
                plugin->ListDatabasesL(aDatabaseInfoArray);
                FillInDbInfoListL(aDatabaseInfoArray, plugin);
                }
            else
                {
                RPointerArray<HPosLmDatabaseInfo> dbList;
                CleanupStack::PushL(TCleanupItem(CleanupPointerArray, &dbList));
                CPosLmDatabaseManagerPluginBase* plugin =
                    iPlugins->GetInstanceAt(i);
                plugin->ListDatabasesL(dbList);
                FillInDbInfoListL(dbList, plugin);
                TInt dbCount = dbList.Count();
                for (TInt j = 0; j < dbCount; j++)
                    {
                    // transfer ownership instead of copy object
                    User::LeaveIfError(aDatabaseInfoArray.Append(dbList[0]));
                    dbList.Remove(0);
                    }
                CleanupStack::PopAndDestroy(&dbList);
                }
            }
        }
    else
        {
        CPosLmDatabaseManagerPluginBase* plugin =
            iPlugins->GetInstanceL(aProtocol);
        plugin->ListDatabasesL(aDatabaseInfoArray);
        FillInDbInfoListL(aDatabaseInfoArray, plugin);
        }
    }
Exemple #24
0
// -----------------------------------------------------------------------------
// MceSip::ToContactHeaderL
// -----------------------------------------------------------------------------
//
CSIPContactHeader* MceSip::ToContactHeaderL( const TDesC8& aContact )
    {
    CSIPContactHeader* contact = NULL;
    
    RPointerArray< CSIPContactHeader > contacts = CSIPContactHeader::DecodeL( aContact );
    if ( contacts.Count() > 0 )
        {
        contact = contacts[0]; 
        contacts.Remove(0);
        contacts.ResetAndDestroy();
        }
    else
        {
        contacts.Close();
        User::Leave( KErrNotFound );
        }
        
    return contact;
    
    }
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
TInt CPolicyClientRequestHandler::RemovePolicyInfo(RPointerArray<CActionPolicy>& aPolInfo, TUint aAction, TBool aDelete)
	{
	CActionPolicy* tPol = NULL;
	TInt polInfoCount = aPolInfo.Count();
	
	for(TInt i = 0; i < polInfoCount; i++)
		{
		tPol = aPolInfo[i];
		if(tPol->iAction == aAction)
			{
			if(aDelete)
				{
				delete tPol;
				tPol = NULL;
				}
			aPolInfo.Remove(i);
			return KErrNone;
			}
		}
	return KErrNotFound;
	}
// -----------------------------------------------------------------------------
// CPIMAgnListAdapter::FetchNativeEntryL
// Fetches an entry according to a PIM item id.
// Returns: A calendar entry.
//          The ownership of the item is transferred to the caller.
// -----------------------------------------------------------------------------
//
CCalEntry* CPIMAgnListAdapter::FetchNativeEntryL(TPIMItemID aItemId,
        CCalEntry::TType aEntryType)
{
    JELOG2(EPim);
    EnsureOpenSessionL();
    __ASSERT_ALWAYS(aItemId != KPIMNullItemID, User::Leave(KErrArgument));

    RPointerArray<CCalEntry> entryArray;
    CleanupResetAndDestroyPushL(entryArray);
    iCalEntryView->FetchL(aItemId, entryArray);

    // Only one entry should be returned. NOTE that if there is no items
    // in the fetched array it means that the item might have been removed
    // so, we MUST NOT panic here as we did previously...
    __ASSERT_ALWAYS(entryArray.Count() > 0 && entryArray[0]->EntryTypeL()
                    == aEntryType, User::Leave(KErrNotFound));

    CCalEntry* entry = entryArray[0];
    // Take the ownership of the first item. Child instances are simply ignored
    entryArray.Remove(0);
    CleanupStack::PopAndDestroy(&entryArray);
    return entry;
}
Exemple #27
0
EXPORT_C void CEnvironment::GetKeysL(RPointerArray<HBufC>& aResult) const
	{
	WaitLC();
	aResult.ResetAndDestroy();
	TStringHashIter<HBufC*> iter(iConstVars);
	while (iter.NextValue() != NULL)
		{
		if (*iter.CurrentValue() != NULL)
			{
			HBufC* key = iter.CurrentKey()->AllocLC();
			aResult.AppendL(key);
			CleanupStack::Pop(key);
			}
		}
	
	if (iParentEnv)
		{
		RPointerArray<HBufC> parentKeys;
		LtkUtils::CleanupResetAndDestroyPushL(parentKeys);
		iParentEnv->GetKeysL(parentKeys);
		for (TInt i = parentKeys.Count()-1; i >= 0; i--)
			{
			HBufC* key = parentKeys[i];
			if (iConstVars.Find(*key) == NULL)
				{
				// Only add stuff in parent that isn't also in ours
				aResult.AppendL(key);
				parentKeys.Remove(i);
				}
			}
		CleanupStack::PopAndDestroy(&parentKeys);
		}

	// Make sure the resulting array is alphabetic, as RStringHash doesn't guarantee that (unlike RVarSet)
	aResult.Sort(TLinearOrder<HBufC>(&StringCompare));
	CleanupStack::PopAndDestroy(); // Release lock
	}
TCalLocalUid CDstIntUtils::ImportVCalL(RFs& aFs, CCalSession& aSession, CCalEntryView& aEntryView, const TDesC& aFileName)
	{
	RFileReadStream readStream;
	User::LeaveIfError(readStream.Open(aFs, aFileName, EFileRead));
	CleanupClosePushL(readStream);

	// Create ptr array for new entries
	RPointerArray<CCalEntry> entryArray;
	CleanupStack::PushL(TCleanupItem(ResetAndDestroyArrayOfEntries, &entryArray));

	CCalDataExchange* dataExchange = CCalDataExchange::NewL(aSession);
	CleanupStack::PushL(dataExchange);
	dataExchange->ImportL(KUidVCalendar, readStream, entryArray);

	TInt elements = entryArray.Count();
	TCalLocalUid id = 0;

	if(elements > 0)
		{
		CCalEntry* entry = entryArray[0];
		// add the first entry only
		while (entryArray.Count() > 1)
			{
			delete entryArray[1];
			entryArray.Remove(1);
			}
		TInt success = 0;
		aEntryView.StoreL(entryArray, success);
		id = entryArray[0]->LocalUidL();
		}

	CleanupStack::PopAndDestroy(dataExchange);
	CleanupStack::PopAndDestroy();	// ResetAndDestroyArrayOfEntries(entryArray)
	CleanupStack::PopAndDestroy();	// readStream.Close()

	return id;
	}
/** list all the child part to this part 
    /note This method leaves with KErrNotSupported if it is NOT multi-part.
*/
EXPORT_C void CMsgStoreMessagePart::ChildPartsL( RPointerArray<CMsgStoreMessagePart>& aParts )
{
	
	TPartsArray partsArray( iContext, iMailBoxId, aParts );
	
	iContext.iSession.ChildrenPropertiesL( iId,               // aId
	                                       iParentId,         // aParentId
	                                       EMsgStorePartBits, // aContainerType
	                                       EFalse,            // aQuickProperties
	                                       EFalse,            // aRecursive	                                        	                                        
	                                       partsArray );	
	
	// make sure body come before attachments
	TInt count = aParts.Count(); 
	if ( count > 1 )
		{
		for ( TInt i = 0 ; i < count; i++ )
			{
			CMsgStoreMessagePart* part = aParts[i];
			TUint index = 0;
			if ( part->FindProperty( KMsgStorePropertyContentType, index ) )
				{
				const TDesC& contentType = part->PropertyValueDesL( index );
				if ( contentType == KFSMailContentTypeMultipartAlternative )
					{
						if( i > 0 )  
							{
							//body is not the first child, move it to the first place
							aParts.Remove(i);
							aParts.InsertL( part, 0 );
							}
						break;
					}
				}
			}
		}
}
Exemple #30
0
/**
 * This function manages the creation of uninstallation tree where each node 
 * corresponds to a package which may be uninstalled. 
 * 
 * @param aRootNode Root package to be uninstalled.
 */
void CPlanner::CreateUninstallationTreeL(CUninstallationNode& aRootNode)
	{
	RPointerArray<CUninstallationNode> unprocessedTreeNodes;
	CleanupClosePushL(unprocessedTreeNodes);
	
	CUninstallationNode* currentNode = &aRootNode;
	
	// PlannedPackages is used to avoid duplicate node in the uninstallation
	// tree.
	RPointerArray<CSisRegistryPackage> plannedPackages;
	CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(plannedPackages);

	// Add the root node in the planned packages, so that it is not added again (as a node in the tree)
	// in case of a cyclic dependency.	
	CSisRegistryPackage* rootPackage = CSisRegistryPackage::NewL(currentNode->PackageL());
	plannedPackages.AppendL(rootPackage);
	
	while(ETrue)
		{
		// plannedPackages is used to avoid creation of duplicate nodes in the tree
		CreateChildNodesL(*currentNode, plannedPackages);
		// After processing currentNode its child nodes should be processed.
		// Therefore append child nodes of currentNode to unprocessedTreeNodes
		AppendArrayL(unprocessedTreeNodes, currentNode->ChildNodes());
		TInt index = unprocessedTreeNodes.Count() - 1;
		if(index < 0)
			{
			break;
			}
		// Here we are processing the array from the end to make it a "Depth First Search"
		currentNode = unprocessedTreeNodes[index];
		unprocessedTreeNodes.Remove(index);
		}
	CleanupStack::PopAndDestroy(&plannedPackages);	
	CleanupStack::PopAndDestroy(&unprocessedTreeNodes);
	}