Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: commdb.h
Link against: commdb.lib

Class CCommsDatabase

CCommsDatabase

Support

Supported from 5.0

Description

Accesses the communications database through the DBMS.

An object of this type must be constructed and opened by a client before any of the tables in the database can be accessed.

Derivation

CBaseBase class for all classes to be instantiated on the heap
CCommsDatabaseAccesses the communications database through the DBMS
CCommsDatabaseBaseBase class for CCommsDatabase

Defined in CCommsDatabase:
BeginTransaction(), CancelRequestNotification(), ClearGlobalSettingL(), Close(), CloseDatabase(), CommitTransaction(), GetClientTimeoutL(), GetCurrentDialOutSettingL(), GetDefaultRecordL(), GetGlobalSettingL(), GetRouteTimeoutL(), InTransaction(), NewL(), Open(), OpenConnectionPrefTableInRankOrderLC(), OpenConnectionPrefTableLC(), OpenConnectionPrefTableViewOnRankLC(), OpenIAPTableViewMatchingBearerSetLC(), OpenTableLC(), OpenViewLC(), OpenViewMatchingBoolLC(), OpenViewMatchingTextLC(), OpenViewMatchingUintLC(), OpenViewOnProxyRecordLC(), RequestNotification(), ResolvePhoneNumberFromDatabaseL(), ResolvePhoneNumberL(), RollbackTransaction(), SetClientTimeoutL(), SetDefaultRecordL(), SetGlobalSettingL(), SetRouteTimeoutL(), ShowHiddenRecords(), Type(), ~CCommsDatabase()

Inherited from CBase:
operator new()

Inherited from CCommsDatabaseBase:
IsDatabaseWriteLockedL(), Version()


Allocation and construction


NewL()

static CCommsDatabase* NewL(TCommDbDatabaseType aType);

Support

Supported from 6.0

Description

Allocates and constructs a new communications database object on the heap.

The function creates the directory for the database file and creates a database with empty tables if there is no existing database. It also connects the DBMS server and opens the database for shared access. It leaves with an error if the database and server are not opened successfully. The error can be any error returned by calls to the file server or the DBMS server.

The database and the connection to the server are closed on deletion of all instantiations of CCommsDatabase.

The aType parameter indicates the type of database the client is expecting to open. The two types are:

These two types cannot co-exist: any particular database is of one type or the other. If the client knows which type of database it wants to open, then it should use the appropriate parameter. If on the other hand it does not mind which type the database is, it can specify the type as unknown. Note, however, that if the type is unknown, a database must already exist. If not, the type must be specified.

Parameters

TCommDbDatabaseType aType

Type of database

Return value

CCommsDatabase*

A pointer to a communications database object


NewL()

static CCommsDatabase* NewL();

Support

Withdrawn in 6.0

Description

Allocates and constructs a new communications database object on the heap.

If there is insufficient memory available to create the object, the function leaves. If allocation is successful, it returns a pointer to the new object.

Return value

CCommsDatabase*

A pointer to a communications database object

[Top]


Destruction


~CCommsDatabase()

~CCommsDatabase();

Support

Supported from 6.0

Description

Frees all resources owned by this object, prior to its destruction.

In particular, the destructor closes the communications database and disconnects from the DBMS.

[Top]


Database type


Type()

TCommDbDatabaseType Type() const;

Support

Supported from 6.0

Description

Gets the database type.

Return value

TCommDbDatabaseType

[Top]


Global settings


GetGlobalSettingL()

void GetGlobalSettingL(const TDesC& aSetting, TUint32& aVal);

Support

Supported from 6.0

Description

Gets a global settings table integer field.

Note that:

Parameters

const TDesC& aSetting

Setting to get

TUint32& aVal

On return, setting value

Leave codes

KErrNotSupported

aSetting is invalid

KErrNotFound

The global setting has not been set


GetGlobalSettingL()

void GetGlobalSettingL(const TDesC& aSetting, TDes& aVal);

Support

Supported from 6.0

Description

Gets a global settings table string field.

Parameters

const TDesC& aSetting

Setting to get

TDes& aVal

On return, setting value

Leave codes

KErrNotSupported

aSetting is invalid

KErrNotFound

