epoc32/include/mw/chttpformencoder.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/chttpformencoder.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
williamr@2
    17
williamr@2
    18
/**
williamr@2
    19
 @file CHTTPFormEncoder.h
williamr@2
    20
 @warning : This file contains Rose Model ID comments - please do not delete
williamr@2
    21
*/
williamr@2
    22
williamr@2
    23
#ifndef __CHTTPFORMENCODER__
williamr@2
    24
#define __CHTTPFORMENCODER__
williamr@2
    25
williamr@2
    26
// System includes
williamr@2
    27
#include <http/mhttpdatasupplier.h>
williamr@2
    28
williamr@2
    29
//##ModelId=3C4C187902EB
williamr@2
    30
class CHTTPFormEncoder : public CBase, public MHTTPDataSupplier
williamr@2
    31
/** 
williamr@2
    32
A data supplier class that is used to build up data that is to be encoded to application/x-www-form-urlencoded.
williamr@2
    33
williamr@2
    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 
williamr@2
    35
body of an http request that is a forms submission.  
williamr@2
    36
williamr@2
    37
The name and value must both be supplied in the correct character encoding that you want to send to the server. This then 
williamr@2
    38
gets url encoded.
williamr@2
    39
@publishedAll
williamr@2
    40
@released
williamr@2
    41
*/
williamr@2
    42
	{
williamr@2
    43
public:
williamr@2
    44
	//##ModelId=3C4C18790347
williamr@2
    45
	IMPORT_C static CHTTPFormEncoder* NewL();
williamr@2
    46
	//##ModelId=3C4C18790346
williamr@2
    47
	IMPORT_C  ~CHTTPFormEncoder();
williamr@2
    48
williamr@2
    49
	// from MHTTPDataSupplier
williamr@2
    50
	//##ModelId=3C4C1879033D
williamr@2
    51
	virtual TBool GetNextDataPart(TPtrC8& aDataPart);
williamr@2
    52
	//##ModelId=3C4C1879033C
williamr@2
    53
	virtual void ReleaseData();
williamr@2
    54
	//##ModelId=3C4C1879033B
williamr@2
    55
	virtual TInt OverallDataSize();
williamr@2
    56
	//
williamr@2
    57
	//##ModelId=3C4C18790335
williamr@2
    58
	virtual TInt Reset();
williamr@2
    59
williamr@2
    60
	/** Adds a field to the data.
williamr@2
    61
	A field consists a name and value pair
williamr@2
    62
	@param aFieldName A name. This must not be empty
williamr@2
    63
	@param aFieldValue A value. This may be an empty descriptor
williamr@2
    64
	@leave KErrNoMemory There was not enough memory
williamr@2
    65
	@leave KErrArgument aFieldName was empty
williamr@2
    66
	@panic Will panic if called after the first data has been supplied or OverallDataSize has been called
williamr@2
    67
	*/
williamr@2
    68
	//##ModelId=3C4C18790332
williamr@2
    69
	IMPORT_C void AddFieldL(const TDesC8& aFieldName, const TDesC8& aFieldValue);
williamr@2
    70
	
williamr@2
    71
	
williamr@2
    72
private:
williamr@2
    73
	//##ModelId=3C4C18790331
williamr@2
    74
	CHTTPFormEncoder();
williamr@2
    75
	//##ModelId=3C4C1879032A
williamr@2
    76
	void ConstructL();
williamr@2
    77
	
williamr@2
    78
	//##ModelId=3C4C18790328
williamr@2
    79
	TBool IsAlphaNumeric(TUint8 aChar);
williamr@2
    80
	//##ModelId=3C4C1879031F
williamr@2
    81
	void AppendSpecialChar(TUint8 aChar);
williamr@2
    82
	//##ModelId=3C4C1879031D
williamr@2
    83
	void AppendData(const TDesC8& aData);
williamr@2
    84
williamr@2
    85
private:
williamr@2
    86
	enum THTTPFormEncoderState
williamr@2
    87
		{
williamr@2
    88
		EAllowAppendData, // when first constructed 
williamr@2
    89
		ESuppliedSize,
williamr@2
    90
		ESupplyingData,    // GetDataChunk has been called but ReleaseData has not
williamr@2
    91
		EDataReleased
williamr@2
    92
		};
williamr@2
    93
williamr@2
    94
	//##ModelId=3C4C18790315
williamr@2
    95
	THTTPFormEncoderState iState;
williamr@2
    96
	//##ModelId=3C4C1879030D
williamr@2
    97
	HBufC8* iData;		// data is ALWAYS kept in the form-url-encoded format
williamr@2
    98
	};
williamr@2
    99
williamr@2
   100
#endif // __CHTTPFORMENCODER__