Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: cntdb.h
Link against: cntmodel.lib

Class CContactDatabase

CContactDatabase

Support

Supported from 5.0

Description

A database of contact items.

Contact items can be added to and removed from the database and items in the database can be opened or read. To edit an item, the item must first be opened. Changes to the item can then be committed to the database using CommitContactL(). Committing can only take place to an open item. Reading an item provides read only access to it.

When deleting a contact item, note that each item has an access count. The item cannot be fully deleted unless its access count is zero. This is to prevent contact items which have been synchronised with a PC scheduler application for example from being deleted. Also, if the item is a template, it cannot be deleted if other items are based on it.

More than one contact database can exist on an EPOC device, but there is always a single default contact database. The default database is the database which is loaded by default when the Contacts application starts up. Its filename is contacts.cdb. The default database can be moved between drives, but must always be stored in the \system\data\ folder.

The CContactDatabase class implements searching and sorting. It also provides separate phone number matching functions. Phone number matching provides a high speed method of indexing and looking up phone numbers. This is primarily intended for looking up caller IDs on incoming calls. Before looking up phone numbers, the index must be created. This only needs to be done once, when the contact database is opened. From then on, the index is automatically maintained by the database server. Index creation is started by a call to InitLoadPhoneMatchesL(). Then it is updated using calls to LoadPhoneMatchesL().

The database owns speed dial information. This is a mapping between a single digit integer and a telephone number. There may be up to 9 speed dial telephone numbers; each of them belongs to a contact item in the database — if a contact item is deleted, its speed dial mapping is removed.

The following functions defined in class CContactDatabase are not currently supported. If called, they leave with KErrNotSupported.

Derivation

CBaseBase class for all classes to be instantiated on the heap
CContactDatabaseA database of contact items
MContactDbPrivObserverBase class used in the derivation of CContactDatabase

Defined in CContactDatabase:
AddContactToGroupL(), AddNewContactL(), CloseContactL(), CloseTables(), CommitContactL(), CompactL(), CompressL(), CompressRequired(), ConnectionId(), ContactsChangedSinceL(), CountL(), CreateCompressorLC(), CreateContactCardTemplateL(), CreateContactCardTemplateLC(), CreateContactGroupL(), CreateContactGroupLC(), CreateL(), CreateOwnCardL(), CreateOwnCardLC(), CreateRecoverLC(), DatabaseDrive(), DeleteContactL(), DeleteContactsL(), DeleteDefaultFileL(), DeletedContactsLC(), EDecreaseAccessCount, EExcludeUid, EImportSingleContact, EIncludeX, EIncreaseAccessCount, EMultiThread, ESingleThread, ETTFormat, ExportSelectedContactsL(), FileSize(), FileUid(), FilterDatabaseL(), FindAsyncL(), FindContactFile(), FindInTextDefAsyncL(), FindInTextDefLC(), FindLC(), GetCardTemplateIdListL(), GetCurrentDatabase(), GetCurrentItem(), GetDbViewContactType(), GetDefaultNameL(), GetGroupIdListL(), GetLastSyncDateL(), GetSpeedDialFieldL(), GroupCount(), ImportContactsL(), InitLoadPhoneMatchesL(), IsDamaged(), LoadPhoneMatchesL(), MachineId(), MatchPhoneNumberL(), NullUidValue(), OpenContactL(), OpenContactLX(), OpenL(), OpenTablesL(), OwnCardId(), PhoneMatchListL(), PrefTemplateId(), ReadContactAndAgentL(), ReadContactL(), ReadContactLC(), ReadContactTextDefL(), ReadMinimalContactL(), ReadMinimalContactLC(), RecoverL(), RemoveContactFromGroupL(), RemoveSpeedDialFieldL(), ReplaceL(), SetCurrentDatabase(), SetCurrentItem(), SetDatabaseDriveL(), SetDateFormatTextL(), SetDbViewContactType(), SetFieldAsSpeedDialL(), SetLastSyncDateL(), SetOwnCardL(), SetPrefTemplateL(), SetTextDefinitionL(), SetViewDefinitionL(), SortArrayL(), SortArrayLC(), SortByTypeL(), SortL(), SortedItemsL(), TOptions, TSortPref, TThreadAccess, TemplateContentType(), TemplateCount(), TemplateId(), TextDefinition(), TextToPhoneMatchNumber(), Version(), ~CContactDatabase()

Inherited from CBase:
operator new()


Create and open


OpenL()

static CContactDatabase* OpenL();
static CContactDatabase* OpenL(const TDesC& aFileName);

Support

Withdrawn in 6.0

Description

Opens a contact database. The database may be named, or, if no name is specified, the default database is opened.

The name of the default contact database is hard coded as \system\data\contacts.cdb. By default it is assumed to be on drive c:, but this can be changed using the SetDatabaseDriveL() function.

Note:

Clients should not assume any knowledge of the default database name or location — they may be changed in future releases.

Parameters

const TDesC& aFileName

The path and filename of the database to open.

Return value

CContactDatabase*

Pointer to the open contact database.

Leave codes

KErrNotFound

The database does not exist.


OpenL()

static CContactDatabase* OpenL(TThreadAccess aAccess=ESingleThread);
static CContactDatabase* OpenL(const TDesC& aFileName,TThreadAccess aAccess=ESingleThread);

Support

Supported from 6.0

Description

Opens a contact database. The database may be named, or, if no name is specified, the default database is opened.

The name of the default contact database is hard coded as \system\data\contacts.cdb. By default it is assumed to be on drive c:, but this can be changed using the SetDatabaseDriveL() function.

Note:

Clients should not assume any knowledge of the default database name or location — they may be changed in future releases.

Parameters

const TDesC& aFileName

The path and filename of the database to open.

TThreadAccess aAccess=ESingleThread

The default, ESingleThread allows access to the session with the database server from a single client thread only (as in EPOC Releases 5 and 5.1). EMultiThread allows multiple client threads to share the same session with the server. As multi-threaded programs are uncommon in EPOC, this argument can be ignored by most C++ developers.

Return value

CContactDatabase*

Pointer to the open contact database.

Leave codes

KErrNotFound

The database does not exist.


CreateL()

static CContactDatabase* CreateL();
static CContactDatabase* CreateL(const TDesC& aFileName);

Support

Withdrawn in 6.0

Description

Creates and opens an empty contact database. The new database may be assigned a name, or if no name is specified, a database with the default name is created.

Parameters

const TDesC& aFileName

The path and filename of the database to create.

Return value

CContactDatabase*

Pointer to the new contact database.

Leave codes

KErrAlreadyExists

The database file already exists.


CreateL()

static CContactDatabase* CreateL(TThreadAccess aAccess=ESingleThread);
static CContactDatabase* CreateL(const TDesC& aFileName,TThreadAccess aAccess=ESingleThread);

