Пример #1
0
/* In this section, we edit the desired number of groups in the database
 * Set label for them and associate them with desired number of groups
 * With this database updation, group views can be constructed and accessed
 */
void CTestContactViewDatabaseUtilitiesStep::IterateThroAllGroupSectionsAndUpdateL()
	{
	_LIT(KListOfGroupsSectionsString, "listofgroupsections");
	TPtrC listOfGroupsSectionsString;
	GetStringFromConfig(ConfigSection(), KListOfGroupsSectionsString, listOfGroupsSectionsString);

	RArray<TPtrC>	listOfGroupsSections;
	CleanupClosePushL(listOfGroupsSections);
	ViewUtilityReference().TokenizeStringL(listOfGroupsSectionsString, listOfGroupsSections);

	CCntFilter* filter = CCntFilter::NewL();
	CleanupStack::PushL(filter);
	filter->SetContactFilterTypeGroup(ETrue);
	DatabaseReference().FilterDatabaseL(*filter);

	for ( TInt i = 0; i < listOfGroupsSections.Count(); ++i )
		{
		CContactIdArray* idArray = filter->iIds;
		TContactItemId groupId = (*idArray)[i];
		CContactItem* group = DatabaseReference().OpenContactL(groupId);
		CleanupStack::PushL(group);
		CContactGroup* newGroup = static_cast<CContactGroup*>(group);
		UpdateGroupsL(listOfGroupsSections[i], *newGroup);
		DatabaseReference().CommitContactL(*group);
		DatabaseReference().CloseContactL(groupId);
		CleanupStack::PopAndDestroy(group);
		}

	CleanupStack::PopAndDestroy(2, &listOfGroupsSections);
	}
/* In this section, we edit the desired number of groups in the database
 * Set label for them and associate them with contacts
 @ param aGroupSection - Desired Group Name
 @ param aContact - Contact to be updated
 */
void CTestContactViewCRUDOperationsStep::UpdateContactsInGroupL(const TInt aNumberOfContactsToBeUpdated, const TPtrC& aGroupSection)
	{
	RArray<TPtrC>	listOfGroupsSections;
	CleanupClosePushL(listOfGroupsSections);
	ViewUtilityReference().TokenizeStringL(aGroupSection, listOfGroupsSections);

	for ( TInt i = 0; i < listOfGroupsSections.Count(); ++i )
		{
		CCntFilter* filter = CCntFilter::NewL();
		CleanupStack::PushL(filter);
		filter->SetContactFilterTypeGroup(ETrue);
		DatabaseReference().FilterDatabaseL(*filter);

		for ( TInt i = 0; i < filter->iIds->Count(); ++i )
			{
			TContactItemId groupId = (*filter->iIds)[i];
			CContactItem* group = DatabaseReference().OpenContactL(groupId);
			CContactGroup* newGroup = static_cast<CContactGroup*>(group);


			if(aGroupSection.Compare(newGroup->GetGroupLabelL())  == 0)
				{
				const CContactIdArray* listOfContacts = newGroup->ItemsContained();
				for(TInt i(0); i < aNumberOfContactsToBeUpdated; i++)
					{
					TContactItemId contactItemId = (*listOfContacts)[i];
					CContactItem* contactItem = DatabaseReference().ReadContactL(contactItemId);
					CleanupStack::PushL(contactItem);
					UpdateFieldsL(*contactItem);
					CContactItem* updatedContactItem = DatabaseReference().UpdateContactLC(contactItemId, contactItem);
					CleanupStack::PopAndDestroy(updatedContactItem);
					CleanupStack::PopAndDestroy(contactItem);
					}
				delete listOfContacts;
				DatabaseReference().CloseContactL(groupId);
				break;
				}
			DatabaseReference().CloseContactL(groupId);
			}

    	CleanupStack::PopAndDestroy(filter);
		}

	CleanupStack::PopAndDestroy(&listOfGroupsSections);
	}
Пример #3
0
LOCAL_C void NonDateBasedFilterTest()
{
    //This test has been created because, formerly,
    //CContactDatabase::FilterDatabase(...) could not
    //filter on contact types ONLY.
    //Previously, the CCntFilter passed in had to
    //have specified filtering based on the
    //time-based states as well (e.g. new, modified, deleted).
    //Addresses DEF036345
    CCntFilter* theFilter = CCntFilter::NewLC();
    theFilter->SetContactFilterTypeGroup(EFalse);
    theFilter->SetContactFilterTypeTemplate(EFalse);
    theFilter->SetContactFilterTypeOwnCard(EFalse);
    theFilter->SetContactFilterTypeCard(ETrue);
    //Get a filtered version of the database
    CntTest->Db()->FilterDatabaseL(*theFilter);
    test(theFilter->iIds->Count()==KTotalNumRecords);
    CleanupStack::PopAndDestroy(theFilter);
}
/* In this section, we edit the desired number of groups in the database
 * Set label for them and associate them with contacts
 @ param aGroupSection - Desired Group Name
 @ param aContact - Contact to be updated
 */
