本文整理汇总了C++中CContactDatabase::CommitContactL方法的典型用法代码示例。如果您正苦于以下问题:C++ CContactDatabase::CommitContactL方法的具体用法?C++ CContactDatabase::CommitContactL怎么用?C++ CContactDatabase::CommitContactL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContactDatabase
的用法示例。
在下文中一共展示了CContactDatabase::CommitContactL方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestTemplateFieldModificationL
/**
@SYMTestCaseID PIM-T-TEMPL-INC100029-0001
@SYMTestType UT
@SYMTestPriority Critical
@SYMDEF INC100029
@SYMTestCaseDesc Tests that if an attempt is made to commit the System template
with a field which contains data that the commit leaves with KErrNotSupported.
@SYMTestActions
1. Open the System template.
2. Add data to the field KUidContactFieldGivenName.
3. Commit the System template.
4. Check that step 3 leaves with error KErrNotSupported.
@SYMTestExpectedResults As per Test Action 4.
*/
LOCAL_C void TestTemplateFieldModificationL()
{
test.Next( _L("@SYMTestCaseID:PIM-T-TEMPL-INC100029-0001 Validate template field modification") );
CContactDatabase* db = CntTest->OpenDatabaseL();
//
// 1. Open the System template.
//
CContactTemplate* contactTemplate = static_cast<CContactTemplate*>( db->OpenContactLX( db->TemplateId() ) );
CleanupStack::PushL( contactTemplate );
//
// 2. Add data to the field KUidContactFieldGivenName.
//
SetNameL(*contactTemplate, KUidContactFieldGivenName, _L("Invalid"), EFalse );
//
// 3. Commit the System template.
//
TRAPD( err, db->CommitContactL( *contactTemplate ) );
//
// 4. Check that step 3 leaves with error KErrNotSupported.
//
test( err == KErrNotSupported );
CleanupStack::PopAndDestroy(2); // contactTemplate and lock.
CntTest->CloseDatabase();
}
示例2: 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;
}
示例3: 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
}
示例4: 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;
}
示例5: TestDeleteNameL
/** Delete the surname field of the contact indicated by the index. Will Leave if the contact has no surname
@leave KErrNotFound contact has no surname
@param aDb The contact database
@param aIndex The index of the contact whose surname will be removed
*/
LOCAL_C void TestDeleteNameL(CContactDatabase& aDb, TInt aIndex)
{
CContactItem* item=aDb.OpenContactL(aIndex);
CleanupStack::PushL(item);
CContactItemFieldSet& fields=item->CardFields();
TInt i = fields.Find(KUidContactFieldFamilyName);
User::LeaveIfError(i);
fields[i].TextStorage()->SetTextL(KNullDesC);
aDb.CommitContactL(*item);
CleanupStack::PopAndDestroy(item);
}
示例6: EditEntryL
void CPbTester::EditEntryL(TContactItemId itemId)
{
_LIT(KEmailAddress,"[email protected]");
CContactItem *item = ipbDb->OpenContactL(itemId);
CContactCard* card = NULL;
CleanupStack::PushL(item);
card = (CContactCard*)item;
// Create the emailAddress field and add the data to it
CContactItemField* emailAddr = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldEMail);
emailAddr->SetMapping(KUidContactFieldVCardMapEMAILINTERNET);
emailAddr ->TextStorage()->SetTextL(KEmailAddress);
card->AddFieldL(*emailAddr);
CleanupStack::Pop(emailAddr);
ipbDb->CommitContactL(*item);
CleanupStack::PopAndDestroy(item);
}
示例7: FailWriteValidationL
/**
* Unsuccessful edit. Fail the write validation request
* @param aDb Contact database
* @param aId Item Id to edit
*/
void FailWriteValidationL(CContactDatabase& aDb, TContactItemId aId)
{
syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);
syncChecker->SetValidateResponseL(MContactSynchroniser::EEdit, KErrNone);
syncChecker->SetValidateWriteResponseL(KErrAccessDenied);
syncChecker->ResetMethodCallCountsL();
CContactItem* item = aDb.OpenContactLX(aId);
CleanupStack::PushL(item);
CContactItemFieldSet& fieldset = item->CardFields();
const TInt pos = fieldset.Find(KUidContactFieldFamilyName);
CContactItemField& field = fieldset[pos];
CContactTextField* textfield = field.TextStorage();
textfield->SetTextL(KGivenEditName);
TRAPD(err, aDb.CommitContactL(*item));
test(syncChecker->ValidateMethodCallCountL() == 4);
test(err==KErrAccessDenied);
CleanupStack::PopAndDestroy(2); //item, lock record
}
示例8: CreateICCTemplateL
/**
* Create template card for ICC contact items
* @param aDb Contact database
*/
TContactItemId CreateICCTemplateL(CContactDatabase& aDb)
{
CContactItem* temp = aDb.CreateContactCardTemplateLC(KTemplateName);
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);
CContactItemField* name = CContactItemField::NewLC(KStorageTypeText,KUidContactFieldFamilyName);
name->SetMapping(KUidContactFieldVCardMapUnusedN);
temp->AddFieldL(*name);
CleanupStack::Pop(name);
CContactItemField* number = CContactItemField::NewLC(KStorageTypeText,KUidContactFieldPhoneNumber);
number->SetMapping(KUidContactFieldVCardMapTEL);
temp->AddFieldL(*number);
CleanupStack::Pop(number);
CContactItemField* slotnum = CContactItemField::NewLC(KStorageTypeText,KUidContactFieldICCSlot);
temp->AddFieldL(*slotnum);
CleanupStack::Pop(slotnum);
CContactItemField* phonebook = CContactItemField::NewLC(KStorageTypeText,KUidContactFieldICCPhonebook);
temp->AddFieldL(*phonebook);
CleanupStack::Pop(phonebook);
aDb.CommitContactL(*temp);
CleanupStack::PopAndDestroy(2); // temp, close template
return templateId;
}
示例9: CreateTestGroupsL
void CRemoteViewTestResources::CreateTestGroupsL()
{
test.Next(_L("Test for creating a remote view and validating that queued events are received in the correct order."));
TContactViewEvent event;
// Create A then "unnanmed", then rename "unnamed" to B
test.Next(_L("Test for Create group A, then create group B"));
CContactItem* group1 = iDb->CreateContactGroupLC(_L("A"));
iViewEventQueue->ListenForEvent(2,event);
CheckEvent(event, TContactViewEvent::EItemAdded, 0, group1->Id());
CContactItem* group0 = iDb->CreateContactGroupLC(_L(""));
iViewEventQueue->ListenForEvent(2,event);
CheckEvent(event, TContactViewEvent::EItemAdded, 1, group0->Id());
CContactItem *group00 = iDb->OpenContactL(group0->Id());
static_cast<CContactGroup*> (group00)->SetGroupLabelL(_L("B"));
iDb->CommitContactL(*group00);
// Received 3 events, grp changed, removed and added
iViewEventQueue->ListenForEvent(2,event);
CheckEvent(event, TContactViewEvent::EGroupChanged, 0, group00->Id());
iViewEventQueue->ListenForEvent(2,event);
CheckEvent(event, TContactViewEvent::EItemRemoved, 1, group00->Id());
iViewEventQueue->ListenForEvent(2,event);
CheckEvent(event, TContactViewEvent::EItemAdded, 1, group00->Id());
// Create D then "unnamed", then rename "unnamed" to C
test.Next(_L("Test for Create group D, then create group C"));
CContactItem* group2 = iDb->CreateContactGroupLC(_L("D"));
iViewEventQueue->ListenForEvent(2,event);
CheckEvent(event, TContactViewEvent::EItemAdded, 2, group2->Id());
CContactItem* group3 = iDb->CreateContactGroupLC(_L(""));
iViewEventQueue->ListenForEvent(2,event);
CheckEvent(event, TContactViewEvent::EItemAdded, 3, group3->Id());
CContactItem *group4 = iDb->OpenContactL(group3->Id());
static_cast<CContactGroup*> (group4)->SetGroupLabelL(_L("C"));
iDb->CommitContactL(*group4);
// Received 3 events, grp changed, removed and added
iViewEventQueue->ListenForEvent(2,event);
CheckEvent(event, TContactViewEvent::EGroupChanged, 0, group4->Id());
iViewEventQueue->ListenForEvent(2,event);
CheckEvent(event, TContactViewEvent::EItemRemoved, 3, group4->Id());
iViewEventQueue->ListenForEvent(2,event);
CheckEvent(event, TContactViewEvent::EItemAdded, 2, group4->Id());
// More complex set of add and deletes.
test.Next(_L("Test-Addgroup E, Addgroup F, Addgroup G , RemoveGroup G Addgroup H RenameGroup H as EA"));
CContactItem* group5 = iDb->CreateContactGroupLC(_L("E"));
CContactItem* group6 = iDb->CreateContactGroupLC(_L("F"));
CContactItem* group7 = iDb->CreateContactGroupLC(_L("G"));
iDb->DeleteContactL(group7->Id());
CContactItem* group8 = iDb->CreateContactGroupLC(_L("H"));
CContactItem *group01 = iDb->OpenContactL(group8->Id());
static_cast<CContactGroup*> (group01)->SetGroupLabelL(_L("EA"));
iDb->CommitContactL(*group01);
// Should receive events for operations above, order is not important
// Should receive events as add for E F EA(H) - In the order E EA(H) F
// (none for G as add, then remove)
iViewEventQueue->ListenForEvent( 2, event );
CheckEvent( event, TContactViewEvent::EItemAdded, 4, group5->Id() );
iViewEventQueue->ListenForEvent( 2, event );
CheckEvent( event, TContactViewEvent::EItemAdded, 5, group6->Id() );
iViewEventQueue->ListenForEvent( 2, event );
CheckEvent( event, TContactViewEvent::EItemAdded, 6, group8->Id() );
iViewEventQueue->ListenForEvent( 2, event );
CheckEvent( event, TContactViewEvent::EItemAdded, 7, group7->Id() );
iViewEventQueue->ListenForEvent( 2, event );
CheckEvent( event, TContactViewEvent::EItemRemoved, 7, group7->Id() );
iViewEventQueue->ListenForEvent( 2, event );
CheckEvent( event, TContactViewEvent::EGroupChanged, 0, group8->Id() );
// Cleanup
delete group01;
delete group00;
delete group4;
CleanupStack::PopAndDestroy(group8);
CleanupStack::PopAndDestroy(group7);
CleanupStack::PopAndDestroy(group6);
CleanupStack::PopAndDestroy(group5);
CleanupStack::PopAndDestroy(group3);
CleanupStack::PopAndDestroy(group2);
CleanupStack::PopAndDestroy(group0);
CleanupStack::PopAndDestroy(group1);
}