The global setting has not been set


SetGlobalSettingL()

void SetGlobalSettingL(const TDesC& aSetting, TUint32 aVal);

Support

Supported from 6.0

Description

Sets a global settings table integer field.

Parameters

const TDesC& aSetting

Setting to get

TUint32 aVal

Setting value

Leave codes

KErrNotSupported

aSetting is invalid


SetGlobalSettingL()

void SetGlobalSettingL(const TDesC& aSetting, const TDesC& aVal);

Support

Supported from 6.0

Description

Sets a global settings table string field.

Parameters

const TDesC& aSetting

Setting to get

const TDesC& aVal

Setting value

Leave codes

KErrNotSupported

aSetting is invalid


ClearGlobalSettingL()

void ClearGlobalSettingL(const TDesC& aSetting);

Support

Supported from 6.0

Description

Clears a global settings table field.

Parameters

const TDesC& aSetting

Setting to clear

Leave codes

KErrNotSupported

aSetting is invalid

[Top]


Simple access to dial-out settings


GetCurrentDialOutSettingL()

void GetCurrentDialOutSettingL(const TDesC& aSetting, TUint32& aValue);

Support

Supported from 6.0

Description

Gets the default ISP, location or modem for dial-out.

This function is not used with IAP databases.

The function is provided for simplicity, as its use is not dependent on a database type.

Parameters

const TDesC& aSetting

Setting to get

TUint32& aValue

On return, setting value

[Top]


Open the database


Open()

TInt Open();

Support

Withdrawn in 6.0

Description

Connects to the DBMS.

If the communications database does not exist, it is created with an empty set of tables before the connection to the server takes place.

The database is opened for shared access.

This function can be called any number of times on thisCCommsDatabase object; however, creation of the communications database and connection to the DBMS server only occur on the first call toOpen().

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


Close()

void Close();

Support

Withdrawn in 6.0

Description

Compacts, closes, and disconnects from, the communications database.

If there has been more than one earlier call to Open() on this CCommsDatabase object and this call is not the last call toClose(), then the database remains open, it is not compacted and the connection to the DBMS remains active.

If this is the last call to Close() on thisCCommsDatabase object, then any outstanding notification request is cancelled.

Close() can be safely called, if the database has already been closed and the connection to the DBMS removed.


CloseDatabase()

void CloseDatabase();

Support

Withdrawn in 6.0

Description

Compacts and closes the communications database.

If there has been more than one earlier call to Open() on this CCommsDatabase object and this call is not the last call toCloseDatabase(), then the database remains open and is not compacted.

CloseDatabase() can be safely called, if the database has already been closed.

Notes:

This function does not disconnect the client from the DBMS. The connection can be severed later by calling Close().

If there is an outstanding request for notification of changes to the database, then this request remains outstanding while the connection to the DBMS remains.

[Top]


Notification service


RequestNotification()

TInt RequestNotification(TRequestStatus& aStatus);

Support

Withdrawn in 6.0

Description

Requests notification when any change is made to the database, whether by this client or any other.

The request is an asynchronous request.

When any change is made to the database, the outstanding notification request completes and TRequestStatus contains a value indicating what type of change has occurred. The value is one of the enumerators of theRDbNotifier::TEvent enumeration defined in d32dbms.h.

Alternatively, if an outstanding notification request is cancelled by a call to thisCCommsDatabase'sCancelRequestNotification()member function, then the request completes with aKErrCancel.

An outstanding notification request is also cancelled if the connection to the DBMS is severed through a call to Close().

Parameters

TRequestStatus& aStatus

A reference to the request status object. If the request is cancelled, this is set to KErrCancel. If the request completes normally, this is set to one of the enumerators of theRDbNotifier::TEventenumeration.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


CancelRequestNotification()

void CancelRequestNotification();

Support

Withdrawn in 6.0

Description

Cancels an outstanding request for notification of changes to the communications database.

An outstanding request completes with KErrCancel.

[Top]


Open views onto a table in the communications database


OpenTableLC()

CCommsDbTableView* OpenTableLC(const TDesC& aTableName);

Support

Withdrawn in 6.0

Description

Opens a view onto a whole table and returns a pointer to that view.

