ncdengine/provider/server/inc/ncdoperationmanager.h
changeset 4 32704c33136d
equal deleted inserted replaced
-1:000000000000 4:32704c33136d
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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:   Contains CNcdOperationManager class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NCD_OPERATION_MANAGER_H
       
    20 #define NCD_OPERATION_MANAGER_H
       
    21 
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <e32cmn.h>
       
    25 
       
    26 #include "catalogscommunicable.h"
       
    27 #include "ncdoperationremovehandler.h"
       
    28 #include "ncdoperationdatatypes.h"
       
    29 #include "ncdoperationqueue.h"
       
    30 
       
    31 class CNcdProvider;
       
    32 class CNcdBaseOperation;
       
    33 class MNcdStorageManager;
       
    34 class MNcdProtocol;
       
    35 class MCatalogsHttpSession;
       
    36 class MCatalogsSmsSession;
       
    37 class CNcdNodeManager;
       
    38 class CNcdPurchaseHistoryDb;
       
    39 class MNcdConfigurationManager;
       
    40 class MCatalogsContext;
       
    41 class MCatalogsAccessPointManager;
       
    42 class MNcdStorage;
       
    43 class CNcdSubscriptionManager;
       
    44 class CNcdNodeIdentifier;
       
    45 class CNcdReportManager;
       
    46 class CNcdGeneralManager;
       
    47 
       
    48 /**
       
    49  *  CNodeManager provides functions to ...
       
    50  *  @lib ?library
       
    51  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    52  */
       
    53 class CNcdOperationManager : public CCatalogsCommunicable, 
       
    54                              public MNcdOperationRemoveHandler,
       
    55                              public MNcdOperationQueue
       
    56     {
       
    57 
       
    58 public:
       
    59 
       
    60     /**
       
    61      * NewL
       
    62      *
       
    63      * @param aStorageManager Storage manager
       
    64      * @return CNcdOperationManager* Pointer to the created object 
       
    65      * of this class.
       
    66      */
       
    67     static CNcdOperationManager* NewL(
       
    68         CNcdProvider& aProvider,
       
    69         CNcdGeneralManager& aGeneralManager,        
       
    70         CNcdSubscriptionManager& aSubscriptionManager );
       
    71 
       
    72 
       
    73 
       
    74     /**
       
    75      * Destructor
       
    76      *
       
    77      * Deletes the nodes from the node cache.
       
    78      */
       
    79     virtual ~CNcdOperationManager();
       
    80 
       
    81 
       
    82     /**
       
    83      * @leave
       
    84      * @param 
       
    85      * @return 
       
    86      */
       
    87     void CreateLoadNodeOperationRequestL(
       
    88         MCatalogsBaseMessage& aMessage );
       
    89         
       
    90     /**
       
    91      * @leave
       
    92      * @param 
       
    93      * @return 
       
    94      */
       
    95     //virtual void CreateLoadNodeChildrenOperationRequestL(
       
    96     //    MCatalogsBaseMessage& aMessage );
       
    97     
       
    98     /**
       
    99      * @leave
       
   100      * @param 
       
   101      * @return 
       
   102      */
       
   103     void CreateLoadRootNodeOperationRequestL(
       
   104         MCatalogsBaseMessage& aMessage );
       
   105 
       
   106     /**
       
   107      * @leave
       
   108      * @param 
       
   109      * @return 
       
   110      */
       
   111     void CreateLoadBundleNodeOperationRequestL(
       
   112         MCatalogsBaseMessage& aMessage );
       
   113 
       
   114 
       
   115     /**
       
   116      * @leave
       
   117      * @param 
       
   118      * @return 
       
   119      */
       
   120     void CreateDownloadOperationRequestL(
       
   121         MCatalogsBaseMessage& aMessage );
       
   122     
       
   123 
       
   124     /**
       
   125      * @leave
       
   126      * @param 
       
   127      * @return 
       
   128      */
       
   129     void CreatePurchaseOperationRequestL(
       
   130         MCatalogsBaseMessage& aMessage );
       
   131 
       
   132 
       
   133     /**
       
   134      * @leave
       
   135      * @param 
       
   136      * @return 
       
   137      */
       
   138     void CreateInstallOperationRequestL(
       
   139         MCatalogsBaseMessage& aMessage );
       
   140 
       
   141 
       
   142     /**
       
   143      * @leave
       
   144      * @param 
       
   145      * @return 
       
   146      */
       
   147     void CreateSilentInstallOperationRequestL(
       
   148         MCatalogsBaseMessage& aMessage );
       
   149 
       
   150 
       
   151     /**
       
   152      * @leave
       
   153      * @param 
       
   154      * @return 
       
   155      */
       
   156     void CreateRightsObjectOperationRequestL(
       
   157         MCatalogsBaseMessage& aMessage );
       
   158 
       
   159     /**
       
   160      * @leave
       
   161      * @param 
       
   162      * @return 
       
   163      */
       
   164     void CreateSubscriptionOperationRequestL(
       
   165         MCatalogsBaseMessage& aMessage );
       
   166 
       
   167 
       
   168     
       
   169     /**
       
   170      * @leave
       
   171      * @param 
       
   172      * @return 
       
   173      */
       
   174     void CreateCreateAccessPointOperationRequestL(
       
   175         MCatalogsBaseMessage& aMessage );
       
   176     
       
   177 
       
   178 
       
   179     /**
       
   180      * @leave
       
   181      * @param 
       
   182      * @return 
       
   183      */
       
   184     void CreateSendHttpRequestOperationRequestL(
       
   185         MCatalogsBaseMessage& aMessage );
       
   186     
       
   187 
       
   188     /**
       
   189      * @leave
       
   190      * @param 
       
   191      * @return 
       
   192      */
       
   193     void RestoreDownloadOperationsRequestL(
       
   194         MCatalogsBaseMessage& aMessage );
       
   195 
       
   196 
       
   197     /**
       
   198      * @leave
       
   199      * @param 
       
   200      * @return 
       
   201      */
       
   202     void CreateServerReportOperationRequestL(
       
   203         MCatalogsBaseMessage& aMessage );
       
   204 
       
   205 
       
   206     CNcdReportManager& ReportManagerL( MCatalogsContext& aContext );
       
   207 
       
   208 
       
   209 public: // CCatalogsCommunicable
       
   210 
       
   211     /**
       
   212      * @see CCatalogsCommunicable::ReceiveMessage
       
   213      */
       
   214     void ReceiveMessage( MCatalogsBaseMessage* aMessage,
       
   215                                  TInt aFunctionNumber );
       
   216 
       
   217     /**
       
   218      * @see CCatalogsCommunicable::CounterPartLost
       
   219      */
       
   220     void CounterPartLost( const MCatalogsSession& aSession );
       
   221 
       
   222 
       
   223 public: // MNcdOperationRemoveHandler
       
   224 
       
   225     /**
       
   226      * @see MNcdOperationRemoveHandler::RemoveOperation()
       
   227      */
       
   228     void RemoveOperation( CNcdBaseOperation& aOperation );
       
   229     
       
   230 public: // MNcdOperationQueue
       
   231 
       
   232     /**
       
   233      * @see MNcdOperationQueue
       
   234      */     
       
   235     void QueueOperationL( CNcdBaseOperation& aOperation );
       
   236     
       
   237     /**
       
   238      * @see MNcdOperationQueue
       
   239      */
       
   240     void QueuedOperationComplete( CNcdBaseOperation& aOperation );
       
   241         
       
   242 
       
   243 protected:
       
   244 
       
   245     /**
       
   246      * Constructor
       
   247      */
       
   248     CNcdOperationManager(
       
   249         CNcdProvider& aProvider,
       
   250         CNcdGeneralManager& aGeneralManager,        
       
   251         CNcdSubscriptionManager& aSubscriptionManager );
       
   252 
       
   253     /**
       
   254      * ConstructL
       
   255      */
       
   256     void ConstructL();
       
   257 
       
   258 
       
   259 private:
       
   260 
       
   261     // Prevent if not implemented
       
   262     CNcdOperationManager( const CNcdOperationManager& aObject );
       
   263     CNcdOperationManager& operator =( const CNcdOperationManager& aObject );
       
   264 
       
   265 
       
   266 private:
       
   267 
       
   268     MCatalogsHttpSession& HttpSessionL( MCatalogsContext& aContext );
       
   269     MCatalogsSmsSession& SmsSessionL( MCatalogsContext& aContext );
       
   270 
       
   271 
       
   272     MNcdStorage* StorageL( const TDesC& aClientUid,
       
   273         const TDesC& aNamespace ) const;
       
   274         
       
   275     /**
       
   276      * This function is called from the proxy side when the proxy
       
   277      * is deleted.
       
   278      *
       
   279      * @param aMessage Contains data from the proxy and can be used
       
   280      * to send data back to proxy.
       
   281      */
       
   282     void ReleaseRequest( MCatalogsBaseMessage& aMessage ) const;
       
   283 
       
   284 
       
   285     /**
       
   286      * Checks if a download matching the criteria already exists
       
   287      */
       
   288     TBool DownloadExistsL( MCatalogsBaseMessage& aMessage, 
       
   289         const CNcdNodeIdentifier& aIdentifier, 
       
   290         TNcdDownloadDataType aType, 
       
   291         TInt aIndex );
       
   292 
       
   293     /**
       
   294      * Checks if there are load bundle node operations
       
   295      * in operation queue.
       
   296      */        
       
   297     TBool QueuedLoadBundleOperationsExists() const;
       
   298     
       
   299     /**
       
   300      * Checks that is there an operation running for the same metadata for another client.
       
   301      *
       
   302      * @note If aNodeIdentifier identifies some root node, aCompareIdsDirectly value is
       
   303      * forced to be ETrue inside this function.
       
   304      *
       
   305      * @param aNodeIdentifier Id to check for.
       
   306      * @param aContext Context of the client requesting an operation.
       
   307      * @param aCompareIdsDirectly If true, then the aNodeIdentifier is compared directly
       
   308      * with operations' identifiers. This is needed for cases where the operations' identifiers don't
       
   309      * contain a proper node identifier (generic file download).
       
   310      * @return ETrue if another op is running for the metadata.
       
   311      */    
       
   312     TBool ParallelOperationExistsForMetadataL( const CNcdNodeIdentifier& aNodeIdentifier,
       
   313         const MCatalogsContext& aContext,
       
   314         TBool aCompareIdsDirectly = EFalse ) const;
       
   315 
       
   316     /**
       
   317      * Retrieves node id from operation, if possible.
       
   318      *
       
   319      * @param aOperation Operation to get id from.
       
   320      * @return Id or NULL.
       
   321      */
       
   322     const CNcdNodeIdentifier* GetNodeIdFromOperation( const CNcdBaseOperation& aOperation ) const;
       
   323         
       
   324 private: // data
       
   325 
       
   326     CNcdProvider&       iProvider;
       
   327 
       
   328     CNcdGeneralManager& iGeneralManager;
       
   329     
       
   330     // Storage manager
       
   331     MNcdStorageManager& iStorageManager;    
       
   332     
       
   333     // Protocol handler manages protocol sessions and provides access
       
   334     // to response parser and request processing
       
   335     MNcdProtocol& iProtocolHandler;
       
   336         
       
   337     CNcdNodeManager& iNodeManager;
       
   338     
       
   339     // Purchase history.
       
   340     CNcdPurchaseHistoryDb& iPurchaseHistory;
       
   341 
       
   342     MNcdConfigurationManager& iConfigurationManager;
       
   343     
       
   344     MCatalogsAccessPointManager& iAccessPointManager;
       
   345 
       
   346     CNcdSubscriptionManager& iSubscriptionManager;
       
   347 
       
   348     // This array contains all the operations that have been created.
       
   349     RPointerArray< CNcdBaseOperation > iOperationCache;
       
   350     
       
   351     // This is an array of queued operations. Only one load
       
   352     // bundle node operation can be running.
       
   353     RPointerArray< CNcdBaseOperation > iOperationQueue;
       
   354     };
       
   355 
       
   356 
       
   357 #endif // NCD_OPERATION_MANAGER_H