ncdengine/provider/server/inc/ncdpurchaseoptionimpl.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_NCDPURCHASEOPTIONIMPL_H
       
    20 #define C_NCDPURCHASEOPTIONIMPL_H
       
    21  
       
    22 // For streams
       
    23 #include <s32mem.h>
       
    24 
       
    25 #include "catalogscommunicable.h"
       
    26 #include "ncdstoragedataitem.h"
       
    27 #include "ncdnodeclassids.h"
       
    28 #include "ncdprotocoltypes.h"
       
    29 #include "ncdpurchaseoption.h" // To get TType enum for purchaseoption
       
    30 
       
    31 class MNcdPreminetProtocolPurchaseOption;
       
    32 class CNcdPurchaseDownloadInfo;
       
    33 
       
    34 class CNcdServerSubscription;
       
    35 class CNcdServerPartOfSubscription;
       
    36 class CNcdServerUpgrade;
       
    37 class CNcdNodeMetaData;
       
    38 class CNcdNodeIdentifier;
       
    39 class CNcdServerSubscribableContent;
       
    40 class CNcdNodeIcon;
       
    41 
       
    42 
       
    43 /**
       
    44  *  Server-side purchaseoption-implementation
       
    45  *
       
    46  *  This class implements server-side functionality related to
       
    47  *  each node's purchaseoptions.
       
    48  *
       
    49  *  @lib ?library
       
    50  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    51  */
       
    52 class CNcdPurchaseOptionImpl : public CCatalogsCommunicable,
       
    53                                public MNcdStorageDataItem
       
    54 {
       
    55 
       
    56 public:
       
    57 
       
    58     
       
    59     static CNcdPurchaseOptionImpl* NewL(
       
    60         const CNcdNodeMetaData& aParentMetaData );
       
    61     
       
    62     static CNcdPurchaseOptionImpl* NewLC(
       
    63         const CNcdNodeMetaData& aParentMetaData );
       
    64     
       
    65     virtual ~CNcdPurchaseOptionImpl();
       
    66 
       
    67     /**
       
    68      * Retrieves the data type that informs what class the data is for.
       
    69      * By checking the data type information, an InternalizeL function
       
    70      * of a right class can be called when the object data is set
       
    71      * from the storage.
       
    72      * The data type may be decided and set in a object that creates this 
       
    73      * class object.
       
    74      *
       
    75      * @return NcdNodeClassIds::TNcdNodeClassId Describes the data type. 
       
    76      */
       
    77     NcdNodeClassIds::TNcdNodeClassId ClassId() const;
       
    78 
       
    79 
       
    80     /**
       
    81      * This function is called when the owner of this object
       
    82      * wants to internalize the content according to the data
       
    83      * that has been received from the parser.
       
    84      * 
       
    85      * @param aOption The data is set in the protocol parser and can
       
    86      *                be used to initialize this class object.
       
    87      */
       
    88     void InternalizeL( const MNcdPreminetProtocolPurchaseOption& aOption );
       
    89 
       
    90 
       
    91     /**
       
    92      * Returns reference to parent meta data's node identifier.
       
    93      * 
       
    94      * @return Node identifier of parent meta data.
       
    95      */
       
    96     const CNcdNodeIdentifier& ParentMetaIdentifier() const;
       
    97 
       
    98     /**
       
    99      * Returns pointer to parent node's subscribable content.
       
   100      * 
       
   101      * @return Subscribable content info of parent node. NULL if
       
   102      *         not found.
       
   103      */
       
   104     const CNcdServerSubscribableContent* ParentSubscribableContent() const;
       
   105 
       
   106     /**
       
   107      * Returns reference to parent node's icon.
       
   108      * 
       
   109      * @return Icon of parent node.
       
   110      */
       
   111     const CNcdNodeIcon& ParentIconL() const;
       
   112 
       
   113     /**
       
   114      * Getter for the name of the purchaseoption.
       
   115      *
       
   116      * @note This function is not named simply Name, because such
       
   117      *       function allready exists in CObject. Only the return value
       
   118      *       would be different.
       
   119      * 
       
   120      * @return Name of the purchase option
       
   121      */
       
   122     const TDesC& PurchaseOptionName() const;
       
   123 
       
   124     /**
       
   125      * Setter for the id of the purchaseoption. Intended to be used
       
   126      * only when creting a new purchase option.
       
   127      *
       
   128      * @return Id of the purchase option
       
   129      */
       
   130     void SetIdL( const TDesC& aId );
       
   131     
       
   132     /**
       
   133      * Getter for the id of the purchaseoption.
       
   134      *
       
   135      * @return Id of the purchase option
       
   136      */
       
   137     const TDesC& Id() const;
       
   138 
       
   139     /**
       
   140      * Getter for the type of the purchaseoption.
       
   141      *
       
   142      * @return Type of the purchase option
       
   143      */
       
   144     MNcdPurchaseOption::TType PurchaseOptionType() const;
       
   145 
       
   146     /**
       
   147      * Tells whether this purchase option is free.
       
   148      *
       
   149      * @return ETrue if the purchase option is free, EFalse otherwise.
       
   150      */
       
   151     TBool IsFree() const;
       
   152 
       
   153     /**
       
   154      * Tells whether purchase process is reuqired when using
       
   155      * this option.
       
   156      *
       
   157      * @return ETrue if the purchase process is required, EFalse
       
   158      *         otherwise.
       
   159      */    
       
   160     TBool RequirePurchaseProcess() const;
       
   161 
       
   162     /**
       
   163      * Setter for price text.
       
   164      *
       
   165      * @param aPriceText New price text for this purchase option. 
       
   166      */
       
   167     void SetPriceTextL( const TDesC& aPriceText );
       
   168 
       
   169     /**
       
   170      * Getter for price text.
       
   171      * 
       
   172      * @return Textual representation of the price
       
   173      */
       
   174     const TDesC& PriceText() const;
       
   175 
       
   176     /**
       
   177      * Getter for amount of download infos.
       
   178      *
       
   179      * @return Amount of download infos. 
       
   180      */
       
   181     TInt DownloadInfoCount() const;
       
   182     /**
       
   183      * Getter for amount of download info with given index.
       
   184      *
       
   185      * @return Download info.
       
   186      */
       
   187     const CNcdPurchaseDownloadInfo& DownloadInfo( TInt aInfoIndex ) const;
       
   188 
       
   189 
       
   190 
       
   191     /**
       
   192      * Getter for the subscription info of this purchaseoption.
       
   193      * If subscription is purchased, this tells details of the
       
   194      * subscription.
       
   195      *
       
   196      * @return Object representing subscription info of this purchase option.
       
   197      *         NULL if not found.
       
   198      *
       
   199      */
       
   200     const CNcdServerSubscription* SubscriptionInfo() const;
       
   201 
       
   202     /**
       
   203      * Getter for the partOfSubscription info of this purchaseoption.
       
   204      * These things are used to purchase something using a subscription.
       
   205      *
       
   206      *
       
   207      * @return Object representing partOfSubscription info of this
       
   208      *         purchase option. NULL if not found.
       
   209      *
       
   210      */
       
   211     const CNcdServerPartOfSubscription* PartOfSubscriptionInfo() const;
       
   212 
       
   213     /**
       
   214      * Getter for the upgrade info of this purchaseoption. These
       
   215      * things are used to upgrade a subscription.
       
   216      *
       
   217      *
       
   218      * @return Object representing upgrade info of this
       
   219      *         purchase option. NULL if not found.
       
   220      *
       
   221      */
       
   222     const CNcdServerUpgrade* UpgradeInfo() const;
       
   223 
       
   224 
       
   225     /**
       
   226      * This function is called to set internal flag of the purchase
       
   227      * option to inform whether the purchase option has been recently
       
   228      * updated or not.
       
   229      *
       
   230      * @param aNewState New state for the recently updated flag.
       
   231      *
       
   232      */
       
   233     void SetRecentlyUpdated( TBool aNewState );
       
   234 
       
   235     /**
       
   236      * This function returns the information whether the purchase
       
   237      * option has been recently updated or not.
       
   238      *
       
   239      * @return State for the recently updated flag.
       
   240      */    
       
   241     TBool RecentlyUpdated() const;
       
   242 
       
   243 
       
   244 public: // MNcdStorageDataItem 
       
   245 
       
   246     // These functions are used to get the data from and to insert the data
       
   247     // into the database using by the given stream.
       
   248 
       
   249     /**
       
   250      * @see MNcdStorageDataItem::ExternalizeL
       
   251      */
       
   252     virtual void ExternalizeL( RWriteStream& aStream );
       
   253 
       
   254 
       
   255     /**
       
   256      * @see MNcdStorageDataItem::InternalizeL
       
   257      */
       
   258     virtual void InternalizeL( RReadStream& aStream );
       
   259 
       
   260 
       
   261 public: // CCatalogsCommunicable
       
   262 
       
   263     /**
       
   264      * @see CCatalogsCommunicable::ReceiveMessage
       
   265      */
       
   266     virtual void ReceiveMessage( MCatalogsBaseMessage* aMessage,
       
   267                                  TInt aFunctionNumber );
       
   268 
       
   269     /**
       
   270      * @see CCatalogsCommunicable::CounterPartLost
       
   271      */
       
   272     virtual void CounterPartLost( const MCatalogsSession& aSession );
       
   273 
       
   274 protected:
       
   275 
       
   276     CNcdPurchaseOptionImpl(
       
   277         NcdNodeClassIds::TNcdNodeClassId aClassId,
       
   278         const CNcdNodeMetaData& aParentMetaData );
       
   279 
       
   280     void ConstructL();
       
   281 
       
   282     /**
       
   283      * This function is called when the proxy wants to get the
       
   284      * data from the serverside. This function calls the
       
   285      * InternalizeDataForRequestL which may be overloaded in the
       
   286      * child classes
       
   287      * @param aMessage Contains data from the proxy and can be used
       
   288      * to send data back to proxy
       
   289      */
       
   290     void InternalizeRequestL( MCatalogsBaseMessage& aMessage ) const;
       
   291         
       
   292     /**
       
   293      * This function writes the object data to the stream. 
       
   294      * The stream content will be sent to the proxy that requested the data.
       
   295      * Child classes should add their own data after this parent data.
       
   296      * @param aStream The data content of this class object will be written
       
   297      * into this stream.
       
   298      */
       
   299     virtual void ExternalizeDataForRequestL( RWriteStream& aStream ) const;
       
   300 
       
   301     /**
       
   302      * This function is called from the proxy side. When the proxy
       
   303      * is deleted.
       
   304      * @param aMessage Contains data from the proxy and can be used
       
   305      * to send data back to proxy
       
   306      */
       
   307     void ReleaseRequest( MCatalogsBaseMessage& aMessage ) const;
       
   308 
       
   309 private:
       
   310 
       
   311     // Prevent these two if they are not implemented
       
   312     CNcdPurchaseOptionImpl( const CNcdPurchaseOptionImpl& aObject );
       
   313     CNcdPurchaseOptionImpl& operator =( const CNcdPurchaseOptionImpl& aObject );
       
   314 
       
   315 
       
   316     /**
       
   317      * This function is called during internalization of this object to
       
   318      * internalize subscriptions related info.
       
   319      * 
       
   320      * @param aOption The data is set in the protocol parser and can
       
   321      *                be used to initialize this class object.
       
   322      */
       
   323     void InternalizeSubscriptionsInfoL( 
       
   324         const MNcdPreminetProtocolPurchaseOption& aOption );
       
   325 
       
   326     /**
       
   327      * This function is called during internalization of this object to
       
   328      * internalize downloaddetails.
       
   329      * 
       
   330      * @param aOption The data is set in the protocol parser and can
       
   331      *                be used to initialize this class object.
       
   332      */
       
   333     void InternalizeDownloadDetailsL(
       
   334         const MNcdPreminetProtocolPurchaseOption& aOption );
       
   335     
       
   336 
       
   337     /**
       
   338      * Deletes all allocated member variables and sets the pointers to NULL.
       
   339      * Also sets other variables to their initial values.
       
   340      *
       
   341      * @since S60 ?S60_version
       
   342      */    
       
   343     void ResetMemberVariables();    
       
   344 
       
   345 private:
       
   346 
       
   347     // The class id is identifies this class. The id may be used to
       
   348     // identify what kind of class object is created when data is gotten
       
   349     // from the db.
       
   350     NcdNodeClassIds::TNcdNodeClassId  iClassId;
       
   351 
       
   352     // The message is set when ReceiveMessage is called. The message
       
   353     // is used in the CounterPartLost-function that informs the message
       
   354     // if the session has been lost.
       
   355     MCatalogsBaseMessage* iMessage;
       
   356 
       
   357 
       
   358     // Parent meta data.
       
   359     const CNcdNodeMetaData& iParentMetaData;
       
   360 
       
   361 
       
   362     /*
       
   363      * Internal flag of the purchase option to inform whether the
       
   364      * purchase option has been recently updated or not. This has
       
   365      * to be set by user.
       
   366      */    
       
   367     TBool iRecentlyUpdated;
       
   368 
       
   369 
       
   370     /**
       
   371      * Name of the option. For example "Try" or "Full".
       
   372      * Own. 
       
   373      */  
       
   374     HBufC* iName;
       
   375     /**
       
   376      * Textual representation of price when using this purchase option.
       
   377      * Own. 
       
   378      */      
       
   379     HBufC* iPriceText;
       
   380     /**
       
   381      * If iPriceText is not used then this tells the price.
       
   382      */     
       
   383     TReal32 iPrice;
       
   384     /**
       
   385      * Currency of iPriceText.
       
   386      * Own. 
       
   387      */     
       
   388     HBufC* iPriceCurrency;
       
   389     /**
       
   390      * If target is free using this purchase option.
       
   391      */ 
       
   392     TBool iIsFree;
       
   393 
       
   394     /**
       
   395      * Id of this purchase option.
       
   396      * Own. 
       
   397      */
       
   398     HBufC* iPurchaseOptionId;
       
   399 
       
   400     /**
       
   401      * Type of this entity.
       
   402      */    
       
   403     MNcdPurchaseOption::TType iType;
       
   404  
       
   405     /**
       
   406      * If purchase process is needed when buying target with this
       
   407      * purchase option.
       
   408      */    
       
   409     TBool iRequirePurchaseProcess;
       
   410 
       
   411     /**
       
   412      * Array to store downloadinfo related to this purchase option
       
   413      */     
       
   414     RPointerArray<CNcdPurchaseDownloadInfo> iDownloadInfo;
       
   415     
       
   416     
       
   417     // NOTICE: purchaseoption can contain more than one of the
       
   418     //         following components. For example it could be
       
   419     //         possible that a subscription is a part of subscription
       
   420     //         although in reality this is probably never the case.
       
   421     
       
   422     /**
       
   423      * Subscription info if this is a subscription.
       
   424      * Own. 
       
   425      */    
       
   426     CNcdServerSubscription* iSubscription;
       
   427 
       
   428     /**
       
   429      * Part of subscription info if this is a part of subscription.
       
   430      * Own. 
       
   431      */    
       
   432     CNcdServerPartOfSubscription* iPartOfSubscription;
       
   433 
       
   434     /**
       
   435      * Upgrade info if this is a upgrade.
       
   436      * Own. 
       
   437      */
       
   438     CNcdServerUpgrade* iUpgrade;
       
   439     
       
   440     
       
   441 };
       
   442 
       
   443 
       
   444 #endif // C_NCDPURCHASEOPTIONIMPL_H