engine/inc/HttpClient.h
changeset 2 29cda98b007e
child 13 f58e3c482bd9
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 __HTTPCLIENT_H__
       
    20 #define __HTTPCLIENT_H__
       
    21 
       
    22 #include <http/rhttpsession.h>
       
    23 #include "HttpClientObserver.h"
       
    24 #include "HttpEventHandler.h"
       
    25 #include "PodcastModel.h"
       
    26 #include "connectionengine.h"
       
    27 #include "es_sock.h"
       
    28 #include "constants.h"
       
    29 
       
    30 _LIT8(KUserAgent, "Symbian/Podcatcher");
       
    31 _LIT8(KAccept, "*/*");
       
    32 
       
    33 class CHttpClient : public CBase, public MConnectionObserver
       
    34 {
       
    35 public:
       
    36 	virtual ~CHttpClient();
       
    37 	static CHttpClient* NewL(CPodcastModel& aPodcastModel, MHttpClientObserver& aResObs);
       
    38 	TBool GetL(const TDesC& aUrl, const TDesC& aFileName, TBool aSilent = EFalse);
       
    39 	void Stop();
       
    40   	TBool IsActive();
       
    41 	void ClientRequestCompleteL(TInt aErrorCode);
       
    42 	void SetResumeEnabled(TBool aEnabled);
       
    43 
       
    44 private:
       
    45 	CHttpClient(CPodcastModel& aPodcastModel, MHttpClientObserver& aResObs);
       
    46 	static CHttpClient* NewLC(CPodcastModel& aPodcastModel, MHttpClientObserver& aResObs);
       
    47 	void ConstructL();
       
    48 	void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue);
       
    49 	void ConnectHttpSessionL();
       
    50 	void ConnectCompleteL(TInt aErrorCode);
       
    51 	void Disconnected();
       
    52 	void DoGetAfterConnectL();
       
    53 private:
       
    54 	RHTTPSession iSession;	
       
    55 	TBool iWaitingForGet;
       
    56 	TBool iIsActive;
       
    57 	RHTTPTransaction iTrans;
       
    58 	CHttpEventHandler* iHandler;
       
    59 	TBool iResumeEnabled;
       
    60 	CPodcastModel& iPodcastModel;
       
    61 	MHttpClientObserver& iObserver;
       
    62 	TInt iTransactionCount;
       
    63 	TBuf8<KDefaultURLBufferLength> iCurrentURL;
       
    64 	TUriParser8 iUriParser;
       
    65 	TBool iSilentGet;
       
    66 	TFileName iCurrentFileName;
       
    67 };
       
    68 #endif
       
    69