Support

Supported from 6.0

Description

Creates and opens an empty contact database. The new database may be assigned a name, or if no name is specified, a database with the default name is created.

Parameters

const TDesC& aFileName

The path and filename of the database to create.

TThreadAccess aAccess

The default, ESingleThread allows access to the session with the database server from a single client thread only (as in EPOC Releases 5 and 5.1). EMultiThread allows multiple client threads to share the same session with the server. As multi-threaded programs are uncommon in EPOC, this argument can be ignored by most C++ developers.

Return value

CContactDatabase*

Pointer to the new contact database.

Leave codes

KErrAlreadyExists

The database file already exists.


ReplaceL()

static CContactDatabase* ReplaceL();
static CContactDatabase* ReplaceL(const TDesC& aFileName);

Support

Withdrawn in 6.0

Description

Creates and opens an empty contact database, replacing any existing file with the same name. The name may be specified, or if not, the function replaces the default database.

Parameters

const TDesC& aFileName

The path and filename of the database to replace.

Return value

CContactDatabase*

Pointer to the new contact database.


ReplaceL()

static CContactDatabase* ReplaceL(TThreadAccess aAccess=ESingleThread);
static CContactDatabase* ReplaceL(const TDesC& aFileName,TThreadAccess aAccess=ESingleThread);

Support

Supported from 6.0

Description

Creates and opens an empty contact database, replacing any existing file with the same name. The name may be specified, or if not, the function replaces the default database.

Parameters

const TDesC& aFileName

The path and filename of the database to replace.

TThreadAccess aAccess

The default, ESingleThread allows access to the session with the database server from a single client thread only (as in EPOC Releases 5 and 5.1). EMultiThread allows multiple client threads to share the same session with the server. As multi-threaded programs are uncommon in EPOC, this argument can be ignored by most C++ developers.

Return value

CContactDatabase*

Pointer to the new contact database.


DeleteDefaultFileL()

static void DeleteDefaultFileL();

Description

Deletes the default contact database.

[Top]


Destructor


~CContactDatabase()

~CContactDatabase()

Description

The destructor frees all resources owned by the contact database, prior to its destruction.

[Top]


Location


DatabaseDrive()

static TBool DatabaseDrive(TDriveUnit& aDriveUnit);

Description

Gets the currently set database drive. The database drive is the drive on which the default contact database is located.

Parameters

TDriveUnit& aDriveUnit

On return, contains the database drive.

Return value

TBool

ETrue if the database drive has been set using SetDatabaseDriveL(). Otherwise EFalse and in this case, the function returns drive c: in aDriveUnit as the current drive.


SetDatabaseDriveL()

static void SetDatabaseDriveL(TDriveUnit aDriveUnit, TBool aCopy=ETrue);

Description

Sets the contact database drive and optionally moves the default contact database from its current location to the new drive. This function guarantees an all or nothing operation. If the database is not successfully moved, the drive setting is not updated to reflect the change.

Parameters

TDriveUnit aDriveUnit

The drive to which to move the database.

TBool aCopy=ETrue

ETrue to move the existing file to \system\data\ on the specified drive. EFalse does not move the file.

Leave codes

KErrNotReady

There is no media present in the drive.


FindContactFile()

static TBool FindContactFile(TDes& aFileName);

Description

Finds the location of the contact database with the default file name (\system\data\contacts.cdb). Drives are searched using class TFindFile and the name of the first file found is copied into aFileName.

Parameters

TDes& aFileName

On return, contains the full path and filename of the default contact database.

Return value

TBool

EFalse if no file is found. ETrue if a file is found.


GetDefaultNameL()

static void GetDefaultNameL(TDes& aDes);

Description

Gets the full file name of the default contact database.

The name of the default contact database is \system\data\contacts.cdb. By default it is assumed to be on drive c:, but this can be changed using the SetDatabaseDriveL() function.

Parameters

TDes& aDes

On return, contains the full path and filename of the default contact database.

[Top]


View and text definitions


SetViewDefinitionL()

void SetViewDefinitionL(CContactViewDef* aView);

Description

Sets the default view definition. The contact database takes ownership of the view definition specified. The default view definition is used in calls to ReadContactL(), ReadContactLC() and ReadContactAndAgentL() when no view definition is explicitly specified.

Parameters

CContactViewDef* aView

The view definition.


SetTextDefinitionL()

void SetTextDefinitionL(CContactTextDef* aView);

Description

Sets the current text definition. The contact database takes ownership of the text definition specified.

Parameters

CContactTextDef* aView

The new text definition.


TextDefinition()

const CContactTextDef* TextDefinition() const;

Description

Gets a pointer to the current text definition.

Return value

CContactTextDef*

A pointer to the current text definition.


SetDateFormatTextL()

void SetDateFormatTextL(const TDesC &aFormat);

Description

This function is not currently supported.

[Top]


Groups


CreateContactGroupL()

CContactItem* CreateContactGroupL(TBool aInTransaction=EFalse);
CContactItem* CreateContactGroupL(const TDesC& aGroupLabel,TBool aInTransaction=EFalse);

Support

Supported from 6.0

Description

Creates a new contact group and adds it to the database — overloaded function. The group label may be specified, or if not, the default string "Group Label" is assigned as the label for the group. The caller takes ownership of the returned object.

Parameters

TBool aInTransaction=EFalse

This argument should be ignored by developers.

const TDesC& aGroupLabel

If specified, the string to set as the group label.

Return value

CContactItem*

Pointer to the newly created contact group.


CreateContactGroupLC()

CContactItem* CreateContactGroupLC(TBool aInTransaction=EFalse);
CContactItem* CreateContactGroupLC(const TDesC& aGroupLabel,TBool aInTransaction=EFalse);

Support

Supported from 6.0

Description

Creates a new contact group and adds it to the database — overloaded function. The group label may be specified, or if not, the default string "Group Label" is assigned as the label for the group. The pointer to the group is left on the cleanup stack. The caller takes ownership of the returned object.

Parameters

TBool aInTransaction=EFalse

This argument should be ignored by developers.

const TDesC& aGroupLabel

If specified, the string to set as the group label.

Return value

CContactItem*

Pointer to the newly created contact group.


GetGroupIdListL()

CContactIdArray* GetGroupIdListL() const;

Support

Supported from 6.0

Description

Returns a copy of the database's group ID list. This is a list which contains the contact item IDs for each group in the database. The caller takes ownership of the returned object.

Return value

CContactIdArray*

Pointer to an array containing the contact item IDs for each group in the database. NULL if there are no groups in the database.


AddContactToGroupL()

