ncdengine/provider/server/inc/ncdnodemetadataimpl.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:   Contains CNcdNodeMetaData class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NCD_NODE_META_DATA_H
       
    20 #define NCD_NODE_META_DATA_H
       
    21 
       
    22 
       
    23 #include <e32cmn.h>
       
    24 #include <s32mem.h>
       
    25 #include <badesca.h>
       
    26 
       
    27 #include "catalogscommunicable.h"
       
    28 #include "ncdnodemanager.h"
       
    29 #include "ncdstoragedataitem.h"
       
    30 #include "ncdnodeclassids.h"
       
    31 
       
    32 
       
    33 class CNcdNodeIdentifier;
       
    34 class MNcdPreminetProtocolDataEntity;
       
    35 class MNcdPreminetProtocolPurchaseOption;
       
    36 class CNcdNodeIcon;
       
    37 class CNcdNodeScreenshot;
       
    38 class CNcdNodeSkin;
       
    39 class CNcdPurchaseOptionImpl;
       
    40 class CNcdNodeDisclaimer;
       
    41 class CNcdNodeUriContent;
       
    42 class CNcdNodeDownload;
       
    43 class CNcdNodeInstall;
       
    44 class CNcdNodeContentInfo;
       
    45 class CNcdNodePreview;
       
    46 class CNcdNodeUpgrade;
       
    47 class CNcdNodeDependency;
       
    48 class CNcdServerSubscribableContent;
       
    49 class CNcdPurchaseDetails;
       
    50 class MNcdPurchaseDetails;
       
    51 class CNcdNodeUserData;
       
    52 class CNcdKeyValuePair;
       
    53 
       
    54 /**
       
    55  *  CNcdNodeMetaData ...
       
    56  *  @lib ?library
       
    57  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    58  */
       
    59 class CNcdNodeMetaData : public CCatalogsCommunicable,
       
    60                          public MNcdStorageDataItem
       
    61     {
       
    62 
       
    63 public:
       
    64 
       
    65     /**
       
    66      * Destructor
       
    67      */
       
    68     virtual ~CNcdNodeMetaData();
       
    69 
       
    70 
       
    71     /**
       
    72      * @return The nodemanager that has created this node metadata.
       
    73      */
       
    74     CNcdNodeManager& NodeManager() const;
       
    75 
       
    76 
       
    77     /**
       
    78      *
       
    79      */
       
    80     const CNcdNodeIdentifier& Identifier() const;
       
    81     
       
    82 
       
    83     /**
       
    84      * Retrieves the data type that informs what class the data is for.
       
    85      * By checking the data type information, an InternalizeL function
       
    86      * of a right class can be called when the object data is set
       
    87      * from the storage.
       
    88      * The data type may be decided and set in a factory that creates object.
       
    89      * The factory should know which integer is reserved for which class.
       
    90      *
       
    91      * @return NcdNodeClassIds::TNcdNodeClassId Describes the data type. 
       
    92      */
       
    93     NcdNodeClassIds::TNcdNodeClassId ClassId() const;
       
    94 
       
    95 
       
    96     /**
       
    97      *
       
    98      */
       
    99     const TDesC& TimeStamp() const;
       
   100 
       
   101     /**
       
   102      *
       
   103      */
       
   104     const TDesC& NodeName() const;
       
   105     
       
   106     void SetNodeNameL( const TDesC& aName );
       
   107 
       
   108     /**
       
   109      *
       
   110      */
       
   111     const TDesC& Description() const;
       
   112     
       
   113     void SetDescriptionL( const TDesC& aDescription);
       
   114     
       
   115     /**
       
   116      * Returns the layout type if defined.
       
   117      */
       
   118     const TDesC& LayoutType() const;
       
   119 
       
   120     /**
       
   121      * @exception KErrNotFound if the disclaimer does not exist.
       
   122      */
       
   123     const CNcdNodeDisclaimer& DisclaimerL() const;
       
   124     
       
   125     /**
       
   126      * Disclaimer setter. Used by bundle load operation for setting
       
   127      * the bundle disclaimer
       
   128      */
       
   129     void SetDisclaimer( CNcdNodeDisclaimer* aDisclaimer );
       
   130 
       
   131     /**
       
   132      *
       
   133      */
       
   134     CNcdNodeIcon& IconL() const;
       
   135     
       
   136     void SetIcon( CNcdNodeIcon* aIcon );
       
   137 
       
   138     /**
       
   139      *
       
   140      */
       
   141     const CNcdNodeScreenshot& ScreenshotL() const;
       
   142 
       
   143     /**
       
   144      *
       
   145      */
       
   146     const CNcdNodeSkin& SkinL() const;
       
   147 
       
   148 
       
   149     /**
       
   150      *
       
   151      */
       
   152     CNcdNodePreview& PreviewL() const;
       
   153     
       
   154     
       
   155     /**
       
   156      *
       
   157      */
       
   158     const CNcdNodeUpgrade& UpgradeL() const;
       
   159 
       
   160 
       
   161     /**
       
   162      *
       
   163      */
       
   164     const CNcdNodeDependency& DependencyL() const;
       
   165 
       
   166     
       
   167     /**
       
   168      * Content info getter
       
   169      *
       
   170      * @return Content info
       
   171      */     
       
   172     const CNcdNodeContentInfo& ContentInfoL() const;
       
   173 
       
   174 
       
   175     const CNcdNodeDisclaimer& MoreInfoL() const;
       
   176 
       
   177     /**
       
   178      *
       
   179      */
       
   180     const CNcdServerSubscribableContent* SubscribableContent() const;
       
   181     
       
   182     /**
       
   183      *
       
   184      */
       
   185     const RPointerArray<CNcdPurchaseOptionImpl>& PurchaseOptions() const;
       
   186 
       
   187     CNcdPurchaseOptionImpl& PurchaseOptionByIdL(
       
   188         const TDesC& aPurchaseOptionId ) const;
       
   189     
       
   190     /**
       
   191      * Tells whether the node should be always visible in UI.
       
   192      *
       
   193      * @return True if always visible, otherwise false.
       
   194      */
       
   195     TBool AlwaysVisible() const;
       
   196     
       
   197     /**
       
   198      * Sets the always visible property.
       
   199      *
       
   200      * @param aValue The new value.
       
   201      */
       
   202     void SetAlwaysVisible( TBool aValue );
       
   203 
       
   204 
       
   205     /**
       
   206      *
       
   207      */
       
   208     void InternalizeL( MNcdPreminetProtocolDataEntity& aData );
       
   209     
       
   210 
       
   211     void InternalizeContentInfoL( const MNcdPurchaseDetails& aDetails );
       
   212 
       
   213     void InternalizeUriContentL( const MNcdPurchaseDetails& aDetails );
       
   214 
       
   215     
       
   216     /**
       
   217      * Get content download.
       
   218      *
       
   219      * @return Reference to the node download. 
       
   220      * @exception KErrNotFound if node download has not been set.
       
   221      */
       
   222     CNcdNodeDownload& DownloadL();
       
   223 
       
   224     /**
       
   225      * Internalizes data to the node download from purchase history. If the
       
   226      * node download does not exists it is created.
       
   227      */
       
   228     void InternalizeDownloadL( const MNcdPurchaseDetails& aDetails );
       
   229 
       
   230 
       
   231     /**
       
   232      * Get content install.
       
   233      *
       
   234      * @return Reference to the node install. 
       
   235      * @exception KErrNotFound if node install has not been set.
       
   236      */    
       
   237     CNcdNodeInstall& InstallL();
       
   238 
       
   239     /**
       
   240      * Internalizes data to the node install from purchase history. If the
       
   241      * node install does not exists it is created.
       
   242      */    
       
   243     void InternalizeInstallL( const MNcdPurchaseDetails& aDetails );
       
   244 
       
   245     /**
       
   246      * Internalizes install from content info. Creates node install if necessary
       
   247      */
       
   248     void InternalizeInstallFromContentInfoL();
       
   249     
       
   250     /**
       
   251      * Internalizes dependency information from purchase history
       
   252      *
       
   253      * @param aDetails Purchase details
       
   254      */
       
   255     void InternalizeDependencyL( const MNcdPurchaseDetails& aDetails );
       
   256 
       
   257     /**
       
   258      * Internalizes icon information from purchase history
       
   259      *
       
   260      * @param aDetails Purchase details
       
   261      */
       
   262     void InternalizeIconL( const MNcdPurchaseDetails& aDetails );
       
   263     
       
   264     /**
       
   265      * Get purchase details from the purchase history
       
   266      */
       
   267     CNcdPurchaseDetails* PurchaseDetailsLC( TBool aLoadIcon = EFalse ) const;
       
   268     
       
   269     
       
   270     /**
       
   271      * Updates CNcdNodeUpgrade from CNcdNodeContentInfo and CNcdNodeInstall
       
   272      */
       
   273     TBool HandleContentUpgradeL();
       
   274             
       
   275     
       
   276     void SetDeleteSoon( TBool aDeleteSoon );
       
   277     
       
   278     
       
   279     TBool DeleteSoon() const;
       
   280     
       
   281         
       
   282 public: // MNcdStorageDataItem
       
   283 
       
   284     /**
       
   285      * @see MNcdStorageDataItem::ExternalizeL
       
   286      */
       
   287     virtual void ExternalizeL( RWriteStream& aStream );
       
   288 
       
   289 
       
   290     /**
       
   291      * @see MNcdStorageDataItem::InternalizeL
       
   292      */
       
   293     virtual void InternalizeL( RReadStream& aStream );
       
   294 
       
   295 
       
   296 public: // CCatalogsCommunicable
       
   297 
       
   298     /**
       
   299      * @see CCatalogsCommunicable::ReceiveMessage
       
   300      */
       
   301     virtual void ReceiveMessage( MCatalogsBaseMessage* aMessage,
       
   302                                  TInt aFunctionNumber );
       
   303 
       
   304     /**
       
   305      * @see CCatalogsCommunicable::CounterPartLost
       
   306      */
       
   307     virtual void CounterPartLost( const MCatalogsSession& aSession );
       
   308 
       
   309 
       
   310 protected:
       
   311 
       
   312     /**
       
   313      * Constructor
       
   314      */
       
   315     CNcdNodeMetaData(
       
   316         NcdNodeClassIds::TNcdNodeClassId aClassId,
       
   317         CNcdNodeManager& aNodeManager );
       
   318 
       
   319     /**
       
   320      * ConstructL
       
   321      */
       
   322     virtual void ConstructL( const CNcdNodeIdentifier& aIdentifier );
       
   323 
       
   324 
       
   325     /**
       
   326      * This function is called when the proxy wants to get the
       
   327      * data from the serverside. This function calls the
       
   328      * InternalizeDataForRequestL which may be overloaded in the
       
   329      * child classes
       
   330      */
       
   331     void InternalizeRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   332     /**
       
   333      * This function writes the object data to the stream. Child
       
   334      * classes should add theri own data after the parent data.
       
   335      */
       
   336     virtual void ExternalizeDataForRequestL( RWriteStream& aStream ) const;
       
   337 
       
   338 
       
   339     /**
       
   340      *
       
   341      */
       
   342     void InternalizePurchaseMeansRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   343 
       
   344     /**
       
   345      * This function writes the purchase option amount and handles
       
   346      * to the stream. 
       
   347      */        
       
   348     void ExternalizePurchaseMeansForRequestL(
       
   349         const CDesCArray& aPurchaseOptionIds,
       
   350         RWriteStream& aStream,
       
   351         MCatalogsSession& aSession ) const;
       
   352 
       
   353     /**
       
   354      *
       
   355      */
       
   356     void InternalizePurchaseHistoryRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   357 
       
   358     /**
       
   359      *
       
   360      */
       
   361     void ExternalizePurchaseHistoryForRequestL( RWriteStream& aStream ) const;
       
   362     
       
   363         
       
   364     /**
       
   365      * This function is called when the proxy wants to get purchase
       
   366      * option ids from the server side.
       
   367      */
       
   368     void PurchaseOptionIdsRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   369         
       
   370 
       
   371     void ReleaseRequest( MCatalogsBaseMessage& aMessage ) const;
       
   372 
       
   373     void IconIdRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   374     void IconDataRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   375     
       
   376     void UserDataHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   377     void DisclaimerHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   378     void IconHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   379     void ScreenshotHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   380     void SkinHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   381     void UriContentHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   382     void ContentInfoHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   383     void PreviewHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   384     void UpgradeHandleRequestL( MCatalogsBaseMessage& aMessage );
       
   385     void DependencyHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   386     void DownloadHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   387     void InstallHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   388     void MoreInfoHandleRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   389     void IsPurchaseSupportedRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   390 
       
   391 private:
       
   392 
       
   393     // Prevent these two if they are not implemented
       
   394     CNcdNodeMetaData( const CNcdNodeMetaData& aObject );
       
   395     CNcdNodeMetaData& operator =( const CNcdNodeMetaData& aObject );
       
   396 
       
   397 
       
   398     // Functions related to internalization of purchase options
       
   399 
       
   400     
       
   401     /**
       
   402      * Function that creates needed purchaseoption and internalizes
       
   403      * it from the given data or reinternalizes already existing
       
   404      * purchase option if purchase option with the same id is found
       
   405      */
       
   406     void InternalizePurchaseOptionL(
       
   407         const MNcdPreminetProtocolPurchaseOption& aData );
       
   408     
       
   409     /**
       
   410      * Gets existing purchase option with given id or if
       
   411      * one is not found creates one and inserts it into array
       
   412      * containing existing purchase options. Option can be
       
   413      * removed from the array later if necessary with
       
   414      * RemovePurchaseOptionL() function.
       
   415      */
       
   416     CNcdPurchaseOptionImpl& CreateOrGetPurchaseOptionL(
       
   417         const TDesC& aPurchaseOptionId );
       
   418     
       
   419     /**
       
   420      * Finds purchase option with given id and removes it
       
   421      * from the array of the current purchase options. Also
       
   422      * closes the option once.
       
   423      */
       
   424     void RemovePurchaseOptionL( const TDesC& aPurchaseOptionId );
       
   425     
       
   426     /**
       
   427      * Removes all purchase options that have not been recently
       
   428      * updated. Used to remove purchase options that are still in
       
   429      * memory but are not received from the server anymore.
       
   430      * Also sets all options as not recently updated.
       
   431      */
       
   432     void RemoveNotUpdatedPurchaseOptions();
       
   433 
       
   434     /**
       
   435      * Function that creates needed purchaseoption and internalizes
       
   436      * it from the given data or reinternalizes already existing
       
   437      * purchase option if purchase option with the same id is found
       
   438      */
       
   439     void InternalizePurchaseOptionL( RReadStream& aStream );
       
   440 
       
   441 
       
   442     /**
       
   443      * Updates free content URIs to purchase history if they have been
       
   444      * 'bought'. Also internalizes CNcdNodeContentUri
       
   445      */
       
   446     void HandleContentUriUpdateL( const CNcdPurchaseOptionImpl& aOption );
       
   447     
       
   448     
       
   449 private: // data
       
   450     
       
   451     // The class id is the id for this class that a factory uses
       
   452     // when it creates an object of this class.
       
   453     NcdNodeClassIds::TNcdNodeClassId  iClassId;
       
   454     
       
   455     // Node manager
       
   456     CNcdNodeManager& iNodeManager;
       
   457    
       
   458     // This info is set already during creation of the object
       
   459     CNcdNodeIdentifier* iIdentifier;
       
   460     
       
   461     // This information is set when internalizing
       
   462     HBufC* iTimeStamp;
       
   463     HBufC* iName;
       
   464     HBufC* iDescription;
       
   465     HBufC* iLayoutType;
       
   466     
       
   467     // This class owns user data if it has been created.
       
   468     CNcdNodeUserData* iUserData;    
       
   469     
       
   470     CNcdNodeDisclaimer* iDisclaimer;
       
   471     
       
   472     CNcdNodeIcon* iIcon;
       
   473     
       
   474     CNcdNodeScreenshot* iScreenshot;
       
   475 
       
   476     CNcdNodeSkin* iSkin;
       
   477 
       
   478     CNcdNodePreview* iPreview;
       
   479     
       
   480     CNcdServerSubscribableContent* iSubscribableContent;
       
   481     RPointerArray<CNcdPurchaseOptionImpl> iPurchaseOptions;
       
   482 
       
   483     CNcdNodeUriContent* iUriContent;
       
   484     
       
   485     CNcdNodeContentInfo* iContentInfo;
       
   486 
       
   487     // This class owns node download if it has been set.
       
   488     CNcdNodeDownload* iDownload;
       
   489     
       
   490     // This class owns node install if it has been set
       
   491     CNcdNodeInstall* iInstall;
       
   492     
       
   493     CNcdNodeDisclaimer* iMoreInfo;
       
   494     
       
   495     RPointerArray<CNcdKeyValuePair> iDetails;
       
   496 
       
   497     CNcdNodeUpgrade* iUpgrade;
       
   498 
       
   499     CNcdNodeDependency* iDependency;
       
   500     
       
   501     TBool iAlwaysVisible;
       
   502 
       
   503     // The message is set when ReceiveMessage is called. The message
       
   504     // is used in the CounterPartLost-function that informs the message
       
   505     // if the session has been lost.
       
   506     MCatalogsBaseMessage* iMessage;
       
   507         
       
   508     // ETrue if the metadata object should be deleted as soon as possible
       
   509     // from memory. It's not necessary save this on disk
       
   510     TBool iDeleteSoon;
       
   511     
       
   512     // Version of the bought content if any. This is read from purchase history 
       
   513     // This is here because NodeInstall may not be available when 
       
   514     // this is needed and making it available in those cases would make
       
   515     // things much more complicated    
       
   516     TCatalogsVersion iBoughtContentVersion;
       
   517     };
       
   518     
       
   519 #endif // NCD_NODE_META_DATA_H