applayerprotocols/httpexamples/TestWebBrowser/inc/browsertransaction.h
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2005-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 _HTTPTRANSACTION_H
       
    17 #define _HTTPTRANSACTION_H
       
    18 
       
    19 #include <http.h>
       
    20 
       
    21 class CHttpExampleUtils;
       
    22 class CBrowserTransaction;
       
    23 class CHtmlHandler;
       
    24 
       
    25 class MBrowserTransactionObserver 
       
    26 	{
       
    27 	public:
       
    28 		virtual void OnTransactionCreateL ( const TDesC8& aUri, TBool aParseHtml ) = 0;
       
    29 		virtual void OnTransactionClose ( CBrowserTransaction* aTrans ) = 0;
       
    30 	};
       
    31 
       
    32 // -------------------------------------------------------------------
       
    33 class CBrowserTransaction : public CBase, public MHTTPTransactionCallback
       
    34 	{
       
    35 	public:
       
    36 		
       
    37 		enum TMimeType
       
    38 			{
       
    39 			eXml,
       
    40 			eHtml,
       
    41 			eUnknown				
       
    42 			};
       
    43 		
       
    44 		virtual ~CBrowserTransaction();
       
    45 		
       
    46 		static CBrowserTransaction* NewLC ( RHTTPSession& aSession, 
       
    47 											CHttpExampleUtils& aTestUtils,
       
    48 											MBrowserTransactionObserver* aObserver,
       
    49 											const TDesC& aFilePath,
       
    50 											TBool aParseHtml  = EFalse  );
       
    51 									
       
    52 		static CBrowserTransaction* NewL ( 	RHTTPSession& aSession, 
       
    53 											CHttpExampleUtils& aTestUtils,
       
    54 											MBrowserTransactionObserver* aObserver,	
       
    55 											const TDesC& aFilePath,
       
    56 											TBool aParseHtml  = EFalse  );
       
    57 							
       
    58 		void CreateTransactionL ( const TDesC8& aUri );
       
    59 		void StartTransactionL ();
       
    60 		
       
    61 		//
       
    62 		// methods from MHTTPTransactionCallback
       
    63 		//
       
    64 		virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
       
    65 		virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
       
    66 			
       
    67 	protected:
       
    68 		CBrowserTransaction( RHTTPSession& aSession, CHttpExampleUtils& aTestUtils, MBrowserTransactionObserver* aObserver, TBool aParseHtml  = EFalse  );
       
    69 		void ConstructL ( const TDesC& aFilePath );
       
    70 
       
    71 	private:	
       
    72 		void ExtractContentTypeL ( RHTTPResponse& aResponse, RStringF& aContentTypeValue );
       
    73 		void LoadPluginL ( TMimeType aType );
       
    74 		void SetAcceptHdrL ();
       
    75 		TMimeType GetMimeType ( const RStringF& aType );
       
    76 	private:
       
    77 		RHTTPTransaction iTransaction;	
       
    78 		
       
    79 		RHTTPSession& iSession;	
       
    80 		MBrowserTransactionObserver* iTransObserver;	
       
    81 		CHttpExampleUtils& iTestUtils;
       
    82 		
       
    83 		HBufC* iFilePath;
       
    84 		
       
    85 		RFs iFileServer;
       
    86 		RFile iRespBodyFile;
       
    87 		MHTTPDataSupplier* iRespBody;	
       
    88 		
       
    89 		CHtmlHandler *iHtmlHandler;
       
    90 		
       
    91 		TBool iParseHtml;
       
    92 		
       
    93 		TBool iSavingBody;
       
    94 		
       
    95 	};
       
    96 
       
    97 #endif // _HTTPTRANSACTION_H