ncdengine/provider/client/inc/ncdsubscriptionmanagerproxy.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 CNcdSubscriptionManagerProxy class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_NCD_SUBSCRIPTION_MANAGER_PROXY_H
       
    20 #define C_NCD_SUBSCRIPTION_MANAGER_PROXY_H
       
    21 
       
    22 
       
    23 // For the streams
       
    24 #include <s32mem.h>
       
    25 
       
    26 #include "ncdinterfacebaseproxy.h"
       
    27 #include "ncdsubscriptionmanager.h"
       
    28 
       
    29 class CNcdOperationManagerProxy;
       
    30 class CNcdSubscriptionGroupProxy;
       
    31 class CNcdSubscriptionProxy;
       
    32 class MNcdSubscriptionOperation;
       
    33 class MNcdSubscriptionOperationObserver;
       
    34 class CNcdKeyValuePair;
       
    35 class CNcdSubscriptionManagerListener;
       
    36 class CNcdNodeManagerProxy;
       
    37 
       
    38 /**
       
    39  *  This class implements the functionality for the
       
    40  *  MNcdSubscriptionManager interface. The interface is provided for
       
    41  *  API users.
       
    42  *
       
    43  *  @since S60 v3.2
       
    44  */
       
    45 class CNcdSubscriptionManagerProxy : public CNcdInterfaceBaseProxy, 
       
    46                                      public MNcdSubscriptionManager
       
    47     {
       
    48 
       
    49 public:
       
    50 
       
    51     /**
       
    52      * @param aSession The session between the client proxy and the
       
    53      * corresponding server object.
       
    54      * @param aHandle The handle which identifies the server object
       
    55      * that this proxy uses.
       
    56      * @param aOperationManager This class uses operation manager to get the
       
    57      * operations for certain tasks.
       
    58      * @param aParent Parent whose reference count AddRef of this
       
    59      *                object increments.
       
    60      * @return CNcdNodeManagerProxy* Pointer to the created object 
       
    61      * of this class.
       
    62      */
       
    63     static CNcdSubscriptionManagerProxy* NewL(
       
    64         MCatalogsClientServer& aSession,
       
    65         TInt aHandle,
       
    66         CCatalogsInterfaceBase* aParent,
       
    67         CNcdOperationManagerProxy& aOperationManager );
       
    68 
       
    69     /**
       
    70      * @param aSession The session between the client proxy and the
       
    71      * corresponding server object.
       
    72      * @param aHandle The handle which identifies the server object
       
    73      * that this proxy uses.
       
    74      * @param aParent Parent whose reference count AddRef of this
       
    75      *                object increments.
       
    76      * @param aOperationManager This class uses operation manager to get the
       
    77      * operations for certain tasks. 
       
    78      * @return CNcdSubscriptionManagerProxy* Pointer to the created object 
       
    79      * of this class.
       
    80      */
       
    81     static CNcdSubscriptionManagerProxy* NewLC(
       
    82         MCatalogsClientServer& aSession, 
       
    83         TInt aHandle,
       
    84         CCatalogsInterfaceBase* aParent,
       
    85         CNcdOperationManagerProxy& aOperationManager );
       
    86 
       
    87 
       
    88     /**
       
    89      * Destructor.
       
    90      */
       
    91     virtual ~CNcdSubscriptionManagerProxy();
       
    92      
       
    93     /**
       
    94      * Setter for node manager. Needed so that pointer to node manager
       
    95      * can be set after construction of this class.
       
    96      */
       
    97     void SetNodeManager( CNcdNodeManagerProxy* aManager );
       
    98 
       
    99     /**
       
   100      * Gets the data for descriptors from the server side. This function is
       
   101      * called to update proxy data. The function uses the protected virtual
       
   102      * internalize functions. So, the child classes may provide their own
       
   103      * implementations for internalizations of certain metadata.
       
   104      */
       
   105     void InternalizeL();
       
   106     
       
   107 
       
   108     /**
       
   109      * Checks if a subscription with given identification is active.
       
   110      */    
       
   111     TBool ActiveSubscriptionExists( const TDesC& aEntityId,
       
   112                                     const TDesC& aNamespace,
       
   113                                     const TDesC& aPurchaseOptionId );
       
   114 
       
   115     /**
       
   116      * @return pointer to specified subscription if such a subscription
       
   117      *         exists. (In other words if a subscription such a
       
   118      *         subscription has been made at some point.) Returns NULL
       
   119      *         if not found.
       
   120      *         NOTICE: Ownership is NOT transferred and reference count
       
   121      *                 is NOT incremented.
       
   122      */    
       
   123     CNcdSubscriptionProxy* Subscription( const TDesC& aEntityId,
       
   124                                          const TDesC& aNamespace,
       
   125                                          const TDesC& aPurchaseOptionId );
       
   126 
       
   127     /**
       
   128      * This is called by the subscription manager listener when it is notified that
       
   129      * the server side subscriptions has been altered.
       
   130      */                                         
       
   131     void SubscriptionsChangedL();                                         
       
   132 
       
   133 public: // MNcdSubscriptionManager
       
   134 
       
   135     /**
       
   136      * @see MNcdSubscriptionManager::SubscriptionsL
       
   137      */ 
       
   138     virtual RCatalogsArray<MNcdSubscription> SubscriptionsL() const;
       
   139 
       
   140     /**
       
   141      * @see MNcdSubscriptionManager::RefreshSubscriptionsL
       
   142      */ 
       
   143     virtual MNcdSubscriptionOperation* RefreshSubscriptionsL( 
       
   144         MNcdSubscriptionOperationObserver& aObserver );
       
   145 
       
   146 
       
   147 protected:
       
   148 
       
   149     /**
       
   150      * Constructor
       
   151      *
       
   152      * @param aSession The session between the client proxy and the
       
   153      * corresponding server object.
       
   154      * @param aHandle The handle which identifies the server object
       
   155      * that this proxy uses.
       
   156      * @param aParent Parent whose reference count AddRef of this
       
   157      *                object increments.
       
   158      * @param aOperationManager This class uses operation manager to get the
       
   159      * operations for certain tasks. 
       
   160      * @return CNcdSubscriptionManagerProxy* Pointer to the created object 
       
   161      * of this class.
       
   162      */
       
   163     CNcdSubscriptionManagerProxy(
       
   164         MCatalogsClientServer& aSession,
       
   165         TInt aHandle,
       
   166         CCatalogsInterfaceBase* aParent,
       
   167         CNcdOperationManagerProxy& aOperationManager );
       
   168 
       
   169     /**
       
   170      * ConstructL
       
   171      */
       
   172     virtual void ConstructL();
       
   173     
       
   174     
       
   175     /**
       
   176      * @return CNcdOperationManagerProxy& Gives the operation manager proxy.
       
   177      * Operation manager may be asked to create new operations for this class
       
   178      * object.
       
   179      */
       
   180     CNcdOperationManagerProxy& OperationManager() const;
       
   181 
       
   182 
       
   183 
       
   184     // These functions are used to update the data of this class object
       
   185 
       
   186     /**
       
   187      * @param aStream This stream will contain all the data content for
       
   188      * this class object. The stream is gotten from the server side. The
       
   189      * memeber variables will be updated according to the data from
       
   190      * the stream. 
       
   191      */
       
   192     virtual void InternalizeDataL( RReadStream& aStream );
       
   193     
       
   194     /**
       
   195      * Request the identifiers of all the subscription groups in the server side
       
   196      * and creates an array containing them.
       
   197      *
       
   198      * @return The array.
       
   199      */
       
   200     RPointerArray<CNcdKeyValuePair> SubscriptionGroupIdentifiersL() const;
       
   201     
       
   202     /**
       
   203      * Deletes the subscription groups that don't exist in the given array.
       
   204      *
       
   205      * @param aGroupIdentifiers Array of subscription group identifiers.
       
   206      */
       
   207     void DeleteMissingSubscriptionGroups(
       
   208         const RPointerArray<CNcdKeyValuePair>& aGroupIdentifiers );
       
   209         
       
   210     /**
       
   211      * Calls InternalizeL to the existing subscription groups.
       
   212      */
       
   213     void InternalizeSubscriptionGroupsL() const;
       
   214 
       
   215 
       
   216 private:
       
   217 
       
   218     // Prevent if not implemented
       
   219     CNcdSubscriptionManagerProxy( 
       
   220         const CNcdSubscriptionManagerProxy& aObject );
       
   221     CNcdSubscriptionManagerProxy& operator=( 
       
   222         const CNcdSubscriptionManagerProxy& aObject );
       
   223     
       
   224     
       
   225     /**
       
   226      * @return pointer to specified subscriptiongroup if such a group
       
   227      *         exists. (In other words if a subscription from such a group
       
   228      *         is made.)
       
   229      *         NOTICE: Ownership is NOT transferred and reference count
       
   230      *                 is NOT incremented. Although this method
       
   231      *                 is internal, it is good to remember to mention these
       
   232      *                 things if this method would ever become a public method.
       
   233      */    
       
   234     CNcdSubscriptionGroupProxy* SubscriptionGroup( const TDesC& aEntityId,
       
   235                                                    const TDesC& aNamespace );
       
   236     
       
   237 private: // data
       
   238 
       
   239     CNcdOperationManagerProxy& iOperationManager;
       
   240     
       
   241     /* Pointer to node manager.
       
   242      * Not own.
       
   243      */
       
   244     CNcdNodeManagerProxy* iNodeManager;
       
   245     
       
   246     RPointerArray<CNcdSubscriptionGroupProxy> iSubscriptionGroups;
       
   247     
       
   248     /**
       
   249      * Active object which listens for update events from the server side subscription
       
   250      * manager.
       
   251      */
       
   252     CNcdSubscriptionManagerListener* iListener;
       
   253     
       
   254     RBuf8 iInputBuf;
       
   255     RBuf8 iOutputBuf;
       
   256     
       
   257     };
       
   258 
       
   259 
       
   260 #endif // C_NCD_SUBSCRIPTION_MANAGER_PROXY_H