ncdengine/provider/client/inc/ncdnodeproxy.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 CNcdNodeProxy class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NCD_NODE_PROXY_H
       
    20 #define NCD_NODE_PROXY_H
       
    21 
       
    22 
       
    23 // For streams
       
    24 #include <s32mem.h>
       
    25 
       
    26 #include "ncdinterfacebaseproxy.h"
       
    27 #include "ncdnode.h"
       
    28 #include "ncdloadnodeoperationobserver.h"
       
    29 #include "ncdnodechildoftransparent.h"
       
    30 #include "ncdnodefavorite.h"
       
    31 #include "catalogsarray.h"
       
    32 
       
    33 
       
    34 class CNcdNodeManagerProxy;
       
    35 class CNcdOperationManagerProxy;
       
    36 class MNcdOperation;
       
    37 class CNcdNodeIdentifier;
       
    38 class CNcdNodeMetadataProxy;
       
    39 class CNcdNodeUserDataProxy;
       
    40 class CNcdFavoriteManagerProxy;
       
    41 class CNcdNodeSeenProxy;
       
    42 
       
    43 
       
    44 /**
       
    45  * Base class for the proxies.
       
    46  * Provides basic methods for client server session function calls.
       
    47  *
       
    48  *  @lib ?library
       
    49  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    50  */
       
    51 class CNcdNodeProxy: public CNcdInterfaceBaseProxy,
       
    52                      public MNcdNode,
       
    53                      public MNcdLoadNodeOperationObserver,
       
    54                      public MNcdNodeChildOfTransparent,
       
    55                      public MNcdNodeFavorite
       
    56                      
       
    57     {
       
    58 
       
    59 public:
       
    60 
       
    61     /**
       
    62      * Destructor
       
    63      *
       
    64      * @note Usually Release function should be used instead of
       
    65      * directly calling delete for this class object.
       
    66      *
       
    67      * Informs the node manager that this node is deleted.
       
    68      */
       
    69     virtual ~CNcdNodeProxy();
       
    70 
       
    71 
       
    72     /**
       
    73      * @return CNcdNodeIdentifier& Identifier of this node.
       
    74      */
       
    75     CNcdNodeIdentifier& NodeIdentifier() const;
       
    76 
       
    77 
       
    78     /** 
       
    79      * @return CNcdNodeManagerProxy& Node manager may be used to get
       
    80      * or create nodes.
       
    81      */
       
    82     CNcdNodeManagerProxy& NodeManager() const;
       
    83 
       
    84 
       
    85     /** 
       
    86      * @return CNcdOperationManagerProxy& Operation manager may be used
       
    87      * to get or create operations.
       
    88      */
       
    89     CNcdOperationManagerProxy& OperationManager() const;
       
    90     
       
    91 
       
    92 
       
    93     // Getter functions to get the interface class objects.
       
    94     // These are provided here so the client side may use
       
    95     // all the functionality provided by the classes instead
       
    96     // of asking only API interfaces.
       
    97 
       
    98     /**
       
    99      * @return CNcdNodeMetadataProxy* Metadata object if it exists. 
       
   100      * NULL if the metadata has not been set. Ownership is not transferred.
       
   101      */
       
   102     CNcdNodeMetadataProxy* Metadata() const;
       
   103 
       
   104 
       
   105     /**
       
   106      * Calls all the internalization functions to set the data for the node.
       
   107      * If child classes have additional internalization functions, the child
       
   108      * should overload this function. So, all the functions will be called.
       
   109      * At least InternalizeNodeDataL is called to initialize this node.
       
   110      */ 
       
   111     virtual void InternalizeL();
       
   112     
       
   113     
       
   114     /**
       
   115      * Adds the node to favorite nodes. If the node is already
       
   116      * a favorite node, does nothing.
       
   117      *
       
   118      * @param aRemoveOnDisconnect If true, the node is removed from favorites when
       
   119      * client-server session is closed.
       
   120      * @exception Leave System wide error code 
       
   121      */    
       
   122     void AddToFavoritesL( TBool aRemoveOnDisconnect );
       
   123     
       
   124 
       
   125 public: // MNcdNode
       
   126 
       
   127     /**
       
   128      * @see MNcdNode::State
       
   129      */
       
   130     virtual TState State() const;
       
   131 
       
   132     
       
   133     /**
       
   134      * @see MNcdNode::Id
       
   135      */
       
   136     virtual const TDesC& Id() const;
       
   137 
       
   138 
       
   139     /**
       
   140      * @see MNcdNodeMetaData::Namespace
       
   141      */
       
   142     virtual const TDesC& Namespace() const;
       
   143 
       
   144 
       
   145     /**
       
   146      * @see MNcdNode::CatalogSourceName
       
   147      */
       
   148     virtual const TDesC& CatalogSourceName() const;
       
   149 
       
   150 
       
   151     /**
       
   152      * @see MNcdNode::ParentL
       
   153      */
       
   154     virtual MNcdNodeContainer* ParentL() const;
       
   155     
       
   156 
       
   157     /**
       
   158      * @see MNcdNode::LoadL
       
   159      */
       
   160     virtual MNcdLoadNodeOperation* LoadL( MNcdLoadNodeOperationObserver& aObserver );
       
   161 
       
   162 
       
   163     /**
       
   164      * @see MNcdNode::OperationsL
       
   165      */
       
   166     virtual RCatalogsArray< MNcdOperation > OperationsL() const;
       
   167 
       
   168 
       
   169     /**
       
   170      * @see MNcdNode::AddToFavoritesL
       
   171      */
       
   172     virtual void AddToFavoritesL();    
       
   173 
       
   174 
       
   175 public:// MNcdLoadNodeOperationObserver
       
   176 
       
   177     // This interface is used just to check when the load operation
       
   178     // is complete. So, the node may update its data from server side
       
   179     // by calling the internalize function.
       
   180     
       
   181     /**
       
   182      * @see MNcdLoadNodeOperationObserver::NodesUpdated
       
   183      */
       
   184     virtual void NodesUpdated( MNcdLoadNodeOperation& aOperation,
       
   185                                RCatalogsArray< MNcdNode >& aNodes );
       
   186     
       
   187     /**
       
   188      * @see MNcdLoadNodeOperationObserver::QueryReceived
       
   189      */
       
   190     virtual void QueryReceived( MNcdLoadNodeOperation& aOperation,
       
   191                                 MNcdQuery* aQuery );
       
   192 
       
   193     /**
       
   194      * @see MNcdLoadNodeOperationObserver::OperationComplete     
       
   195      */
       
   196     virtual void OperationComplete( MNcdLoadNodeOperation& aOperation,
       
   197                                     TInt aError );
       
   198                                     
       
   199 
       
   200 public: // MNcdNodeChildOfTransparent
       
   201     
       
   202     virtual MNcdNode* TransparentParentL() const;
       
   203     
       
   204     
       
   205 public: // MNcdNodeFavorite
       
   206 
       
   207     /**
       
   208      * @see MNcdNodeFavorite::RemoveFromFavoritesL.
       
   209      */
       
   210     virtual void RemoveFromFavoritesL();
       
   211                                
       
   212     /**
       
   213      * @see MNcdNodeFavorite::SetDisclaimerL.
       
   214      */
       
   215     virtual void SetDisclaimerL( MNcdNode* aDisclaimerOwner );
       
   216     
       
   217     /**
       
   218      * @see MNcdNodeFavorite::DisclaimerL.
       
   219      */
       
   220     virtual MNcdQuery* DisclaimerL() const;
       
   221     
       
   222     
       
   223 protected:
       
   224 
       
   225     /**
       
   226      * Constructor
       
   227      *
       
   228      * @param aSession The session between the client proxy and the
       
   229      * corresponding server object.
       
   230      * @param aHandle The handle which identifies the server object
       
   231      * that this proxy uses.
       
   232      * @param aNodeManager The manager that creates the nodes and keeps
       
   233      * track of the existing nodes.
       
   234      * @param aOperationManager This manager is used to create operations
       
   235      * for the node.     
       
   236      */
       
   237     CNcdNodeProxy( MCatalogsClientServer& aSession,
       
   238                    TInt aHandle, 
       
   239                    CNcdNodeManagerProxy& aNodeManager,
       
   240                    CNcdOperationManagerProxy& aOperationManager,
       
   241                    CNcdFavoriteManagerProxy& aFavoriteManager );
       
   242 
       
   243     /**
       
   244      * ConstructL
       
   245      */
       
   246     virtual void ConstructL( );
       
   247 
       
   248 
       
   249     /**
       
   250      * @exception ETrue if link handle exists. In other words
       
   251      * if this node can connect to the link data of the server side.
       
   252      * EFalse if the link handle is not set.
       
   253      */
       
   254     TBool LinkHandleSet() const;
       
   255     
       
   256 
       
   257     /**
       
   258      * @return TInt link handle.
       
   259      * @exception KErrNotReady if link does not exist
       
   260      */
       
   261     TInt LinkHandleL() const;
       
   262     
       
   263     /**
       
   264      * 
       
   265      */
       
   266     void SetLinkHandle( TInt aHandle );
       
   267 
       
   268 
       
   269     /**
       
   270      * @return TTime gives the time when this node expires.
       
   271      */
       
   272     TTime ExpiredTime() const;
       
   273     
       
   274     /**
       
   275      * @return CNcdNodeIdentifier* The parent identifier.
       
   276      * Ownership is not transferred.
       
   277      */
       
   278     CNcdNodeIdentifier* ParentIdentifier() const;
       
   279 
       
   280 
       
   281     /** 
       
   282      * @return TBool ETrue if the node is remote node (for example, if the
       
   283      * node is a catalog instead of normal folder). Else EFalse. 
       
   284      */
       
   285     TBool IsRemote() const;
       
   286     
       
   287 
       
   288     // These function are called to update proxy data by getting data
       
   289     // from the server side.
       
   290      
       
   291     /**
       
   292      * Internalizes the link data if it can be found from
       
   293      * the server side. Uses InternalizeNodeLinkDataL.
       
   294      */
       
   295     void InternalizeLinkL();
       
   296     
       
   297     
       
   298     // These functions are used to update the data of this class object
       
   299  
       
   300     /**
       
   301      * Initializes the node. At least identifier data should be set.
       
   302      * InternalizeL calls this function.
       
   303      *
       
   304      * @param aStream Contains data that is used to initialize the node.
       
   305      */
       
   306     virtual void InternalizeNodeDataL( RReadStream& aStream );
       
   307 
       
   308     /**
       
   309      * Initializes the node link data.
       
   310      * InternalizeL calls this function.
       
   311      *
       
   312      * @param aStream Contains data that is used to initialize 
       
   313      * the node link information.
       
   314      */
       
   315     virtual void InternalizeNodeLinkDataL( RReadStream& aStream );
       
   316 
       
   317 
       
   318     // These functions are used to update data of the class objects 
       
   319     // owned by this node.
       
   320     
       
   321     void InternalizeMetadataL();
       
   322     
       
   323     void InternalizeNodeSeenL(); 
       
   324 
       
   325 
       
   326 private:
       
   327     // Prevent if not implemented
       
   328     CNcdNodeProxy( const CNcdNodeProxy& aObject );
       
   329     CNcdNodeProxy& operator =( const CNcdNodeProxy& aObject );
       
   330             
       
   331 private: // data
       
   332 
       
   333     // Node manager is used to create the nodes. And it keeps track of
       
   334     // the existing nodes. Thus, when this node is ready to be destroyed, 
       
   335     // it should inform the manager about it. And, the manager may then
       
   336     // destroy this node proxy. This is done by checking the reference count
       
   337     // of the node when Release is called. When the reference count is one
       
   338     // after Release, the manager should be informed. The manager may
       
   339     // call the Release and this node is delete when reference count is zero. 
       
   340     //
       
   341     // Not owned
       
   342     CNcdNodeManagerProxy& iNodeManager;
       
   343     
       
   344     // Operation manager is used to create operations for this node.
       
   345     //
       
   346     // Not owned
       
   347     CNcdOperationManagerProxy& iOperationManager;
       
   348     
       
   349     // Favorite manager is used to add and remove nodes from favorite list.
       
   350     //
       
   351     // Not owned
       
   352     CNcdFavoriteManagerProxy& iFavoriteManager;
       
   353 
       
   354 
       
   355     CNcdNodeIdentifier* iNodeIdentifier;
       
   356 
       
   357     // This is the parent shown in UI.
       
   358     CNcdNodeIdentifier* iParentIdentifier;
       
   359     
       
   360     // This is the real parent in engine (may be transparent folder).
       
   361     CNcdNodeIdentifier* iRealParentIdentifier;
       
   362 
       
   363     // This flag informs if the node is originally a remote node.
       
   364     // For example if the node were a catalog instead of a normal node, the
       
   365     // flag would be ETrue.
       
   366     TBool iRemoteFlag;    
       
   367 
       
   368 
       
   369     // MNceNode data
       
   370     
       
   371     HBufC* iTimestamp;
       
   372     HBufC* iCatalogSourceName;
       
   373     TTime iExpiredTime;
       
   374 
       
   375     TInt iLinkHandle;
       
   376     TBool iLinkHandleSet;
       
   377         
       
   378     // These are the possible additional interface objects that this node
       
   379     // may use. If the pointer value is NULL then the node does not provide
       
   380     // functionality for that interface at that moment. Mainly these objects
       
   381     // are created after certain operations have been done for the node.
       
   382 
       
   383     // Node metadata
       
   384     CNcdNodeMetadataProxy* iMetadata;
       
   385     
       
   386     // Node seen
       
   387     CNcdNodeSeenProxy* iNodeSeen;
       
   388 
       
   389     };
       
   390 
       
   391 
       
   392 #endif // NCD_NODE_PROXY_H