codhandler/codeng/inc/DownloadDataClient.h
changeset 0 dd21522fd290
child 10 a359256acfc6
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *      Declaration of class CDownloadDataClient.
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef DOWNLOAD_DATA_CLIENT_H
       
    22 #define DOWNLOAD_DATA_CLIENT_H
       
    23 
       
    24 // INCLUDES
       
    25 
       
    26 #include <e32base.h>
       
    27 #include "HttpDownloadData.h"
       
    28 
       
    29 // ================= CONSTANTS =======================
       
    30 
       
    31 // FORWARD DECLARATION
       
    32 
       
    33 class CDesC8ArrayFlat;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38 * Media Data.
       
    39 */
       
    40 NONSHARABLE_CLASS( CMediaDataClient ) : public CMediaDataBase
       
    41     {
       
    42     
       
    43     public:     // Constructors and destructor
       
    44         
       
    45         /**
       
    46         * Two-phased constructor.
       
    47         */
       
    48         static CMediaDataClient* NewL();
       
    49         
       
    50         /**
       
    51         * Two-phased constructor.
       
    52         */
       
    53         static CMediaDataClient* NewLC();
       
    54         
       
    55         /**
       
    56         * Destructor.
       
    57         */      
       
    58         ~CMediaDataClient();
       
    59         
       
    60     public:     // Methods
       
    61     
       
    62     	/**
       
    63         * Creates an HBufC8 representation of 'this'.
       
    64         */
       
    65         HBufC8* MarshalDataL() const;
       
    66         
       
    67         /**
       
    68         * Writes 'this' to the stream.
       
    69         */
       
    70         void ExternalizeL(RWriteStream& aStream) const;
       
    71         
       
    72         /**
       
    73         * Dummy function - No implementation.
       
    74         */
       
    75         void InternalizeL(RReadStream& aStream);
       
    76         
       
    77     public:     // Getters
       
    78     
       
    79         /**
       
    80         * Get size of this class including actual memory occupied by descriptors.
       
    81         * @return Bytes.
       
    82         */
       
    83         TInt Bytes() const;
       
    84         
       
    85     public:     // Setters
       
    86         
       
    87         /**
       
    88         * Set Name attribute.
       
    89         * @param Name.
       
    90         * @return ETrue if set, EFalse for invalid data.
       
    91         */
       
    92         TBool SetNameL( const TDesC& aName );
       
    93 
       
    94         /**
       
    95         * Set Url attribute.
       
    96         * @param Url.
       
    97         * @return ETrue if set, EFalse for invalid data.
       
    98         */
       
    99         TBool SetUrlL( const TDesC8& aUrl );
       
   100 
       
   101         /**
       
   102         * Set Size attribute.
       
   103         * @param Size.
       
   104         * @return ETrue if set, EFalse for invalid data.
       
   105         */
       
   106         TBool SetSize( TUint aSize );
       
   107 
       
   108         /**
       
   109         * Set Type attribute (replace all).
       
   110         * @param Type.
       
   111         * @return ETrue if set, EFalse for invalid data.
       
   112         */
       
   113         TBool SetTypeL( const TDesC8& aType );
       
   114 
       
   115         /**
       
   116         * Set Type attribute.
       
   117         * @param Type.
       
   118         * @return ETrue if set, EFalse for invalid data.
       
   119         */
       
   120         TBool AddTypeL( const TDesC8& aType );
       
   121         
       
   122         /**
       
   123         * Reset the Type array.
       
   124         * @return Number of elements.
       
   125         */
       
   126         void ResetTypes();
       
   127 
       
   128         /**
       
   129         * Set Icon attribute.
       
   130         * @param Icon.
       
   131         */
       
   132         TBool SetIconL( const TDesC8& aIcon );
       
   133 
       
   134         /**
       
   135         * Set source URI.
       
   136         * @param aSourceUri Source URI.
       
   137         */
       
   138         void SetSourceUriL( const TDesC8& aSourceUri );
       
   139 
       
   140         /**
       
   141         * Set Progressive download attribute.
       
   142         * @param aProgressiveDl Progressive Download setting.
       
   143         */
       
   144         void SetProgressiveDownload( TBool aProgressiveDl );
       
   145         
       
   146         /**
       
   147         * Set state attribute.
       
   148         * @param TMediaObjectState.
       
   149         * @return void.
       
   150         */
       
   151         void SetState( TMediaObjectState aState );
       
   152 
       
   153         /**
       
   154         * Set result attribute.
       
   155         * @param aResult.
       
   156         * @return void.
       
   157         */
       
   158         void SetResult( TInt aResult );
       
   159         
       
   160         /**
       
   161         * Set redir Url attribute.
       
   162         * @param aRedirUrl Redirected Url.
       
   163         * @return ETrue if set, EFalse for invalid data.
       
   164         */
       
   165         TBool SetRedirUrlL( const TDesC8& aRedirUrl );
       
   166         
       
   167         /**
       
   168         * Set method attribute.
       
   169         * @param aMethod Http request method.
       
   170         */
       
   171         void SetMethod( TInt aMethod );
       
   172         
       
   173         /**
       
   174         * Set Progressive download attribute.
       
   175         * @param aRedirected Whether redirected or not.
       
   176         */
       
   177         void SetRedirected( TBool aRedirected );
       
   178         
       
   179         /**
       
   180         * Set destination filename attribute.
       
   181         * @param aDestFilename Destination filename.
       
   182         * @return ETrue if set, EFalse for invalid data.
       
   183         */
       
   184         TBool SetDestFilenameL( const TDesC& aDestFilename );
       
   185         
       
   186         /**
       
   187         * Set Temp filename attribute.
       
   188         * @param aTempFilename Temp filename.
       
   189         * @return ETrue if set, EFalse for invalid data.
       
   190         */
       
   191         TBool SetTempFilenameL( const TDesC& aTempFilename );
       
   192         
       
   193         /**
       
   194         * Set downloaded size attribute.
       
   195         * @param aDownloadedSize Downloaded size of the media object.
       
   196         * @return ETrue if set, EFalse for invalid data.
       
   197         */
       
   198         TBool SetDownloadedSize( TInt aDownloadedSize );
       
   199         
       
   200         /**
       
   201         * Set destination removable attribute.
       
   202         * @param aDesRemovable Whether removable media drive.
       
   203         */
       
   204         void SetDesRemovable( TBool aDesRemovable );
       
   205         
       
   206         /**
       
   207         * Set last error id attribute.
       
   208         * @param aLastErrorId Last error ID.
       
   209         */
       
   210         void SetLastErrorId( TInt aLastErrorId );
       
   211         
       
   212         /**
       
   213         * Set global error id attribute.
       
   214         * @param aGlobalErrorId Global error ID.
       
   215         */
       
   216         void SetGlobalErrorId( TInt aGlobalErrorId );
       
   217         
       
   218         /**
       
   219         * Set Pausable attribute.
       
   220         * @param aPausable Whether download pausable or not.
       
   221         */
       
   222         void SetPausable( TBool aPausable );
       
   223         
       
   224     private:    // implementation details
       
   225 
       
   226         /**
       
   227         * Common setter for string attributes, with overflow check.
       
   228         * @param aBuf Buffer to set.
       
   229         * @param aString String to set.
       
   230         * @param aMaxLength Max length to check.
       
   231         * @return ETrue if set, EFalse for invalid data.
       
   232         */
       
   233         TBool SetStringAttrL
       
   234             ( HBufC*& aBuf, const TDesC& aString, TInt aMaxLength );
       
   235 
       
   236         /**
       
   237         * Common setter for string attributes, with overflow check.
       
   238         * @param aBuf Buffer to set.
       
   239         * @param aString String to set.
       
   240         * @param aMaxLength Max length to check.
       
   241         * @return ETrue if set, EFalse for invalid data.
       
   242         */
       
   243         TBool SetStringAttrL
       
   244             ( HBufC8*& aBuf, const TDesC& aString, TInt aMaxLength );
       
   245         
       
   246         /**
       
   247         * Common setter for string attributes, with overflow check.
       
   248         * @param aBuf Buffer to set.
       
   249         * @param aString String to set.
       
   250         * @param aMaxLength Max length to check.
       
   251         * @return ETrue if set, EFalse for invalid data.
       
   252         */
       
   253         TBool SetStringAttrL
       
   254             ( HBufC8*& aBuf, const TDesC8& aString, TInt aMaxLength );
       
   255         
       
   256     protected:  // Constructors and destructor
       
   257         
       
   258         /** 
       
   259         * Constructor.
       
   260         */
       
   261         CMediaDataClient(){}
       
   262         
       
   263         /**
       
   264         * Second phase constructor. Leaves on failure.
       
   265         */      
       
   266         void ConstructL();
       
   267 
       
   268     };
       
   269     
       
   270 
       
   271 /**
       
   272 * Download Data.
       
   273 */  
       
   274 NONSHARABLE_CLASS( CDownloadDataClient ) : public CDownloadDataBase
       
   275     {
       
   276     
       
   277     public:     // Constructors and destructor
       
   278         
       
   279         /**
       
   280         * Two-phased constructor.
       
   281         */
       
   282         static CDownloadDataClient* NewL();
       
   283         
       
   284         /**
       
   285         * Two-phased constructor.
       
   286         */
       
   287         static CDownloadDataClient* NewLC();
       
   288         
       
   289         /**
       
   290         * Destructor.
       
   291         */      
       
   292         ~CDownloadDataClient();
       
   293         
       
   294     public:     // Methods
       
   295         
       
   296         /**
       
   297         * Creates an HBufC8 representation of 'this'.
       
   298         */
       
   299         HBufC8* MarshalDataL() const;
       
   300         
       
   301         /**
       
   302         * Writes 'this' to the stream.
       
   303         */
       
   304         void ExternalizeL(RWriteStream& aStream) const;
       
   305         
       
   306     public:     // Methods to manage media data
       
   307     
       
   308         /**
       
   309         * Append given media object to the array
       
   310         * @return index of the media object
       
   311         */
       
   312         TInt AppendMediaData( CMediaDataClient *aMO );
       
   313         
       
   314         /**
       
   315         * Append given media object to the array
       
   316         * @return media object
       
   317         */
       
   318         CMediaDataBase* operator[]( TInt aIndex );
       
   319 
       
   320         /**
       
   321         * Append given media object to the array
       
   322         * @return media object
       
   323         */
       
   324         CMediaDataBase* operator[]( TInt aIndex ) const;
       
   325         
       
   326     public:     // Getters
       
   327     
       
   328         /**
       
   329         * Get size of this class including actual memory occupied by descriptors.
       
   330         * @return Bytes.
       
   331         */
       
   332         TInt Bytes() const;
       
   333         
       
   334     public:     // Setters
       
   335     
       
   336         /**
       
   337         * Set Name attribute.
       
   338         * @param Name.
       
   339         * @return ETrue if set, EFalse for invalid data.
       
   340         */
       
   341         TBool SetNameL( const TDesC& aName );
       
   342 
       
   343         /**
       
   344         * Set Size attribute.
       
   345         * @param Size.
       
   346         * @return ETrue if set, EFalse for invalid data.
       
   347         */
       
   348         TBool SetSize( TUint aSize );
       
   349 
       
   350         /**
       
   351         * Set Icon attribute.
       
   352         * @param Icon.
       
   353         */
       
   354         TBool SetIconL( const TDesC8& aIcon );
       
   355 
       
   356        /**
       
   357         * Set updated DD URI attribute. 
       
   358         * @param Updated DD Uri.
       
   359         */
       
   360         TBool SetUpdatedDDURI( const TDesC8& aUrl );
       
   361         
       
   362     private:    // implementation details
       
   363 
       
   364         /**
       
   365         * Common setter for string attributes, with overflow check.
       
   366         * @param aBuf Buffer to set.
       
   367         * @param aString String to set.
       
   368         * @param aMaxLength Max length to check.
       
   369         * @return ETrue if set, EFalse for invalid data.
       
   370         */
       
   371         TBool SetStringAttrL
       
   372             ( HBufC*& aBuf, const TDesC& aString, TInt aMaxLength );
       
   373 
       
   374         /**
       
   375         * Common setter for string attributes, with overflow check.
       
   376         * @param aBuf Buffer to set.
       
   377         * @param aString String to set.
       
   378         * @param aMaxLength Max length to check.
       
   379         * @return ETrue if set, EFalse for invalid data.
       
   380         */
       
   381         TBool SetStringAttrL
       
   382             ( HBufC8*& aBuf, const TDesC& aString, TInt aMaxLength );
       
   383             
       
   384         /**
       
   385         * Common setter for string attributes, with overflow check.
       
   386         * @param aBuf Buffer to set.
       
   387         * @param aString String to set.
       
   388         * @param aMaxLength Max length to check.
       
   389         * @return ETrue if set, EFalse for invalid data.
       
   390         */
       
   391         TBool SetStringAttrL
       
   392             ( HBufC8*& aBuf, const TDesC8& aString, TInt aMaxLength );
       
   393         
       
   394     protected:  // Constructors and destructor
       
   395         
       
   396         /**
       
   397         * Constructor.
       
   398         */
       
   399         CDownloadDataClient(){}
       
   400         
       
   401         /**
       
   402         * Second phase constructor. Leaves on failure.
       
   403         */      
       
   404         void ConstructL();
       
   405 
       
   406     };
       
   407 
       
   408 #endif /* def DOWNLOAD_DATA_CLIENT_H */