当前位置: 首页>>代码示例>>C++>>正文


C++ CContactItem::CardFields方法代码示例

本文整理汇总了C++中CContactItem::CardFields方法的典型用法代码示例。如果您正苦于以下问题:C++ CContactItem::CardFields方法的具体用法?C++ CContactItem::CardFields怎么用?C++ CContactItem::CardFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CContactItem的用法示例。


在下文中一共展示了CContactItem::CardFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestCustomUidsL

/**
Test: opens contact item, and adds a custom uid to each field, 
then checks if uid was stored correctly
*/
void CCustomLabelUid::TestCustomUidsL( const TContactItemId aCid )
	{
	//open contact	
	CContactItem *contactItem = NULL;
	contactItem = iContactsDatabase->OpenContactLX(aCid,*iViewAll);
	CleanupStack::PushL(contactItem);
	CContactItemFieldSet *ContactFields = &(contactItem->CardFields());
	
	//add an extra (custom) uid to each fieldtype of this contact
	AddUIDsL(*ContactFields,TestConstants::KInitialUID);

	//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
	SINGLECOMPARE( CheckUIDsL(*ContactFields,TestConstants::KInitialUID), 0 ,0 );
	//check that contact fields updated correctly
	SINGLECOMPARE( CheckContactFieldsL(*contactItem), 0, 0 );
	
	CleanupStack::PopAndDestroy(contactItem);
	}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例2: WriteBlobL

/**
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
	}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:46,代码来源:cntpersistenceutility.cpp

示例3: ReadTextBlobL

/**
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); 
	}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:43,代码来源:cntpersistenceutility.cpp

示例4: TestUpdateContactL

LOCAL_C void TestUpdateContactL()
{
    test.Next(_L("TestUpdateContactL"));

    SETUP;

    CContactItem* contact = CContactItem::NewLC(KUidContactCard);

    TContactItemId id = cntClient.CreateContactL(*contact);
    CleanupStack::PopAndDestroy(contact);

    // View definition to read image field
    CContactItemViewDef* imageViewDef = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields, CContactItemViewDef::EMaskHiddenFields);
    imageViewDef->AddL(KUidContactFieldMatchAll);

    contact = cntClient.OpenContactLX(imageViewDef ,id);
    CleanupStack::PushL(contact);

    CContactItemField* newField = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldCodImage);
    newField->SetMapping(KUidContactFieldVCardMapUnknown);
    newField->TextStorage()->SetTextL(KSrcImage());
    contact->AddFieldL(*newField); // Takes ownership
    CleanupStack::Pop(newField);

    cntClient.CommitContactL(*contact, EFalse);
    CleanupStack::PopAndDestroy(2);  //  contact, imageViewDef

    // View definition to read image field
    imageViewDef = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields, CContactItemViewDef::EMaskHiddenFields);
    imageViewDef->AddL(KUidContactFieldCodImage);

    contact = cntClient.ReadContactL(imageViewDef ,id);

    TInt index = contact->CardFields().Find(KUidContactFieldCodImage, KUidContactFieldVCardMapUnknown);

    // Test image field found
    test(index != KErrNotFound);

    CContactItemField& field = contact->CardFields()[index];
    TPtrC imagePtr = field.TextStorage()->Text();

    // Image should exist
    test(BaflUtils::FileExists(fs, imagePtr));

    // Test for GUID
    TPtrC guid = contact->Guid();
    test(imagePtr.Find(guid));

    cntClient.CloseContact(id);
    CleanupStack::PopAndDestroy(2);  //  contact, imageViewDef

    TEAR_DOWN;
}
开发者ID:KDE,项目名称:android-qt-mobility,代码行数:53,代码来源:mt_imagefieldprocessing.cpp

示例5: SetTextFieldL

EXPORT_C void CCntItemModifier::SetTextFieldL(TFieldType aFieldType, const TDesC& aText, CContactItem& aContactItem)
{
    CContactItemFieldSet& fields = aContactItem.CardFields();
    TInt fieldIndex = aContactItem.CardFields().Find(aFieldType);

    if (fieldIndex > KErrNotFound)
    {
        CContactItemField& field = fields[ fieldIndex ];
        ASSERT(field.StorageType() == KStorageTypeText);

        STATIC_CAST(CContactTextField*, field.Storage())->SetText(aText.AllocL());
    }
开发者ID:zccrs,项目名称:qt-mobility,代码行数:12,代码来源:nbcnttestlib.cpp

示例6: field

/**
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);
	}
开发者ID:,项目名称:,代码行数:59,代码来源:

示例7: CreatePhonebookTemplateL

/**
 * Create a new template and add it to the database
 * @param aDb Contact database
 * @param aTemplateName Name for the template
 * @param aFieldSet Array of fields which should are added to the template
 * @return TContactItemId Id of the newly created template
 */
