TBool CPackagerCntComparator::DoCompareCContactItemFieldSet(const CContactItemFieldSet& anItemFieldSet1, const CContactItemFieldSet& anItemFieldSet2) const
/** Compares two CContactItemFieldSet items. 

@param anItemFieldSet1 The first CContactItemFieldSet to be compared.
@param anItemFieldSet2 The second CContactItemFieldSet to be compared.
@return ETrue if the two items are equal, EFalse otherwise. */
	{// Need to check for NULL  arrays first.	
	if((!&anItemFieldSet1[0]) && (!&anItemFieldSet2[0]))
		{
		return ETrue;
		}

	if((!&anItemFieldSet1[0]) || (!&anItemFieldSet2[0]))
		{
		return EFalse;
		}
		
	// Check if arrays are same length to begin with.
	TInt maxCount = anItemFieldSet1.Count();
	if(!DoCompareTInt(maxCount, anItemFieldSet2.Count()))
		{
		return EFalse;
		}	
		
	for(TInt i=0; i<maxCount; ++i)
		{		
		if(!(DoCompareCContactItemField(anItemFieldSet1[i],anItemFieldSet2[i])))
			{
			return EFalse;	
			}
		}
		
	return ETrue;
	}
/**
Utility method used to read text blob fields from contacts database. Provides a mechanism to
fill a contact item with informations stored in text blobs within contact database.
A reference to the contact item to be fill has to be provided. A template has to be provided
if the contact item is based on a template. Template can be NULL. Also a view definition can
be provided to filter which fields are read from blob fields.

@param 		aTextHeader reference to a read stream from which header values will be read
@param 		aTextValues reference to a descriptor from which text values will be read
@param		aItem Contact item to be filled with information from text blob field.
@param		aView View definition specifying what item fields should be read from text blob field
@param		aTemplate Contact item representing a template based on which aItem should be read. Can be NULL
@leave		KErrNotFound if the specified contact item does not exist any more in contact database
*/	
void TCntPersistenceUtility::ReadTextBlobL(CEmbeddedStore& aTextHeaderStore, TPtrC& aTextValues, CContactItem& aItem, const CContactItemViewDef& aView, const CContactItem* aTemplate)
	{
	HBufC* textFieldsBuf = aTextValues.AllocLC();
	
	if (aTemplate) 
		{
		// If a system template is provided, we create a new CContactItemFieldSet object
		// and restore it based on provided template (CContactItemField objects composing
		// template). CContactItem object will be set with the newly created CContactItemFieldSet.
		CContactItemFieldSet* original = CContactItemFieldSet::NewLC();
		RestoreTextL(*original, aTextHeaderStore, aTextHeaderStore.Root(), textFieldsBuf, aView, aTemplate);
		
		for(TInt loop = 0;loop < original->Count();loop++)
			{
			CContactItemField* additionalField = CContactItemField::NewLC((*original)[loop]);
			aItem.CardFields().AddL(*additionalField);
			CleanupStack::Pop(additionalField);
			}
		CleanupStack::PopAndDestroy(original);
		}
	else
		{
		// If there is no template provided, we will fill the CContactItemField set provided
		// in the curent CContactItem object
		RestoreTextL(aItem.CardFields(), aTextHeaderStore, aTextHeaderStore.Root(), textFieldsBuf, aView, NULL);
		}
	
	CleanupStack::PopAndDestroy(textFieldsBuf); 
	}
