epoc32/include/chttpformencoder.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 chttpformencoder.h
     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 CHTTPFormEncoder.h
       
    20  @warning : This file contains Rose Model ID comments - please do not delete
       
    21 */
       
    22 
       
    23 #ifndef __CHTTPFORMENCODER__
       
    24 #define __CHTTPFORMENCODER__
       
    25 
       
    26 // System includes
       
    27 #include <http/mhttpdatasupplier.h>
       
    28 
       
    29 //##ModelId=3C4C187902EB
       
    30 class CHTTPFormEncoder : public CBase, public MHTTPDataSupplier
       
    31 /** 
       
    32 A data supplier class that is used to build up data that is to be encoded to application/x-www-form-urlencoded.
       
    33 
       
    34 A client will create an instance of this class and add name/value pairs. They then use this as the data supplier for the 
       
    35 body of an http request that is a forms submission.  
       
    36 
       
    37 The name and value must both be supplied in the correct character encoding that you want to send to the server. This then 
       
    38 gets url encoded.
       
    39 @publishedAll
       
    40 @released
       
    41 */
       
    42 	{
       
    43 public:
       
    44 	//##ModelId=3C4C18790347
       
    45 	IMPORT_C static CHTTPFormEncoder* NewL();
       
    46 	//##ModelId=3C4C18790346
       
    47 	IMPORT_C  ~CHTTPFormEncoder();
       
    48 
       
    49 	// from MHTTPDataSupplier
       
    50 	//##ModelId=3C4C1879033D
       
    51 	virtual TBool GetNextDataPart(TPtrC8& aDataPart);
       
    52 	//##ModelId=3C4C1879033C
       
    53 	virtual void ReleaseData();
       
    54 	//##ModelId=3C4C1879033B
       
    55 	virtual TInt OverallDataSize();
       
    56 	//
       
    57 	//##ModelId=3C4C18790335
       
    58 	virtual TInt Reset();
       
    59 
       
    60 	/** Adds a field to the data.
       
    61 	A field consists a name and value pair
       
    62 	@param aFieldName A name. This must not be empty
       
    63 	@param aFieldValue A value. This may be an empty descriptor
       
    64 	@leave KErrNoMemory There was not enough memory
       
    65 	@leave KErrArgument aFieldName was empty
       
    66 	@panic Will panic if called after the first data has been supplied or OverallDataSize has been called
       
    67 	*/
       
    68 	//##ModelId=3C4C18790332
       
    69 	IMPORT_C void AddFieldL(const TDesC8& aFieldName, const TDesC8& aFieldValue);
       
    70 	
       
    71 	
       
    72 private:
       
    73 	//##ModelId=3C4C18790331
       
    74 	CHTTPFormEncoder();
       
    75 	//##ModelId=3C4C1879032A
       
    76 	void ConstructL();
       
    77 	
       
    78 	//##ModelId=3C4C18790328
       
    79 	TBool IsAlphaNumeric(TUint8 aChar);
       
    80 	//##ModelId=3C4C1879031F
       
    81 	void AppendSpecialChar(TUint8 aChar);
       
    82 	//##ModelId=3C4C1879031D
       
    83 	void AppendData(const TDesC8& aData);
       
    84 
       
    85 private:
       
    86 	enum THTTPFormEncoderState
       
    87 		{
       
    88 		EAllowAppendData, // when first constructed 
       
    89 		ESuppliedSize,
       
    90 		ESupplyingData,    // GetDataChunk has been called but ReleaseData has not
       
    91 		EDataReleased
       
    92 		};
       
    93 
       
    94 	//##ModelId=3C4C18790315
       
    95 	THTTPFormEncoderState iState;
       
    96 	//##ModelId=3C4C1879030D
       
    97 	HBufC8* iData;		// data is ALWAYS kept in the form-url-encoded format
       
    98 	};
       
    99 
       
   100 #endif // __CHTTPFORMENCODER__