00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __DOWNLOADMGR_CLIENT_H__
00022 #define __DOWNLOADMGR_CLIENT_H__
00023
00024
00025 #include <e32base.h>
00026 #include <f32file.h>
00027 #include <HttpDownloadMgrCommon.h>
00028 #include <http.h>
00029
00030
00031 class CDownloadMgrHandler;
00032 class RHttpDownload;
00033 class MHttpDownloadMgrObserver;
00034 class CDefaultAttrib;
00035 class CRHttpDownloadExtension;
00036 class CRHttpDownloadMgrExtension;
00037 class CRHttpDlExtension;
00038 class CEikonEnv;
00039 class CTransactionObserver;
00040 class THttpTransactionCallback;
00041 class CCodDownload;
00042 class CCodObserver;
00043
00050 void HashL( const TDesC8& aMessage, TDes8& aHash );
00051
00052
00053 typedef CArrayPtrFlat< RHttpDownload > CDownloadArray;
00054 typedef CArrayPtrFlat< MHttpDownloadMgrObserver > CDownloadMgrObserver;
00055
00056
00057
00064 NONSHARABLE_CLASS( THttpDownloadEvent )
00065 {
00066 public:
00067
00068 THttpDownloadState iDownloadState;
00069
00070 THttpProgressState iProgressState;
00071 };
00072
00080 class MHttpDownloadMgrObserver
00081 {
00082
00083 public:
00084
00091 virtual void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent ) = 0;
00092 };
00093
00101 class MHttpDownloadMgrNextUriObserver
00102 {
00103
00104 public:
00105
00112 virtual void NextUriL( RHttpDownload& aDownload, const TDesC8& aUri ) = 0;
00113 };
00114
00121 NONSHARABLE_CLASS( RHttpDownloadMgr ) : public RSessionBase,
00122 public MHttpDownloadMgrObserver
00123 {
00124 public:
00128 IMPORT_C RHttpDownloadMgr();
00129
00130 public:
00131
00140 IMPORT_C void ConnectL( TUid aAppUid,
00141 MHttpDownloadMgrObserver& aObserver,
00142 TBool aMaster );
00143
00149 IMPORT_C TVersion Version() const;
00150
00156 IMPORT_C void Close();
00157
00163 IMPORT_C const CDownloadArray& CurrentDownloads() const;
00164
00172 IMPORT_C RHttpDownload& CreateDownloadL( const TDesC8& aUrl, TBool& aResult );
00173
00181 IMPORT_C RHttpDownload& CreateDownloadL( const TDesC8& aUrl );
00182
00189 IMPORT_C RHttpDownload& CreateClientSideDownloadL( TInt aHttpTransaction,TBool& aResult );
00190
00202 IMPORT_C RHttpDownload& CreateCodDownloadL( const TDesC8& aUrl,
00203 const TDesC8& aBuf,
00204 const TDesC8& aMimeType,
00205 CEikonEnv* aEikEnv,
00206 TBool& aResult );
00207
00216 IMPORT_C RHttpDownload* FindDownload( const TDesC8& aUrl, const TDesC8& aMsgBody );
00217
00223 IMPORT_C TInt PauseAll();
00224
00230 IMPORT_C TInt StartAll();
00231
00237 IMPORT_C TInt ResetAll();
00238
00244 IMPORT_C TInt DeleteAll();
00245
00251 IMPORT_C TInt Disconnect();
00252
00259 IMPORT_C TInt GetIntAttribute( const TUint aAttribute, TInt32& aValue );
00260
00267 IMPORT_C TInt GetBoolAttribute( const TUint aAttribute, TBool& aValue );
00268
00275 IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes16& aValue );
00276
00283 IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes8& aValue );
00284
00291 IMPORT_C TInt SetIntAttribute( const TUint aAttribute, TInt32 aValue );
00292
00299 IMPORT_C TInt SetBoolAttribute( const TUint aAttribute, TBool aValue );
00300
00307 IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC16& aValue );
00308
00315 IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC8& aValue );
00316
00323 IMPORT_C TInt SetDefaultIntAttribute( const TUint aAttribute, TInt32 aValue );
00324
00331 IMPORT_C TInt SetDefaultBoolAttribute( const TUint aAttribute, TBool aValue );
00332
00339 IMPORT_C TInt SetDefaultStringAttribute( const TUint aAttribute, const TDesC16& aValue );
00340
00347 IMPORT_C TInt SetDefaultStringAttribute( const TUint aAttribute, const TDesC8& aValue );
00348
00354 IMPORT_C void AddObserverL( MHttpDownloadMgrObserver& aObserver );
00355
00361 IMPORT_C void RemoveObserver( MHttpDownloadMgrObserver& aObserver );
00362
00368 IMPORT_C void SetNextUriObserver( MHttpDownloadMgrNextUriObserver* aObserver );
00369
00370 protected:
00371
00378 void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent );
00379
00380 private:
00381
00388 void HandleSessionEventL( TInt aHandle, THttpDownloadEvent aEvent );
00389
00390 private:
00391
00400 void DoConnectL( TUid aAppUid,
00401 MHttpDownloadMgrObserver& aObserver,
00402 TBool aMaster );
00403
00412 void InitializeL( TUid aAppUid,
00413 MHttpDownloadMgrObserver& aObserver,
00414 TBool aMaster );
00415
00416 protected:
00417
00424 RHttpDownload& AddToArrayL( RHttpDownload* aElement );
00425
00426 private:
00427
00433 void RemoveFromArray( RHttpDownload* aElement );
00434
00441 TInt FindInArray( RHttpDownload* aElement, TInt& aIndex ) const;
00442
00448 RHttpDownload& DownloadFromHandleL( TUint aHandle );
00449
00456 TInt FindObserver( MHttpDownloadMgrObserver& aObserver, TInt& aIndex ) const;
00457
00463 void AttachL( TDes8& aBuf );
00464
00470 void CloseDownload( RHttpDownload* aElement );
00471
00477 HBufC8* PackedDefaultAttributesLC();
00478
00485 void DoSetDefaultAttributeL( const TUint aAttribute, TInt32 aValue );
00486
00493 void DoSetDefaultAttributeL( const TUint aAttribute, TBool aValue );
00494
00501 void DoSetDefaultAttributeL( const TUint aAttribute, const TDesC8& aValue );
00502
00509 void DoSetDefaultAttributeL( const TUint aAttribute, const TDesC16& aValue );
00510
00516 void StartSessionEventNotification( const TDesC8& aDownloadState,
00517 const TDesC8& aProgressState,
00518 const TDesC8& aHandle,
00519 TRequestStatus& aStatus );
00520
00526 void CancelSessionEventNotification();
00527
00531 RHttpDownload* DoFindDownloadL( const TDesC8& aUrl, const TDesC8& aMsgBody );
00532
00538 TInt NumberOfClientSideDownload( TInt32& aValue );
00539
00545 TBool IsEventBroadcasting();
00546
00553 void DoHandleSessionEventL( TInt aHandle, THttpDownloadEvent aEvent );
00554
00561 void BroadcastEvent( RHttpDownload& aDownload,
00562 THttpDownloadEvent aEvent );
00563
00568 MHttpDownloadMgrNextUriObserver* NextUriObserver() const;
00569
00574 TInt SessionId() const;
00575
00581
00582
00587 TInt EventPriorityFlag() const;
00588
00593 void IncrementEventPriorityFlag();
00594
00599 void DecrementEventPriorityFlag();
00600
00601 private:
00602
00603 TUid iAppUid;
00604
00605 CDownloadArray* iDownloadArray;
00606
00607 CDownloadMgrObserver* iObservers;
00608
00609 CArrayPtrFlat< CDefaultAttrib >* iDefaultAttribs;
00610
00611 CDownloadMgrHandler* iManagerHandler;
00612
00613 CRHttpDownloadMgrExtension* iExtension;
00614
00615 public:
00616
00617 friend class RHttpDownload;
00618 friend class CDownloadMgrHandler;
00619 friend class CTransactionObserver;
00620 friend class CCodObserver;
00621 };
00622
00629 NONSHARABLE_CLASS( RHttpDownload ): public RSubSessionBase
00630 {
00631 public:
00635 enum TCodProgressState
00636 {
00637 ENotActive,
00638 EPaused,
00639 EInProgress
00640 };
00641 private:
00642
00646 RHttpDownload( RHttpDownloadMgr* aServer );
00647
00648 public:
00649
00655 IMPORT_C TInt Start();
00656
00662 IMPORT_C TInt Pause();
00663
00669 IMPORT_C TInt Reset();
00670
00676 IMPORT_C TInt Delete();
00677
00683 IMPORT_C TInt Move();
00684
00691 IMPORT_C TInt GetIntAttribute( const TUint aAttribute, TInt32& aValue );
00692
00699 IMPORT_C TInt GetBoolAttribute( const TUint aAttribute, TBool& aValue );
00700
00707 IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes16& aValue );
00708
00715 IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes8& aValue );
00716
00721 IMPORT_C TInt GetFileHandleAttribute( RFile& aFile );
00722
00729 IMPORT_C TInt SetIntAttribute( const TUint aAttribute, TInt32 aValue );
00730
00737 IMPORT_C TInt SetBoolAttribute( const TUint aAttribute, TBool aValue );
00738
00745 IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC16& aValue );
00746
00753 IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC8& aValue );
00754
00761 IMPORT_C TInt SetFileHandleAttribute( RFile& aFile );
00769 IMPORT_C TInt GetIntAttribute( const TUint aAttribute, const TInt32& aMoIndex, TInt32& aValue );
00770
00778 IMPORT_C TInt GetBoolAttribute( const TUint aAttribute, const TInt32& aMoIndex, TBool& aValue );
00779
00787 IMPORT_C TInt GetStringAttribute( const TUint aAttribute, const TInt32& aMoIndex, TDes16& aValue );
00788
00796 IMPORT_C TInt GetStringAttribute( const TUint aAttribute, const TInt32& aMoIndex, TDes8& aValue );
00797
00805 IMPORT_C TInt SetStringAttribute(const TUint aAttribute, const TInt32& aMoIndex, const TDesC16& aValue );
00806
00813 IMPORT_C TInt SetDownloadDataAttribute( const TDesC8& aValue );
00814
00821 IMPORT_C TInt SetTrackDataAttribute( const TInt aIndex, const TDesC8& aValue );
00822
00823 public:
00824
00830 void Close();
00831
00832
00838 TBool IsClosed()
00839 {
00840 return iClosed;
00841 }
00842
00848 void ResumeCodDownloadL() ;
00849
00855 TInt GetProductDownloadedSize();
00856
00857 private:
00858
00864 void CloseSubSession();
00865
00871 void SaveDownloadInfoL();
00872
00878 void CreateL( const TDesC8& aUrl, const TPtr8 aPackedAttribs );
00879
00885 void AttachL( TInt aHandle );
00886
00895 void StartEventNotification( TDes8& aDownloadState,
00896 TDes8& aProgressState,
00897 TDes8& aEventAttrib,
00898 TRequestStatus& aStatus );
00899
00905 void CancelEventNotification();
00906
00912 TBool IsDownload( TInt aHandle );
00913
00921 TBool IsDownloadL( const TUriParser8& aParsedReqUrl,
00922 const TDesC8& aMsgBody );
00923
00929 void SetDefaultAttributesL( const TDesC8& aPackedAttribs );
00930
00936 void BufferAttributesL();
00937
00943 void SetEventType( THttpDownloadState aEventType );
00944
00950 void SetHttpTransactionL( TInt aHttpTransaction );
00951
00957 void DeleteTransaction();
00958
00968 void InitCodDownloadL( const TDesC8& aBuf,
00969 const TDesC8& aMimeType,
00970 CEikonEnv* aEikEnv );
00971
00977 void InitPausedCodDownloadL( const TUid aAppUid );
00978
00983 void DoStartCodL();
00984
00992 TBool CheckContentTypeAndCreateCodDownloadL();
00993
01000 TInt SetOnError( TInt aError,
01001 THttpDownloadMgrError aDlError = EGeneral );
01002
01003 #ifdef DEAD_CODE
01004
01008 HBufC8* AllocEventAttribBufL();
01009 #endif
01010
01016 void UnpackEventAttribL( const TDesC8& aPack );
01017
01023 TBool IsClientSideDownload() const;
01024
01030 TBool IsToBeDeleted();
01031
01037 void DoStartL();
01038
01043 TInt EventPriorityFlag() const;
01044
01049 TBool IsDeleteCodWhenDone() const;
01050
01055 void SetCodInProgress( TCodProgressState aVal );
01056
01062 void AttachToDownloadL( const TInt32 aDlId );
01063
01068 TInt32 ActiveMoIndex() const;
01069
01074 void StopWaitingAS();
01075
01076 private:
01077
01078 CDownloadMgrHandler* iDownloadHandler;
01079
01080 RHttpDownloadMgr* iDownloadMgr;
01081
01082 TInt iHandle;
01083
01084 CRHttpDownloadExtension* iExtension;
01085
01086 CTransactionObserver* iTransactionObserver;
01087 RHTTPTransaction* iHttpTransaction;
01088
01089 CCodDownload* iCodDownload;
01090
01091 CCodObserver* iCodObserver;
01092
01093 TBool iClientSideDownload;
01094
01095 TBool iClosed;
01096
01097 TBool iClosedSubSession;
01098
01099 CRHttpDlExtension* iDlExtension;
01100
01101 CActiveSchedulerWait* iWait;
01102
01103
01104 TBool iASReady;
01105
01106 public:
01107
01108 friend class CDownloadMgrHandler;
01109 friend class RHttpDownloadMgr;
01110 friend class RHttpDownloadMgrApiExt;
01111 friend class CTransactionObserver;
01112 friend class CCodObserver;
01113 friend class CDownloadMgrHandler;
01114
01115 };
01116
01117 #endif
01118