Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



How to register a service in the database

After the database has been opened, a service record can be created. You do this by supplying the UUID for the service class of the record. As the service class may be a single UUID or a list of UUIDs in the form of a DES, there are two overloaded functions.

The steps to register a service are as follows:

  1. Create a blank service record object, TSdpServRecordHandle.

  2. If the service class attribute should be a single UUID, create and set a TUUID object. If the attribute should be a list of UUIDs, create a attribute list object, CSdpAttrValueDES or CSdpAttrValueDEA, and call MSdpElementBuilder::BuildUUIDL() repeatedly to add UUIDs to the list.

  3. Call RSdpDatabase::CreateServiceRecordL() on an open subsession. On return, the record handle object holds a handle to the service record.

Example: single service class

The following example creates a service record with a single service class.

// Assumes sdpSession is an open session to the database
// 1. Create blank record handle
TSdpServRecordHandle recordHandle = 0;

// 2. Create the service class UUIDs
TUUID uuid(0x20000);

// 3. Enter record into the database
sdpSubSession.CreateServiceRecordL(uuid, recordHandle);

Example: service class list

The following example creates a service record with a list of service classes.

// 1. Create a blank record handle
TSdpServRecordHandle recordHandle = 0;

// 2. Create a list of service class UUIDs
CSdpAttrValueDES* UUIDlist = CSdpAttrValueDES::NewDESL(NULL);
CleanupStack::PushL(UUIDlist);
UUIDlist
    ->StartListL()
        ->BuildUUIDL(TUUID(TUint32(0x20002000)))
        ->BuildUUIDL(TUUID(TUint32(0x11112222), TUint32(0x33334444),
                              TUint32(0x55556666), TUint32(0x77778888)))
        ->BuildUUIDL(TUUID(TUint32(0x40000)))
    ->EndListL();

// 3. Enter record into the database
sdpSubSession.CreateServiceRecordL(*UUIDlist, recordHandle);
CleanupStack::PopL(); // UUIDlist

Note

The examples shows UUIDs of varying length. Both 16- and 32-bit integers may be used, which are assumed to be offsets from the Bluetooth base UUID.