web_plat/cod_handler_api/inc/CodDownload.h
changeset 0 dd21522fd290
child 48 79859ed3eea9
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 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:  Declaration of class CCodDownload.   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef COD_DOWNLOAD_H
       
    20 #define COD_DOWNLOAD_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 // FORWARD DECLARATION
       
    27 
       
    28 class CCodDownload;
       
    29 class CCodDownloadImpl;
       
    30 class CAiwGenericParamList;
       
    31 class CEikonEnv;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 
       
    35 /**
       
    36 * Cod Download observer.
       
    37 */
       
    38 NONSHARABLE_CLASS( MCodDownloadObserver )
       
    39     {
       
    40     public:     // types
       
    41 
       
    42         enum TEvent              ///< Event.
       
    43             {
       
    44             EStart,              ///< Load initiated.
       
    45             ENameChanged,        ///< Name changed.
       
    46             ETypeChanged,        ///< Type changed.
       
    47             EProgressUpdate,     ///< Progress update.
       
    48             EDone,               ///< Finished (success or failure).
       
    49             EAccept,             ///< Load accepted by user (start of load).
       
    50             EEndLoad,            ///< Waiting for service flow (end of load).
       
    51             EPdPlayAvailable,	 ///< in case of PD allow user to choose 'play'
       
    52             EUpdatedDDURI,       ///< Updated DD URI notification to the DM Server
       
    53             EResumed,			 ///< Resume successful and ready for PD
       
    54             EDownloadPausable,   ///< Informs the Server that download is PAUSABLE
       
    55             EDownloadNonPausable,///< Informs the Server that download is NOT PAUSABLE
       
    56             EHandlePostResponse, ///<  Intiates fresh download as part handling PostResponseURL of metering response 
       
    57             EUpdatedMediaInfo,   ///< Updated Media Info to DM Server
       
    58             ESetActiveDownload,  ///< Inform the server about currently active download
       
    59             EUpdatedTrackInfo    ///< Updated Media Info to DM Server
       
    60             };
       
    61 
       
    62     public:     // New methods.
       
    63 
       
    64         /**
       
    65         * Cod Download event.
       
    66         * @param aDownload Download.
       
    67         * @param aEvent Event.
       
    68         */
       
    69         virtual void CodEventL( CCodDownload& aDownload, TEvent aEvent ) = 0;
       
    70 
       
    71     };
       
    72 
       
    73 /**
       
    74 * Cod Download progress tracking.
       
    75 */
       
    76 NONSHARABLE_STRUCT( TCodDownloadProgress )
       
    77     {
       
    78     public:     // types
       
    79 
       
    80         enum TState             ///< State.
       
    81             {
       
    82             EInit,              ///< Initial state.
       
    83             EInProgress,        ///< In progress.
       
    84             ESucceeded,         ///< Succeeded.
       
    85             EFailedTemporary,   ///< Failed (temporary error).
       
    86             EFailedPermanent,    ///< Failed (permanent error).
       
    87             EPaused  			///< Paused
       
    88             };
       
    89 
       
    90     public:     // data
       
    91 
       
    92         TState iState;  ///< Download state.
       
    93         TInt iError;    ///< Error code.
       
    94         TInt iBytesCur; ///< Bytes downloaded so far (-1 if unknown).
       
    95         TInt iBytesMax; ///< Total download size (estimated; -1 if unknown).
       
    96     };
       
    97 
       
    98 /**
       
    99 * Descriptor-based download.
       
   100 * Supported descriptor types:
       
   101 * - text/x-co-desc (Nokia COD)
       
   102 * - application/vnd.oma.dd+xml (OMA DD)
       
   103 * - multipart/related, where the first part is one of the two above.
       
   104 */
       
   105 NONSHARABLE_CLASS( CCodDownload ): public CBase
       
   106     {
       
   107     public:     // Constructors and destructor
       
   108 
       
   109         /**
       
   110         * Two-phased constructor. Leaves on failure.
       
   111         * @param aBuf The descriptor.
       
   112         * @param aType Descriptor data type.
       
   113         * @param aObserver Observer.
       
   114         * @param aEikEnv Eikon environment or NULL. Can be NULL if download
       
   115         * does not require UI functionality. If download needs UI but NULL is
       
   116         * passed here, the download fails with EFailedPermanent KErrCancel.
       
   117         * @return The constructed object.
       
   118         */
       
   119         IMPORT_C static CCodDownload* NewL
       
   120             (
       
   121             const TDesC8& aBuf,
       
   122             const TDesC8& aType,
       
   123             MCodDownloadObserver& aObserver,
       
   124             CEikonEnv* aEikEnv
       
   125             );
       
   126 
       
   127         /**
       
   128         * Two-phased constructor. Leaves on failure.
       
   129         * This one supports multipart/related where the first part of the
       
   130         * multipart is the descriptor.
       
   131         * @param aBuf Data buffer (descriptor or multipart).
       
   132         * @param aType Data type.
       
   133         * @param aObserver Observer.
       
   134         * @param aEikEnv Eikon environment or NULL. Can be NULL if download
       
   135         * does not require UI functionality. If download needs UI but NULL is
       
   136         * passed here, the download fails with EFailedPermanent KErrCancel.
       
   137         * @param aMultipartBoundary Multipart boundary or NULL.
       
   138         * Required for processing multipart.
       
   139         * @param aMultipartUrl Multipart URL or NULL.
       
   140         * Required for processing multipart.
       
   141         * @return The constructed object.
       
   142         */
       
   143         IMPORT_C static CCodDownload* NewL
       
   144             (
       
   145             const TDesC8& aBuf,
       
   146             const TDesC8& aType,
       
   147             MCodDownloadObserver& aObserver,
       
   148             CEikonEnv* aEikEnv,
       
   149             const TDesC8* aMultipartBoundary,
       
   150             const TDesC16* aMultipartUrl
       
   151             );
       
   152 
       
   153         /**
       
   154         * Destructor.
       
   155         */
       
   156         IMPORT_C virtual ~CCodDownload();
       
   157 
       
   158     public:     // New methods
       
   159 
       
   160         /**
       
   161         * Start download. Panics if already active.
       
   162         * Restart is OK for completed downloads.
       
   163         * @param aParams Parameters or NULL.
       
   164         */
       
   165         IMPORT_C void StartL( const CAiwGenericParamList* aParams );
       
   166 
       
   167         /**
       
   168         * Stop (cancel) download. Safe to call in any state.
       
   169         * Note: processing continues until MCodDownloadObserver::EDone event.
       
   170         */
       
   171         IMPORT_C void Stop();
       
   172 
       
   173         /**
       
   174         * Pauses the COD download
       
   175         */  
       
   176         IMPORT_C void Pause();
       
   177         
       
   178         /**
       
   179         * Get progress.
       
   180         * @return Progress.
       
   181         */
       
   182         IMPORT_C const TCodDownloadProgress& Progress() const;
       
   183 
       
   184         /**
       
   185         * Get name attribute. This may be empty string, if attribute is
       
   186         * empty or not available. Do not store pointer (data may change as
       
   187         * download proceeds).
       
   188         */
       
   189         IMPORT_C TPtrC Name();
       
   190 
       
   191         /**
       
   192         * Get data type of content (or empty string: type may not be
       
   193         * available).
       
   194         * @return Data type.
       
   195         */
       
   196         IMPORT_C TPtrC8 Type() const;
       
   197 
       
   198         /**
       
   199         * Get path of saved content (or empty string).
       
   200         * Available in ESucceeded state only.
       
   201         * @return Path of saved content. Fits to KMaxFileName.
       
   202         */
       
   203         IMPORT_C TPtrC GetPath() const;
       
   204 
       
   205         /**
       
   206         * Perform service flow after a succesful or failed download.
       
   207         * This consists of zero, one or both of
       
   208         * - launching downloaded content
       
   209         * - activating Next-URL.
       
   210         * Load may also be retried.
       
   211         * Call this in response to EEndLoad event.
       
   212         */
       
   213         IMPORT_C void ServiceFlowL();
       
   214 
       
   215         /**
       
   216         * Get Next-URL.
       
   217         * @return Next-URL. Owner is the caller.
       
   218         */
       
   219         IMPORT_C HBufC8* NextUrlL() const;
       
   220         
       
   221         /**
       
   222         * Get PostResponse-URL.
       
   223         * @return PostResponse-URL. Owner is the caller.
       
   224         */
       
   225         IMPORT_C HBufC8* GetPostResponseUrlL() const;
       
   226 
       
   227         /**
       
   228         * Get the updated DD URL.
       
   229         * @return Updated DD URL.
       
   230         */
       
   231         IMPORT_C HBufC8* UpdatedDDUriL() const;
       
   232         
       
   233 		/**
       
   234         * Check if downloading to removable media.
       
   235         * Available after EAccept event.
       
   236         * @return ETrue if downloading to removable media.
       
   237         */
       
   238         IMPORT_C TBool RemovableMedia() const;
       
   239 
       
   240         /**
       
   241         * Set COD download attached
       
   242         * @param aValue If equals ETrue - download is attached
       
   243         */
       
   244         IMPORT_C void SetCodDlAttached(const TBool aValue);
       
   245 
       
   246     public:     // Transparent user data
       
   247 
       
   248         /**
       
   249         * Get tansparent user data.
       
   250         * @return User data.
       
   251         */
       
   252         IMPORT_C TAny* UserData() const;
       
   253 
       
   254         /**
       
   255         * Set tansparent user data.
       
   256         * @param aUserData User data.
       
   257         */
       
   258         IMPORT_C void SetUserData( TAny* aUserData );
       
   259 
       
   260     public:     //Added as part of multiple download
       
   261 
       
   262         /**
       
   263         * Two-phased constructor. Leaves on failure.
       
   264         * @param aDownloadId Download ID.
       
   265         * @param aDlUid App UID.        
       
   266         * @param aType Descriptor data type.
       
   267         * @param aObserver Observer.
       
   268         * @param aEikEnv Eikon environment or NULL. Can be NULL if download
       
   269         * does not require UI functionality. If download needs UI but NULL is
       
   270         * passed here, the download fails with EFailedPermanent KErrCancel.
       
   271         * @return The constructed object.
       
   272         */            
       
   273         IMPORT_C static CCodDownload* NewL
       
   274 	        (
       
   275 	        const TInt aDownloadId,
       
   276 	        const TUid aDlUid,
       
   277 	        const TDesC8& aType,
       
   278 	        MCodDownloadObserver& aObserver,
       
   279 	        CEikonEnv* aEikEnv 
       
   280 	        );
       
   281 
       
   282         /**
       
   283         * Set the CodData stream descriptor.
       
   284         * @param aDesStream.
       
   285         */
       
   286         IMPORT_C HBufC8* UpdatedDownloadDataL() const;
       
   287         
       
   288         /**
       
   289         * Set the stream descriptor for single media object (track).
       
   290         * @param aDesStream.
       
   291         */
       
   292         IMPORT_C HBufC8* UpdatedTrackDataL(TInt& aValue) const;
       
   293 
       
   294         /**
       
   295         * Get COD Active download 
       
   296         * @return Count of currently active download
       
   297         */
       
   298         IMPORT_C TInt ActiveDownload ( );
       
   299         /**
       
   300         * Get Destination file name 
       
   301         * @param aMOIndex media object index between 1 to 'n'
       
   302         * @return NULL if index out of range
       
   303         */
       
   304         IMPORT_C TPtrC GetDestFilePath (TInt aMOIndex ) const;
       
   305             
       
   306     private:    // Constructor
       
   307 
       
   308         /**
       
   309         * Constructor.
       
   310         */
       
   311         CCodDownload();
       
   312 
       
   313     private:    // Data 
       
   314 
       
   315         CCodDownloadImpl* iImpl;    ///< Implementation. Owned.
       
   316 
       
   317     };
       
   318 
       
   319 #endif /* def COD_DOWNLOAD_H */