void AddContactToGroupL(TContactItemId aItemId, TContactItemId aGroupId);
void AddContactToGroupL(TContactItemId aItemId, TContactItemId aGroupId, TBool aInTransaction);
void AddContactToGroupL(CContactItem& aItem, CContactItem& aGroup);

Support

Supported from 6.0

Description

Sets a contact item which already exists in the database to be a member of a contact group — overloaded function. Specify a reference to the item and group, or their contact item IDs.

Parameters

TContactItemId aItemId

The ID of the item to add to the group.

TContactItemId aGroupId

The ID of the group to which the item should be added.

TBool aInTransaction

This argument should be ignored by third party developers.

CContactItem& aItem

Reference to the item to add to the group.

CContactItem& aGroup

Reference to the group to which the item should be added.

Leave codes

KErrNotFound

Either the group or the item does not exist.

KErrNotSupported

The group is not of type KUidContactGroup.


RemoveContactFromGroupL()

void RemoveContactFromGroupL(CContactItem& aItem, CContactItem& aGroup);
void RemoveContactFromGroupL(TContactItemId aItemId, TContactItemId aGroupId);

Support

Supported from 6.0

Description

Removes the association between a contact item and a group — overloaded function.

A panic is raised if:

Parameters

CContactItem& aItem

Reference to the item to remove.

CContactItem& aGroup

Reference to the group from which the item should be removed.

TContactItemId aItemId

ID of the item to remove.

TContactItemId aGroupId

ID of the group from which the item should be removed.


GroupCount()

TInt GroupCount() const;

Support

Supported from 6.0

Description

Returns the number of groups that currently exist in the database.

Return value

TInt

The number of groups that currently exist in the database.

[Top]


Open and close a contact


OpenContactL()

CContactItem* OpenContactL(TContactItemId aContactId);
CContactItem* OpenContactL(TContactItemId aContactId,const CContactItemViewDef& aViewDef);

Description

Opens a contact item for editing — overloaded function. The returned contact item is locked and left open until either CommitContactL() or CloseContactL() is called.

The variant of the function which does not take a view definition parameter uses a view definition which loads every field.

Notes:

Parameters

TContactItemId aContactId

The ID of the contact item to open.

const CContactItemViewDef& aViewDef

If specified, the view definition.

Return value

CContactItem*

The open, locked contact.

Leave codes

KErrInUse

The contact item is already open.

KErrNotFound

The contact item is not present in the database.


OpenContactLX()

CContactItem* OpenContactLX(TContactItemId aContactId);
CContactItem* OpenContactLX(TContactItemId aContactId,const CContactItemViewDef& aViewDef);

Description

Opens the contact item for editing — overloaded function. The returned item is locked and left open until either CommitContactL() or CloseContactL() is called.

The variant of the function which does not take a view definition parameter uses a view definition which loads every field.

The LX suffix means that the lock record of the contact item is left on the cleanup stack.

Notes:

Parameters

TContactItemId aContactId

The ID of the contact item to open.

const CContactItemViewDef& aViewDef

The view definition.

Return value

CContactItem*

The open, locked contact item.

Leave codes

KErrInUse

The contact item is already open.

KErrNotFound

The contact item is not present in the database.


CloseContactL()

void CloseContactL(TContactItemId aContactId);

Description

Closes the contact item allowing other applications to access it. Specifying a contact item that is not open, or cannot be found, is harmless. This function does not commit any changes made to the item. Despite the trailing L in the function's name, this function cannot leave.

Parameters

TContactItemId aContactId

The ID of the contact to close.


CommitContactL()

void CommitContactL(const CContactItem& aContact);

Description

Overwrites a contact item with the values contained in aContact. The contact item is also closed by this call.

Parameters

const CContactItem& aContact

Contains the new values for the contact item.

Leave codes

KErrAccessDenied

The contact item is not locked by the caller.

KErrNotFound

The contact item's ID is not present in the database.

[Top]


Reading


ReadContactL()

CContactItem* ReadContactL(TContactItemId aContactId);
CContactItem* ReadContactL(TContactItemId aContactId,const CContactItemViewDef& aViewDef);

Description

Reads a contact item — overloaded function. Unlike OpenContactL(), these functions do not lock the contact.

The variant of the function which does not take a view definition parameter uses the default view definition (as set by SetViewDefinitionL()). The caller takes ownership of the returned object.

Parameters

TContactItemId aContactId

The ID of the contact item to read.

const CContactItemViewDef& aViewDef

If specified, the view definition to use.

Return value

CContactItem*

Pointer to the contact item.

Leave codes

KErrNotFound

The specified contact item does not exist in the database.


ReadContactLC()

CContactItem* ReadContactLC(TContactItemId aContactId);
CContactItem* ReadContactLC(TContactItemId aContactId,const CContactItemViewDef& aViewDef);

Description

Reads a contact item — overloaded function. Unlike OpenContactL(), this function does not lock the contact.

The variant of the function which does not take a view definition parameter uses the default view definition (as set by SetViewDefinitionL()). The caller takes ownership of the returned object.

Parameters

TContactItemId aContactId

The ID of the contact to read.

const CContactItemViewDef& aViewDef

If specified, the view definition to use.

Return value

CContactItem*

Pointer to the contact whose ID is aContactId. The contact is left on the cleanup stack.

Leave codes

KErrNotFound

The specified contact item does not exist in the database.


ReadMinimalContactL()

CContactItem* ReadMinimalContactL(TContactItemId aContactId);

Support

Supported from 6.0

Description

Reads a contact item (contact card, own card, template, or contact group), but does not read the group or template information. This function is identical to the variant of ReadContactL() which uses the database's default view definition, except that the following information is not read: —

Notes:

Parameters

TContactItemId aContactId

The ID of the contact to read.

Return value

CContactItem*

Pointer to the contact whose ID is aContactId.

Leave codes

KErrNotFound

The specified contact item cannot be found in the database.


ReadMinimalContactLC()

CContactItem* ReadMinimalContactLC(TContactItemId aContactId);

Support

Supported from 6.0

Description

Reads a contact item (contact card, own card, template, or contact group), but does not read the group or template information. The object is left on the cleanup stack. This function is identical to the variant of ReadContactL() which uses the database's default view definition, except that the following information is not read: —

Notes:

Parameters

TContactItemId aContactId

The ID of the contact to read.

Return value

CContactItem*

Pointer to the contact whose ID is aContactId. The contact is left on the cleanup stack.

Leave codes

KErrNotFound

The specified contact item cannot be found in the database.


ReadContactTextDefL()

void ReadContactTextDefL(const CContactItem& aItem, TDes& aResult);
void ReadContactTextDefL(const CContactItem& aItem, TDes& aResult,CContactTextDef* aTextDef);

Description

Reads text into a descriptor from a pre-loaded contact item, using a text definition — overloaded function.

