ncdengine/provider/server/inc/ncdfavoritemanagerimpl.h
branchRCL_3
changeset 19 7ca52d38f8c3
parent 0 ba25891c3a9e
child 41 0410b3201a77
equal deleted inserted replaced
18:3ba40be8e484 19:7ca52d38f8c3
   105      * @see CCatalogsCommunicable::CounterPartLost
   105      * @see CCatalogsCommunicable::CounterPartLost
   106      */
   106      */
   107     virtual void CounterPartLost(
   107     virtual void CounterPartLost(
   108         const MCatalogsSession& aSession );
   108         const MCatalogsSession& aSession );
   109     
   109     
   110 protected:
       
   111 
       
   112     class CNcdClientFavorites;
       
   113     class CNcdTemporaryFavorites;
       
   114     
       
   115     CNcdFavoriteManager( CNcdGeneralManager& aGeneralManager );
       
   116     
       
   117     void ConstructL();
       
   118     
       
   119     /**
       
   120      * Called from ReceiveMessage if favorite is added.
       
   121      */
       
   122     void AddFavoriteRequestL( MCatalogsBaseMessage& aMessage );
       
   123 
       
   124     /**
       
   125      * Called from ReceiveMessage if favorite is removed.
       
   126      */
       
   127     void RemoveFavoriteRequestL( MCatalogsBaseMessage& aMessage );
       
   128     
       
   129     /**
       
   130      * Called from ReceiveMessage if disclaimer need to be added or removed.
       
   131      */
       
   132     void SetDisclaimerRequestL( MCatalogsBaseMessage& aMessage );
       
   133     
       
   134     /**
       
   135      * Called from ReceiveMessage if disclaimer handle is requested.
       
   136      */
       
   137     void DisclaimerHandleRequestL( MCatalogsBaseMessage& aMessage );
       
   138     
       
   139     /**
       
   140      * Called from ReceiveMessage if proxy object wants to release the server side
       
   141      * object.
       
   142      */    
       
   143     void ReleaseRequest( MCatalogsBaseMessage& aMessage );
       
   144     
       
   145     /**
       
   146      * Called from ReceiveMessage if proxy object wants to internalize its state
       
   147      * from server side.
       
   148      */    
       
   149     void InternalizeRequestL( MCatalogsBaseMessage& aMessage );
       
   150     
       
   151     /**
       
   152      * Adds the given favorite node.
       
   153      *
       
   154      * @param aNodeIdentifier The identifier.
       
   155      */
       
   156     void AddFavoriteL( CNcdNodeIdentifier* aNodeIdentifier );
       
   157     
       
   158     /**
       
   159      * Adds the given favorite node temporarily. The node is removed from
       
   160      * favorites when the given session is closed.
       
   161      *
       
   162      * If the node is favorite node already, nothing is done.
       
   163      *
       
   164      * @param aNodeIdentifier The identifier.
       
   165      * @param aSession The session.
       
   166      */
       
   167     void AddTemporaryFavoriteL(
       
   168         CNcdNodeIdentifier* aNodeIdentifier,
       
   169         MCatalogsSession& aSession );
       
   170     
       
   171     /**
       
   172      * Removes the given favorite node.
       
   173      *
       
   174      * @param aNodeIdentifier The identifier.
       
   175      */
       
   176     void RemoveFavoriteL( CNcdNodeIdentifier* aNodeIdentifier );
       
   177     
       
   178     /**
       
   179      * Removes the temporary favorites of the given session.
       
   180      *
       
   181      * @param aSession The session.
       
   182      */
       
   183     void RemoveTemporaryFavoritesL( MCatalogsSession& aSession );
       
   184     
       
   185     /**
       
   186      * Externalizes the favorite identifiers of the given client to the given stream.
       
   187      *
       
   188      * @param aStream The stream.
       
   189      * @param aClientUid The client uid.
       
   190      */
       
   191     void ExternalizeIdentifiersL( RWriteStream& aStream, const TUid& aClientUid );
       
   192     
       
   193     /**
       
   194      * Finds the favorite node set of the given client.
       
   195      *
       
   196      * @param aClientUid The client uid.
       
   197      * @return Index of the set in iFavorites member variable or KErrNone if the
       
   198      *         client does not exist.
       
   199      */
       
   200     TInt FindClientFavorites( const TUid& aClientUid ) const;
       
   201     
       
   202     /**
       
   203      * Returns the temporary favorites of the given session. The given
       
   204      * object is created if there is no existing CNcdTemporaryFavorites object
       
   205      * for the given session.
       
   206      *
       
   207      * @param aSession The session.
       
   208      * @return The temporary favorites of the session.
       
   209      */
       
   210     CNcdTemporaryFavorites& TemporaryFavoritesL( MCatalogsSession& aSession );
       
   211     
       
   212     /**
       
   213      * Tells whether the given session has temporary favorites.
       
   214      *
       
   215      * @param aSession The session.
       
   216      * @return ETrue if there are temporary favorites, otherwise false.
       
   217      */
       
   218     TBool HasTemporaryFavorites( MCatalogsSession& aSession ) const;
       
   219     
       
   220     /**
       
   221      * Loads the client's favorite identifiers from database. If the database
       
   222      * does not contain any favorite identifiers, creates an empty identifier set
       
   223      * for the client to iFavorites member variable.
       
   224      *
       
   225      * @param aClientUid The client uid.
       
   226      */
       
   227     void DbLoadFavoritesL( const TUid& aClientUid );
       
   228     
       
   229     /**
       
   230      * Saves the given client's favorite identifiers to the database.
       
   231      *
       
   232      * @param aFavorites The favorites to save.
       
   233      */ 
       
   234     void DbSaveFavoritesL( CNcdClientFavorites& aFavorites );    
       
   235     
       
   236     
       
   237 private:
   110 private:
   238 
   111 
   239     /**
   112     /**
   240      * CNcdClientFavorites object encapsulates the favorite identifiers of one
   113      * CNcdClientFavorites object encapsulates the favorite identifiers of one
   241      * client.
   114      * client.
   315     // Temp favorite mappings.
   188     // Temp favorite mappings.
   316     RPointerArray<CNcdTemporaryFavorites> iTempFavorites;
   189     RPointerArray<CNcdTemporaryFavorites> iTempFavorites;
   317     
   190     
   318     // Storage manager.
   191     // Storage manager.
   319     MNcdStorageManager& iStorageManager;       
   192     MNcdStorageManager& iStorageManager;       
       
   193     
       
   194 protected:
       
   195 
       
   196     class CNcdTemporaryFavorites;
       
   197     
       
   198     CNcdFavoriteManager( CNcdGeneralManager& aGeneralManager );
       
   199     
       
   200     void ConstructL();
       
   201     
       
   202     /**
       
   203      * Called from ReceiveMessage if favorite is added.
       
   204      */
       
   205     void AddFavoriteRequestL( MCatalogsBaseMessage& aMessage );
       
   206 
       
   207     /**
       
   208      * Called from ReceiveMessage if favorite is removed.
       
   209      */
       
   210     void RemoveFavoriteRequestL( MCatalogsBaseMessage& aMessage );
       
   211     
       
   212     /**
       
   213      * Called from ReceiveMessage if disclaimer need to be added or removed.
       
   214      */
       
   215     void SetDisclaimerRequestL( MCatalogsBaseMessage& aMessage );
       
   216     
       
   217     /**
       
   218      * Called from ReceiveMessage if disclaimer handle is requested.
       
   219      */
       
   220     void DisclaimerHandleRequestL( MCatalogsBaseMessage& aMessage );
       
   221     
       
   222     /**
       
   223      * Called from ReceiveMessage if proxy object wants to release the server side
       
   224      * object.
       
   225      */    
       
   226     void ReleaseRequest( MCatalogsBaseMessage& aMessage );
       
   227     
       
   228     /**
       
   229      * Called from ReceiveMessage if proxy object wants to internalize its state
       
   230      * from server side.
       
   231      */    
       
   232     void InternalizeRequestL( MCatalogsBaseMessage& aMessage );
       
   233     
       
   234     /**
       
   235      * Adds the given favorite node.
       
   236      *
       
   237      * @param aNodeIdentifier The identifier.
       
   238      */
       
   239     void AddFavoriteL( CNcdNodeIdentifier* aNodeIdentifier );
       
   240     
       
   241     /**
       
   242      * Adds the given favorite node temporarily. The node is removed from
       
   243      * favorites when the given session is closed.
       
   244      *
       
   245      * If the node is favorite node already, nothing is done.
       
   246      *
       
   247      * @param aNodeIdentifier The identifier.
       
   248      * @param aSession The session.
       
   249      */
       
   250     void AddTemporaryFavoriteL(
       
   251         CNcdNodeIdentifier* aNodeIdentifier,
       
   252         MCatalogsSession& aSession );
       
   253     
       
   254     /**
       
   255      * Removes the given favorite node.
       
   256      *
       
   257      * @param aNodeIdentifier The identifier.
       
   258      */
       
   259     void RemoveFavoriteL( CNcdNodeIdentifier* aNodeIdentifier );
       
   260     
       
   261     /**
       
   262      * Removes the temporary favorites of the given session.
       
   263      *
       
   264      * @param aSession The session.
       
   265      */
       
   266     void RemoveTemporaryFavoritesL( MCatalogsSession& aSession );
       
   267     
       
   268     /**
       
   269      * Externalizes the favorite identifiers of the given client to the given stream.
       
   270      *
       
   271      * @param aStream The stream.
       
   272      * @param aClientUid The client uid.
       
   273      */
       
   274     void ExternalizeIdentifiersL( RWriteStream& aStream, const TUid& aClientUid );
       
   275     
       
   276     /**
       
   277      * Finds the favorite node set of the given client.
       
   278      *
       
   279      * @param aClientUid The client uid.
       
   280      * @return Index of the set in iFavorites member variable or KErrNone if the
       
   281      *         client does not exist.
       
   282      */
       
   283     TInt FindClientFavorites( const TUid& aClientUid ) const;
       
   284     
       
   285     /**
       
   286      * Returns the temporary favorites of the given session. The given
       
   287      * object is created if there is no existing CNcdTemporaryFavorites object
       
   288      * for the given session.
       
   289      *
       
   290      * @param aSession The session.
       
   291      * @return The temporary favorites of the session.
       
   292      */
       
   293     CNcdTemporaryFavorites& TemporaryFavoritesL( MCatalogsSession& aSession );
       
   294     
       
   295     /**
       
   296      * Tells whether the given session has temporary favorites.
       
   297      *
       
   298      * @param aSession The session.
       
   299      * @return ETrue if there are temporary favorites, otherwise false.
       
   300      */
       
   301     TBool HasTemporaryFavorites( MCatalogsSession& aSession ) const;
       
   302     
       
   303     /**
       
   304      * Loads the client's favorite identifiers from database. If the database
       
   305      * does not contain any favorite identifiers, creates an empty identifier set
       
   306      * for the client to iFavorites member variable.
       
   307      *
       
   308      * @param aClientUid The client uid.
       
   309      */
       
   310     void DbLoadFavoritesL( const TUid& aClientUid );
       
   311     
       
   312     /**
       
   313      * Saves the given client's favorite identifiers to the database.
       
   314      *
       
   315      * @param aFavorites The favorites to save.
       
   316      */ 
       
   317     void DbSaveFavoritesL( CNcdClientFavorites& aFavorites );    
       
   318     
       
   319     
   320 };
   320 };
   321 
   321 
   322 #endif
   322 #endif