예제 #1
0
LOCAL_C void CommonIdArrayTestsL(CContactIdArray& aIds,TInt aId)
	{
	TInt index=aIds.Find(aId);
	test(index!=KErrNotFound);
	for (TInt ii=0;ii<5;ii++)
		{
		aIds.MoveL(index,ii);
		test(aIds.Count()==5);
		const TInt newPos=aIds.Find(aId);
		test(newPos==ii);
		aIds.MoveL(newPos,index);
		test(aIds.Count()==5);
		test(aIds.Find(aId)==index);
		}
	aIds.Remove(index);
	test(aIds.Count()==4);
	aIds.InsertL(index,aId);
	test(aIds.Count()==5);
	test(aIds.Find(aId)==index);
	test(aIds[index]==aId);
	}
예제 #2
0
/*
	Creates a random array of numbers corresponding to the Contacts Id in the 
	Contacts model.  No Contact Id is repeated  
*/
void CDeleteMany::CreateRandomIdArrayL(CContactIdArray& aUids, TInt aNumIds, TInt aNumEntriesInDb)
	{
	TTime now;
	now.UniversalTime();
	TInt64 KRandomSeed = now.DateTime().MicroSecond();

	TInt uid(0);
	for(TInt i = 0; i < aNumIds; ++i)
		{
		uid = (Math::Rand(KRandomSeed) % aNumEntriesInDb) + 1;
		while(aUids.Find(uid) != KErrNotFound)
			{
			uid = (Math::Rand(KRandomSeed) % aNumEntriesInDb) + 1;
			}
		aUids.AddL(uid);		
		}
	}
예제 #3
0
/** 
Filter server-side view based on filter supplied by client.  The IDs of matching
contact items are externalized to the client-side.

@param aMessage.Int0() Filter (from client).
@param aMessage.Ptr1() Descriptor containing matching contact IDs (to client).
*/
void CViewSubSessionBase::GetContactsMatchingFilterL(const RMessage2& aMessage)
    {
    const TInt filter(aMessage.Int0());
    
    RArray<TContactIdWithMapping> array;
    CleanupClosePushL(array);
    TContactIdWithMapping idMap;

    const TInt viewCount(iView->CountL());
    if (filter & CContactDatabase::ECustomFilter3)
        {
        // CContactDatabase::ECustomFilter3 was used to filter the contacts 
        // which can be used in speed dial fetch dialog. 
        MLplCollection& collection = iViewManager.FactoryL().GetCollectorL();
        collection.Reset();
        CContactIdArray* speedDialIDArray = collection.FindSpeedDialContactsL();
        CleanupStack::PushL(speedDialIDArray);
       // Filter view contacts.
        for (TInt i=0;i<viewCount;++i)
	        {
	        const CViewContact& contact = iView->ContactAtL(i);
	        if(KErrNotFound !=speedDialIDArray->Find(contact.Id())) // Check if the contacts support speed dial.
	            {
	            idMap.iId=contact.Id();
	            idMap.iMapping=i;
	            User::LeaveIfError(array.Append(idMap));
	            }
	        }
        CleanupStack::PopAndDestroy(speedDialIDArray);
        }
        else
        {
        // Filter view contacts.
        for (TInt i=0;i<viewCount;++i)
            {
            const CViewContact& contact = iView->ContactAtL(i);
            if(contact.ContactMatchesFilter(filter))
                {
                idMap.iId=contact.Id();
                idMap.iMapping=i;
                User::LeaveIfError(array.Append(idMap));
                }
            }
        }

    // Externalize array to client.
    const TInt count(array.Count());
    const TInt maxBufSize = (1+(array.Count()*2))*sizeof(TInt);
    HBufC8* buf=HBufC8::NewLC(maxBufSize);
    TPtr8 bufPtr(buf->Des());
    RDesWriteStream writeStream(bufPtr);
    CleanupClosePushL(writeStream);
    writeStream.WriteUint32L(count);
    for (TInt j=0; j<count; ++j)
        {
        writeStream.WriteInt32L(array[j].iId);
        writeStream.WriteInt32L(array[j].iMapping);
        }
    bufPtr.SetLength(maxBufSize);
    aMessage.WriteL(1,*buf);
    CleanupStack::PopAndDestroy(3,&array);
    }