本文整理汇总了C++中CContactDatabase::ReadContactLC方法的典型用法代码示例。如果您正苦于以下问题:C++ CContactDatabase::ReadContactLC方法的具体用法?C++ CContactDatabase::ReadContactLC怎么用?C++ CContactDatabase::ReadContactLC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContactDatabase
的用法示例。
在下文中一共展示了CContactDatabase::ReadContactLC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestDeleteL
/**
* Verify that the synchroniser is called when deleting an icc entry, and that the
* deletion of an icc entry fails if the icc is locked.
* @param aDb Contact database
*/
void TestDeleteL(CContactDatabase& aDb)
{
test.Next(_L("Test delete when ICC locked"));
syncChecker->SetDeleteContactResponseL(KErrLocked);
TContactItemId iccId=AddIccEntryL(aDb,KUidIccGlobalAdnPhonebook);
syncChecker->ResetMethodCallCountsL();
TRAPD(err,aDb.DeleteContactL(iccId));
test(err==KErrLocked);
test(syncChecker->ValidateMethodCallCountL() == 2);
syncChecker->ResetMethodCallCountsL();
CContactItem* item=aDb.ReadContactLC(iccId);
test(syncChecker->ValidateMethodCallCountL() == 1);
test(item!=NULL);
CleanupStack::PopAndDestroy(item);
item=NULL;
test.Next(_L("Test successful delete of non-icc entry when ICC locked"));
TContactItemId nonIccId=AddContactCardL(aDb);
syncChecker->ResetMethodCallCountsL();
TRAP(err,aDb.DeleteContactL(nonIccId));
test(err==KErrNone);
test(syncChecker->ValidateMethodCallCountL() == 0);
test.Next(_L("Test successful delete"));
syncChecker->SetDeleteContactResponseL(KErrNone);
syncChecker->ResetMethodCallCountsL();
TRAP(err,aDb.DeleteContactL(iccId));
test(syncChecker->ValidateMethodCallCountL() == 2);
test(err==KErrNone);
syncChecker->ResetMethodCallCountsL();
TRAP(err,aDb.ReadContactLC(iccId));
test(syncChecker->ValidateMethodCallCountL() == 0);
test(err==KErrNotFound);
}
示例2: TestReadContactL
void TestReadContactL(CContactDatabase& aDb, TContactItemId aIccId, TContactItemId aNonIccId)
{
test.Next(_L("Test ReadContactL"));
// Successful read of icc entry
syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);
syncChecker->ResetMethodCallCountsL();
test(syncChecker->ValidateMethodCallCountL() == 0);
CContactItem* item=aDb.ReadContactLC(aIccId);
test(syncChecker->ValidateMethodCallCountL() == 1);
test(item!=NULL);
CleanupStack::PopAndDestroy(item);
item=NULL;
// Unsuccessful read of icc entry because icc locked
syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrAccessDenied);
syncChecker->ResetMethodCallCountsL();
test(syncChecker->ValidateMethodCallCountL() == 0);
TRAPD(err,item=aDb.ReadContactL(aIccId));
test(item==NULL);
test(err==KErrAccessDenied);
test(syncChecker->ValidateMethodCallCountL() == 1);
// successful read of non-icc entry, even though icc locked
syncChecker->ResetMethodCallCountsL();
test(syncChecker->ValidateMethodCallCountL() == 0);
item=aDb.ReadContactLC(aNonIccId);
test(syncChecker->ValidateMethodCallCountL() == 0);
test(item!=NULL);
CleanupStack::PopAndDestroy(item);
item=NULL;
}
示例3: AddContactsL
void CContactsRamTest::AddContactsL(const TInt aNumber)
/**
Add number of contacts to db, using the system template.
@return None
@param aNumber number of contacts to be added
@pre None
@post database now contains aNumber of empty contacts
*/
{
//viewdef that loads all fields
CContactItemViewDef *viewAll = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields,CContactItemViewDef::EIncludeHiddenFields);
viewAll->AddL(KUidContactFieldMatchAll);
CContactTemplate *ttemplate = static_cast< CContactTemplate* >(
iContactsDatabase->ReadContactLC( iContactsDatabase->TemplateId(), *viewAll ) );
CContactCard* contact = CContactCard::NewLC(ttemplate);
SetManyFieldsL(KFieldValue, KManyFields, contact->CardFields());
for(TInt k = 0; k<aNumber; k++)
{
iContactsDatabase->AddNewContactL(*contact);
}
CleanupStack::PopAndDestroy(contact);
CleanupStack::PopAndDestroy(ttemplate);
CleanupStack::PopAndDestroy(viewAll);
}
示例4: doAddIccEntryL
/**
* Create an entry based on the template for this specific phonebook, and add
* the entry to the contact database
* @param aDb Contact database
* @param aPhonebookUid The phonebook uid
* @return TContactItemId Id of the newly created icc entry
*/
TContactItemId doAddIccEntryL(CContactDatabase& aDb,TUid aPhonebookUid)
{
syncChecker->ResetMethodCallCountsL();
TContactItemId templateId = aDb.ICCTemplateIdL(aPhonebookUid);
test(syncChecker->ValidateMethodCallCountL() == 1);
CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
CleanupStack::PopAndDestroy(iccTemplate);
CleanupStack::PushL(entry);
// Add to the database
CheckPhonebookField(*entry,aPhonebookUid, EFalse);
syncChecker->ResetMethodCallCountsL();
TContactItemId id = aDb.AddNewContactL(*entry);
test(syncChecker->ValidateMethodCallCountL() == 3);
CleanupStack::PopAndDestroy(entry);
test(id!=KNullContactId);
// Check group membership
syncChecker->ResetMethodCallCountsL();
CContactICCEntry* fetchedItem = static_cast<CContactICCEntry*>(aDb.ReadContactL(id));
test(syncChecker->ValidateMethodCallCountL() == 1);
CleanupStack::PushL(fetchedItem);
const CContactIdArray* owned = fetchedItem->GroupsJoined();
test(owned!=NULL && owned->Count() == 1);
test((*owned)[0]==syncChecker->GroupIdL(aPhonebookUid));
test(fetchedItem->Type() == KUidContactICCEntry);
// Verify that the phonebook field has been set
CheckPhonebookField(*fetchedItem,aPhonebookUid, ETrue);
CleanupStack::PopAndDestroy(fetchedItem);
return id;
}
示例5: TestAddingWithoutGroupL
/**
* Test addition to database without adding to a group
* @param aDb Contact database
*/
void TestAddingWithoutGroupL(CContactDatabase& aDb)
{
TContactItemId templateId = aDb.ICCTemplateIdL(KUidIccGlobalAdnPhonebook);
CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
CleanupStack::PopAndDestroy(iccTemplate);
CleanupStack::PushL(entry);
SetNameL(*entry,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,KGivenName,EFalse);
SetNameL(*entry,KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,KTelephoneNum,EFalse);
syncChecker->ResetMethodCallCountsL();
syncChecker->SetValidateWriteResponseL(KErrNone);
TInt oldGroupId = syncChecker->GroupIdL(KUidIccGlobalAdnPhonebook);
test(KErrNone == syncChecker->UpdatePhonebookGroupIdL(KUidIccGlobalAdnPhonebook, KNullContactId));
TContactItemId id = aDb.AddNewContactL(*entry);
test(syncChecker->ValidateMethodCallCountL() == 3);
CleanupStack::PopAndDestroy(entry);
CContactICCEntry* fetchedItem = static_cast<CContactICCEntry*>(aDb.ReadContactL(id));
CleanupStack::PushL(fetchedItem);
//Check group membership
const CContactIdArray* owned = fetchedItem->GroupsJoined();
test(owned==NULL || owned->Count() == 0);
CleanupStack::PopAndDestroy(fetchedItem);
test(KErrNone == syncChecker->UpdatePhonebookGroupIdL(KUidIccGlobalAdnPhonebook, oldGroupId));
}
示例6: 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);
}
}
示例7: GetValidUIDFromContactsDbL
/**
* To return a valid contact item id.
*/
TContactItemId CSyncTestStep::GetValidUIDFromContactsDbL()
{
TContactItemId firstId(KNullContactId);
CContactDatabase *iDb = NULL;
TRAPD(err,iDb = CContactDatabase::OpenL()); // open existing database
CleanupStack::PushL(iDb);
if (err != KErrNone)
{
CleanupStack::PopAndDestroy(); // iDb
return firstId;
}
iDb->SetDbViewContactType(KUidContactICCEntry);
// to get the unique groupId for the phonebook
TContactItemId groupId(KNullContactId);
User::LeaveIfError(iSession.GetPhoneBookId(groupId, RPhoneBookSession::ESyncGroupId));
TESTCHECKCONDITIONL(groupId != KNullContactId);
// based on the groupId, get an item belonging to the phonebook
CContactGroup* group = static_cast<CContactGroup*>(iDb->ReadContactLC(groupId));
const CContactIdArray* array = group->ItemsContained();
TInt count(array->Count());
if (count > 0)
firstId = (*array)[0];
CleanupStack::PopAndDestroy(group);
CleanupStack::PopAndDestroy(); // iDb
return firstId;
}
示例8: TestSuccessfulAddL
/**
* Test successful addition to database.
* @param aDb Contact database
*/
void TestSuccessfulAddL(CContactDatabase& aDb)
{
//Create group
TContactItemId groupId = CreatePhonebookGroupL(aDb);
test(KErrNone == syncChecker->UpdatePhonebookGroupIdL(KUidIccGlobalAdnPhonebook, groupId));
//Create item and add fields
TContactItemId templateId = aDb.ICCTemplateIdL(KUidIccGlobalAdnPhonebook);
CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
CleanupStack::PopAndDestroy(iccTemplate);
CleanupStack::PushL(entry);
SetNameL(*entry,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,KGivenName,EFalse);
SetNameL(*entry,KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,KTelephoneNum,EFalse);
//Add to database
syncChecker->ResetMethodCallCountsL();
syncChecker->SetValidateWriteResponseL(KErrNone);
syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);
test(syncChecker->ValidateMethodCallCountL() == 0);
TContactItemId id = aDb.AddNewContactL(*entry);
CleanupStack::PopAndDestroy(entry);
test(syncChecker->ValidateMethodCallCountL() == 3);
test(id!=KNullContactId);
CContactICCEntry* fetchedItem = static_cast<CContactICCEntry*>(aDb.ReadContactL(id));
CleanupStack::PushL(fetchedItem);
//Check group membership
const CContactIdArray* owned = fetchedItem->GroupsJoined();
test(owned!=NULL && owned->Count() == 1);
test((*owned)[0]==groupId);
//Check number of fields and content
CContactItemFieldSet& fieldset = fetchedItem->CardFields();
TInt pos = fieldset.Find(KUidContactFieldTemplateLabel);
test(pos==KErrNotFound);
// test(fieldset.Count() == 3);
/* for (TInt i=0; i<fieldset.Count(); i++)
{
CContactItemField& field = fieldset[i];
TInt count = field.ContentType().FieldTypeCount();
for (TInt j=0; j<count; j++)
{
TFieldType ft= field.ContentType().FieldType(j);
}
TUid mapping = field.ContentType().Mapping();
}
*/
CheckFieldContentL(fieldset,KUidContactFieldFamilyName,KGivenName);
// CheckFieldContentL(fieldset,KUidContactFieldPhoneNumber,KTelephoneNum);
CleanupStack::PopAndDestroy(fetchedItem);
}
示例9: TestCreationL
void TestCreationL(CContactDatabase& aDb)
{
_LIT(KTestCreation,"Create CContactICCEntry item");
test.Start(_L("@SYMTESTCaseID:PIM-T-ICCENTRY-0001 Create CContactICCEntry item"));
//System Template
TContactItemId systemTemplateId = aDb.TemplateId();
CContactItem* systemTemplate = aDb.ReadContactLC(systemTemplateId);
CContactICCEntry* entry = CContactICCEntry::NewL(*systemTemplate);
CleanupStack::PopAndDestroy(systemTemplate);
CleanupStack::PushL(entry);
//Test CContactICCEntry items can be identified from normal contact cards
test(entry->Type() == KUidContactICCEntry);
test(entry->TemplateRefId() == systemTemplateId);
CleanupStack::PopAndDestroy(entry);
//Create user defined template for ICC contacts
test.Next(_L("CContactDatabase::ICCTemplateL()"));
TContactItemId templateId = CreateICCTemplateL(aDb);
test(KErrNone == syncChecker->UpdatePhonebookEntryL(KUidIccGlobalAdnPhonebook, templateId, KNullContactId));
//Check that contacts model calls the plug-in when asked for the
//template ID.
TInt callCount = syncChecker->ValidateMethodCallCountL();
test(callCount==0);
TContactItemId templateIdFromCntmodel;
templateIdFromCntmodel = aDb.ICCTemplateIdL(KUidIccGlobalAdnPhonebook);
test(syncChecker->ValidateMethodCallCountL() == 1);
test(templateId == templateIdFromCntmodel);
CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
CheckTemplateL(*iccTemplate);
//create ICC contact
CContactICCEntry* iccentry = CContactICCEntry::NewL(*iccTemplate);
CleanupStack::PopAndDestroy(iccTemplate);
CleanupStack::PushL(iccentry);
test(iccentry->Type() == KUidContactICCEntry);
test(iccentry->TemplateRefId() == templateId);
CleanupStack::PopAndDestroy(iccentry);
test.End();
}
示例10: AddContactCardL
/**
* Verify that adding contact cards doesn't call the synchroniser interface
* @param aDb Contact database
*/
TContactItemId AddContactCardL(CContactDatabase& aDb)
{
_LIT(KTemplateName,"contact card template");
RArray<TFieldEntry> entries=fieldSetForPhonebook(KUidIccGlobalAdnPhonebook);
TContactItemId templateId=CreatePhonebookTemplateL(aDb,KTemplateName,entries);
entries.Close();
CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
CContactCard* card = CContactCard::NewLC(iccTemplate);
syncChecker->ResetMethodCallCountsL();
TContactItemId id=aDb.AddNewContactL(*card);
test(syncChecker->ValidateMethodCallCountL() == 0);
CleanupStack::PopAndDestroy(2,iccTemplate);
return id;
}
示例11: TestDatabaseIterationL
void TestDatabaseIterationL(CContactDatabase& aDb)
{
test.Next(_L("Test database iteration"));
aDb.SetDbViewContactType(KUidContactICCEntry);
TContactIter iterator(aDb);
TContactItemId id = iterator.FirstL();
while (id!=KNullContactId)
{
CContactItem* item = aDb.ReadContactLC(id);
test(item->Type() == KUidContactICCEntry);
CleanupStack::PopAndDestroy(item);
id = iterator.NextL();
}
}
示例12: TestUnsuccessfulAddL
/**
* Test an unsuccessful addition to the database
* @param aDb Contact database
*/
void TestUnsuccessfulAddL(CContactDatabase& aDb)
{
TContactItemId templateId = aDb.ICCTemplateIdL(KUidIccGlobalAdnPhonebook);
CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
CleanupStack::PopAndDestroy(iccTemplate);
CleanupStack::PushL(entry);
SetNameL(*entry,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,KGivenName,EFalse);
SetNameL(*entry,KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,KTelephoneNum,EFalse);
syncChecker->ResetMethodCallCountsL();
syncChecker->SetValidateWriteResponseL(KErrAccessDenied);
TRAPD(error, aDb.AddNewContactL(*entry));
test(error==KErrAccessDenied);
test(syncChecker->ValidateMethodCallCountL() == 1);
CleanupStack::PopAndDestroy(entry);
}
示例13: TestReadContactL
/**
* Verify that the plug-in implementation is called when the
* ReadContactL API is used.
*
* Tests code called by methods:
* IMPORT_C CContactItem* ReadContactL(TContactItemId aContactId);
* IMPORT_C CArrayPtr<CContactItem>* ReadContactAndAgentL(TContactItemId aContactId);
* IMPORT_C CContactItem* ReadContactL(TContactItemId aContactId,const CContactItemViewDef& aViewDef);
* IMPORT_C CContactItem* ReadContactLC(TContactItemId aContactId);
* IMPORT_C CContactItem* ReadContactLC(TContactItemId aContactId,const CContactItemViewDef& aViewDef);
*
* @param aDb Contact database
* @param aId Contact item ID to read
*/
void TestReadContactL(CContactDatabase& aDb, TContactItemId aId)
{
syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);
syncChecker->ResetMethodCallCountsL();
test(syncChecker->ValidateMethodCallCountL() == 0);
CContactItem* item = aDb.ReadContactLC(aId);
test(syncChecker->ValidateMethodCallCountL() == 1);
CleanupStack::PopAndDestroy(item);
syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrAccessDenied);
syncChecker->ResetMethodCallCountsL();
test(syncChecker->ValidateMethodCallCountL() == 0);
item=NULL;
TRAPD(err, item = aDb.ReadContactL(aId));
delete item;
test(err==KErrAccessDenied);
test(syncChecker->ValidateMethodCallCountL() == 1);
}
示例14: CreateTestICCEntryL
/**
* Create example ICC Entry
* @param aDb Contact database
*/
TContactItemId CreateTestICCEntryL(CContactDatabase& aDb)
{
TContactItemId templateId = aDb.ICCTemplateIdL(KUidIccGlobalAdnPhonebook);
CContactItem* iccTemplate = aDb.ReadContactLC(templateId);
CContactICCEntry* entry = CContactICCEntry::NewL(*iccTemplate);
CleanupStack::PopAndDestroy(iccTemplate);
CleanupStack::PushL(entry);
SetNameL(*entry,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,KGivenName,EFalse);
SetNameL(*entry,KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL,KTelephoneNum,EFalse);
//Add to database
syncChecker->SetValidateWriteResponseL(KErrNone);
syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);
syncChecker->SetDeleteContactResponseL(KErrNone);
TContactItemId id = aDb.AddNewContactL(*entry);
CleanupStack::PopAndDestroy(entry);
test(id!=KNullContactId);
return id;
}
示例15: test
LOCAL_C void CheckConsistentL
(CContactDatabase& aDb,
const CContactGroupView& aGroupView,
const CContactViewBase& aBaseView,
TContactItemId aGroupId)
{
const TInt groupViewCount = aGroupView.CountL();
test(groupViewCount <= aBaseView.CountL());
CContactGroup* group = static_cast<CContactGroup*>(aDb.ReadContactLC(aGroupId));
const TInt count = aBaseView.CountL();
TInt checked = 0;
for (TInt i=0; i < count; ++i)
{
const TContactItemId id = aBaseView.AtL(i);
if (group->ContainsItem(id))
{
test(aGroupView.FindL(id) != KErrNotFound);
++checked;
}
}
test(checked == groupViewCount);
CleanupStack::PopAndDestroy(group);
}