|
1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CHEADERFIELD_H |
|
21 #define CHEADERFIELD_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <HttpDownloadMgrCommon.h> |
|
26 #include <http.h> |
|
27 |
|
28 // CONSTANTS |
|
29 const TInt KResponseHeaderConvTable[][2] = { |
|
30 {EDlAttrResponseCharSet, HTTP::ECharset}, |
|
31 {EDlAttrResponseAge, HTTP::EAge}, |
|
32 {EDlAttrResponseETag, HTTP::EETag}, |
|
33 {EDlAttrResponseLocation, HTTP::ELocation}, |
|
34 {EDlAttrResponseRetryAfter, HTTP::ERetryAfter}, |
|
35 {EDlAttrResponseServer, HTTP::EServer}, |
|
36 {EDlAttrResponseVary, HTTP::EVary }, |
|
37 {0,0}, |
|
38 }; |
|
39 |
|
40 const TInt KRequestHeaderConvTable[][2] = { |
|
41 {EDlAttrRequestAccept, HTTP::EAccept }, |
|
42 {EDlAttrRequestAcceptCharSet, HTTP::EAcceptCharset }, |
|
43 {EDlAttrRequestAcceptLanguage, HTTP::EAcceptLanguage }, |
|
44 {EDlAttrRequestExpect, HTTP::EExpect}, |
|
45 {EDlAttrRequestFrom, HTTP::EFrom }, |
|
46 {EDlAttrRequestHost, HTTP::EHost }, |
|
47 {EDlAttrRequestMaxForwards, HTTP::EMaxForwards }, |
|
48 {EDlAttrRequestPragma, HTTP::EPragma }, |
|
49 {EDlAttrRequestReferer, HTTP::EReferer }, |
|
50 {EDlAttrRequestUserAgent, HTTP::EUserAgent }, |
|
51 {EDlAttrRequestVary, HTTP::EVary }, |
|
52 {0,0}, |
|
53 }; |
|
54 |
|
55 const TInt KEntityHeaderConvTable[][2] = { |
|
56 {EDlAttrEntityAllow, HTTP::EAllow }, |
|
57 {EDlAttrEntityContentEncoding, HTTP::EContentEncoding }, |
|
58 {EDlAttrEntityContentLanguage, HTTP::EContentLanguage }, |
|
59 {EDlAttrEntityContentLocation, HTTP::EContentLocation }, |
|
60 {EDlAttrEntityExpires, HTTP::EExpires }, |
|
61 {EDlAttrEntityLastModified, HTTP::ELastModified }, |
|
62 {0,0}, |
|
63 }; |
|
64 |
|
65 const TInt KGeneralHeaderConvTable[][2] = { |
|
66 {EDlAttrGeneralCacheControl, HTTP::ECacheControl }, |
|
67 {EDlAttrGeneralDate, HTTP::EDate }, |
|
68 {EDlAttrGeneralPragma, HTTP::EPragma }, |
|
69 {EDlAttrGeneralVia, HTTP::EVia }, |
|
70 {EDlAttrGeneralWarning, HTTP::EWarning }, |
|
71 {0,0}, |
|
72 }; |
|
73 |
|
74 // MACROS |
|
75 //#define ?macro ?macro_def |
|
76 |
|
77 // DATA TYPES |
|
78 //enum ?declaration |
|
79 //typedef ?declaration |
|
80 //extern ?data_type; |
|
81 |
|
82 // FUNCTION PROTOTYPES |
|
83 void Trim( TPtrC8& aTrim ); |
|
84 |
|
85 // FORWARD DECLARATIONS |
|
86 class RFile; |
|
87 |
|
88 // CLASS DECLARATION |
|
89 |
|
90 /** |
|
91 * ?one_line_short_description. |
|
92 * ?other_description_lines |
|
93 * |
|
94 * @lib ?library |
|
95 * @since Series 60 v2.8 |
|
96 */ |
|
97 NONSHARABLE_CLASS( CHeaderField ) : public CBase |
|
98 { |
|
99 public: // Constructors and destructor |
|
100 |
|
101 /** |
|
102 * Two-phased constructor. |
|
103 */ |
|
104 static CHeaderField* NewL( const TDesC8* aFieldName = NULL, |
|
105 const TDesC8* aFieldRawData = NULL, |
|
106 TInt aFieldIndex = KErrNotFound ); |
|
107 |
|
108 /** |
|
109 * Destructor. |
|
110 */ |
|
111 virtual ~CHeaderField(); |
|
112 |
|
113 // static TDesC8 FieldNameByAttr( TInt aFieldAttr ); |
|
114 // static THttpDownloadMgrAttrib FieldAttrByName( RStringPool& aStrPool, TDesC8& aFieldName ); |
|
115 |
|
116 public: // New functions |
|
117 |
|
118 /** |
|
119 * Returns pointer to field name. |
|
120 * @since Series 60 v2.8 |
|
121 * @return pointer to field name. |
|
122 */ |
|
123 inline HBufC8* FieldName() const; |
|
124 |
|
125 /** |
|
126 * Returns pointer to raw data of the field |
|
127 * @since Series 60 v2.8 |
|
128 * @return pointer to raw data of the field |
|
129 */ |
|
130 inline HBufC8* FieldRawData() const; |
|
131 |
|
132 /** |
|
133 * Returns the |
|
134 */ |
|
135 inline TInt FieldIndex() const; |
|
136 |
|
137 /** |
|
138 * Returns the header value converted to TInt |
|
139 * @return raw header value converted to TInt |
|
140 */ |
|
141 TInt Int() const; |
|
142 |
|
143 /** |
|
144 * Loads header field from file. |
|
145 * @since Series 60 v2.8 |
|
146 * @param aInFile file to read header field from |
|
147 * @return none. Leaves on error. |
|
148 */ |
|
149 void LoadHeaderInfoL( RFile& aInFile ); |
|
150 |
|
151 public: // Functions from base classes |
|
152 |
|
153 protected: // New functions |
|
154 |
|
155 protected: // Functions from base classes |
|
156 |
|
157 private: |
|
158 |
|
159 /** |
|
160 * C++ default constructor. |
|
161 */ |
|
162 CHeaderField( TInt aFieldIndex ); |
|
163 |
|
164 /** |
|
165 * By default Symbian 2nd phase constructor is private. |
|
166 */ |
|
167 void ConstructL( const TDesC8* aFieldname, |
|
168 const TDesC8* aFieldRawData ); |
|
169 |
|
170 // Prohibit copy constructor if not deriving from CBase. |
|
171 // CHeaderField( const CHeaderField& ); |
|
172 // Prohibit assigment operator if not deriving from CBase. |
|
173 // CHeaderField& operator=( const CHeaderField& ); |
|
174 |
|
175 public: // Data |
|
176 // ?one_line_short_description_of_data |
|
177 //?data_declaration; |
|
178 |
|
179 protected: // Data |
|
180 // ?one_line_short_description_of_data |
|
181 TInt iFieldIndex; // Index value of the given field in the |
|
182 // related header id array. (e.g. KResponseHeaderConvTable ) |
|
183 HBufC8* iFieldName; |
|
184 HBufC8* iFieldRawData; |
|
185 |
|
186 private: // Data |
|
187 // ?one_line_short_description_of_data |
|
188 //?data_declaration; |
|
189 |
|
190 // Reserved pointer for future extension |
|
191 //TAny* iReserved; |
|
192 |
|
193 public: // Friend classes |
|
194 //?friend_class_declaration; |
|
195 protected: // Friend classes |
|
196 //?friend_class_declaration; |
|
197 private: // Friend classes |
|
198 //?friend_class_declaration; |
|
199 |
|
200 }; |
|
201 |
|
202 #endif // CHEADERFIELD_H |
|
203 |
|
204 inline TInt CHeaderField::FieldIndex() const |
|
205 { |
|
206 return iFieldIndex; |
|
207 } |
|
208 |
|
209 inline HBufC8* CHeaderField::FieldName() const |
|
210 { |
|
211 return iFieldName; |
|
212 } |
|
213 |
|
214 inline HBufC8* CHeaderField::FieldRawData() const |
|
215 { |
|
216 return iFieldRawData; |
|
217 } |
|
218 |
|
219 // End of File |