|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE task |
|
11 PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> |
|
12 <task id="GUID-4FE5CA06-8C3A-4AC1-80CE-4418AC55937A" xml:lang="en"><title>Reading |
|
13 headers in a WSP buffer</title><shortdesc><codeph>TWspField</codeph> object holds the name and value pair |
|
14 of the WSP header field. <codeph>TWspHeaderSegmenter</codeph> pulls the header |
|
15 / value pair out of the WSP buffer (into <codeph>TWspField</codeph>). Call <codeph>TWspHeaderSegmenter::NextL()</codeph> to |
|
16 iterate through the WSP buffer. It calls <codeph>TWspPrimitiveDecoder</codeph>.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
17 <prereq id="GUID-333175CE-6D40-4F5C-9AD8-122A383CA3EF"> <p><xref href="GUID-8E0D4BBE-BD06-396F-9517-45F9BFCDEF37.dita"><apiname>CWspHeaderEncoder</apiname></xref> allows you to encode |
|
18 the values and parameters of the header field. It creates one header at a |
|
19 time from the name / value pairs.</p> </prereq> |
|
20 <context id="GUID-CAFFF446-43D5-440C-9B32-C3B9A518D2D3"> <p>The following are the steps to encode the WSP header:</p> |
|
21 </context> |
|
22 <steps id="GUID-4DD07DEC-6017-4237-BE46-1D69E5FBD744-GENID-1-8-1-11-1-1-6-1-5-1-5-1-9-1-3-1-3-3"> |
|
23 <step id="GUID-9A69E5AD-E938-4092-A8C2-CB65C37C8962-GENID-1-8-1-11-1-1-6-1-5-1-5-1-9-1-3-1-3-3-1"><cmd/> |
|
24 <info>Create a header encoder object.</info> |
|
25 <stepxmp><codeblock xml:space="preserve">//creates a pointer to CWspHeaderEncoder object |
|
26 CWspHeaderEncoder* primEncoder = CWspHeaderEncoder::NewLC();</codeblock></stepxmp> |
|
27 </step> |
|
28 <step id="GUID-C40D9259-C67F-4DA8-B524-A29E3BE2D0E0"><cmd/> |
|
29 <info>Start a new encoded header to encode the parameter value. </info> |
|
30 <stepxmp><codeblock xml:space="preserve">// start a new encoded header |
|
31 primEncoder->StartHeaderL(0x27);</codeblock></stepxmp> |
|
32 </step> |
|
33 <step id="GUID-69650498-F216-4D21-B799-983B89022FA3"><cmd/> |
|
34 <info>Call <xref href="GUID-8E0D4BBE-BD06-396F-9517-45F9BFCDEF37.dita#GUID-8E0D4BBE-BD06-396F-9517-45F9BFCDEF37/GUID-D35C01C4-10A9-3BED-88F8-695DAC6411B7"><apiname>CWspHeaderEncoder::StartValueLengthL()</apiname></xref> to calculate |
|
35 the length of encodings that are added subsequently. The value calculated, |
|
36 is stored as part of the encoded string, as specified in the WSP standard. </info> |
|
37 <stepxmp><codeblock xml:space="preserve">primEncoder->StartValueLengthL();</codeblock></stepxmp> |
|
38 </step> |
|
39 <step id="GUID-4958F0F4-1A49-4E3E-81F5-196DF68F253E"><cmd/> |
|
40 <info>Encode the header field and add it to the encoded field. </info> |
|
41 <info> <b>Note</b>: The appropriate WSP method is used for encoding the header |
|
42 field of a data type such as integer, date, text string and so on. </info> |
|
43 <stepxmp><codeblock xml:space="preserve">primEncoder->AddIntegerL(0x7F); |
|
44 primEncoder->AddUintVarL(0xff); |
|
45 primEncoder->AddLongIntL(999999); |
|
46 _LIT8(KString, "WSP Encode: String"); |
|
47 primEncoder->AddTextStringL(KString); |
|
48 TDateTime time(2006,EMarch,20,06,36,30,000000); //create a date time object |
|
49 primEncoder->AddDateL(time); // add |
|
50 TUInt intVal=489; |
|
51 primEncoder->AddLTokenL(intVal); |
|
52 _LIT8(KTokenText, "WSP Encode: Token Text"); |
|
53 primEncoder->AddLTokenTextL(KTokenText);</codeblock></stepxmp> |
|
54 </step> |
|
55 <step id="GUID-E99EF950-7080-4718-98FD-69DA9E8074DD"><cmd/> |
|
56 <info>Call <xref href="GUID-8E0D4BBE-BD06-396F-9517-45F9BFCDEF37.dita#GUID-8E0D4BBE-BD06-396F-9517-45F9BFCDEF37/GUID-80F4AA16-53D6-3836-A048-DADCDFEF4652"><apiname>CWspHeaderEncoder::EndValuesLengthL()</apiname></xref> at the |
|
57 time of header construction when ValueLength can be calculated.</info> |
|
58 </step> |
|
59 <step id="GUID-3A70308A-ACCA-4059-9D26-D82A70B610BD"><cmd/> |
|
60 <info>Assuming that the length of the header encodings has been calculated |
|
61 and added to the encoder field, call <xref href="GUID-8E0D4BBE-BD06-396F-9517-45F9BFCDEF37.dita#GUID-8E0D4BBE-BD06-396F-9517-45F9BFCDEF37/GUID-80F4AA16-53D6-3836-A048-DADCDFEF4652"><apiname>CWspHeaderEncoder::EndValuesLengthL()</apiname></xref>.</info> |
|
62 <stepxmp><codeblock xml:space="preserve">primEncoder->EndValueLengthL();</codeblock></stepxmp> |
|
63 </step> |
|
64 <step id="GUID-9DEE2868-591D-488B-AAC9-D12EF2936CC2"><cmd/> |
|
65 <info>Call <xref href="GUID-8E0D4BBE-BD06-396F-9517-45F9BFCDEF37.dita#GUID-8E0D4BBE-BD06-396F-9517-45F9BFCDEF37/GUID-68A186E8-030B-3A0E-BFF0-ACCAD81C7F3D"><apiname>CWspHeaderEncoder::EndHeaderL()</apiname></xref>, to complete |
|
66 the header encoding. This completes and returns the encoded header field's |
|
67 8 bit buffer. <codeph>EndHeaderL()</codeph> panics if <codeph>EndValueLengthL()</codeph> is |
|
68 not called after <xref href="GUID-8E0D4BBE-BD06-396F-9517-45F9BFCDEF37.dita#GUID-8E0D4BBE-BD06-396F-9517-45F9BFCDEF37/GUID-D35C01C4-10A9-3BED-88F8-695DAC6411B7"><apiname>CWspHeaderEncoder::StartValueLengthL()</apiname></xref>. </info> |
|
69 <stepxmp><codeblock xml:space="preserve">HBufC8* buf = primEncoder->EndHeaderL();</codeblock></stepxmp> |
|
70 <stepresult><p>This returns a pointer to the buffer containing the encoded |
|
71 field. </p></stepresult> |
|
72 </step> |
|
73 </steps> |
|
74 </taskbody></task> |