void CTestContactViewCRUDOperationsStep::IterateThroAllGroupSectionsAndUpdateContactL(const TPtrC& aGroupSection,
																									 CContactCard& aContact)
	{
	RArray<TPtrC>	listOfGroupsSections;
	CleanupClosePushL(listOfGroupsSections);
	ViewUtilityReference().TokenizeStringL(aGroupSection, listOfGroupsSections);

	for ( TInt i = 0; i < listOfGroupsSections.Count(); ++i )
		{
		CCntFilter* filter = CCntFilter::NewL();
		CleanupStack::PushL(filter);
		filter->SetContactFilterTypeGroup(ETrue);
		DatabaseReference().FilterDatabaseL(*filter);

		for ( TInt i = 0; i < filter->iIds->Count(); ++i )
			{
			TContactItemId groupId = (*filter->iIds)[i];
			CContactItem* group = DatabaseReference().OpenContactL(groupId);
			CContactGroup* newGroup = static_cast<CContactGroup*>(group);
			if(aGroupSection.Compare(newGroup->GetGroupLabelL())  == 0)
				{
				TRAP_IGNORE(DatabaseReference().RemoveContactFromGroupL(aContact, *newGroup));
				TRAP_IGNORE(DatabaseReference().AddContactToGroupL(aContact, *newGroup));
				DatabaseReference().CommitContactL(*group);
				const CContactIdArray* listOfContacts = newGroup->ItemsContained();
				const TInt count = listOfContacts->Count();
				delete listOfContacts;
				DatabaseReference().CloseContactL(groupId);
				break;
				}
			DatabaseReference().CloseContactL(groupId);
			}

    	CleanupStack::PopAndDestroy(filter);
		}

	CleanupStack::PopAndDestroy(&listOfGroupsSections);
	}
Пример #5
0
// SetInclude* are exclusive
// SetContactFilterType* is cumulative
//
LOCAL_C void CheckFilterSettingsL(TBool aSetting)
{
    CCntFilter* filter = CCntFilter::NewLC();

    filter->Reset();
    filter->SetIncludeModifiedContacts(aSetting);
    if (aSetting)
    {
        test(filter->IncludeModifiedContacts());
        test(!filter->IncludeNewContacts());
        test(!filter->IncludeDeletedContacts());
    }

    filter->SetIncludeNewContacts(aSetting);
    if (aSetting)
    {
        test(filter->IncludeNewContacts());
        test(!filter->IncludeModifiedContacts());
        test(!filter->IncludeDeletedContacts());
    }


    filter->SetIncludeDeletedContacts(aSetting);
    if (aSetting)
    {
        test(filter->IncludeDeletedContacts());
        test(!filter->IncludeModifiedContacts());
        test(!filter->IncludeNewContacts());
    }

    filter->SetContactFilterTypeCard(aSetting);
    filter->SetContactFilterTypeGroup(aSetting);
    filter->SetContactFilterTypeTemplate(aSetting);
    filter->SetContactFilterTypeOwnCard(aSetting);
    if (aSetting)
    {
        test(filter->ContactFilterTypeGroup());
        test(filter->ContactFilterTypeCard());
        test(filter->ContactFilterTypeTemplate());
        test(filter->ContactFilterTypeOwnCard());
    }
    else
    {
        test(!filter->ContactFilterTypeGroup());
        test(!filter->ContactFilterTypeCard());
        test(!filter->ContactFilterTypeTemplate());
        test(!filter->ContactFilterTypeOwnCard());
    }

    filter->SetContactFilterTypeALL(aSetting);
    if (aSetting)
    {
        test(filter->ContactFilterTypeALL());
        test(filter->ContactFilterTypeGroup());
        test(filter->ContactFilterTypeCard());
        test(filter->ContactFilterTypeTemplate());
        test(filter->ContactFilterTypeOwnCard());
    }

    TTime time;
    time.UniversalTime();
    filter->SetFilterDateTime(time);
    test(filter->GetFilterDateTime()==time);

    CleanupStack::PopAndDestroy(filter);
}