|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file WSPEncoder.h |
|
18 @publishedAll |
|
19 @deprecated |
|
20 */ |
|
21 |
|
22 #ifndef __WSPENCODER_H__ |
|
23 #define __WSPENCODER_H__ |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <f32file.h> // RFs |
|
27 #include <badesca.h> // arrays etc. |
|
28 #include <stringpool.h> |
|
29 |
|
30 /** |
|
31 enum CodecPanic |
|
32 @publishedAll |
|
33 @deprecated |
|
34 */ |
|
35 enum TWspCodecPanic |
|
36 { |
|
37 /** Due to failure to call StartValueLength function */ |
|
38 EWspCodecPanicStartValueLengthNotCalled=0, |
|
39 /** Due to failure to call EndValueLength matching a call to StartValueLength */ |
|
40 EWspCodecPanicEndValueLengthNotCalled, |
|
41 /** Due to failure to call StartHeaderL function */ |
|
42 EWspCodecPanicStartHeaderLNotCalled, |
|
43 /** Due to StartHeaderL function being called twice without EndHeaderL */ |
|
44 EWspCodecPanicStartHeaderCalledTwice, |
|
45 /** Due to parameter Token not having the top bit set */ |
|
46 EWspCodecPanicInvalidToken |
|
47 }; |
|
48 |
|
49 /** |
|
50 This class can be used to encode one header field at a time, |
|
51 with all its values and parameters. |
|
52 |
|
53 It has no knowledge of encoding the BNF of a particular header field, but |
|
54 the functions provided can be used in combination, producing an 8-bit buffer |
|
55 containing the encoded header. |
|
56 |
|
57 Intended usage would be to call a series of functions. The first one being StartHeader, |
|
58 The final one being EndHeader, which would return a buffer containing |
|
59 the complete encoded header field. |
|
60 eg: |
|
61 encoder->StartHeaderL(); |
|
62 encoder->AddLongIntL(); |
|
63 encoder->AddTextStringL(); |
|
64 HBufC8* output = encoder->EndHeaderL(); |
|
65 @publishedAll |
|
66 @deprecated |
|
67 */ |
|
68 class CWspHeaderEncoder : public CBase |
|
69 { |
|
70 public: |
|
71 IMPORT_C static CWspHeaderEncoder* NewL(); |
|
72 |
|
73 IMPORT_C static CWspHeaderEncoder* NewLC(); |
|
74 |
|
75 |
|
76 IMPORT_C virtual ~CWspHeaderEncoder(); |
|
77 |
|
78 IMPORT_C void StartHeaderL(TUint8 aToken); |
|
79 |
|
80 |
|
81 IMPORT_C void StartHeaderL(const TDesC8& aString); |
|
82 |
|
83 IMPORT_C void StartHeaderL(const RStringF aString); |
|
84 |
|
85 |
|
86 IMPORT_C HBufC8* EndHeaderL(); |
|
87 |
|
88 |
|
89 |
|
90 IMPORT_C void AddIntegerL(const TUint aInt); |
|
91 |
|
92 |
|
93 IMPORT_C void AddShortIntL(const TUint8 aValue); |
|
94 |
|
95 IMPORT_C void AddShortLengthL(const TUint8 aValue); |
|
96 |
|
97 |
|
98 IMPORT_C void AddLongIntL(const TUint32 aValue); |
|
99 |
|
100 |
|
101 IMPORT_C void AddUintVarL(const TUint aInt); |
|
102 |
|
103 |
|
104 IMPORT_C void AddTextStringL(const RString& aText); |
|
105 |
|
106 IMPORT_C void AddTextStringL(const TDesC8& aText); |
|
107 |
|
108 IMPORT_C void AddDateL(const TDateTime aDate); |
|
109 |
|
110 IMPORT_C void AddTokenL(const TUint8 aToken); |
|
111 |
|
112 IMPORT_C void AddTokenTextL(const TDesC8& aTokenText); |
|
113 |
|
114 IMPORT_C void AddDataL(const TDesC8& aData); |
|
115 |
|
116 |
|
117 |
|
118 IMPORT_C void StartValueLengthL(); |
|
119 |
|
120 IMPORT_C void EndValueLengthL(); |
|
121 |
|
122 private: |
|
123 |
|
124 CWspHeaderEncoder(); |
|
125 |
|
126 void Init(); |
|
127 |
|
128 |
|
129 void ConstructL(); |
|
130 |
|
131 private: |
|
132 /** |
|
133 Array for storing the partial encoded header. |
|
134 Each time StartValueLength is called a new array |
|
135 element is used. When EndValueLength is called, |
|
136 the array is decremented, data from the last |
|
137 element being added to the one before. |
|
138 */ |
|
139 RPointerArray<CDesC8Array> iArray; |
|
140 |
|
141 /** |
|
142 Value incremented as the encoded header increases in size. |
|
143 Used to allocate the buffer for storing the final |
|
144 encoded header, output when EndHeader is called. |
|
145 */ |
|
146 TInt iTotalLength; |
|
147 }; |
|
148 |
|
149 /** |
|
150 Class encapsulating primitive encoding methods which are defined in the WSP standard. |
|
151 Input will be encoded and returned in an 8 bit buffer. |
|
152 @publishedAll |
|
153 @deprecated |
|
154 */ |
|
155 class TWspPrimitiveEncoder |
|
156 { |
|
157 public: |
|
158 IMPORT_C static TUint8 ShortInt(const TUint8 aValue); |
|
159 |
|
160 IMPORT_C static HBufC8* LongIntL(const TUint32 aValue); |
|
161 |
|
162 IMPORT_C static HBufC8* UintVarL(const TUint32 aInt); |
|
163 |
|
164 IMPORT_C static HBufC8* TextStringL(const RString aText); |
|
165 |
|
166 IMPORT_C static HBufC8* TextStringL(const TDesC8& aText); |
|
167 |
|
168 IMPORT_C static HBufC8* DateL(const TDateTime aDate); |
|
169 }; |
|
170 |
|
171 #endif // __WSPENCODER_H__ |