|
|
|
|
A contact item is an element in a contact database. Each contact item is
uniquely identified in the database by a contact item ID
(TContactItemId). More than one contact item ID is referred to
using a contact item ID array (CContactIdArray - a wrapper class
for an array of contact item IDs).
Contact items are accessed through the contacts database. Opening a
contact item (using CContactDatabase::OpenContactL()) locks it so
that it cannot be edited by another client. Closing the contact item (using
CContactDatabase::CloseContactL()) releases the lock on the item
without saving any changes made to it. Committing the contact item (using
CContactDatabase::CommitContactL()) releases the lock and saves
any changes made to it.
For instance, the following code opens an item, edits it, then commits the changes:
CContactItem* contactItem = db->OpenContactL(itemID);
CleanupStack::PushL(contactItem);
// First get the item's field set
CContactItemFieldSet& fieldSet=contactItem->CardFields();
// Search the field set for the given name field
TInt index = fieldSet.Find(KUidContactFieldGivenName);
CContactItemField &field= fieldSet[index];
// Set the given name field to "Fred"
_LIT(KName, "Fred");
field.TextStorage()->SetTextL(KName);
// Commit the change back to database and clean up
db->CommitContactL(*contactItem);
CleanupStack::PopAndDestroy(contactItem);
All contact items have the abstract base class CContactItem.
Concrete implementations of the base class are:
Contact cards: CContactCard
Templates, which set the initial fields for other contact items:
CContactCardTemplate
Contact groups, which hold a set of associated contact item IDs:
CContactGroup
Own card, which is a contact card that contains information about the
device's owner: CContactOwnCard