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


C++ CContactItemField类代码示例

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


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

示例1: _LIT

/**
* Add one contact to the database.
*/
void CMainThread::TestAddContactL()
	{
    
    // Add a contact 
	_LIT(KForename,"Jo"); 
	_LIT(KSurname,"Stichbury"); 

	// Create a  contact card to contain the data
	CContactCard* newCard = CContactCard::NewLC();
    
	// Create the firstName field and add the data to it
	CContactItemField* firstName = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldGivenName);
	firstName->TextStorage()->SetTextL(KForename);
	newCard->AddFieldL(*firstName);
  	CleanupStack::Pop(firstName);
  	
	// Create the lastName field and add the data to it
   	CContactItemField* lastName= CContactItemField::NewLC(KStorageTypeText, KUidContactFieldFamilyName);
  	lastName ->TextStorage()->SetTextL(KSurname);
  	newCard->AddFieldL(*lastName);
   	CleanupStack::Pop(lastName);
   		    
	// Add newCard to the database
	iContactId = database->AddNewContactL(*newCard);
	CleanupStack::PopAndDestroy(newCard);
	
	iTest->Printf( _L("Thread1: Added 1 contact to the database."));
	}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:31,代码来源:t_concurrent.cpp

示例2: _LIT

TContactItemId CPbTester::AddEntryL()
	{
	_LIT(KForename,"John"); 
	_LIT(KSurname,"Smith"); 
	_LIT(KPhoneNumber,"+441617779700"); 

	// Create a  contact card to contain the data
	CContactCard* newCard = CContactCard::NewLC();

	// Create the firstName field and add the data to it
	CContactItemField* firstName = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldGivenName);
	firstName->TextStorage()->SetTextL(KForename);
	newCard->AddFieldL(*firstName);
	CleanupStack::Pop(firstName);

	// Create the lastName field and add the data to it
	CContactItemField* lastName= CContactItemField::NewLC(KStorageTypeText, KUidContactFieldFamilyName);
	lastName ->TextStorage()->SetTextL(KSurname);
	newCard->AddFieldL(*lastName);
	CleanupStack::Pop(lastName);

	// Create the phoneNo field and add the data to it
	CContactItemField* phoneNumber = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldPhoneNumber);
	phoneNumber->SetMapping(KUidContactFieldVCardMapTEL);
	phoneNumber ->TextStorage()->SetTextL(KPhoneNumber);
	newCard->AddFieldL(*phoneNumber);
	CleanupStack::Pop(phoneNumber);

	// Add newCard to the database
	const TContactItemId contactId = ipbDb->AddNewContactL(*newCard);

	CleanupStack::PopAndDestroy(newCard);

	return contactId;
	}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:35,代码来源:t_contactdbevent.cpp

示例3: 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

示例4:

TContactItemId CTestResources::CreateTestContactL
        (const TDesC& aFamilyName, TBool aWithPhoneNumber)
    {
    // Create a contact card
    CContactCard* card = CContactCard::NewLC();
    // Create a name field
    CContactItemField* field = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldFamilyName);
    field->TextStorage()->SetTextL(aFamilyName);
    card->AddFieldL(*field);
    CleanupStack::Pop(field);
    // Create a phone number field
    if (aWithPhoneNumber)
        {
        // Create a phone number field
        CContactItemField* field = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldPhoneNumber);
        field->TextStorage()->SetTextL(_L("555"));
        card->AddFieldL(*field);
        CleanupStack::Pop(field);
        }
    // Add the contact to the DB
    const TContactItemId contactId = iDb->AddNewContactL(*card);
    CleanupStack::PopAndDestroy(card);
    // Eat away contact db events
    TContactDbObserverEvent event;
    while 
        (iDbEventQueue->ListenForEvent(10,event) && 
        (event.iType != EContactDbObserverEventContactAdded ||
        event.iContactId != contactId))
        {
        }
    iTestContactId = contactId;
    return contactId;
    }
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:33,代码来源:t_filteredviewevents.cpp

示例5: 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