The view excludes hidden records, unless access to them has previously been explicitly requested by calling the ShowHiddenRecords()member function of this object.

If the open process is succesful, the function constructs and returns a pointer to a CCommsDbTableView object which encapsulates the information on that view. The pointer is also put onto the cleanup stack.

Note:

Parameters

const TDesC& aTableName

A reference to a descriptor containing the name of a table in the communications database.

Return value

CCommsDbTableView*

A pointer to the view object.

Leave codes

 

The function may leave for a number of reasons, for example, if the table named in aTablename does not exist.


OpenViewMatchingUintLC()

CCommsDbTableView* OpenViewMatchingUintLC(const TDesC& aTableName, const TDesC& aColumnToMatch, TUint32 aValueToMatch);

Support

Withdrawn in 6.0

Description

Opens a view onto a specified table based on a matching unsigned integer value, and returns a pointer to that view.

The view includes all those records where the column, identified byaColumnToMatch, matches the unsigned integer valueaValueToMatch.

The view excludes hidden records, unless access to them has previously been explicitly requested by calling the ShowHiddenRecords()member function of this object.

If the open process is succesful, the function constructs and returns a pointer to a CCommsDbTableView object which encapsulates the information on that view. The pointer is also put onto the cleanup stack.

Note:

Parameters

const TDesC& aTableName

A reference to a descriptor containing the name of a table in the communications database.

const TDesC& aColumnToMatch

A reference to a descriptor containing the name of the column to be used in the selection process.

TUint32 aValueToMatch

The value to be matched with the content of columnaColumnToMatch.

Return value

CCommsDbTableView*

A pointer to the view object.

Leave codes

 

The function may leave for a number of reasons, for example, if the table does not exist or the named column cannot be found.


OpenViewMatchingBoolLC()

CCommsDbTableView* OpenViewMatchingBoolLC(const TDesC& aTableName, const TDesC& aColumnToMatch, TBool aValueToMatch);

Support

Withdrawn in 6.0

Description

Opens a view onto a specified table based on a matching boolean value, and returns a pointer to that view.

The view includes all those records where the column, identified byaColumnToMatch, matches the boolean valueaValueToMatch.

The view excludes hidden records, unless access to them has previously been explicitly requested by calling the ShowHiddenRecords()member function.

If the open process is succesful, the function constructs and returns a pointer to a CCommsDbTableView object which encapsulates the information on that view. The pointer is also put onto the cleanup stack.

Note:

Parameters

const TDesC& aTableName

A reference to a descriptor containing the name of a table in the communications database.

const TDesC& aColumnToMatch

A reference to a descriptor containing the name of the column to be used in the selection process.

TBool aValueToMatch

The value to be matched with the content of columnaColumnToMatch.

Return value

CCommsDbTableView*

A pointer to the view object.

Leave codes

 

The function may leave for a number of reasons, for example, if the table does not exist or the named column cannot be found.


OpenViewMatchingTextLC()

CCommsDbTableView* OpenViewMatchingTextLC(const TDesC& aTableName, const TDesC& aColumnToMatch, const TDesC8& aValueToMatch);

Support

Withdrawn in 6.0

Description

Opens a view onto a specified table based on a matching 8 bit text type, and returns a pointer to that view.

The view includes all those records where the column, identified byaColumnToMatch, matches the narrow text supplied in the descriptoraValueToMatch.

The view excludes hidden records, unless access to them has previously been explicitly requested by calling the ShowHiddenRecords()member function of this object.

If the open process is succesful, the function constructs and returns a pointer to a CCommsDbTableView object which encapsulates the information on that view. The pointer is also put onto the cleanup stack.

Note:

The function generates an SQL query to create the view.

Parameters

const TDesC& aTableName

A reference to a descriptor containing the name of a table in the communications database.

const TDesC& aColumnToMatch

A reference to a descriptor containing the name of the column to be used in the selection process.

const TDesC8& aValueToMatch

The narrow (ASCII) text to be matched with the content of columnaColumnToMatch.

Return value

CCommsDbTableView*

A pointer to the view object.

Leave codes

 

The function may leave for a number of reasons, for example, if the table does not exist or the named column cannot be found.


OpenViewMatchingTextLC()

