本文整理汇总了C++中CContactItem类的典型用法代码示例。如果您正苦于以下问题:C++ CContactItem类的具体用法?C++ CContactItem怎么用?C++ CContactItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CContactItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckBasicPopulatedGroup
LOCAL_C void CheckBasicPopulatedGroup()
{
test.Next(_L("Populate Basic Group"));
CntTest->CloseDatabase();
CntTest->DeleteDatabaseL();
CntTest->CreateDatabaseL();
TRAP_IGNORE(PopulateDatabaseL(KFamilySizeRecords,ETrue));
CContactItem* newGroup = CntTest->Db()->CreateContactGroupLC(_L("Family Group"));
TContactItemId groupId = newGroup->Id();
for(TInt ii=2;ii<12;ii++)
{
CntTest->Db()->AddContactToGroupL(ii,groupId);
}
CntTest->CloseDatabase();
CntTest->OpenDatabaseL();
//
CContactItem* familyGroup = CntTest->Db()->ReadContactLC(groupId);
CContactIdArray* memberArray = STATIC_CAST(CContactGroup*,familyGroup)->ItemsContainedLC();
test(memberArray->Count()==10);
//
CContactItem* familyMember = CntTest->Db()->ReadContactLC(2);
CContactIdArray* groups = STATIC_CAST(CContactCard*, familyMember)->GroupsJoinedLC();
test(groups->Count()==1);
TContactItemId memberShip = (*groups)[0];
test(memberShip==groupId);
CleanupStack::PopAndDestroy(5);
// newGroup familyGroup memberArray familyMember groups
}
示例2: 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;
}
示例3: GroupAddRemoveTestL
// Regression testcode for MAT-5B7JD4 "AddContactToGroupL()/RemoveContactFromGroupL() does not update
// object passed as argument"
//
LOCAL_C void GroupAddRemoveTestL()
{
test.Next(_L("Group addition/removal defect"));
CntTest->CloseDatabase();
CntTest->DeleteDatabaseL();
CContactDatabase* db=CntTest->CreateDatabaseL();
_LIT(KCntmodelGroup,"MyGroup");
CContactItem* group = db->CreateContactGroupLC(KCntmodelGroup);
TContactItemId groupId = group->Id();
TContactItemId itemId=AddContactL(db,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,_L("C"));
CContactItem* item = CntTest->Db()->ReadContactLC(itemId);
CntTest->Db()->AddContactToGroupL(*item,*group);
// write change to database
const CContactIdArray* groupsJoined = STATIC_CAST(CContactItemPlusGroup*,item)->GroupsJoined();
test(groupsJoined->Find(groupId)==0);
const CContactIdArray* itemsContained = STATIC_CAST(CContactGroup*,group)->ItemsContained();
test(itemsContained->Find(itemId)==0);
CntTest->Db()->RemoveContactFromGroupL(*item,*group);
test(STATIC_CAST(CContactItemPlusGroup*,item)->GroupsJoined()->Find(groupId)!=0);
test(STATIC_CAST(CContactGroup*,group)->ItemsContained()->Find(itemId)!=0);
CleanupStack::PopAndDestroy(item);
CleanupStack::PopAndDestroy(group);
}
示例4: 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);
}
示例5: 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);
}
}
示例6: DeleteL
/**
Deletes all the communication addresses for a particular contact item. Should be used when
deleting a contact item from the database altogether.
@param aItem The contact item whose communcation addresses are to be deleted.
*/
void CPplCommAddrTable::DeleteL(const CContactItem& aItem, TBool& aLowDiskErrorOccurred)
{
const TUid KType = aItem.Type();
if (KType != KUidContactCard && KType != KUidContactOwnCard && KType != KUidContactICCEntry && KType != KUidContactGroup)
{
return;
}
RSqlStatement stmnt;
CleanupClosePushL(stmnt);
stmnt.PrepareL(iDatabase, iAllForItemDeleteStmnt->SqlStringL() );
const TInt KContactIdParamIndex(KFirstIndex); // first and only parameter in query
User::LeaveIfError(stmnt.BindInt(KContactIdParamIndex, aItem.Id() ) );
TInt err = stmnt.Exec();
CleanupStack::PopAndDestroy(&stmnt);
if (err == KErrDiskFull)
{
aLowDiskErrorOccurred = ETrue;
}
else
{
User::LeaveIfError(err);
}
}
示例7: 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);
}
}
示例8: GetIntFromConfig
/**
* 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"));
}
示例9: AddUidRevPropertyL
/** Add UID and REV properties to the input vCard files
* This helps in importing the vCards in Merge Mode
* @param aContactItem - existing contact item
* @param fsSession - File Session
* @param aSource - new file
* @param aDestination - File contains Uid of existing Contact item and field value from new file
* @return - void
*/
void CTestImportContactMergeModeStep::AddUidRevPropertyL(const CContactItem& aContactItem, RFs& fsSession, const TDesC& aSource, const TDesC& aDestination)
{
CParserVCard* vCardParser=CParserVCard::NewL();
CleanupStack::PushL(vCardParser);
InternalizeFileL(*vCardParser,aSource,fsSession);
CParserPropertyValueDateTime* valueDateTime = CreateDateTimePropertyL(aContactItem.LastModified(),TVersitDateTime::EIsMachineLocal);
CleanupStack::PushL(valueDateTime);
CParserProperty* property=CParserGroupedProperty::NewL(*valueDateTime,KVersitTokenREV,NULL,NULL);
CleanupStack::Pop(valueDateTime);
CleanupStack::PushL(property);
vCardParser->AddPropertyL(property); //takes ownership
CleanupStack::Pop(property);
TInt64 machineUniqueId = dBase->MachineId();
TPtrC guid=aContactItem.UidStringL(machineUniqueId);
CParserPropertyValueHBufC* uidValue=CParserPropertyValueHBufC::NewL(guid);
CleanupStack::PushL(uidValue);
CParserProperty* uidproperty=CParserGroupedProperty::NewL(*uidValue,KVersitTokenUID,NULL,NULL);
CleanupStack::Pop(uidValue);
CleanupStack::PushL(uidproperty);
vCardParser->AddPropertyL(uidproperty); //takes ownership
CleanupStack::Pop(uidproperty);
ExternaliseFileL(*vCardParser,aDestination, fsSession);
CleanupStack::PopAndDestroy(vCardParser);
}
示例10: RestoreTextL
/**
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);
}
示例11: 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
}
示例12: 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
}
示例13: TestOneL
void TestOneL()
{
g_test.Start(_L("@SYMTestCaseID:PIM-T-SPEEDDIALTEST-0001 Create Database with Speed Dials then Delete and Create database"));
TestDatabaseWithSpeedDialsL();
g_test.Next(_L("Delete database"));
CContactDatabase::DeleteDatabaseL(KDbFileName);
g_test.Next( _L("open database should fail"));
CContactDatabase* database = NULL;
TRAPD(openError, database = CContactDatabase::OpenL(KDbFileName));
g_test(openError == KErrNotFound && database == NULL);
g_test.Next( _L("create replacement database"));
database = CContactDatabase::CreateL(KDbFileName);
CleanupStack::PushL(database);
CreateContactsL(*database);
CContactItem* item = database->ReadContactL(KSpeedDialContact);
CleanupStack::PushL(item);
g_test.Next( _L("Check that Speed dial is forgotten"));
g_test(item->Id() == KSpeedDialContact);
// retored item should not be a SpeedDial
g_test(!ContactIsASpeedDial( *item ));
CleanupStack::PopAndDestroy(item);
CleanupStack::PopAndDestroy(database);
g_test.End();
}
示例14: 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 );
}
示例15: RenameDefectL
// This tests tries to reproduce defect
// EDNRTRN-4J5C5E "Groups in Cntmodel cannot be renamed.."
//
// This defect was caused because groups weren't included in the view and
// MoveInSortArrayL doesn't check that the contact item will be in the
// iSortedItems list (this list depends on the view chosen).
//
LOCAL_C void RenameDefectL()
{
test.Next(_L("Rename a group"));
CntTest->CloseDatabase();
CntTest->DeleteDatabaseL();
CContactDatabase* db=CntTest->CreateDatabaseL();
_LIT(KCntmodelOriginalName,"Original");
_LIT(KCntmodelRevisedName,"Revised");
CContactItem* newGroup = CntTest->Db()->CreateContactGroupLC(KCntmodelOriginalName);
TContactItemId groupId = newGroup->Id();
CleanupStack::PopAndDestroy(); //newGroup
TContactItemId contactA=AddContactL(db,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,_L("a"));
TContactItemId contactB=AddContactL(db,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,_L("b"));
CntTest->Db()->AddContactToGroupL(contactA,groupId);
CntTest->Db()->AddContactToGroupL(contactB,groupId);
CntTest->Db()->SetDbViewContactType(KUidContactCard);
CntTest->Db()->SortedItemsL(); // ensures theres a iSortedItems
SetSortOrderL(*db,TUid::Uid(KUidContactFieldDefinedTextValue)); // required so that the comparision
CContactGroup* group = static_cast<CContactGroup*>(CntTest->Db()->OpenContactL(groupId));
CleanupStack::PushL(group);
group->SetGroupLabelL(KCntmodelRevisedName);
CntTest->Db()->CommitContactL(*group);
CntTest->Db()->CloseContactL(groupId);
CleanupStack::PopAndDestroy(); //group
CContactItem* revisedGroup = CntTest->Db()->ReadContactLC(groupId,*CntTest->Db()->AllFieldsView());
TPtrC testLabel = static_cast<CContactGroup*>(revisedGroup)->GetGroupLabelL();
test(testLabel==KCntmodelRevisedName);
CleanupStack::PopAndDestroy(); //revisedGroup
}