applayerpluginsandutils/httpprotocolplugins/wspheadercodec/CWspHeaderCodec.h
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     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 #ifndef __CWSPHEADERCODEC_H__
       
    17 #define __CWSPHEADERCODEC_H__
       
    18 
       
    19 // System Includes
       
    20 #include <e32std.h>
       
    21 #include <http.h>
       
    22 #include <http/framework/cheadercodec.h>
       
    23 
       
    24 
       
    25 /**
       
    26 @internalAll
       
    27 @since			7.0
       
    28 This class is the WSP specific header codec that is required to encode and decode
       
    29 WSP headers between a usable form and the form required for transport. The codec
       
    30 derives from CHeaderCodec interface and provided the WSP specific encoding and
       
    31 decoding of header fields following the specifications stated in the WSP specs
       
    32 available from http://www.wapforum.org and the RFC2616.
       
    33 */
       
    34 //##ModelId=3C4C41B30305
       
    35 class CWspHeaderCodec : public CHeaderCodec
       
    36 	{
       
    37 public: // enums
       
    38 	/**
       
    39 	Enumeration defining the different WSP encoding versions that are supported
       
    40 	@since			7.0
       
    41 	*/
       
    42 	enum TWspVersion
       
    43 		{
       
    44 		EVersion1_1, // Version 1.1
       
    45 		EVersion1_2, // Version 1.2
       
    46 		EVersion1_3, // Version 1.3
       
    47 		EVersion1_4  // Version 1.4
       
    48 		};
       
    49 
       
    50 public: // methods
       
    51 
       
    52 	/**
       
    53 	Standard factory 2 phase construction
       
    54 	@leave			KErrNoMemory
       
    55 	@since			7.0
       
    56 	@param			aStrPool A handle to an open string pool with the string table 
       
    57 					that contains the header field names already open
       
    58 	@param			aStrTable The string table that contains the header field names
       
    59 	@return			A pointer to the newly created object
       
    60 	@pre 			None
       
    61 	@post			Fully constructed and initialized object
       
    62 	*/
       
    63 	//##ModelId=3C4C41B3037D
       
    64 	static CWspHeaderCodec* NewL(RStringPool aStrPool, const TStringTable& aStrTable);
       
    65 
       
    66 	/**
       
    67 	Standard virtual destructor
       
    68 	@since			7.0
       
    69 	@post			Object has been fully destroyed
       
    70 	*/
       
    71 	//##ModelId=3C4C41B30375
       
    72 	virtual ~CWspHeaderCodec();
       
    73  
       
    74 	/**
       
    75 	This method returns whether the header field passed in can
       
    76 					be encoded or not.
       
    77 	@since			7.0
       
    78 	@param			aHeaderField The header field to enquire about
       
    79 	@return			ETrue if the header can be encoded otherwise EFalse
       
    80 	*/
       
    81 	//##ModelId=3C4C41B30373
       
    82 	virtual TBool CanEncode(RStringF aHeaderField) const;
       
    83 
       
    84 	/**
       
    85 	This method returns whether the header field passed in can
       
    86 					be decoded or not.
       
    87 	@since			7.0
       
    88 	@param			aHeaderField The header field to enquire about
       
    89 	@return			ETrue if the header can be decoded otherwise EFalse
       
    90 	*/
       
    91 	//##ModelId=3C4C41B3036A
       
    92 	virtual TBool CanDecode(RStringF aHeaderField) const;
       
    93  
       
    94 	/**
       
    95 	This method should be used to find an alternative codec for the
       
    96 					header field name if this codec cannot handle the header field.
       
    97 					The caller takes ownership of the returned codec.
       
    98 	@since			7.0
       
    99 	@param			aHeaderField The header field name string
       
   100 	@return			A pointer to the newly created codec if one is found, otherwise
       
   101 					NULL is returned if a codec cannot be found. The caller takes
       
   102 					ownership of the returned codec.	
       
   103 	*/
       
   104 	//##ModelId=3C4C41B30360
       
   105 	virtual CHeaderCodec* FindDelegateCodecL(RStringF aHeaderField) const;
       
   106 
       
   107 	/**
       
   108 	This method gets the current encoding version that is being
       
   109 					used.
       
   110 	@since			7.0
       
   111 	@return			The encoding version enumeration
       
   112 	*/
       
   113 	//##ModelId=3C4C41B3035F
       
   114 	TWspVersion GetWspVersion() const;
       
   115 
       
   116 	/**
       
   117 	This method sets the encoding version to use. The encoding
       
   118 					version defaults to 1.2 if this method is not called.
       
   119 	@since			7.0
       
   120 	@param			aWspVersion The encoding version enumeration
       
   121 	@post			The encoding version is set to the version passed in
       
   122 	*/
       
   123 	//##ModelId=3C4C41B30357
       
   124 	void SetWspVersion(TWspVersion aWspVersion);
       
   125 
       
   126 	/**
       
   127 	This method encodes a header field name to its correct encoded
       
   128 					token value. For WSP the returned value must be then be encoded
       
   129 					to a short integer by flipping the first bit to a 1, this is NOT
       
   130 					done in this method.
       
   131 	@since			7.0
       
   132 	@param			aFieldName The header field name string
       
   133 	@return			The encoded token value of the header field name. KErrNotFound if
       
   134 					no encoding value could be found for the header field name
       
   135 	*/
       
   136 	//##ModelId=3C4C41B30355
       
   137 	TInt EncodeFieldName(RStringF aFieldName) const;
       
   138 
       
   139 protected: // methods
       
   140 
       
   141 	/**
       
   142 	Standard constructor
       
   143 	@since			7.0
       
   144 	@param			aStrPool A handle to an opened string pool with the string table 
       
   145 					that contains the header field names already open
       
   146 	@param			aStrTable The string table that contains the header field names
       
   147 	@pre 			None
       
   148 	@post			Object is constructed
       
   149 	*/
       
   150 	//##ModelId=3C4C41B30342 
       
   151 	CWspHeaderCodec(RStringPool aStrPool, const TStringTable& aStrTable);
       
   152 
       
   153 	/**
       
   154 	Standard 2nd phase construction
       
   155 	@leave		KErrNoMemory
       
   156 	@since			7.0
       
   157 	@pre 			Object is constructed
       
   158 	@post			Object is initialized and all the required string tables have
       
   159 					been opened in the string pool
       
   160 	*/
       
   161 	//##ModelId=3C4C41B30341
       
   162 	void ConstructL();
       
   163 
       
   164 private: // methods
       
   165 
       
   166 	/**
       
   167 	Standard default private constructor
       
   168 	@since			7.0
       
   169 	@pre 			None
       
   170 	@post			Object is constructed
       
   171 	*/
       
   172 	//##ModelId=3C4C41B3034D
       
   173 	CWspHeaderCodec();
       
   174 
       
   175 private: // attributes
       
   176 
       
   177 	/** 
       
   178 		Handle to an opened string pool with the header field names table open 
       
   179 	*/
       
   180 	//##ModelId=3C4C41B30339 
       
   181 	RStringPool iStrPool;
       
   182 
       
   183 	/** 
       
   184 		The string table that contains the header field names 
       
   185 	*/
       
   186 	//##ModelId=3C4C41B3032D
       
   187 	const TStringTable& iStrTable;
       
   188 
       
   189 	/**
       
   190 		The current encoding version that is to be used, defaults to 1.2 
       
   191 	*/
       
   192 	//##ModelId=3C4C41B3031C
       
   193 	TWspVersion iWspVersion;
       
   194 	};
       
   195 
       
   196 /**
       
   197 @internalAll
       
   198 @since			7.0
       
   199 This class is the default WSP Header Codec that is used if no codec can encode/
       
   200 decode a particular header. This codec will encode/decode headers with the default
       
   201 behaviour of treating the data as a text-string as defined in the WSP specifications
       
   202 at www.wapforum.org.
       
   203 */
       
   204 class CWspDefaultHeaderCodec : public CHeaderCodec
       
   205 	{
       
   206 public:
       
   207 
       
   208 	/**
       
   209 	Standard factory 2 phase construction
       
   210 	@leave		KErrNoMemory
       
   211 	@since			7.0
       
   212 	@param			aStrPool A handle to an open string pool with the string table 
       
   213 					that contains the header field names already open
       
   214 	@return			A pointer to the newly created object
       
   215 	@pre 			None
       
   216 	@post			Fully constructed and initialized object
       
   217 	*/
       
   218 	static CWspDefaultHeaderCodec* NewL(RStringPool aStrPool);
       
   219 
       
   220 	/**
       
   221 	Standard virtual destructor
       
   222 	@since			7.0
       
   223 	@post			Object has been fully destroyed
       
   224 	*/
       
   225 	virtual ~CWspDefaultHeaderCodec();
       
   226 
       
   227 	/**
       
   228 	This method returns whether the header field passed in can
       
   229 					be encoded or not. Always returns true because it will
       
   230 					handle anything by design!
       
   231 	@since			7.0
       
   232 	@param			aHeaderField The header field to enquire about
       
   233 	@return			ETrue if the header can be encoded otherwise EFalse. In this
       
   234 					case ETrue is always returned
       
   235 	*/
       
   236 	virtual TBool CanEncode(RStringF aHeaderField) const;
       
   237 
       
   238 	/**
       
   239 	This method returns whether the header field passed in can
       
   240 					be decoded or not. Always returns true because it will
       
   241 					handle anything by design!
       
   242 	@since			7.0
       
   243 	@param			aHeaderField The header field to enquire about
       
   244 	@return			ETrue if the header can be decoded otherwise EFalse. In this
       
   245 					case ETrue is always returned
       
   246 	*/
       
   247 	virtual TBool CanDecode(RStringF aHeaderField) const;
       
   248 
       
   249 	/**
       
   250 	Find a delegate codec... always returns NULL, since this codec
       
   251 					handles anything by design.
       
   252 	@since			7.0
       
   253 	@param			aHeaderField The header field name string
       
   254 	@return			A pointer to the newly created codec if one is found, otherwise
       
   255 					NULL is returned if a codec cannot be found. The caller takes
       
   256 					ownership of the returned codec. In this case NULL is always
       
   257 					returned
       
   258 	*/
       
   259 	virtual CHeaderCodec* FindDelegateCodecL(RStringF aHeaderField) const;
       
   260 
       
   261 protected: // methods
       
   262 
       
   263 	/**
       
   264 	Standard constructor
       
   265 	@since			7.0
       
   266 	@param			aStrPool A handle to an opened string pool with the string table 
       
   267 					that contains the header field names already open
       
   268 	@pre 			None
       
   269 	@post			Object is constructed
       
   270 	*/
       
   271 	CWspDefaultHeaderCodec(RStringPool aStrPool);
       
   272 
       
   273 	/**
       
   274 	Standard 2nd phase construction
       
   275 	@leave		KErrNoMemory
       
   276 	@since			7.0
       
   277 	@pre 			Object is constructed
       
   278 	@post			Object is initialized and all the required string tables have
       
   279 					been opened in the string pool
       
   280 	*/
       
   281 	void ConstructL();
       
   282 
       
   283 private:// methods
       
   284 
       
   285 	/**
       
   286 	Standard default private constructor
       
   287 	@since			7.0
       
   288 	@pre 			None
       
   289 	@post			Object is constructed
       
   290 	*/
       
   291 	CWspDefaultHeaderCodec();
       
   292 
       
   293 private: // attributes
       
   294 
       
   295 	/** 
       
   296 		Handle to an opened string pool 
       
   297 	*/
       
   298 	RStringPool iStrPool;
       
   299 	};
       
   300 
       
   301 #endif // __CWSPHEADERCODEC_H__