CCommsDbTableView* OpenViewMatchingTextLC(const TDesC& aTableName, const TDesC& aColumnToMatch, const TDesC16& aValueToMatch);

Support

Withdrawn in 6.0

Description

Opens a view onto a specified table based on a matching 16 bit text type, and returns a pointer to that view.

The view includes all those records where the column, identified byaColumnToMatch, matches the wide text supplied in the descriptoraValueToMatch.

The view excludes hidden records, unless access to them has previously been explicitly requested by calling the ShowHiddenRecords()member function of this object.

If the open process is succesful, the function constructs and returns a pointer to a CCommsDbTableView object which encapsulates the information on that view. The pointer is also put onto the cleanup stack.

Note:

Parameters

const TDesC& aTableName

A reference to a descriptor containing the name of a table in the communications database.

const TDesC& aColumnToMatch

A reference to a descriptor containing the name of the column to be used in the selection process.

const TDesC16& aValueToMatch

The wide (Unicode) text to be matched with the content of columnaColumnToMatch.

Return value

CCommsDbTableView*

A pointer to the view object.

Leave codes

 

The function may leave for a number of reasons, for example, if the table does not exist or the named column cannot be found.


OpenViewLC()

CCommsDbTableView* OpenViewLC(const TDesC& aTableName, const TDesC& aSqlQuery);

Support

Withdrawn in 6.0

Description

Opens a view onto a specified table based on an explicitly coded SQL query, and returns a pointer to that view.

The view includes all those records which match the SQL query supplied in the descriptor aSqlQuery. It is the caller's responsibility to code this query correctly.

As the SQL query is defined by the caller, the resulting view does not exclude hidden records unless explicitly stated in the query itself. To exclude hidden records, insert Hidden=0 as a search condition into the SQL query text.

If the open process is succesful, the function constructs and returns a pointer to a CCommsDbTableView object which encapsulates the information on that view. The pointer is also put onto the cleanup stack.

Parameters

const TDesC& aTableName

A reference to a descriptor containing the name of a table in the communications database.

const TDesC& aSqlQuery

A reference to a descriptor containing the SQL query text

Return value

CCommsDbTableView*

A pointer to the view object.

Leave codes

 

The function may leave for a number of reasons, for example, if the table does not exist or the named column cannot be found.

[Top]


Opening a view on the Connection Preferences table

Description

Views on the Connection Preferences table cannot be opened with the generic functions such as CCommsDatabaseBase::OpenViewLC(). Instead, one of the following must be used.

See also:


OpenConnectionPrefTableLC()

CCommsDbConnectionPrefTableView* OpenConnectionPrefTableLC();

Support

Supported from 6.1

Description

Opens a view on the Connection Preferences table.

When the use of the view object is complete, it should be popped from the cleanup stack, and deleted.

Return value

CCommsDbConnectionPrefTableView*

The opened view

Leave codes

 

KErrNoMemory, or DBMS-related errors


OpenConnectionPrefTableLC()

CCommsDbConnectionPrefTableView* OpenConnectionPrefTableLC(TCommDbConnectionDirection aDirection);

Support

Supported from 6.1

Description

Opens a view on the records in the Connection Preferences table with a specified direction.

When the use of the view object is complete, it should be popped from the cleanup stack, and deleted.

Parameters

TCommDbConnectionDirection aDirection

Direction of the records to include in the view

Return value

CCommsDbConnectionPrefTableView*

The opened view

Leave codes

 

KErrNoMemory, or DBMS-related errors


OpenConnectionPrefTableInRankOrderLC()

CCommsDbConnectionPrefTableView* OpenConnectionPrefTableInRankOrderLC(TCommDbConnectionDirection aDirection);

Support

Supported from 6.1

Description

Opens a view on the records in the Connection Preferences table with a specified direction, and with records sorted into ranking order.

Records are sorted in rank order from ranking 1 first. Records with rank 0 are not included.

When the use of the view object is complete, it should be popped from the cleanup stack, and deleted.

Parameters

TCommDbConnectionDirection aDirection

Direction of the records to include in the view

Return value

CCommsDbConnectionPrefTableView*

The opened view

Leave codes

 

KErrNoMemory, or DBMS-related errors


