epoc32/include/mw/http/framework/cheadercodec.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
equal deleted inserted replaced
2:2fe1408b6811 3:e1b950c65cb4
       
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file CHeaderCodec.h
       
    20  @warning : This file contains Rose Model ID comments - please do not delete
       
    21 */
       
    22 
       
    23 #ifndef __CHEADERCODEC_H__
       
    24 #define __CHEADERCODEC_H__
       
    25 
       
    26 // System includes
       
    27 #include <e32base.h>
       
    28 #include <http/framework/rheaderfield.h>
       
    29 
       
    30 // Forward declarations
       
    31 class CHeaderWriter;
       
    32 class CHeaderReader;
       
    33 
       
    34 
       
    35 //##ModelId=3C4C18850126
       
    36 class CHeaderCodec : public CBase
       
    37 /**
       
    38 An abstract HTTP header codec.  
       
    39 
       
    40 Each instance of a concrete subclass of CHeaderCodec is associated with, and owned
       
    41 by, a specific	CProtocolHandler.  It provides on-demand encoding/decoding of
       
    42 HTTP header data, between the generic format used by clients/filters to formulate
       
    43 requests and interpret responses, and the raw format used by
       
    44 the transport handlers (and origin servers/gateways/etc.)
       
    45 
       
    46 The CHeaderCodec has an associated instance of a sub-class of each of
       
    47 CHeaderReader and CHeaderWriter.  It delegates the actual encoding and
       
    48 decoding function to these instances.
       
    49 
       
    50 Header codecs provide a mechanism for extensibility whereby if one codec can't
       
    51 decode (or encode) a given header, it locates a codec that can, and then delegates
       
    52 the task to that codec instead.
       
    53 @publishedAll
       
    54 @released
       
    55 */
       
    56 	{
       
    57 public: // methods
       
    58 
       
    59 /** 
       
    60 	Intended Usage:	Destructor - cleans up and releases resources to the system.
       
    61 */
       
    62 	//##ModelId=3C4C18850194
       
    63 	IMPORT_C virtual ~CHeaderCodec();
       
    64 
       
    65 /**
       
    66 	Encode the supplied header field.  This method uses the associated
       
    67 	concrete CHeaderWriter object to do a conversion of the field into
       
    68 	raw form from the generic internal representation.
       
    69 
       
    70 	@param aHeader (in) A proxy for the header field to be encoded
       
    71 	@leave KErrNotSupported if a codec that supports encoding this header
       
    72 		   cannot be found
       
    73 */
       
    74 	//##ModelId=3C4C1885018C
       
    75 	IMPORT_C void EncodeHeaderL(RHeaderField& aHeader) const;
       
    76 
       
    77 /**
       
    78 	Decode the supplied header field.  This method uses the associated
       
    79 	concrete CHeaderReader object to do a conversion of the field into
       
    80 	the generic internal representation from the raw form.
       
    81 
       
    82 	@param aHeader (in) A proxy for the header field to be decoded
       
    83 	
       
    84 	@leave KErrNotSupported if a codec that supports decoding this header
       
    85    		   cannot be found
       
    86 
       
    87 */
       
    88 	//##ModelId=3C4C1885018A
       
    89 	IMPORT_C void DecodeHeaderL(RHeaderField& aHeader) const;
       
    90 
       
    91 /**
       
    92 	Intended Usage: Concrete header codec classes must implement this method to
       
    93 	indicate to the framework whether their concrete CHeaderWriter is
       
    94 	capable of encoding the named header field.
       
    95 	@param aHeaderField	(in) A proxy for the header field to be encoded
       
    96 	@return A flag indicating ETrue if the field can be encoded.
       
    97 */
       
    98 	//##ModelId=3C4C18850181
       
    99 	virtual TBool CanEncode(RStringF aHeaderField) const = 0;
       
   100 
       
   101 /**
       
   102 	Intended Usage: Concrete header codec classes must implement this method to
       
   103 					indicate to the framework whether their concrete CHeaderReader is
       
   104 					capable of decoding the named header field.
       
   105 	@param			aHeaderField		(in) A proxy for the header field to be encoded
       
   106 	@return			A flag indicating ETrue if the field can be decoded.
       
   107  */
       
   108 	//##ModelId=3C4C18850178
       
   109 	virtual TBool CanDecode(RStringF aHeaderField) const = 0;
       
   110 
       
   111 /**
       
   112 	Intended Usage: Concrete header codecs must be implement this method if they wish to
       
   113 					delegate the encoding/decoding of particular header fields to a
       
   114 					different codec.  
       
   115 					This would be done if the codec doesn't have the ability itself to
       
   116 					do the encode/decode but can locate an alternative that does. This 
       
   117 					function may leave with a Standard Symbian OS error code. eg. KErrNoMemory
       
   118 
       
   119 					The caller takes ownership of the returned codec.
       
   120 	@param aHeaderField (in) A proxy for the header field to be encoded
       
   121 	@return A pointer to the new CHeaderCodec, or NULL if one couldn't be found.
       
   122 	@leave KErrNoMemory, Not enough memory to create object.	
       
   123 */
       
   124 	//##ModelId=3C4C18850176
       
   125 	virtual CHeaderCodec* FindDelegateCodecL(RStringF aHeaderField) const = 0;
       
   126 
       
   127 protected: // methods
       
   128 
       
   129 /**
       
   130 	Default constructor.
       
   131  */
       
   132 	//##ModelId=3A914DF20273
       
   133 	IMPORT_C CHeaderCodec();
       
   134 
       
   135 /**
       
   136 	Second phase construction in which any necessary allocation is done
       
   137 	Implementations of this interface may leave with standard erros like KErrNoMemory if there is
       
   138 	insufficient memory for allocation in the second phase.
       
   139  */
       
   140 	//##ModelId=3C4C1885016E
       
   141 	IMPORT_C void ConstructL();
       
   142 
       
   143 protected: // attributes
       
   144 
       
   145 	/** The owned header writer object that does actual encoding of header fields.
       
   146 	*/
       
   147 	//##ModelId=3C4C18850164
       
   148 	CHeaderWriter* iWriter;
       
   149 
       
   150 	/** The owned header reader object that does actual decoding of header fields.
       
   151 	*/
       
   152 	//##ModelId=3C4C1885015A
       
   153 	CHeaderReader* iReader;
       
   154 
       
   155 private: // methods
       
   156 
       
   157 /**	
       
   158 	Intended Usage:	Reserve a slot in the v-table to preserve future BC
       
   159  */
       
   160 	//##ModelId=3C4C1885016D
       
   161 	inline virtual void Reserved1();
       
   162 
       
   163 /**	
       
   164 	Intended Usage:	Reserve a slot in the v-table to preserve future BC
       
   165  */
       
   166 	//##ModelId=3C4C1885016C
       
   167 	inline virtual void Reserved2();
       
   168 
       
   169 private: // attributes
       
   170 
       
   171 	/** The most recently-obtained delegate codec
       
   172 	*/
       
   173 	//##ModelId=3C4C18850150
       
   174 	mutable CHeaderCodec* iDelegateCodec;
       
   175 	};
       
   176 
       
   177 
       
   178 //##ModelId=3C4C188601D1
       
   179 class CHeaderWriter : public CBase
       
   180 /**
       
   181 An abstract HTTP header encoder.  CHeaderWriter provides an interface used by its
       
   182 owning codec to do conversion of header data from the generic internal header
       
   183 representation to the raw representation used for a particular protocol/transport.
       
   184 Specific sub-classes of CHeaderWriter are associated with specific protocol handlers.
       
   185 @publishedAll
       
   186 @released
       
   187 */
       
   188 	{
       
   189 public: // methods
       
   190 
       
   191 /** 
       
   192 	Intended Usage:	Destructor - cleans up and release resources to the system.
       
   193 */
       
   194 	//##ModelId=3C4C188601FC
       
   195 	IMPORT_C virtual ~CHeaderWriter();
       
   196 
       
   197 /**
       
   198 	Intended Usage:	Encodes the supplied header field.  This method does a conversion
       
   199 					of the field into raw form from the generic internal representation.
       
   200 
       
   201 					Implementations of this interface may leave with any of KErrNotSupported, KErrHttpEncodeDoWWWAuthenticate,
       
   202 					KErrHttpEncodeAuthorization, KErrHttpEncodeDoAge, KErrHttpEncodeDoVary, KErrHttpEncodeDoContentLanguage.
       
   203 
       
   204 					Specific header writer sub-classes must implement this method.
       
   205 	@param			aHeader		(in) A proxy for the header field to be encoded
       
   206  */
       
   207 	//##ModelId=3C4C188601FA
       
   208 	virtual void EncodeHeaderL(RHeaderField& aHeader) = 0;
       
   209 
       
   210 protected: // methods
       
   211 
       
   212 /**
       
   213 	Default constructor.
       
   214  */
       
   215 	IMPORT_C CHeaderWriter();
       
   216 
       
   217 /**
       
   218 	Second phase construction in which any necessary allocation is done
       
   219 	Implementations of this interface may leave with standard errors like KErrNoMemory.
       
   220  */
       
   221 	//##ModelId=3C4C188601F9
       
   222 	IMPORT_C void ConstructL();
       
   223 
       
   224 private: // methods
       
   225 
       
   226 /**	
       
   227 	Intended Usage:	Reserve a slot in the v-table to preserve future BC
       
   228  */
       
   229 	//##ModelId=3C4C188601F1
       
   230 	inline virtual void Reserved1();
       
   231 
       
   232 /**	
       
   233 	Intended Usage:	Reserve a slot in the v-table to preserve future BC
       
   234  */
       
   235 	//##ModelId=3C4C188601F0
       
   236 	inline virtual void Reserved2();
       
   237 	};
       
   238 
       
   239 
       
   240 //##ModelId=3C4C188602FE
       
   241 class CHeaderReader : public CBase
       
   242 /**
       
   243 An abstract HTTP header decoder.  CHeaderReader provides an interface used by its
       
   244 owning codec to do conversion of header data from the raw representation used for
       
   245 a particular protocol/transport to the generic internal header representation.
       
   246 Specific sub-classes of CHeaderWriter are associated with specific protocol
       
   247 handlers.
       
   248 @publishedAll
       
   249 @released
       
   250 */
       
   251 	{
       
   252 public: // methods
       
   253 
       
   254 /** 
       
   255 	Intended Usage:	Destructor - cleans up and release resources to the system.
       
   256 */
       
   257 	//##ModelId=3C4C1886031E
       
   258 	IMPORT_C virtual ~CHeaderReader();
       
   259 
       
   260 /**
       
   261 	Intended Usage:	Decodes the supplied header field.  This method does a conversion
       
   262 	of the field from the generic internal representation into raw form.
       
   263 
       
   264 	Specific header reader sub-classes must implement this method.
       
   265 
       
   266 	Implementations of this interface may leave with any of KErrHttpDecodeAccept, KErrHttpDecodeAcceptCharset, 
       
   267 	KErrHttpDecodeAcceptLanguage, KErrHttpDecodeAcceptEncoding, KErrNotSupported.
       
   268 
       
   269 	@param aHeader (in) A proxy for the header field to be decoded
       
   270 	
       
   271 */
       
   272 	//##ModelId=3C4C1886031C
       
   273 	virtual void DecodeHeaderL(RHeaderField& aHeader) = 0;
       
   274 
       
   275 protected: // methods
       
   276 
       
   277 /**
       
   278 	Default constructor.
       
   279  */
       
   280 	IMPORT_C CHeaderReader();
       
   281 
       
   282 /**
       
   283 	Second phase construction in which any necessary allocation is done
       
   284 	Implementations of this interface may leave with standard errors like KErrNoMemory.
       
   285  */
       
   286 	//##ModelId=3C4C18860315
       
   287 	IMPORT_C void ConstructL();
       
   288 
       
   289 private: // methods
       
   290 
       
   291 /**	
       
   292 	Intended Usage:	Reserve a slot in the v-table to preserve future BC
       
   293  */
       
   294 	//##ModelId=3C4C18860314
       
   295 	inline virtual void Reserved1();
       
   296 
       
   297 /**	
       
   298 	Intended Usage:	Reserve a slot in the v-table to preserve future BC
       
   299  */
       
   300 	//##ModelId=3C4C18860313
       
   301 	inline virtual void Reserved2();
       
   302 	};
       
   303 
       
   304 
       
   305 inline void CHeaderCodec::Reserved1()
       
   306 	{}
       
   307 inline void CHeaderCodec::Reserved2()
       
   308 	{}
       
   309 inline void CHeaderWriter::Reserved1()
       
   310 	{}
       
   311 inline void CHeaderWriter::Reserved2()
       
   312 	{}
       
   313 inline void CHeaderReader::Reserved1()
       
   314 	{}
       
   315 inline void CHeaderReader::Reserved2()
       
   316 	{}
       
   317 
       
   318 #endif /* __CHEADERCODEC_H__ */