| 2 |      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();
 | 
| 13 |     52 | 	void ConnectionSelectionStart() {}
 | 
|  |     53 | 	void ConnectionSelectionEnd() {}
 | 
| 2 |     54 | 	void DoGetAfterConnectL();
 | 
|  |     55 | private:
 | 
|  |     56 | 	RHTTPSession iSession;	
 | 
|  |     57 | 	TBool iWaitingForGet;
 | 
|  |     58 | 	TBool iIsActive;
 | 
|  |     59 | 	RHTTPTransaction iTrans;
 | 
|  |     60 | 	CHttpEventHandler* iHandler;
 | 
|  |     61 | 	TBool iResumeEnabled;
 | 
|  |     62 | 	CPodcastModel& iPodcastModel;
 | 
|  |     63 | 	MHttpClientObserver& iObserver;
 | 
|  |     64 | 	TInt iTransactionCount;
 | 
|  |     65 | 	TBuf8<KDefaultURLBufferLength> iCurrentURL;
 | 
|  |     66 | 	TUriParser8 iUriParser;
 | 
|  |     67 | 	TBool iSilentGet;
 | 
|  |     68 | 	TFileName iCurrentFileName;
 | 
|  |     69 | };
 | 
|  |     70 | #endif
 | 
|  |     71 | 
 |