void CReadContactsAO::GetTextFieldFromFieldSet(CContactItemFieldSet& aFieldSet, const TUid aField,TDesC& name)
{
	TInt index = aFieldSet.Find(aField);

    if ((index >= 0) && (index < aFieldSet.Count()))
    {
   	    CContactItemField& textfield = aFieldSet[index];
        CContactTextField* textValue = textfield.TextStorage();

		((TDes&)name).Copy(textValue->Text());		
    } 
}
Beispiel #4
0
/**
this function encompasses two tests
Test1(!aNewFields) opens contact item, and adds a custom uid to each field, changes lable to custom label
then checks if uid and label were stored correctly
Test2(aNewFields) opens contact item and adds ten new fields, and adds a custom uid to 
each field(new and old), changes lable to custom label then checks if uid and 
label were stored correctly. also checks both uids of new fields
*/
void CCustomLabelUid::TestCustomUidLabelsL( const TContactItemId aCid, const TBool aNewFields )
	{
	CContactItem *contactItem = NULL;
	//open contact
	contactItem = iContactsDatabase->OpenContactLX(aCid,*iViewAll);
	CleanupStack::PushL(contactItem);
	CContactItemFieldSet *ContactFields = &(contactItem->CardFields());
		
	if(aNewFields)
		{
		TInt length = 10;//add 10 new custom fields
		for(TInt i = 0, uids = TestConstants::KAltUID; i < length; i++, uids++)
			{
			AddNewFieldL( *ContactFields, TestConstants::KShortString, TFieldType::Uid(uids) );
			}
		}
	//set custom labels for contact fields	
	SetContactLabelsL(*contactItem);
	//set custom uids for contact fields
	AddUIDsL(*ContactFields,TestConstants::KInitialUID);
	//populate contact fields and update
	SetContactFieldsL(*contactItem);
	iContactsDatabase->CommitContactL(*contactItem);
	
	CleanupStack::PopAndDestroy(contactItem);
	CleanupStack::Pop();//lock
	
	//read contact
	contactItem = NULL;
	contactItem = iContactsDatabase->ReadContactLC(aCid,*iViewAll);
	ContactFields = &(contactItem->CardFields());
	
	//check uids were update correctly
	SINGLECOMPARE( CheckUIDsL(*ContactFields,TestConstants::KInitialUID),0,0 );
	//check labels were update correctly
	SINGLECOMPARE( CheckContactLabelsL(*contactItem),0,0 );
	//check fields were populated correctly
	SINGLECOMPARE( CheckContactFieldsL(*contactItem),0,0 );
	
	if(aNewFields)
		{
		//check that new fields contain the correct uids(2), initial and updated custom values
		TInt length = ContactFields->Count();
		TInt i = ContactFields->Find( TFieldType::Uid(TestConstants::KAltUID) );
		for(TInt uids = TestConstants::KAltUID; i < length; i++, uids++)
			{
			SINGLECOMPARE( CheckNewFieldL( *ContactFields, i, TFieldType::Uid(uids) ), i, 0);
			}
		}		
	CleanupStack::PopAndDestroy(contactItem);
	}
Beispiel #5
0
/**Utility function to remove any specified contact field from a specified contact item*/
TBool CAgentTest::RemoveFieldFromContactL(TContactItemId aContactId, TUid aContactField)
	{
	CContactItem* mainItem = NULL;
	CContactItemFieldSet* fields = NULL;
	mainItem = iDb->OpenContactL(aContactId);
	CleanupStack::PushL(mainItem);
	fields = &mainItem->CardFields();
	TInt pos = 0;
	pos = fields->Find(aContactField);
	if (pos != KErrNotFound)
		{
		fields->Remove(pos);	
		}
	iDb->CommitContactL(*mainItem);
	CleanupStack::PopAndDestroy();	
	return pos;	
	}
Beispiel #6
0
/** 
 * Check that the field of type aFieldType has the same content as 
 * aExpectedContent
 * @param aFieldset Contact item fieldset
 * @param aFieldType Field type to test
 * @param aExpectedContent Expected data
 */
void CheckFieldContentL(CContactItemFieldSet& aFieldset, TFieldType aFieldType, const TDesC& aExpectedContent)
	{
	TInt pos = aFieldset.Find(aFieldType);
	CContactItemField& field = aFieldset[pos];
	CContactTextField* textField = field.TextStorage();
	test(textField != NULL);
	test(textField->Text() == aExpectedContent);
	}
