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