示例6: CreateFieldLC

CContactItemField* CFilteredViewTester::CreateFieldLC(const TUid aMappingUId, TFieldType aFieldType, const TDesC &aText)
	{
	CContactItemField * field =CContactItemField::NewLC(KStorageTypeText, aFieldType);
	field->SetMapping(aMappingUId);
	field->TextStorage()->SetTextL(aText);
	return field;
	}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:7,代码来源:t_filteredviewevents.cpp

示例7: GetIntFromConfig

/** Create Contact Item and add field to it and 
 *	verify the field is being added
 *	aValue - field value
 *  @param aStorageType - Storage type of each field
 *	@param aContFieldUid - Uid of Contact field
 *	@param avCardMapUid - Uid of vCard 
 *	@return - void
*/	
void CTestAddFieldsStep::AddFieldsL(TPtrC aValue, TInt aStorageType,TUid aContFieldUid, TUid avCardMap)	
	{
	TPtrC value;
	TInt year, month, day;

	// Create contact Item and add field to it	
	CContactItem* item = CContactCard::NewLC();
    CContactItemField* field = CContactItemField::NewL(aStorageType, aContFieldUid);
    CleanupStack::PushL(field); 
    field->SetMapping(avCardMap);
    if(aStorageType==KStorageTypeDateTime)
    	{
    	GetIntFromConfig(ConfigSection(), KIniYear, year);
    	GetIntFromConfig(ConfigSection(), KIniMonth, month);
    	GetIntFromConfig(ConfigSection(), KIniDay, day);
		TDateTime date(year,(TMonth)month,day,0,0,0,0);
   		field->DateTimeStorage()->SetTime(date);
    	}
    else
    	{
    	field->TextStorage()->SetTextL(aValue);	
    	}	
   	item->AddFieldL(*field);   
  
   	// verify the field is being added    	
	CContactItemFieldSet& ContactFieldSet = item->CardFields();
	TInt pos = ContactFieldSet.Find(aContFieldUid, avCardMap);	
	if(pos != KErrNotFound)	
		{
		if(aStorageType==KStorageTypeDateTime)
			{
			TDateTime result=ContactFieldSet[pos].DateTimeStorage()->Time().DateTime();
			//compair the results
			if((result.Year() == year) && (result.Month() == (TMonth)month) && (result.Day() == day)) 
				{
				SetTestStepResult(EPass);	
				}
			else
				{
				SetTestStepResult(EFail);	
				}
			}
		else
			{	
			value.Set(ContactFieldSet[pos].TextStorage()->Text());
			//compair the results
			if(aValue.Compare(value)==0 )
				{
				SetTestStepResult(EPass);
				}
			else
				{
				SetTestStepResult(EFail);
				}
			}
		}
	CleanupStack::Pop(field);
	CleanupStack::PopAndDestroy(item);
	}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:67,代码来源:testaddfieldsstep.cpp

示例8: PRINT