/**
Utility method used to read text fields from blob and fill item field set,Provides a mechanism to restore a 
contact item field set from text blob field within contact database.
Blob informations are stored based on contact item field. At restore, a reference to a contact item field set
is provided. For every contact item field in the item field set, a text restore is made.

@param		aFieldSet Reference to CContactItemFieldSet. Item field set that has to be filled with informations from blob
@param		aHeaderStore Stream store containing the header informations
@param		aId Root id for the header stream store
@param		aValuesStore Read stream used to read text fields from text blob
@param		aViewDef View definition indicating which fields have to be read from blob
@param		aTemplate Template indicating if current field set should be filled based on a template
*/	
void TCntPersistenceUtility::RestoreTextL(CContactItemFieldSet& aFieldSet, CStreamStore& aHeaderStore, TStreamId aId, HBufC* textStream, const CContactItemViewDef& aViewDef, const CContactItem* aTemplate)
	{
	const TBool KIncludeFields = ( aViewDef.Use() == CContactItemViewDef::EIncludeFields );
	
	if (KIncludeFields && aViewDef.Count() == 0)
		{
		// If view definition does not contain any field we don't do anything (don't read from 
		// blob). We simply return from method without doing anything.
		// This is not an error condition
		return;	
		}
		
	RStoreReadStream stream;
	stream.OpenLC(aHeaderStore,aId);
	
	TCardinality fieldCount;
	stream>>fieldCount;
	
	TInt textFieldIndex=0;

	for (TInt ii = 0; ii < fieldCount; ++ii)
		{
		// Restore text for every CContactItemField in provided CContactItemFieldSet.
		CContactItemField* field = CContactItemField::NewLC();
		
		if(aTemplate)
		    {
    		field->RestoreFieldTypesL(stream, &(aTemplate->CardFields()));
		    }
		else
		    {
    		field->RestoreFieldTypesL(stream, NULL);
		    }    
		    
		ASSERT(field->StorageType() == KStorageTypeText);

		TBool fieldDefined = ETrue;
		if(!aViewDef.MatchesAll())
			{
			fieldDefined = (aViewDef.Find(field->ContentType()) != KErrNotFound);
			}

		if ((!((fieldDefined && KIncludeFields) || (!fieldDefined && !KIncludeFields))) || 
			(field->IsHidden() && aViewDef.Mode() == CContactItemViewDef::EMaskHiddenFields))
			{
    		CleanupStack::PopAndDestroy(field); 	
			}
		else
		    {
    		field->RestoreTextL(textStream, textFieldIndex);
			aFieldSet.AddL(*field);
    		CleanupStack::Pop(field); 	
		    }	
		    
        ++textFieldIndex;
		}
	CleanupStack::PopAndDestroy(&stream);	
	}
Beispiel #8
0
/**Utility function for finding number of agents in a contact item*/
TInt CAgentTest::GetAgentCountL(TContactItemId aContactId)
	{
	CContactItem* mainItem = NULL;
	mainItem = iDb->ReadContactL(aContactId);
	CleanupStack::PushL(mainItem);
	CContactItemFieldSet* fields = &mainItem->CardFields();
	TInt count = fields->Count();	
	TInt agentCount = 0;
	TInt i = 0;
	for(; i < count; ++i)
		{
		if( (*fields)[i].StorageType() == KStorageTypeContactItemId )
			{
			++agentCount;
			}
		}
	CleanupStack::PopAndDestroy();
	return agentCount;
	}
