本文整理汇总了C++中CContactDatabase::ReadContactL方法的典型用法代码示例。如果您正苦于以下问题:C++ CContactDatabase::ReadContactL方法的具体用法?C++ CContactDatabase::ReadContactL怎么用?C++ CContactDatabase::ReadContactL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContactDatabase
的用法示例。
在下文中一共展示了CContactDatabase::ReadContactL方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: TestResultL
void CAsyncTest::TestResultL()
{
CContactDatabase* db = iOpenOp->TakeDatabase();
if(db == NULL)
User::Leave(KErrNotFound);
// Test adding a contact
CContactItemViewDef* matchAll = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields,CContactItemViewDef::EIncludeHiddenFields);
matchAll->AddL(KUidContactFieldMatchAll);
CContactItem* cntTemplate = db->ReadContactL(0, *matchAll);
CleanupStack::PopAndDestroy(matchAll);
CleanupStack::PushL(cntTemplate);
CCntItemBuilder* cntItemBldr = CCntItemBuilder::NewLC(static_cast<CContactTemplate&>(*cntTemplate));
CContactItem* tempCntItem = cntItemBldr->GetCntItemLC();
db->AddNewContactL(*tempCntItem);
CleanupStack::PopAndDestroy(tempCntItem);
CleanupStack::PopAndDestroy(cntItemBldr);
CleanupStack::PopAndDestroy(cntTemplate);
delete iOpenOp;
delete db;
iOpenOp = NULL;
db = NULL;
iTest->Next(_L("Read data from Database\n"));
}
示例3: 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;
}
示例4: 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();
}
示例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: 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);
}
示例7: TestFourL
void TestFourL()
{
g_test.Start(_L("Check that Settings are saved - killing ContactLockSrv"));
g_test.Next(_L("Setting up..."));
CLockServerTester* lockSrvTester = CLockServerTester::NewL();
CleanupStack::PushL(lockSrvTester);
CContactDatabase* database = SetupLC();
g_test.Next( _L("Assign Speed Dial"));
TInt error = KErrNone;
TRAP(error, AssignSpeedDialL( KSpeedDialContact, KSpeedDialPositionOne, *database ) );
g_test(error == KErrNone);
g_test.Next( _L("Update Speed Dial"));
error = KErrNone;
TRAP(error, UpdateSpeedDialL( KSpeedDialContact, KSpeedDialPositionTwo, *database ) );
g_test(error == KErrNone);
g_test.Next( _L("Change Database Drive"));
CContactDatabase::SetDatabaseDriveL(TDriveUnit(EDriveD),EFalse);
CleanupStack::PopAndDestroy(database);
// Kill ContactLockServer process
g_test.Next( _L("Kill CntServer"));
lockSrvTester->FindServerAndKillItL();
CleanupStack::PopAndDestroy( lockSrvTester );
g_test.Next( _L("Open Database"));
database = CContactDatabase::OpenL(KDbFileName);
CleanupStack::PushL(database);
TDriveUnit driveUnit;
CContactDatabase::DatabaseDrive(driveUnit);
g_test.Next( _L("Check that Database Drive is changed"));
g_test(driveUnit==TDriveUnit(EDriveD));
CContactItem* item = database->ReadContactL(KSpeedDialContact);
CleanupStack::PushL(item);
g_test.Next( _L("Check that Speed Dial is remembered"));
g_test(item->Id() == KSpeedDialContact);
// retored item should be a SpeedDial
g_test(ContactIsASpeedDial( *item ));
// reset Database Drive
g_test.Next( _L("Reset Database Drive setting"));
CContactDatabase::SetDatabaseDriveL(TDriveUnit(EDriveC),EFalse);
CleanupStack::PopAndDestroy(item);
CleanupStack::PopAndDestroy(database);
g_test.End();
}
示例8: TestThreeL
void TestThreeL()
{
g_test.Start(_L("Check that Settings are saved - normal shutdown"));
g_test.Next(_L("Setting up..."));
CContactDatabase* database = SetupLC();
g_test.Next( _L("Assign Speed Dial"));
TInt error = KErrNone;
TRAP(error, AssignSpeedDialL( KSpeedDialContact, KSpeedDialPositionOne, *database ) );
g_test(error == KErrNone);
g_test.Next( _L("Update Speed Dial"));
error = KErrNone;
TRAP(error, UpdateSpeedDialL( KSpeedDialContact, KSpeedDialPositionTwo, *database ) );
g_test(error == KErrNone);
g_test.Next( _L("Change Database Drive"));
CContactDatabase::SetDatabaseDriveL(TDriveUnit(EDriveD),EFalse);
CleanupStack::PopAndDestroy( database );
g_test.Next(_L("Wait for Contact Server to shutdown"));
// wait until Contacts Lock Server shuts down
// applicabale only in the case of transient server.
User::After(6000000);
g_test.Next( _L("Try to open Database again"));
database = CContactDatabase::OpenL(KDbFileName);
CleanupStack::PushL(database);
TDriveUnit driveUnit;
CContactDatabase::DatabaseDrive(driveUnit);
g_test.Next( _L("Check that Database Drive is changed"));
g_test(driveUnit==TDriveUnit(EDriveD));
CContactItem* item = database->ReadContactL(KSpeedDialContact);
CleanupStack::PushL(item);
g_test.Next( _L("Check that Speed Dial is remembered"));
g_test(item->Id() == KSpeedDialContact);
// retored item should be a SpeedDial
g_test(ContactIsASpeedDial( *item ));
// reset Database Drive
g_test.Next( _L("Reset Database Drive setting"));
CContactDatabase::SetDatabaseDriveL(TDriveUnit(EDriveC),EFalse);
CleanupStack::PopAndDestroy(item);
CleanupStack::PopAndDestroy(database);
g_test.End();
}
示例9: TestUnsuccessfulDeleteL
/**
* Test an unsuccessful delete
* @param aDb Contact database
*/
void TestUnsuccessfulDeleteL(CContactDatabase& aDb)
{
syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);
syncChecker->SetValidateResponseL(MContactSynchroniser::EEdit, KErrNone);
TContactItemId id = CreateTestICCEntryL(aDb);
// Creating the contact sets the delete error to KErrNone, so must do this afterwards
syncChecker->SetDeleteContactResponseL(KErrCorrupt);
syncChecker->ResetMethodCallCountsL();
TRAPD(err, aDb.DeleteContactL(id));
test(syncChecker->ValidateMethodCallCountL() == 2);
test(err==KErrCorrupt);
//Read contact to check it wasn't deleted anyway
CContactItem* item = NULL;
TRAP(err,item = aDb.ReadContactL(id));
test(err==KErrNone);
delete item;
}
示例10: 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);
}
示例11: TestDatabaseWithSpeedDialsL
void TestDatabaseWithSpeedDialsL()
{
g_test.Next(_L("Setting up..."));
CContactDatabase* database = SetupLC();
g_test.Next(_L("First Speed dial assignment"));
// Assign First time ok !
TRAPD(error, AssignSpeedDialL( KSpeedDialContact, KSpeedDialPositionOne, *database ) );
g_test(error == KErrNone);
g_test.Next(_L("Second Speed dial assignment"));
// Assign Second time falls over !
TRAP(error, AssignSpeedDialL( KSpeedDialContact, KSpeedDialPositionOne, *database ) );
g_test(error == KErrNone);
g_test.Next(_L("Open contact, remove from speed dial, open again"));
// The remove from speed dial on the open contact should return KErrInUse.
// The second open should also return KErrInUse.
TRAP(error, RemoveSpeedDialWhenOpenL(KSpeedDialContact, KSpeedDialPositionOne, *database));
g_test(error == KErrNone);
CleanupStack::PopAndDestroy( database );
// wait until Contacts Lock Server shuts down
User::After(6000000);
g_test.Next( _L("Try to open db again"));
database = CContactDatabase::OpenL(KDbFileName);
CleanupStack::PushL(database);
CContactItem* item = database->ReadContactL(KSpeedDialContact);
CleanupStack::PushL(item);
g_test.Next( _L("Check that Speed dial is remembered"));
g_test(item->Id() == KSpeedDialContact);
// retored item should be a SpeedDial
g_test(ContactIsASpeedDial( *item ));
CleanupStack::PopAndDestroy(item);
CleanupStack::PopAndDestroy(database);
}
示例12: TestTwoL
void TestTwoL()
{
g_test.Start(_L("Create Database with Speed Dials then Replace database"));
TestDatabaseWithSpeedDialsL();
g_test.Next(_L("Replace database"));
CContactDatabase* database = ReplaceDatabaseAndCreateContactsLC();
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();
}