downloadmgrclient.h

Go to the documentation of this file.
00001 /*
00002 * ==============================================================================
00003 *  Name        : DownloadMgrClient.h
00004 *  Part of     : DownloadMgrClntSrv / DownloadMgr
00005 *  Interface   : ?Interface_category, ?Interface_name
00006 *  Description : This file contains the definition of the Client interface of Download Mgr Server.
00007 *  Version     : ?Version
00008 *
00009 *  Copyright © 2002-2004 Nokia. All rights reserved.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia. All rights are reserved. Copying, including 
00013 *  reproducing, storing, adapting or translating, any 
00014 *  or all of this material requires the prior written consent of 
00015 *  Nokia. This material also contains confidential 
00016 *  information which may not be disclosed to others without the 
00017 *  prior written consent of Nokia.
00018 * ==============================================================================
00019 */
00020 
00021 #ifndef __DOWNLOADMGR_CLIENT_H__
00022 #define __DOWNLOADMGR_CLIENT_H__
00023 
00024 //  INCLUDES
00025 #include <e32base.h>
00026 #include <f32file.h>
00027 #include <HttpDownloadMgrCommon.h>
00028 #include <http.h>
00029 
00030 // DATA TYPES
00031 
00032 // FORWARD DECLARATIONS
00033 class CDownloadMgrHandler;
00034 class RHttpDownload;
00035 class MHttpDownloadMgrObserver;
00036 class CDefaultAttrib;
00037 class CRHttpDownloadExtension;
00038 class CRHttpDownloadMgrExtension;
00039 class CEikonEnv;
00040 class CTransactionObserver;
00041 class THttpTransactionCallback;
00042 class CCodDownload;
00043 class CCodObserver;
00044 
00051 void HashL( const TDesC8& aMessage, TDes8& aHash );
00052 
00053 // TYPEDEFS
00054 typedef CArrayPtrFlat< RHttpDownload > CDownloadArray;
00055 typedef CArrayPtrFlat< MHttpDownloadMgrObserver >  CDownloadMgrObserver;
00056 
00057 // CLASS DECLARATION
00058 
00065 NONSHARABLE_CLASS( THttpDownloadEvent )
00066     {
00067     public: // Data
00068         // download state
00069         THttpDownloadState iDownloadState;
00070         // download progress state
00071         THttpProgressState iProgressState;
00072     };
00073 
00081 class MHttpDownloadMgrObserver
00082     {
00083 
00084     public:
00085 
00092         virtual void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent ) = 0;
00093     };
00094 
00102 class MHttpDownloadMgrNextUriObserver
00103     {
00104 
00105     public:
00106 
00113         virtual void NextUriL( RHttpDownload& aDownload, const TDesC8& aUri ) = 0;
00114     };
00115 
00122 NONSHARABLE_CLASS( RHttpDownloadMgr ) : public RSessionBase,
00123                                         public MHttpDownloadMgrObserver
00124         {
00125     public:
00129         IMPORT_C RHttpDownloadMgr();
00130 
00131     public:  // New functions
00132 
00141         IMPORT_C void ConnectL( TUid aAppUid,
00142                                 MHttpDownloadMgrObserver& aObserver,
00143                                 TBool aMaster );
00144 
00150         IMPORT_C TVersion Version() const;
00151 
00157         IMPORT_C void Close();
00158 
00164         IMPORT_C const CDownloadArray& CurrentDownloads() const;
00165 
00173         IMPORT_C RHttpDownload& CreateDownloadL( const TDesC8& aUrl, TBool& aResult );
00174 
00182         IMPORT_C RHttpDownload& CreateDownloadL( const TDesC8& aUrl );
00183 
00190         IMPORT_C RHttpDownload& CreateClientSideDownloadL( TInt aHttpTransaction,TBool& aResult );
00191 
00203         IMPORT_C RHttpDownload& CreateCodDownloadL( const TDesC8& aUrl,
00204                                                     const TDesC8& aBuf,
00205                                                     const TDesC8& aMimeType,
00206                                                     CEikonEnv* aEikEnv,
00207                                                     TBool& aResult );
00208 
00217         IMPORT_C RHttpDownload* FindDownload( const TDesC8& aUrl, const TDesC8& aMsgBody );
00218 
00224         IMPORT_C TInt PauseAll();
00225 
00231         IMPORT_C TInt StartAll();
00232 
00238         IMPORT_C TInt ResetAll();
00239 
00245         IMPORT_C TInt DeleteAll();
00246 
00252         IMPORT_C TInt Disconnect();
00253 
00260                 IMPORT_C TInt GetIntAttribute( const TUint aAttribute, TInt32& aValue );
00261 
00268                 IMPORT_C TInt GetBoolAttribute( const TUint aAttribute, TBool& aValue );
00269 
00276                 IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes16& aValue  );
00277 
00284         IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes8& aValue  );
00285 
00292                 IMPORT_C TInt SetIntAttribute( const TUint aAttribute, TInt32 aValue );
00293 
00300                 IMPORT_C TInt SetBoolAttribute( const TUint aAttribute, TBool aValue );
00301 
00308                 IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC16& aValue );
00309 
00316         IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC8& aValue );
00317 
00324                 IMPORT_C TInt SetDefaultIntAttribute( const TUint aAttribute, TInt32 aValue );
00325 
00332                 IMPORT_C TInt SetDefaultBoolAttribute( const TUint aAttribute, TBool aValue );
00333 
00340                 IMPORT_C TInt SetDefaultStringAttribute( const TUint aAttribute, const TDesC16& aValue );
00341 
00348         IMPORT_C TInt SetDefaultStringAttribute( const TUint aAttribute, const TDesC8& aValue );
00349 
00355         IMPORT_C void AddObserverL( MHttpDownloadMgrObserver& aObserver );
00356 
00362         IMPORT_C void RemoveObserver( MHttpDownloadMgrObserver& aObserver );
00363         
00369         IMPORT_C void SetNextUriObserver( MHttpDownloadMgrNextUriObserver* aObserver );
00370 
00371     protected: // from MHttpDownloadMgrObserver
00372 
00379         void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent );
00380 
00381     private:
00382 
00389         void HandleSessionEventL( TInt aHandle, THttpDownloadEvent aEvent );
00390 
00391     private:  // New functions
00392 
00401         void DoConnectL( TUid aAppUid,
00402                          MHttpDownloadMgrObserver& aObserver,
00403                          TBool aMaster );
00404 
00413         void InitializeL( TUid aAppUid,
00414                           MHttpDownloadMgrObserver& aObserver,
00415                           TBool aMaster );
00416 
00417     protected: // New functions
00418 
00425         RHttpDownload& AddToArrayL( RHttpDownload* aElement );
00426 
00427     private:  // New functions
00428 
00434         void RemoveFromArray( RHttpDownload* aElement );
00435 
00442         TInt FindInArray( RHttpDownload* aElement, TInt& aIndex ) const;
00443 
00449         RHttpDownload& DownloadFromHandleL( TUint aHandle );
00450 
00457         TInt FindObserver( MHttpDownloadMgrObserver& aObserver, TInt& aIndex ) const;
00458 
00464         void AttachL( TDes8& aBuf );
00465 
00471         void CloseDownload( RHttpDownload* aElement );
00472 
00478         HBufC8* PackedDefaultAttributesLC();
00479 
00486         void DoSetDefaultAttributeL( const TUint aAttribute, TInt32 aValue );
00487 
00494         void DoSetDefaultAttributeL( const TUint aAttribute, TBool aValue );
00495 
00502         void DoSetDefaultAttributeL( const TUint aAttribute, const TDesC8& aValue );
00503 
00510         void DoSetDefaultAttributeL( const TUint aAttribute, const TDesC16& aValue );
00511 
00517         void StartSessionEventNotification( const TDesC8& aDownloadState,
00518                                             const TDesC8& aProgressState,
00519                                             const TDesC8& aHandle,
00520                                             TRequestStatus& aStatus );
00521 
00527         void CancelSessionEventNotification();
00528         
00532         RHttpDownload* DoFindDownloadL( const TDesC8& aUrl, const TDesC8& aMsgBody );
00533         
00539         TInt NumberOfClientSideDownload( TInt32& aValue );
00540         
00546         TBool IsEventBroadcasting();
00547         
00554         void DoHandleSessionEventL( TInt aHandle, THttpDownloadEvent aEvent );
00555 
00562         void BroadcastEvent( RHttpDownload& aDownload, 
00563                              THttpDownloadEvent aEvent );
00564 
00569         MHttpDownloadMgrNextUriObserver* NextUriObserver() const;
00570         
00575         TInt SessionId() const;
00576 
00582 //        void BroadcastDeleting( RHttpDownload& aDownload );
00583         
00588         TInt EventPriorityFlag() const;
00589         
00594         void IncrementEventPriorityFlag();
00595         
00600         void DecrementEventPriorityFlag();        
00601                              
00602     private:     // Data
00603         // The client application UID.
00604         TUid                             iAppUid;
00605         // List of downloads.
00606         CDownloadArray*                  iDownloadArray;  
00607         // List of observers.
00608         CDownloadMgrObserver*            iObservers;      
00609         // Default attributes.
00610         CArrayPtrFlat< CDefaultAttrib >* iDefaultAttribs; 
00611         // Moved event handler
00612         CDownloadMgrHandler*             iManagerHandler; 
00613         // Extension class
00614         CRHttpDownloadMgrExtension*      iExtension;      
00615 
00616     public:     // Friend classes
00617 
00618         friend class RHttpDownload;
00619         friend class CDownloadMgrHandler;
00620         friend class CTransactionObserver;
00621         friend class CCodObserver;        
00622         };
00623 
00630 NONSHARABLE_CLASS( RHttpDownload ): public RSubSessionBase
00631         {
00632     private:
00633 
00637         RHttpDownload( RHttpDownloadMgr* aServer );
00638 
00639     public:  // New functions
00640 
00646         IMPORT_C TInt Start();
00647 
00653         IMPORT_C TInt Pause();
00654 
00660         IMPORT_C TInt Reset();
00661 
00667         IMPORT_C TInt Delete();
00668 
00674         IMPORT_C TInt Move();
00675 
00682                 IMPORT_C TInt GetIntAttribute( const TUint aAttribute, TInt32& aValue );
00683 
00690                 IMPORT_C TInt GetBoolAttribute( const TUint aAttribute, TBool& aValue );
00691 
00698                 IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes16& aValue  );
00699 
00706         IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes8& aValue  );
00707 
00712         IMPORT_C TInt GetFileHandleAttribute( RFile& aFile );
00713         
00720                 IMPORT_C TInt SetIntAttribute( const TUint aAttribute, TInt32 aValue );
00721 
00728                 IMPORT_C TInt SetBoolAttribute( const TUint aAttribute, TBool aValue );
00729 
00736                 IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC16& aValue );
00737 
00744         IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC8& aValue );
00745 
00752         IMPORT_C TInt SetFileHandleAttribute( RFile& aFile );
00753 
00754     public: // New functions
00755 
00761         void Close();
00762         
00763 
00769         TBool IsClosed()
00770         {
00771             return iClosed;
00772         }
00773 
00774     private: // New functions
00775 
00781         void CreateL( const TDesC8& aUrl, const TPtr8 aPackedAttribs );
00782 
00788         void AttachL( TInt aHandle );
00789 
00798         void StartEventNotification( TDes8& aDownloadState,
00799                                      TDes8& aProgressState,
00800                                      TDes8& aEventAttrib,                                     
00801                                      TRequestStatus& aStatus );
00802 
00808         void CancelEventNotification();
00809 
00815         TBool IsDownload( TInt aHandle );
00816         
00824         TBool IsDownloadL( const TUriParser8& aParsedReqUrl, 
00825                            const TDesC8& aMsgBody );
00826 
00832         void SetDefaultAttributesL( const TDesC8& aPackedAttribs );
00833 
00839         void BufferAttributesL();
00840 
00846         void SetEventType( THttpDownloadState aEventType );
00847 
00853         void SetHttpTransactionL( TInt aHttpTransaction );
00854 
00860         void DeleteTransaction();
00861         
00871         void InitCodDownloadL( const TDesC8& aBuf, 
00872                                const TDesC8& aMimeType,
00873                                CEikonEnv* aEikEnv );
00874 
00879         void DoStartCodL();
00880         
00888         TBool CheckContentTypeAndCreateCodDownloadL();
00889 
00896         TInt SetOnError( TInt aError,
00897                          THttpDownloadMgrError aDlError = EGeneral ); 
00898 
00899 #ifdef DEAD_CODE
00900 
00904         HBufC8* AllocEventAttribBufL();
00905 #endif
00906         
00912         void UnpackEventAttribL( const TDesC8& aPack );
00913 
00919         TBool IsClientSideDownload() const;
00920         
00926         TBool IsToBeDeleted();
00927         
00933         void DoStartL(); 
00934         
00939         TInt EventPriorityFlag() const;
00940         
00945         TBool IsDeleteCodWhenDone() const;
00946         
00951         void SetCodInProgress( TBool aVal ); 
00952 
00958         void AttachToDownloadL( const TInt32 aDlId );
00959 
00960     private:    // Data
00961         // Event notification handler.
00962         CDownloadMgrHandler*     iDownloadHandler;  
00963         // Download manager session.
00964         RHttpDownloadMgr*        iDownloadMgr;      
00965         // Unique identifier of server side subsession.
00966         TInt                     iHandle;
00967         // Extension class
00968         CRHttpDownloadExtension* iExtension;        
00969 
00970         CTransactionObserver*    iTransactionObserver;
00971         RHTTPTransaction*        iHttpTransaction;
00972         // Descriptor Based download COD/DD
00973         CCodDownload*            iCodDownload;      
00974         // Cod observer
00975         CCodObserver*            iCodObserver;    
00976         // Client Side Download
00977         TBool                    iClientSideDownload;
00978         // Boolean flag which indicates download closure
00979         TBool                    iClosed;
00980         
00981     public:     // Friend classes
00982  
00983         friend class CDownloadMgrHandler;
00984         friend class RHttpDownloadMgr;
00985         friend class RHttpDownloadMgrApiExt;
00986         friend class CTransactionObserver;
00987         friend class CCodObserver;
00988         friend class CDownloadMgrHandler;
00989 
00990         };
00991 
00992 #endif /* __DOWNLOADMGR_CLIENT_H__ */
00993 

Copyright © Nokia Corporation 2001-2008
Back to top