OpenConnectionPrefTableViewOnRankLC()

CCommsDbConnectionPrefTableView* OpenConnectionPrefTableViewOnRankLC(TCommDbConnectionDirection aDirection, TUint32 aRank);

Support

Supported from 6.1

Description

Opens a view on the records in the Connection Preferences table with a specified direction and ranking.

When the use of the view object is complete, it should be popped from the cleanup stack, and deleted.

Parameters

TCommDbConnectionDirection aDirection

Direction of the records to include in the view

TUint32 aRank

Ranking of the records to include in the view

Return value

CCommsDbConnectionPrefTableView*

The opened view

Leave codes

 

KErrNoMemory, or DBMS-related errors; KErrOverflow if the value of aRank exceeds the maximum allowed.

[Top]


Opening views by matching service type


OpenIAPTableViewMatchingBearerSetLC()

CCommsDbTableView* OpenIAPTableViewMatchingBearerSetLC(TUint32 aBearerSet, TCommDbConnectionDirection aDirection);

Support

Supported from 6.1

Description

Opens a view on records in the IAP table with a specified range of service types.

IAP records are included that have matching bearers and direction, as read from the Connection preference table, to those specified.

When the use of the view object is complete, it should be popped from the cleanup stack, and deleted.

Parameters

TUint32 aBearerSet

Bearers to match. For suitable values, see CONNECT_PREF_BEARER_SET in the Connection preferences table.

TCommDbConnectionDirection aDirection

Direction to match

Return value

CCommsDbTableView*

The opened view

Leave codes

KErrArgument

Either aBearerSet or aDirection is invalid.

Other

DBMS-related error codes

See also:


OpenViewOnProxyRecordLC()

CCommsDbTableView* OpenViewOnProxyRecordLC(TUint32 aServiceId, const TDesC& aServiceType);

Support

Supported from 6.1

Description

Opens a view on records in the Proxies table with a specified range of service types and service IDs.

Proxies records are included that have matching service types and IDs. When the use of the view object is complete, it should be popped from the cleanup stack, and deleted.

Parameters

TUint32 aServiceId

ID of the service to match

const TDesC& aServiceType

Service type to match

Return value

CCommsDbTableView*

The opened view

Leave codes

KErrArgument

Either aServiceId or aServiceType is invalid.

Other

DBMS-related error codes

See also:

[Top]


Transaction support


BeginTransaction()

TInt BeginTransaction();

Support

Withdrawn in 6.0

Description

Marks the start of a transaction and gets a shared read-lock on the database. Other clients of the database can concurrently acquire a shared read-lock but no client can gain an exclusive write-lock until this transaction (and any transaction started by other clients) completes as a result of a call to either CommitTransaction()orRollbackTransaction().

Note:

Return value

TInt

KErrNone if the database has been successfully locked; the transaction can start. KErrLocked if another client already has an exclusive write-lock on the database.


CommitTransaction()

TInt CommitTransaction();

Support

Withdrawn in 6.0

Description

Marks the end of a transaction and commits any changes made since the start of the transaction. The client's shared read-lock is removed if no write operations were performed, or the exclusive write-lock is removed if write operations were performed.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


RollbackTransaction()

void RollbackTransaction();

Support

Withdrawn in 6.0

Description

Marks the end of a transaction and abandons any changes made since the start of the transaction. The database is, in effect, rolled back to the state it was in at the beginning of the transaction. The client's shared read-lock is removed if no write operations were performed, or the exclusive write-lock is removed if write operations were performed.


InTransaction()

TBool InTransaction();

Support

Withdrawn in 6.0

Description

Tests whether a transaction is in progress, i.e. whether a call toBeginTransaction() has been called.

Return value

TBool

true, if a transaction is in progress; false, otherwise.

[Top]


Default record handling


GetDefaultRecordL()

void GetDefaultRecordL(const TDesC& aTableName, TUint32& aId);

Support

Withdrawn in 6.0

Description

Gets the Id of the default record belonging to a specified table. The Id is copied into aId.

The only tables which can have a default record are:

Note:

Parameters

const TDesC& aTableName

A reference to a descriptor containing the name of a table in the communications database.

TUint32& aId