/**
Utility method used to write text and binary blob fields into write streams. The write
streams will be used to persist the blob informations in contact database.
Provides a mechanism to get information from a contact item and store them in the
right blob fields within contact database. Template can be NULL. 

@param		aTextHeader reference to a write stream in which text header will be written
@param		aTextValues reference to a write stream in which text values will be written.
			From the caller point of view this reference should be a reference to a RSqlParamWriteStream instance
@param		aBinaryHeader reference to a write stream in which binary header will be written
@param		aBinaryValues reference to a write stream in which binary values will be written.
@param		aItem Contact item to be filled with information from text blob field.
@param      aSysTemplate System template item.
*/		
void TCntPersistenceUtility::WriteBlobL(CEmbeddedStore& aTextEmbeddedStore, RWriteStream& aTextValues, CEmbeddedStore& aBinaryEmbeddedStore, CEmbeddedStore& aBinaryEmbeddedBlobStore, const CContactItem& aItem, const CContactTemplate* aSysTemplate)
	{
	CContactItemFieldSet& fieldSet = aItem.CardFields();
	CContactItemFieldSet* textFieldSet = CContactItemFieldSet::NewLC();
	CContactItemFieldSet* binaryFieldSet = CContactItemFieldSet::NewLC();
	
	for(TInt i = 0; i < fieldSet.Count(); ++i)
		{
		CContactItemField* item	= CContactItemField::NewL((aItem.CardFields())[i]);
		CleanupStack::PushL(item);
		if(item->StorageType() == KStorageTypeText)
			{
			textFieldSet->AddL(*item);	
			}
		else
			{
			binaryFieldSet->AddL(*item);	
			}	
		CleanupStack::Pop(item);	
		}
	
	TStreamId rootId = textFieldSet->StoreL(aTextEmbeddedStore, aSysTemplate, aTextValues, aBinaryEmbeddedBlobStore, NULL);// *textEmbeddedBlobStore); 
	aTextEmbeddedStore.SetRootL(rootId);
	aTextEmbeddedStore.CommitL();

	rootId = binaryFieldSet->StoreL(aBinaryEmbeddedStore, aSysTemplate, aTextValues, aBinaryEmbeddedBlobStore, NULL); 
	aBinaryEmbeddedStore.SetRootL(rootId);
	aBinaryEmbeddedStore.CommitL();
	aBinaryEmbeddedBlobStore.CommitL();
		
	CleanupStack::PopAndDestroy(2, textFieldSet);  //binaryFieldSet, textFieldSet
	}
Beispiel #10
0
TBool CAgentAddressbook::ContainsEmptyField(const CContactItemFieldSet& fields)
	{
	for (TInt i = 0; i < fields.Count(); i++)
		{
		const CContactItemField& itemField = fields[i];
		if (itemField.StorageType() == KStorageTypeText || itemField.StorageType() == KStorageTypeDateTime)
			{
			if (!itemField.Storage()->IsFull())
				return ETrue;
			}
		}
	return EFalse;
	}
/**
sets aMany fields of a currently read / open item to aText
*/
void CContactsRamTest::SetManyFieldsL(const TDesC& aText, const TInt aMany, CContactItemFieldSet &fields)
	{
	TInt count = fields.Count();
	if( count > aMany )
		{
		count = aMany;
		}
	TInt i = 0;
	for(; i < count; ++i)
		{
		SetFieldL(fields[i],aText);
		}
	}
Beispiel #12
0
/**Utility function for Adding any number of contact items
   with name and telephone fields.
*/
void CAgentTest::AddContactItemsL(TInt aCount)
	{
	iIdArray->Reset();
	CContactItem* templateCard = NULL;
	CContactCard* card = NULL;
	CContactItemFieldSet* fieldSet = NULL;
	
	for(TInt loop = 0; loop < aCount; ++loop)
		{
		TInt pos = KErrNotFound;
		TBuf<16> name;
		name.Format(_L("NAME%d"),loop);
		TBuf<16> tel;
		tel.Format(_L("123456%d"),loop);
		
		templateCard = iDb->ReadContactLC(iDb->TemplateId());
		card = CContactCard::NewLC(templateCard); 
	
		fieldSet = &card->CardFields();
		pos = fieldSet->Find(KUidContactFieldFamilyName);
		if (pos != KErrNotFound)
			{
			(*fieldSet)[pos].TextStorage()->SetTextL(name);		
			}
		pos = fieldSet->Find(KUidContactFieldPhoneNumber);
		
		if (pos != KErrNotFound)
			{
			(*fieldSet)[pos].TextStorage()->SetTextL(tel);	
			}
		
    	TContactItemId contactId = iDb->AddNewContactL(*card);
		iIdArray->AddL(contactId);
		CleanupStack::PopAndDestroy(2);
		}
	}