The variant of the function which does not take a text definition parameter uses the database's currently set text definition (as set using CContactDatabase::SetTextDefinitionL()).

Parameters

const CContactItem& aItem

The contact item to read.

TDes& aResult

On return, contains the text read from the contact item aItem, using either the database's current text definition or the text definition specified in aTextDef.

CContactTextDef* aTextDef

If specified, the text definition to use.


ReadContactTextDefL()

void ReadContactTextDefL(TContactItemId aContactId, TDes& aResult);
void ReadContactTextDefL(TContactItemId aContactId, TDes& aResult,CContactTextDef* aTextDef);

Description

Reads text from a contact item stored in the database into a descriptor — overloaded function. It uses the database's currently set text definition (as set using CContactDatabase::SetTextDefinitionL()), or, if specified, the text definition aTextDef. The contact item is identified by its contact ID.

Parameters

TContactItemId aContactId

The ID of the contact to read.

TDes& aResult

On return, contains the text read from the contact item identified by aContactId, using either the database's current text definition or the text definition specified in aTextDef.

CContactTextDef* aTextDef

If specified, the text definition to use.

Leave codes

KErrNotFound

The specified contact item cannot be found in the database.


ReadContactAndAgentL()

CArrayPtr<CContactItem>* ReadContactAndAgentL(TContactItemId aContactId);

Description

Reads a contact item and an agent if the item has an agent field. The item and agent (if present) are returned in an array. The function uses the database's default view definition (as set by SetViewDefinitionL()). The caller takes ownership of the returned object.

Parameters

TContactItemId aContactId

The ID of the contact item to read.

Return value

CArrayPtr<CContactItem>*

Pointer to an array containing the contact item and agent, if present.

Leave codes

KErrNotFound

The specified contact item cannot be found in the database.

[Top]


Add and remove items


AddNewContactL()

TContactItemId AddNewContactL(CContactItem& aContact);

Description

Adds a new contact item to the database and returns its contact item ID.

Parameters

CContactItem& aContact

The contact item to add to the database.

Return value

TContactItemId

The ID of the new contact item.


DeleteContactL()

void DeleteContactL(TContactItemId aContactId);

Description

Deletes a contact item.

Note:

If the contact’s access count is greater than zero the contact is not fully deleted from the database. A skeleton of the contact is left, containing only basic information, and no field data. The skeleton contact can still be accessed if a record of its contact ID has been retained (or call DeletedContactsLC()). The skeleton is removed when the access count is zero.

Parameters

TContactItemId aContactId

The contact item ID of the contact to delete.

Leave codes

KErrNotFound

aContactId is not present in the database.

KErrInUse

The contact item is open.


DeleteContactsL()

void DeleteContactsL(const CContactIdArray& aContactIds);

Description

Deletes an array of contacts. The function commits the database for every 16 contacts deleted, and compresses the database as required. A changed message is not sent for every contact deleted, instead a single unknown change event message (EContactDbObserverEventUnknownChanges) is sent after all the contacts have been deleted and the changes committed.

Parameters

const CContactIdArray& aContactIds

An array of contacts to delete.

Leave codes

KErrNotFound

A contact item ID contained in the array is not present in the database.

KErrInUse

One or more of the contact items is open.

[Top]


Import and export


ImportContactsL()

CArrayPtr<CContactItem>* ImportContactsL(const TUid& aFormat,RReadStream& aReadStream,TBool& aImportSuccessful,TInt aOption);

Description

Imports one or more vCards from a read stream. The vCards are converted into contact items, and added to the database. If at least one contact item was successfully imported, aImportSuccessful is set to ETrue. If EImportSingleContact is specified in aOption, the read stream marker is left at the next position, ready to read the next contact item. The caller takes ownership of the returned object.

Parameters

const TUid& aFormat

Indicates the format for imported and exported contacts. Its value must be KVersitEntityUidVCard.

RReadStream& aReadStream

The stream to read from.

TBool& aImportSuccessful

On return, ETrue if at least one contact was successfully imported. EFalse if not.

TInt aOption

Indicates the options for import and export. See the TOptions enum.

Return value

CArrayPtr<CContactItem>*

The array of contact items imported.

Leave codes

KErrNotSupported

aFormat.iUid is not KVersitEntityUidVCard.


ExportSelectedContactsL()

void ExportSelectedContactsL(const TUid& aFormat,const CContactIdArray& aSelectedContactIds,RWriteStream& aWriteStream,TInt aOption,TBool aExportPrivateFields=ETrue);
void ExportSelectedContactsL(const TUid& aFormat,const CContactIdArray& aSelectedContactIds,RWriteStream& aWriteStream,TInt aOption,const CVersitParser::TVersitCharSet aCharSet, TBool aExportPrivateFields=ETrue);

Support

Supported from 6.0

Description

Exports an array of contact items to a write stream — overloaded function. The items are converted into vCards before being written to the stream.

Parameters

const TUid& aFormat

Indicates the format for imported and exported contacts. Must have a value of KVersitEntityUidVCard.

const CContactIdArray& aSelectedContactIds

Array of contact IDs to export.

RWriteStream& aWriteStream

The stream to write to.

TInt aOption

Indicates the options for import and export. See the TOptions enum.

const CVersitParser::TVersitCharSet aCharSet

The character format. If not specified, defaults to CVersitParser::EUTF8CharSet.

TBool aExportPrivateFields=ETrue

ETrue exports fields marked as private. EFalse does not export fields marked as private. See CContactItemField::SetPrivate().

Leave codes

KErrNotSupported

aFormat.iUid is not KVersitEntityUidVCard.

KErrNotFound

One or more of the contact items does not exist in the database.

[Top]


Search


FindLC()

CContactIdArray* FindLC(const TDesC& aText,const CContactItemFieldDef *aFieldDef);

Description

Searches the database for a text string. The function searches the fields contained in the field definition. The caller takes ownership of the returned object.

Parameters

const TDesC& aText

The text to search for.

const CContactItemFieldDef *aFieldDef

Specifies the fields to search.

Return value

CContactIdArray*

Array of contact IDs identifying the contact items which contain the specified text.


FindAsyncL()

CIdleFinder* FindAsyncL(const TDesC& aText,const CContactItemFieldDef *aFieldDef, MIdleFindObserver *aObserver);

Description

Searches the database asynchronously for a text string. The function searches the fields contained in the field definition asynchronously using the MIdleFindObserver and CIdleFinder classes. The caller takes ownership of the returned object.

Parameters

const TDesC& aText

The text to search for.

const CContactItemFieldDef *aFieldDef

Specifies the fields to search.

MIdleFindObserver *aObserver

Implements the callback function IdleFindCallback(). NULL if no observer is needed.

Return value

CIdleFinder*

