ncdengine/provider/server/inc/ncddownloadsuboperation.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_NCDDOWNLOADSUBOPERATION_H
       
    20 #define C_NCDDOWNLOADSUBOPERATION_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "ncdbaseoperation.h"
       
    25 #include "ncdoperationdatatypes.h"
       
    26 #include "ncddownloadoperationstates.h"
       
    27 #include "catalogshttptypes.h"
       
    28 #include "catalogshttpobserver.h"
       
    29 #include "ncdoperationobserver.h"
       
    30 
       
    31 class RWriteStream;
       
    32 class RReadStream;
       
    33 
       
    34 class MCatalogsHttpSession;
       
    35 class MCatalogsHttpConfig;
       
    36 class MCatalogsHttpOperation;
       
    37 class MCatalogsHttpHeaders;
       
    38 class CNcdGeneralManager;
       
    39 
       
    40 /** 
       
    41  * Download operation
       
    42  *
       
    43  * @ Add username & password -handling
       
    44  * @ Add observers if this is used by other operations
       
    45  */
       
    46 class CNcdDownloadSubOperation : public CNcdBaseOperation,
       
    47     public MCatalogsHttpObserver
       
    48     {
       
    49 public:
       
    50     
       
    51     /**
       
    52      * NewL
       
    53      *
       
    54      * @param aHttpSession HTTP session used for creating download operations
       
    55      * @param aDestination Destination directory if the descriptor ends in '\'
       
    56      * otherwise full destination path (path + filename)
       
    57      *
       
    58      * @note Preferably the HTTP session has suitable defaults but if not then
       
    59      * Config() can be used to retrieve and change the settings for the download.
       
    60      * @note At least the target directory and access point must be set to the 
       
    61      * configuration.
       
    62      *    
       
    63      */
       
    64     static CNcdDownloadSubOperation* NewL( 
       
    65         CNcdGeneralManager& aGeneralManager,
       
    66         MCatalogsHttpSession& aHttpSession,
       
    67         const TDesC& aUri,
       
    68         const TDesC& aDestination,
       
    69         MNcdOperationObserver& aObserver,
       
    70         MCatalogsSession& aSession );
       
    71 
       
    72 
       
    73     /**
       
    74      * NewL
       
    75      *
       
    76      * Internalizes a download operation from a stream
       
    77      */
       
    78     static CNcdDownloadSubOperation* NewL( 
       
    79         CNcdGeneralManager& aGeneralManager,
       
    80         MCatalogsHttpSession& aHttpSession,
       
    81         MNcdOperationObserver& aObserver,
       
    82         RReadStream& aStream,
       
    83         MCatalogsSession& aSession );
       
    84         
       
    85     
       
    86     /**
       
    87      * Destructor
       
    88      */
       
    89     virtual ~CNcdDownloadSubOperation();
       
    90     
       
    91 public: // New methods
       
    92 
       
    93     /** 
       
    94      * HTTP configuration getter. 
       
    95      */
       
    96     MCatalogsHttpConfig& Config();
       
    97     
       
    98     /**
       
    99      * HTTP request headers getter
       
   100      */
       
   101     MCatalogsHttpHeaders& RequestHeaders();
       
   102     
       
   103     const MCatalogsHttpHeaders& ResponseHeadersL();
       
   104     
       
   105     /**
       
   106      * Download operation getter
       
   107      */
       
   108     MCatalogsHttpOperation& HttpOperation();
       
   109     
       
   110     
       
   111 public: // From CNcdBaseOperation
       
   112 
       
   113     /**
       
   114      * Starts the operation.
       
   115      */
       
   116     TInt Start();
       
   117 
       
   118 
       
   119     /**
       
   120      *
       
   121      */
       
   122     TInt Pause();
       
   123     
       
   124     
       
   125     TInt Resume();
       
   126     
       
   127     /**
       
   128      * @see CNcdBaseOperation::Cancel()
       
   129      */
       
   130     void Cancel();    
       
   131     
       
   132 
       
   133 public: // From MCatalogsHttpObserver
       
   134 
       
   135     /**
       
   136      * @see MCatalogsHttpObserver::HandleHttpEvent()
       
   137      */
       
   138     void HandleHttpEventL( 
       
   139         MCatalogsHttpOperation& aOperation, 
       
   140         TCatalogsHttpEvent aEvent );
       
   141         
       
   142     /**
       
   143      * @see MCatalogsHttpObserver::HandleHttpError()
       
   144      */
       
   145     TBool HandleHttpError(
       
   146         MCatalogsHttpOperation& aOperation,
       
   147         TCatalogsHttpError aError );
       
   148 
       
   149 
       
   150 public:
       
   151        
       
   152     /**
       
   153      * Externalize
       
   154      *
       
   155      * @param aStream Target stream
       
   156      */ 
       
   157     void ExternalizeL( RWriteStream& aStream ) const;
       
   158     
       
   159     
       
   160     /**
       
   161      * Internalize
       
   162      *
       
   163      * @param aStream Source stream
       
   164      */
       
   165     void InternalizeL( RReadStream& aStream ); 
       
   166 
       
   167 
       
   168 protected: // From CNcdBaseOperation
       
   169 
       
   170     /**
       
   171      * @see CNcdBaseOperation::RunOperation()
       
   172      */
       
   173     TInt RunOperation();        
       
   174     
       
   175     
       
   176 protected:
       
   177 
       
   178     // Constructor
       
   179     CNcdDownloadSubOperation(  
       
   180         CNcdGeneralManager& aGeneralManager,
       
   181         MCatalogsHttpSession& aHttpSession,
       
   182         MCatalogsSession& aSession );
       
   183         
       
   184     void ConstructL( 
       
   185         const TDesC& aUri, 
       
   186         const TDesC& aDestination,
       
   187         MNcdOperationObserver& aObserver );
       
   188 
       
   189 
       
   190     void ConstructL( 
       
   191         MNcdOperationObserver& aObserver );
       
   192 
       
   193 private:
       
   194 
       
   195     void NotifyObserversComplete( TInt aError );
       
   196     
       
   197     void NotifyObserversProgress();    
       
   198         
       
   199 private:
       
   200 
       
   201     MCatalogsHttpSession& iHttpSession;
       
   202     MCatalogsHttpOperation* iDownload;
       
   203     TNcdDownloadState iDownloadState;        
       
   204     };
       
   205 
       
   206 #endif // C_NCDDOWNLOADSUBOPERATION_H