epoc32/include/mw/chttpformencoder.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/mw/chttpformencoder.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,100 @@
     1.4 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// 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
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +
    1.21 +/**
    1.22 + @file CHTTPFormEncoder.h
    1.23 + @warning : This file contains Rose Model ID comments - please do not delete
    1.24 +*/
    1.25 +
    1.26 +#ifndef __CHTTPFORMENCODER__
    1.27 +#define __CHTTPFORMENCODER__
    1.28 +
    1.29 +// System includes
    1.30 +#include <http/mhttpdatasupplier.h>
    1.31 +
    1.32 +//##ModelId=3C4C187902EB
    1.33 +class CHTTPFormEncoder : public CBase, public MHTTPDataSupplier
    1.34 +/** 
    1.35 +A data supplier class that is used to build up data that is to be encoded to application/x-www-form-urlencoded.
    1.36 +
    1.37 +A client will create an instance of this class and add name/value pairs. They then use this as the data supplier for the 
    1.38 +body of an http request that is a forms submission.  
    1.39 +
    1.40 +The name and value must both be supplied in the correct character encoding that you want to send to the server. This then 
    1.41 +gets url encoded.
    1.42 +@publishedAll
    1.43 +@released
    1.44 +*/
    1.45 +	{
    1.46 +public:
    1.47 +	//##ModelId=3C4C18790347
    1.48 +	IMPORT_C static CHTTPFormEncoder* NewL();
    1.49 +	//##ModelId=3C4C18790346
    1.50 +	IMPORT_C  ~CHTTPFormEncoder();
    1.51 +
    1.52 +	// from MHTTPDataSupplier
    1.53 +	//##ModelId=3C4C1879033D
    1.54 +	virtual TBool GetNextDataPart(TPtrC8& aDataPart);
    1.55 +	//##ModelId=3C4C1879033C
    1.56 +	virtual void ReleaseData();
    1.57 +	//##ModelId=3C4C1879033B
    1.58 +	virtual TInt OverallDataSize();
    1.59 +	//
    1.60 +	//##ModelId=3C4C18790335
    1.61 +	virtual TInt Reset();
    1.62 +
    1.63 +	/** Adds a field to the data.
    1.64 +	A field consists a name and value pair
    1.65 +	@param aFieldName A name. This must not be empty
    1.66 +	@param aFieldValue A value. This may be an empty descriptor
    1.67 +	@leave KErrNoMemory There was not enough memory
    1.68 +	@leave KErrArgument aFieldName was empty
    1.69 +	@panic Will panic if called after the first data has been supplied or OverallDataSize has been called
    1.70 +	*/
    1.71 +	//##ModelId=3C4C18790332
    1.72 +	IMPORT_C void AddFieldL(const TDesC8& aFieldName, const TDesC8& aFieldValue);
    1.73 +	
    1.74 +	
    1.75 +private:
    1.76 +	//##ModelId=3C4C18790331
    1.77 +	CHTTPFormEncoder();
    1.78 +	//##ModelId=3C4C1879032A
    1.79 +	void ConstructL();
    1.80 +	
    1.81 +	//##ModelId=3C4C18790328
    1.82 +	TBool IsAlphaNumeric(TUint8 aChar);
    1.83 +	//##ModelId=3C4C1879031F
    1.84 +	void AppendSpecialChar(TUint8 aChar);
    1.85 +	//##ModelId=3C4C1879031D
    1.86 +	void AppendData(const TDesC8& aData);
    1.87 +
    1.88 +private:
    1.89 +	enum THTTPFormEncoderState
    1.90 +		{
    1.91 +		EAllowAppendData, // when first constructed 
    1.92 +		ESuppliedSize,
    1.93 +		ESupplyingData,    // GetDataChunk has been called but ReleaseData has not
    1.94 +		EDataReleased
    1.95 +		};
    1.96 +
    1.97 +	//##ModelId=3C4C18790315
    1.98 +	THTTPFormEncoderState iState;
    1.99 +	//##ModelId=3C4C1879030D
   1.100 +	HBufC8* iData;		// data is ALWAYS kept in the form-url-encoded format
   1.101 +	};
   1.102 +
   1.103 +#endif // __CHTTPFORMENCODER__