TContactItemId CreatePhonebookTemplateL(CContactDatabase& aDb, const TDesC& aTemplateName, RArray<TFieldEntry>& aFieldSet)
	{
	CContactItem* temp = aDb.CreateContactCardTemplateLC(aTemplateName);
	TContactItemId templateId = temp->Id();
	CleanupStack::PopAndDestroy(temp);
	temp=NULL;

	//Remove all the unnecessary fields
	temp = aDb.OpenContactLX(templateId);
	CleanupStack::PushL(temp);	
	const TInt fieldCount = temp->CardFields().Count();
	for(TInt i=fieldCount-1;i>=0;i--)
		temp->RemoveField(i);

	// Add each of the required fields to the template
	for (TInt j=0; j<aFieldSet.Count(); ++j)
		{
		TFieldEntry fieldEntry=aFieldSet[j];

		CContactItemField* field = CContactItemField::NewLC(KStorageTypeText,fieldEntry.iField);
		if (fieldEntry.iFieldType!=KNullUid)
			field->AddFieldTypeL(fieldEntry.iFieldType);
		temp->AddFieldL(*field);
		CleanupStack::Pop(field);
		}

	aDb.CommitContactL(*temp);
	CleanupStack::PopAndDestroy(2); // temp, close template
	
	return templateId;
	}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:38,代码来源:t_iccmultiplephonebook.cpp

示例8: ProcessImageFieldL

/**
Parse through contact fields and find the image field. Copy the image
pointed by the path to an internal folder and update the contact fields.
This function is used internally by contacts model when saving/updating
a contact that has an image. It is a synchronous function

@param aItem Contact containing fields to be processed. Once the image
is resized and copied into the new location, this parameter will contain
the image field with the new path. If failures occur while resizing, the
image field content is not updated
*/
void CImageRescaler::ProcessImageFieldL(CContactItem& aItem)
    {
    // If there is no images dir do not do anything
    if (!iImagesDirPath.Length())
        {
        return;
        }
    CContactItemFieldSet& fieldSet = aItem.CardFields();
    // Check if there is any image field before
    TInt index = fieldSet.Find(KUidContactFieldCodImage, KUidContactFieldVCardMapUnknown);
    
    // Update the image path field if found and the private image does not exists
    if (index != KErrNotFound )
        {
        // Get a copy of fields set
        // Image path field from list of contact fields
        CContactItemField& imageField = fieldSet[index];
        TPtrC oldImagePath = imageField.TextStorage()->Text();
        
        // Do not resize if old image is stored in private folder
        if ( oldImagePath.Length() && !ExistsInImagesDirectory(oldImagePath) )
            {
            // Resize image if needed
            TPath newImagePath;
            newImagePath = ResizeAndCopyImage(oldImagePath, aItem);
            TCntImageRescaleUtility::StoreImageFieldL( aItem, newImagePath );
            }
        }
    }
开发者ID:,项目名称:,代码行数:40,代码来源:

示例9: DeletePerformanceL

/**
 * Deleting the 1000 contact item
 * with all new fields
 * @return - void
 */