A CIdle-derived object which provides information about the progress of the operation, and which can be used to retrieve an array of contact IDs.


FindInTextDefLC()

CContactIdArray* FindInTextDefLC(const MDesCArray& aFindWords, const TCallBack& aWordParserCallback);
CContactIdArray* FindInTextDefLC(const MDesCArray& aFindWords,CContactTextDef* aTextDef, const TCallBack& aWordParserCallback);

Description

Allows the user to search the database for a string containing text which is stored in one or more fields — overloaded function. The string is specified as an array of words.

For example, a user might want to search for the string "John Smith". To the user the string is a single item, but the text which makes up the string is stored in two separate fields in the database.

The caller of this function needs to provide an array of words to find (aFindWords), and a function to break down the text in the contact item into a list of words (aWordParserCallback).

The array of words to find would typically not contain punctuation. For example if the user searches for “Smith, John” this would be passed to this function as an array of two words: “Smith” and “John”, with the separator being discarded.

For a match to succeed, all words in the aFindWords array must match words in the array generated from the contact item by the aWordParserCallback function. To match, the word generated from the contact item must begin with the search word, i.e. a search for "Sm" would find any word beginning in "Sm". If a word is specified twice in the aFindWords array, then it must exist in two separate places in the contact item.

The function only searches the fields contained in the text definition aTextDef, if specified. If not specified, the function uses the currently set text definition.

The caller takes ownership of the returned object.

Parameters

const MDesCArray& aFindWords

An array of words to find.

const TCallBack& aWordParserCallback

A function supplied by the caller to break the text in the contact down into a list of words.

CContactTextDef* aTextDef

If specified, the text definition.

Return value

CContactIdArray*

Array of contact IDs.


FindInTextDefAsyncL()

CIdleFinder* FindInTextDefAsyncL(const MDesCArray& aFindWords, MIdleFindObserver *aObserver, const TCallBack& aWordParserCallback);
CIdleFinder* FindInTextDefAsyncL(const MDesCArray& aFindWords,const CContactTextDef* aTextDef, MIdleFindObserver *aObserver, const TCallBack& aWordParserCallback);

Description

Searches the database for an array of words — overloaded function.

These two functions work in the same way as the corresponding variants of FindInTextDefLC(), except that they operate asynchronously using the MIdleFindObserver and CIdleFinder classes. The caller takes ownership of the returned object.

Parameters

const MDesCArray& aFindWords

An array of words to find.

MIdleFindObserver *aObserver

Implements the callback function IdleFindCallback(). May be NULL if no observer is needed.

const TCallBack& aWordParserCallback

A function to break the text in the contact down into a list of words.

const CContactTextDef* aTextDef

If specified, the text definition.

Return value

CIdleFinder*

A CIdle-derived object which provides information about the progress of the operation, and which can be used to retrieve an array of contact IDs.

[Top]


Sort


SortL()

void SortL(CArrayFix<TSortPref>* aSortOrder);

Description

Sorts the database. The sort only includes items of the type set by SetDbViewContactType(). The database takes ownership of the sort order array passed in. Contacts are sorted using the first TSortPref in the array. Any identical matches are then sorted using the next TSortPref and so on. When there are no more TSortPrefs to use, any remaining unsorted contacts are left in the natural database order.

Note:

After calling this function, use CContactDatabase::SortedItemsL() to retrieve the sorted array of contact IDs.

Parameters

CArrayFix<TSortPref>* aSortOrder

Sort order array. If the array's count is zero, no sorting takes place.


SortArrayL()

CContactIdArray* SortArrayL(const CContactIdArray* aIdArray, const CArrayFix<TSortPref>* aSortOrder)

Description

Sorts an array of contact IDs. The sort uses the same logic as SortL(). The caller takes ownership of the returned object.

Parameters

const CContactIdArray* aIdArray

Pointer to array of contact IDs to sort.

const CArrayFix<TSortPref>* aSortOrder

Sort order array.

Return value

CContactIdArray*

Pointer to sorted array of contact IDs.


SortArrayLC()

CContactIdArray* SortArrayLC(const CContactIdArray* aIdArray, const CArrayFix<TSortPref>* aSortOrder);

Support

Supported from 6.0

Description

Sorts an array of contact IDs. The sort uses the same logic as SortL(). The returned array is left on the cleanup stack. The caller takes ownership of the returned object.

Parameters

const CContactIdArray* aIdArray

Pointer to array of contact IDs to sort.

const CArrayFix<TSortPref>* aSortOrder

Sort order array.

Return value

CContactIdArray*

Pointer to sorted array of contact IDs.


SetDbViewContactType()

void SetDbViewContactType(const TUid aUid);

Support

Supported from 6.0

Description

Sets the type of contact items to be included in sorted views of the database. See also SortL() and SortByTypeL().

This value is initialised to KUidContactItem when the database is opened. This means that all CContactItem-derived types (cards, non-system templates, groups, own cards) are included in database views.

Parameters

const TUid aUid

Specifies a contact type. One of the following: — KUidContactCard (contact cards), KUidContactGroup (contact item groups), KUidContactOwnCard (own cards), KUidContactCardTemplate (templates which are not system templates, i.e. which have been added to the database), KUidContactItem (all of the above)


GetDbViewContactType()

TUid GetDbViewContactType() const;

Support

Supported from 6.0

Description

Gets the type of contact items which are included in sorted views of the database, as set by SetDbViewContactType().

Return value

TUid

Specifies a contact type. One of the following: — KUidContactCard (contact cards), KUidContactGroup (contact item groups), KUidContactOwnCard (own cards), KUidContactCardTemplate (templates which are not system, i.e. which have been added to the database), KUidContactItem (all of the above)


SortByTypeL()

void SortByTypeL(CArrayFix<TSortPref>* aSortOrder);

Support

Supported from 6.0

Description

Sorts the database using the view type value set by SetDbViewContactType(). The database takes ownership of the sort order array passed in.

The sort uses the same logic as SortL() — the two functions have the same effect.

After calling this function, use CContactDatabase::SortedItemsL() to retrieve the sorted array of contact IDs.

Parameters

CArrayFix<TSortPref>* aSortOrder

Sort order array.


SortedItemsL()

const CContactIdArray* SortedItemsL();

Description

Returns a pointer to the array of contact items which have been sorted by either SortByTypeL() or SortL(). This pointer is valid until a change is made to the database or until the database’s active object is allowed to run. If the array is required after one of the above two events has occurred, a copy of the array must first be made.

Return value

CContactIdArray*

A pointer to the array of sorted items. The caller does not take ownership of this object.

[Top]


Own card


CreateOwnCardL()

CContactItem* CreateOwnCardL();

Support

Supported from 6.0

Description

Creates a default own card based on the system template and adds it to the database. This is set as the database's current own card, replacing any existing current own card. The caller takes ownership of the returned object.

