engine/inc/HttpEventHandler.h
changeset 2 29cda98b007e
child 117 c2a99fe1afd0
equal deleted inserted replaced
1:5f8e5adbbed9 2:29cda98b007e
       
     1 /*
       
     2 * Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB
       
     3 *
       
     4 * All rights reserved.
       
     5 * This component and the accompanying materials are made available
       
     6 * under the terms of the License "Eclipse Public License v1.0"
       
     7 * which accompanies this distribution, and is available
       
     8 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     9 *
       
    10 * Initial Contributors:
       
    11 * EmbedDev AB - initial contribution.
       
    12 *
       
    13 * Contributors:
       
    14 *
       
    15 * Description:
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef HTTPEVENTHANDLER_H
       
    20 #define HTTPEVENTHANDLER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <http/mhttpdatasupplier.h>
       
    24 #include <http/rhttpsession.h>
       
    25 #include <http/rhttpheaders.h>
       
    26 #include <http/mhttptransactioncallback.h>
       
    27 #include <httpstringconstants.h>
       
    28 #include "HttpClientObserver.h"
       
    29 
       
    30 const TInt KMaxSubmitSize = 1024;
       
    31 const TInt KMaxHeaderNameLen = 32;
       
    32 const TInt KMaxHeaderValueLen = 128;
       
    33 const TInt KByteOverlap = 4096;
       
    34 
       
    35 class CHttpEventHandler : public CBase,
       
    36                           public MHTTPTransactionCallback
       
    37   {
       
    38   public:
       
    39 	virtual ~CHttpEventHandler();
       
    40 	static CHttpEventHandler* NewLC(CHttpClient* aClient, MHttpClientObserver &aCallbacks, RFs& aFs);
       
    41 	static CHttpEventHandler* NewL(CHttpClient* aClient, MHttpClientObserver &aCallbacks, RFs& aFs);
       
    42 	void SetSaveFileName(const TDesC &fName,TBool aContinue=EFalse);
       
    43 	void CloseSaveFile();	
       
    44 	// from MHTTPTransactionCallback
       
    45 	virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
       
    46 	virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
       
    47 	void SetSilent(TBool aSilent);
       
    48 
       
    49 	
       
    50 protected:
       
    51 	CHttpEventHandler(CHttpClient* aClient, MHttpClientObserver &aCallbacks, RFs& aFs);
       
    52 	void ConstructL();
       
    53 	
       
    54 private:
       
    55 	void DumpRespHeadersL(RHTTPTransaction& aTrans);
       
    56 	void DumpRespBody(RHTTPTransaction& aTrans);
       
    57 	void DumpIt(const TDesC8& aData);
       
    58 
       
    59 private:
       
    60 	TBool iVerbose;
       
    61 	TBool iSavingResponseBody;
       
    62 	RFs& iFileServ;
       
    63 	RFile iRespBodyFile;
       
    64 	TFileName iFileName;
       
    65 	TParse iParsedFileName;
       
    66 	MHTTPDataSupplier* iRespBody;	
       
    67 	TInt iBytesDownloaded;
       
    68 	TInt iBytesTotal;
       
    69 	CHttpClient* iHttpClient;
       
    70 	MHttpClientObserver& iCallbacks;
       
    71 	TBool iSilent;
       
    72 	TBool iContinue;
       
    73 	TInt iLastStatusCode;
       
    74 };
       
    75 
       
    76 #endif