void PrintFieldsTableL(RFile& outFile, 	const CContactItemFieldSet& fldSet, TBuf8<255>& buf)
	{
	SDescArr sTStorageType[] = {
		_S("KStorageTypeText"),
		_S("KStorageTypeStore"),
		_S("KStorageTypeContactIt"),
		_S("KStorageTypeDateTime")
		};

	SFlagsDict sFieldFlag[]= {
		FF(EHidden),
		FF(EReadOnly),
		FF(ESynchronize),
		FF(EDisabled),
		FF(EUserMask),
		FF(EOverRidesLabel),
		FF(EUsesTemplateData),
		FF(EUserAddedField),
		FF(ETemplate),
		FF(ELabelUnspecified),
		FF(EDeleted),
		FF(NbTestLast)
		};

	outFile.Write(_L8("<html><body><table width=100% cellpadding=1 cellspacing=1 border=1>"));
	outFile.Write(_L8("<tr><td>Fld</td><td>Label</td><td>Field types:</td><td>Storg type</td>" \
		"<td>Field</td><td>Attr</td><td>Ext.Att</td><td>Templ</td></tr>\r\n"));

	const TInt numOfFields = fldSet.Count();
	for (TInt i=0; i < numOfFields; ++i)
		{
		const CContactItemField& field = fldSet[i];
		const CMyField& myField = reinterpret_cast<const CMyField&>(field);
		const CContentType& conType = *myField.iContentType;

		buf.Format(_L8("<tr><td>%d</td>"), myField.iId);
		outFile.Write(buf);

		outFile.Write(_L8("<td>"));
		if (myField.iLabel)
			{
			buf.Copy(*myField.iLabel);
			outFile.Write(buf);
			}
		outFile.Write(_L8("</td>\r\n"));

		//test.Printf(_L("Field types are:"));
		outFile.Write(_L8("<td>"));

		for(TInt j=0; j < conType.FieldTypeCount(); ++j)
			{
			const TFieldType& fldType = conType.FieldType(j);
			//test.Printf(_L(" %s"), VCardMaping(fldType));
			const TPtrC str = VCardMaping(fldType);
			buf.Copy(str);
			outFile.Write(buf);
			outFile.Write(_L8(",<br>"));
			}

		//Print Mapping of the field 
		outFile.Write(_L8("MP>: "));
		const TPtrC mapp = VCardMaping(conType.Mapping());
		buf.Copy(mapp);
		outFile.Write(buf);

		outFile.Write(_L8("</td>\r\n<td>"));

		//test.Printf(_L("Storg type: %s"), sTStorageType[myField.iStorageType]);
		const TPtrC str (sTStorageType[myField.iStorageType]);
		buf.Copy(str);
		outFile.Write(buf);

		outFile.Write(_L8("</td>\r\n<td>"));
		switch(myField.iStorageType)
			{
			case KStorageTypeText:  
				{
				const TPtrC& textFld = static_cast<CContactTextField*>(field.Storage())->Text();
				//test.Printf(_L("Text	  : %S"),  textFld);
				buf.Copy(textFld);
				outFile.Write(buf);
				}
			break;
			default: 
			break;
			}

		outFile.Write(_L8("</td>\r\n"));

		//test.Printf(_L("Attributes: 0x%08x"), myField.iAttributes);
		buf.Format(_L8("<td>0x%08x"), myField.iAttributes);
		outFile.Write(buf);

		for (TInt i = 0;; ++i)
			{
			const SFlagsDict& aFlag = sFieldFlag[i];

			if (aFlag.iFlag & myField.iAttributes)
				{
				TPtrC str(aFlag.iDescript);
				buf.Copy(str);

				outFile.Write(_L8(",<br>"));
				outFile.Write(buf);
				}


			if (aFlag.iFlag == NbTestLast)
				{
				break;
				}
			}

		outFile.Write(_L8("</td>\r\n"));

		//test.Printf(_L("Ext Attrib: 0x%08x"), myField.iExtendedAttributes);
		buf.Format(_L8("<td>0x%08x</td>\r\n"), myField.iExtendedAttributes);
		outFile.Write(buf);

		//test.Printf(_L("Temp fldId: 0x%08x"), myField.iTemplateFieldId);
		buf.Format(_L8("<td>%d</td>\r\n"), myField.iTemplateFieldId);
		outFile.Write(buf);

		
		outFile.Write(_L8("</tr>\r\n\r\n"));
		}

	outFile.Write(_L8("</table></body></html>\r\n"));
	}