void CTestContactPerformanceStep::DeletePerformanceL()
{
    // delete multiple contact item field
    CContactItem *readItem = NULL;

    //Get the number of contact item from ini file
    GetIntFromConfig(ConfigSection(), KNoOfContactItem, iNoOfCI);

    for(TInt readContact=0; readContact<iNoOfCI; readContact++)
    {
        readItem = dBase->ReadContactLC(idArray[readContact]);
        CContactItemFieldSet& ContactFieldSet = readItem->CardFields();
        for(TInt del=0; del<7; del++)
        {
            TInt pos = ContactFieldSet.Find(iFieldUid[del], iVcardUid[del]);
            if(pos != KErrNotFound)
            {
                ContactFieldSet.Remove(pos);
                SetTestStepResult(EPass);
            }
            else
            {
                ERR_PRINTF1(_L("field not deleted"));
                SetTestStepResult(EFail);
            }
        }
        CleanupStack::PopAndDestroy(readItem);
    }
    INFO_PRINTF1(_L("Fields deleted successfully"));
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:35,代码来源:testcontactperformancestep.cpp

示例10: SetNameL

/** Set the contents of a text field */
LOCAL_C void SetNameL(CContactItem& aItem,TUid aType,const TDesC& aName)
{
    CContactItemFieldSet& fieldSet=aItem.CardFields();
    const TInt pos=fieldSet.Find(aType);
    if (pos!=KErrNotFound)
        fieldSet[pos].TextStorage()->SetTextL(aName);
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例11: AssignSpeedDialL

void AssignSpeedDialL( TInt aContact, TInt aSpeedDialID, CContactDatabase& database )
	{
	CContactItem* item = NULL;
	item = database.OpenContactL( aContact );
	
	CleanupStack::PushL( item );

	if ( ContactIsASpeedDial( *item ) )
		{
		g_test.Printf( _L("Contact is a speed dial !!! \n") );
		}
	else
		{
		g_test.Printf( _L("Contact is NOT A SPEED DIAL \n") );
		}

	CContactItemFieldSet &fieldSet = item->CardFields();
    for(TInt index = fieldSet.Count() - 1; index > 0; --index)
        {
        if(fieldSet[index].StorageType() == KStorageTypeText)
            {
            //set the last text field from the fieldset as speeddial field.
        	database.SetFieldAsSpeedDialL(*item, index, aSpeedDialID );
            break;
            }
        }
        
	g_test.Next( _L("Contact changed to speed dial") );
	g_test(ContactIsASpeedDial( *item ));

	CleanupStack::PopAndDestroy( item );
	}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:32,代码来源:t_speeddialtest.cpp

示例12: initializeThumbnailFieldL

void CntThumbnailCreator::initializeThumbnailFieldL()
{
    // Assume the golden template is not changed run-time and fetch it only
    // when initializeThumbnailFieldL is called for the first time during the
    // life-time of the CntThumbnailCreator object (requires the instance to
    // live longer than one thumbnail create operation to be effective,
    // otherwise we would end up opening contact database and reading the
    // system template every time a thumbnail is stored for a contact).
    if(!m_thumbnailFieldFromTemplate) {
        CContactDatabase *contactDatabase = CContactDatabase::OpenL();
        CleanupStack::PushL(contactDatabase);
        CContactItem *goldenTemplate = contactDatabase->ReadContactLC(KGoldenTemplateId);
        const CContactItemFieldSet& cardFields = goldenTemplate->CardFields();

        // Check if thumbnail field type is KUidContactFieldPictureValue
        TInt pictureFieldIndex = cardFields.Find(KUidContactFieldPicture, KUidContactFieldVCardMapPHOTO);

        // Check if thumbnail field type is KUidContactFieldVCardMapJPEG
        if(pictureFieldIndex == KErrNotFound) {
            pictureFieldIndex = cardFields.Find(KUidContactFieldVCardMapJPEG, KUidContactFieldVCardMapPHOTO);
        }

        if(pictureFieldIndex == KErrNotFound) {
            // Either KUidContactFieldPictureValue or KUidContactFieldVCardMapJPEG
            // thumbnail field types should be in the template
            User::Leave(KErrNotFound);
        }

        m_thumbnailFieldFromTemplate = CContactItemField::NewL(cardFields[pictureFieldIndex]);
        CleanupStack::PopAndDestroy(goldenTemplate);
        CleanupStack::PopAndDestroy(contactDatabase);
    }
}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:33,代码来源:cntthumbnailcreator.cpp

示例13: pure

/**
Merging pure (minimal) contact with the template should be out of scope of the
Persistence Layer.  The only reason to have this functions in the test interface
is that CContactItem::RestoreTemplateFieldsL() is not exported.
*/
void CLplTester::MergeContactWithTemplateL(CContactItem& aContact, const CContactItem& aTempl, const CContactItemViewDef& aView) const
	{	
	if (aContact.TemplateRefId()!=KNullContactId &&  aContact.Type() != KUidContactCardTemplate)
		{
		aContact.RestoreTemplateFieldsL(iProps.SystemTemplateL().CardFields(), aTempl.CardFields(), aView);
		}
	}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:12,代码来源:cplpersistencebroker.cpp

示例14: SetPhoneNumberField

/**
 * Set the phone number field of the contact with id aId to contain the number aNumber
 * @param aDb Contact database
 * @param aId Contact item id
 * @param aNumber A telephone number
 */
void SetPhoneNumberField(CContactDatabase& aDb,TContactItemId aId,const TDesC& aNumber)
	{
	syncChecker->ResetMethodCallCountsL();
	CContactItem* item = aDb.OpenContactLX(aId);
	CleanupStack::PushL(item);
	if (item->Type() == KUidContactICCEntry)
		{
		test(syncChecker->ValidateMethodCallCountL() == 2);
		}
	else
		{
		test(syncChecker->ValidateMethodCallCountL() == 0);
		}
	CContactItemFieldSet& fieldset = item->CardFields();
	TInt pos = fieldset.Find(KUidContactFieldPhoneNumber);
	test(pos!=KErrNotFound);
	
	CContactItemField& field = fieldset[pos];
	CContactTextField* textfield = field.TextStorage();
	textfield->SetTextL(aNumber);

	syncChecker->ResetMethodCallCountsL();
	aDb.CommitContactL(*item);
	if (item->Type() == KUidContactICCEntry)
		{
		test(syncChecker->ValidateMethodCallCountL() == 2);
		}
	else
		{
		test(syncChecker->ValidateMethodCallCountL() == 0);
		}
	CleanupStack::PopAndDestroy(2); // item, lock record
	}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:39,代码来源:t_iccmultiplephonebook.cpp

示例15: TestPhoneMatchingL

void TestPhoneMatchingL(CContactDatabase& aDb)
	{
	test.Next(_L("Test phone match"));

	CContactIdArray* array = aDb.MatchPhoneNumberL(KTelephoneNum,KMaxPhoneMatchLength);	
	test(array->Count() == 4);
	delete array;

	syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);
	syncChecker->SetValidateResponseL(MContactSynchroniser::EEdit, KErrNone);
	syncChecker->SetValidateWriteResponseL(KErrNone);
	aDb.SetDbViewContactType(KUidContactICCEntry);
	TContactItemId id = (*aDb.SortedItemsL())[0];
	CContactItem* item = aDb.OpenContactLX(id);
	CleanupStack::PushL(item);
	CContactItemFieldSet& fieldset = item->CardFields();
	const TInt pos = fieldset.Find(KUidContactFieldPhoneNumber);	
	CContactItemField& field = fieldset[pos];
	CContactTextField* textfield = field.TextStorage();
	textfield->SetTextL(KTelephoneNumModified);
	aDb.CommitContactL(*item);
	CleanupStack::PopAndDestroy(2); //item, lock record

	CContactIdArray* array2 = aDb.MatchPhoneNumberL(KTelephoneNumModified,KMaxPhoneMatchLength);	
	test(array2->Count() == 1);
	delete array2;
	}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:27,代码来源:t_iccentry.cpp


注:本文中的CContactItem::CardFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。