ncdengine/provider/server/inc/ncdnodeupgradeimpl.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     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 CNcdNodeUpgrade class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NCD_NODE_UPGRADE_H
       
    20 #define NCD_NODE_UPGRADE_H
       
    21 
       
    22 
       
    23 // For streams
       
    24 #include <s32mem.h>
       
    25 // For array
       
    26 #include <e32cmn.h>
       
    27 
       
    28 #include "ncdcommunicable.h"
       
    29 #include "ncdstoragedataitem.h"
       
    30 #include "ncdnodeclassids.h"
       
    31 
       
    32 class MNcdPreminetProtocolDataEntity;
       
    33 class CNcdDependencyInfo;
       
    34 class CNcdNodeMetaData;
       
    35 class CNcdDownloadInfo;
       
    36 class CNcdAttributes;
       
    37 
       
    38 
       
    39 /**
       
    40  *  This server side class contains the data and the functionality
       
    41  *  that the proxy objects will use to internalize itself.
       
    42  *
       
    43  *  This object should be added to the session. So, it will be usable
       
    44  *  in the proxy side by using the handle gotten during addition. 
       
    45  *  The handle is used to identify to what object the proxy directs 
       
    46  *  the function call.  When objects are added to sessions, 
       
    47  *  multiple handles may be gotten for the same object if addition is 
       
    48  *  done multiple times.
       
    49  *
       
    50  *  @lib ?library
       
    51  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    52  */
       
    53 class CNcdNodeUpgrade : public CNcdCommunicable,
       
    54                         public MNcdStorageDataItem
       
    55     {
       
    56 public:
       
    57 
       
    58     enum TUpgradeData
       
    59         {
       
    60         EUpgradeDataVersion = 0,
       
    61         EUpgradeDataUid,
       
    62         
       
    63         // Keep this last
       
    64         EUpgradeDataInternal
       
    65         };
       
    66 public:
       
    67     /**
       
    68      * NewL
       
    69      *
       
    70      * @param aParentMetaData Metadata that owns this class object.
       
    71      * @return CNcdNodeUpgrade* Pointer to the created object 
       
    72      * of this class.
       
    73      */
       
    74     static CNcdNodeUpgrade* NewL( CNcdNodeMetaData& aParentMetaData );
       
    75 
       
    76     /**
       
    77      * NewLC
       
    78      *
       
    79      * @param aParentMetaData Metadata that owns this class object.
       
    80      * @return CNcdNodeUpgrade* Pointer to the created object 
       
    81      * of this class.
       
    82      */
       
    83     static CNcdNodeUpgrade* NewLC( CNcdNodeMetaData& aParentMetaData );
       
    84 
       
    85 
       
    86     /**
       
    87      * Destructor
       
    88      *
       
    89      * @note Because this is CCatalogsCommunicable function the
       
    90      * session that owns this object should delete this class object.
       
    91      * So, instead of directly deleting this object from some other
       
    92      * class. Close-method should be used instead.
       
    93      */
       
    94     virtual ~CNcdNodeUpgrade();
       
    95 
       
    96 
       
    97     /**
       
    98      * Retrieves the data type that informs what class the data is for.
       
    99      * By checking the data type information, an InternalizeL function
       
   100      * of a right class can be called when the object data is set
       
   101      * from the storage.
       
   102      * The data type may be decided and set in a object that creates this 
       
   103      * class object.
       
   104      *
       
   105      * @return NcdNodeClassIds::TNcdNodeClassId Describes the data type. 
       
   106      */
       
   107     NcdNodeClassIds::TNcdNodeClassId ClassId() const;
       
   108 
       
   109 
       
   110     /**
       
   111      * @return RPointerArray<CNcdDownloadInfo>& Contains list of content targets. 
       
   112      * This list provides objects that contain information about the contents 
       
   113      * that this class object can upgrade.
       
   114      */
       
   115     const RPointerArray<CNcdDownloadInfo>& ContentTargets() const;
       
   116 
       
   117 
       
   118     /**
       
   119      * @return RPointerArray<CNcdDependencyInfo>& Contains list of node targets. 
       
   120      * This list provides objects that contain metadata ids and other information 
       
   121      * of the nodes that this class object can upgrade.
       
   122      */
       
   123     const RPointerArray<CNcdDependencyInfo>& NodeTargets() const;
       
   124     
       
   125 
       
   126     /**
       
   127      * This function is called when the owner of this object
       
   128      * wants to internalize the content according to the data
       
   129      * that has been received from the parser.
       
   130      * 
       
   131      * @param aData The data is set in the protocol parser and can
       
   132      * be used to initialize this class object.
       
   133      * @param aVersion Version number of this item. Used to check whether this actually
       
   134      * upgrades anything     
       
   135      */
       
   136     void InternalizeL( MNcdPreminetProtocolDataEntity& aData, const TDesC& aVersion );
       
   137 
       
   138 
       
   139     /**
       
   140      * Checks if all of the upgradable items have been installed already     
       
   141      */
       
   142     TBool AllUpgradesInstalledL() const;
       
   143     
       
   144     /**
       
   145      * Sets content upgrade data
       
   146      *
       
   147      * If aContentUpgrades is true, aUid and aVersion will be 
       
   148      * available on the proxy side
       
   149      */
       
   150     void SetContentUpgradesL( 
       
   151         TBool aContentUpgrades, 
       
   152         const TUid& aUid,
       
   153         const TDesC& aVersion );
       
   154     
       
   155     TBool ContentUpgrades() const;
       
   156     
       
   157 public: // MNcdStorageDataItem 
       
   158 
       
   159     // These functions are used to get the data from and to insert the data
       
   160     // into the database using by the given stream.
       
   161 
       
   162     /**
       
   163      * @see MNcdStorageDataItem::ExternalizeL
       
   164      */
       
   165     virtual void ExternalizeL( RWriteStream& aStream );
       
   166 
       
   167 
       
   168     /**
       
   169      * @see MNcdStorageDataItem::InternalizeL
       
   170      */
       
   171     virtual void InternalizeL( RReadStream& aStream );
       
   172 
       
   173 
       
   174 public: // CCatalogsCommunicable
       
   175 
       
   176     /**
       
   177      * @see CCatalogsCommunicable::ReceiveMessage
       
   178      */
       
   179     virtual void ReceiveMessage( MCatalogsBaseMessage* aMessage,
       
   180                                  TInt aFunctionNumber );
       
   181 
       
   182     /**
       
   183      * @see CCatalogsCommunicable::CounterPartLost
       
   184      */
       
   185     virtual void CounterPartLost( const MCatalogsSession& aSession );
       
   186 
       
   187 
       
   188 protected:
       
   189 
       
   190     /**
       
   191      * Constructor
       
   192      *
       
   193      * @param aParentMetaData Metadata that owns this class object.
       
   194      * @param aClassId Identifies this class. 
       
   195      * Is set in the NewLC function 
       
   196      */
       
   197     CNcdNodeUpgrade( CNcdNodeMetaData& aParentMetaData,
       
   198                      NcdNodeClassIds::TNcdNodeClassId aClassId );
       
   199 
       
   200     /**
       
   201      * ConstructL
       
   202      */
       
   203     virtual void ConstructL();
       
   204     
       
   205 
       
   206     // These functions are called from the ReceiveMessage when
       
   207     // the given function id has matched to the function.
       
   208 
       
   209     /**
       
   210      * This function is called when the proxy wants to get the
       
   211      * data from the serverside. This function calls the
       
   212      * InternalizeDataForRequestL which may be overloaded in the
       
   213      * child classes
       
   214      * @param aMessage Contains data from the proxy and can be used
       
   215      * to send data back to proxy
       
   216      */
       
   217     void InternalizeRequestL( MCatalogsBaseMessage& aMessage );
       
   218         
       
   219     /**
       
   220      * This function writes the object data to the stream. 
       
   221      * The stream content will be sent to the proxy that requested the data.
       
   222      * Child classes should add their own data after this parent data.
       
   223      * @param aStream The data content of this class object will be written
       
   224      * into this stream.
       
   225      */
       
   226     virtual void ExternalizeDataForRequestL( RWriteStream& aStream );
       
   227 
       
   228     /**
       
   229      * This function is called from the proxy side when the proxy
       
   230      * is deleted.
       
   231      * @param aMessage Contains data from the proxy and can be used
       
   232      * to send data back to proxy
       
   233      */
       
   234     void ReleaseRequest( MCatalogsBaseMessage& aMessage ) const;
       
   235 
       
   236 
       
   237 private:
       
   238 
       
   239     // Prevent these two if they are not implemented
       
   240     CNcdNodeUpgrade( const CNcdNodeUpgrade& aObject );
       
   241     CNcdNodeUpgrade& operator =( const CNcdNodeUpgrade& aObject );
       
   242 
       
   243 
       
   244     // Functions to help externalize and internalize data
       
   245     void ExternalizeNodeUpgradeArrayL( RWriteStream& aStream );
       
   246     void InternalizeNodeUpgradeArrayL( RReadStream& aStream );
       
   247 
       
   248     void ExternalizeContentUpgradeArrayForRequestL( RWriteStream& aStream );
       
   249     void ExternalizeContentUpgradeArrayL( RWriteStream& aStream );
       
   250     void InternalizeContentUpgradeArrayL( RReadStream& aStream );
       
   251 
       
   252 
       
   253 private: // data
       
   254     
       
   255     // Metadata that owns this class object.
       
   256     CNcdNodeMetaData& iParentMetaData;
       
   257     
       
   258     // The class id identifies this class. The id may be used to identify
       
   259     // what kind of class object is created when data is gotten from the db.
       
   260     NcdNodeClassIds::TNcdNodeClassId iClassId;
       
   261 
       
   262     // The message is set when ReceiveMessage is called. The message
       
   263     // is used in the CounterPartLost-function that informs the message
       
   264     // if the session has been lost.
       
   265     MCatalogsBaseMessage* iMessage;
       
   266     
       
   267     RPointerArray<CNcdDependencyInfo> iUpgradeNodeTargets;
       
   268     RPointerArray<CNcdDownloadInfo> iUpgradeContentTargets;
       
   269     
       
   270     TBool iContentUpgrades;
       
   271     
       
   272     // If this node is an content upgrade (content version has been
       
   273     // updated in the server) this contains the old version number    
       
   274     CNcdAttributes* iUpgradeData;
       
   275     };
       
   276     
       
   277 #endif // NCD_NODE_UPGRADE_H