Beispiel #14
0
static void PhonebookWriteReqL(PktBuf &in, PktBuf &out)
{
	TUint16 memtype, ns, type, subtype;
	TUint32 location;
	CContactItem *item;
	CContactItemFieldSet *fieldset;
	CContactItemField *field;
	TBuf<64> name;
	TPtrC family_name, given_name;
	int i, s;

	g->InitPhoneBookL();

	in >> memtype;
	in >> location;

	if (memtype != GN_MT_ME) {
		out << (TUint16)GNAPPLET_MSG_PHONEBOOK_WRITE_RESP;
		out << (TUint16)GN_ERR_INVALIDMEMORYTYPE;
		return;
	}

	fieldset = CContactItemFieldSet::NewLC();
	in >> ns;
	for (i = 0; i < ns; i++) {
		in >> type >> subtype >> name;
		switch (type) {
		case GN_PHONEBOOK_ENTRY_Name:
			for (s = 0; s < name.Length() && name[s] != ' '; s++) ;
			if (s >= 1 && s < name.Length()) {
				family_name.Set(name.Ptr(), s);
				given_name.Set(name.Ptr() + s + 1, name.Length() - s - 1);
			} else {
				family_name.Set(name);
			}
			if (family_name.Length() > 0) {
				field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldFamilyName);
				//field->SetLabelL(_L("alma"));
				field->SetMapping(KUidContactFieldVCardMapUnusedN);
				field->TextStorage()->SetTextL(family_name);
				fieldset->AddL(*field);
			}
			if (given_name.Length() > 0) {
				field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldGivenName);
				//field->SetLabelL(_L("alma"));
				field->SetMapping(KUidContactFieldVCardMapUnusedN);
				field->TextStorage()->SetTextL(given_name);
				fieldset->AddL(*field);
			}
			break;
		case GN_PHONEBOOK_ENTRY_Email:
			field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldEMail);
			field->SetMapping(KUidContactFieldVCardMapEMAILINTERNET);
			field->TextStorage()->SetTextL(name);
			fieldset->AddL(*field);
			break;
		case GN_PHONEBOOK_ENTRY_Note:
			field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldNote);
			field->SetMapping(KUidContactFieldVCardMapNOTE);
			field->TextStorage()->SetTextL(name);
			fieldset->AddL(*field);
			break;
		case GN_PHONEBOOK_ENTRY_Number:
			if (subtype == GN_PHONEBOOK_NUMBER_Fax) {
				field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldFax);
				field->SetMapping(KUidContactFieldVCardMapTEL);
				field->AddFieldTypeL(KUidContactFieldVCardMapFAX);
			} else {
				field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldPhoneNumber);
				field->SetMapping(KUidContactFieldVCardMapTEL);
				switch (subtype) {
				case GN_PHONEBOOK_NUMBER_Home:
					field->AddFieldTypeL(KUidContactFieldVCardMapHOME);
					break;
				case GN_PHONEBOOK_NUMBER_Mobile:
					field->AddFieldTypeL(KUidContactFieldVCardMapCELL);
					break;
				case GN_PHONEBOOK_NUMBER_Work:
					field->AddFieldTypeL(KUidContactFieldVCardMapWORK);
					break;
				}
			}
			field->TextStorage()->SetTextL(name);
			fieldset->AddL(*field);
			break;
		case GN_PHONEBOOK_ENTRY_Ringtone:
			//field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldRingTone);
			//field->TextStorage()->SetTextL(name);
			//fieldset->AddL(*field);
			break;
		case GN_PHONEBOOK_ENTRY_Group:
			//field = CContactItemField::NewL(KStorageTypeText,
			//field->TextStorage()->SetTextL(name);
			//fieldset->AddL(*field);
			break;
		case GN_PHONEBOOK_ENTRY_URL:
			field = CContactItemField::NewL(KStorageTypeText, KUidContactFieldUrl);
			field->SetMapping(KUidContactFieldVCardMapURL);
			field->TextStorage()->SetTextL(name);
			fieldset->AddL(*field);
			break;
		default:
			break;
		}
	}
	in.FinishL();

	TRAPD(error, item = g->cdb->OpenContactL(location));
	if (error == KErrNone) {
		item->UpdateFieldSet(fieldset);
		CleanupStack::Pop(fieldset);
		CleanupStack::PushL(item);
		g->cdb->CommitContactL(*item);
	} else {
		item = CContactCard::NewL();
		item->UpdateFieldSet(fieldset);
		CleanupStack::Pop(fieldset);
		CleanupStack::PushL(item);
		location = g->cdb->AddNewContactL(*item);
	}
	CleanupStack::Pop(item);

	out << (TUint16)GNAPPLET_MSG_PHONEBOOK_WRITE_RESP;
	out << (TUint16)GN_ERR_NONE;
	out << memtype;
	out << location;
	cons->Printf(_L("write: %d\n"), location);
}
Beispiel #15
0
/**
Test: opens contact item, add two identical uids to each field, 
alternating between custom and existing uids, 
then checks if uids were stored correctly
*/
void CCustomLabelUid::DuplicateUidsTestL( const TContactItemId aCid )
	{	
	//open contact	
	CContactItem *contactItem = NULL;
	contactItem = iContactsDatabase->OpenContactLX(aCid,*iViewAll);
	CleanupStack::PushL(contactItem);
	CContactItemFieldSet *contactFields = &(contactItem->CardFields());
	
	//add two identical uids to each field, alternating between custom and existing uids
	const TInt KFieldsCount = contactFields->Count();
	TInt error = KErrNone;


	//add duplicate custom uids
	CContactItemField *contactField1 = CContactItemField::NewL(KStorageTypeText);
	CleanupStack::PushL(contactField1);
	contactField1->SetTemplateField(EFalse);
	TRAP( error, contactField1->AddFieldTypeL( TFieldType::Uid(TestConstants::KInitialUID) ));
	INTCOMPARE( KErrNone, ==, error, 0, 0 );
	TRAP( error, contactField1->AddFieldTypeL( TFieldType::Uid(TestConstants::KInitialUID) ));
	INTCOMPARE( KErrNone, ==, error, 0, 0 );
	contactItem->AddFieldL(*contactField1);
	CleanupStack::Pop(contactField1);
	
	//add duplicate existing uids
	CContactItemField *contactField2 = CContactItemField::NewL(KStorageTypeText);
	CleanupStack::PushL(contactField2);
	contactField2->SetTemplateField(EFalse);
	TRAP( error, contactField2->AddFieldTypeL(KUidContactFieldAdditionalName));
	INTCOMPARE( KErrNone, ==, error, 1, 0 );
	TRAP( error, contactField2->AddFieldTypeL(KUidContactFieldAdditionalName));
	INTCOMPARE( KErrNone, ==, error, 1, 0 );
	contactItem->AddFieldL(*contactField2);
	CleanupStack::Pop(contactField2);


	//populate contact fields
	SetContactFieldsL(*contactItem);
	//update contact
	iContactsDatabase->CommitContactL(*contactItem);
	
	
	CleanupStack::PopAndDestroy(contactItem);
	CleanupStack::Pop();//lock
	contactItem = NULL;
	
	//read contact item
	contactItem = iContactsDatabase->ReadContactLC(aCid,*iViewAll);
	contactFields = &(contactItem->CardFields());
	//check that contact field uids updated correctly
	
	const TInt KReadFieldsCount = contactFields->Count();
	const CContentType *KContentType = NULL;
	INTCOMPARE( KReadFieldsCount, >, 0, 0, 0 );

	KContentType = &(*contactFields)[KFieldsCount].ContentType();
	SINGLECOMPARE( KContentType->ContainsFieldType( TFieldType::Uid(TestConstants::KInitialUID) ), KFieldsCount,0 );
	
	KContentType = &(*contactFields)[KFieldsCount+1].ContentType();
	SINGLECOMPARE( KContentType->ContainsFieldType(KUidContactFieldAdditionalName), KFieldsCount+1,0 );

	//check that contact fields updated correctly
	SINGLECOMPARE( CheckContactFieldsL(*contactItem), 0, 0 );

	CleanupStack::PopAndDestroy(contactItem);
	}