applayerprotocols/httptransportfw/Test/testhttpmessage/ctestmessagecomposer.h
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2003-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 #ifndef __CTESTMESSAGECOMPOSER_H__
       
    17 #define __CTESTMESSAGECOMPOSER_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #if !defined HTTP_H
       
    21 #include <http.h>
       
    22 #endif
       
    23 #include "rhttpmessagecomposer.h"
       
    24 #include "mhttpmessagecomposerobserver.h"
       
    25 
       
    26 #if !defined MHTTPTRANSACTIONCALLBACK_H__
       
    27 #include <http/mhttptransactioncallback.h>
       
    28 #endif
       
    29 
       
    30 #if !defined __MTESTOBSERVER_H__
       
    31 #include "mtestobserver.h"
       
    32 #endif
       
    33 
       
    34 
       
    35 class CTestMessageComposer : public CActive,
       
    36 							   public MHttpMessageComposerObserver,public MHTTPTransactionCallback
       
    37 	{
       
    38 	
       
    39 public:	// methods
       
    40 
       
    41 	static CTestMessageComposer* NewL(MTestObserver& aTestObserver);
       
    42 
       
    43 	virtual ~CTestMessageComposer();
       
    44 	void SetHeaderL(TInt aNumberofHeaders);
       
    45 	void StartRequest();
       
    46 
       
    47 private:	// methods from CActive
       
    48 
       
    49 	virtual void RunL();
       
    50 	virtual void DoCancel();
       
    51 	virtual TInt RunError(TInt aError);
       
    52 
       
    53 private:	// methods from MHttpMessageComposerObserver
       
    54 
       
    55 	virtual void StartLineL(TPtrC8& aToken1, TPtrC8& aToken2, TPtrC8& aToken3);
       
    56 	virtual TInt NextHeaderL(TPtrC8& aHeaderName, TPtrC8& aHeaderValue);
       
    57 	virtual TInt NextTrailerL(TPtrC8& aHeaderName, TPtrC8& aHeaderValue);
       
    58 	virtual MHTTPDataSupplier* HasBodyL();
       
    59 	virtual void MessageComplete();
       
    60 	virtual void MessageDataReadyL();
       
    61 
       
    62 	virtual TInt HandleComposeError(TInt aError);
       
    63 
       
    64 	virtual void Reserved_MHttpMessageComposerObserver();
       
    65 	
       
    66 private:
       
    67 	//
       
    68 	// methods from MHTTPTransactionCallback
       
    69 	//
       
    70 	virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
       
    71 	virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
       
    72 
       
    73 private:	// enums
       
    74 
       
    75 	enum TMessageState
       
    76 		{
       
    77 		EPendingStartLine			= 0,
       
    78 		EPendingNextHeader,
       
    79 		EPendingHasBody,
       
    80 		EPendingNextTrailer,
       
    81 		EPendingMessageComplete,
       
    82 		EDone
       
    83 		};
       
    84 private:	// helper classes
       
    85 
       
    86 	class THeaderField
       
    87 		{
       
    88 	public:	// methods
       
    89 
       
    90 		THeaderField(const TDesC8& aName, const TDesC8& aValue) : iName(aName), iValue(aValue) {};
       
    91 
       
    92 	public:	// attributes
       
    93 
       
    94 		TPtrC8		iName;
       
    95 		TPtrC8		iValue;
       
    96 
       
    97 		};
       
    98 private:	// methods
       
    99 
       
   100 	CTestMessageComposer(MTestObserver& aObserver);
       
   101 	void ConstructL();
       
   102 
       
   103 	void CompleteSelf();
       
   104 	void DoReset();
       
   105 	
       
   106 private:
       
   107 
       
   108 	RStringPool iStringPool;
       
   109 	RHTTPSession iSession;
       
   110 	RHTTPTransaction iTransaction; // only used to create headers
       
   111 	RHTTPHeaders iHTTPHeaders;
       
   112 	RArray<THeaderField>	iHeaders;
       
   113 	TInt					iHeaderIndex;
       
   114 	MTestObserver&		iObserver;
       
   115 	RHttpMessageComposer	iMessageComposer;
       
   116 	RHTTPRequest			iRequest;
       
   117 	TMessageState			iState;
       
   118 	TBool iFlag;
       
   119 	};
       
   120 
       
   121 #endif  // __CTestMessageComposer_H__