TBool CPredictiveSearchSynchronizer::ReadMailAddressesL(CContactItem& aContact)
	{
	PRINT(_L("CPredictiveSearchSynchronizer::ReadMailAddressesL"));

	// SELECT value FROM comm_addr
	//	 WHERE contact_id = [contact id value] AND type = [type value];
    _LIT(KSelectMailAddrFormat, "SELECT %S FROM %S WHERE %S = %d AND %S = %d;");
	const TInt KContactIdLength = 10;
	const TInt KCommAddrTypeLength = 2; // CPplCommAddrTable::EEmailAddress is enum
	TInt bufSize = KSelectMailAddrFormat().Length() +
				   KCommAddrValue().Length() +
				   KSqlContactCommAddrTableName().Length() +
				   KCommAddrContactId().Length() +
				   KContactIdLength +
				   KCommAddrType().Length() +
				   KCommAddrTypeLength;
	HBufC* sqlStatement = HBufC::NewLC(bufSize);
	sqlStatement->Des().AppendFormat(KSelectMailAddrFormat,
		&KCommAddrValue,
		&KSqlContactCommAddrTableName,
		&KCommAddrContactId,
		aContact.Id(),
		&KCommAddrType,
		CPplCommAddrTable::EEmailAddress);

	RSqlStatement stmnt;
	CleanupClosePushL(stmnt);
	PRINT1(_L("prepare SQL statement:%S"), sqlStatement);
    stmnt.PrepareL(iDatabase, *sqlStatement);

	const TInt KValueIndex = 0;
	TBool foundMailAddress(EFalse);
	TInt err(KErrNone);
    while ((err = stmnt.Next()) == KSqlAtRow)
        {
		TPtrC value;
		if (stmnt.ColumnText(KValueIndex, value) == KErrNone)
			{
			PRINT2(_L("  id=%d, found mail address=%S"), aContact.Id(), &value);
			CContactItemField* field =
				CContactItemField::NewLC(KStorageTypeText, KUidContactFieldEMail);
			CContactTextField* textfield = field->TextStorage();
			textfield->SetTextL(value);
			aContact.AddFieldL(*field); // Takes ownership
			CleanupStack::Pop(field);
			foundMailAddress = ETrue;
			}
        }

    if (err != KSqlAtEnd)
        {
		PRINT1(_L("CPredictiveSearchSynchronizer::ReadMailAddressesL SQL err=%d"), err);
        User::Leave(err);
        }
    CleanupStack::PopAndDestroy(&stmnt);
	CleanupStack::PopAndDestroy(sqlStatement);
	PRINT1(_L("CPredictiveSearchSynchronizer::ReadMailAddressesL return %d"), foundMailAddress);
	return foundMailAddress;
	}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:59,代码来源:cpredictivesearchsynchronizer.cpp

示例9:

LOCAL_C void AddFieldToContactL
        (CContactItem& aContact, TFieldType aFieldType, const TDesC& aText)
    {
    CContactItemField* field = CContactItemField::NewLC(KStorageTypeText, aFieldType);
    field->TextStorage()->SetTextL(aText);
    aContact.AddFieldL(*field);
    CleanupStack::Pop(field);
    }
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:8,代码来源:t_groupviewpanic.cpp

示例10:

EXPORT_C void TCnt::TGetSet::operator+= (const TDesC& aStr)
{
    //Create the field if it is not found
    CContactItemField* field = CContactItemField::NewLC(KStorageTypeText, *iContType);
    iCnt->AddFieldL(*field); //Takes ownership

    field->TextStorage()->SetTextL(aStr);

    CleanupStack::Pop(field);
    CleanupStack::PopAndDestroy(iContType);
}
开发者ID:zccrs,项目名称:qt-mobility,代码行数:11,代码来源:nbcnttestlib.cpp

示例11: 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

示例12: LongNumSpeedDialTestsL

