upnp/upnpstack/upnphttptransfer/inc/httpfile.h
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 /** @file
       
     2 * Copyright (c) 2007 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 "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:  Represents one downloadable file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CHTTPFILE_H
       
    20 #define C_CHTTPFILE_H
       
    21 
       
    22 
       
    23 // System include files
       
    24 #include <e32cmn.h>
       
    25 #include <e32base.h>
       
    26 #include <f32file.h>
       
    27 
       
    28 // User include files
       
    29 #include "httpheader.h"
       
    30 
       
    31 /**
       
    32  * Class which represents one dowloaded/uploaded file  
       
    33  *
       
    34  * @lib httptransfer.lib
       
    35  * @since S60 v3.2
       
    36  */
       
    37 NONSHARABLE_CLASS ( CHttpFile ) : public CBase
       
    38     {
       
    39 public:
       
    40 
       
    41     /**
       
    42      * Constructor
       
    43      *
       
    44      * @since S60 v3.2
       
    45      * @param aKey Identifier of the file
       
    46      * @param aUri Uri of the file
       
    47      * @param aPath Local path of the file
       
    48      * @return Instance of CHttpFile object
       
    49      */
       
    50     static CHttpFile* NewL( TAny* aKey, const TDesC8& aUri,
       
    51                             const TDesC& aPath );
       
    52 
       
    53     /**
       
    54      * Constructor
       
    55      *
       
    56      * @since S60 v3.2
       
    57      * @param aKey Identifier of the file
       
    58      * @param aUri Uri of the file
       
    59      * @param aPath Local path of the file
       
    60      * @return Identifier of the object
       
    61      */
       
    62     static CHttpFile* NewLC( TAny* aKey, const TDesC8& aUri, 
       
    63                              const TDesC& aPath );
       
    64 
       
    65     /**
       
    66      * Constructor
       
    67      *
       
    68      * @since S60 v3.2
       
    69      * @param aKey Identifier of the file
       
    70      * @param aUri Uri of the file
       
    71      * @param aFileHandle Handle to the file
       
    72      * @return Instance of CHttpFile object
       
    73      */
       
    74     static CHttpFile* NewL( TAny* aKey, const TDesC8& aUri,
       
    75                             const RFile& aFileHandle );
       
    76 
       
    77     /**
       
    78      * Constructor
       
    79      *
       
    80      * @since S60 v3.2
       
    81      * @param aKey Identifier of the file
       
    82      * @param aUri Uri of the file
       
    83      * @param aFileHandle Handle to the file
       
    84      * @return Identifier of the object
       
    85      */
       
    86     static CHttpFile* NewLC( TAny* aKey, const TDesC8& aUri, 
       
    87                              const RFile& aFileHandle );
       
    88 
       
    89     /**
       
    90      * Virtual destructor
       
    91      *
       
    92      * @since S60 v3.2
       
    93      */
       
    94     ~CHttpFile();
       
    95 
       
    96     /**
       
    97      * Setter for the member variable iTrackProgress
       
    98      *
       
    99      * @since S60 v3.2
       
   100      * @param aValue Value of the progress flag
       
   101      * @return Identifier of the object
       
   102      */
       
   103     void TrackProgress( TBool aValue );
       
   104 
       
   105     /**
       
   106      * Returns if tracking is set on.
       
   107      *
       
   108      * @since S60 v3.2
       
   109      * @return True if tracking is on, false otherwise
       
   110      */
       
   111     TBool TrackingOn() const;
       
   112     
       
   113     /**
       
   114      * Getter for the member variable iKey
       
   115      *
       
   116      * @since S60 v3.2
       
   117      * @return Identifier of the object
       
   118      */
       
   119     TAny* Key() const;
       
   120 
       
   121     /**
       
   122      * Getter for the iUri member variable
       
   123      *
       
   124      * @since S60 v3.2
       
   125      * @return Reference to the Uri
       
   126      */
       
   127     const HBufC8* Uri() const;
       
   128 
       
   129     /**
       
   130      * Setter for iUri
       
   131      *
       
   132      * @since S60 v3.2
       
   133      */
       
   134     void SetUriL( const TDesC8& aUri );
       
   135     
       
   136     /**
       
   137      * Getter for the iPath member variable
       
   138      *
       
   139      * @since S60 v3.2
       
   140      * @return Pointer to the path
       
   141      */
       
   142     const HBufC* Path() const;
       
   143 
       
   144     /**
       
   145      * Getter for the filehandle
       
   146      *
       
   147      * @since S60 v3.2
       
   148      * @return Handle to the file
       
   149      */
       
   150     RFile FileHandle() const;
       
   151 
       
   152     /**
       
   153      * Sets a header
       
   154      *
       
   155      * @since S60 v3.2
       
   156      * @param aFieldName The field name, e.g. 'Accept'
       
   157      * @param aFieldValue The field value. e.g. 'text/plain'
       
   158      */
       
   159     void SetHeaderL( const TDesC8& aFieldName, const TDesC8& aFieldValue );
       
   160 
       
   161     /**
       
   162      * Getter for header array
       
   163      *
       
   164      * @since S60 v3.2
       
   165      * @return Array of CHttpHeader objects which are set to this file
       
   166      */
       
   167     RPointerArray<CHttpHeader>& Headers();
       
   168 
       
   169     /**
       
   170      * Creates the file in the file system
       
   171      *
       
   172      * @since S60 v3.2
       
   173      */
       
   174     void CreateFileInFileSystemL();
       
   175 
       
   176     /**
       
   177      * Deletes the file from the file system
       
   178      *
       
   179      * @since S60 v3.2
       
   180      */
       
   181     void DeleteFileFromFileSystemL();
       
   182     
       
   183     /**
       
   184      * Closes the file
       
   185      */
       
   186     void CloseFile();
       
   187 
       
   188 private:
       
   189 
       
   190     /**
       
   191      * Default constructor
       
   192      *
       
   193      * @since S60 v3.2
       
   194      * @param aKey Identifier of the file
       
   195      * @return Identifier of the object
       
   196      */
       
   197     CHttpFile( TAny* aKey );
       
   198 
       
   199     /**
       
   200      * Default constructor
       
   201      *
       
   202      * @since S60 v3.2
       
   203      * @param aKey Identifier of the file
       
   204      * @param aFileHandle Handle to the file
       
   205      * @return Identifier of the object
       
   206      */
       
   207     CHttpFile( TAny* aKey, const RFile& aFileHandle );
       
   208 
       
   209     /**
       
   210      * Second phase constructor
       
   211      *
       
   212      * @since S60 v3.2
       
   213      * @param aUri Uri of the file
       
   214      * @param aPath Local path of the file
       
   215      */
       
   216     void ConstructL( const TDesC8& aUri, const TDesC& aPath );
       
   217 
       
   218     /**
       
   219      * Second phase constructor
       
   220      *
       
   221      * @since S60 v3.2
       
   222      * @param aUri Uri of the file
       
   223      */
       
   224     void ConstructL( const TDesC8& aUri );
       
   225 
       
   226 private: 
       
   227 
       
   228     /**
       
   229      * Indicator if tracking of the progress is switched on
       
   230      */
       
   231     TBool iTrackProgress;
       
   232 
       
   233     /**
       
   234      * Identifier of the object
       
   235      * Not own.
       
   236      */
       
   237     TAny* iKey;
       
   238 
       
   239     /**
       
   240      * Uri
       
   241      * Own.
       
   242      */
       
   243     HBufC8* iUri;
       
   244 
       
   245     /**
       
   246      * Full path on local system
       
   247      * Own.
       
   248      */
       
   249     HBufC* iPath;
       
   250     
       
   251     /**
       
   252      * Array of headers
       
   253      */
       
   254     RPointerArray<CHttpHeader> iHeaderArray;
       
   255     
       
   256     /**
       
   257      * Handle to the file
       
   258      */
       
   259     RFile iFile;
       
   260 
       
   261     /**
       
   262      * File server session
       
   263      */
       
   264     RFs iFsSession;
       
   265 
       
   266     };
       
   267 
       
   268 #endif // C_CHTTPFILE_H