S60 3rd Edition API Reference: downloadmgrclient.h Source File

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 
00419 
00420     private:  // New functions
00421 
00427         void RemoveFromArray( RHttpDownload* aElement );
00428 
00435         TInt FindInArray( RHttpDownload* aElement, TInt& aIndex ) const;
00436 
00442         RHttpDownload& DownloadFromHandleL( TUint aHandle );
00443 
00450         TInt FindObserver( MHttpDownloadMgrObserver& aObserver, TInt& aIndex ) const;
00451 
00457         void AttachL( TDes8& aBuf );
00458 
00464         void CloseDownload( RHttpDownload* aElement );
00465 
00471         HBufC8* PackedDefaultAttributesLC();
00472 
00479         void DoSetDefaultAttributeL( const TUint aAttribute, TInt32 aValue );
00480 
00487         void DoSetDefaultAttributeL( const TUint aAttribute, TBool aValue );
00488 
00495         void DoSetDefaultAttributeL( const TUint aAttribute, const TDesC8& aValue );
00496 
00503         void DoSetDefaultAttributeL( const TUint aAttribute, const TDesC16& aValue );
00504 
00510         void StartSessionEventNotification( const TDesC8& aDownloadState,
00511                                             const TDesC8& aProgressState,
00512                                             const TDesC8& aHandle,
00513                                             TRequestStatus& aStatus );
00514 
00520         void CancelSessionEventNotification();
00521         
00525         RHttpDownload* DoFindDownloadL( const TDesC8& aUrl, const TDesC8& aMsgBody );
00526         
00532         TInt NumberOfClientSideDownload( TInt32& aValue );
00533         
00539         TBool IsEventBroadcasting();
00540         
00547         void DoHandleSessionEventL( TInt aHandle, THttpDownloadEvent aEvent );
00548 
00555         void BroadcastEvent( RHttpDownload& aDownload, 
00556                              THttpDownloadEvent aEvent );
00557 
00562         MHttpDownloadMgrNextUriObserver* NextUriObserver() const;
00563         
00568         TInt SessionId() const;
00569 
00575 //        void BroadcastDeleting( RHttpDownload& aDownload );
00576         
00581         TInt EventPriorityFlag() const;
00582         
00587         void IncrementEventPriorityFlag();
00588         
00593         void DecrementEventPriorityFlag();        
00594                              
00595     private:     // Data
00596         // The client application UID.
00597         TUid                             iAppUid;
00598         // List of downloads.
00599         CDownloadArray*                  iDownloadArray;  
00600         // List of observers.
00601         CDownloadMgrObserver*            iObservers;      
00602         // Default attributes.
00603         CArrayPtrFlat< CDefaultAttrib >* iDefaultAttribs; 
00604         // Moved event handler
00605         CDownloadMgrHandler*             iManagerHandler; 
00606         // Extension class
00607         CRHttpDownloadMgrExtension*      iExtension;      
00608 
00609     public:     // Friend classes
00610 
00611         friend class RHttpDownload;
00612         friend class CDownloadMgrHandler;
00613         friend class CTransactionObserver;
00614         friend class CCodObserver;        
00615         };
00616 
00623 NONSHARABLE_CLASS( RHttpDownload ): public RSubSessionBase
00624         {
00625     private:
00626 
00630         RHttpDownload( RHttpDownloadMgr* aServer );
00631 
00632     public:  // New functions
00633 
00639         IMPORT_C TInt Start();
00640 
00646         IMPORT_C TInt Pause();
00647 
00653         IMPORT_C TInt Reset();
00654 
00660         IMPORT_C TInt Delete();
00661 
00667         IMPORT_C TInt Move();
00668 
00675                 IMPORT_C TInt GetIntAttribute( const TUint aAttribute, TInt32& aValue );
00676 
00683                 IMPORT_C TInt GetBoolAttribute( const TUint aAttribute, TBool& aValue );
00684 
00691                 IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes16& aValue  );
00692 
00699         IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes8& aValue  );
00700 
00705         IMPORT_C TInt GetFileHandleAttribute( RFile& aFile );
00706         
00713                 IMPORT_C TInt SetIntAttribute( const TUint aAttribute, TInt32 aValue );
00714 
00721                 IMPORT_C TInt SetBoolAttribute( const TUint aAttribute, TBool aValue );
00722 
00729                 IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC16& aValue );
00730 
00737         IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC8& aValue );
00738 
00745         IMPORT_C TInt SetFileHandleAttribute( RFile& aFile );
00746 
00747     public: // New functions
00748 
00754         void Close();
00755 
00756     private: // New functions
00757 
00763         void CreateL( const TDesC8& aUrl, const TPtr8 aPackedAttribs );
00764 
00770         void AttachL( TInt aHandle );
00771 
00780         void StartEventNotification( TDes8& aDownloadState,
00781                                      TDes8& aProgressState,
00782                                      TDes8& aEventAttrib,                                     
00783                                      TRequestStatus& aStatus );
00784 
00790         void CancelEventNotification();
00791 
00797         TBool IsDownload( TInt aHandle );
00798         
00806         TBool IsDownloadL( const TUriParser8& aParsedReqUrl, 
00807                            const TDesC8& aMsgBody );
00808 
00814         void SetDefaultAttributesL( const TDesC8& aPackedAttribs );
00815 
00821         void BufferAttributesL();
00822 
00828         void SetEventType( THttpDownloadState aEventType );
00829 
00835         void SetHttpTransactionL( TInt aHttpTransaction );
00836 
00842         void DeleteTransaction();
00843         
00853         void InitCodDownloadL( const TDesC8& aBuf, 
00854                                const TDesC8& aMimeType,
00855                                CEikonEnv* aEikEnv );
00856 
00861         void DoStartCodL();
00862         
00870         TBool CheckContentTypeAndCreateCodDownloadL();
00871 
00878         TInt SetOnError( TInt aError,
00879                          THttpDownloadMgrError aDlError = EGeneral ); 
00880 
00885         HBufC8* AllocEventAttribBufL();
00886         
00892         void UnpackEventAttribL( const TDesC8& aPack );
00893 
00899         TBool IsClientSideDownload() const;
00900         
00906         TBool IsToBeDeleted();
00907         
00913         void DoStartL(); 
00914         
00919         TInt EventPriorityFlag() const;
00920         
00925         TBool IsDeleteCodWhenDone() const;
00926         
00931         void SetCodInProgress( TBool aVal ); 
00932 
00938         void AttachToDownloadL( const TInt32 aDlId );
00939 
00945         void SetCloseIndicator( TBool* aClose );
00946 
00947     private:    // Data
00948         // Event notification handler.
00949         CDownloadMgrHandler*     iDownloadHandler;  
00950         // Download manager session.
00951         RHttpDownloadMgr*        iDownloadMgr;      
00952         // Unique identifier of server side subsession.
00953         TInt                     iHandle;
00954         // Extension class
00955         CRHttpDownloadExtension* iExtension;        
00956 
00957         CTransactionObserver*    iTransactionObserver;
00958         RHTTPTransaction*        iHttpTransaction;
00959         // Descriptor Based download COD/DD
00960         CCodDownload*            iCodDownload;      
00961         // Cod observer
00962         CCodObserver*            iCodObserver;    
00963         // Client Side Download
00964         TBool                    iClientSideDownload;
00965         
00966     public:     // Friend classes
00967  
00968         friend class CDownloadMgrHandler;
00969         friend class RHttpDownloadMgr;
00970         friend class CTransactionObserver;
00971         friend class CCodObserver;
00972         friend class CDownloadMgrHandler;
00973 
00974         };
00975 
00976 #endif /* __DOWNLOADMGR_CLIENT_H__ */
00977 

Copyright © Nokia Corporation 2001-2007
Back to top