Return value

CContactItem*

Pointer to the new default own card.


CreateOwnCardLC()

CContactItem* CreateOwnCardLC();

Support

Supported from 6.0

Description

Creates a default own card based on the system template and adds it to the database. This is set as the database's current own card, replacing any existing current own card. The caller takes ownership of the returned object.

Return value

CContactItem*

Pointer to the new default own card. The pointer is left on the cleanup stack.


OwnCardId()

TContactItemId OwnCardId() const;

Support

Supported from 6.0

Description

Returns the ID of the database's current own card.

Having obtained this ID, the client may then open the own card in the same way as an ordinary contact card (using ReadContactL() or OpenContactL()).

Return value

TContactItemId

The ID of the database's current own card. KNullContactId if the own card has been deleted or has not yet been set.


SetOwnCardL()

void SetOwnCardL(const CContactItem& aContact);

Support

Supported from 6.0

Description

Sets an existing contact item to be the database's current own card.

Parameters

const CContactItem& aContact

The contact item to set as the database's current own card. It must already exist in the database. It can be of any contact item type.

Leave codes

KErrNotFound

aContact does not exist in the database.

[Top]


Current item and database


SetCurrentItem()

void SetCurrentItem(const TContactItemId aContactId);

Support

Supported from 6.0

Description

Sets the ID of the current item and persists it in the database. The current item is provided for use by clients who want to identify one contact item in the database as the currently selected item.

Parameters

const TContactItemId aContactId

The ID of the current item.


GetCurrentItem()

const TContactItemId GetCurrentItem() const;

Support

Supported from 6.0

Description

Gets the ID of the current item, as set by SetCurrentItem(). The current item ID is initialised to KNullContactId when the database is opened.

Return value

TContactItemId

The ID of the current item.


SetCurrentDatabase()

TInt SetCurrentDatabase(const TDesC& aDatabase) const;

Support

Supported from 6.0

Description

Where there are multiple contact databases on a device, this function can be used to set a database as the current one.

Note:

This function simply updates a file name which is stored by the contacts server and its use is optional. It is provided as part of current item functionality. In order to pass a current item from one contacts model client to another, the receiving client needs to be using the same database.

Parameters

const TDesC& aDatabase

The path and filename of the current database.

Return value

TInt

KErrNone if the function completed successfully, otherwise one of the standard error codes.


GetCurrentDatabase()

TInt GetCurrentDatabase(TDes& aDatabase) const;

Support

Supported from 6.0

Description

Where there are multiple contact databases on a device, this function can be used to enquire which database is the current one. The current database functions are provided as part of current item functionality. In order to pass a current item from one contacts model client to another, the receiving client needs to be using the same database.

The current database is a path and filename, set using SetCurrentDatabase() which is persisted by the contacts server.

Parameters

TDes& aDatabase

The path and filename of the current database. KNullDesC if the current database has not been set.

Return value

TInt

KErrNone if the function completed successfully, otherwise one of the standard error codes.

[Top]


Connectivity


FilterDatabaseL()

void FilterDatabaseL(CCntFilter& aFilter);

Support

Supported from 6.0

Description

Filters the database. On return, aFilter contains an array of filtered contact item IDs.

Parameters

CCntFilter& aFilter

The filter to use. On return, contains a filtered array of contact item IDs.


SetLastSyncDateL()

TContactSyncId SetLastSyncDateL(const TTime& aSyncDate);
void SetLastSyncDateL(TContactSyncId aSyncId, const TTime& aSyncDate);

Support

Supported from 6.0

Description

Sets the date/time the database was last synchronised e.g. with a PC scheduler application. The first overload sets the last synchronised date/time where the sync ID is not known, and returns the sync ID that was created (a sync ID identifies a machine with which the database has been synchronised). The second overload is for a particular sync ID and updates the database's last synchronised date/time for that ID. It leaves with KErrNotFound if the specified sync ID is not found.

Parameters

TContactSyncId aSyncId

An existing sync ID.

const TTime& aSyncDate

The database's new last synchronised date/time.

Return value

TContactSyncId

The sync ID created by the function.


GetLastSyncDateL()

void GetLastSyncDateL(TContactSyncId aSyncId, TTime& aSyncDate);

Support

Supported from 6.0

Description

Returns the date/time the database was last synchronised with a particular sync ID, as set by SetLastSyncDateL().

Parameters

TContactSyncId aSyncId

An existing sync ID.

TTime& aSyncDate

On return contains the date/time the database was last synchronised with the sync ID specified.

Leave codes

KErrNotFound

The ID aSyncId cannot be found in the database.


ContactsChangedSinceL()

CContactIdArray* ContactsChangedSinceL(const TTime& aTime);

Description

Gets an array of contacts modified since the specified date/time. The caller takes ownership of the returned object.

Parameters

const TTime& aTime

The date/time of interest.

Return value

CContactIdArray*

Pointer to the array of contacts modified since the specified time.


DeletedContactsLC()

CContactIdArray* DeletedContactsLC();

Description

Gets an array of IDs for contact items that still exist in the database, but are marked as deleted. These are contact items which have been deleted, but which have a non-zero access count. The caller takes ownership of the returned object.

Return value

CContactIdArray*

Pointer to the array of contacts marked as deleted.

[Top]


Database ID


MachineId()

TInt64 MachineId() const;

Support

Supported from 5.1

Description

Returns a number unique to the contacts database. This value may be passed to CContactItem::UidStringL().

Return value

TInt64

The database's unique ID.

[Top]


Compression


CompressRequired()

TBool CompressRequired();

Description

Tests whether a compress is recommended. This function provides an easy way of testing whether the database is being used efficiently.

ETrue is returned if:

Return value

TBool

ETrue if a compress is recommended, EFalse if not or if an error occurred.


CompactL()

void CompactL();

Description

Compacts the database to its minimum size synchronously.


CompressL()

void CompressL();

Description

Compacts the database using an active compressor. This function is identical to CompactL(), except that it is asynchronous.


CreateCompressorLC()

CContactActiveCompress* CreateCompressorLC();

Description

Creates an active compressor to compress the database with an active object.

An observer set up on the active compressor can be used to provide a progress dialog. The caller takes ownership of the returned object.

Return value

CContactActiveCompress*

Pointer to an active compressor.

[Top]


Recovery


IsDamaged()

TBool IsDamaged() const;

Description

Tests whether the database is damaged and needs to be recovered.

Return value

TBool

ETrue if the database is damaged and needs recovery, EFalse otherwise.


RecoverL()

void RecoverL();

Description

Recovers the database from a rollback. First closes all tables and then reopens them after the recover.


CreateRecoverLC()

CContactActiveRecover* CreateRecoverLC();

Description