LOCAL_C void LongNumSpeedDialTestsL()
    {
	_LIT(KLongNumSpeedDialTest, "Long Phone Number Speed Dial Test");
	g_test.Start(KLongNumSpeedDialTest);

	// create default, empty database
	CContactDatabase* db = CContactDatabase::ReplaceL(KLongNumSpeedDialDbName);
	CleanupStack::PushL(db);
	
	// create a contact and add it to the db
	CContactItem* contact = CContactCard::NewLC();
	CContactItemField* fname = CContactItemField::NewLC(KStorageTypeText, 
			KUidContactFieldGivenName);
	_LIT(KFname, "James");
	fname->TextStorage()->SetTextL(KFname() );
	contact->AddFieldL(*fname);
	CleanupStack::Pop(fname);
	CContactItemField* phone = CContactItemField::NewLC(KStorageTypeText,
			KUidContactFieldPhoneNumber);
	_LIT(KPhoneNum,	"01234567890123456789012345678901234567890123456789012345678901234567890123456789"); // 80 chars
	phone->TextStorage()->SetTextL(KPhoneNum() );
	contact->AddFieldL(*phone);
	CleanupStack::Pop(phone);
	const TContactItemId KContactId = db->AddNewContactL(*contact);
	CleanupStack::PopAndDestroy(contact);
	contact = NULL;

	// retrieve contact and assign its number to speed dial #1
	contact = db->OpenContactL(KContactId);
	CleanupStack::PushL(contact);
	const TInt KSpeedDial1(1);
	const TInt KPhoneNumIndex = contact->CardFields().Find(KUidContactFieldPhoneNumber);
	db->SetFieldAsSpeedDialL(*contact, KPhoneNumIndex, KSpeedDial1);
	TBuf<100> speedDialNumberText;
	TContactItemId speedDialId = db->GetSpeedDialFieldL(KSpeedDial1, speedDialNumberText);
	_LIT(KOutputFormat, "retrieved speed dial id: %d;\nretrieved speed dial phone number: ...\n%S\n");
	g_test.Printf(KOutputFormat, speedDialId, &speedDialNumberText);
	db->CloseContactL(KContactId);
	
	// cleanup
	CleanupStack::PopAndDestroy(2, db);	// and contact
	CContactDatabase::DeleteDatabaseL(KLongNumSpeedDialDbName);

	// Since PDEF121954, long phone numbers set as speed dial are truncated to 
	// the length of KSpeedDialPhoneLength. So, we need to get the truncated 
	// version of the phone number for comparison with the speed dial value.
	TPtrC phoneNum(KPhoneNum().Mid(0, KSpeedDialPhoneLength));
	g_test(speedDialId == KContactId && speedDialNumberText.CompareC(phoneNum) == 0);
	g_test.End();
	g_test.Close();
    }
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:51,代码来源:t_speeddialtest.cpp

示例13: InsertTextFieldL

//------------------------------------------------------------------------------------------------------------	
void CPerfTestContact::InsertTextFieldL(TFieldType aID, const TDesC& aStringOfStuff )
	{
	CContactItemField* itemFieldPtr = NULL;
	CContactTextField* textStoragePtr = NULL;

	itemFieldPtr = CContactItemField::NewLC( KStorageTypeText, aID );
	textStoragePtr = itemFieldPtr->TextStorage(); // we don't have ownership here, hence no stack.

	textStoragePtr->SetTextL( aStringOfStuff );
	textStoragePtr = NULL; // we've finished with this ptr now.

	iContactItem->AddFieldL( *itemFieldPtr ); // hand ownership over here
	CleanupStack::Pop( itemFieldPtr ); // and pop,
	}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:15,代码来源:t_perfdbcreator.cpp

示例14: InsertBinaryFieldL

//------------------------------------------------------------------------------------------------------------	
void CPerfTestContact::InsertBinaryFieldL(TUid aID, const TDesC8& aBufOfStuff )
	{
	CContactItemField*  itemFieldPtr = NULL;
	CContactStoreField* binStoragePtr = NULL;

	itemFieldPtr = CContactItemField::NewLC( KStorageTypeStore, aID );
	binStoragePtr = itemFieldPtr->StoreStorage(); // we don't have ownership here, hence no stack.

	binStoragePtr->SetThingL(aBufOfStuff);
	binStoragePtr = NULL; // we've finished with this ptr now.

	iContactItem->AddFieldL( *itemFieldPtr ); // hand ownership over here
	CleanupStack::Pop( itemFieldPtr ); // and pop,
	}	
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:15,代码来源:t_perfdbcreator.cpp

示例15: CreateTestContactsL

LOCAL_C void CreateTestContactsL(CTestResources& aRes, TInt aCount)
    {
    for (TInt i=1; i <= aCount; ++i)
        {
        CContactCard* card = CContactCard::NewLC();
        CContactItemField* field = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldFamilyName);
        TBuf<30> name;
        name.Format(_L("Contact%02d"), i);
        field->TextStorage()->SetTextL(name);
        card->AddFieldL(*field);
        CleanupStack::Pop(field);
        aRes.iDb->AddNewContactL(*card);
        CleanupStack::PopAndDestroy(card);
        }
    }
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:15,代码来源:t_localviewduplicates.cpp


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