williamr@2: // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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 williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @file CHeaderCodec.h williamr@2: @warning : This file contains Rose Model ID comments - please do not delete williamr@2: */ williamr@2: williamr@2: #ifndef __CHEADERCODEC_H__ williamr@2: #define __CHEADERCODEC_H__ williamr@2: williamr@2: // System includes williamr@2: #include williamr@2: #include williamr@2: williamr@2: // Forward declarations williamr@2: class CHeaderWriter; williamr@2: class CHeaderReader; williamr@2: williamr@2: williamr@2: //##ModelId=3C4C18850126 williamr@2: class CHeaderCodec : public CBase williamr@2: /** williamr@2: An abstract HTTP header codec. williamr@2: williamr@2: Each instance of a concrete subclass of CHeaderCodec is associated with, and owned williamr@2: by, a specific CProtocolHandler. It provides on-demand encoding/decoding of williamr@2: HTTP header data, between the generic format used by clients/filters to formulate williamr@2: requests and interpret responses, and the raw format used by williamr@2: the transport handlers (and origin servers/gateways/etc.) williamr@2: williamr@2: The CHeaderCodec has an associated instance of a sub-class of each of williamr@2: CHeaderReader and CHeaderWriter. It delegates the actual encoding and williamr@2: decoding function to these instances. williamr@2: williamr@2: Header codecs provide a mechanism for extensibility whereby if one codec can't williamr@2: decode (or encode) a given header, it locates a codec that can, and then delegates williamr@2: the task to that codec instead. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: // methods williamr@2: williamr@2: /** williamr@2: Intended Usage: Destructor - cleans up and releases resources to the system. williamr@2: */ williamr@2: //##ModelId=3C4C18850194 williamr@2: IMPORT_C virtual ~CHeaderCodec(); williamr@2: williamr@2: /** williamr@2: Encode the supplied header field. This method uses the associated williamr@2: concrete CHeaderWriter object to do a conversion of the field into williamr@2: raw form from the generic internal representation. williamr@2: williamr@2: @param aHeader (in) A proxy for the header field to be encoded williamr@2: @leave KErrNotSupported if a codec that supports encoding this header williamr@2: cannot be found williamr@2: */ williamr@2: //##ModelId=3C4C1885018C williamr@2: IMPORT_C void EncodeHeaderL(RHeaderField& aHeader) const; williamr@2: williamr@2: /** williamr@2: Decode the supplied header field. This method uses the associated williamr@2: concrete CHeaderReader object to do a conversion of the field into williamr@2: the generic internal representation from the raw form. williamr@2: williamr@2: @param aHeader (in) A proxy for the header field to be decoded williamr@2: williamr@2: @leave KErrNotSupported if a codec that supports decoding this header williamr@2: cannot be found williamr@2: williamr@2: */ williamr@2: //##ModelId=3C4C1885018A williamr@2: IMPORT_C void DecodeHeaderL(RHeaderField& aHeader) const; williamr@2: williamr@2: /** williamr@2: Intended Usage: Concrete header codec classes must implement this method to williamr@2: indicate to the framework whether their concrete CHeaderWriter is williamr@2: capable of encoding the named header field. williamr@2: @param aHeaderField (in) A proxy for the header field to be encoded williamr@2: @return A flag indicating ETrue if the field can be encoded. williamr@2: */ williamr@2: //##ModelId=3C4C18850181 williamr@2: virtual TBool CanEncode(RStringF aHeaderField) const = 0; williamr@2: williamr@2: /** williamr@2: Intended Usage: Concrete header codec classes must implement this method to williamr@2: indicate to the framework whether their concrete CHeaderReader is williamr@2: capable of decoding the named header field. williamr@2: @param aHeaderField (in) A proxy for the header field to be encoded williamr@2: @return A flag indicating ETrue if the field can be decoded. williamr@2: */ williamr@2: //##ModelId=3C4C18850178 williamr@2: virtual TBool CanDecode(RStringF aHeaderField) const = 0; williamr@2: williamr@2: /** williamr@2: Intended Usage: Concrete header codecs must be implement this method if they wish to williamr@2: delegate the encoding/decoding of particular header fields to a williamr@2: different codec. williamr@2: This would be done if the codec doesn't have the ability itself to williamr@2: do the encode/decode but can locate an alternative that does. This williamr@2: function may leave with a Standard Symbian OS error code. eg. KErrNoMemory williamr@2: williamr@2: The caller takes ownership of the returned codec. williamr@2: @param aHeaderField (in) A proxy for the header field to be encoded williamr@2: @return A pointer to the new CHeaderCodec, or NULL if one couldn't be found. williamr@2: @leave KErrNoMemory, Not enough memory to create object. williamr@2: */ williamr@2: //##ModelId=3C4C18850176 williamr@2: virtual CHeaderCodec* FindDelegateCodecL(RStringF aHeaderField) const = 0; williamr@2: williamr@2: protected: // methods williamr@2: williamr@2: /** williamr@2: Default constructor. williamr@2: */ williamr@2: //##ModelId=3A914DF20273 williamr@2: IMPORT_C CHeaderCodec(); williamr@2: williamr@2: /** williamr@2: Second phase construction in which any necessary allocation is done williamr@2: Implementations of this interface may leave with standard erros like KErrNoMemory if there is williamr@2: insufficient memory for allocation in the second phase. williamr@2: */ williamr@2: //##ModelId=3C4C1885016E williamr@2: IMPORT_C void ConstructL(); williamr@2: williamr@2: protected: // attributes williamr@2: williamr@2: /** The owned header writer object that does actual encoding of header fields. williamr@2: */ williamr@2: //##ModelId=3C4C18850164 williamr@2: CHeaderWriter* iWriter; williamr@2: williamr@2: /** The owned header reader object that does actual decoding of header fields. williamr@2: */ williamr@2: //##ModelId=3C4C1885015A williamr@2: CHeaderReader* iReader; williamr@2: williamr@2: private: // methods williamr@2: williamr@2: /** williamr@2: Intended Usage: Reserve a slot in the v-table to preserve future BC williamr@2: */ williamr@2: //##ModelId=3C4C1885016D williamr@2: inline virtual void Reserved1(); williamr@2: williamr@2: /** williamr@2: Intended Usage: Reserve a slot in the v-table to preserve future BC williamr@2: */ williamr@2: //##ModelId=3C4C1885016C williamr@2: inline virtual void Reserved2(); williamr@2: williamr@2: private: // attributes williamr@2: williamr@2: /** The most recently-obtained delegate codec williamr@2: */ williamr@2: //##ModelId=3C4C18850150 williamr@2: mutable CHeaderCodec* iDelegateCodec; williamr@2: }; williamr@2: williamr@2: williamr@2: //##ModelId=3C4C188601D1 williamr@2: class CHeaderWriter : public CBase williamr@2: /** williamr@2: An abstract HTTP header encoder. CHeaderWriter provides an interface used by its williamr@2: owning codec to do conversion of header data from the generic internal header williamr@2: representation to the raw representation used for a particular protocol/transport. williamr@2: Specific sub-classes of CHeaderWriter are associated with specific protocol handlers. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: // methods williamr@2: williamr@2: /** williamr@2: Intended Usage: Destructor - cleans up and release resources to the system. williamr@2: */ williamr@2: //##ModelId=3C4C188601FC williamr@2: IMPORT_C virtual ~CHeaderWriter(); williamr@2: williamr@2: /** williamr@2: Intended Usage: Encodes the supplied header field. This method does a conversion williamr@2: of the field into raw form from the generic internal representation. williamr@2: williamr@2: Implementations of this interface may leave with any of KErrNotSupported, KErrHttpEncodeDoWWWAuthenticate, williamr@2: KErrHttpEncodeAuthorization, KErrHttpEncodeDoAge, KErrHttpEncodeDoVary, KErrHttpEncodeDoContentLanguage. williamr@2: williamr@2: Specific header writer sub-classes must implement this method. williamr@2: @param aHeader (in) A proxy for the header field to be encoded williamr@2: */ williamr@2: //##ModelId=3C4C188601FA williamr@2: virtual void EncodeHeaderL(RHeaderField& aHeader) = 0; williamr@2: williamr@2: protected: // methods williamr@2: williamr@2: /** williamr@2: Default constructor. williamr@2: */ williamr@2: IMPORT_C CHeaderWriter(); williamr@2: williamr@2: /** williamr@2: Second phase construction in which any necessary allocation is done williamr@2: Implementations of this interface may leave with standard errors like KErrNoMemory. williamr@2: */ williamr@2: //##ModelId=3C4C188601F9 williamr@2: IMPORT_C void ConstructL(); williamr@2: williamr@2: private: // methods williamr@2: williamr@2: /** williamr@2: Intended Usage: Reserve a slot in the v-table to preserve future BC williamr@2: */ williamr@2: //##ModelId=3C4C188601F1 williamr@2: inline virtual void Reserved1(); williamr@2: williamr@2: /** williamr@2: Intended Usage: Reserve a slot in the v-table to preserve future BC williamr@2: */ williamr@2: //##ModelId=3C4C188601F0 williamr@2: inline virtual void Reserved2(); williamr@2: }; williamr@2: williamr@2: williamr@2: //##ModelId=3C4C188602FE williamr@2: class CHeaderReader : public CBase williamr@2: /** williamr@2: An abstract HTTP header decoder. CHeaderReader provides an interface used by its williamr@2: owning codec to do conversion of header data from the raw representation used for williamr@2: a particular protocol/transport to the generic internal header representation. williamr@2: Specific sub-classes of CHeaderWriter are associated with specific protocol williamr@2: handlers. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: // methods williamr@2: williamr@2: /** williamr@2: Intended Usage: Destructor - cleans up and release resources to the system. williamr@2: */ williamr@2: //##ModelId=3C4C1886031E williamr@2: IMPORT_C virtual ~CHeaderReader(); williamr@2: williamr@2: /** williamr@2: Intended Usage: Decodes the supplied header field. This method does a conversion williamr@2: of the field from the generic internal representation into raw form. williamr@2: williamr@2: Specific header reader sub-classes must implement this method. williamr@2: williamr@2: Implementations of this interface may leave with any of KErrHttpDecodeAccept, KErrHttpDecodeAcceptCharset, williamr@2: KErrHttpDecodeAcceptLanguage, KErrHttpDecodeAcceptEncoding, KErrNotSupported. williamr@2: williamr@2: @param aHeader (in) A proxy for the header field to be decoded williamr@2: williamr@2: */ williamr@2: //##ModelId=3C4C1886031C williamr@2: virtual void DecodeHeaderL(RHeaderField& aHeader) = 0; williamr@2: williamr@2: protected: // methods williamr@2: williamr@2: /** williamr@2: Default constructor. williamr@2: */ williamr@2: IMPORT_C CHeaderReader(); williamr@2: williamr@2: /** williamr@2: Second phase construction in which any necessary allocation is done williamr@2: Implementations of this interface may leave with standard errors like KErrNoMemory. williamr@2: */ williamr@2: //##ModelId=3C4C18860315 williamr@2: IMPORT_C void ConstructL(); williamr@2: williamr@2: private: // methods williamr@2: williamr@2: /** williamr@2: Intended Usage: Reserve a slot in the v-table to preserve future BC williamr@2: */ williamr@2: //##ModelId=3C4C18860314 williamr@2: inline virtual void Reserved1(); williamr@2: williamr@2: /** williamr@2: Intended Usage: Reserve a slot in the v-table to preserve future BC williamr@2: */ williamr@2: //##ModelId=3C4C18860313 williamr@2: inline virtual void Reserved2(); williamr@2: }; williamr@2: williamr@2: williamr@2: inline void CHeaderCodec::Reserved1() williamr@2: {} williamr@2: inline void CHeaderCodec::Reserved2() williamr@2: {} williamr@2: inline void CHeaderWriter::Reserved1() williamr@2: {} williamr@2: inline void CHeaderWriter::Reserved2() williamr@2: {} williamr@2: inline void CHeaderReader::Reserved1() williamr@2: {} williamr@2: inline void CHeaderReader::Reserved2() williamr@2: {} williamr@2: williamr@2: #endif /* __CHEADERCODEC_H__ */