Creates an active recoverer object to recover the database using an active object. The caller takes ownership of the returned object.

Return value

CContactActiveRecover*

Pointer to an active recoverer.


CloseTables()

void CloseTables();

Description

Closes all database tables. After a rollback and recover all tables need to be closed and re-opened before the database can be accessed again.


OpenTablesL()

void OpenTablesL();

Description

Opens all database tables. After a rollback and recover all tables need to be closed and re-opened before the database can be accessed again. This function calls CloseTables() first to ensure that all tables are closed before opening them.

[Top]


Phone number matching


InitLoadPhoneMatchesL()

TInt InitLoadPhoneMatchesL();

Description

Initialises the phone number matching process. Returns the total number of contacts to be indexed.

Return value

TInt

The total number of contacts to be indexed.


LoadPhoneMatchesL()

TInt LoadPhoneMatchesL();

Description

Indexes the next set of contact items for phone number matching.

Indexing involves reading a batch of contact items. For all items which contain a telephone number field, the number is extracted and is added to a list of telephone numbers stored internally by the contacts model.

Note:

This function handles any changes which occur during the indexing to the number of contact items. The function returns zero on completion or remains fixed at one until all the contacts are indexed.

Return value

TInt

The number of contact items whch have not yet been indexed. Zero when all contacts have been indexed.


PhoneMatchListL()

CContactIdArray *PhoneMatchListL(const TDesC& aNumber) const;

Description

Gets an array of contact item IDs that might match the specified phone number. The algorithm doesn’t check for an exact match (only the last eight digits of aNumber are compared) but provides a fast way of finding contacts that probably match the number.

All fields in the contact items returned by this function should be checked for a match. The caller takes ownership of the returned object.

Note:

These three functions could be used as follows: —

In the following code, phoneNumber is a descriptor containing a phone number to match as text.

TInt todo=database->InitLoadPhoneMatchesL();
while(todo>0)
    todo=database->LoadPhoneMatchesL();
CContactIdArray *matchArray=database->PhoneMatchListL(phoneNumber);

Parameters

const TDesC& aNumber

Descriptor specifying the number to find.

Return value

CContactIdArray

Array of contact IDs which identify contact items containing phone numbers matching aNumber.


TextToPhoneMatchNumber()

static TInt TextToPhoneMatchNumber(const TDesC &aText, TInt &aNumDigits, TInt aPhoneMatchLength=8);

Description

Converts a telephone number stored in a text string into numeric format. The number of digits (counting from the end of the string) to convert can be specified. By default it is the last eight digits. The return value from this function can be passed to MatchPhoneNumberL(). The method only looks at digits in the text string provided, all other characters are ignored. If the string contains no digits, the function returns zero.

Parameters

const TDesC &aText

Telephone number stored as text.

TInt &aNumDigits

On return, contains the number of digits in the returned telephone number.

TInt aPhoneMatchLength=8

The number of digits (counting from the end of the string) to convert. Must be greater than zero, or the function raises a panic.

Return value

TInt

The telephone number. Zero if the string contains no digits.


MatchPhoneNumberL()

CContactIdArray* MatchPhoneNumberL(TInt aPhoneNumber);

Support

Supported from 6.0

Description

Returns an array of contact item IDs for all the contact items which contain the specified telephone number in any of their fields.

Notes:

Parameters

TInt aPhoneNumber

The telephone number.

Return value

CContactIdArray*

Array of contact item IDs for all contact items which contain the specified telephone number in any of their fields.

Leave codes

KErrNotFound

The telephone number cannot be found.

[Top]


Speed dialling


SetFieldAsSpeedDialL()

void SetFieldAsSpeedDialL(CContactItem& aItem, TInt aFieldId, TInt aSpeedDialPosition);

Support

Supported from 6.0

Description

Sets a field containing a telephone number as a speed dial field. The field is identified by aFieldId within the contact item aItem. It is assigned a speed dial position between 1 and 9 inclusive.

The field's speed dial and user added attributes are set and the appropriate UID (KUidSpeedDialXxx) is added to the field's content type. The changes are committed to the database.

Notes:

If an item's telephone number field has already been assigned to position aSpeedDialPosition, that item is updated so that the speed dial attribute is removed from its field and the speed dial field type UID is removed from the field's content type, before the new speed dial field is set.

The speed dial attribute can be tested for using the CContactItemField::IsSpeedDial() function.

The contact item passed to this function (aItem) must have been obtained using one of the variants of CContactDatabase::OpenContactL(). This is because it is modified and committed to the database by this function — no further commits are necessary.

Parameters

CContactItem& aItem

The contact item containing the field to set as a speed dial field.

TInt aFieldId

Identifies a field in aItem's field set to set as a speed dial field.

TInt aSpeedDialPosition

The speed dial position. This is an integer in the range 1 to 9 inclusive. If outside this range, the function leaves with KErrArgument.


GetSpeedDialFieldL()

TContactItemId GetSpeedDialFieldL(TInt aSpeedDialPosition, TDes& aPhoneNumber);

Support

Supported from 6.0

Description

Returns the ID of the contact item whose telephone number field is mapped to the speed dial position specified. This function is provided so that information may be displayed about a contact item whose telephone number is being dialled using speed dialling.

The function also retrieves the telephone number stored in the field.

Parameters

TInt aSpeedDialPosition

The speed dial position. This is an integer in the range 1 to 9 inclusive. If outside this range, the function leaves with KErrArgument.

TDes& aPhoneNumber

On return, contains the telephone number which is mapped to the speed dial position specified. Returns KNullDesC if the speed dial position requested has not been set.

Return value

TContactItemId

The ID of the contact item for which the speed dial has been set.


RemoveSpeedDialFieldL()

void RemoveSpeedDialFieldL(TContactItemId aContactId, TInt aSpeedDialPosition);

Support

Supported from 6.0

Description

Removes the mapping between a contact item field and a speed dial position.

Removes the KUidSpeedDialXxx UID from the field's content type, removes the field's speed dial attribute and commits the changes to the contact item.

Parameters

TContactItemId aContactId

The ID of the contact item containing the speed dial field.

TInt aSpeedDialPosition

The speed dial position. This is an integer in the range 1 to 9 inclusive. If outside this range, the function leaves with KErrArgument.

[Top]


Templates


TemplateId()

TContactItemId TemplateId() const;

Description

Gets the ID of the system template. This can then be read, opened and committed like any other contact item.

Return value

TContactItemId

ID of the system template.


TemplateContentType()

const CContentType& TemplateContentType(const CContactItemField& aField) const;

Description

Gets the content type of the template field which a specified field maps onto. If the field does not map onto a field in a template, then its own content type is returned.

Parameters

const CContactItemField& aField

The field of interest.

Return value

CContentType

The content type of the field.


