Symbian3/SDK/Source/GUID-E2A2FA2A-5D9A-56FE-B7E5-69CCBC656BB9.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-E2A2FA2A-5D9A-56FE-B7E5-69CCBC656BB9"><title>Handling SDP Attributes</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>SDP Database service records are made up of a number of attributes. The attributes identify information about the service such as the class of service, that is the general category to which the service belongs, the date on which the service record was first created, the service's UUID and more. See the SDP specification, link provided elsewhere, for more information. The only required attribute is the UUID for the service. </p> <section><title>How to create and manipulate attributes</title> <p>Symbian have identified a special pattern for creating and manipulating SDP attributes. </p> <p><b>Attribute types</b> </p> <p>Attributes in service records can be one of fixed number of types. The API encapsulates each attribute type in a class, each of which is derived from <xref href="GUID-5528763A-0A50-3029-BEAB-CEC3BA08ABF1.dita"><apiname>CSdpAttrValue</apiname></xref>. The type is easily deducible from the name: e.g. <codeph>CSdpAttrValueUint</codeph> encapsulates an unsigned integer type attribute. </p> <ul><li id="GUID-E92A60EB-5028-5CDC-83FB-20C626CECB82"><p> <xref href="GUID-B1D56FE2-29E4-3EB3-B638-04336A84F80B.dita"><apiname>CSdpAttrValueBoolean</apiname></xref>  </p> </li> <li id="GUID-991D696E-BA93-5D17-B0F0-529ABDB21B9A"><p> <xref href="GUID-74C4154F-9C20-3C23-86EB-D4B602E79DC1.dita"><apiname>CSdpAttrValueDEA</apiname></xref>  </p> </li> <li id="GUID-57357160-CD33-54A9-8019-2E33ABCAB25A"><p> <xref href="GUID-7AF08589-F6E5-36A1-AD2C-84D3CB877451.dita"><apiname>CSdpAttrValueDES</apiname></xref>  </p> </li> <li id="GUID-144544D2-3C0B-54BD-90E4-5C89FB97E3E1"><p> <xref href="GUID-31EE0888-4D8D-3668-8658-62A1ACFA9E4C.dita"><apiname>CSdpAttrValueInt</apiname></xref>  </p> </li> <li id="GUID-78B376DB-7BEF-501F-8E9D-FB2EF279732A"><p> <xref href="GUID-63EDF468-719A-3EDF-A7F3-53F837AC762B.dita"><apiname>CSdpAttrValueNil</apiname></xref>  </p> </li> <li id="GUID-7F074756-D3B1-5E95-BB5A-7038145F0687"><p> <xref href="GUID-3E049232-901E-3C1A-BA7B-8D1F8B90B85C.dita"><apiname>CSdpAttrValueString</apiname></xref>  </p> </li> <li id="GUID-D0121510-803F-5CEC-ACBB-EB4CFF8165C9"><p> <xref href="GUID-127DA8BE-A9F2-3536-97EA-A4BCCD51A0E3.dita"><apiname>CSdpAttrValueUint</apiname></xref>  </p> </li> <li id="GUID-704CA520-1BDC-556F-AB9F-9C12DC036233"><p> <xref href="GUID-B55A8C55-D7DB-3A96-935A-D09161DE848E.dita"><apiname>CSdpAttrValueURL</apiname></xref>  </p> </li> <li id="GUID-88B13916-67BC-57AE-BF75-12A294CEC6B3"><p> <xref href="GUID-CE08D370-E599-37F4-B0CC-D889C1E04B30.dita"><apiname>CSdpAttrValueUUID</apiname></xref>  </p> </li> </ul> <p><b>Complex Attributes</b> </p> <p>Complex attribute values are stored as lists of other elements; nested lists are allowed. </p> <p>The list classes are: </p> <ul><li id="GUID-A0900A5B-3B74-581E-9E01-494F622B2F59"><p> <codeph>CSdpAttrValueDEA</codeph>: a Data element alternative, a data element whose data field is a sequence of data elements from which one data element is to be selected. </p> </li> <li id="GUID-24633CF0-8C72-5107-A8E5-02D830F08706"><p> <codeph>CSdpAttrValueDES</codeph>: a Data element sequence, a data element whose data field is a sequence of data elements. </p> </li> </ul> <p>Both of these implement the <xref href="GUID-3DC9CB25-E55D-38E6-8940-B3320EF7E9DD.dita"><apiname>MSdpElementBuilder</apiname></xref> interface, which supplies functions of the form <codeph>Build</codeph> <varname>type</varname> <codeph>L()</codeph> to add elements of the specified <varname>type</varname> to the list. </p> <p><b> Creating a Protocol List Attribute</b> </p> <p>The following example builds a ProtocolDescriptorList attribute (attribute ID 0x0004), which is a list containing two nested lists. </p> <ol id="GUID-8AA434EC-40A2-549A-BD8F-3E343C51225E"><li id="GUID-936D92B9-B8E8-58BD-AB3C-A698253EC71C"><p>Create the list. (NULL indicates that the list is not itself in another list) </p> <codeblock id="GUID-057DB9B7-CB3E-5381-9EB7-BDC2B73085F9" xml:space="preserve">CSdpAttrValueDES* attrValProt = CSdpAttrValueDES::NewDESL(NULL);
CleanupStack::PushL(attrValProt);</codeblock> </li> <li id="GUID-7B850D69-6F08-59A3-9220-09D4E48242A6"><p>Build the first nested list. Notice the pattern used to push the new attribute value onto the service record. </p> <codeblock id="GUID-EC6E75C7-39AD-5D30-AD3F-B5BEF8161571" xml:space="preserve">attrValProt
    -&gt;StartListL()
        -&gt;BuildDESL()
        -&gt;StartListL()
            -&gt;BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
        -&gt;EndListL()</codeblock> </li> <li id="GUID-F3A52C4E-F82A-5EC4-B004-8F23515E23B1"><p>Build the second nested list. </p> <codeblock id="GUID-55F49BC1-7082-576C-B0BB-1B8CB5A02B63" xml:space="preserve">  -&gt;BuildDESL()
        -&gt;StartListL()
            -&gt;BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
            -&gt;BuildUintL(TServAttrInt&lt;TUint8&gt;&gt;(1)) // DLCI = 1
        -&gt;EndListL()
    -&gt;EndListL();</codeblock> <p>Notice that all the code from the start of 2 above to the end of 3 is essentially a single long line of code. This is an example of the SDP pattern discussed earlier. </p> </li> </ol> <p> <b> Note: </b>  </p> <ul><li id="GUID-3EA609A2-BB81-52F1-936B-B4A0FC74C6F7"><p> <codeph>MSdpElementBuilder</codeph> functions are called cumulatively as part of a single statement. </p> </li> <li id="GUID-87B95637-9AFA-52E6-9AC3-34F7D6EBC5F8"><p>The start of a list is indicated by a call to <xref href="GUID-3DC9CB25-E55D-38E6-8940-B3320EF7E9DD.dita#GUID-3DC9CB25-E55D-38E6-8940-B3320EF7E9DD/GUID-08A8B787-304E-34BC-9110-FAE4B2873FB8"><apiname>MSdpElementBuilder::StartListL()</apiname></xref> and ended by <xref href="GUID-3DC9CB25-E55D-38E6-8940-B3320EF7E9DD.dita#GUID-3DC9CB25-E55D-38E6-8940-B3320EF7E9DD/GUID-F00D7635-1B0D-3A13-8574-D6DE91870C11"><apiname>MSdpElementBuilder::EndListL()</apiname></xref>. </p> </li> </ul> </section> <section><title>Where next?</title> <p>The complete set of Service Discovery Database tutorials are shown below: </p> <ol id="GUID-360A4ECF-05FD-50D5-89CE-3C0A9216B9C5"><li id="GUID-BBC0B062-F5D3-5595-9675-20E4A27DD121"><p> <xref href="GUID-B75BD3DE-9C2E-5429-B55B-891462B92795.dita">Connecting to the service discovery database</xref>  </p> </li> <li id="GUID-A4CE3FF9-053C-58CF-8863-67DB7664E405"><p> <b>Handling SDP attributes</b> - This document </p> </li> <li id="GUID-2802DB1F-5983-5C75-A942-2E5E794ACC70"><p> <xref href="GUID-2373A158-C18A-51B5-BE9A-6B8F7FC63A35.dita">Registering Services</xref>  </p> </li> <li id="GUID-D11ADFBE-6FF1-5FED-846D-7B9D4F33652B"><p> <xref href="GUID-33210C48-3198-51BC-9970-8B29F711A8E2.dita">Setting service record attributes</xref>  </p> </li> <li id="GUID-30808463-3A6F-5D6A-969A-CAE442AD744B"><p> <xref href="GUID-ED342E6B-A4A3-576B-8934-7E7C049837F0.dita">SDP Service records and attributes</xref>  </p> </li> </ol> <p>Also refer to the <xref href="GUID-E5893C4A-024A-53A7-805F-68989382DC3F.dita">Bluetooth Service Discovery Database overview</xref> and the <xref href="GUID-8451102A-8E68-5C86-9E40-D53183E32261.dita">Bluetooth SDP Overview</xref> for additional background information. </p> </section> </conbody></concept>