ncdengine/provider/client/inc/ncdsubscriptionproxy.h
changeset 4 32704c33136d
equal deleted inserted replaced
-1:000000000000 4:32704c33136d
       
     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 CNcdSubscriptionProxy class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_NCD_SUBSCRIPTION_PROXY_H
       
    20 #define C_NCD_SUBSCRIPTION_PROXY_H
       
    21 
       
    22 
       
    23 // For the streams
       
    24 #include <s32mem.h>
       
    25 
       
    26 #include "ncdinterfacebaseproxy.h"
       
    27 #include "ncdsubscription.h"
       
    28 
       
    29 class CNcdOperationManagerProxy;
       
    30 class CNcdSubscriptionGroupProxy;
       
    31 class CNcdNodeManagerProxy;
       
    32 
       
    33 /**
       
    34  *  This class implements the functionality for the
       
    35  *  MNcdSubscription
       
    36  *  These interfaces are provided for API users.
       
    37  *
       
    38  *  @since S60 v3.2
       
    39  */
       
    40 class CNcdSubscriptionProxy : public CNcdInterfaceBaseProxy, 
       
    41                               public MNcdSubscription
       
    42     {
       
    43 
       
    44 public:
       
    45 
       
    46     /**
       
    47      * @param aSession The session between the client proxy and the
       
    48      * corresponding server object.
       
    49      * @param aHandle The handle which identifies the server object
       
    50      * that this proxy uses.
       
    51      * @param aOperationManager This class uses operation manager to get the
       
    52      * operations for certain tasks.
       
    53      * @param aNodeManager This class uses node manager to get certain
       
    54      *                     nodes.
       
    55      * @param aParentGroup The parent subscription group.
       
    56      * @return CNcdSubscriptionProxy* Pointer to the created object 
       
    57      * of this class.
       
    58      */
       
    59     static CNcdSubscriptionProxy* NewL(
       
    60         MCatalogsClientServer& aSession,
       
    61         TInt aHandle,
       
    62         CNcdOperationManagerProxy& aOperationManager,
       
    63         CNcdNodeManagerProxy& aNodeManager,
       
    64         CNcdSubscriptionGroupProxy& aParentGroup );
       
    65 
       
    66     /**
       
    67      * @param aSession The session between the client proxy and the
       
    68      * corresponding server object.
       
    69      * @param aHandle The handle which identifies the server object
       
    70      * that this proxy uses.
       
    71      * @param aOperationManager This class uses operation manager to get the
       
    72      * operations for certain tasks.
       
    73      * @param aNodeManager This class uses node manager to get certain
       
    74      *                     nodes.
       
    75      * @param aParentGroup The parent subscription group.
       
    76      * @return CNcdSubscriptionProxy* Pointer to the created object 
       
    77      * of this class.
       
    78      */
       
    79     static CNcdSubscriptionProxy* NewLC(
       
    80         MCatalogsClientServer& aSession, 
       
    81         TInt aHandle,
       
    82         CNcdOperationManagerProxy& aOperationManager,
       
    83         CNcdNodeManagerProxy& aNodeManager,
       
    84         CNcdSubscriptionGroupProxy& aParentGroup );
       
    85 
       
    86 
       
    87     /**
       
    88      * Destructor.
       
    89      * The destructor is set public. So, the node that owns this object may
       
    90      * delete it directly when the reference count of the node reaches zero
       
    91      * and the destructor of the node is called.
       
    92      */
       
    93     virtual ~CNcdSubscriptionProxy();
       
    94      
       
    95 
       
    96     /**
       
    97      * Gets the data for descriptors from the server side. This function is
       
    98      * called to update proxy data. The function uses the protected virtual
       
    99      * internalize functions. So, the child classes may provide their own
       
   100      * implementations for internalizations of certain metadata.
       
   101      */
       
   102     void InternalizeL();
       
   103 
       
   104 
       
   105     /**
       
   106      * Sets subscription into obsolete state and it should
       
   107      * not be used anymore.
       
   108      *
       
   109      * @since S60 ?S60_version
       
   110      * @param aIsObsolete New value for obsolete info of the
       
   111      *                    subscription.
       
   112      */     
       
   113     void SetObsolete();
       
   114 
       
   115     /**
       
   116      * Id of the purchaseoption where from this subscription was
       
   117      * bought.
       
   118      */    
       
   119     virtual TDesC& PurchaseOptionId() const;
       
   120     
       
   121 
       
   122 public: // MNcdSubscription
       
   123 
       
   124 // from base class MNcdSubscription
       
   125 
       
   126     /**
       
   127      * From MNcdPurchaseOption.
       
   128      * @see MNcdPurchaseOption::Name
       
   129      */
       
   130     virtual const TDesC& Name() const;
       
   131 
       
   132     /**
       
   133      * From MNcdPurchaseOption.
       
   134      * @see MNcdPurchaseOption::IconL
       
   135      */
       
   136     virtual HBufC8* IconL() const;
       
   137     
       
   138     /**
       
   139      * From MNcdPurchaseOption.
       
   140      * @see MNcdPurchaseOption::SubscriptionStatus
       
   141      */
       
   142     virtual MNcdSubscription::TStatus SubscriptionStatus() const;
       
   143 
       
   144     /**
       
   145      * From MNcdPurchaseOption.
       
   146      * @see MNcdPurchaseOption::IsObsolete
       
   147      */     
       
   148     TBool IsObsolete() const;
       
   149 
       
   150 
       
   151     /**
       
   152      * From MNcdSubscription.
       
   153      * @see MNcdSubscription::Unsubscribed
       
   154      */
       
   155     virtual TBool Unsubscribed() const;
       
   156 
       
   157     /**
       
   158      * From MNcdSubscription.
       
   159      * @see MNcdSubscription::UnsubscribeL
       
   160      */
       
   161     virtual MNcdSubscriptionOperation* UnsubscribeL( 
       
   162         MNcdSubscriptionOperationObserver& aObserver );
       
   163     
       
   164 
       
   165     /**
       
   166      * From MNcdSubscription.
       
   167      * @see MNcdSubscription::SubscriptionType
       
   168      */
       
   169     virtual MNcdSubscription::TType SubscriptionType() const;
       
   170     
       
   171 
       
   172     /**
       
   173      * From MNcdSubscription.
       
   174      * @see MNcdSubscription::ValidityTime
       
   175      */
       
   176     virtual TBool ValidityTime( TTime& aValidUntil ) const;
       
   177 
       
   178 
       
   179     /**
       
   180      * From MNcdSubscription.
       
   181      * @see MNcdSubscription::CreditLimit
       
   182      */
       
   183     virtual TBool CreditLimit( TReal& aCreditsLeft, TReal& aTotalCredits ) const;
       
   184 
       
   185 
       
   186     /**
       
   187      * From MNcdSubscription.
       
   188      * @see MNcdSubscription::DownloadLimit
       
   189      */
       
   190     virtual TBool DownloadLimit( TInt& aDownloadsLeft, TInt& aTotalDownloads) const;
       
   191 
       
   192     /**
       
   193      * From MNcdSubscription.
       
   194      * @see MNcdSubscription::OriginNodeL
       
   195      */
       
   196     virtual MNcdNode* OriginNodeL() const;
       
   197 
       
   198     /**
       
   199      * From MNcdSubscription.
       
   200      * @see MNcdSubscription::OriginPurchaseOptionId
       
   201      */
       
   202     virtual const TDesC& OriginPurchaseOptionId() const;
       
   203     
       
   204 
       
   205 protected:
       
   206 
       
   207     /**
       
   208      * Constructor
       
   209      *
       
   210      * @param aSession The session between the client proxy and the
       
   211      * corresponding server object.
       
   212      * @param aHandle The handle which identifies the server object
       
   213      * that this proxy uses.
       
   214      * @param aOperationManager This class uses operation manager to get the
       
   215      * operations for certain tasks.
       
   216      * @param aNodeManager This class uses node manager to get certain
       
   217      *                     nodes.
       
   218      * @param aParentGroup The parent subscription group.
       
   219      * @return CNcdSubscriptionProxy* Pointer to the created object 
       
   220      * of this class.
       
   221      */
       
   222     CNcdSubscriptionProxy( MCatalogsClientServer& aSession,
       
   223                            TInt aHandle,
       
   224                            CNcdOperationManagerProxy& aOperationManager,
       
   225                            CNcdNodeManagerProxy& aNodeManager,
       
   226                            CNcdSubscriptionGroupProxy& aParentGroup );
       
   227 
       
   228     /**
       
   229      * ConstructL
       
   230      */
       
   231     virtual void ConstructL();
       
   232     
       
   233     
       
   234     /**
       
   235      * @return CNcdOperationManagerProxy& Gives the operation manager proxy.
       
   236      * Operation manager may be asked to create new operations for this class
       
   237      * object.
       
   238      */
       
   239     CNcdOperationManagerProxy& OperationManager() const;
       
   240 
       
   241 
       
   242 
       
   243     // These functions are used to update the data of this class object
       
   244 
       
   245     /**
       
   246      * @param aStream This stream will contain all the data content for
       
   247      * this class object. The stream is gotten from the server side. The
       
   248      * memeber variables will be updated according to the data from
       
   249      * the stream. 
       
   250      */
       
   251     virtual void InternalizeDataL( RReadStream& aStream );
       
   252 
       
   253 
       
   254 private:
       
   255 
       
   256     // Prevent if not implemented
       
   257     CNcdSubscriptionProxy( const CNcdSubscriptionProxy& aObject );
       
   258     CNcdSubscriptionProxy& operator =( const CNcdSubscriptionProxy& aObject );
       
   259 
       
   260     void ResetSubscriptionVariables();    
       
   261         
       
   262     
       
   263 private: // data
       
   264 
       
   265     CNcdOperationManagerProxy& iOperationManager;
       
   266     CNcdNodeManagerProxy& iNodeManager;
       
   267     
       
   268     /**
       
   269      * If this subscription is obsolete and should not be used
       
   270      * anymore. This can happen if the group is reinternalized
       
   271      * and someone still has handle to any of the subscriptions
       
   272      * of the group.
       
   273      */ 
       
   274     TBool iObsolete;
       
   275 
       
   276     /*
       
   277      * Subscription data.
       
   278      * Own.
       
   279      */
       
   280     HBufC* iName;    
       
   281     HBufC* iExpiredOn;
       
   282     
       
   283     TBool iCancelled;
       
   284     
       
   285     MNcdSubscription::TType iSubscriptionType;
       
   286     
       
   287     TBool iValidityTimeSet;
       
   288     TTime iValidUntil;
       
   289     
       
   290     TBool iCreditLimitSet;
       
   291     TReal32 iCreditsLeft;
       
   292     TReal32 iTotalCredits;
       
   293     
       
   294     TBool iDownloadLimitSet;
       
   295     TInt iDownloadsLeft;
       
   296     TInt iTotalDownloads;
       
   297     
       
   298     HBufC* iPurchaseOptionId;
       
   299         
       
   300     /**
       
   301      * Reference to the parent subscription group.
       
   302      */
       
   303     CNcdSubscriptionGroupProxy& iParentGroup;
       
   304 
       
   305     };
       
   306 
       
   307 
       
   308 #endif // C_NCD_SUBSCRIPTION_PROXY_H