CreateContactCardTemplateL()

CContactItem* CreateContactCardTemplateL(const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);
CContactItem* CreateContactCardTemplateL(const CContactItem* aTemplate,const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);

Support

Supported from 6.0

Description

Creates a contact card template and adds it to the database — overloaded function.

The caller can optionally specify a contact item on which the new template's field set is based. This could be a contact card, an own card, another template or even a group. If this is not specified, then the new template's field set is based on the system template. Note that no field data is copied into the new template. All of the new template's fields are marked as template fields.

A template label must be specifed. This can be changed later using CContactCardTemplate::SetTemplateLabelL().

The caller takes ownership of the returned object.

Parameters

const CContactItem* aTemplate

Pointer to an instance of a CContactItem-derived class. This is used to initialise the new template's field set.

const TDesC& aTemplateLabel

The string to set as the template label.

TBool aInTransaction=EFalse

This argument should be ignored by developers.

Return value

CContactItem*

Pointer to the contact card template.


CreateContactCardTemplateLC()

CContactItem* CreateContactCardTemplateLC(const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);
CContactItem* CreateContactCardTemplateLC(const CContactItem* aTemplate,const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);

Support

Supported from 6.0

Description

Creates a contact card template and adds it to the database — overloaded function.

The caller can optionally specify a contact item on which the new template's field set is based. This could be a contact card, an own card, another template or even a group. If this is not specified, then the new template's field set is based on the system template. Note that no field data is copied into the new template. All of the new template's fields are marked as template fields.

A template label must be specifed. This can later be changed using CContactCardTemplate::SetTemplateLabelL().

The pointer to the template is left on the cleanup stack. The caller takes ownership of the returned object.

Parameters

const CContactItem* aTemplate

Pointer to an instance of a CContactItem-derived class. This is used to initialise the new template's field set.

const TDesC& aTemplateLabel

The string to set as the template label.

TBool aInTransaction=EFalse

This argument should be ignored by developers.

Return value

CContactItem*

Pointer to the contact card template.


GetCardTemplateIdListL()

CContactIdArray* GetCardTemplateIdListL() const;

Support

Supported from 6.0

Description

Returns a copy of the database's template ID list. This is a list of the IDs of all contact card templates which have been added to the database. The caller takes ownership of the returned object.

Return value

CContactIdArray*

Pointer to a copy of the database's template ID list — this does not include the system template. NULL if there are no templates in the database.


TemplateCount()

TInt TemplateCount() const;

Support

Supported from 6.0

Description

Returns the number of contact card templates that currently exist in the database. This does not include the system template.

Return value

TInt

The number of contact card templates that currently exist in the database.


PrefTemplateId()

TContactItemId PrefTemplateId() const;

Support

Supported from 6.0

Description

Returns the ID of the database's preferred template, as set by SetPrefTemplateL(). KNullContactId if not set. The preferred template is for clients who may have multiple templates but want to identify one as preferred.

Return value

TContactItemId

The ID of the database's current preferred template.


SetPrefTemplateL()

void SetPrefTemplateL(const CContactItem& aContact);

Support

Supported from 6.0

Description

Sets the database's preferred template.

The preferred template's ID persists when the database is opened and closed. If the preferred template is subsequently deleted, the preferred template ID is set to KNullContactId.

Parameters

const CContactItem& aContact

The contact card template to set as the database's preferred template. This must be a contact card template (of type KUidContactCardTemplate), or the function leaves with KErrNotSupported.

[Top]


Database enquiry


CountL()

TInt CountL();

Description

Gets the number of CContactItems in the database. The count includes non-system template items. It does not include items marked as deleted.

Return value

TInt

The number of contact items in the database.


FileUid()

TPtrC FileUid();

Description

Gets the database's UID. This value is used to identify a particular contact database. The database UID is generated when the database is first created.

Return value

TPtrC

Descriptor containing the database UID.


NullUidValue()

static TInt NullUidValue();

Support

Supported from 6.0

Description

Returns the NULL contact ID value.

Return value

TInt

KNullContactId.


FileSize()

TInt FileSize() const;

Description

Gets the size of the contact database file in bytes.

Return value

TInt

The size of the contacts file.


ConnectionId()

TUint ConnectionId() const;

Description

Gets the ID of the connection to the lock server.

This can be compared with the connection IDs of incoming messages to identify which connection generated the message.

Return value

TUint

The ID of the connection to the lock server.


Version()

TVersion Version() const;

Description

Gets the contact model's version number.

Return value

TVersion

The version number of the contacts model.

[Top]


Enumerations


Enum TOptions

TOptions

Description

Import and export contact format option flags. Contacts can be imported into or exported from the contact database. Imported or exported contacts must be in the vCard format.

The following options are available during import and export.

EIncludeX

Handle Symbian’s extended vCard format options.

ETTFormat

Support non-standard extensions requried by Symbian PC connectivity software and Microsoft amongst others.

EExcludeUid

Don't export the contact ID (for exporting only).

EDecreaseAccessCount

Decrease the contact's access count when importing and exporting.

EIncreaseAccessCount

Increase the contact's access count when importing and exporting.

EImportSingleContact

Only import the first contact in the read stream (for importing only).


Enum TThreadAccess

TThreadAccess

Support

Supported from 6.0

Description

Specifies whether the database can be accessed from single or multiple threads.

ESingleThread

Allows access to the contacts database from a single thread only.

EMultiThread

Allows for a multi-threaded program to access the contact database from multiple threads but note that the contacts model provides no synchronisation support for such use.

[Top]


Classes


Class TSortPref

TSortPref

Description

Specifies the field type and order preferences used for sorting items in the contacts database — see CContactDatabase::SortL() and CContactDatabase::SortArrayL(). The contents of the first field in a contact item matching the field type is used as the data to sort on. The order can either be ascending or descending.

The TSortPref class is nested within the CContactDatabase class.

Defined in CContactDatabase::TSortPref:
EAsc, EDesc, TOrder, TSortPref(), iFieldType, iOrder

Construction

TSortPref()


TSortPref();

Description

Constructs a TSortPref object. The order is initialised to EAsc and the field type to KNullUid.

TSortPref()


TSortPref(TFieldType aFieldType,TOrder aOrder=EAsc);

Description

Constructs the TSortPref object with a field type and an order.

Parameters

TFieldType aFieldType

Specifies the field type to sort on.

TOrder aOrder=EAsc

Specifies the sort order.

Enumerations

Enum TOrder


TOrder

Description

The sort order.

EAsc

Ascending sort order.

EDesc

Descending sort order.

Data members

iOrder


TOrder iOrder

Description

Specifies whether the sort should be ascending or descending.

iFieldType


TFieldType iFieldType

Description

The first field matching this field type is used for the text to sort on.