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