Symbian3/PDK/Source/GUID-1B3D9B3D-D507-5D78-9E90-060C26D3F971.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Tue, 30 Mar 2010 11:56:28 +0100
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 14 578be2adaf3e
permissions -rw-r--r--
Week 12 contribution of PDK documentation_content. See release notes for details. Fixes Bug 2054, Bug 1583, Bug 381, Bug 390, Bug 463, Bug 1897, Bug 344, Bug 1319, Bug 394, Bug 1520, Bug 1522, Bug 1892"

<?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-1B3D9B3D-D507-5D78-9E90-060C26D3F971"><title>Examples Showing the use of the SIP Codec API</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The following sections describe the use of the SIP Codec API. </p> <ul><li id="GUID-57701C66-D973-5F0B-96A0-1E99C347B7EA"><p> <xref href="GUID-1B3D9B3D-D507-5D78-9E90-060C26D3F971.dita#GUID-1B3D9B3D-D507-5D78-9E90-060C26D3F971/GUID-F124CB52-955C-53B5-9A43-E0D9B04F539C">Decoding a Contact Header using the SIP stack</xref>  </p> </li> <li id="GUID-4E087736-B5E4-594E-9877-7F4CB6C7F292"><p> <xref href="GUID-1B3D9B3D-D507-5D78-9E90-060C26D3F971.dita#GUID-1B3D9B3D-D507-5D78-9E90-060C26D3F971/GUID-96C179ED-FAFF-58CE-8BBF-58A5BE82FA2F">Decoding several Contact Headers using the SIP stack </xref>  </p> </li> <li id="GUID-C3B0A1C3-9224-5E48-9112-5DB58941E99D"><p> <xref href="GUID-1B3D9B3D-D507-5D78-9E90-060C26D3F971.dita#GUID-1B3D9B3D-D507-5D78-9E90-060C26D3F971/GUID-3A587908-769D-569E-9A6A-C23CFF38DCD6">Creating a CSIPContactHeader using the SIP stack</xref>  </p> </li> </ul> <section id="GUID-F124CB52-955C-53B5-9A43-E0D9B04F539C"><title> Decoding a Contact Header using the SIP stack</title> <p>The following code snippet shows how an application decodes a Contact header that uses the SIP stack: </p> <codeblock id="GUID-4E53526F-764D-500B-B7BC-F530CDF8C1B8" xml:space="preserve">RPointerArray&lt;CSIPContactHeader&gt; headers;
_LIT8 (KThreeParams, "sip:user@localhost;expires=0;q=1.0;p=value");
headers = CSIPContactHeader::DecodeL(KThreeParams);
TInt count = headers.Count(); //count == 1
iSIPContactHeader = headers[0];
headers.Reset();
iSIPContactHeader-&gt;ExpiresParameter();//return zero
iSIPContactHeader-&gt;QParameter();//return 1.0
delete iSIPContactHeader; iSIPContactHeader = 0;
</codeblock> </section> <section id="GUID-96C179ED-FAFF-58CE-8BBF-58A5BE82FA2F"><title> Decoding several Contact Headers using the SIP stack </title> <p>The following code snippet shows how an application decodes the Contact headers that use the SIP stack: </p> <codeblock id="GUID-EBA24C46-ED9F-5105-B3FD-45E85AAE6930" xml:space="preserve">RPointerArray&lt;CSIPContactHeader&gt; headers;
_LIT8 (KHeaders1, "&lt;sip:u1@host&gt;, u2 &lt;sip:u2@host&gt; , sip:host  ");
headers = CSIPContactHeader::DecodeL(KHeaders1);
headers.Count();//return 3
headers.ResetAndDestroy();
</codeblock> </section> <section id="GUID-3A587908-769D-569E-9A6A-C23CFF38DCD6"><title>Creating a CSIPContactHeader using the SIP stack </title> <p>The following code snippet shows how an application creates <codeph>CSIPContactHeader</codeph> that uses the SIP stack : </p> <codeblock id="GUID-A467810F-B774-511F-8679-5125D3073E87" xml:space="preserve">TUriParser8 parser;
_LIT8 (KValue, "sip:user@host1");
User::LeaveIfError(parser.Parse(KValue));
CUri8* uri8 = CUri8::NewLC(parser);
CSIPAddress* sipAddress = CSIPAddress::NewL(uri8);
CleanupStack::Pop(); // uri8, ownership given to sipAddress
CleanupStack::PushL(sipAddress);
CSIPContactHeader* contactHeader = CSIPContactHeader::NewL(sipAddress);
CleanupStack::Pop(); // sipAddress, ownership given to contactHeader
</codeblock> <p> <b> Note:</b> Open the string pool before you use it. All the predefined SIP constants are in the string table, which are accessed by the string pool. At the end of handling, the SIP Codec string pool must be closed. </p> <codeblock id="GUID-2C9C0A6B-9FA6-5CE0-AF92-40C5F99D51EF" xml:space="preserve">#include "sipstrings.h"
SIPStrings::OpenL();
RStringPool pool = SIPStrings::Pool();</codeblock> </section> </conbody></concept>