|
||
This section contains code fragments that show some simple uses of the SIP Codec API.
The following is an example of how an application using the SIP stack decodes a Contact header:
RPointerArray<CSIPContactHeader> 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->ExpiresParameter();//return zero
iSIPContactHeader->QParameter();//return 1.0
delete iSIPContactHeader; iSIPContactHeader = 0;
The following is an example of how an application using the SIP stack decodes several Contact headers:
RPointerArray<CSIPContactHeader> headers;
_LIT8 (KHeaders1, "<sip:u1@host>, u2 <sip:u2@host> , sip:host ");
headers = CSIPContactHeader::DecodeL(KHeaders1);
headers.Count();//return 3
headers.ResetAndDestroy();
The following is an example of how an application using the SIP stack
creates CSIPContactHeader
:
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
Note: The string pool must be opened before using it. All the predefined SIP constants are in the string table, which can be accessed by the string pool. At the end of handling, the SIP Codec string pool must be closed.
#include "sipstrings.h"
….
SIPStrings::OpenL();
RStringPool pool = SIPStrings::Pool();