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