epoc32/include/mw/downloadmgrclient.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 /*
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:  This file contains the definition of the Client interface of Download Mgr Server.
    15 *
    16 */
    17 
    18 
    19 #ifndef __DOWNLOADMGR_CLIENT_H__
    20 #define __DOWNLOADMGR_CLIENT_H__
    21 
    22 //  INCLUDES
    23 #include <e32base.h>
    24 #include <f32file.h>
    25 #include <HttpDownloadMgrCommon.h>
    26 #include <http.h>
    27 
    28 // FORWARD DECLARATIONS
    29 class CDownloadMgrHandler;
    30 class RHttpDownload;
    31 class MHttpDownloadMgrObserver;
    32 class CDefaultAttrib;
    33 class CRHttpDownloadExtension;
    34 class CRHttpDownloadMgrExtension;
    35 class CRHttpDlExtension;
    36 class CEikonEnv;
    37 class CTransactionObserver;
    38 class THttpTransactionCallback;
    39 class CCodDownload;
    40 class CCodObserver;
    41 
    42 /**
    43 * Calculate a hash and in the form of a 32 character hex result.
    44 * @param aMessage Source.
    45 * @param aHash Hash value.
    46 * @return None.        
    47 */
    48 void HashL( const TDesC8& aMessage, TDes8& aHash );
    49 
    50 // TYPEDEFS
    51 typedef CArrayPtrFlat< RHttpDownload > CDownloadArray;
    52 typedef CArrayPtrFlat< MHttpDownloadMgrObserver >  CDownloadMgrObserver;
    53 
    54 // CLASS DECLARATION
    55 
    56 /**
    57 *  Contains download states
    58 *
    59 *  @lib -
    60 *  @since Series 60 2.8
    61 */
    62 NONSHARABLE_CLASS( THttpDownloadEvent )
    63     {
    64     public: // Data
    65         // download state
    66         THttpDownloadState iDownloadState;
    67         // download progress state
    68         THttpProgressState iProgressState;
    69     };
    70 
    71 /**
    72 *  Provides the interface for notification of events from a Download Manager 
    73 *  session and its subsessions.
    74 *
    75 *  @lib -
    76 *  @since Series 60 2.8
    77 */
    78 class MHttpDownloadMgrObserver
    79     {
    80 
    81     public:
    82 
    83         /**
    84         * Indicates an event.
    85         * @param aDownload The download with which the event occured.
    86         * @param aEvent Event type.
    87         * @return None.
    88         */
    89         virtual void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent ) = 0;
    90     };
    91 
    92 /**
    93 *  Provides the interface for sending next uri to 
    94 *  the client when downloading OMA or COD.
    95 *
    96 *  @lib -
    97 *  @since Series 60 3.0
    98 */
    99 class MHttpDownloadMgrNextUriObserver
   100     {
   101 
   102     public:
   103 
   104         /**
   105         * Send next uri to the client. The client can then handle it.
   106         * @param aDownload Reference to the download.
   107         * @param aUri Next URI of the OMA or COD download.
   108         * @return None.
   109         */
   110         virtual void NextUriL( RHttpDownload& aDownload, const TDesC8& aUri ) = 0;
   111     };
   112 
   113 /**
   114 *  Creates a download manager session and performs operations on it 
   115 *
   116 *  @lib -
   117 *  @since Series 60 2.8
   118 */
   119 NONSHARABLE_CLASS( RHttpDownloadMgr ) : public RSessionBase,
   120                                         public MHttpDownloadMgrObserver
   121 	{
   122     public:
   123         /**
   124         * C++ default constructor.
   125         */
   126         IMPORT_C RHttpDownloadMgr();
   127 
   128     public:  // New functions
   129 
   130         /**
   131         * Creates a download manager session.
   132         * @param aAppUid Client application's UID.
   133         * @param aObserver Observer
   134         * @param aMaster Indicates whether (if ETrue) this instance 
   135         * inherints all downloads of other instances. (stand-alone app flag).
   136         * @return None.
   137         */
   138         IMPORT_C void ConnectL( TUid aAppUid,
   139                                 MHttpDownloadMgrObserver& aObserver,
   140                                 TBool aMaster );
   141 
   142         /**
   143         * Gives version information.
   144         * @param -
   145         * @return TVersion Contains version information.
   146         */
   147         IMPORT_C TVersion Version() const;
   148 
   149         /**
   150         * Closes download manager session.
   151         * @param -
   152         * @return None.
   153         */
   154         IMPORT_C void Close();
   155 
   156         /**
   157         * Returns a list of the current downloads.
   158         * @param -
   159         * @return CDownloadArray
   160         */
   161         IMPORT_C const CDownloadArray& CurrentDownloads() const;
   162 
   163         /**
   164         * Creates a new download subsession.
   165         * @param aUrl The url to be downloaded.
   166         * @param aResult The result is true if the download is created.
   167         * If the URL is already being downloaded the seult is false.
   168         * @return RHttpDownload&
   169         */
   170         IMPORT_C RHttpDownload& CreateDownloadL( const TDesC8& aUrl, TBool& aResult );
   171 
   172         /**
   173         * Creates a new download subsession. It creates a new one even
   174         * if the URL is already beeing downloaded.
   175         * @param aUrl The url to be downloaded.
   176         * If the URL is already being downloaded the seult is false.
   177         * @return RHttpDownload&
   178         */
   179         IMPORT_C RHttpDownload& CreateDownloadL( const TDesC8& aUrl );
   180 
   181         /**
   182         * Creates a new download in client side.
   183         * @param aHttpTransaction http transaction.
   184         * @param aResult The result is true if the download is created.
   185         * If the URL is already being downloaded the seult is false.        
   186         */
   187         IMPORT_C RHttpDownload& CreateClientSideDownloadL( TInt aHttpTransaction,TBool& aResult );
   188 
   189         /**
   190         * Creates a new download subsession for COD.
   191         * @param aUrl The url from the COD is downloaded.
   192         * @param aBuf The COD descriptor.
   193         * @param aMimeType The mimetype.
   194         * @param aEikEnv Eikon environment or NULL. Can be NULL if download
   195         * does not require UI functionality.        
   196         * @param aResult The result is true if the download is created.       
   197         * If the URL is already being downloaded the seult is false.
   198         * @return RHttpDownload&
   199         */
   200         IMPORT_C RHttpDownload& CreateCodDownloadL( const TDesC8& aUrl,
   201                                                     const TDesC8& aBuf,
   202                                                     const TDesC8& aMimeType,
   203                                                     CEikonEnv* aEikEnv,
   204                                                     TBool& aResult );
   205 
   206         /**
   207         * Finds if the download is already created
   208         * @since 2.8
   209         * @param aUrl given URL
   210         * @param aMsgBody Message body from post operation
   211         * @return Returns a pointer to the found download or null.
   212         *         This pointer is NOT owned by the client!
   213         */        
   214         IMPORT_C RHttpDownload* FindDownload( const TDesC8& aUrl, const TDesC8& aMsgBody );
   215 
   216         /**
   217         * Pauses all downloads.
   218         * @param -
   219         * @return None.
   220         */
   221         IMPORT_C TInt PauseAll();
   222 
   223         /**
   224         * Resumes all downloads.
   225         * @param -
   226         * @return None.
   227         */
   228         IMPORT_C TInt StartAll();
   229 
   230         /**
   231         * Resets all downloads.
   232         * @param -
   233         * @return None.
   234         */
   235         IMPORT_C TInt ResetAll();
   236 
   237         /**
   238         * Deletes all downloads.
   239         * @param -
   240         * @return None.
   241         */
   242         IMPORT_C TInt DeleteAll();
   243 
   244         /**
   245         * Disconnect the http connection and pauses all downloads.
   246         * @param -
   247         * @return None.
   248         */
   249         IMPORT_C TInt Disconnect();
   250 
   251 		/**
   252 		* Gets the value for a TInt attribute.
   253 		* @param aAttribute Identifies the attribute to be retrived.
   254 		* @param aValue On completion, contains the requested TInt attribute.
   255         * @return None.
   256 		*/
   257 		IMPORT_C TInt GetIntAttribute( const TUint aAttribute, TInt32& aValue );
   258 
   259 		/**
   260 		* Gets the value for a TBool attribute.
   261 		* @param aAttribute Identifies the attribute to be retrived.
   262 		* @param aValue On completion, contains the requested TBool attribute.
   263         * @return None.
   264 		*/
   265 		IMPORT_C TInt GetBoolAttribute( const TUint aAttribute, TBool& aValue );
   266 
   267 		/**
   268 		* Gets the value for a TDes16 attribute.
   269 		* @param aAttribute Identifies the attribute to be retrived.
   270 		* @param aValue On completion, contains the requested TDes16 attribute.
   271         * @return None.
   272 		*/
   273 		IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes16& aValue  );
   274 
   275 		/**
   276 		* Gets the value for a TDes8 attribute.
   277 		* @param aAttribute Identifies the attribute to be retrived.
   278 		* @param aValue On completion, contains the requested TDes8 attribute.
   279         * @return None.
   280 		*/
   281         IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes8& aValue  );
   282 
   283 		/**
   284 		* Sets the value for a TInt attribute.
   285 		* @param aAttribute Identifies the attribute to be set.
   286 		* @param aValue The value to be set.
   287         * @return None.
   288 		*/
   289 		IMPORT_C TInt SetIntAttribute( const TUint aAttribute, TInt32 aValue );
   290 
   291 		/**
   292 		* Sets the value for a TBool attribute.
   293 		* @param aAttribute Identifies the attribute to be set.
   294 		* @param aValue The value to be set.
   295         * @return None.
   296 		*/
   297 		IMPORT_C TInt SetBoolAttribute( const TUint aAttribute, TBool aValue );
   298 
   299 		/**
   300 		* Sets the value for a TDesC attribute.
   301 		* @param aAttribute Identifies the attribute to be set.
   302 		* @param aValue The value to be set.
   303         * @return None.
   304 		*/
   305 		IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC16& aValue );
   306 
   307 		/**
   308 		* Sets the value for a TDesC8 attribute.
   309 		* @param aAttribute Identifies the attribute to be set.
   310 		* @param aValue The value to be set.
   311         * @return None.
   312 		*/
   313         IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC8& aValue );
   314 
   315 		/**
   316 		* Sets the value for the default TInt attribute.
   317 		* @param aAttribute Identifies the attribute to be set.
   318 		* @param aValue The value to be set.
   319         * @return None.
   320 		*/
   321 		IMPORT_C TInt SetDefaultIntAttribute( const TUint aAttribute, TInt32 aValue );
   322 
   323 		/**
   324 		* Sets the value for the default TBool attribute.
   325 		* @param aAttribute Identifies the attribute to be set.
   326 		* @param aValue The value to be set.
   327         * @return None.
   328 		*/
   329 		IMPORT_C TInt SetDefaultBoolAttribute( const TUint aAttribute, TBool aValue );
   330 
   331 		/**
   332 		* Sets the value for the default TDesC attribute.
   333 		* @param aAttribute Identifies the attribute to be set.
   334 		* @param aValue The value to be set.
   335         * @return None.
   336 		*/
   337 		IMPORT_C TInt SetDefaultStringAttribute( const TUint aAttribute, const TDesC16& aValue );
   338 
   339 		/**
   340 		* Sets the value for the default TDesC8 attribute.
   341 		* @param aAttribute Identifies the attribute to be set.
   342 		* @param aValue The value to be set.
   343         * @return None.
   344 		*/
   345         IMPORT_C TInt SetDefaultStringAttribute( const TUint aAttribute, const TDesC8& aValue );
   346 
   347 		/**
   348 		* Adds client to the observer list.
   349 		* @param aObserver Observer.
   350         * @return None.
   351 		*/
   352         IMPORT_C void AddObserverL( MHttpDownloadMgrObserver& aObserver );
   353 
   354 		/**
   355 		* Removes client from the observer list.
   356 		* @param aObserver Observer.
   357         * @return None.
   358 		*/
   359         IMPORT_C void RemoveObserver( MHttpDownloadMgrObserver& aObserver );
   360         
   361 		/**
   362 		* Set next uri observer.
   363 		* @param aObserver Observer.
   364         * @return None.
   365 		*/        
   366         IMPORT_C void SetNextUriObserver( MHttpDownloadMgrNextUriObserver* aObserver );
   367 
   368     protected: // from MHttpDownloadMgrObserver
   369 
   370         /**
   371         * Indicates an event.
   372         * @param aDownload The download with which the event occured.
   373         * @param aEvent Event type.
   374         * @return None.
   375         */
   376         void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent );
   377 
   378     private:
   379 
   380         /**
   381         * Indicates the session's event.
   382         * @param aHandle Unique identifier of server side subsession.
   383         * @param aEvent Event type.
   384         * @return None.
   385         */
   386         void HandleSessionEventL( TInt aHandle, THttpDownloadEvent aEvent );
   387 
   388     private:  // New functions
   389 
   390         /**
   391         * Creates a download manager session.
   392         * @param aAppUid Client application's UID.
   393         * @param aObserver Observer
   394         * @param aMaster Indicates whether (if ETrue) this instance 
   395         * inherints all downloads of other instances. (stand-alone app flag).
   396         * @return None.
   397         */
   398         void DoConnectL( TUid aAppUid,
   399                          MHttpDownloadMgrObserver& aObserver,
   400                          TBool aMaster );
   401 
   402         /**
   403         * Initializes the download manager session.
   404         * @param aAppUid Client app's UID.
   405         * @param aObserver Observer to add to the observer list.
   406         * @param aMaster Indicates whether (if ETrue) this instance 
   407         * inherints all downloads of other instances. (stand-alone app flag).
   408         * @return None.
   409         */
   410         void InitializeL( TUid aAppUid,
   411                           MHttpDownloadMgrObserver& aObserver,
   412                           TBool aMaster );
   413 
   414     protected: // New functions
   415 
   416         /**
   417         * Adds the created download to the list. If it is already added, 
   418         * then it will do nothing.
   419         * @param aElement Download subsession.
   420         * @return RHttpDownload& reference to the added item in the list.
   421         */
   422         RHttpDownload& AddToArrayL( RHttpDownload* aElement );
   423 
   424     private:  // New functions
   425 
   426         /**
   427         * Removes the download from the list.
   428         * @param aElement Download subsession.
   429         * @return None.
   430         */
   431         void RemoveFromArray( RHttpDownload* aElement );
   432 
   433         /**
   434         * Finds the download in the list.
   435         * @param aElement Download subsession.
   436         * @param aIndex Index of the element found.
   437         * @return KErrNone if found, KErrNotFound otherwise..
   438         */
   439         TInt FindInArray( RHttpDownload* aElement, TInt& aIndex ) const;
   440 
   441         /**
   442         * Returns a reference to the download identified by a handle.
   443         * @param aHandle Handle identifier.
   444         * @return RHttpDownload&
   445         */
   446         RHttpDownload& DownloadFromHandleL( TUint aHandle );
   447 
   448         /**
   449         * Finds observer based on index.
   450         * @param aObserver Observer found.
   451         * @param aIndex Index.
   452         * @return TInt
   453         */
   454         TInt FindObserver( MHttpDownloadMgrObserver& aObserver, TInt& aIndex ) const;
   455 
   456         /**
   457         * Attach client to the session.
   458         * @param aBuf Buffer to the subsession IDs.
   459         * @return None.
   460         */
   461         void AttachL( TDes8& aBuf );
   462 
   463         /**
   464         * Close a download subsession.
   465         * @param aElement Download subsession.
   466         * @return None.
   467         */
   468         void CloseDownload( RHttpDownload* aElement );
   469 
   470 		/**
   471 		* Packes the default values of the attributes.
   472 		* @param -
   473         * @return bbuffer of the packed attribs.
   474 		*/
   475         HBufC8* PackedDefaultAttributesLC();
   476 
   477 		/**
   478 		* Sets the default value for the TInt32 attribute.
   479 		* @param aAttribute Identifies the attribute to be set.
   480 		* @param aValue The value to be set.
   481         * @return None.
   482 		*/
   483         void DoSetDefaultAttributeL( const TUint aAttribute, TInt32 aValue );
   484 
   485 		/**
   486 		* Sets the default value for the TBool attribute.
   487 		* @param aAttribute Identifies the attribute to be set.
   488 		* @param aValue The value to be set.
   489         * @return None.
   490 		*/
   491         void DoSetDefaultAttributeL( const TUint aAttribute, TBool aValue );
   492 
   493 		/**
   494 		* Sets the default value for the TDesC8 attribute.
   495 		* @param aAttribute Identifies the attribute to be set.
   496 		* @param aValue The value to be set.
   497         * @return None.
   498 		*/
   499         void DoSetDefaultAttributeL( const TUint aAttribute, const TDesC8& aValue );
   500 
   501 		/**
   502 		* Sets the default value for the TDesC16 attribute.
   503 		* @param aAttribute Identifies the attribute to be set.
   504 		* @param aValue The value to be set.
   505         * @return None.
   506 		*/
   507         void DoSetDefaultAttributeL( const TUint aAttribute, const TDesC16& aValue );
   508 
   509         /**
   510         * Start session's event notification.
   511         * @param aStatus Handler's request status.
   512         * @return None.
   513         */
   514         void StartSessionEventNotification( const TDesC8& aDownloadState,
   515                                             const TDesC8& aProgressState,
   516                                             const TDesC8& aHandle,
   517                                             TRequestStatus& aStatus );
   518 
   519         /**
   520         * Cancels session's event notification.
   521         * @param -
   522         * @return None.
   523         */
   524         void CancelSessionEventNotification();
   525         
   526         /**
   527         * Leave version of FindDownload
   528         */
   529         RHttpDownload* DoFindDownloadL( const TDesC8& aUrl, const TDesC8& aMsgBody );
   530         
   531         /**
   532         * Gets the number of client side download.
   533         * @param aValue Num of client side download
   534         * @return Error code.
   535         */        
   536         TInt NumberOfClientSideDownload( TInt32& aValue );
   537         
   538         /**
   539         * Tells that event is being broadcasted.
   540         * @param None
   541         * @return TBool.
   542         */         
   543         TBool IsEventBroadcasting();
   544         
   545         /**
   546         * Do-Indicates the session's event.
   547         * @param aHandle Unique identifier of server side subsession.
   548         * @param aEvent Event type.
   549         * @return None.
   550         */
   551         void DoHandleSessionEventL( TInt aHandle, THttpDownloadEvent aEvent );
   552 
   553         /**
   554         * Broadcasts an event.
   555         * @param aDownload The download with which the event occured.
   556         * @param aEvent Event type.
   557         * @return None.
   558         */
   559         void BroadcastEvent( RHttpDownload& aDownload, 
   560                              THttpDownloadEvent aEvent );
   561 
   562         /**
   563         * Returns the next uri observer from the extension calss.
   564         * @return Next uri observer.
   565         */                             
   566         MHttpDownloadMgrNextUriObserver* NextUriObserver() const;
   567         
   568         /**
   569         * Returns the session id
   570         * @return session id
   571         */
   572         TInt SessionId() const;
   573 
   574         /**
   575         * Broadcast deleting event.
   576         * @param aDownload download is beenig deleted.
   577         * @return None.
   578         */        
   579 //        void BroadcastDeleting( RHttpDownload& aDownload );
   580         
   581         /**
   582         * Returns the the event priority flag
   583         * @return TInt
   584         */        
   585         TInt EventPriorityFlag() const;
   586         
   587         /**
   588         * Increments the event priority flas
   589         * @return void
   590         */        
   591         void IncrementEventPriorityFlag();
   592         
   593         /**
   594         * Decrements the event priority flag
   595         * @return void
   596         */        
   597         void DecrementEventPriorityFlag();        
   598                              
   599     private:     // Data
   600         // The client application UID.
   601         TUid                             iAppUid;
   602         // List of downloads.
   603         CDownloadArray*                  iDownloadArray;  ///< Owned.
   604         // List of observers.
   605         CDownloadMgrObserver*            iObservers;      ///< Owned.
   606         // Default attributes.
   607         CArrayPtrFlat< CDefaultAttrib >* iDefaultAttribs; ///< Owned.
   608         // Moved event handler
   609         CDownloadMgrHandler*             iManagerHandler; ///< Owned.
   610         // Extension class
   611         CRHttpDownloadMgrExtension*      iExtension;      ///< Owned.
   612 
   613     public:     // Friend classes
   614 
   615         friend class RHttpDownload;
   616         friend class CDownloadMgrHandler;
   617         friend class CTransactionObserver;
   618         friend class CCodObserver;        
   619 	};
   620 
   621 /**
   622 *  Creates a download manager subsession and performs operations on it 
   623 *
   624 *  @lib -
   625 *  @since Series 60 2.8
   626 */
   627 NONSHARABLE_CLASS( RHttpDownload ): public RSubSessionBase
   628 	{
   629     public:
   630         /**
   631         * Cod download progress states
   632         */
   633         enum TCodProgressState
   634             {
   635             ENotActive,
   636             EPaused,
   637             EInProgress
   638             };
   639     private:
   640 
   641         /**
   642         * C++ default constructor.
   643         */
   644         RHttpDownload( RHttpDownloadMgr* aServer );
   645 
   646     public:  // New functions
   647 
   648         /**
   649         * Starts downloading.
   650         * @param -
   651         * @return None.
   652         */
   653         IMPORT_C TInt Start();
   654 
   655         /**
   656         * Pauses downloading.
   657         * @param -
   658         * @return None.
   659         */
   660         IMPORT_C TInt Pause();
   661 
   662         /**
   663         * Resets downloading.
   664         * @param -
   665         * @return None.
   666         */
   667         IMPORT_C TInt Reset();
   668 
   669         /**
   670         * Deletes downloading.
   671         * @param -
   672         * @return None.
   673         */
   674         IMPORT_C TInt Delete();
   675 
   676         /**
   677         * Moves downloaded content to the previously specified location
   678         * @param -
   679         * @return None.
   680         */
   681         IMPORT_C TInt Move();
   682 
   683 		/**
   684 		* Gets the value for a TInt attribute.
   685 		* @param aAttribute Identifies the attribute to be retrived.
   686 		* @param aValue On completion, contains the requested TInt attribute.
   687         * @return None.
   688 		*/
   689 		IMPORT_C TInt GetIntAttribute( const TUint aAttribute, TInt32& aValue );
   690 
   691 		/**
   692 		* Gets the value for a TBool attribute.
   693 		* @param aAttribute Identifies the attribute to be retrived.
   694 		* @param aValue On completion, contains the requested TBool attribute.
   695         * @return None.
   696 		*/
   697 		IMPORT_C TInt GetBoolAttribute( const TUint aAttribute, TBool& aValue );
   698 
   699 		/**
   700 		* Gets the value for a TDes16 attribute.
   701 		* @param aAttribute Identifies the attribute to be retrived.
   702 		* @param aValue On completion, contains the requested TDes16 attribute.
   703         * @return None.
   704 		*/
   705 		IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes16& aValue  );
   706 
   707 		/**
   708 		* Gets the value for a TDes8 attribute.
   709 		* @param aAttribute Identifies the attribute to be retrived.
   710 		* @param aValue On completion, contains the requested TDes8 attribute.
   711         * @return None.
   712 		*/
   713         IMPORT_C TInt GetStringAttribute( const TUint aAttribute, TDes8& aValue  );
   714 
   715         /**
   716         * Gets the download's destination file's handle.
   717         * @param aFile RFile that adopts file handle from download.
   718         */
   719         IMPORT_C TInt GetFileHandleAttribute( RFile& aFile );
   720         
   721 		/**
   722 		* Sets the value for a TInt attribute.
   723 		* @param aAttribute Identifies the attribute to be set.
   724 		* @param aValue The value to be set.
   725         * @return None.
   726 		*/
   727 		IMPORT_C TInt SetIntAttribute( const TUint aAttribute, TInt32 aValue );
   728 
   729 		/**
   730 		* Sets the value for a TDesC attribute.
   731 		* @param aAttribute Identifies the attribute to be set.
   732 		* @param aValue The value to be set.
   733         * @return None.
   734 		*/
   735 		IMPORT_C TInt SetBoolAttribute( const TUint aAttribute, TBool aValue );
   736 
   737 		/**
   738 		* Sets the value for a TDesC attribute.
   739 		* @param aAttribute Identifies the attribute to be set.
   740 		* @param aValue The value to be set.
   741         * @return None.
   742 		*/
   743 		IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC16& aValue );
   744 
   745 		/**
   746 		* Sets the value for a TDesC8 attribute.
   747 		* @param aAttribute Identifies the attribute to be set.
   748 		* @param aValue The value to be set.
   749         * @return None.
   750 		*/
   751         IMPORT_C TInt SetStringAttribute( const TUint aAttribute, const TDesC8& aValue );
   752 
   753         /**
   754         * Sets the download's destination file handle.
   755         * @param aFile RFile to be transfered to server.
   756         * @return KErrNotSupported on non-support platform.
   757         * @return KErrBadHandle is file is not opened.
   758         */
   759         IMPORT_C TInt SetFileHandleAttribute( RFile& aFile );
   760 		/**
   761 		* Gets the value for a TInt attribute.
   762 		* @param aAttribute Identifies the attribute to be retrived.
   763 		* @param aMoIndex Identifies the media object index.
   764 		* @param aValue On completion, contains the requested TInt attribute.
   765         * @return None.
   766 		*/
   767 		IMPORT_C TInt GetIntAttribute( const TUint aAttribute, const TInt32& aMoIndex, TInt32& aValue );
   768 		
   769 		/**
   770 		* Gets the value for a TBool attribute.
   771 		* @param aAttribute Identifies the attribute to be retrived.
   772 		* @param aMoIndex Identifies the media object index.
   773 		* @param aValue On completion, contains the requested TBool attribute.
   774         * @return None.
   775 		*/
   776 		IMPORT_C TInt GetBoolAttribute( const TUint aAttribute, const TInt32& aMoIndex, TBool& aValue );
   777 		
   778 		/**
   779 		* Gets the value for a TDes16 attribute.
   780 		* @param aAttribute Identifies the attribute to be retrived.
   781 		* @param aMoIndex Identifies the media object index.
   782 		* @param aValue On completion, contains the requested TDes16 attribute.
   783         * @return None.
   784 		*/
   785 		IMPORT_C TInt GetStringAttribute( const TUint aAttribute, const TInt32& aMoIndex, TDes16& aValue );
   786         
   787         /**
   788 		* Gets the value for a TDes8 attribute.
   789 		* @param aAttribute Identifies the attribute to be retrived.
   790 		* @param aMoIndex Identifies the media object index.
   791 		* @param aValue On completion, contains the requested TDes8 attribute.
   792         * @return None.
   793 		*/
   794         IMPORT_C TInt GetStringAttribute( const TUint aAttribute, const TInt32& aMoIndex, TDes8& aValue );
   795 		
   796 		/**
   797 		* Sets the value for a TDesC attribute.
   798 		* @param aAttribute Identifies the attribute to be set.
   799 		* @param aMoIndex Identifies the media object index.
   800 		* @param aValue The value to be set.
   801         * @return None.
   802 		*/
   803 		IMPORT_C TInt SetStringAttribute(const TUint aAttribute, const TInt32& aMoIndex, const TDesC16& aValue );
   804         
   805         /**
   806         * Sets the download data (media information).
   807         * @param sizeBytes The length of descriptor (second parameter) in bytes.
   808 		* @param aValue The value to be set.
   809         * @return None.
   810         */
   811         IMPORT_C TInt SetDownloadDataAttribute( const TDesC8& aValue );
   812         
   813         /**
   814         * Sets the download data (media information).
   815         * @param sizeBytes The length of descriptor (second parameter) in bytes.
   816 		* @param aValue The value to be set.
   817         * @return None.
   818         */
   819         IMPORT_C TInt SetTrackDataAttribute( const TInt aIndex, const TDesC8& aValue );
   820 
   821     public: // New functions
   822 
   823         /**
   824         * Closes download subsession.
   825         * @param -
   826         * @return None.
   827         */
   828         void Close();
   829         
   830 
   831         /**
   832         * Indicates whether the download is closed.
   833         * @param - None
   834         * @return TBool - ETrue if download is closed else EFalse.
   835         */        
   836         TBool IsClosed()
   837         {
   838             return iClosed;
   839         }
   840         
   841         /**
   842         * Resume COD download.
   843         * @param -
   844         * @return None.
   845         */
   846 		void ResumeCodDownloadL()  ;
   847 		
   848 		/**
   849         * Get Downloaded Size of product.
   850         * @param -
   851         * @return TInt.
   852         */
   853 		TInt GetProductDownloadedSize();        
   854         
   855      private: // New functions
   856      
   857         /**
   858         * Closes download subsession. This is called internally to close the sub session when the download
   859         * is completed. Only the subsession will be closed but retains the RHttpDownload object.
   860         * @return none.
   861         */
   862         void CloseSubSession();
   863         
   864         /**
   865         * This is called internally to save the downloaded subsession before closing the subsession
   866         * @param -
   867         * @return None.
   868         */
   869         void SaveDownloadInfoL();
   870 
   871         /**
   872         * Creates download subsession.
   873         * @param aUrl The url to be downloaded.
   874         * @return None.
   875         */
   876         void CreateL( const TDesC8& aUrl, const TPtr8 aPackedAttribs );
   877 
   878         /**
   879         * Attaches subsession to the server subsession by handle.
   880         * @param aHandle A handle which identifies the server subsession.
   881         * @return None.
   882         */
   883         void AttachL( TInt aHandle );
   884 
   885         /**
   886         * Start event notification.
   887         * @param aDownloadState State.
   888         * @param aProgressState Progress.
   889         * @param aEventAttrib Packed attribs
   890         * @param aStatus Handler's request status.
   891         * @return None.
   892         */
   893         void StartEventNotification( TDes8& aDownloadState,
   894                                      TDes8& aProgressState,
   895                                      TDes8& aEventAttrib,                                     
   896                                      TRequestStatus& aStatus );
   897 
   898         /**
   899         * Cancels event notification.
   900         * @param -
   901         * @return None.
   902         */
   903         void CancelEventNotification();
   904 
   905         /**
   906         * Returns true if the handle is equals with the stored one.
   907         * @param aHandle Handle.
   908         * @return TBool.
   909         */
   910         TBool IsDownload( TInt aHandle );
   911         
   912         /**
   913         * Returns true if the params belongs to this download.
   914         * @since 2.8
   915         * @param aParsedReqUrl given URL
   916         * @param aMsgBody Message body from post operation
   917         * @return TBool
   918         */           
   919         TBool IsDownloadL( const TUriParser8& aParsedReqUrl, 
   920                            const TDesC8& aMsgBody );
   921 
   922 		/**
   923 		* Sets the default value for the attributes.
   924 		* @param aDownload The download which default attributes to be set.
   925         * @return None.
   926 		*/
   927         void SetDefaultAttributesL( const TDesC8& aPackedAttribs );
   928 
   929 		/**
   930 		* Buffers attributes which need when a client deletes download.
   931 		* @param None.
   932         * @return None.
   933 		*/
   934         void BufferAttributesL();
   935 
   936 		/**
   937 		* Sets event type.
   938 		* @param aEventType.
   939         * @return None.
   940 		*/
   941         void SetEventType( THttpDownloadState aEventType );
   942 
   943 		/**
   944 		* Sets http transaction.
   945 		* @param aHttpTransaction.
   946         * @return None.
   947 		*/
   948         void SetHttpTransactionL( TInt aHttpTransaction );
   949 
   950 		/**
   951 		* Delete http transaction.
   952 		* @param .
   953         * @return None.
   954 		*/
   955         void DeleteTransaction();
   956         
   957 		/**
   958 		* Initialize OMA DD download.
   959         * @param aBuf The descriptor.
   960         * @param aType Descriptor data type.
   961         * @param aEikEnv Eikon environment or NULL. Can be NULL if download
   962         * does not require UI functionality. If download needs UI but NULL is
   963         * passed here, the download fails with EFailedPermanent KErrCancel.
   964         * @return None.
   965 		*/        
   966         void InitCodDownloadL( const TDesC8& aBuf, 
   967                                const TDesC8& aMimeType,
   968                                CEikonEnv* aEikEnv );
   969 
   970 		/**
   971 		* Initialize paused OMA DD download.
   972         * @param aAppUid App UID of the client.
   973         * @return None.
   974 		*/ 
   975        void InitPausedCodDownloadL( const TUid aAppUid );
   976        
   977 		/**
   978 		* Starts COD download.
   979         * @return None.
   980 		*/                               
   981         void DoStartCodL();
   982         
   983 		/**
   984 		* Checks the mime type of a completed content.
   985 		* Creates a cod download if it is considered as OMA DD.
   986 		* The return value is the result of the checking.
   987 		* Leaves in case of failure.
   988         * @return TBool.
   989 		*/         
   990         TBool CheckContentTypeAndCreateCodDownloadL();
   991 
   992 		/**
   993 		* Sets the error value.
   994 		* @param aAttribute Identifies the attribute to be set.
   995 		* @param aValue The value to be set.
   996         * @return None.
   997 		*/        
   998         TInt SetOnError( TInt aError,
   999                          THttpDownloadMgrError aDlError = EGeneral ); 
  1000 
  1001 #ifdef DEAD_CODE
  1002 		/**
  1003 		* Allocate buffer for event attribute. Part of IPC optimalization.
  1004         * @return HBufC8.
  1005 		*/      
  1006         HBufC8* AllocEventAttribBufL();
  1007 #endif
  1008         
  1009 		/**
  1010 		* Unpack event attribute package.
  1011 		* @param aPack Packed attributes.
  1012         * @return None.
  1013 		*/          
  1014         void UnpackEventAttribL( const TDesC8& aPack );
  1015 
  1016         /**
  1017         * True if it is a client side download
  1018         * @param -
  1019         * @return TBool.
  1020         */                                        
  1021         TBool IsClientSideDownload() const;
  1022         
  1023         /**
  1024         * Tells that download should be deleted.
  1025         * @param None
  1026         * @return TBool.
  1027         */         
  1028         TBool IsToBeDeleted();
  1029         
  1030         /**
  1031         * Starts downloading.
  1032         * @param None
  1033         * @return None.
  1034         */         
  1035         void DoStartL(); 
  1036         
  1037         /**
  1038         * Returns the the event priority flag from session
  1039         * @return TInt
  1040         */        
  1041         TInt EventPriorityFlag() const;
  1042         
  1043         /**
  1044         * ETrue if download should be deleted on COD completion.
  1045         * @return TBool
  1046         */         
  1047         TBool IsDeleteCodWhenDone() const;
  1048         
  1049         /**
  1050         * Sets COD in progress flag.
  1051         * @return None
  1052         */        
  1053         void SetCodInProgress( TCodProgressState aVal ); 
  1054 
  1055         /**
  1056         * Attach to an existing download.
  1057         * @param aDlId Download ID.
  1058         * @return None.
  1059         */
  1060         void AttachToDownloadL( const TInt32 aDlId );
  1061         
  1062         /**
  1063         * Sets COD in progress flag.
  1064         * @return iExtension
  1065         */
  1066         TInt32 ActiveMoIndex() const;
  1067         
  1068         /**
  1069         * To stop waiting loop of AS
  1070         * @return None.
  1071         */
  1072         void StopWaitingAS();
  1073 
  1074     private:    // Data
  1075         // Event notification handler.
  1076         CDownloadMgrHandler*     iDownloadHandler;  ///< Owned.
  1077         // Download manager session.
  1078         RHttpDownloadMgr*        iDownloadMgr;      ///< NOT Owned.
  1079         // Unique identifier of server side subsession.
  1080         TInt                     iHandle;
  1081         // Extension class
  1082         CRHttpDownloadExtension* iExtension;        ///< Owned.
  1083 
  1084         CTransactionObserver*    iTransactionObserver;
  1085         RHTTPTransaction*        iHttpTransaction;
  1086         // Descriptor Based download COD/DD
  1087         CCodDownload*            iCodDownload;      ///< Owned.        
  1088         // Cod observer
  1089         CCodObserver*            iCodObserver;    ///< Owned.
  1090         // Client Side Download
  1091         TBool                    iClientSideDownload;
  1092         // Boolean flag which indicates download closure
  1093         TBool                    iClosed;
  1094         // Boolean flag which indicates download subsession closure
  1095         TBool                    iClosedSubSession;
  1096         // Extension class to cache the cloased subsession
  1097         CRHttpDlExtension* 		 iDlExtension;        ///< Owned.
  1098         
  1099         CActiveSchedulerWait*    iWait;
  1100         
  1101         // Boolean flag which indicates Active Scheduler is Ready
  1102         TBool                    iASReady;
  1103         
  1104     public:     // Friend classes
  1105  
  1106         friend class CDownloadMgrHandler;
  1107         friend class RHttpDownloadMgr;
  1108         friend class RHttpDownloadMgrApiExt;
  1109         friend class CTransactionObserver;
  1110         friend class CCodObserver;
  1111         friend class CDownloadMgrHandler;
  1112 
  1113 	};
  1114 
  1115 #endif /* __DOWNLOADMGR_CLIENT_H__ */
  1116