A reference to an unsigned integer passed by the caller. On successful return from this function, contains the Id of the default record.

Leave codes

 

The function leaves with KErrNotSupported if it is called for any other table than those specified above.


SetDefaultRecordL()

void SetDefaultRecordL(const TDesC& aTableName, TUint32 aId);

Support

Withdrawn in 6.0

Description

Identifies, to CommDb, the Id of the default record belonging to a specified table.

Note:

Parameters

const TDesC& aTableName

A reference to a descriptor containing the name of a table in the communications database.

TUint32 aId

The Id of the record in table aTableName which is to be the default record of this table.

Leave codes

 

The function leaves with KErrNotSupported if the table name passed in does not have a default record. E.g. Not all tables can have a default record; if the table name passed in aTableName is not one of: DIAL_OUT_SERVICE (the dial-out service table), CONNECTED_MODEM (the connected modem table), MODEM_PREFS (the modem preferences table), LOCATION, (the location table) then this function leaves withKErrNotSupported .

[Top]


Hidden records


ShowHiddenRecords()

TInt ShowHiddenRecords();

Support

Withdrawn in 6.0

Description

Ensures that hidden records are included in the search criteria when creating views using the member functions:

Return value

TInt

KErrNone always.

[Top]


Accessing timeouts


GetClientTimeoutL()

void GetClientTimeoutL(TUint32& aTimeout);

Support

Withdrawn in 6.0

Description

Gets the client timeout value from the communications database.

The function puts the value into aTimeout.

Parameters

TUint32& aTimeout

A reference to an unsigned integer passed by the caller. On successful return from this function, contains a copy of the client timeout value.


SetClientTimeoutL()

void SetClientTimeoutL(const TUint32 aTimeout);

Support

Withdrawn in 6.0

Description

Sets the value of the client timeout in the communications database.

Parameters

TUint32 aTimeout

The client timeout value to be set.


GetRouteTimeoutL()

void GetRouteTimeoutL(TUint32& aTimeout);

Support

Withdrawn in 6.0

Description

Gets the route timeout value from the communications database.

The function puts the value into aTimeout.

Parameters

TUint32& aTimeout

A reference to an unsigned integer passed by the caller. On successful return from this function, contains a copy of the route timeout value.


SetRouteTimeoutL()

void SetRouteTimeoutL(const TUint32 aTimeout);

Support

Withdrawn in 6.0

Description

Sets the value of the route timeout value in the communications database.

Parameters

TUint32 aTimeout

The route timeout value to be set.

[Top]


Resolve phone number


ResolvePhoneNumberL()

static void ResolvePhoneNumberL(TDesC& aNumber, TDes8& aDialString, TParseMode aDialParseMode);

Support

Withdrawn in 6.0

Description

Resolves a telephone number and places it into a reference containing the parsed number. The resolution of the number uses the default location table record to determine dialling codes and formats.

All read operations to tables within the database are wrapped within a transaction.

The function does not resolve for mobile phones; aNumber is just copied to aDialString.

Note:

Parameters

TDesC& aNumber

A reference to the descriptor containing the number to be parsed.

TDes& aDialString

A reference to a descriptor; on return from the function, contains the parsed number.

TParseMode aDialParseMode

The parse mode: indicates whether the parsed string is intended for dialling or for display. This enumerator is defined in dial.h

Leave codes

 

The function leaves if there is no default record in the location table.


ResolvePhoneNumberFromDatabaseL()

void ResolvePhoneNumberFromDatabaseL(TDesC& aNumber, TDes8& aDialString, TParseMode aDialParseMode);

Support

Withdrawn in 6.0

Description

Resolves the telephone number supplied in the descriptor and places it into a reference containing the parsed number.

The resolution of the number uses the default record to determine dialling codes and formats.

The function does not resolve for mobile phones; aNumber is just copied to aDialString.

Note:

Parameters

TDesC& aNumber

A reference to the descriptor containing the number to be parsed.

TDes& aDialString

A reference to a descriptor; on return from the function, contains the parsed number.

TParseMode aDialParseMode

The parse mode: indicates whether the parsed string is intended for dialling or for display. This enumerator is defined in dial.h

Leave codes

 

The function leaves if there is no default record in the location table.