iaupdate/IAD/engine/controller/inc/iaupdatenodecontainer.h
changeset 0 ba25891c3a9e
child 11 3ba40be8e484
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2009 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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef IAUPDATENODECONTAINER_H
       
    21 #define IAUPDATENODECONTAINER_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 
       
    26 class CIAUpdateController;
       
    27 class CIAUpdateNode;
       
    28 class CIAUpdateFwNode;
       
    29 class CIAUpdateNodeDependency;
       
    30 
       
    31 class CIAUpdateNodeContainer : public CBase
       
    32     {
       
    33     
       
    34 public:
       
    35 
       
    36     static CIAUpdateNodeContainer *NewLC( 
       
    37         CIAUpdateController& aController );
       
    38     static CIAUpdateNodeContainer *NewL(
       
    39         CIAUpdateController& aController );
       
    40     
       
    41     virtual ~CIAUpdateNodeContainer();
       
    42 
       
    43     
       
    44     /**
       
    45      * Add a node to the node container.
       
    46      *
       
    47      * @note Caller should take care that same node is inserted only once.
       
    48      * This function does not do any checks. So, if the node is inserted more than once
       
    49      * it will be deleted multiple times which will result to panic.
       
    50      *
       
    51      * @note If the content of the given node can be thought as installed or if it can not be
       
    52      * installed, then this node will be immediately deleted. So, the node pointer may become 
       
    53      * obsolete when this function is called. Also, if this function is about to leave, 
       
    54      * the node will automatically be deleted.
       
    55      *
       
    56      * @param aNode Node to be added. Ownership is transferred.
       
    57      **/
       
    58     void AddNodeL( CIAUpdateNode* aNode );
       
    59 
       
    60 
       
    61     /**
       
    62      * Add an excess node to the node container. These nodes are some extra nodes that a user
       
    63      * of this class wants to store into the container separately. They are also handled
       
    64      * separately and no intelligence are done to these nodes. For example, dependecy chains
       
    65      * are not checked here. This function will also automatically make the node hidden.
       
    66      *
       
    67      * @note Caller should take care that same node is inserted only once.
       
    68      * This function does not do any checks. So, if the node is inserted more than once
       
    69      * it will be deleted multiple times which will result to panic.
       
    70      *
       
    71      * @param aNode Node to be added. Ownership is transferred.
       
    72      **/
       
    73     void AddExcessNodeL( CIAUpdateNode* aNode );
       
    74 
       
    75 
       
    76     /**
       
    77      * Add a firmware update node to the node container.
       
    78      *
       
    79      * @note Caller should take care that same node is inserted only once.
       
    80      * This function does not do any checks. So, if the node is inserted more than once
       
    81      * it will be deleted multiple times which will result to panic.
       
    82      *
       
    83      * @note If the content of the given node can be thought as installed or if it can not be
       
    84      * installed, then this node will be immediately deleted. So, the node pointer may become 
       
    85      * obsolete when this function is called. Also, if this function is about to leave, 
       
    86      * the node will automatically be deleted.
       
    87      *
       
    88      * @param aNode Node to be added. Ownership is transferred.
       
    89      **/
       
    90     void AddFwNodeL( CIAUpdateFwNode* aNode );
       
    91 
       
    92     
       
    93     /**
       
    94      * Clears node container and frees memory. 
       
    95      * Is automatically called during container destruction.
       
    96      **/
       
    97     void Clear();
       
    98     
       
    99 
       
   100     /**
       
   101      * @return const RPointerArray< CIAUpdateNode >& All nodes of the container, including ones that
       
   102      * are not header nodes. Excess nodes are not included here.
       
   103      */
       
   104     const RPointerArray< CIAUpdateNode >& AllNodes() const;
       
   105 
       
   106 
       
   107     /**
       
   108      * @return const RPointerArray< CIAUpdateNode >& Excess nodes of the container.
       
   109      */
       
   110     const RPointerArray< CIAUpdateNode >& ExcessNodes() const;
       
   111     
       
   112     
       
   113     /**
       
   114      * Gets current head nodes of nodes added to this container. Also updates node dependencies by calling
       
   115      * UpdateDependenciesL()
       
   116      * Head node is a node that represents the latest update available to a software installed on the device.
       
   117      * They should be the primary nodes to be offered to the user to make his update selections.
       
   118      * If a node is a head node it does NOT mean that it always can be installed, because if might have
       
   119      * dependencies to other nodes that cannot be installed for whatever reason.
       
   120      * @return const RPointerArray< CIAUpdateNode >& Head nodes. Ownership of the arary and its contents are
       
   121      * not transferred.
       
   122      **/
       
   123     const RPointerArray< CIAUpdateNode >& HeadNodesL();
       
   124 
       
   125 
       
   126     /**
       
   127      * @return const RPointerArray< CIAUpdateFwNode >& Firmware update nodes
       
   128      * of the container.
       
   129      */
       
   130     const RPointerArray< CIAUpdateFwNode >& FwNodes();
       
   131 
       
   132     
       
   133 private:
       
   134 
       
   135     /**
       
   136      * Constructor
       
   137      */
       
   138     CIAUpdateNodeContainer( CIAUpdateController& aController );
       
   139     
       
   140     /**
       
   141      * ConstructL
       
   142      */    
       
   143     void ConstructL();
       
   144 
       
   145 
       
   146     // Prevent these if not implemented
       
   147     CIAUpdateNodeContainer( const CIAUpdateNodeContainer& aObject );
       
   148     CIAUpdateNodeContainer& operator =( const CIAUpdateNodeContainer& aObject );
       
   149 
       
   150 
       
   151     /**
       
   152      * Updates node dependencies.
       
   153      **/
       
   154     void UpdateDependenciesL();    
       
   155 
       
   156     TInt UpdateNodeDependenciesL( CIAUpdateNode& aNode, 
       
   157                                   TInt aDepth );
       
   158 
       
   159     TInt FindBestMatchL( CIAUpdateNode& aNode, 
       
   160                          CIAUpdateNodeDependency& aDependency,
       
   161                          TInt aDepth );
       
   162     
       
   163     void FindMatchesL( RPointerArray<CIAUpdateNode>& aNodes, 
       
   164                        const CIAUpdateNodeDependency& aDependency );
       
   165 
       
   166 
       
   167     void ManageHeaderNodesL();
       
   168     
       
   169     /**
       
   170      * Updates the head node list.
       
   171      * If the node content has not been installed yet or if the content
       
   172      * is newer version than installed one, then the node is thought as
       
   173      * head node.
       
   174      * @param aNode Ownership is transferred.
       
   175      */
       
   176     void UpdateHeadNodeListL( CIAUpdateNode& aNode );
       
   177     
       
   178     TBool ReplaceRecommendedL( const CIAUpdateNode& aCurrentNode, 
       
   179                                const CIAUpdateNode& aNewNode ) const;
       
   180 
       
   181     TBool PackageTypeAcceptedL( const CIAUpdateNode& aNode ) const;
       
   182 
       
   183     TBool NodeAlreadyExists( const CIAUpdateNode& aNode ) const;
       
   184 
       
   185     // Creates bundle for self update purposes.
       
   186     // Sets the possible existing self updater and NCD head nodes to hidden.
       
   187     // So, they will not be provided for UI. After, RemoveHiddenNodesFromHeadList
       
   188     // function is called.
       
   189     void CreateSelfUpdateBundleL();
       
   190 
       
   191     // Removes all possible existing head nodes that are marked as hidden from the head list.
       
   192     void RemoveHiddenNodesFromHeadList();
       
   193 
       
   194     // This will start to set the correct values to the service pack 
       
   195     // dependency nodes.
       
   196     void HandleServicePacksL();
       
   197 
       
   198     // Checks if newer version of the node is already installed.
       
   199     // Check is passed if newer version is not installed.
       
   200     // If same version of the node is installed, makes it hidden.
       
   201     TBool InstallCheckL( CIAUpdateNode& aNode ) const;
       
   202 
       
   203     
       
   204 private: // data
       
   205 
       
   206     // Controller object
       
   207     CIAUpdateController& iController;
       
   208 
       
   209     // This array will contain all the nodes that belong to the intact dependency chains.
       
   210     // These nodes are head nodes and possible dependency nodes (for example previous versions
       
   211     // that are required).
       
   212     // Array owns the nodes. And they will be deleted when the array is cleared.
       
   213     RPointerArray<CIAUpdateNode> iNodes;
       
   214     
       
   215     // This array will contain only the head nodes after all the dependency checks are done.
       
   216     // Array does not own the nodes.
       
   217     RPointerArray<CIAUpdateNode> iHeadNodes;
       
   218         
       
   219     // This array will contain all the nodes excess nodes that are given by the user of this
       
   220     // class object. The excess nodes are just stored here and no normal actions are directed 
       
   221     // to them by the operations of this class object.
       
   222     RPointerArray<CIAUpdateNode> iExcessNodes;
       
   223 
       
   224     // This array will contain all the firmware update nodes.
       
   225     // Array owns the nodes.
       
   226     RPointerArray<CIAUpdateFwNode> iFwNodes;
       
   227 
       
   228     };
       
   229 
       
   230 #endif  //  IAUPDATENODECONTAINER_H